diff options
-rw-r--r-- | dialog.cpp | 40 | ||||
-rw-r--r-- | dialog.h | 4 | ||||
-rw-r--r-- | dialog.ui | 70 | ||||
-rw-r--r-- | main.cpp | 2 | ||||
-rw-r--r-- | mainwindow.cpp | 45 | ||||
-rw-r--r-- | mainwindow.h | 4 | ||||
-rw-r--r-- | mainwindow.ui | 19 |
7 files changed, 140 insertions, 44 deletions
@@ -215,6 +215,8 @@ void Dialog::on_checkBoxClipboard_clicked() { if (ui->checkBoxClipboard->isChecked()) { ui->checkBoxAutoclear->setEnabled(true); + ui->checkBoxHidePassword->setEnabled(true); + ui->checkBoxHideContent->setEnabled(true); if (ui->checkBoxAutoclear->isChecked()) { ui->spinBoxAutoclearSeconds->setEnabled(true); ui->labelSeconds->setEnabled(true); @@ -226,6 +228,8 @@ void Dialog::on_checkBoxClipboard_clicked() ui->checkBoxAutoclear->setEnabled(false); ui->spinBoxAutoclearSeconds->setEnabled(false); ui->labelSeconds->setEnabled(false); + ui->checkBoxHidePassword->setEnabled(false); + ui->checkBoxHideContent->setEnabled(false); } } @@ -291,3 +295,39 @@ void Dialog::on_checkBoxAutoclear_clicked() { on_checkBoxClipboard_clicked(); } + +/** + * @brief Dialog::hidePassword + * @return + */ +bool Dialog::hidePassword() +{ + return ui->checkBoxHidePassword->isChecked(); +} + +/** + * @brief Dialog::hideContent + * @return + */ +bool Dialog::hideContent() +{ + return ui->checkBoxHideContent->isChecked(); +} + +/** + * @brief Dialog::hidePassword + * @param hidePassword + */ +void Dialog::hidePassword(bool hidePassword) +{ + ui->checkBoxHidePassword->setChecked(hidePassword); +} + +/** + * @brief Dialog::hideContent + * @param hideContent + */ +void Dialog::hideContent(bool hideContent) +{ + ui->checkBoxHideContent->setChecked(hideContent); +} @@ -23,6 +23,8 @@ public: void useClipboard(bool); void useAutoclear(bool); void setAutoclear(int); + void hidePassword(bool); + void hideContent(bool); QString getPassPath(); QString getGitPath(); QString getGpgPath(); @@ -31,6 +33,8 @@ public: bool useClipboard(); bool useAutoclear(); int getAutoclear(); + bool hidePassword(); + bool hideContent(); private slots: void on_radioButtonNative_clicked(); @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>469</width> - <height>370</height> + <width>507</width> + <height>446</height> </rect> </property> <property name="windowTitle"> @@ -20,9 +20,6 @@ <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"> @@ -37,6 +34,9 @@ </property> </widget> </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="passPath"/> + </item> </layout> </widget> </item> @@ -101,13 +101,23 @@ </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> + </property> + </widget> + </item> <item row="3" column="0"> <widget class="QGroupBox" name="groupBox"> <property name="title"> <string>Other</string> </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> + <layout class="QGridLayout" name="gridLayout_6"> + <item row="0" column="0"> <layout class="QGridLayout" name="gridLayout_5"> <item row="0" column="0"> <widget class="QLabel" name="labelStorePath"> @@ -116,6 +126,9 @@ </property> </widget> </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="storePath"/> + </item> <item row="0" column="2"> <widget class="QToolButton" name="toolButtonStore"> <property name="text"> @@ -123,52 +136,53 @@ </property> </widget> </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="storePath"/> - </item> </layout> </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <item> + <item row="1" column="0"> + <layout class="QGridLayout" name="gridLayout_7"> + <item row="0" column="0"> <widget class="QCheckBox" name="checkBoxClipboard"> <property name="text"> <string>Clipboard</string> </property> </widget> </item> - <item> + <item row="0" column="1"> <widget class="QCheckBox" name="checkBoxAutoclear"> <property name="text"> <string>Autoclear</string> </property> </widget> </item> - <item> - <widget class="QSpinBox" name="spinBoxAutoclearSeconds"/> - </item> - <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"> + <string>Hide password</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="checkBoxHideContent"> + <property name="text"> + <string>Hide content</string> + </property> + </widget> + </item> </layout> </item> </layout> </widget> </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> - </property> - </widget> - </item> </layout> </widget> <resources/> @@ -9,7 +9,7 @@ int main(int argc, char *argv[]) QCoreApplication::setOrganizationName("IJHack"); QCoreApplication::setOrganizationDomain("ijhack.org"); QCoreApplication::setApplicationName("QtPass"); - QCoreApplication::setApplicationVersion("0.0.1"); + QCoreApplication::setApplicationVersion("0.1.0"); //Setup and load translator for localization QTranslator translator; diff --git a/mainwindow.cpp b/mainwindow.cpp index 61434024..bdf35e8f 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -12,7 +12,7 @@ MainWindow::MainWindow(QWidget *parent) : ui(new Ui::MainWindow) { process = new QProcess(this); - connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(readyRead())); +// connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(readyRead())); connect(process, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError))); connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processFinished(int, QProcess::ExitStatus))); ui->setupUi(this); @@ -38,6 +38,8 @@ void MainWindow::checkConfig() { useClipboard = (settings.value("useClipboard") == "true"); useAutoclear = (settings.value("useAutoclear") == "true"); autoclearSeconds = settings.value("autoclearSeconds").toInt(); + hidePassword = (settings.value("hidePassword") == "true"); + hideContent = (settings.value("hideContent") == "true"); passStore = settings.value("passStore").toString(); if (passStore == "") { @@ -103,6 +105,8 @@ void MainWindow::checkConfig() { ui->treeView->setHeaderHidden(true); ui->treeView->setIndentation(15); ui->treeView->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); + + ui->textBrowser->setOpenExternalLinks(true); } /** @@ -120,6 +124,8 @@ void MainWindow::config() { d->useClipboard(useClipboard); d->useAutoclear(useAutoclear); d->setAutoclear(autoclearSeconds); + d->hidePassword(hidePassword); + d->hideContent(hideContent); if (d->exec()) { if (d->result() == QDialog::Accepted) { @@ -131,6 +137,8 @@ void MainWindow::config() { useClipboard = d->useClipboard(); useAutoclear = d->useAutoclear(); autoclearSeconds = d->getAutoclear(); + hidePassword = d->hidePassword(); + hideContent = d->hideContent(); QSettings settings("IJHack", "QtPass"); @@ -142,6 +150,8 @@ void MainWindow::config() { settings.setValue("useClipboard", useClipboard ? "true" : "false"); settings.setValue("useAutoclear", useAutoclear ? "true" : "false"); settings.setValue("autoclearSeconds", autoclearSeconds); + settings.setValue("hidePassword", hidePassword ? "true" : "false"); + settings.setValue("hideContent", hideContent ? "true" : "false"); ui->treeView->setRootIndex(model.setRootPath(passStore)); } @@ -206,7 +216,7 @@ void MainWindow::executeWrapper(QString app, QString args) { /** * @brief MainWindow::readyRead */ -void MainWindow::readyRead() { +void MainWindow::readyRead(bool finished = false) { QString output = ui->textBrowser->document()->toPlainText(); QString error = process->readAllStandardError(); if (error.size() > 0) { @@ -214,6 +224,24 @@ void MainWindow::readyRead() { output += error; } else { output += process->readAllStandardOutput(); + if (finished && currentAction == GPG) { + QClipboard *clip = QApplication::clipboard(); + QStringList tokens = output.split("\n"); + if (useClipboard) { + clip->setText(tokens[0]); + ui->statusBar->showMessage(tr("Password copied to clipboard"), 3000); + if (useAutoclear) { + QTimer::singleShot(1000*autoclearSeconds, this, SLOT(clearClipboard())); + } + } + if (hidePassword) { + tokens.pop_front(); + output = tokens.join("\n"); + } + if (hideContent) { + output = tr("Content hidden"); + } + } } ui->textBrowser->setText(output); } @@ -238,18 +266,9 @@ void MainWindow::processFinished(int exitCode, QProcess::ExitStatus exitStatus) if (exitStatus != QProcess::NormalExit || exitCode > 0) { ui->textBrowser->setTextColor(Qt::red); } - readyRead(); + readyRead(true); enableUiElements(true); - if (currentAction == GPG && useClipboard) { - //Copy first line to clipboard - QClipboard *clip = QApplication::clipboard(); - QStringList tokens = ui->textBrowser->document()->toPlainText().split("\n",QString::SkipEmptyParts); - clip->setText(tokens[0]); - ui->statusBar->showMessage(tr("Password copied to clipboard"), 3000); - if (useAutoclear) { - QTimer::singleShot(1000*autoclearSeconds, this, SLOT(clearClipboard())); - } - } + } /** diff --git a/mainwindow.h b/mainwindow.h index 33c17eef..33725c3c 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -31,7 +31,7 @@ private slots: void on_updateButton_clicked(); void on_treeView_clicked(const QModelIndex &index); void on_configButton_clicked(); - void readyRead(); + void readyRead(bool finished); void processFinished(int, QProcess::ExitStatus); void processError(QProcess::ProcessError); void clearClipboard(); @@ -50,6 +50,8 @@ private: bool usePass; bool useClipboard; bool useAutoclear; + bool hidePassword; + bool hideContent; int autoclearSeconds; QString passStore; QString passExecutable; diff --git a/mainwindow.ui b/mainwindow.ui index dc57ca75..48899d0e 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -53,7 +53,24 @@ </layout> </item> <item> - <widget class="QTextBrowser" name="textBrowser"/> + <widget class="QTextBrowser" name="textBrowser"> + <property name="html"> + <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'.Helvetica Neue DeskInterface'; font-size:13pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:25.6px;"><span style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:16px; color:#333333;">QtPass is a gui forĀ </span><a href="http://www.passwordstore.org/"><span style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:16px; text-decoration: underline; color:#4183c4; background-color:transparent;">pass</span></a></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:x-large; font-weight:600; color:#333333;">ALPHA release</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:x-large; font-weight:600; color:#333333;"><br /></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:x-large; font-weight:600; color:#333333;">TODO</span></p> +<ol style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; -qt-list-indent: 1;"><li style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:16px; color:#333333;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16px;">edit</span></li> +<li style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:16px; color:#333333;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16px;">insert</span></li> +<li style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:16px; color:#333333;" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:16px;">gpg-id management</span></li></ol> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:16px; color:#333333;"><br /></p> +<p style=" margin-top:0px; margin-bottom:16px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:25.6px;"><a href="http://ijhack.github.io/qtpass/"><span style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:16px; text-decoration: underline; color:#4183c4; background-color:transparent;">Documentation</span></a></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; line-height:25.6px;"><a href="https://github.com/IJHack/qtpass"><span style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:16px; text-decoration: underline; color:#4183c4; background-color:transparent;">Source code</span></a></p></body></html></string> + </property> + </widget> </item> </layout> </item> |