summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Klimt <jounathaen@mail.de>2016-11-17 17:14:34 +0100
committerJonathan Klimt <jounathaen@mail.de>2016-11-17 17:14:34 +0100
commit81287f0af4fe41328a9483a18f41c3d7a6bdbfe5 (patch)
treea6821e09ca64c391150966c22bfe954f1359d3e3
parent160c7c67188a35e995b5ac24a3c66149da097229 (diff)
UI improvements: improved Mainwindow, treeView can be deselected
-rw-r--r--deselectabletreeview.h38
-rw-r--r--mainwindow.cpp13
-rw-r--r--mainwindow.h5
-rw-r--r--mainwindow.ui60
-rw-r--r--qtpass.pro5
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; }
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; font-weight:600; color:#333333;&quot;&gt;QtPass&lt;/span&gt;&lt;span style=&quot; font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; color:#333333;&quot;&gt; is a GUI for &lt;/span&gt;&lt;a href=&quot;https://www.passwordstore.org/&quot;&gt;&lt;span style=&quot; font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; text-decoration: underline; color:#4183c4; background-color:transparent;&quot;&gt;pass&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; color:#333333;&quot;&gt;, the standard unix password manager.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; color:#333333;&quot;&gt;&lt;br /&gt;Please report any &lt;/span&gt;&lt;a href=&quot;https://github.com/IJHack/qtpass/issues&quot;&gt;&lt;span style=&quot; font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; text-decoration: underline; color:#4183c4;&quot;&gt;issues&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; color:#333333;&quot;&gt; you might have with this software.&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;https://qtpass.org/&quot;&gt;&lt;span style=&quot; font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; text-decoration: underline; color:#4183c4; background-color:transparent;&quot;&gt;Documentation&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;https://github.com/IJHack/qtpass&quot;&gt;&lt;span style=&quot; font-family:'Helvetica Neue,Helvetica,Segoe UI,Arial,freesans,sans-serif'; font-size:13pt; text-decoration: underline; color:#4183c4; background-color:transparent;&quot;&gt;Source code&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;https://github.com/IJHack/qtpass&quot;&gt;&lt;span style=&quot; font-size:12pt; text-decoration: underline; color:#4183c4;&quot;&gt;SourceCode&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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>
diff --git a/qtpass.pro b/qtpass.pro
index 25983378..18236b1f 100644
--- a/qtpass.pro
+++ b/qtpass.pro
@@ -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
}