summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnne Jan Brouwer <brouwer@annejan.com>2014-08-15 23:10:02 +0200
committerAnne Jan Brouwer <ajbrouwer@totalactivemedia.nl>2014-08-15 23:10:02 +0200
commitc27ed019de512493a60d1ea2d779e028e2824ecf (patch)
tree91d159d8d60de484a66c2e6b83e434897fa28a05
parentfb797ea513e15c7cfc9ea9ed197fc10db23a1674 (diff)
working keyboard magic
-rw-r--r--README.md16
-rw-r--r--mainwindow.cpp44
-rw-r--r--mainwindow.h13
-rw-r--r--mainwindow.ui13
-rw-r--r--qtpass.pro3
5 files changed, 73 insertions, 16 deletions
diff --git a/README.md b/README.md
index 004ef524..b04ccc5f 100644
--- a/README.md
+++ b/README.md
@@ -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>
diff --git a/qtpass.pro b/qtpass.pro
index 79e8ca5b..11311384 100644
--- a/qtpass.pro
+++ b/qtpass.pro
@@ -41,7 +41,8 @@ win32 {
ICON = artwork/icon.icns
}
-OTHER_FILES += LICENSE
+OTHER_FILES += LICENSE \
+ README.md
target.path = /usr/local/bin/
INSTALLS += target