feat: open containing folder
This commit is contained in:
parent
00168a34f0
commit
9e1b10831a
|
@ -52,6 +52,7 @@ void ActionManager::setupAction(MainWindow *mainWindow)
|
||||||
CREATE_NEW_ACTION(mainWindow, actionToggleProtectMode);
|
CREATE_NEW_ACTION(mainWindow, actionToggleProtectMode);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionSettings);
|
CREATE_NEW_ACTION(mainWindow, actionSettings);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionHelp);
|
CREATE_NEW_ACTION(mainWindow, actionHelp);
|
||||||
|
CREATE_NEW_ACTION(mainWindow, actionLocateInFileManager);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionProperties);
|
CREATE_NEW_ACTION(mainWindow, actionProperties);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionQuitApp);
|
CREATE_NEW_ACTION(mainWindow, actionQuitApp);
|
||||||
|
|
||||||
|
@ -86,6 +87,7 @@ void ActionManager::retranslateUi(MainWindow *mainWindow)
|
||||||
actionToggleProtectMode->setText(QCoreApplication::translate("MainWindow", "Protected mode", nullptr));
|
actionToggleProtectMode->setText(QCoreApplication::translate("MainWindow", "Protected mode", nullptr));
|
||||||
actionSettings->setText(QCoreApplication::translate("MainWindow", "Configure...", nullptr));
|
actionSettings->setText(QCoreApplication::translate("MainWindow", "Configure...", nullptr));
|
||||||
actionHelp->setText(QCoreApplication::translate("MainWindow", "Help", nullptr));
|
actionHelp->setText(QCoreApplication::translate("MainWindow", "Help", nullptr));
|
||||||
|
actionLocateInFileManager->setText("Open Containing Folder"); // TODO: what should it called?
|
||||||
actionProperties->setText(QCoreApplication::translate("MainWindow", "Properties", nullptr));
|
actionProperties->setText(QCoreApplication::translate("MainWindow", "Properties", nullptr));
|
||||||
actionQuitApp->setText(QCoreApplication::translate("MainWindow", "Quit", nullptr));
|
actionQuitApp->setText(QCoreApplication::translate("MainWindow", "Quit", nullptr));
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ public:
|
||||||
QAction *actionToggleProtectMode;
|
QAction *actionToggleProtectMode;
|
||||||
QAction *actionSettings;
|
QAction *actionSettings;
|
||||||
QAction *actionHelp;
|
QAction *actionHelp;
|
||||||
|
QAction *actionLocateInFileManager;
|
||||||
QAction *actionProperties;
|
QAction *actionProperties;
|
||||||
QAction *actionQuitApp;
|
QAction *actionQuitApp;
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: FramelessWindow(parent)
|
: FramelessWindow(parent)
|
||||||
|
@ -437,6 +439,9 @@ void MainWindow::contextMenuEvent(QContextMenuEvent *event)
|
||||||
menu->addAction(helpAction);
|
menu->addAction(helpAction);
|
||||||
if (currentFileUrl.isValid()) {
|
if (currentFileUrl.isValid()) {
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
|
if (currentFileUrl.isLocalFile()) {
|
||||||
|
menu->addAction(m_am->actionLocateInFileManager);
|
||||||
|
}
|
||||||
menu->addAction(propertiesAction);
|
menu->addAction(propertiesAction);
|
||||||
}
|
}
|
||||||
menu->exec(mapToGlobal(event->pos()));
|
menu->exec(mapToGlobal(event->pos()));
|
||||||
|
@ -703,6 +708,22 @@ void MainWindow::on_actionProperties_triggered()
|
||||||
ad->deleteLater();
|
ad->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionLocateInFileManager_triggered()
|
||||||
|
{
|
||||||
|
QUrl currentFileUrl = currentImageFileUrl();
|
||||||
|
if (!currentFileUrl.isValid()) return;
|
||||||
|
|
||||||
|
QFileInfo fileInfo(currentFileUrl.toLocalFile());
|
||||||
|
if (!fileInfo.exists()) return;
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
QProcess::startDetached("explorer", QStringList() << "/select," << QDir::toNativeSeparators(fileInfo.absoluteFilePath()));
|
||||||
|
#else
|
||||||
|
// maybe use https://www.freedesktop.org/wiki/Specifications/file-manager-interface/ for linux?
|
||||||
|
QDesktopServices::openUrl(QUrl::fromLocalFile(fileInfo.absolutePath()));
|
||||||
|
#endif // Q_OS_WIN
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionQuitApp_triggered()
|
void MainWindow::on_actionQuitApp_triggered()
|
||||||
{
|
{
|
||||||
quitAppAction(false);
|
quitAppAction(false);
|
||||||
|
|
|
@ -91,6 +91,7 @@ private slots:
|
||||||
void on_actionSettings_triggered();
|
void on_actionSettings_triggered();
|
||||||
void on_actionHelp_triggered();
|
void on_actionHelp_triggered();
|
||||||
void on_actionProperties_triggered();
|
void on_actionProperties_triggered();
|
||||||
|
void on_actionLocateInFileManager_triggered();
|
||||||
void on_actionQuitApp_triggered();
|
void on_actionQuitApp_triggered();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user