diff options
author | Anne Jan Brouwer <brouwer@annejan.com> | 2015-05-03 16:15:01 +0200 |
---|---|---|
committer | Anne Jan Brouwer <brouwer@annejan.com> | 2015-05-03 16:15:01 +0200 |
commit | 0f9bc6925c370b4c4e5123ddc9bbeb53874c7dcb (patch) | |
tree | a024f5874f63b2be2923a2dbdceb7f5e27b1508d | |
parent | 3927c8947a9080776ebfe7ab95db0c24c25d376e (diff) |
adding of newly created .gpg-id file(s)
-rw-r--r-- | dialog.cpp | 18 | ||||
-rw-r--r-- | dialog.h | 4 | ||||
-rw-r--r-- | dialog.ui | 137 | ||||
-rw-r--r-- | mainwindow.cpp | 18 | ||||
-rw-r--r-- | mainwindow.h | 1 |
5 files changed, 112 insertions, 66 deletions
@@ -330,3 +330,21 @@ void Dialog::hideContent(bool hideContent) { ui->checkBoxHideContent->setChecked(hideContent); } + +/** + * @brief Dialog::addGPGId + * @return + */ +bool Dialog::addGPGId() +{ + return ui->checkBoxAddGPGId->isChecked(); +} + +/** + * @brief Dialog::addGPGId + * @param addGPGId + */ +void Dialog::addGPGId(bool addGPGId) +{ + ui->checkBoxAddGPGId->setChecked(addGPGId); +} @@ -25,6 +25,7 @@ public: void setAutoclear(int); void hidePassword(bool); void hideContent(bool); + void addGPGId(bool); QString getPassPath(); QString getGitPath(); QString getGpgPath(); @@ -35,6 +36,7 @@ public: int getAutoclear(); bool hidePassword(); bool hideContent(); + bool addGPGId(); private slots: void on_radioButtonNative_clicked(); @@ -43,9 +45,7 @@ private slots: void on_toolButtonGpg_clicked(); void on_toolButtonPass_clicked(); void on_toolButtonStore_clicked(); - void on_checkBoxClipboard_clicked(); - void on_checkBoxAutoclear_clicked(); private: @@ -13,34 +13,26 @@ <property name="windowTitle"> <string>Configuration</string> </property> - <layout class="QGridLayout" name="gridLayout_4"> - <item row="2" column="0"> - <widget class="QGroupBox" name="groupBoxPass"> - <property name="title"> - <string>Pass</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="2"> - <widget class="QToolButton" name="toolButtonPass"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="labelPassPath"> - <property name="text"> - <string>Executable pass</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="passPath"/> - </item> - </layout> - </widget> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <item> + <widget class="QRadioButton" name="radioButtonNative"> + <property name="text"> + <string>&Native git/gpg</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="radioButtonPass"> + <property name="text"> + <string>&Use pass</string> + </property> + </widget> + </item> + </layout> </item> - <item row="1" column="0"> + <item> <widget class="QGroupBox" name="groupBoxNative"> <property name="title"> <string>Native</string> @@ -83,35 +75,33 @@ </layout> </widget> </item> - <item row="0" column="0"> - <layout class="QHBoxLayout" name="horizontalLayout_5"> - <item> - <widget class="QRadioButton" name="radioButtonNative"> - <property name="text"> - <string>Native git/gpg</string> - </property> - </widget> - </item> - <item> - <widget class="QRadioButton" name="radioButtonPass"> - <property name="text"> - <string>Use pass</string> - </property> - </widget> - </item> - </layout> - </item> - <item row="5" column="0"> - <widget class="QDialogButtonBox" name="buttonBox"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="standardButtons"> - <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + <item> + <widget class="QGroupBox" name="groupBoxPass"> + <property name="title"> + <string>Pass</string> </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="2"> + <widget class="QToolButton" name="toolButtonPass"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="labelPassPath"> + <property name="text"> + <string>Executable pass</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="passPath"/> + </item> + </layout> </widget> </item> - <item row="3" column="0"> + <item> <widget class="QGroupBox" name="groupBox"> <property name="title"> <string>Other</string> @@ -154,16 +144,6 @@ </property> </widget> </item> - <item row="0" column="3"> - <widget class="QLabel" name="labelSeconds"> - <property name="text"> - <string>Seconds</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QSpinBox" name="spinBoxAutoclearSeconds"/> - </item> <item row="1" column="0"> <widget class="QCheckBox" name="checkBoxHidePassword"> <property name="text"> @@ -178,11 +158,42 @@ </property> </widget> </item> + <item row="1" column="2"> + <widget class="QCheckBox" name="checkBoxAddGPGId"> + <property name="text"> + <string>Automatically add .gpg-id files</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QSpinBox" name="spinBoxAutoclearSeconds"/> + </item> + <item> + <widget class="QLabel" name="labelSeconds"> + <property name="text"> + <string>Seconds</string> + </property> + </widget> + </item> + </layout> + </item> </layout> </item> </layout> </widget> </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> </layout> </widget> <resources/> diff --git a/mainwindow.cpp b/mainwindow.cpp index aa8b747f..d176fb28 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -7,6 +7,7 @@ #include <QInputDialog> #include <QMessageBox> #include <QTimer> +#include <QFileInfo> #ifdef Q_OS_WIN #include <windows.h> #include <winnetwk.h> @@ -130,6 +131,7 @@ void MainWindow::checkConfig() { autoclearSeconds = settings.value("autoclearSeconds").toInt(); hidePassword = (settings.value("hidePassword") == "true"); hideContent = (settings.value("hideContent") == "true"); + addGPGId = (settings.value("addGPGId") != "false"); passStore = settings.value("passStore").toString(); if (passStore == "") { @@ -210,6 +212,7 @@ void MainWindow::config() { d->setAutoclear(autoclearSeconds); d->hidePassword(hidePassword); d->hideContent(hideContent); + d->addGPGId(addGPGId); if (d->exec()) { if (d->result() == QDialog::Accepted) { @@ -224,6 +227,7 @@ void MainWindow::config() { autoclearSeconds = d->getAutoclear(); hidePassword = d->hidePassword(); hideContent = d->hideContent(); + addGPGId = d->addGPGId(); QSettings &settings(getSettings()); @@ -237,6 +241,7 @@ void MainWindow::config() { settings.setValue("autoclearSeconds", autoclearSeconds); settings.setValue("hidePassword", hidePassword ? "true" : "false"); settings.setValue("hideContent", hideContent ? "true" : "false"); + settings.setValue("addGPGId", addGPGId ? "true" : "false"); ui->treeView->setRootIndex(model.setRootPath(passStore)); } @@ -765,7 +770,15 @@ void MainWindow::on_usersButton_clicked() return; } d.setUsers(NULL); - QFile gpgId(dir + ".gpg-id"); + QString gpgIdFile = dir + ".gpg-id"; + QFile gpgId(gpgIdFile); + bool addFile = false; + if (addGPGId) { + QFileInfo checkFile(gpgIdFile); + if (!checkFile.exists() || !checkFile.isFile()) { + addFile = true; + } + } if (!gpgId.open(QIODevice::WriteOnly | QIODevice::Text)) { QMessageBox::critical(this, tr("Cannot update"), tr("Failed to open .gpg-id for writing.")); @@ -777,6 +790,9 @@ void MainWindow::on_usersButton_clicked() } } gpgId.close(); + if (addFile) { + executeWrapper(gitExecutable, "add " + gpgIdFile); + } } /** diff --git a/mainwindow.h b/mainwindow.h index 1c763c04..2eeb079e 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -64,6 +64,7 @@ private: bool useAutoclear; bool hidePassword; bool hideContent; + bool addGPGId; int autoclearSeconds; QString passStore; QString passExecutable; |