diff options
author | Ken Moore <ken@pcbsd.org> | 2015-02-03 08:54:28 -0500 |
---|---|---|
committer | Ken Moore <ken@pcbsd.org> | 2015-02-03 08:54:28 -0500 |
commit | 9d98a248bac435de7b53ffad8f33fdb9f1e9b13d (patch) | |
tree | 4733a129d517da2621fe6998b39fdae2cdf2dbcc | |
parent | Make sure that the panel has the "sticky" flag set. This ensures that it is c... (diff) | |
download | lumina-9d98a248bac435de7b53ffad8f33fdb9f1e9b13d.tar.gz lumina-9d98a248bac435de7b53ffad8f33fdb9f1e9b13d.tar.bz2 lumina-9d98a248bac435de7b53ffad8f33fdb9f1e9b13d.zip |
Add an "apply" button to the lumina-config theme editor. Now the "save" button is for saving the theme to file (without closing the editor), and "apply" will both save and close the editor. Also make sure the save and apply buttons are actively enabled/disabled as necessary.
-rw-r--r-- | lumina-config/ThemeDialog.cpp | 28 | ||||
-rw-r--r-- | lumina-config/ThemeDialog.h | 2 | ||||
-rw-r--r-- | lumina-config/ThemeDialog.ui | 7 |
3 files changed, 36 insertions, 1 deletions
diff --git a/lumina-config/ThemeDialog.cpp b/lumina-config/ThemeDialog.cpp index c149255e..21413841 100644 --- a/lumina-config/ThemeDialog.cpp +++ b/lumina-config/ThemeDialog.cpp @@ -11,6 +11,7 @@ ThemeDialog::ThemeDialog(QWidget *parent, LPlugins *plugs, QString themeFilePath //Load the icons for the window ui->push_cancel->setIcon( LXDG::findIcon("dialog-cancel","") ); ui->push_save->setIcon( LXDG::findIcon("document-save","") ); + ui->push_apply->setIcon( LXDG::findIcon("dialog-ok","") ); ui->tool_color->setIcon( LXDG::findIcon("color-picker","") ); //Now create entries for the available colors in the database QStringList colors = plugs->colorItems(); @@ -27,26 +28,35 @@ ThemeDialog::ThemeDialog(QWidget *parent, LPlugins *plugs, QString themeFilePath //Now load the given file loadTheme(); connect(colormenu, SIGNAL(triggered(QAction*)),this, SLOT(menuTriggered(QAction*)) ); + connect(ui->text_file, SIGNAL(textChanged()), this, SLOT(themeChanged()) ); } void ThemeDialog::loadTheme(){ QStringList contents = LUtils::readFile(filepath); ui->text_file->setPlainText( contents.join("\n") ); + ui->push_save->setEnabled(false); + ui->push_apply->setEnabled(false); } void ThemeDialog::saveTheme(){ QString name = ui->line_name->text(); QStringList contents = ui->text_file->toPlainText().split("\n"); LTHEME::saveLocalTheme(name, contents); + ui->push_save->setEnabled(false); + ui->push_apply->setEnabled(false); } +void ThemeDialog::themeChanged(){ + ui->push_save->setEnabled(true); + ui->push_apply->setEnabled(true); +} // BUTTONS void ThemeDialog::on_push_save_clicked(){ //Now set the output values themename = ui->line_name->text(); themepath = QDir::homePath()+"/.lumina/themes/"+themename+".qss.template"; - //Check if that color already exists + //Check if that theme already exists if(QFile::exists(themepath)){ if( QMessageBox::Yes != QMessageBox::question(this, tr("Theme Exists"), tr("This theme already exists.\n Overwrite it?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ){ themename.clear(); @@ -56,6 +66,22 @@ void ThemeDialog::on_push_save_clicked(){ } //save the colors and close saveTheme(); + //this->close(); +} + +void ThemeDialog::on_push_apply_clicked(){ + //Now set the output values + themename = ui->line_name->text(); + themepath = QDir::homePath()+"/.lumina/themes/"+themename+".qss.template"; + //Check if that theme already exists + if(QFile::exists(themepath)){ + if( QMessageBox::Yes != QMessageBox::question(this, tr("Theme Exists"), tr("This theme already exists.\n Overwrite it?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ){ + themename.clear(); + themepath.clear(); + return; //cancelled + } + } + saveTheme(); this->close(); } diff --git a/lumina-config/ThemeDialog.h b/lumina-config/ThemeDialog.h index 15299e41..95bd9d73 100644 --- a/lumina-config/ThemeDialog.h +++ b/lumina-config/ThemeDialog.h @@ -49,8 +49,10 @@ public: QString themename, themepath; private slots: + void themeChanged(); void on_push_save_clicked(); void on_push_cancel_clicked(); + void on_push_apply_clicked(); void menuTriggered(QAction*); }; diff --git a/lumina-config/ThemeDialog.ui b/lumina-config/ThemeDialog.ui index f2c4b8d7..e26e2320 100644 --- a/lumina-config/ThemeDialog.ui +++ b/lumina-config/ThemeDialog.ui @@ -95,6 +95,13 @@ </property> </widget> </item> + <item> + <widget class="QPushButton" name="push_apply"> + <property name="text"> + <string>Apply</string> + </property> + </widget> + </item> </layout> </item> </layout> |