From 1686b03031dff2b66d8a1c78db9e0465f8ea508c Mon Sep 17 00:00:00 2001 From: Saturneric Date: Tue, 6 Jul 2021 11:17:33 +0800 Subject: Improve UI. --- src/ui/widgets/FilePage.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/ui/widgets/FilePage.cpp') diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp index bab6cf68..e330eb68 100644 --- a/src/ui/widgets/FilePage.cpp +++ b/src/ui/widgets/FilePage.cpp @@ -46,15 +46,28 @@ FilePage::FilePage(QWidget *parent) : QWidget(parent) { createPopupMenu(); - upLevelButton = new QPushButton("Up"); + + upLevelButton = new QPushButton(); connect(upLevelButton, SIGNAL(clicked(bool)), this, SLOT(slotUpLevel())); + auto upPixmap = QPixmap(":up.png"); + upPixmap = upPixmap.scaled(18, 18, Qt::KeepAspectRatio, Qt::SmoothTransformation); + QIcon upButtonIcon(upPixmap); + upLevelButton->setIcon(upButtonIcon); + upLevelButton->setIconSize(upPixmap.rect().size()); + refreshButton = new QPushButton("Refresh"); connect(refreshButton, SIGNAL(clicked(bool)), this, SLOT(slotGoPath())); - goPathButton = new QPushButton("Go"); + goPathButton = new QPushButton(); connect(goPathButton, SIGNAL(clicked(bool)), this, SLOT(slotGoPath())); + auto updatePixmap = QPixmap(":refresh.png"); + updatePixmap = updatePixmap.scaled(18, 18, Qt::KeepAspectRatio, Qt::SmoothTransformation); + QIcon updateButtonIcon(updatePixmap); + goPathButton->setIcon(updateButtonIcon); + goPathButton->setIconSize(updatePixmap.rect().size()); + pathEdit = new QLineEdit(); pathEdit->setText(dirModel->rootPath()); -- cgit v1.2.3 From 4ada913c515cf090c65d9d155aa9880a50501591 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Mon, 12 Jul 2021 17:03:12 +0800 Subject: Project structure adjustment; Project configuration adjustment; Add version detection; UI interface improvements; Introduce JSON processing library; Update Documents; --- src/ui/widgets/FilePage.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/ui/widgets/FilePage.cpp') diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp index e330eb68..65755509 100644 --- a/src/ui/widgets/FilePage.cpp +++ b/src/ui/widgets/FilePage.cpp @@ -50,11 +50,15 @@ FilePage::FilePage(QWidget *parent) : QWidget(parent) { upLevelButton = new QPushButton(); connect(upLevelButton, SIGNAL(clicked(bool)), this, SLOT(slotUpLevel())); + QString buttonStyle = "QPushButton{border:none;background-color:rgba(255, 255, 255,100);}"; + + auto upPixmap = QPixmap(":up.png"); upPixmap = upPixmap.scaled(18, 18, Qt::KeepAspectRatio, Qt::SmoothTransformation); QIcon upButtonIcon(upPixmap); upLevelButton->setIcon(upButtonIcon); upLevelButton->setIconSize(upPixmap.rect().size()); + upLevelButton->setStyleSheet(buttonStyle); refreshButton = new QPushButton("Refresh"); connect(refreshButton, SIGNAL(clicked(bool)), this, SLOT(slotGoPath())); @@ -67,6 +71,7 @@ FilePage::FilePage(QWidget *parent) : QWidget(parent) { QIcon updateButtonIcon(updatePixmap); goPathButton->setIcon(updateButtonIcon); goPathButton->setIconSize(updatePixmap.rect().size()); + goPathButton->setStyleSheet(buttonStyle); pathEdit = new QLineEdit(); pathEdit->setText(dirModel->rootPath()); @@ -75,7 +80,7 @@ FilePage::FilePage(QWidget *parent) : QWidget(parent) { menuLayout->addWidget(upLevelButton); menuLayout->setStretchFactor(upLevelButton, 1); menuLayout->addWidget(pathEdit); - menuLayout->setStretchFactor(pathEdit, 8); + menuLayout->setStretchFactor(pathEdit, 10); menuLayout->addWidget(goPathButton); menuLayout->setStretchFactor(goPathButton, 1); // menuLayout->addWidget(refreshButton); -- cgit v1.2.3 From 3d8c8f3c4550d88d1bb16bda003c88fc69e6acc5 Mon Sep 17 00:00:00 2001 From: Saturneric Date: Mon, 19 Jul 2021 18:03:21 +0800 Subject: Improved and Modified. --- src/ui/widgets/FilePage.cpp | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'src/ui/widgets/FilePage.cpp') diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp index 65755509..b9602d58 100644 --- a/src/ui/widgets/FilePage.cpp +++ b/src/ui/widgets/FilePage.cpp @@ -105,17 +105,22 @@ FilePage::FilePage(QWidget *parent) : QWidget(parent) { } void FilePage::fileTreeViewItemClicked(const QModelIndex &index) { - mPath = dirModel->fileInfo(index).absoluteFilePath(); - qDebug() << "mPath" << mPath; + selectedPath = dirModel->fileInfo(index).absoluteFilePath(); + qDebug() << "selectedPath" << selectedPath; } void FilePage::slotUpLevel() { QModelIndex currentRoot = dirTreeView->rootIndex(); - mPath = dirModel->fileInfo(currentRoot.parent()).absoluteFilePath(); - auto fileInfo = QFileInfo(mPath); + + mPath = dirModel->fileInfo(currentRoot).absoluteFilePath(); + QDir dir(mPath); + dir.makeAbsolute(); + dir.setPath(QDir::cleanPath(dir.filePath(QStringLiteral("..")))); + mPath = dir.absolutePath(); + auto fileInfo = QFileInfo(dir.absolutePath()); if(fileInfo.isDir() && fileInfo.isReadable() && fileInfo.isExecutable()) { - dirTreeView->setRootIndex(currentRoot.parent()); pathEdit->setText(mPath); + slotGoPath(); } qDebug() << "Current Root mPath" << mPath; emit pathChanged(mPath); @@ -124,8 +129,9 @@ void FilePage::slotUpLevel() { void FilePage::fileTreeViewItemDoubleClicked(const QModelIndex &index) { mPath = dirModel->fileInfo(index).absoluteFilePath(); auto fileInfo = QFileInfo(mPath); + auto targetModelIndex = dirTreeView->model()->index(index.row(), 0, index.parent()); if(fileInfo.isDir() && fileInfo.isReadable() && fileInfo.isExecutable()) { - dirTreeView->setRootIndex(index); + dirTreeView->setRootIndex(targetModelIndex); pathEdit->setText(mPath); } qDebug() << "Index mPath" << mPath; @@ -133,7 +139,7 @@ void FilePage::fileTreeViewItemDoubleClicked(const QModelIndex &index) { } QString FilePage::getSelected() const { - return mPath; + return selectedPath; } void FilePage::slotGoPath() { @@ -177,10 +183,10 @@ void FilePage::createPopupMenu() { void FilePage::onCustomContextMenu(const QPoint &point) { QModelIndex index = dirTreeView->indexAt(point); - mPath = dirModel->fileInfo(index).absoluteFilePath(); - qDebug() << "Right Click" << mPath; + selectedPath = dirModel->fileInfo(index).absoluteFilePath(); + qDebug() << "Right Click" << selectedPath; if (index.isValid()) { - QFileInfo info(mPath); + QFileInfo info(selectedPath); encryptItemAct->setEnabled(info.isFile() && (info.suffix() != "gpg" && info.suffix() != "sig")); decryptItemAct->setEnabled(info.isFile() && info.suffix() == "gpg"); signItemAct->setEnabled(info.isFile() && (info.suffix() != "gpg" && info.suffix() != "sig")); @@ -252,3 +258,10 @@ void FilePage::slotVerifyItem() { if(mainWindow != nullptr) mainWindow->slotFileVerify(); } + +void FilePage::keyPressEvent(QKeyEvent *event) { + qDebug() << "Key Press" << event->key(); + if(event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) { + slotGoPath(); + } +} -- cgit v1.2.3