diff options
author | Jonathan Klimt <jounathaen@mail.de> | 2016-11-17 17:14:34 +0100 |
---|---|---|
committer | Jonathan Klimt <jounathaen@mail.de> | 2016-11-17 17:14:34 +0100 |
commit | 81287f0af4fe41328a9483a18f41c3d7a6bdbfe5 (patch) | |
tree | a6821e09ca64c391150966c22bfe954f1359d3e3 | |
parent | 160c7c67188a35e995b5ac24a3c66149da097229 (diff) |
UI improvements: improved Mainwindow, treeView can be deselected
-rw-r--r-- | deselectabletreeview.h | 38 | ||||
-rw-r--r-- | mainwindow.cpp | 13 | ||||
-rw-r--r-- | mainwindow.h | 5 | ||||
-rw-r--r-- | mainwindow.ui | 60 | ||||
-rw-r--r-- | qtpass.pro | 5 |
5 files changed, 85 insertions, 36 deletions
diff --git a/deselectabletreeview.h b/deselectabletreeview.h new file mode 100644 index 00000000..4209b0ee --- /dev/null +++ b/deselectabletreeview.h @@ -0,0 +1,38 @@ +#ifndef DESELECTABLETREEVIEW_H +#define DESELECTABLETREEVIEW_H +/* taken from http://stackoverflow.com/questions/2761284/ thanks to Yassir Ennazk */ +#include "QTreeView" +#include "QMouseEvent" +#include "QDebug" +#include "mainwindow.h" + +class DeselectableTreeView : public QTreeView +{ + Q_OBJECT + +public: + DeselectableTreeView(QWidget *parent) : QTreeView(parent) {} + virtual ~DeselectableTreeView() {} + +signals: + void emptyClicked(); + +private: + virtual void mousePressEvent(QMouseEvent *event) + { + QModelIndex item = indexAt(event->pos()); + bool selected = selectionModel()->isSelected(indexAt(event->pos())); + QTreeView::mousePressEvent(event); + if ((item.row() == -1 && item.column() == -1) || selected) + { + clearSelection(); + const QModelIndex index; + selectionModel()->setCurrentIndex(index, QItemSelectionModel::Select); + emit emptyClicked(); + //QTreeView::mousePressEvent(event); + + } + } +}; + +#endif // DESELECTABLETREEVIEW_H diff --git a/mainwindow.cpp b/mainwindow.cpp index 3f6a364d..ba5ffba1 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -54,8 +54,6 @@ MainWindow::MainWindow(QWidget *parent) QtPass = NULL; QTimer::singleShot(10, this, SLOT(focusInput())); - treeview(); - // Add a Actions to the Add-Button QIcon addFileIcon = QIcon::fromTheme("file_new"); QIcon addFolderIcon = QIcon::fromTheme("folder_new"); @@ -378,7 +376,7 @@ bool MainWindow::checkConfig() { ui->treeView->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->treeView, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(showContextMenu(const QPoint &))); - + connect(ui->treeView, SIGNAL(emptyClicked()), this, SLOT(deselect())); ui->textBrowser->setOpenExternalLinks(true); ui->textBrowser->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->textBrowser, SIGNAL(customContextMenuRequested(const QPoint &)), @@ -428,7 +426,6 @@ bool MainWindow::checkConfig() { void MainWindow::config() { QScopedPointer<ConfigDialog> d(new ConfigDialog(this)); d->setModal(true); - // Automatically default to pass if it's available usePass = freshStart ? QFile(passExecutable).exists() : usePass; @@ -692,6 +689,7 @@ void MainWindow::on_treeView_clicked(const QModelIndex &index) { "-d --quiet --yes --no-encrypt-to --batch --use-agent \"" + file + '"'); } else { + clearPanel(); ui->editButton->setEnabled(false); ui->deleteButton->setEnabled(true); } @@ -720,6 +718,13 @@ void MainWindow::on_treeView_doubleClicked(const QModelIndex &index) { } } +void MainWindow::deselect(){ + currentDir = "/"; + setClippedPassword(""); + ui->Passwordname->setText(""); + clearPanel(); +} + /** * @brief MainWindow::executePass easy wrapper for running pass * @param args diff --git a/mainwindow.h b/mainwindow.h index 6262a279..44d2b320 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -87,12 +87,16 @@ public: passwordConfiguration pwdConfig; + protected: void closeEvent(QCloseEvent *event); void keyPressEvent(QKeyEvent *event); void changeEvent(QEvent *event); bool eventFilter(QObject *obj, QEvent *event); +public slots: + void deselect(); + private slots: void on_updateButton_clicked(); void on_pushButton_clicked(); @@ -131,6 +135,7 @@ private: StoreModel proxyModel; QScopedPointer<QItemSelectionModel> selectionModel; QScopedPointer<QProcess> process; + QTreeView *treeView; bool usePass; clipBoardType useClipboard; bool useAutoclear; diff --git a/mainwindow.ui b/mainwindow.ui index e396bba2..8f77a51f 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -289,38 +289,24 @@ <number>5</number> </property> <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLineEdit" name="lineEdit"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>26</height> - </size> - </property> - <property name="text"> - <string/> - </property> - <property name="placeholderText"> - <string>Search Password</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="QTreeView" name="treeView"> - <property name="frameShape"> - <enum>QFrame::NoFrame</enum> + <widget class="QLineEdit" name="lineEdit"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>26</height> + </size> </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> + <property name="text"> + <string/> </property> - <property name="tabKeyNavigation"> - <bool>true</bool> + <property name="placeholderText"> + <string>Search Password</string> </property> </widget> </item> + <item> + <widget class="DeselectableTreeView" name="treeView"/> + </item> </layout> </widget> <widget class="QWidget" name="verticalLayoutWidget"> @@ -432,7 +418,10 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:12px; margin-bottom:12px; 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:13pt; font-weight:600; color:#333333;">QtPass</span><span style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; color:#333333;"> is a GUI for </span><a href="https://www.passwordstore.org/"><span style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; text-decoration: underline; color:#4183c4; background-color:transparent;">pass</span></a><span style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; color:#333333;">, the standard unix password manager.</span></p> <p style=" margin-top:12px; margin-bottom:12px; 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:13pt; color:#333333;"><br />Please report any </span><a href="https://github.com/IJHack/qtpass/issues"><span style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; text-decoration: underline; color:#4183c4;">issues</span></a><span style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; color:#333333;"> you might have with this software.</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://qtpass.org/"><span style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; text-decoration: underline; color:#4183c4; background-color:transparent;">Documentation</span></a></p> -<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/IJHack/qtpass"><span style=" font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; text-decoration: underline; color:#4183c4; background-color:transparent;">Source code</span></a></p></body></html></string> +<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="https://github.com/IJHack/qtpass"><span style=" font-size:12pt; text-decoration: underline; color:#4183c4;">SourceCode</span></a></p></body></html></string> + </property> + <property name="acceptRichText"> + <bool>true</bool> </property> </widget> </item> @@ -498,9 +487,17 @@ p, li { white-space: pre-wrap; } </action> </widget> <layoutdefault spacing="6" margin="11"/> + <customwidgets> + <customwidget> + <class>DeselectableTreeView</class> + <extends>QTreeView</extends> + <header location="global">deselectabletreeview.h</header> + <slots> + <signal>signal1()</signal> + </slots> + </customwidget> + </customwidgets> <tabstops> - <tabstop>lineEdit</tabstop> - <tabstop>treeView</tabstop> <tabstop>textBrowser</tabstop> <tabstop>addButton</tabstop> <tabstop>editButton</tabstop> @@ -516,4 +513,7 @@ p, li { white-space: pre-wrap; } <include location="resources.qrc"/> </resources> <connections/> + <slots> + <slot>deselect()</slot> + </slots> </ui> @@ -41,7 +41,8 @@ HEADERS += mainwindow.h \ keygendialog.h \ trayicon.h \ passworddialog.h \ - qprogressindicator.h + qprogressindicator.h \ + deselectabletreeview.h FORMS += mainwindow.ui \ configdialog.ui \ @@ -92,7 +93,7 @@ isEmpty(QMAKE_LRELEASE) { unix { !exists($$QMAKE_LRELEASE) { greaterThan(QT_MAJOR_VERSION, 4) { - QMAKE_LRELEASE = lrelease-qt5 + QMAKE_LRELEASE = lrelease } else { QMAKE_LRELEASE = lrelease-qt4 } |