summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortezeb <tezeb+github@outoftheblue.pl>2016-11-27 00:33:37 +0100
committertezeb <tezeb+github@outoftheblue.pl>2016-11-27 00:33:37 +0100
commit59044608722357037c64c59b329c2b7f0b3ccbda (patch)
treebe8f462428f9872f138c4748e5d9f15f8233b8de
parentf7a82295065527673e0e2bacea6143dd33850c91 (diff)
fix Panel and Pass timers
- make Panel timer non dyn-allocated, with fixed config and working(it was not) - add Pass timer as member, with fixed config
-rw-r--r--mainwindow.cpp43
-rw-r--r--mainwindow.h5
2 files changed, 27 insertions, 21 deletions
diff --git a/mainwindow.cpp b/mainwindow.cpp
index 68b1ef13..d7165348 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -73,7 +73,11 @@ MainWindow::MainWindow(QWidget *parent)
ui->statusBar->showMessage(tr("Welcome to QtPass %1").arg(VERSION), 2000);
freshStart = true;
startupPhase = true;
- autoclearTimer = NULL;
+ clearPanelTimer.setSingleShot(true);
+ connect(&clearPanelTimer, SIGNAL(timeout()), this, SLOT(clearPanel()));
+ clearClipboardTimer.setSingleShot(true);
+ connect(&clearClipboardTimer, SIGNAL(timeout()), this,
+ SLOT(clearClipboard()));
pwdConfig.selected = 0;
if (!checkConfig()) {
// no working config
@@ -353,6 +357,10 @@ bool MainWindow::checkConfig() {
}
pass->updateEnv();
+ clearPanelTimer.setInterval(1000 *
+ QtPassSettings::getAutoclearPanelSeconds());
+ clearClipboardTimer.setInterval(1000 * QtPassSettings::getAutoclearSeconds());
+
if (!QtPassSettings::isUseGit() ||
(QtPassSettings::getGitExecutable().isEmpty() &&
QtPassSettings::getPassExecutable().isEmpty())) {
@@ -483,6 +491,11 @@ void MainWindow::config() {
if (freshStart && Util::checkConfig())
config();
pass->updateEnv();
+ clearPanelTimer.setInterval(1000 *
+ QtPassSettings::getAutoclearPanelSeconds());
+ clearClipboardTimer.setInterval(1000 *
+ QtPassSettings::getAutoclearSeconds());
+
if (!QtPassSettings::isUseGit() ||
(QtPassSettings::getGitExecutable().isEmpty() &&
QtPassSettings::getPassExecutable().isEmpty())) {
@@ -632,12 +645,7 @@ void MainWindow::executeWrapperStarted() {
ui->textBrowser->clear();
ui->textBrowser->setTextColor(Qt::black);
enableUiElements(false);
- if (autoclearTimer != NULL) {
- autoclearTimer->stop();
- // TODO(bezet): why dynamic allocation?
- delete autoclearTimer;
- autoclearTimer = NULL;
- }
+ clearPanelTimer.stop();
}
/**
@@ -664,8 +672,7 @@ void MainWindow::readyRead(bool finished = false) {
if (QtPassSettings::getClipBoardType() == Enums::CLIPBOARD_ALWAYS)
copyTextToClipboard(tokens[0]);
if (QtPassSettings::isUseAutoclearPanel()) {
- QTimer::singleShot(1000 * QtPassSettings::getAutoclearPanelSeconds(),
- this, SLOT(clearPanel(true)));
+ clearPanelTimer.start();
}
if (QtPassSettings::isHidePassword() &&
!QtPassSettings::isUseTemplate()) {
@@ -716,14 +723,7 @@ void MainWindow::readyRead(bool finished = false) {
addToGridLayout(0, tr("Password"), password);
}
if (QtPassSettings::isUseAutoclearPanel()) {
- autoclearPass = output;
- autoclearTimer = new QTimer(this);
- autoclearTimer->setSingleShot(true);
- autoclearTimer->setInterval(1000 *
- QtPassSettings::getAutoclearPanelSeconds());
- connect(autoclearTimer, SIGNAL(timeout()), this,
- SLOT(clearPanel(true)));
- autoclearTimer->start();
+ clearPanelTimer.start();
}
}
output.replace(QRegExp("<"), "&lt;");
@@ -791,6 +791,12 @@ void MainWindow::clearPanel(bool notify = true) {
}
/**
+ * @brief MainWindow::clearPanel because slots needs the same amout of params as
+ * signals
+ */
+void MainWindow::clearPanel() { clearPanel(true); }
+
+/**
* @brief MainWindow::processFinished process is finished, if there is another
* one queued up to run, start it.
* @param exitCode
@@ -1469,8 +1475,7 @@ void MainWindow::copyTextToClipboard(const QString &text) {
clippedText = text;
ui->statusBar->showMessage(tr("Copied to clipboard"), 2000);
if (QtPassSettings::isUseAutoclear()) {
- QTimer::singleShot(1000 * QtPassSettings::getAutoclearSeconds(), this,
- SLOT(clearClipboard()));
+ clearClipboardTimer.start();
}
}
diff --git a/mainwindow.h b/mainwindow.h
index 8af4ceb8..afd30c15 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -110,6 +110,7 @@ private slots:
void processError(QProcess::ProcessError);
void clearClipboard();
void clearPanel(bool notify);
+ void clearPanel();
void on_lineEdit_textChanged(const QString &arg1);
void on_lineEdit_returnPressed();
void on_addButton_clicked();
@@ -144,8 +145,8 @@ private:
QTreeView *treeView;
QProcess fusedav;
QString clippedText;
- QString autoclearPass;
- QTimer *autoclearTimer;
+ QTimer clearPanelTimer;
+ QTimer clearClipboardTimer;
actionType currentAction;
QString lastDecrypt;
QQueue<execQueueItem> *execQueue;