aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/ui/widgets/FilePage.cpp35
-rw-r--r--src/ui/widgets/FilePage.h13
2 files changed, 45 insertions, 3 deletions
diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp
index ca1e358f..3982630f 100644
--- a/src/ui/widgets/FilePage.cpp
+++ b/src/ui/widgets/FilePage.cpp
@@ -45,7 +45,7 @@ FilePage::FilePage(QWidget* parent, const QString& target_path)
connect(ui_->upPathButton, &QPushButton::clicked, ui_->treeView,
&FileTreeView::SlotUpLevel);
connect(ui_->refreshButton, &QPushButton::clicked, this,
- &FilePage::SlotGoPath);
+ &FilePage::SlotRefreshState);
connect(this->ui_->newDirButton, &QPushButton::clicked, ui_->treeView,
&FileTreeView::SlotMkdir);
@@ -85,6 +85,8 @@ FilePage::FilePage(QWidget* parent, const QString& target_path)
GetSettings().value("gnupg/non_ascii_at_file_operation", true).toBool());
switch_asc_mode_act->setChecked(ascii_mode_);
+ update_harddisk_menu();
+
connect(ui_->pathEdit, &QLineEdit::textChanged, [=]() {
auto path = ui_->pathEdit->text();
auto dir = QDir(path);
@@ -130,6 +132,11 @@ void FilePage::SlotGoPath() {
ui_->treeView->SlotGoPath(ui_->pathEdit->text());
}
+void FilePage::SlotRefreshState() {
+ update_harddisk_menu();
+ SlotGoPath();
+}
+
void FilePage::keyPressEvent(QKeyEvent* event) {
if (ui_->pathEdit->hasFocus() &&
(event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter)) {
@@ -206,4 +213,30 @@ auto FilePage::IsBatchMode() const -> bool {
}
auto FilePage::IsASCIIMode() const -> bool { return ascii_mode_; }
+
+auto FilePage::update_harddisk_menu() -> void {
+ if (harddisk_popup_menu_ != nullptr) {
+ harddisk_popup_menu_->deleteLater();
+ harddisk_popup_menu_ = nullptr;
+ }
+
+ harddisk_popup_menu_ = new QMenu(this);
+
+ for (const auto& storage_device : QStorageInfo::mountedVolumes()) {
+ LOG_D() << "found storage device: " << storage_device.rootPath() << " "
+ << storage_device.displayName() << " " << storage_device.isRoot();
+
+ auto* device_act = new QAction(storage_device.displayName(), this);
+ device_act->setData(storage_device.rootPath());
+ connect(device_act, &QAction::triggered, this, [=]() {
+ auto path = device_act->data().toString();
+ ui_->pathEdit->setText(path);
+ SlotGoPath();
+ });
+ harddisk_popup_menu_->addAction(device_act);
+ }
+
+ ui_->hardDiskButton->setMenu(harddisk_popup_menu_);
+}
+
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/FilePage.h b/src/ui/widgets/FilePage.h
index 9516db4e..62696b08 100644
--- a/src/ui/widgets/FilePage.h
+++ b/src/ui/widgets/FilePage.h
@@ -78,6 +78,12 @@ class FilePage : public QWidget {
*/
void SlotGoPath();
+ /**
+ * @brief
+ *
+ */
+ void SlotRefreshState();
+
signals:
/**
@@ -122,8 +128,9 @@ class FilePage : public QWidget {
QCompleter* path_edit_completer_; ///<
QStringListModel* path_complete_model_; ///<
- QMenu* popup_menu_{}; ///<
- QMenu* option_popup_menu_{}; ///<
+ QMenu* popup_menu_{}; ///<
+ QMenu* option_popup_menu_{}; ///<
+ QMenu* harddisk_popup_menu_{}; ///<
bool ascii_mode_;
private slots:
@@ -133,6 +140,8 @@ class FilePage : public QWidget {
*
*/
void update_main_basic_opera_menu(const QStringList&);
+
+ void update_harddisk_menu();
};
} // namespace GpgFrontend::UI