feat: new action for open a dialog to select image files
This commit is contained in:
parent
560ece0f2f
commit
f202bb58f4
|
@ -41,6 +41,7 @@ void ActionManager::setupAction(MainWindow *mainWindow)
|
||||||
CREATE_NEW_ACTION(mainWindow, actionPrevPicture);
|
CREATE_NEW_ACTION(mainWindow, actionPrevPicture);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionNextPicture);
|
CREATE_NEW_ACTION(mainWindow, actionNextPicture);
|
||||||
|
|
||||||
|
CREATE_NEW_ACTION(mainWindow, actionOpen);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionHorizontalFlip);
|
CREATE_NEW_ACTION(mainWindow, actionHorizontalFlip);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionFitInView);
|
CREATE_NEW_ACTION(mainWindow, actionFitInView);
|
||||||
CREATE_NEW_ACTION(mainWindow, actionFitByWidth);
|
CREATE_NEW_ACTION(mainWindow, actionFitByWidth);
|
||||||
|
@ -63,6 +64,8 @@ void ActionManager::retranslateUi(MainWindow *mainWindow)
|
||||||
{
|
{
|
||||||
Q_UNUSED(mainWindow);
|
Q_UNUSED(mainWindow);
|
||||||
|
|
||||||
|
actionOpen->setText(QCoreApplication::translate("MainWindow", "&Open...", nullptr));
|
||||||
|
|
||||||
actionActualSize->setText(QCoreApplication::translate("MainWindow", "Actual size", nullptr));
|
actionActualSize->setText(QCoreApplication::translate("MainWindow", "Actual size", nullptr));
|
||||||
actionToggleMaximize->setText(QCoreApplication::translate("MainWindow", "Toggle maximize", nullptr));
|
actionToggleMaximize->setText(QCoreApplication::translate("MainWindow", "Toggle maximize", nullptr));
|
||||||
actionZoomIn->setText(QCoreApplication::translate("MainWindow", "Zoom in", nullptr));
|
actionZoomIn->setText(QCoreApplication::translate("MainWindow", "Zoom in", nullptr));
|
||||||
|
@ -89,6 +92,7 @@ void ActionManager::retranslateUi(MainWindow *mainWindow)
|
||||||
|
|
||||||
void ActionManager::setupShortcuts()
|
void ActionManager::setupShortcuts()
|
||||||
{
|
{
|
||||||
|
actionOpen->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_O));
|
||||||
actionActualSize->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_0));
|
actionActualSize->setShortcut(QKeySequence(Qt::CTRL | Qt::Key_0));
|
||||||
actionZoomIn->setShortcut(QKeySequence(QKeySequence::ZoomIn));
|
actionZoomIn->setShortcut(QKeySequence(QKeySequence::ZoomIn));
|
||||||
actionZoomOut->setShortcut(QKeySequence(QKeySequence::ZoomOut));
|
actionZoomOut->setShortcut(QKeySequence(QKeySequence::ZoomOut));
|
||||||
|
|
|
@ -16,6 +16,8 @@ public:
|
||||||
void setupShortcuts();
|
void setupShortcuts();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
QAction *actionOpen;
|
||||||
|
|
||||||
QAction *actionActualSize;
|
QAction *actionActualSize;
|
||||||
QAction *actionToggleMaximize;
|
QAction *actionToggleMaximize;
|
||||||
QAction *actionZoomIn;
|
QAction *actionZoomIn;
|
||||||
|
|
|
@ -27,6 +27,8 @@
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QStandardPaths>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
: FramelessWindow(parent)
|
: FramelessWindow(parent)
|
||||||
|
@ -406,6 +408,8 @@ void MainWindow::contextMenuEvent(QContextMenuEvent *event)
|
||||||
QAction * helpAction = m_am->actionHelp;
|
QAction * helpAction = m_am->actionHelp;
|
||||||
QAction * propertiesAction = m_am->actionProperties;
|
QAction * propertiesAction = m_am->actionProperties;
|
||||||
|
|
||||||
|
menu->addAction(m_am->actionOpen);
|
||||||
|
|
||||||
if (copyMenu->actions().count() == 1) {
|
if (copyMenu->actions().count() == 1) {
|
||||||
menu->addActions(copyMenu->actions());
|
menu->addActions(copyMenu->actions());
|
||||||
} else {
|
} else {
|
||||||
|
@ -540,6 +544,17 @@ QSize MainWindow::sizeHint() const
|
||||||
return QSize(710, 530);
|
return QSize(710, 530);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::on_actionOpen_triggered()
|
||||||
|
{
|
||||||
|
QStringList picturesLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
|
||||||
|
QUrl pictureUrl = picturesLocations.isEmpty() ? QUrl::fromLocalFile(picturesLocations.first())
|
||||||
|
: QUrl::fromLocalFile(QDir::homePath());
|
||||||
|
QList<QUrl> urls(QFileDialog::getOpenFileUrls(this, QString(), pictureUrl));
|
||||||
|
if (!urls.isEmpty()) {
|
||||||
|
showUrls(urls);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionActualSize_triggered()
|
void MainWindow::on_actionActualSize_triggered()
|
||||||
{
|
{
|
||||||
m_graphicsView->resetScale();
|
m_graphicsView->resetScale();
|
||||||
|
|
|
@ -68,6 +68,8 @@ protected:
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void on_actionOpen_triggered();
|
||||||
|
|
||||||
void on_actionActualSize_triggered();
|
void on_actionActualSize_triggered();
|
||||||
void on_actionToggleMaximize_triggered();
|
void on_actionToggleMaximize_triggered();
|
||||||
void on_actionZoomIn_triggered();
|
void on_actionZoomIn_triggered();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user