@@ -81,7 +81,7 @@ void MainDialog::activate()
81
81
ui->dropShadows ->setCurrentIndex (xml_get_bool_text (" /labwc_config/theme/dropShadows" ));
82
82
83
83
/* Icon Theme */
84
- QStringList themes = findIconThemes ();
84
+ QStringList themes = findIconThemes (LAB_ICON_THEME_TYPE_ICON );
85
85
ui->iconTheme ->addItems (themes);
86
86
ui->iconTheme ->setCurrentIndex (themes.indexOf (xml_get (" /labwc_config/theme/icon" )));
87
87
@@ -104,22 +104,9 @@ void MainDialog::activate()
104
104
/* # MOUSE & TOUCHPAD */
105
105
106
106
/* Cursor Theme */
107
- struct themes cursor_themes = { 0 };
108
- theme_find (&cursor_themes, " icons" , " cursors" );
109
-
110
- active_id = getenv (" XCURSOR_THEME" ) ?: (char *)" " ;
111
- active = -1 ;
112
- for (int i = 0 ; i < cursor_themes.nr ; ++i) {
113
- struct theme *theme = cursor_themes.data + i;
114
- if (!strcmp (theme->name , active_id)) {
115
- active = i;
116
- }
117
- ui->cursorTheme ->addItem (theme->name );
118
- }
119
- if (active != -1 ) {
120
- ui->cursorTheme ->setCurrentIndex (active);
121
- }
122
- theme_free_vector (&cursor_themes);
107
+ QStringList cursorThemes = findIconThemes (LAB_ICON_THEME_TYPE_CURSOR);
108
+ ui->cursorTheme ->addItems (cursorThemes);
109
+ ui->cursorTheme ->setCurrentIndex (cursorThemes.indexOf (getenv (" XCURSOR_THEME" ) ?: (char *)" " ));
123
110
124
111
/* Cursor Size */
125
112
ui->cursorSize ->setValue (atoi (getenv (" XCURSOR_SIZE" ) ?: " 24" ));
@@ -263,7 +250,13 @@ bool hasOnlyCursorSubdir(QString path)
263
250
return entries.contains (" cursors" ) && entries.length () == 1 ;
264
251
}
265
252
266
- QStringList MainDialog::findIconThemes (void )
253
+ bool hasCursorSubdir (QString path)
254
+ {
255
+ QStringList entries = QDir (path).entryList (QDir::Dirs | QDir::NoDotAndDotDot);
256
+ return entries.contains (" cursors" );
257
+ }
258
+
259
+ QStringList MainDialog::findIconThemes (enum lab_icon_theme_type type)
267
260
{
268
261
QStringList paths;
269
262
@@ -286,10 +279,21 @@ QStringList MainDialog::findIconThemes(void)
286
279
QDir dir (path);
287
280
QStringList entries = dir.entryList (QDir::Dirs | QDir::NoDotAndDotDot);
288
281
for (const QString &entry : std::as_const (entries)) {
289
- if (hasOnlyCursorSubdir (QString (path + " /" + entry))) {
290
- continue ;
282
+ switch (type) {
283
+ case LAB_ICON_THEME_TYPE_ICON:
284
+ if (hasOnlyCursorSubdir (QString (path + " /" + entry))) {
285
+ continue ;
286
+ }
287
+ themes.push_back (entry);
288
+ break ;
289
+ case LAB_ICON_THEME_TYPE_CURSOR:
290
+ if (hasCursorSubdir (QString (path + " /" + entry))) {
291
+ themes.push_back (entry);
292
+ }
293
+ break ;
294
+ default :
295
+ break ;
291
296
}
292
- themes.push_back (entry);
293
297
}
294
298
}
295
299
themes.removeDuplicates ();
0 commit comments