diff options
-rw-r--r-- | README.md | 16 | ||||
-rw-r--r-- | mainwindow.cpp | 44 | ||||
-rw-r--r-- | mainwindow.h | 13 | ||||
-rw-r--r-- | mainwindow.ui | 13 | ||||
-rw-r--r-- | qtpass.pro | 3 |
5 files changed, 73 insertions, 16 deletions
@@ -15,6 +15,20 @@ TODO ---- 1. ~~non-blocking actions~~ 2. ~~multi-lingual~~ -3. filtering and autocomplete +3. ~~filtering and autocomplete~~ 4. edit, insert 5. gpg-id management (per-folder) + +Instalation +----------- +On most systems all you need is: +`qmake && make && make install` + +On MacOsX: +`qmake && make && macdeployqt QtPass.app -dmg ` + +Further reading +--------------- +[Documentation](http://ijhack.github.io/qtpass/) + +[Source code](https://github.com/IJHack/qtpass) diff --git a/mainwindow.cpp b/mainwindow.cpp index 9255063d..05b2bfe9 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -221,6 +221,7 @@ void MainWindow::readyRead() { /** * @brief MainWindow::clearClipboard + * @TODO check clipboard content (only clear if contains the password) */ void MainWindow::clearClipboard() { @@ -259,6 +260,7 @@ void MainWindow::processFinished(int exitCode, QProcess::ExitStatus exitStatus) void MainWindow::enableUiElements(bool state) { ui->updateButton->setEnabled(state); ui->treeView->setEnabled(state); + ui->lineEdit->setEnabled(state); } /** @@ -340,17 +342,49 @@ void MainWindow::on_lineEdit_textChanged(const QString &arg1) selectFirstFile(); } +/** + * @brief MainWindow::on_lineEdit_returnPressed + */ void MainWindow::on_lineEdit_returnPressed() { selectFirstFile(); - // TODO open selected item ;-) + on_treeView_clicked(ui->treeView->currentIndex()); } +/** + * @brief MainWindow::selectFirstFile + */ void MainWindow::selectFirstFile() { - QModelIndex index; - QItemSelection selection; + QModelIndex index = proxyModel.mapFromSource(model.setRootPath(passStore)); + index = firstFile(index); + ui->treeView->setCurrentIndex(index); +} - //selectionModel->setCurrentIndex(index, QItemSelectionModel::Select); - selectionModel->select(selection, QItemSelectionModel::ClearAndSelect); +/** + * @brief MainWindow::firstFile + * @param parentIndex + * @return QModelIndex + */ +QModelIndex MainWindow::firstFile(QModelIndex parentIndex) { + QModelIndex index = parentIndex; + int numRows = proxyModel.rowCount(parentIndex); + for (int row = 0; row < numRows; ++row) { + index = proxyModel.index(row, 0, parentIndex); + if (model.fileInfo(proxyModel.mapToSource(index)).isFile()) { + return index; + } + if (proxyModel.hasChildren(index)) { + return firstFile(index); + } + } + return index; +} + +/** + * @brief MainWindow::on_clearButton_clicked + */ +void MainWindow::on_clearButton_clicked() +{ + ui->lineEdit->clear(); } diff --git a/mainwindow.h b/mainwindow.h index 1a993faf..33c17eef 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -35,16 +35,18 @@ private slots: void processFinished(int, QProcess::ExitStatus); void processError(QProcess::ProcessError); void clearClipboard(); - void on_lineEdit_textChanged(const QString &arg1); - void on_lineEdit_returnPressed(); + void on_clearButton_clicked(); + private: Ui::MainWindow *ui; QFileSystemModel model; StoreModel proxyModel; QItemSelectionModel *selectionModel; + QProcess *process; + Dialog* d; bool usePass; bool useClipboard; bool useAutoclear; @@ -52,16 +54,15 @@ private: QString passStore; QString passExecutable; QString gitExecutable; - QString gpgExecutable; - QProcess *process; - Dialog* d; + QString gpgExecutable; + actionType currentAction; void updateText(); void executePass(QString); void executeWrapper(QString, QString); void config(); void enableUiElements(bool); void selectFirstFile(); - actionType currentAction; + QModelIndex firstFile(QModelIndex parentIndex); }; #endif // MAINWINDOW_H diff --git a/mainwindow.ui b/mainwindow.ui index 500a0375..dc57ca75 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -36,11 +36,18 @@ <item> <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <layout class="QVBoxLayout" name="verticalLayout_3"> - <item> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="1" column="1"> <widget class="QLineEdit" name="lineEdit"/> </item> - <item> + <item row="1" column="2"> + <widget class="QToolButton" name="clearButton"> + <property name="text"> + <string>X</string> + </property> + </widget> + </item> + <item row="2" column="1"> <widget class="QTreeView" name="treeView"/> </item> </layout> @@ -41,7 +41,8 @@ win32 { ICON = artwork/icon.icns } -OTHER_FILES += LICENSE +OTHER_FILES += LICENSE \ + README.md target.path = /usr/local/bin/ INSTALLS += target |