diff options
author | Anne Jan Brouwer <ajbrouwer@totalactivemedia.nl> | 2014-08-04 11:39:57 +0200 |
---|---|---|
committer | Anne Jan Brouwer <ajbrouwer@totalactivemedia.nl> | 2014-08-04 11:39:57 +0200 |
commit | 7c51eb9904df64f77d8b52b00b3bf65aa4c98b1f (patch) | |
tree | 1499ed3ff0cd851ac947d8dae75a6b9ee2311746 | |
parent | bd56bc04af596c91c7056c2e38786098863f6507 (diff) |
config and autoclear
-rw-r--r-- | README.md | 7 | ||||
-rw-r--r-- | dialog.cpp | 84 | ||||
-rw-r--r-- | dialog.h | 10 | ||||
-rw-r--r-- | dialog.ui | 164 | ||||
-rw-r--r-- | mainwindow.cpp | 38 | ||||
-rw-r--r-- | mainwindow.h | 4 | ||||
-rw-r--r-- | mainwindow.ui | 6 |
7 files changed, 233 insertions, 80 deletions
@@ -14,6 +14,7 @@ Read only access to password-store content. TODO ---- 1. ~~non-blocking actions~~ -2. multi-lingual -3. edit, insert -4. gpg-id management (per-folder) +2. ~~multi-lingual~~ +3. filtering and autocomplete +4. edit, insert +5. gpg-id management (per-folder) @@ -207,3 +207,87 @@ void Dialog::on_toolButtonStore_clicked() ui->storePath->setText(store); } } + +/** + * @brief Dialog::on_checkBoxClipboard_clicked + */ +void Dialog::on_checkBoxClipboard_clicked() +{ + if (ui->checkBoxClipboard->isChecked()) { + ui->checkBoxAutoclear->setEnabled(true); + if (ui->checkBoxAutoclear->isChecked()) { + ui->spinBoxAutoclearSeconds->setEnabled(true); + ui->labelSeconds->setEnabled(true); + } else { + ui->spinBoxAutoclearSeconds->setEnabled(false); + ui->labelSeconds->setEnabled(false); + } + } else { + ui->checkBoxAutoclear->setEnabled(false); + ui->spinBoxAutoclearSeconds->setEnabled(false); + ui->labelSeconds->setEnabled(false); + } +} + +/** + * @brief Dialog::useClipboard + */ +void Dialog::useClipboard(bool useClipboard) +{ + ui->checkBoxClipboard->setChecked(useClipboard); + on_checkBoxClipboard_clicked(); +} + +/** + * @brief Dialog::useAutoclear + * @param useAutoclear + */ +void Dialog::useAutoclear(bool useAutoclear) +{ + ui->checkBoxAutoclear->setChecked(useAutoclear); + on_checkBoxAutoclear_clicked(); +} + +/** + * @brief Dialog::setAutoclear + * @param seconds + */ +void Dialog::setAutoclear(int seconds) +{ + ui->spinBoxAutoclearSeconds->setValue(seconds); +} + +/** + * @brief Dialog::useClipboard + * @return + */ +bool Dialog::useClipboard() +{ + return ui->checkBoxClipboard->isChecked(); +} + +/** + * @brief Dialog::useAutoclear + * @return + */ +bool Dialog::useAutoclear() +{ + return ui->checkBoxAutoclear->isChecked(); +} + +/** + * @brief Dialog::getAutoclear + * @return + */ +int Dialog::getAutoclear() +{ + return ui->spinBoxAutoclearSeconds->value(); +} + +/** + * @brief Dialog::on_checkBoxAutoclear_clicked + */ +void Dialog::on_checkBoxAutoclear_clicked() +{ + on_checkBoxClipboard_clicked(); +} @@ -20,11 +20,17 @@ public: void setGpgPath(QString); void setStorePath(QString); void usePass(bool); + void useClipboard(bool); + void useAutoclear(bool); + void setAutoclear(int); QString getPassPath(); QString getGitPath(); QString getGpgPath(); QString getStorePath(); bool usePass(); + bool useClipboard(); + bool useAutoclear(); + int getAutoclear(); private slots: void on_radioButtonNative_clicked(); @@ -34,6 +40,10 @@ private slots: void on_toolButtonPass_clicked(); void on_toolButtonStore_clicked(); + void on_checkBoxClipboard_clicked(); + + void on_checkBoxAutoclear_clicked(); + private: Ui::Dialog *ui; void setGroupBoxState(); @@ -6,33 +6,41 @@ <rect> <x>0</x> <y>0</y> - <width>418</width> - <height>330</height> + <width>469</width> + <height>370</height> </rect> </property> <property name="windowTitle"> <string>Configuration</string> </property> - <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> + <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="1"> + <widget class="QLineEdit" name="passPath"/> + </item> + <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> + </layout> + </widget> </item> - <item> + <item row="1" column="0"> <widget class="QGroupBox" name="groupBoxNative"> <property name="title"> <string>Native</string> @@ -45,14 +53,14 @@ <widget class="QLineEdit" name="gitPath"/> </item> <item row="0" column="0"> - <widget class="QLabel" name="label_2"> + <widget class="QLabel" name="labelGitPath"> <property name="text"> <string>Executable git</string> </property> </widget> </item> <item row="1" column="0"> - <widget class="QLabel" name="label_3"> + <widget class="QLabel" name="labelGpgPath"> <property name="text"> <string>Executable gpg</string> </property> @@ -75,59 +83,83 @@ </layout> </widget> </item> - <item> - <widget class="QGroupBox" name="groupBoxPass"> - <property name="title"> - <string>Pass</string> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="text"> - <string>Executable pass</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="passPath"/> - </item> - <item row="0" column="2"> - <widget class="QToolButton" name="toolButtonPass"> - <property name="text"> - <string>...</string> - </property> - </widget> - </item> - </layout> - </widget> + <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> + <item row="3" column="0"> <widget class="QGroupBox" name="groupBox"> <property name="title"> <string>Other</string> </property> - <layout class="QGridLayout" name="gridLayout_3"> - <item row="0" column="1"> - <widget class="QLineEdit" name="storePath"/> - </item> - <item row="0" column="0"> - <widget class="QLabel" name="label_4"> - <property name="text"> - <string>Folder password-store</string> - </property> - </widget> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QGridLayout" name="gridLayout_5"> + <item row="0" column="0"> + <widget class="QLabel" name="labelStorePath"> + <property name="text"> + <string>Folder password-store</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QToolButton" name="toolButtonStore"> + <property name="text"> + <string>...</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="storePath"/> + </item> + </layout> </item> - <item row="0" column="2"> - <widget class="QToolButton" name="toolButtonStore"> - <property name="text"> - <string>...</string> - </property> - </widget> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QCheckBox" name="checkBoxClipboard"> + <property name="text"> + <string>Clipboard</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBoxAutoclear"> + <property name="text"> + <string>Autoclear</string> + </property> + </widget> + </item> + <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> </widget> </item> - <item> + <item row="5" column="0"> <widget class="QDialogButtonBox" name="buttonBox"> <property name="orientation"> <enum>Qt::Horizontal</enum> diff --git a/mainwindow.cpp b/mainwindow.cpp index 8cac5fd8..a5f5a770 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1,6 +1,7 @@ #include "mainwindow.h" #include "ui_mainwindow.h" -#include "qclipboard.h" +#include <QClipboard> +#include <QTimer> /** * @brief MainWindow::MainWindow @@ -34,6 +35,10 @@ void MainWindow::checkConfig() { usePass = (settings.value("usePass") == "true"); + useClipboard = (settings.value("useClipboard") == "true"); + useAutoclear = (settings.value("useAutoclear") == "true"); + autoclearSeconds = settings.value("autoclearSeconds").toInt(); + passStore = settings.value("passStore").toString(); if (passStore == "") { passStore = QDir::homePath()+"/.password-store/"; @@ -100,6 +105,9 @@ void MainWindow::config() { d->setGpgPath(gpgExecutable); d->setStorePath(passStore); d->usePass(usePass); + d->useClipboard(useClipboard); + d->useAutoclear(useAutoclear); + d->setAutoclear(autoclearSeconds); if (d->exec()) { if (d->result() == QDialog::Accepted) { @@ -108,6 +116,9 @@ void MainWindow::config() { gpgExecutable = d->getGpgPath(); passStore = d->getStorePath(); usePass = d->usePass(); + useClipboard = d->useClipboard(); + useAutoclear = d->useAutoclear(); + autoclearSeconds = d->getAutoclear(); QSettings settings("IJHack", "QtPass"); @@ -116,6 +127,9 @@ void MainWindow::config() { settings.setValue("gpgExecutable", gpgExecutable); settings.setValue("passStore", passStore); settings.setValue("usePass", usePass ? "true" : "false"); + settings.setValue("useClipboard", useClipboard ? "true" : "false"); + settings.setValue("useAutoclear", useAutoclear ? "true" : "false"); + settings.setValue("autoclearSeconds", autoclearSeconds); ui->treeView->setRootIndex(model.setRootPath(passStore)); } @@ -186,12 +200,15 @@ void MainWindow::readyRead() { output += process->readAllStandardOutput(); } ui->textBrowser->setText(output); +} - //Copy first line to clipboard - QClipboard *clip = QApplication::clipboard(); - QStringList tokens = output.split("\n",QString::SkipEmptyParts); - clip->setText(tokens[0]); - +/** + * @brief MainWindow::clearClipboard + */ +void MainWindow::clearClipboard() +{ + QClipboard *clipboard = QApplication::clipboard(); + clipboard->clear(); } /** @@ -205,6 +222,15 @@ void MainWindow::processFinished(int exitCode, QProcess::ExitStatus exitStatus) } readyRead(); enableUiElements(true); + if (useClipboard) { + //Copy first line to clipboard + QClipboard *clip = QApplication::clipboard(); + QStringList tokens = ui->textBrowser->document()->toPlainText().split("\n",QString::SkipEmptyParts); + clip->setText(tokens[0]); + if (useAutoclear) { + QTimer::singleShot(1000*autoclearSeconds, this, SLOT(clearClipboard())); + } + } } /** diff --git a/mainwindow.h b/mainwindow.h index 58f912e6..7f7db983 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -31,11 +31,15 @@ private slots: void readyRead(); void processFinished(int, QProcess::ExitStatus); void processError(QProcess::ProcessError); + void clearClipboard(); private: Ui::MainWindow *ui; QFileSystemModel model; bool usePass; + bool useClipboard; + bool useAutoclear; + int autoclearSeconds; QString passStore; QString passExecutable; QString gitExecutable; diff --git a/mainwindow.ui b/mainwindow.ui index 947ffffc..5ef1bbf7 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -45,16 +45,12 @@ </item> </layout> </widget> - <action name="actionStuff"> - <property name="text"> - <string>Stuff</string> - </property> - </action> <action name="actionQtpass"> <property name="text"> <string>qtpass</string> </property> </action> + <widget class="QStatusBar" name="statusBar"/> </widget> <layoutdefault spacing="6" margin="11"/> <resources/> |