Commit 39a4897c authored by Li Zefan's avatar Li Zefan Committed by Michal Marek

xconfig: add support to show hidden options which have prompts

This feature has been supported in menuconfig and gconfig, so
here add it to xconfig.
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Signed-off-by: default avatarMichal Marek <mmarek@suse.cz>
parent 120d63e6
...@@ -148,7 +148,7 @@ void ConfigItem::updateMenu(void) ...@@ -148,7 +148,7 @@ void ConfigItem::updateMenu(void)
case S_TRISTATE: case S_TRISTATE:
char ch; char ch;
if (!sym_is_changable(sym) && !list->showAll) { if (!sym_is_changable(sym) && list->optMode == normalOpt) {
setPixmap(promptColIdx, 0); setPixmap(promptColIdx, 0);
setText(noColIdx, QString::null); setText(noColIdx, QString::null);
setText(modColIdx, QString::null); setText(modColIdx, QString::null);
...@@ -319,7 +319,7 @@ ConfigList::ConfigList(ConfigView* p, const char *name) ...@@ -319,7 +319,7 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no),
choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no),
menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void),
showAll(false), showName(false), showRange(false), showData(false), showName(false), showRange(false), showData(false), optMode(normalOpt),
rootEntry(0), headerPopup(0) rootEntry(0), headerPopup(0)
{ {
int i; int i;
...@@ -336,10 +336,10 @@ ConfigList::ConfigList(ConfigView* p, const char *name) ...@@ -336,10 +336,10 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
if (name) { if (name) {
configSettings->beginGroup(name); configSettings->beginGroup(name);
showAll = configSettings->readBoolEntry("/showAll", false);
showName = configSettings->readBoolEntry("/showName", false); showName = configSettings->readBoolEntry("/showName", false);
showRange = configSettings->readBoolEntry("/showRange", false); showRange = configSettings->readBoolEntry("/showRange", false);
showData = configSettings->readBoolEntry("/showData", false); showData = configSettings->readBoolEntry("/showData", false);
optMode = (enum optionMode)configSettings->readNumEntry("/optionMode", false);
configSettings->endGroup(); configSettings->endGroup();
connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));
} }
...@@ -351,6 +351,17 @@ ConfigList::ConfigList(ConfigView* p, const char *name) ...@@ -351,6 +351,17 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
reinit(); reinit();
} }
bool ConfigList::menuSkip(struct menu *menu)
{
if (optMode == normalOpt && menu_is_visible(menu))
return false;
if (optMode == promptOpt && menu_has_prompt(menu))
return false;
if (optMode == allOpt)
return false;
return true;
}
void ConfigList::reinit(void) void ConfigList::reinit(void)
{ {
removeColumn(dataColIdx); removeColumn(dataColIdx);
...@@ -379,7 +390,7 @@ void ConfigList::saveSettings(void) ...@@ -379,7 +390,7 @@ void ConfigList::saveSettings(void)
configSettings->writeEntry("/showName", showName); configSettings->writeEntry("/showName", showName);
configSettings->writeEntry("/showRange", showRange); configSettings->writeEntry("/showRange", showRange);
configSettings->writeEntry("/showData", showData); configSettings->writeEntry("/showData", showData);
configSettings->writeEntry("/showAll", showAll); configSettings->writeEntry("/optionMode", (int)optMode);
configSettings->endGroup(); configSettings->endGroup();
} }
} }
...@@ -605,7 +616,7 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu) ...@@ -605,7 +616,7 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu)
} }
visible = menu_is_visible(child); visible = menu_is_visible(child);
if (showAll || visible) { if (!menuSkip(child)) {
if (!child->sym && !child->list && !child->prompt) if (!child->sym && !child->list && !child->prompt)
continue; continue;
if (!item || item->menu != child) if (!item || item->menu != child)
...@@ -834,7 +845,10 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e) ...@@ -834,7 +845,10 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
e->ignore(); e->ignore();
} }
ConfigView* ConfigView::viewList; ConfigView*ConfigView::viewList;
QAction *ConfigView::showNormalAction;
QAction *ConfigView::showAllAction;
QAction *ConfigView::showPromptAction;
ConfigView::ConfigView(QWidget* parent, const char *name) ConfigView::ConfigView(QWidget* parent, const char *name)
: Parent(parent, name) : Parent(parent, name)
...@@ -859,13 +873,16 @@ ConfigView::~ConfigView(void) ...@@ -859,13 +873,16 @@ ConfigView::~ConfigView(void)
} }
} }
void ConfigView::setShowAll(bool b) void ConfigView::setOptionMode(QAction *act)
{ {
if (list->showAll != b) { if (act == showNormalAction)
list->showAll = b; list->optMode = normalOpt;
list->updateListAll(); else if (act == showAllAction)
emit showAllChanged(b); list->optMode = allOpt;
} else
list->optMode = promptOpt;
list->updateListAll();
} }
void ConfigView::setShowName(bool b) void ConfigView::setShowName(bool b)
...@@ -1320,11 +1337,24 @@ ConfigMainWindow::ConfigMainWindow(void) ...@@ -1320,11 +1337,24 @@ ConfigMainWindow::ConfigMainWindow(void)
connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool)));
connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool))); connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool)));
showDataAction->setOn(configList->showData); showDataAction->setOn(configList->showData);
QAction *showAllAction = new QAction(NULL, _("Show All Options"), 0, this);
showAllAction->setToggleAction(TRUE); QActionGroup *optGroup = new QActionGroup(this);
connect(showAllAction, SIGNAL(toggled(bool)), configView, SLOT(setShowAll(bool))); optGroup->setExclusive(TRUE);
connect(showAllAction, SIGNAL(toggled(bool)), menuView, SLOT(setShowAll(bool))); connect(optGroup, SIGNAL(selected(QAction *)), configView,
showAllAction->setOn(configList->showAll); SLOT(setOptionMode(QAction *)));
connect(optGroup, SIGNAL(selected(QAction *)), menuView,
SLOT(setOptionMode(QAction *)));
configView->showNormalAction = new QAction(NULL, _("Show Normal Options"), 0, optGroup);
configView->showAllAction = new QAction(NULL, _("Show All Options"), 0, optGroup);
configView->showPromptAction = new QAction(NULL, _("Show Prompt Options"), 0, optGroup);
configView->showNormalAction->setToggleAction(TRUE);
configView->showNormalAction->setOn(configList->optMode == normalOpt);
configView->showAllAction->setToggleAction(TRUE);
configView->showAllAction->setOn(configList->optMode == allOpt);
configView->showPromptAction->setToggleAction(TRUE);
configView->showPromptAction->setOn(configList->optMode == promptOpt);
QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this); QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this);
showDebugAction->setToggleAction(TRUE); showDebugAction->setToggleAction(TRUE);
connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool))); connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool)));
...@@ -1367,7 +1397,8 @@ ConfigMainWindow::ConfigMainWindow(void) ...@@ -1367,7 +1397,8 @@ ConfigMainWindow::ConfigMainWindow(void)
showRangeAction->addTo(optionMenu); showRangeAction->addTo(optionMenu);
showDataAction->addTo(optionMenu); showDataAction->addTo(optionMenu);
optionMenu->insertSeparator(); optionMenu->insertSeparator();
showAllAction->addTo(optionMenu); optGroup->addTo(optionMenu);
optionMenu->insertSeparator();
showDebugAction->addTo(optionMenu); showDebugAction->addTo(optionMenu);
// create help menu // create help menu
...@@ -1462,7 +1493,7 @@ void ConfigMainWindow::setMenuLink(struct menu *menu) ...@@ -1462,7 +1493,7 @@ void ConfigMainWindow::setMenuLink(struct menu *menu)
ConfigList* list = NULL; ConfigList* list = NULL;
ConfigItem* item; ConfigItem* item;
if (!menu_is_visible(menu) && !configView->showAll()) if (configList->menuSkip(menu))
return; return;
switch (configList->mode) { switch (configList->mode) {
......
...@@ -44,6 +44,9 @@ enum colIdx { ...@@ -44,6 +44,9 @@ enum colIdx {
enum listMode { enum listMode {
singleMode, menuMode, symbolMode, fullMode, listMode singleMode, menuMode, symbolMode, fullMode, listMode
}; };
enum optionMode {
normalOpt = 0, allOpt, promptOpt
};
class ConfigList : public QListView { class ConfigList : public QListView {
Q_OBJECT Q_OBJECT
...@@ -115,6 +118,8 @@ public slots: ...@@ -115,6 +118,8 @@ public slots:
void setAllOpen(bool open); void setAllOpen(bool open);
void setParentMenu(void); void setParentMenu(void);
bool menuSkip(struct menu *);
template <class P> template <class P>
void updateMenuList(P*, struct menu*); void updateMenuList(P*, struct menu*);
...@@ -124,8 +129,9 @@ public slots: ...@@ -124,8 +129,9 @@ public slots:
QPixmap choiceYesPix, choiceNoPix; QPixmap choiceYesPix, choiceNoPix;
QPixmap menuPix, menuInvPix, menuBackPix, voidPix; QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
bool showAll, showName, showRange, showData; bool showName, showRange, showData;
enum listMode mode; enum listMode mode;
enum optionMode optMode;
struct menu *rootEntry; struct menu *rootEntry;
QColorGroup disabledColorGroup; QColorGroup disabledColorGroup;
QColorGroup inactivedColorGroup; QColorGroup inactivedColorGroup;
...@@ -222,17 +228,15 @@ class ConfigView : public QVBox { ...@@ -222,17 +228,15 @@ class ConfigView : public QVBox {
static void updateList(ConfigItem* item); static void updateList(ConfigItem* item);
static void updateListAll(void); static void updateListAll(void);
bool showAll(void) const { return list->showAll; }
bool showName(void) const { return list->showName; } bool showName(void) const { return list->showName; }
bool showRange(void) const { return list->showRange; } bool showRange(void) const { return list->showRange; }
bool showData(void) const { return list->showData; } bool showData(void) const { return list->showData; }
public slots: public slots:
void setShowAll(bool);
void setShowName(bool); void setShowName(bool);
void setShowRange(bool); void setShowRange(bool);
void setShowData(bool); void setShowData(bool);
void setOptionMode(QAction *);
signals: signals:
void showAllChanged(bool);
void showNameChanged(bool); void showNameChanged(bool);
void showRangeChanged(bool); void showRangeChanged(bool);
void showDataChanged(bool); void showDataChanged(bool);
...@@ -242,6 +246,10 @@ public slots: ...@@ -242,6 +246,10 @@ public slots:
static ConfigView* viewList; static ConfigView* viewList;
ConfigView* nextView; ConfigView* nextView;
static QAction *showNormalAction;
static QAction *showAllAction;
static QAction *showPromptAction;
}; };
class ConfigInfoView : public QTextBrowser { class ConfigInfoView : public QTextBrowser {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment