Skip to content

Commit af737b4

Browse files
mchehabmasahir0y
authored andcommitted
kconfig: qconf: simplify the goBack() logic
The goBack() logic is used only for the configList, as it only makes sense on singleMode. So, let's simplify the code. Signed-off-by: Mauro Carvalho Chehab <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent b06c3ec commit af737b4

File tree

1 file changed

+17
-31
lines changed

1 file changed

+17
-31
lines changed

scripts/kconfig/qconf.cc

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,18 +1455,22 @@ ConfigMainWindow::ConfigMainWindow(void)
14551455
addToolBar(toolBar);
14561456

14571457
backAction = new QAction(QPixmap(xpm_back), "Back", this);
1458-
connect(backAction, SIGNAL(triggered(bool)), SLOT(goBack()));
1459-
backAction->setEnabled(false);
1458+
connect(backAction, SIGNAL(triggered(bool)), SLOT(goBack()));
1459+
14601460
QAction *quitAction = new QAction("&Quit", this);
14611461
quitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
1462-
connect(quitAction, SIGNAL(triggered(bool)), SLOT(close()));
1462+
connect(quitAction, SIGNAL(triggered(bool)), SLOT(close()));
1463+
14631464
QAction *loadAction = new QAction(QPixmap(xpm_load), "&Load", this);
14641465
loadAction->setShortcut(Qt::CTRL + Qt::Key_L);
1465-
connect(loadAction, SIGNAL(triggered(bool)), SLOT(loadConfig()));
1466+
connect(loadAction, SIGNAL(triggered(bool)), SLOT(loadConfig()));
1467+
14661468
saveAction = new QAction(QPixmap(xpm_save), "&Save", this);
14671469
saveAction->setShortcut(Qt::CTRL + Qt::Key_S);
1468-
connect(saveAction, SIGNAL(triggered(bool)), SLOT(saveConfig()));
1470+
connect(saveAction, SIGNAL(triggered(bool)), SLOT(saveConfig()));
1471+
14691472
conf_set_changed_callback(conf_changed);
1473+
14701474
// Set saveAction's initial state
14711475
conf_changed();
14721476
configname = xstrdup(conf_get_configname());
@@ -1667,21 +1671,11 @@ void ConfigMainWindow::searchConfig(void)
16671671
void ConfigMainWindow::changeItens(struct menu *menu)
16681672
{
16691673
configList->setRootMenu(menu);
1670-
1671-
if (configList->rootEntry->parent == &rootmenu)
1672-
backAction->setEnabled(false);
1673-
else
1674-
backAction->setEnabled(true);
16751674
}
16761675

16771676
void ConfigMainWindow::changeMenu(struct menu *menu)
16781677
{
16791678
menuList->setRootMenu(menu);
1680-
1681-
if (menuList->rootEntry->parent == &rootmenu)
1682-
backAction->setEnabled(false);
1683-
else
1684-
backAction->setEnabled(true);
16851679
}
16861680

16871681
void ConfigMainWindow::setMenuLink(struct menu *menu)
@@ -1748,25 +1742,11 @@ void ConfigMainWindow::listFocusChanged(void)
17481742

17491743
void ConfigMainWindow::goBack(void)
17501744
{
1751-
ConfigItem* item, *oldSelection;
1752-
1753-
configList->setParentMenu();
1745+
qInfo() << __FUNCTION__;
17541746
if (configList->rootEntry == &rootmenu)
1755-
backAction->setEnabled(false);
1756-
1757-
if (menuList->selectedItems().count() == 0)
17581747
return;
17591748

1760-
item = (ConfigItem*)menuList->selectedItems().first();
1761-
oldSelection = item;
1762-
while (item) {
1763-
if (item->menu == configList->rootEntry) {
1764-
oldSelection->setSelected(false);
1765-
item->setSelected(true);
1766-
break;
1767-
}
1768-
item = (ConfigItem*)item->parent();
1769-
}
1749+
configList->setParentMenu();
17701750
}
17711751

17721752
void ConfigMainWindow::showSingleView(void)
@@ -1778,6 +1758,8 @@ void ConfigMainWindow::showSingleView(void)
17781758
fullViewAction->setEnabled(true);
17791759
fullViewAction->setChecked(false);
17801760

1761+
backAction->setEnabled(true);
1762+
17811763
menuView->hide();
17821764
menuList->setRootMenu(0);
17831765
configList->mode = singleMode;
@@ -1797,6 +1779,8 @@ void ConfigMainWindow::showSplitView(void)
17971779
fullViewAction->setEnabled(true);
17981780
fullViewAction->setChecked(false);
17991781

1782+
backAction->setEnabled(false);
1783+
18001784
configList->mode = menuMode;
18011785
if (configList->rootEntry == &rootmenu)
18021786
configList->updateListAll();
@@ -1820,6 +1804,8 @@ void ConfigMainWindow::showFullView(void)
18201804
fullViewAction->setEnabled(false);
18211805
fullViewAction->setChecked(true);
18221806

1807+
backAction->setEnabled(false);
1808+
18231809
menuView->hide();
18241810
menuList->setRootMenu(0);
18251811
configList->mode = fullMode;

0 commit comments

Comments
 (0)