Skip to content

Commit 5cb255f

Browse files
committed
kconfig: qconf: refactor icon setups
These icon data are used by ConfigItem, but stored in each instance of ConfigView. There is no point to keep the same data in each of 3 instances, "menu", "config", and "search". Move the icon data to the more relevant ConfigItem class, and make them static members. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 4fa91f5 commit 5cb255f

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

scripts/kconfig/qconf.cc

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ bool ConfigSettings::writeSizes(const QString& key, const QList<int>& value)
7474
return true;
7575
}
7676

77+
QIcon ConfigItem::symbolYesIcon;
78+
QIcon ConfigItem::symbolModIcon;
79+
QIcon ConfigItem::symbolNoIcon;
80+
QIcon ConfigItem::choiceYesIcon;
81+
QIcon ConfigItem::choiceNoIcon;
82+
QIcon ConfigItem::menuIcon;
83+
QIcon ConfigItem::menubackIcon;
7784

7885
/*
7986
* set the new data
@@ -97,7 +104,7 @@ void ConfigItem::updateMenu(void)
97104

98105
list = listView();
99106
if (goParent) {
100-
setIcon(promptColIdx, list->menuBackPix);
107+
setIcon(promptColIdx, menubackIcon);
101108
prompt = "..";
102109
goto set_prompt;
103110
}
@@ -114,7 +121,7 @@ void ConfigItem::updateMenu(void)
114121
*/
115122
if (sym && list->rootEntry == menu)
116123
break;
117-
setIcon(promptColIdx, list->menuPix);
124+
setIcon(promptColIdx, menuIcon);
118125
} else {
119126
if (sym)
120127
break;
@@ -149,22 +156,22 @@ void ConfigItem::updateMenu(void)
149156
switch (expr) {
150157
case yes:
151158
if (sym_is_choice_value(sym) && type == S_BOOLEAN)
152-
setIcon(promptColIdx, list->choiceYesPix);
159+
setIcon(promptColIdx, choiceYesIcon);
153160
else
154-
setIcon(promptColIdx, list->symbolYesPix);
161+
setIcon(promptColIdx, symbolYesIcon);
155162
setText(yesColIdx, "Y");
156163
ch = 'Y';
157164
break;
158165
case mod:
159-
setIcon(promptColIdx, list->symbolModPix);
166+
setIcon(promptColIdx, symbolModIcon);
160167
setText(modColIdx, "M");
161168
ch = 'M';
162169
break;
163170
default:
164171
if (sym_is_choice_value(sym) && type == S_BOOLEAN)
165-
setIcon(promptColIdx, list->choiceNoPix);
172+
setIcon(promptColIdx, choiceNoIcon);
166173
else
167-
setIcon(promptColIdx, list->symbolNoPix);
174+
setIcon(promptColIdx, symbolNoIcon);
168175
setText(noColIdx, "N");
169176
ch = 'N';
170177
break;
@@ -289,9 +296,6 @@ void ConfigLineEdit::keyPressEvent(QKeyEvent* e)
289296
ConfigList::ConfigList(ConfigView* p, const char *name)
290297
: Parent(p),
291298
updateAll(false),
292-
symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no),
293-
choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no),
294-
menuPix(xpm_menu), menuBackPix(xpm_menuback),
295299
showName(false), showRange(false), showData(false), mode(singleMode), optMode(normalOpt),
296300
rootEntry(0), headerPopup(0)
297301
{
@@ -1396,6 +1400,15 @@ ConfigMainWindow::ConfigMainWindow(void)
13961400
if ((x.isValid())&&(y.isValid()))
13971401
move(x.toInt(), y.toInt());
13981402

1403+
// set up icons
1404+
ConfigItem::symbolYesIcon = QIcon(QPixmap(xpm_symbol_yes));
1405+
ConfigItem::symbolModIcon = QIcon(QPixmap(xpm_symbol_mod));
1406+
ConfigItem::symbolNoIcon = QIcon(QPixmap(xpm_symbol_no));
1407+
ConfigItem::choiceYesIcon = QIcon(QPixmap(xpm_choice_yes));
1408+
ConfigItem::choiceNoIcon = QIcon(QPixmap(xpm_choice_no));
1409+
ConfigItem::menuIcon = QIcon(QPixmap(xpm_menu));
1410+
ConfigItem::menubackIcon = QIcon(QPixmap(xpm_menuback));
1411+
13991412
QWidget *widget = new QWidget(this);
14001413
QVBoxLayout *layout = new QVBoxLayout(widget);
14011414
setCentralWidget(widget);

scripts/kconfig/qconf.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,6 @@ public slots:
9898

9999
bool updateAll;
100100

101-
QPixmap symbolYesPix, symbolModPix, symbolNoPix;
102-
QPixmap choiceYesPix, choiceNoPix;
103-
QPixmap menuPix, menuBackPix;
104-
105101
bool showName, showRange, showData;
106102
enum listMode mode;
107103
enum optionMode optMode;
@@ -162,6 +158,10 @@ class ConfigItem : public QTreeWidgetItem {
162158
struct menu *menu;
163159
bool visible;
164160
bool goParent;
161+
162+
static QIcon symbolYesIcon, symbolModIcon, symbolNoIcon;
163+
static QIcon choiceYesIcon, choiceNoIcon;
164+
static QIcon menuIcon, menubackIcon;
165165
};
166166

167167
class ConfigLineEdit : public QLineEdit {

0 commit comments

Comments
 (0)