-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
toolbaraction.h
178 lines (173 loc) · 6.31 KB
/
toolbaraction.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#ifndef TOOLBARACTION_H
#define TOOLBARACTION_H
#include <QString>
#include <QIcon>
#include <QObject>
enum item_enum
{
itemSeparator,
itemAdd,
itemAddText,
itemAddHtml,
itemAddTodo,
itemRemove,
itemRename,
itemBack,
itemForward,
itemPrev,
itemNext,
itemCopy,
itemSetup,
itemInfo,
itemRun,
itemSearch,
itemExit,
itemFormatBold,
itemFormatItalic,
itemFormatStrikeout,
itemFormatUnderline,
itemFormatColor,
itemExportPdf,
itemPrintNote,
itemPrintPreviewNote,
itemMax
};
class ToolbarAction
{
public:
ToolbarAction(item_enum id, bool use_system_icons_theme = false):item_id(id), use_system_icons_theme(use_system_icons_theme) {}
// Returning action's title
inline const QString text() const
{
switch(item_id)
{
case itemSeparator: return QObject::tr("Separator");
case itemAdd: return QObject::tr("Create new note");
case itemAddText: return QObject::tr("Create new Text note");
case itemAddHtml: return QObject::tr("Create new HTML note");
case itemAddTodo: return QObject::tr("Create new TODO note");
case itemRemove: return QObject::tr("Remove this note");
case itemRename: return QObject::tr("Rename this note");
case itemBack: return QObject::tr("Back");
case itemForward: return QObject::tr("Forward");
case itemPrev: return QObject::tr("Prev note");
case itemNext: return QObject::tr("Next note");
case itemCopy: return QObject::tr("Copy this note to clipboard");
case itemSetup: return QObject::tr("Preferences");
case itemInfo: return QObject::tr("Info");
case itemRun: return QObject::tr("Commands");
case itemSearch: return QObject::tr("Search");
case itemExit: return QObject::tr("Exit");
case itemFormatBold: return QObject::tr("Bold");
case itemFormatItalic: return QObject::tr("Italic");
case itemFormatStrikeout: return QObject::tr("Strikeout");
case itemFormatUnderline: return QObject::tr("Underline");
case itemFormatColor: return QObject::tr("Text color");
case itemExportPdf: return QObject::tr("Export note to PDF");
case itemPrintNote: return QObject::tr("Print...");
case itemPrintPreviewNote: return QObject::tr("Print Preview...");
default: return 0;
}
}
//Returning action's icon
inline QIcon icon() const
{
switch(item_id)
{
case itemAdd: return loadIcon("list-add");
case itemAddText: return loadIcon("list-add");
case itemAddHtml: return loadIcon("list-add");
case itemAddTodo: return loadIcon("list-add");
case itemRemove: return loadIcon("list-remove");
case itemRename: return loadIcon("edit-rename");
case itemBack: return loadIcon("go-previous");
case itemForward: return loadIcon("go-next");
case itemPrev: return loadIcon("go-previous-view");
case itemNext: return loadIcon("go-next-view");
case itemCopy: return loadIcon("edit-copy");
case itemSetup: return loadIcon("configure");
case itemInfo: return loadIcon("help-about");
case itemRun: return loadIcon("run-build");
case itemSearch: return loadIcon("edit-find");
case itemExit: return loadIcon("window-close");
case itemFormatBold: return loadIcon("format-text-bold");
case itemFormatItalic: return loadIcon("format-text-italic");
case itemFormatStrikeout: return loadIcon("format-text-strikethrough");
case itemFormatUnderline: return loadIcon("format-text-underline");
case itemFormatColor: return loadIcon("format-text-color");
case itemExportPdf: return loadIcon("application-pdf");
case itemPrintNote: return loadIcon("printer");
case itemPrintPreviewNote: return loadIcon("document-print-preview");
default: return QIcon();
}
}
inline QIcon loadIcon(const QString& file_name) const {
auto fallback_icon = QIcon(":/res/toolbar/" + file_name + ".png");
return use_system_icons_theme ? QIcon::fromTheme(file_name, fallback_icon) : fallback_icon;
}
//Returning action's identifiactor in configuration file
inline const QString pref_name() const
{
switch(item_id)
{
case itemAdd: return "Toolbar/itemAdd";
case itemAddText: return "Toolbar/itemAddText";
case itemAddHtml: return "Toolbar/itemAddHtml";
case itemAddTodo: return "Toolbar/itemAddTodo";
case itemRemove: return "Toolbar/itemRemove";
case itemRename: return "Toolbar/itemRename";
case itemBack: return "Toolbar/itemBack";
case itemForward: return "Toolbar/itemForward";
case itemPrev: return "Toolbar/itemPrev";
case itemNext: return "Toolbar/itemNext";
case itemCopy: return "Toolbar/itemCopy";
case itemSetup: return "Toolbar/itemSetup";
case itemInfo: return "Toolbar/itemInfo";
case itemRun: return "Toolbar/itemRun";
case itemSearch: return "Toolbar/itemSearch";
case itemExit: return "Toolbar/itemExit";
case itemFormatBold: return "Toolbar/itemFormatBold";
case itemFormatItalic: return "Toolbar/itemFormatItalic";
case itemFormatStrikeout: return "Toolbar/itemFormatStrikeout";
case itemFormatUnderline: return "Toolbar/itemFormatUnderline";
case itemFormatColor: return "Toolbar/itemFormatColor";
case itemExportPdf: return "Toolbar/itemExportPdf";
case itemPrintNote: return "Toolbar/itemPrint";
case itemPrintPreviewNote: return "Toolbar/itemPrintPreview";
default: return "";
}
}
inline bool isSeparator() { return item_id == itemSeparator; }
inline bool isCheckable()
{
switch(item_id)
{
case itemSearch:
case itemFormatBold:
case itemFormatItalic:
case itemFormatStrikeout:
case itemFormatUnderline:
return true;
default:
return false;
}
}
//Is item enabled when notelist is empty
inline bool isEnabledWhenEmpty()
{
switch(item_id)
{
case itemAdd:
case itemAddText:
case itemAddHtml:
case itemAddTodo:
return true;
default:
return false;
}
}
private:
item_enum item_id;
bool use_system_icons_theme;
};
#endif // TOOLBARACTION_H