summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Grzeszczak <karl@karlgrz.com>2015-08-05 22:21:12 -0500
committerKarl Grzeszczak <karl@karlgrz.com>2015-08-05 22:21:12 -0500
commit9ce775d65f6459de655f672db86ea65e9f8c1f73 (patch)
treec82c7e708ea9e97f3018b0e835523d401cf63e24
parent14fa17d939ba43b762a3d5f4900e47f3296e9a0c (diff)
Issue #86 - Clear the password display after some time
-rw-r--r--.gitignore3
-rw-r--r--dialog.cpp51
-rw-r--r--dialog.h5
-rw-r--r--dialog.ui30
-rw-r--r--mainwindow.cpp24
-rw-r--r--mainwindow.h3
6 files changed, 116 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 42b830e7..82d5c29f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,6 @@ qtpass.xcworkspace/xcuserdata/*
.DS_Store
.qmake.stash
*.o
+moc_*.cpp
+qrc_*.cpp
+ui_*.h
diff --git a/dialog.cpp b/dialog.cpp
index 9345181e..ef40a08c 100644
--- a/dialog.cpp
+++ b/dialog.cpp
@@ -256,6 +256,20 @@ void Dialog::on_checkBoxClipboard_clicked()
}
/**
+ * @brief Dialog::on_checkBoxAutoclearPanel_clicked
+ */
+void Dialog::on_checkBoxAutoclearPanel_clicked()
+{
+ if (ui->checkBoxAutoclearPanel->isChecked()) {
+ ui->spinBoxAutoclearPanelSeconds->setEnabled(true);
+ ui->labelPanelSeconds->setEnabled(true);
+ } else {
+ ui->spinBoxAutoclearPanelSeconds->setEnabled(false);
+ ui->labelPanelSeconds->setEnabled(false);
+ }
+}
+
+/**
* @brief Dialog::useClipboard
*/
void Dialog::useClipboard(bool useClipboard)
@@ -284,6 +298,25 @@ void Dialog::setAutoclear(int seconds)
}
/**
+ * @brief Dialog::useAutoclearPanel
+ * @param useAutoclearPanel
+ */
+void Dialog::useAutoclearPanel(bool useAutoclearPanel)
+{
+ ui->checkBoxAutoclearPanel->setChecked(useAutoclearPanel);
+ on_checkBoxAutoclearPanel_clicked();
+}
+
+/**
+ * @brief Dialog::setAutoclearPanel
+ * @param seconds
+ */
+void Dialog::setAutoclearPanel(int seconds)
+{
+ ui->spinBoxAutoclearPanelSeconds->setValue(seconds);
+}
+
+/**
* @brief Dialog::useClipboard
* @return
*/
@@ -319,6 +352,24 @@ void Dialog::on_checkBoxAutoclear_clicked()
}
/**
+ * @brief Dialog::useAutoclearPanel
+ * @return
+ */
+bool Dialog::useAutoclearPanel()
+{
+ return ui->checkBoxAutoclearPanel->isChecked();
+}
+
+/**
+ * @brief Dialog::getAutoclearPanel
+ * @return
+ */
+int Dialog::getAutoclearPanel()
+{
+ return ui->spinBoxAutoclearPanelSeconds->value();
+}
+
+/**
* @brief Dialog::hidePassword
* @return
*/
diff --git a/dialog.h b/dialog.h
index 9f008669..b01dd443 100644
--- a/dialog.h
+++ b/dialog.h
@@ -30,6 +30,8 @@ public:
void useClipboard(bool);
void useAutoclear(bool);
void setAutoclear(int);
+ void useAutoclearPanel(bool);
+ void setAutoclearPanel(int);
void hidePassword(bool);
void hideContent(bool);
void addGPGId(bool);
@@ -42,6 +44,8 @@ public:
bool useClipboard();
bool useAutoclear();
int getAutoclear();
+ bool useAutoclearPanel();
+ int getAutoclearPanel();
bool hidePassword();
bool hideContent();
bool addGPGId();
@@ -79,6 +83,7 @@ private slots:
void on_toolButtonStore_clicked();
void on_checkBoxClipboard_clicked();
void on_checkBoxAutoclear_clicked();
+ void on_checkBoxAutoclearPanel_clicked();
void on_addButton_clicked();
void on_deleteButton_clicked();
void on_checkBoxUseTrayIcon_clicked();
diff --git a/dialog.ui b/dialog.ui
index 7ba7f8d2..2280d43f 100644
--- a/dialog.ui
+++ b/dialog.ui
@@ -273,6 +273,34 @@
</item>
</layout>
</item>
+ <item row="1" column="2">
+ <widget class="QCheckBox" name="checkBoxAutoclearPanel">
+ <property name="text">
+ <string>Autoclear panel</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <layout class="QHBoxLayout" name="horizontalLayout_7">
+ <item>
+ <widget class="QSpinBox" name="spinBoxAutoclearPanelSeconds">
+ <property name="minimum">
+ <number>5</number>
+ </property>
+ <property name="value">
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelPanelSeconds">
+ <property name="text">
+ <string>Seconds</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBoxHidePassword">
<property name="text">
@@ -519,6 +547,8 @@
<tabstop>checkBoxClipboard</tabstop>
<tabstop>checkBoxAutoclear</tabstop>
<tabstop>spinBoxAutoclearSeconds</tabstop>
+ <tabstop>checkBoxAutoclearPanel</tabstop>
+ <tabstop>spinBoxAutoclearPanelSeconds</tabstop>
<tabstop>checkBoxHidePassword</tabstop>
<tabstop>checkBoxHideContent</tabstop>
<tabstop>checkBoxUseGit</tabstop>
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 6b74e90d..29611828 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -166,6 +166,8 @@ bool MainWindow::checkConfig() {
useClipboard = (settings.value("useClipboard") == "true");
useAutoclear = (settings.value("useAutoclear") == "true");
autoclearSeconds = settings.value("autoclearSeconds").toInt();
+ useAutoclearPanel = (settings.value("useAutoclearPanel") == "true");
+ autoclearPanelSeconds = settings.value("autoclearPanelSeconds").toInt();
hidePassword = (settings.value("hidePassword") == "true");
hideContent = (settings.value("hideContent") == "true");
addGPGId = (settings.value("addGPGId") != "false");
@@ -227,6 +229,7 @@ bool MainWindow::checkConfig() {
if (freshStart && startMinimized) {
// since we are still in constructor, can't directly hide
QTimer::singleShot(10*autoclearSeconds, this, SLOT(hide()));
+ QTimer::singleShot(10*autoclearPanelSeconds, this, SLOT(hide()));
}
} else if (!useTrayIcon && tray != NULL) {
destroyTrayIcon();
@@ -240,6 +243,9 @@ bool MainWindow::checkConfig() {
if (autoclearSeconds < 5) {
autoclearSeconds = 10;
}
+ if (autoclearPanelSeconds < 5) {
+ autoclearPanelSeconds = 10;
+ }
passwordLength = 16;
passwordChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890~!@#$%^&*()_-+={}[]|:;<>,.?";
if (!pwgenExecutable.isEmpty()) {
@@ -350,6 +356,8 @@ void MainWindow::config() {
d->useClipboard(useClipboard);
d->useAutoclear(useAutoclear);
d->setAutoclear(autoclearSeconds);
+ d->useAutoclearPanel(useAutoclearPanel);
+ d->setAutoclearPanel(autoclearPanelSeconds);
d->hidePassword(hidePassword);
d->hideContent(hideContent);
d->addGPGId(addGPGId);
@@ -376,6 +384,8 @@ void MainWindow::config() {
useClipboard = d->useClipboard();
useAutoclear = d->useAutoclear();
autoclearSeconds = d->getAutoclear();
+ useAutoclearPanel = d->useAutoclearPanel();
+ autoclearPanelSeconds = d->getAutoclearPanel();
hidePassword = d->hidePassword();
hideContent = d->hideContent();
addGPGId = d->addGPGId();
@@ -401,6 +411,8 @@ void MainWindow::config() {
settings.setValue("useClipboard", useClipboard ? "true" : "false");
settings.setValue("useAutoclear", useAutoclear ? "true" : "false");
settings.setValue("autoclearSeconds", autoclearSeconds);
+ settings.setValue("useAutoclearPanel", useAutoclearPanel ? "true" : "false");
+ settings.setValue("autoclearPanelSeconds", autoclearPanelSeconds);
settings.setValue("hidePassword", hidePassword ? "true" : "false");
settings.setValue("hideContent", hideContent ? "true" : "false");
settings.setValue("addGPGId", addGPGId ? "true" : "false");
@@ -616,6 +628,9 @@ void MainWindow::readyRead(bool finished = false) {
clippedPass = tokens[0];
QTimer::singleShot(1000*autoclearSeconds, this, SLOT(clearClipboard()));
}
+ if (useAutoclearPanel) {
+ QTimer::singleShot(1000*autoclearPanelSeconds, this, SLOT(clearPanel()));
+ }
if (hidePassword) {
//tokens.pop_front();
tokens[0] = "***" + tr("Password hidden") + "***";
@@ -668,6 +683,15 @@ void MainWindow::clearClipboard()
}
/**
+ * @brief MainWindow::clearPanel
+ */
+void MainWindow::clearPanel()
+{
+ QString output = "***" + tr("Password and Content hidden") + "***";
+ ui->textBrowser->setHtml(output);
+}
+
+/**
* @brief MainWindow::processFinished
* @param exitCode
* @param exitStatus
diff --git a/mainwindow.h b/mainwindow.h
index 21f78622..b689eb07 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -61,6 +61,7 @@ private slots:
void processFinished(int, QProcess::ExitStatus);
void processError(QProcess::ProcessError);
void clearClipboard();
+ void clearPanel();
void on_lineEdit_textChanged(const QString &arg1);
void on_lineEdit_returnPressed();
void on_clearButton_clicked();
@@ -85,10 +86,12 @@ private:
bool usePass;
bool useClipboard;
bool useAutoclear;
+ bool useAutoclearPanel;
bool hidePassword;
bool hideContent;
bool addGPGId;
int autoclearSeconds;
+ int autoclearPanelSeconds;
QString passStore;
QString passExecutable;
QString gitExecutable;