Mercurial > octave
comparison libgui/src/resource-manager.cc @ 31620:6dfaaf8ecf3b
use gui_settings to store icon fallbacks
* gui-preferences-global.h (global_icon_fallbacks): New gui_pref.
* resource-manager.cc, resource-manager.h
(resource_manager::m_icon_fallbacks): Delete member variable.
(resource_manager::config_icon_theme, resource_manager::icon):
Use gui_settings to store icon fallback themes.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 02 Dec 2022 18:31:30 -0500 |
parents | ad014fc78bd6 |
children | 0645ea65ca6b |
comparison
equal
deleted
inserted
replaced
31619:ad014fc78bd6 | 31620:6dfaaf8ecf3b |
---|---|
62 #include "help.h" | 62 #include "help.h" |
63 | 63 |
64 namespace octave | 64 namespace octave |
65 { | 65 { |
66 resource_manager::resource_manager (void) | 66 resource_manager::resource_manager (void) |
67 : m_settings_directory (), m_settings_file (), | 67 : m_settings_directory (), m_settings_file (), m_temporary_files () |
68 m_temporary_files (), m_icon_fallbacks () | |
69 { | 68 { |
70 // Location, name, and format of settings file determined by | 69 // Location, name, and format of settings file determined by |
71 // settings in qt_application class construtor. | 70 // settings in qt_application class construtor. |
72 | 71 |
73 check_settings (); | 72 check_settings (); |
140 | 139 |
141 } | 140 } |
142 | 141 |
143 void resource_manager::config_icon_theme (void) | 142 void resource_manager::config_icon_theme (void) |
144 { | 143 { |
145 m_icon_fallbacks.clear (); | |
146 | |
147 int theme = global_icon_theme_index.def.toInt (); | 144 int theme = global_icon_theme_index.def.toInt (); |
148 | 145 |
149 gui_settings settings; | 146 gui_settings settings; |
150 | 147 |
151 // check for new and old setting and use old if required | 148 // check for new and old setting and use old if required |
160 settings.remove (global_icon_theme.key); // remove deprecated key | 157 settings.remove (global_icon_theme.key); // remove deprecated key |
161 } | 158 } |
162 | 159 |
163 QIcon::setThemeName (global_all_icon_themes.at (theme)); | 160 QIcon::setThemeName (global_all_icon_themes.at (theme)); |
164 | 161 |
162 QStringList icon_fallbacks; | |
163 | |
165 // set the required fallback search paths | 164 // set the required fallback search paths |
166 switch (theme) | 165 switch (theme) |
167 { | 166 { |
168 case ICON_THEME_SYSTEM: | 167 case ICON_THEME_SYSTEM: |
169 m_icon_fallbacks << global_icon_paths.at (ICON_THEME_OCTAVE); | 168 icon_fallbacks << global_icon_paths.at (ICON_THEME_OCTAVE); |
170 m_icon_fallbacks << global_icon_paths.at (ICON_THEME_TANGO); | 169 icon_fallbacks << global_icon_paths.at (ICON_THEME_TANGO); |
171 break; | 170 break; |
172 case ICON_THEME_TANGO: | 171 case ICON_THEME_TANGO: |
173 m_icon_fallbacks << global_icon_paths.at (ICON_THEME_OCTAVE); | 172 icon_fallbacks << global_icon_paths.at (ICON_THEME_OCTAVE); |
174 break; | 173 break; |
175 case ICON_THEME_OCTAVE: | 174 case ICON_THEME_OCTAVE: |
176 m_icon_fallbacks << global_icon_paths.at (ICON_THEME_TANGO); | 175 icon_fallbacks << global_icon_paths.at (ICON_THEME_TANGO); |
177 break; | 176 break; |
178 } | 177 } |
179 | 178 |
180 m_icon_fallbacks << global_icon_paths.at (ICON_THEME_CURSORS); | 179 icon_fallbacks << global_icon_paths.at (ICON_THEME_CURSORS); |
180 | |
181 settings.setValue (global_icon_fallbacks.key, icon_fallbacks); | |
181 } | 182 } |
182 | 183 |
183 QString resource_manager::get_settings_directory (void) | 184 QString resource_manager::get_settings_directory (void) |
184 { | 185 { |
185 return m_settings_directory; | 186 return m_settings_directory; |
576 if (QIcon::hasThemeIcon (icon_name)) | 577 if (QIcon::hasThemeIcon (icon_name)) |
577 return QIcon (QIcon::fromTheme (icon_name)); | 578 return QIcon (QIcon::fromTheme (icon_name)); |
578 else if ((! icon_alt_name.isEmpty ()) && QIcon::hasThemeIcon (icon_alt_name)) | 579 else if ((! icon_alt_name.isEmpty ()) && QIcon::hasThemeIcon (icon_alt_name)) |
579 return QIcon (QIcon::fromTheme (icon_alt_name)); | 580 return QIcon (QIcon::fromTheme (icon_alt_name)); |
580 | 581 |
581 for (int i = 0; i < m_icon_fallbacks.length (); i++ ) | 582 gui_settings settings; |
582 { | 583 |
583 QString icon_file (m_icon_fallbacks.at (i) + icon_name + ".png"); | 584 QStringList icon_fallbacks |
585 = settings.value (global_icon_fallbacks.key).toStringList (); | |
586 | |
587 for (int i = 0; i < icon_fallbacks.length (); i++ ) | |
588 { | |
589 QString icon_file (icon_fallbacks.at (i) + icon_name + ".png"); | |
584 if (QFile (icon_file).exists ()) | 590 if (QFile (icon_file).exists ()) |
585 return QIcon (icon_file); | 591 return QIcon (icon_file); |
586 } | 592 } |
587 | 593 |
588 //QIcon::setThemeName (current_theme); | 594 //QIcon::setThemeName (current_theme); |