2021-01-24 00:07:58 +08:00
|
|
|
#include "actionmanager.h"
|
|
|
|
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
|
|
|
#include <QCoreApplication>
|
|
|
|
|
|
|
|
#define CREATE_NEW_ACTION(window, action)\
|
|
|
|
action = new QAction(window);\
|
|
|
|
action->setObjectName(QString::fromUtf8( #action ));\
|
|
|
|
window->addAction(action);
|
|
|
|
|
|
|
|
ActionManager::ActionManager()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ActionManager::~ActionManager()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionManager::setupAction(MainWindow *mainWindow)
|
|
|
|
{
|
2021-02-18 20:03:17 +08:00
|
|
|
CREATE_NEW_ACTION(mainWindow, actionZoomIn);
|
|
|
|
CREATE_NEW_ACTION(mainWindow, actionZoomOut);
|
2021-03-19 23:11:06 +08:00
|
|
|
CREATE_NEW_ACTION(mainWindow, actionHorizontalFlip);
|
2021-01-24 00:07:58 +08:00
|
|
|
CREATE_NEW_ACTION(mainWindow, actionCopyPixmap);
|
|
|
|
CREATE_NEW_ACTION(mainWindow, actionCopyFilePath);
|
|
|
|
CREATE_NEW_ACTION(mainWindow, actionPaste);
|
2021-03-01 00:44:50 +08:00
|
|
|
CREATE_NEW_ACTION(mainWindow, actionToggleCheckerboard);
|
2021-01-24 00:07:58 +08:00
|
|
|
CREATE_NEW_ACTION(mainWindow, actionToggleStayOnTop);
|
|
|
|
CREATE_NEW_ACTION(mainWindow, actionToggleProtectMode);
|
|
|
|
CREATE_NEW_ACTION(mainWindow, actionSettings);
|
|
|
|
CREATE_NEW_ACTION(mainWindow, actionHelp);
|
|
|
|
CREATE_NEW_ACTION(mainWindow, actionProperties);
|
|
|
|
CREATE_NEW_ACTION(mainWindow, actionQuitApp);
|
|
|
|
|
|
|
|
retranslateUi(mainWindow);
|
|
|
|
|
|
|
|
QMetaObject::connectSlotsByName(mainWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionManager::retranslateUi(MainWindow *mainWindow)
|
|
|
|
{
|
|
|
|
Q_UNUSED(mainWindow);
|
|
|
|
|
2021-02-18 20:03:17 +08:00
|
|
|
actionZoomIn->setText(QCoreApplication::translate("MainWindow", "Zoom in", nullptr));
|
|
|
|
actionZoomOut->setText(QCoreApplication::translate("MainWindow", "Zoom out", nullptr));
|
2021-03-19 23:11:06 +08:00
|
|
|
actionHorizontalFlip->setText(QCoreApplication::translate("MainWindow", "Horizontal flip", nullptr));
|
2021-01-24 00:07:58 +08:00
|
|
|
actionCopyPixmap->setText(QCoreApplication::translate("MainWindow", "Copy P&ixmap", nullptr));
|
|
|
|
actionCopyFilePath->setText(QCoreApplication::translate("MainWindow", "Copy &File Path", nullptr));
|
|
|
|
actionPaste->setText(QCoreApplication::translate("MainWindow", "&Paste", nullptr));
|
2021-03-01 00:44:50 +08:00
|
|
|
actionToggleCheckerboard->setText(QCoreApplication::translate("MainWindow", "Toggle Checkerboard", nullptr));
|
2021-01-24 00:07:58 +08:00
|
|
|
actionToggleStayOnTop->setText(QCoreApplication::translate("MainWindow", "Stay on top", nullptr));
|
|
|
|
actionToggleProtectMode->setText(QCoreApplication::translate("MainWindow", "Protected mode", nullptr));
|
|
|
|
actionSettings->setText(QCoreApplication::translate("MainWindow", "Configure...", nullptr));
|
|
|
|
actionHelp->setText(QCoreApplication::translate("MainWindow", "Help", nullptr));
|
|
|
|
actionProperties->setText(QCoreApplication::translate("MainWindow", "Properties", nullptr));
|
|
|
|
actionQuitApp->setText(QCoreApplication::translate("MainWindow", "Quit", nullptr));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ActionManager::setupShortcuts()
|
|
|
|
{
|
2021-02-18 23:44:23 +08:00
|
|
|
actionZoomIn->setShortcut(QKeySequence(QKeySequence::ZoomIn));
|
|
|
|
actionZoomOut->setShortcut(QKeySequence(QKeySequence::ZoomOut));
|
2021-01-24 00:07:58 +08:00
|
|
|
actionQuitApp->setShortcuts({
|
|
|
|
QKeySequence(Qt::Key_Space),
|
|
|
|
QKeySequence(Qt::Key_Escape)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|