diff options
-rw-r--r-- | lumina-config/AppDialog.h | 19 | ||||
-rw-r--r-- | lumina-config/AppDialog.ui | 6 | ||||
-rw-r--r-- | lumina-config/mainUI.cpp | 31 | ||||
-rw-r--r-- | lumina-config/mainUI.h | 2 |
4 files changed, 46 insertions, 12 deletions
diff --git a/lumina-config/AppDialog.h b/lumina-config/AppDialog.h index 0ea9b93a..acc6c73e 100644 --- a/lumina-config/AppDialog.h +++ b/lumina-config/AppDialog.h @@ -33,6 +33,7 @@ public: AppDialog(QWidget *parent = 0, QList<XDGDesktop> applist = QList<XDGDesktop>()) : QDialog(parent), ui(new Ui::AppDialog){ ui->setupUi(this); //load the designer file APPS = applist; //save this for later + appreset = false; ui->comboBox->clear(); for(int i=0; i<APPS.length(); i++){ ui->comboBox->addItem( LXDG::findIcon(APPS[i].icon,"application-x-executable"), APPS[i].name ); @@ -44,8 +45,17 @@ public: ~AppDialog(){} - XDGDesktop appselected; + void allowReset(bool allow){ + if(allow){ + ui->buttonBox->setStandardButtons(QDialogButtonBox::RestoreDefaults | QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + }else{ + ui->buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + } + } + XDGDesktop appselected; //selected application (empty template for cancelled/reset) + bool appreset; //Did the user select to reset to defaults? + private slots: void on_buttonBox_accepted(){ appselected = APPS[ ui->comboBox->currentIndex() ]; @@ -54,7 +64,12 @@ private slots: void on_buttonBox_rejected(){ this->close(); } - + void on_buttonBox_clicked(QAbstractButton *button){ + if(ui->buttonBox->standardButton(button) == QDialogButtonBox::RestoreDefaults){ + appreset = true; + this->close(); + } + } }; #endif diff --git a/lumina-config/AppDialog.ui b/lumina-config/AppDialog.ui index 49a1e921..63323f7d 100644 --- a/lumina-config/AppDialog.ui +++ b/lumina-config/AppDialog.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>303</width> - <height>88</height> + <width>348</width> + <height>91</height> </rect> </property> <property name="windowTitle"> @@ -62,7 +62,7 @@ <enum>Qt::Horizontal</enum> </property> <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::RestoreDefaults</set> </property> </widget> </item> diff --git a/lumina-config/mainUI.cpp b/lumina-config/mainUI.cpp index bcf2ba31..c5a0c934 100644 --- a/lumina-config/mainUI.cpp +++ b/lumina-config/mainUI.cpp @@ -309,10 +309,17 @@ QString MainUI::getColorStyle(QString current){ return out; }*/ -XDGDesktop MainUI::getSysApp(){ +XDGDesktop MainUI::getSysApp(bool allowreset){ AppDialog dlg(this, sysApps); + dlg.allowReset(allowreset); dlg.exec(); - return dlg.appselected; + XDGDesktop desk; + if(dlg.appreset && allowreset){ + desk.filePath = "reset"; //special internal flag + }else{ + desk = dlg.appselected; + } + return desk; } //Convert to/from fluxbox key codes @@ -1170,8 +1177,11 @@ void MainUI::getKeyPress(){ //=========== void MainUI::changeDefaultBrowser(){ //Prompt for the new app - XDGDesktop desk = getSysApp(); + XDGDesktop desk = getSysApp(true); if(desk.filePath.isEmpty()){ return; }//nothing selected + if(desk.filePath=="reset"){ + desk.filePath=""; + } //save the new app setting and adjust the button appearance appsettings->setValue("default/webbrowser", desk.filePath); QString tmp = desk.filePath; @@ -1198,8 +1208,11 @@ void MainUI::changeDefaultBrowser(){ void MainUI::changeDefaultEmail(){ //Prompt for the new app - XDGDesktop desk = getSysApp(); + XDGDesktop desk = getSysApp(true); //allow reset to default if(desk.filePath.isEmpty()){ return; }//nothing selected + if(desk.filePath=="reset"){ + desk.filePath=""; + } //save the new app setting and adjust the button appearance appsettings->setValue("default/email", desk.filePath); QString tmp = desk.filePath; @@ -1226,8 +1239,11 @@ void MainUI::changeDefaultEmail(){ void MainUI::changeDefaultFileManager(){ //Prompt for the new app - XDGDesktop desk = getSysApp(); + XDGDesktop desk = getSysApp(true); if(desk.filePath.isEmpty()){ return; }//nothing selected + if(desk.filePath=="reset"){ + desk.filePath="lumina-fm"; + } //save the new app setting and adjust the button appearance appsettings->setValue("default/directory", desk.filePath); sessionsettings->setValue("default-filemanager", desk.filePath); @@ -1255,8 +1271,11 @@ void MainUI::changeDefaultFileManager(){ void MainUI::changeDefaultTerminal(){ //Prompt for the new app - XDGDesktop desk = getSysApp(); + XDGDesktop desk = getSysApp(true); if(desk.filePath.isEmpty()){ return; }//nothing selected + if(desk.filePath=="reset"){ + desk.filePath="xterm"; + } //save the new app setting and adjust the button appearance sessionsettings->setValue("default-terminal", desk.filePath); QString tmp = desk.filePath; diff --git a/lumina-config/mainUI.h b/lumina-config/mainUI.h index 7d655476..93400d93 100644 --- a/lumina-config/mainUI.h +++ b/lumina-config/mainUI.h @@ -72,7 +72,7 @@ private: //QString getNewPanelPlugin(); //Get an application on the system - XDGDesktop getSysApp(); + XDGDesktop getSysApp(bool allowreset = false); //Convert to/from fluxbox keyboard shortcuts QString dispToFluxKeys(QString); |