aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2013-02-11 22:41:56 +0000
committernils <nils@34ebc366-c3a9-4b3c-9f84-69acf7962910>2013-02-11 22:41:56 +0000
commitfad039f680d6eb05d4fcda7fadacf86a027661a4 (patch)
treeb6b57a1c0596372a95bbb017a56a34f04a27e62c
parentupdated TODO and minor beautifying in settings dialog (diff)
downloadgpg4usb-fad039f680d6eb05d4fcda7fadacf86a027661a4.tar.gz
gpg4usb-fad039f680d6eb05d4fcda7fadacf86a027661a4.zip
added signals signalRestartNeeded to settingsdialog to handle a needed restart
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@1009 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r--TODO3
-rw-r--r--mainwindow.cpp23
-rw-r--r--mainwindow.h12
-rwxr-xr-xsettingsdialog.cpp38
-rwxr-xr-xsettingsdialog.h41
5 files changed, 99 insertions, 18 deletions
diff --git a/TODO b/TODO
index 9d87214..119a1c1 100644
--- a/TODO
+++ b/TODO
@@ -5,7 +5,7 @@ Release 0.4
- replace gpgme with kgpg (lots of work and trouble!!!)
- Refresh key from keyserver [DONE]
- add encrypt to self functionality [DONE]
- - add automatic restart if key changed
+ - add automatic restart if key changed [DONE]
- add find action in textedit [DONE]
- BUG: hit strg+f, then hit escape -> text not editable anymore, same with not found expression
- When search previous, text should be searched from end again, if no hit is found
@@ -20,6 +20,7 @@ Release 0.4
- change docu on file de- and encryption
- add possibility to set alternative relative path to keydb [DONE]
- on startup check, if keydb path exists, if keydb path isn't default
+ - add automatic restart, if keydb path changed (check for signal if keydbLabel changed)
- add possibility for creation of RSA keys [DONE]
- add posibility to add keyserver in settings [DONE]
- add posibility to remove keyserver in settings [DONE]
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 74fd645..da0c575 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -38,6 +38,9 @@ MainWindow::MainWindow()
/* List of binary Attachments */
attachmentDockCreated = false;
+ /* Variable containing if restart is needed */
+ this->slotSetRestartNeeded(false);
+
keyMgmt = new KeyMgmt(mCtx, this);
keyMgmt->hide();
/* test attachmentdir for files alll 15s */
@@ -1256,11 +1259,10 @@ void MainWindow::slotFileVerify()
void MainWindow::slotOpenSettingsDialog()
{
+ SettingsDialog *settingsdialog = new SettingsDialog(mCtx, this);
- QString preLang = settings.value("int/lang").toString();
- QString preKeydbPath = settings.value("gpgpaths/keydbpath").toString();
+ connect(settingsdialog, SIGNAL(signalRestartNeeded(bool)), this, SLOT(slotSetRestartNeeded(bool)));
- new SettingsDialog(mCtx, this);
// Iconsize
QSize iconSize = settings.value("toolbar/iconsize", QSize(32, 32)).toSize();
this->setIconSize(iconSize);
@@ -1280,8 +1282,8 @@ void MainWindow::slotOpenSettingsDialog()
closeAttachmentDock();
}
- // restart mainwindow if langugage or keydbpath changed
- if((preLang != settings.value("int/lang").toString()) || preKeydbPath != settings.value("gpgpaths/keydbpath").toString()) {
+ // restart mainwindow if necessary
+ if(getRestartNeeded()) {
if(edit->maybeSaveAnyTab()) {
saveSettings();
qApp->exit(RESTART_CODE);
@@ -1294,7 +1296,6 @@ void MainWindow::slotOpenSettingsDialog()
} else {
this->menuBar()->insertAction(viewMenu->menuAction(), steganoMenu->menuAction());
}
-
}
void MainWindow::slotCleanDoubleLinebreaks()
@@ -1363,3 +1364,13 @@ void MainWindow::slotCutPgpHeader() {
edit->slotFillTextEditWithText(content.trimmed());
}
+
+void MainWindow::slotSetRestartNeeded(bool needed)
+{
+ this->restartNeeded = needed;
+}
+
+bool MainWindow::getRestartNeeded()
+{
+ return this->restartNeeded;
+}
diff --git a/mainwindow.h b/mainwindow.h
index abe3dbe..3257849 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -278,6 +278,12 @@ private slots:
*/
void slotDisableTabActions(int number);
+ /**
+ * @details get value of member restartNeeded to needed.
+ * @param needed true, if application has to be restarted
+ */
+ void slotSetRestartNeeded(bool needed);
+
private:
/**
* @details Create actions for the main-menu.
@@ -343,6 +349,11 @@ private:
*/
void changeMessage(const QString &msg, const bool keep = false);
+ /**
+ * @brief return true, if restart is needed
+ */
+ bool getRestartNeeded();
+
TextEdit *edit; /** Tabwidget holding the edit-windows */
QMenu *fileMenu; /** Submenu for file operations*/
QMenu *editMenu; /** Submenu for text operations*/
@@ -423,6 +434,7 @@ private:
KeyMgmt *keyMgmt; /**< TODO */
KeyServerImportDialog *importDialog; /**< TODO */
bool attachmentDockCreated;
+ bool restartNeeded;
};
#endif // __GPGWIN_H__
diff --git a/settingsdialog.cpp b/settingsdialog.cpp
index 690d9d2..c75b40a 100755
--- a/settingsdialog.cpp
+++ b/settingsdialog.cpp
@@ -45,7 +45,6 @@ SettingsDialog::SettingsDialog(GpgME::GpgContext *ctx, QWidget *parent)
connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccept()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
-
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(tabWidget);
mainLayout->addWidget(buttonBox);
@@ -53,9 +52,29 @@ SettingsDialog::SettingsDialog(GpgME::GpgContext *ctx, QWidget *parent)
setWindowTitle(tr("Settings"));
+ // slots for handling the restartneeded member
+ this->slotSetRestartNeeded(false);
+ connect(generalTab, SIGNAL(signalRestartNeeded(bool)), this, SLOT(slotSetRestartNeeded(bool)));
+ connect(appearanceTab, SIGNAL(signalRestartNeeded(bool)), this, SLOT(slotSetRestartNeeded(bool)));
+ connect(mimeTab, SIGNAL(signalRestartNeeded(bool)), this, SLOT(slotSetRestartNeeded(bool)));
+ connect(keyserverTab, SIGNAL(signalRestartNeeded(bool)), this, SLOT(slotSetRestartNeeded(bool)));
+ connect(gpgPathsTab, SIGNAL(signalRestartNeeded(bool)), this, SLOT(slotSetRestartNeeded(bool)));
+ connect(advancedTab, SIGNAL(signalRestartNeeded(bool)), this, SLOT(slotSetRestartNeeded(bool)));
+
exec();
}
+bool SettingsDialog::getRestartNeeded()
+{
+ return this->restartNeeded;
+}
+
+void SettingsDialog::slotSetRestartNeeded(bool needed)
+{
+ qDebug() << "slot restart needed (settingsdialog): " << needed;
+ this->restartNeeded = needed;
+}
+
void SettingsDialog::slotAccept()
{
generalTab->applySettings();
@@ -64,6 +83,9 @@ void SettingsDialog::slotAccept()
keyserverTab->applySettings();
advancedTab->applySettings();
gpgPathsTab->applySettings();
+ if (getRestartNeeded()) {
+ emit signalRestartNeeded(true);
+ }
close();
}
@@ -146,6 +168,7 @@ GeneralTab::GeneralTab(GpgME::GpgContext *ctx,QWidget *parent)
langBoxLayout->addWidget(langSelectBox);
langBoxLayout->addWidget(new QLabel(tr("<b>NOTE: </b> Gpg4usb will restart automatically if you change the language!")));
langBox->setLayout(langBoxLayout);
+ connect(langSelectBox,SIGNAL(currentIndexChanged(int)),this,SLOT(slotLanguageChanged()));
/*****************************************
* Own Key Select Box
@@ -180,7 +203,6 @@ GeneralTab::GeneralTab(GpgME::GpgContext *ctx,QWidget *parent)
ownKeyBoxLayout->addWidget(ownKeySelectBox);
ownKeyBoxLayout->addWidget(new QLabel(tr("<b>NOTE: </b> Gpg4usb will restart automatically if you change the own key!")));
-
/*****************************************
* Mainlayout
*****************************************/
@@ -243,10 +265,8 @@ void GeneralTab::setSettings()
ownKeySelectBox->setCurrentIndex(ownKeySelectBox->findText("none", Qt::MatchContains));
} else {
ownKeySelectBox->setCurrentIndex(ownKeySelectBox->findText(ownKeyId, Qt::MatchContains));
- qDebug() << ownKeySelectBox->findText(ownKeyId);
}
-
if (settings.value("general/confirmImportKeys",Qt::Checked).toBool()){
importConfirmationCheckBox->setCheckState(Qt::Checked);
}
@@ -266,6 +286,12 @@ void GeneralTab::applySettings()
settings.setValue("general/confirmImportKeys", importConfirmationCheckBox->isChecked());
}
+void GeneralTab::slotLanguageChanged()
+{
+ qDebug() << "slot language changed";
+ emit signalRestartNeeded(true);
+}
+
void GeneralTab::slotOwnKeyIdChanged()
{
// Set ownKeyId to currently selected
@@ -310,6 +336,9 @@ void GeneralTab::slotOwnKeyIdChanged()
gpgConfFile.remove();
gpgConfTempFile.copy(gpgConfTempFile.fileName(),gpgConfFile.fileName());
gpgConfTempFile.remove();
+
+ // emit signal, thta application has to be restarted
+ emit signalRestartNeeded(true);
}
MimeTab::MimeTab(QWidget *parent)
@@ -674,7 +703,6 @@ QString GpgPathsTab::getRelativePath(const QString dir1,const QString dir2)
QString s;
s = dir.relativeFilePath(dir2);
- qDebug() << "relative path: " << s;
if (s.isEmpty()) {
s = ".";
}
diff --git a/settingsdialog.h b/settingsdialog.h
index 2cb0377..4d10665 100755
--- a/settingsdialog.h
+++ b/settingsdialog.h
@@ -72,7 +72,12 @@ class GeneralTab : public QWidget
private slots:
void slotOwnKeyIdChanged();
- };
+ void slotLanguageChanged();
+
+signals:
+ void signalRestartNeeded(bool needed);
+
+};
class MimeTab : public QWidget
{
@@ -87,6 +92,10 @@ private slots:
QCheckBox *mimeParseCheckBox;
QCheckBox *mimeQPCheckBox;
QCheckBox *mimeOpenAttachmentCheckBox;
+
+ signals:
+ void signalRestartNeeded(bool needed);
+
};
class AppearanceTab : public QWidget
@@ -110,6 +119,9 @@ private slots:
QRadioButton *iconAllButton;
QCheckBox *windowSizeCheckBox;
+ signals:
+ void signalRestartNeeded(bool needed);
+
};
class KeyserverTab : public QWidget
@@ -128,7 +140,11 @@ private slots:
void addKeyServer();
void removeKeyServer();
void editTextChangedAction();
-};
+
+ signals:
+ void signalRestartNeeded(bool needed);
+
+ };
class AdvancedTab : public QWidget
{
@@ -141,6 +157,9 @@ private slots:
private:
QCheckBox *steganoCheckBox;
+ signals:
+ void signalRestartNeeded(bool needed);
+
};
class GpgPathsTab : public QWidget
@@ -161,13 +180,16 @@ private:
QString slotChooseKeydbDir();
void slotSetKeydbPathToDefault();
+ signals:
+ void signalRestartNeeded(bool needed);
+
};
class SettingsDialog : public QDialog
{
Q_OBJECT
-public:
+ public:
SettingsDialog(GpgME::GpgContext *ctx, QWidget *parent = 0);
GeneralTab *generalTab;
MimeTab *mimeTab;
@@ -177,14 +199,21 @@ public:
GpgPathsTab *gpgPathsTab;
static QHash<QString, QString> listLanguages();
-
-public slots:
+ public slots:
void slotAccept();
-private:
+ signals:
+ void signalRestartNeeded(bool needed);
+
+ private:
QTabWidget *tabWidget;
QDialogButtonBox *buttonBox;
GpgME::GpgContext *mCtx; /** The current gpg context */
+ bool restartNeeded;
+ bool getRestartNeeded();
+
+ private slots:
+ void slotSetRestartNeeded(bool needed);
};