From c5147040d544c8735f064fe34caa053062211f61 Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Tue, 6 Sep 2016 10:28:31 -0400 Subject: Make sure that going "back" to the main page automatically exapands/highlights the page that the user was just on. --- src-qt5/core-utils/lumina-config/mainWindow.cpp | 4 ++- .../core-utils/lumina-config/pages/PageWidget.h | 2 +- src-qt5/core-utils/lumina-config/pages/getPage.h | 29 ++++++++++++---------- .../core-utils/lumina-config/pages/page_main.cpp | 13 ++++++++++ src-qt5/core-utils/lumina-config/pages/page_main.h | 2 ++ 5 files changed, 35 insertions(+), 15 deletions(-) (limited to 'src-qt5/core-utils/lumina-config') diff --git a/src-qt5/core-utils/lumina-config/mainWindow.cpp b/src-qt5/core-utils/lumina-config/mainWindow.cpp index 0bb3cbf0..5f465199 100644 --- a/src-qt5/core-utils/lumina-config/mainWindow.cpp +++ b/src-qt5/core-utils/lumina-config/mainWindow.cpp @@ -72,7 +72,8 @@ void mainWindow::loadMonitors(){ //============= void mainWindow::changePage(QString id){ PageWidget *page = 0; - if(id!=cpage){ + QString oldpage = this->centralWidget()->whatsThis(); + if(id!=cpage || cpage!=oldpage){ page = GetNewPage(id, this); if(page==0){ return; } qDebug() << "Changing page:" << id; @@ -93,6 +94,7 @@ void mainWindow::changePage(QString id){ } //Now load the new page page->LoadSettings(ui->actionMonitor->whatsThis().toInt()); //need to make this show the current screen as needed + page->setPreviousPage(oldpage); //Now update this UI a bit based on page settings ui->actionMonitor->setVisible( page->needsScreenSelector() && ui->actionMonitor->menu()->actions().length()>1 ); diff --git a/src-qt5/core-utils/lumina-config/pages/PageWidget.h b/src-qt5/core-utils/lumina-config/pages/PageWidget.h index 66fce36a..81ebe0cc 100644 --- a/src-qt5/core-utils/lumina-config/pages/PageWidget.h +++ b/src-qt5/core-utils/lumina-config/pages/PageWidget.h @@ -34,7 +34,7 @@ public: ~PageWidget(){} virtual bool needsScreenSelector(){ return false; } //change this to true for pages which load/set options on a per-screen basis - + virtual void setPreviousPage(QString){ } //re-implement this if the page needs knowledge of what the previous page was signals: //emit this when the page has changes which are waiting to be saved void HasPendingChanges(bool); diff --git a/src-qt5/core-utils/lumina-config/pages/getPage.h b/src-qt5/core-utils/lumina-config/pages/getPage.h index 6a35dbae..f77a72c8 100644 --- a/src-qt5/core-utils/lumina-config/pages/getPage.h +++ b/src-qt5/core-utils/lumina-config/pages/getPage.h @@ -58,20 +58,23 @@ static QList KnownPages(){ static PageWidget* GetNewPage(QString id, QWidget *parent){ //Find the page that matches this "id" - if(id=="wallpaper"){ return new page_wallpaper(parent); } - else if(id=="theme"){ return new page_theme(parent); } - else if(id=="autostart"){ return new page_autostart(parent); } - else if(id=="defaultapps"){ return new page_defaultapps(parent); } - else if(id=="fluxbox-keys"){ return new page_fluxbox_keys(parent); } - else if(id=="fluxbox-settings"){ return new page_fluxbox_settings(parent); } - else if(id=="interface-desktop"){ return new page_interface_desktop(parent); } - else if(id=="interface-panel"){ return new page_interface_panels(parent); } - else if(id=="interface-menu"){ return new page_interface_menu(parent); } - else if(id=="session-locale"){ return new page_session_locale(parent); } - else if(id=="session-options"){ return new page_session_options(parent); } - else if(id=="compton"){ return new page_compton(parent); } + PageWidget* page = 0; + if(id=="wallpaper"){ page = new page_wallpaper(parent); } + else if(id=="theme"){ page = new page_theme(parent); } + else if(id=="autostart"){ page = new page_autostart(parent); } + else if(id=="defaultapps"){ page = new page_defaultapps(parent); } + else if(id=="fluxbox-keys"){ page = new page_fluxbox_keys(parent); } + else if(id=="fluxbox-settings"){ page = new page_fluxbox_settings(parent); } + else if(id=="interface-desktop"){ page = new page_interface_desktop(parent); } + else if(id=="interface-panel"){ page = new page_interface_panels(parent); } + else if(id=="interface-menu"){ page = new page_interface_menu(parent); } + else if(id=="session-locale"){ page = new page_session_locale(parent); } + else if(id=="session-options"){ page = new page_session_options(parent); } + else if(id=="compton"){ page = new page_compton(parent); } //Return the main control_panel page as the fallback/default - return new page_main(parent); + if(page==0){ id.clear(); page = new page_main(parent); } + page->setWhatsThis(id); + return page; } #endif diff --git a/src-qt5/core-utils/lumina-config/pages/page_main.cpp b/src-qt5/core-utils/lumina-config/pages/page_main.cpp index 976e7c69..1bdd3107 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_main.cpp +++ b/src-qt5/core-utils/lumina-config/pages/page_main.cpp @@ -24,6 +24,19 @@ page_main::~page_main(){ } +void page_main::setPreviousPage(QString id){ + for(int i=0; itreeWidget->topLevelItemCount(); i++){ + for(int j=0; jtreeWidget->topLevelItem(i)->childCount(); j++){ + if(ui->treeWidget->topLevelItem(i)->child(j)->whatsThis(0)==id){ + ui->treeWidget->setCurrentItem(ui->treeWidget->topLevelItem(i)->child(j)); + ui->treeWidget->scrollToItem(ui->treeWidget->topLevelItem(i)->child(j)); + return; //found item - done + } + } + } + +} + void page_main::UpdateItems(QString search){ ui->treeWidget->clear(); //First create the categories diff --git a/src-qt5/core-utils/lumina-config/pages/page_main.h b/src-qt5/core-utils/lumina-config/pages/page_main.h index 2e38eb64..7c7539a3 100644 --- a/src-qt5/core-utils/lumina-config/pages/page_main.h +++ b/src-qt5/core-utils/lumina-config/pages/page_main.h @@ -19,6 +19,8 @@ public: page_main(QWidget *parent); ~page_main(); + virtual void setPreviousPage(QString id); + public slots: void SaveSettings(); void LoadSettings(int screennum); -- cgit