summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEttore Dreucci <ettore.dreucci@gmail.com>2018-05-08 12:40:45 +0200
committerEttore Dreucci <ettore.dreucci@gmail.com>2018-05-09 12:13:49 +0200
commitdb5e8c9a63304059cf6e6837ac80314a91eccbd2 (patch)
tree8ec6d62606c07d754a78037d624d15a243196c8a
parent76de9091116b0e988f2dd826edcb7e85098938c6 (diff)
Added checkbox for otp plugin in config dialog. Some problems with signal finishedOtpShow: ui hang
Signed-off-by: Ettore Dreucci <ettore.dreucci@gmail.com>
-rw-r--r--src/configdialog.cpp6
-rw-r--r--src/configdialog.h1
-rw-r--r--src/configdialog.ui31
-rw-r--r--src/mainwindow.cpp16
-rw-r--r--src/mainwindow.h1
-rw-r--r--src/mainwindow.ui2
-rw-r--r--src/pass.cpp1
-rw-r--r--src/qtpasssettings.cpp8
-rw-r--r--src/qtpasssettings.h3
-rw-r--r--src/settingsconstants.cpp1
-rw-r--r--src/settingsconstants.h1
11 files changed, 67 insertions, 4 deletions
diff --git a/src/configdialog.cpp b/src/configdialog.cpp
index e7ba895e..c535b9fe 100644
--- a/src/configdialog.cpp
+++ b/src/configdialog.cpp
@@ -54,6 +54,7 @@ ConfigDialog::ConfigDialog(MainWindow *parent)
useAutoclearPanel(QtPassSettings::isUseAutoclearPanel());
useTrayIcon(QtPassSettings::isUseTrayIcon());
useGit(QtPassSettings::isUseGit());
+ useOtp(QtPassSettings::isUseOtp());
usePwgen(QtPassSettings::isUsePwgen());
useTemplate(QtPassSettings::isUseTemplate());
@@ -137,6 +138,7 @@ void ConfigDialog::on_accepted() {
QtPassSettings::setStartMinimized(ui->checkBoxStartMinimized->isChecked());
QtPassSettings::setProfiles(getProfiles());
QtPassSettings::setUseGit(ui->checkBoxUseGit->isChecked());
+ QtPassSettings::setUseOtp(ui->checkBoxUseOtp->isChecked());
QtPassSettings::setPwgenExecutable(ui->pwgenPath->text());
QtPassSettings::setUsePwgen(ui->checkBoxUsePwgen->isChecked());
QtPassSettings::setAvoidCapitals(ui->checkBoxAvoidCapitals->isChecked());
@@ -558,6 +560,10 @@ void ConfigDialog::useGit(bool useGit) {
on_checkBoxUseGit_clicked();
}
+void ConfigDialog::useOtp(bool useOtp) {
+ ui->checkBoxUseOtp->setChecked(useOtp);
+}
+
/**
* @brief ConfigDialog::on_checkBoxUseGit_clicked enable or disable related
* checkboxes.
diff --git a/src/configdialog.h b/src/configdialog.h
index af1767df..4db4f24c 100644
--- a/src/configdialog.h
+++ b/src/configdialog.h
@@ -36,6 +36,7 @@ public:
bool hideOnClose();
void useTrayIcon(bool useTrayIdon);
void useGit(bool useGit);
+ void useOtp(bool useOtp);
void setPwgenPath(QString);
void usePwgen(bool usePwgen);
void setPasswordConfiguration(const PasswordConfiguration &config);
diff --git a/src/configdialog.ui b/src/configdialog.ui
index 5c7d3b5e..6b242ac8 100644
--- a/src/configdialog.ui
+++ b/src/configdialog.ui
@@ -503,6 +503,37 @@
</layout>
</item>
<item>
+ <layout class="QVBoxLayout" name="Extensions">
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Extensions:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_9">
+ <item>
+ <widget class="QCheckBox" name="checkBoxUseOtp">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Use pass otp extension</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
<layout class="QVBoxLayout" name="Layout_System">
<property name="topMargin">
<number>0</number>
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 123c164d..6d02d92e 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -199,6 +199,7 @@ void MainWindow::connectPassSignalHandlers(Pass *pass) {
connect(pass, &Pass::finishedGitPull, this, &MainWindow::processFinished);
connect(pass, &Pass::finishedGitPush, this, &MainWindow::processFinished);
connect(pass, &Pass::finishedShow, this, &MainWindow::passShowHandler);
+ //connect(pass, &Pass::finishedOtpShow, this, &MainWindow::passOtpHandler);
connect(pass, &Pass::finishedInsert, this, &MainWindow::finishedInsert);
connect(pass, &Pass::finishedRemove, this, &MainWindow::passStoreChanged);
connect(pass, &Pass::finishedInit, this, &MainWindow::passStoreChanged);
@@ -380,6 +381,7 @@ bool MainWindow::checkConfig() {
QtPassSettings::getAutoclearPanelSeconds());
clearClipboardTimer.setInterval(1000 * QtPassSettings::getAutoclearSeconds());
updateGitButtonVisibility();
+ updateOtpButtonVisibility();
startupPhase = false;
return true;
@@ -422,6 +424,7 @@ void MainWindow::config() {
QtPassSettings::getAutoclearSeconds());
updateGitButtonVisibility();
+ updateOtpButtonVisibility();
if (QtPassSettings::isUseTrayIcon() && tray == NULL)
initTrayIcon();
else if (!QtPassSettings::isUseTrayIcon() && tray != NULL) {
@@ -726,6 +729,7 @@ void MainWindow::enableUiElements(bool state) {
ui->actionDelete->setEnabled(state);
ui->actionEdit->setEnabled(state);
updateGitButtonVisibility();
+ updateOtpButtonVisibility();
}
void MainWindow::restoreWindow() {
@@ -1291,9 +1295,8 @@ void MainWindow::editPassword(const QString &file) {
*/
void MainWindow::generateOtp(const QString &file) {
if (!file.isEmpty()) {
- if (QtPassSettings::isUseGit() && QtPassSettings::isAutoPull())
- onUpdate(true);
- QtPassSettings::getPass()->OtpShow(file);
+ if (QtPassSettings::isUseOtp())
+ QtPassSettings::getPass()->OtpShow(file);
}
}
@@ -1451,6 +1454,13 @@ void MainWindow::updateGitButtonVisibility() {
}
}
+void MainWindow::updateOtpButtonVisibility() {
+ if(!QtPassSettings::isUseOtp())
+ ui->actionOtp->setEnabled(false);
+ else
+ ui->actionOtp->setEnabled(true);
+}
+
void MainWindow::enableGitButtons(const bool &state) {
// Following GNOME guidelines is preferable disable buttons instead of hide
ui->actionPush->setEnabled(state);
diff --git a/src/mainwindow.h b/src/mainwindow.h
index ba9f21a3..b44f7bbd 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -141,6 +141,7 @@ private:
void connectPassSignalHandlers(Pass *pass);
void updateGitButtonVisibility();
+ void updateOtpButtonVisibility();
void enableGitButtons(const bool &);
};
diff --git a/src/mainwindow.ui b/src/mainwindow.ui
index 431fd94e..574a3254 100644
--- a/src/mainwindow.ui
+++ b/src/mainwindow.ui
@@ -367,7 +367,7 @@ p, li { white-space: pre-wrap; }
<string>OTP</string>
</property>
<property name="toolTip">
- <string>Generate OTP</string>
+ <string>Generate OTP and copy to clipboard</string>
</property>
<property name="shortcut">
<string>Ctrl+G</string>
diff --git a/src/pass.cpp b/src/pass.cpp
index 2f261fba..1654c371 100644
--- a/src/pass.cpp
+++ b/src/pass.cpp
@@ -183,6 +183,7 @@ void Pass::finished(int id, int exitCode, const QString &out,
break;
case PASS_OTP_SHOW:
emit finishedOtpShow(out);
+ break;
case PASS_INSERT:
emit finishedInsert(out, err);
break;
diff --git a/src/qtpasssettings.cpp b/src/qtpasssettings.cpp
index ab1400f5..14b0c250 100644
--- a/src/qtpasssettings.cpp
+++ b/src/qtpasssettings.cpp
@@ -380,6 +380,14 @@ void QtPassSettings::setUseGit(const bool &useGit) {
getInstance()->setValue(SettingsConstants::useGit, useGit);
}
+bool QtPassSettings::isUseOtp(const bool &defaultValue) {
+ return getInstance()->value(SettingsConstants::useOtp, defaultValue).toBool();
+}
+
+void QtPassSettings::setUseOtp(const bool &useOtp) {
+ getInstance()->setValue(SettingsConstants::useOtp, useOtp);
+}
+
bool QtPassSettings::isUsePwgen(const bool &defaultValue) {
return getInstance()
->value(SettingsConstants::usePwgen, defaultValue)
diff --git a/src/qtpasssettings.h b/src/qtpasssettings.h
index 197f80c5..5d787277 100644
--- a/src/qtpasssettings.h
+++ b/src/qtpasssettings.h
@@ -141,6 +141,9 @@ public:
static bool isUseGit(const bool &defaultValue = QVariant().toBool());
static void setUseGit(const bool &useGit);
+ static bool isUseOtp(const bool &defaultValue = QVariant().toBool());
+ static void setUseOtp(const bool &useOtp);
+
static bool isUsePwgen(const bool &defaultValue = QVariant().toBool());
static void setUsePwgen(const bool &usePwgen);
diff --git a/src/settingsconstants.cpp b/src/settingsconstants.cpp
index 8b8c31ce..066931f3 100644
--- a/src/settingsconstants.cpp
+++ b/src/settingsconstants.cpp
@@ -43,6 +43,7 @@ const QString SettingsConstants::webDavPassword = "webDavPassword";
const QString SettingsConstants::profile = "profile";
const QString SettingsConstants::groupProfiles = "profiles";
const QString SettingsConstants::useGit = "useGit";
+const QString SettingsConstants::useOtp = "useOtp";
const QString SettingsConstants::useClipboard = "useClipboard";
const QString SettingsConstants::usePwgen = "usePwgen";
const QString SettingsConstants::avoidCapitals = "avoidCapitals";
diff --git a/src/settingsconstants.h b/src/settingsconstants.h
index 0f436085..1b719c8e 100644
--- a/src/settingsconstants.h
+++ b/src/settingsconstants.h
@@ -40,6 +40,7 @@ public:
const static QString profile;
const static QString groupProfiles;
const static QString useGit;
+ const static QString useOtp;
const static QString useClipboard;
const static QString usePwgen;
const static QString avoidCapitals;