FOSSredder 0.5.0
Loading...
Searching...
No Matches
AppActions.cpp
Go to the documentation of this file.
1
5
7
8#include <QAction>
9#include <QCoreApplication>
10#include <QGuiApplication>
11
12#include "ui/i18n/Text.h"
13#include "ui/shell/Defaults.h"
14
15namespace ui {
16
17Actions::Actions(QObject* parent) : QObject(parent) {
18 if (!qobject_cast<QGuiApplication*>(QCoreApplication::instance())) {
19 return;
20 }
21
22 newFileAction_ = new QAction(ui::text::actions::newFile(), this);
23 openFileAction_ = new QAction(ui::text::actions::openFile(), this);
24 saveFileAction_ = new QAction(ui::text::actions::saveFile(), this);
25 saveFileAsAction_ = new QAction(ui::text::actions::saveFileAs(), this);
26 quitAction_ = new QAction(ui::text::actions::quit(), this);
27 aboutAction_ = new QAction(ui::text::actions::about(), this);
28
29 newFileAction_->setObjectName(ui::config::objectNames::kActionNewFile);
30 openFileAction_->setObjectName(ui::config::objectNames::kActionOpenFile);
31 saveFileAction_->setObjectName(ui::config::objectNames::kActionSaveFile);
32 saveFileAsAction_->setObjectName(ui::config::objectNames::kActionSaveFileAs);
33
34 quitAction_->setObjectName(ui::config::objectNames::kActionQuit);
35 aboutAction_->setObjectName(ui::config::objectNames::kActionAbout);
36}
37
38QAction* Actions::newFileAction() const {
39 return newFileAction_;
40}
41QAction* Actions::openFileAction() const {
42 return openFileAction_;
43}
44QAction* Actions::saveFileAction() const {
45 return saveFileAction_;
46}
47QAction* Actions::saveFileAsAction() const {
48 return saveFileAsAction_;
49}
50QAction* Actions::quitAction() const {
51 return quitAction_;
52}
53QAction* Actions::aboutAction() const {
54 return aboutAction_;
55}
56
58 if (newFileAction_)
59 newFileAction_->trigger();
60}
62 if (openFileAction_)
63 openFileAction_->trigger();
64}
66 if (saveFileAction_)
67 saveFileAction_->trigger();
68}
70 if (saveFileAsAction_)
71 saveFileAsAction_->trigger();
72}
73
77
81
86
87} // namespace ui
Declares QAction wrappers exposed to the UI layer and QML.
Defines UI-specific runtime constants that are not shared with core.
Provides translated C++ UI strings for shell, workflow, adapter and view model code.
QAction * newFileAction
Definition AppActions.h:20
QAction * quitAction
Definition AppActions.h:24
Actions(QObject *parent=nullptr)
Construct the actions container.
void importBrowseRequested(const QString &filter)
Emitted when QML requests an import file dialog.
Q_INVOKABLE void newFile()
Requests creation of a new workspace file.
Q_INVOKABLE void openFile()
Requests opening an existing workspace file.
Q_INVOKABLE void browseImportPdf()
Requests an import PDF file picker.
QAction * openFileAction
Definition AppActions.h:21
QAction * saveFileAsAction
Definition AppActions.h:23
Q_INVOKABLE void browseExportFile()
Requests an export file picker.
Q_INVOKABLE void saveFile()
Requests saving the current workspace file.
QAction * saveFileAction
Definition AppActions.h:22
QAction * aboutAction
Definition AppActions.h:25
void exportBrowseRequested(const QString &filter)
Emitted when QML requests an export file dialog.
Q_INVOKABLE void saveFileAs()
Requests saving the current workspace file under a new path.
void exportDirectoryBrowseRequested(const QString &title)
Emitted when QML requests an export directory dialog.
Q_INVOKABLE void browseExportDirectory()
Requests an export directory picker.
constexpr auto kActionOpenFile
Object name assigned to the main window's "open file" QAction.
Definition Defaults.h:149
constexpr auto kActionQuit
Object name assigned to the main window's "quit" QAction.
Definition Defaults.h:155
constexpr auto kActionNewFile
Object name assigned to the main window's "new file" QAction.
Definition Defaults.h:147
constexpr auto kActionAbout
Object name assigned to the main window's "about" QAction.
Definition Defaults.h:157
constexpr auto kActionSaveFileAs
Object name assigned to the main window's "save as" QAction.
Definition Defaults.h:153
constexpr auto kActionSaveFile
Object name assigned to the main window's "save file" QAction.
Definition Defaults.h:151
QString saveFileAs()
Label for saving the current workspace under another path.
Definition Text.h:74
QString newFile()
Label for creating a new workspace file.
Definition Text.h:62
QString saveFile()
Label for saving the current workspace file.
Definition Text.h:70
QString openFile()
Label for opening an existing workspace file.
Definition Text.h:66
QString about()
Label for opening the about dialog.
Definition Text.h:82
QString quit()
Label for quitting the application.
Definition Text.h:78
QString importPdfFilter()
File filter for PDF import sources.
Definition Text.h:143
QString exportDirectoryTitle()
Title for selecting an export target directory.
Definition Text.h:123
QString exportFileFilter()
File filter for direct export targets.
Definition Text.h:147