1 /*******************************************************************************************************
2  DkActionManager.cpp
3  Created on:	28.10.2015
4 
5  nomacs is a fast and small image viewer with the capability of synchronizing multiple instances
6 
7  Copyright (C) 2011-2015 Markus Diem <markus@nomacs.org>
8  Copyright (C) 2011-2015 Stefan Fiel <stefan@nomacs.org>
9  Copyright (C) 2011-2015 Florian Kleber <florian@nomacs.org>
10 
11  This file is part of nomacs.
12 
13  nomacs is free software: you can redistribute it and/or modify
14  it under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  nomacs is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  GNU General Public License for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with this program.  If not, see <http://www.gnu.org/licenses/>.
25 
26  *******************************************************************************************************/
27 
28 #include "DkActionManager.h"
29 #include "DkSettings.h"
30 #include "DkImageStorage.h"
31 #include "DkUtils.h"
32 #include "DkStatusBar.h"
33 #include "DkToolbars.h"
34 
35 #include "DkDialog.h"
36 #include "DkMenu.h"
37 
38 #ifdef WITH_PLUGINS
39 #include "DkPluginManager.h"
40 #endif
41 
42 #if defined(Q_OS_WIN) && !defined(SOCK_STREAM)
43 #include <winsock2.h>	// needed since libraw 0.16
44 #endif
45 
46 #pragma warning(push, 0)	// no warnings from includes - begin
47 #include <QMenu>
48 #include <QFileInfo>
49 #include <QDir>
50 #include <QApplication>
51 #include <QDebug>
52 #include <QProgressDialog>
53 #include <QSvgRenderer>
54 
55 #ifdef Q_OS_WIN
56 #include <QWinTaskbarProgress>
57 #include <windows.h>
58 #include <QtWin>
59 #endif
60 #pragma warning(pop)		// no warnings from includes - end
61 
62 namespace nmc {
63 
64 
65 // DkAppManager --------------------------------------------------------------------
DkAppManager(QWidget * parent)66 DkAppManager::DkAppManager(QWidget* parent) : QObject(parent) {
67 
68 	mDefaultNames.resize(app_idx_end);
69 	mDefaultNames[app_photohsop]	= "PhotoshopAction";
70 	mDefaultNames[app_picasa]		= "PicasaAction";
71 	mDefaultNames[app_picasa_viewer]= "PicasaViewerAction";
72 	mDefaultNames[app_irfan_view]	= "IrfanViewAction";
73 	mDefaultNames[app_explorer]		= "ExplorerAction";
74 
75 	loadSettings();
76 	if (mFirstTime)
77 		findDefaultSoftware();
78 
79 	for (int idx = 0; idx < mApps.size(); idx++) {
80 		assignIcon(mApps.at(idx));
81 		connect(mApps.at(idx), SIGNAL(triggered()), this, SLOT(openTriggered()));
82 	}
83 }
84 
~DkAppManager()85 DkAppManager::~DkAppManager() {
86 
87 	// save settings
88 	saveSettings();
89 }
90 
saveSettings() const91 void DkAppManager::saveSettings() const {
92 
93 	DefaultSettings settings;
94 	settings.beginGroup("DkAppManager");
95 	// clear it first
96 	settings.remove("Apps");
97 
98 	settings.beginWriteArray("Apps");
99 
100 	for (int idx = 0; idx < mApps.size(); idx++) {
101 		settings.setArrayIndex(idx);
102 		settings.setValue("appName", mApps.at(idx)->text());
103 		settings.setValue("appPath", mApps.at(idx)->toolTip());
104 		settings.setValue("objectName", mApps.at(idx)->objectName());
105 	}
106 	settings.endArray();
107 	settings.endGroup();
108 }
109 
loadSettings()110 void DkAppManager::loadSettings() {
111 
112 	DefaultSettings settings;
113 	settings.beginGroup("DkAppManager");
114 
115 	int size = settings.beginReadArray("Apps");
116 	if (size > 0)
117 		mFirstTime = false;
118 
119 	for (int idx = 0; idx < size; idx++) {
120 		settings.setArrayIndex(idx);
121 		QAction* action = new QAction(parent());
122 		action->setText(settings.value("appName", "").toString());
123 		action->setToolTip(settings.value("appPath", "").toString());
124 		action->setObjectName(settings.value("objectName", "").toString());
125 
126 		// default shortcuts
127 		if (action->objectName() == mDefaultNames[app_explorer])
128 			action->setShortcut(QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_E));
129 
130 		if (QFileInfo(action->toolTip()).exists() && !action->text().isEmpty())
131 			mApps.append(action);
132 		else
133 			qDebug() << "could not locate: " << action->toolTip();
134 
135 	}
136 	settings.endArray();
137 	settings.endGroup();
138 }
139 
getActions() const140 QVector<QAction* > DkAppManager::getActions() const {
141 
142 	return mApps;
143 }
144 
setActions(QVector<QAction * > actions)145 void DkAppManager::setActions(QVector<QAction* > actions) {
146 
147 	mApps = actions;
148 	saveSettings();
149 }
150 
createAction(const QString & filePath)151 QAction* DkAppManager::createAction(const QString& filePath) {
152 
153 	QFileInfo file(filePath);
154 	if (!file.exists())
155 		return 0;
156 
157 	QAction* newApp = new QAction(file.baseName(), parent());
158 	newApp->setToolTip(QDir::fromNativeSeparators(file.filePath()));
159 	assignIcon(newApp);
160 	connect(newApp, SIGNAL(triggered()), this, SLOT(openTriggered()));
161 
162 	return newApp;
163 }
164 
findAction(const QString & appPath) const165 QAction* DkAppManager::findAction(const QString& appPath) const {
166 
167 	for (int idx = 0; idx < mApps.size(); idx++) {
168 
169 		if (mApps.at(idx)->toolTip() == appPath)
170 			return mApps.at(idx);
171 	}
172 
173 	return 0;
174 }
175 
findDefaultSoftware()176 void DkAppManager::findDefaultSoftware() {
177 
178 	QString appPath;
179 
180 	// Photoshop
181 	if (!containsApp(mApps, mDefaultNames[app_photohsop])) {
182 		appPath = searchForSoftware("Adobe", "Photoshop", "ApplicationPath");
183 		if (!appPath.isEmpty()) {
184 			QAction* a = new QAction(QObject::tr("&Photoshop"), parent());
185 			a->setToolTip(QDir::fromNativeSeparators(appPath));
186 			a->setObjectName(mDefaultNames[app_photohsop]);
187 			mApps.append(a);
188 		}
189 	}
190 
191 	if (!containsApp(mApps, mDefaultNames[app_picasa])) {
192 		// Picasa
193 		appPath = searchForSoftware("Google", "Picasa", "Directory");
194 		if (!appPath.isEmpty()) {
195 			QAction* a = new QAction(QObject::tr("Pic&asa"), parent());
196 			a->setToolTip(QDir::fromNativeSeparators(appPath));
197 			a->setObjectName(mDefaultNames[app_picasa]);
198 			mApps.append(a);
199 		}
200 	}
201 
202 	if (!containsApp(mApps, mDefaultNames[app_picasa_viewer])) {
203 		// Picasa Photo Viewer
204 		appPath = searchForSoftware("Google", "Picasa", "Directory", "PicasaPhotoViewer.exe");
205 		if (!appPath.isEmpty()) {
206 			QAction* a = new QAction(QObject::tr("Picasa Ph&oto Viewer"), parent());
207 			a->setToolTip(QDir::fromNativeSeparators(appPath));
208 			a->setObjectName(mDefaultNames[app_picasa_viewer]);
209 			mApps.append(a);
210 		}
211 	}
212 
213 	if (!containsApp(mApps, mDefaultNames[app_irfan_view])) {
214 		// IrfanView
215 		appPath = searchForSoftware("IrfanView", "shell");
216 		if (!appPath.isEmpty()) {
217 			QAction* a = new QAction(QObject::tr("&IrfanView"), parent());
218 			a->setToolTip(QDir::fromNativeSeparators(appPath));
219 			a->setObjectName(mDefaultNames[app_irfan_view]);
220 			mApps.append(a);
221 		}
222 	}
223 
224 	if (!containsApp(mApps, mDefaultNames[app_explorer])) {
225 		appPath = "C:/Windows/explorer.exe";
226 		if (QFileInfo(appPath).exists()) {
227 			QAction* a = new QAction(QObject::tr("&Explorer"), parent());
228 			a->setToolTip(QDir::fromNativeSeparators(appPath));
229 			a->setObjectName(mDefaultNames[app_explorer]);
230 			mApps.append(a);
231 		}
232 	}
233 }
234 
containsApp(QVector<QAction * > apps,const QString & appName) const235 bool DkAppManager::containsApp(QVector<QAction* > apps, const QString& appName) const {
236 
237 	for (int idx = 0; idx < apps.size(); idx++)
238 		if (apps.at(idx)->objectName() == appName)
239 			return true;
240 
241 	return false;
242 }
243 
assignIcon(QAction * app) const244 void DkAppManager::assignIcon(QAction* app) const {
245 
246 #ifdef Q_OS_WIN
247 
248 	if (!app) {
249 		qDebug() << "SERIOUS problem here, I should assign an icon to a NULL pointer action";
250 		return;
251 	}
252 
253 	QFileInfo file = app->toolTip();
254 
255 	if (!file.exists())
256 		return;
257 
258 	// icon extraction should take between 2ms and 13ms
259 	QPixmap appIcon;
260 	QString winPath = QDir::toNativeSeparators(file.absoluteFilePath());
261 
262 	WCHAR* wDirName = new WCHAR[winPath.length()+1];
263 
264 	// CMakeLists.txt:
265 	// if compile error that toWCharArray is not recognized:
266 	// in msvc: Project Properties -> C/C++ -> Language -> Treat WChar_t as built-in type: set to No (/Zc:wchar_t-)
267 	wDirName = (WCHAR*)winPath.utf16();
268 	wDirName[winPath.length()] = L'\0';	// append null character
269 
270 	int nIcons = ExtractIconExW(wDirName, 0, NULL, NULL, 0);
271 
272 	if (!nIcons)
273 		return;
274 
275 	HICON largeIcon;
276 	HICON smallIcon;
277 	ExtractIconExW(wDirName, 0, &largeIcon, &smallIcon, 1);
278 
279 	if (nIcons != 0 && smallIcon != NULL)
280 		appIcon = QtWin::fromHICON(smallIcon);
281 
282 	DestroyIcon(largeIcon);
283 	DestroyIcon(smallIcon);
284 
285 	app->setIcon(appIcon);
286 
287 #endif
288 
289 }
290 
searchForSoftware(const QString & organization,const QString & application,const QString & pathKey,const QString & exeName) const291 QString DkAppManager::searchForSoftware(const QString& organization, const QString& application, const QString& pathKey, const QString& exeName) const {
292 
293 	//qDebug() << "searching for: " << organization;
294 
295 	// locate the settings entry
296 	QSettings softwareSettings(QSettings::UserScope, organization, application);
297 	QStringList keys = softwareSettings.allKeys();
298 
299 	QString appPath;
300 
301 	for (int idx = 0; idx < keys.length(); idx++) {
302 
303 		// find the path
304 		if (keys[idx].contains(pathKey)) {
305 			appPath = softwareSettings.value(keys[idx]).toString();
306 			break;
307 		}
308 	}
309 
310 	// if we did not find it -> return
311 	if (appPath.isEmpty())
312 		return appPath;
313 
314 	if (exeName.isEmpty()) {
315 
316 		// locate the exe
317 		QDir appFile = appPath.replace("\"", "");	// the string must not have extra quotes
318 		QFileInfoList apps = appFile.entryInfoList(QStringList() << "*.exe");
319 
320 		for (int idx = 0; idx < apps.size(); idx++) {
321 
322 			if (apps[idx].fileName().contains(application)) {
323 				appPath = apps[idx].absoluteFilePath();
324 				break;
325 			}
326 		}
327 	}
328 	else
329 		appPath = QFileInfo(appPath, exeName).absoluteFilePath();	// for correct separators
330 
331 	if (!appPath.isEmpty())
332 		qInfo() << "I found" << organization << "in:" << appPath;
333 
334 	return appPath;
335 }
336 
openTriggered() const337 void DkAppManager::openTriggered() const {
338 
339 	QAction* a = static_cast<QAction*>(QObject::sender());
340 
341 	if (a)
342 		openFileSignal(a);
343 }
344 
345 // DkActionManager --------------------------------------------------------------------
DkActionManager()346 DkActionManager::DkActionManager() {
347 	init();
348 }
349 
~DkActionManager()350 DkActionManager::~DkActionManager() {
351 
352 	qDebug() << "releasing...";
353 }
354 
instance()355 DkActionManager& DkActionManager::instance() {
356 
357 	static DkActionManager inst;
358 	return inst;
359 }
360 
createFileMenu(QWidget * parent)361 QMenu* DkActionManager::createFileMenu(QWidget* parent /* = 0 */) {
362 
363 	mFileMenu = new QMenu(QObject::tr("&File"), parent);
364 
365 	mFileMenu->addAction(mFileActions[menu_file_open]);
366 	mFileMenu->addAction(mFileActions[menu_file_open_dir]);
367 	if (DkSettingsManager::param().global().extendedTabs)
368 		mFileMenu->addAction(mFileActions[menu_file_open_list]);
369 
370 	// add open with menu
371 	mFileMenu->addMenu(openWithMenu());
372 	mFileMenu->addAction(mFileActions[menu_file_quick_launch]);
373 
374 	mFileMenu->addSeparator();
375 	mFileMenu->addAction(mFileActions[menu_file_save]);
376 	mFileMenu->addAction(mFileActions[menu_file_save_as]);
377 	mFileMenu->addAction(mFileActions[menu_file_save_copy]);
378 	if (DkSettingsManager::param().global().extendedTabs)
379 		mFileMenu->addAction(mFileActions[menu_file_save_list]);
380 	mFileMenu->addAction(mFileActions[menu_file_save_web]);
381 	mFileMenu->addAction(mFileActions[menu_file_rename]);
382 	mFileMenu->addSeparator();
383 	mFileMenu->addAction(mFileActions[menu_file_show_recent]);
384 	mFileMenu->addSeparator();
385 	mFileMenu->addAction(mFileActions[menu_file_print]);
386 	mFileMenu->addSeparator();
387 
388 	// add sort menu
389 	mFileMenu->addMenu(sortMenu());
390 	mFileMenu->addAction(mFileActions[menu_file_recursive]);
391 	mFileMenu->addAction(mFileActions[menu_file_goto]);
392 	mFileMenu->addAction(mFileActions[menu_file_find]);
393 	mFileMenu->addAction(mFileActions[menu_file_reload]);
394 	mFileMenu->addAction(mFileActions[menu_file_prev]);
395 	mFileMenu->addAction(mFileActions[menu_file_next]);
396 	mFileMenu->addSeparator();
397 	mFileMenu->addAction(mFileActions[menu_file_new_instance]);
398 	mFileMenu->addAction(mFileActions[menu_file_private_instance]);
399 	mFileMenu->addAction(mFileActions[menu_file_exit]);
400 
401 	return mFileMenu;
402 }
403 
createOpenWithMenu(QWidget * parent)404 QMenu * DkActionManager::createOpenWithMenu(QWidget* parent) {
405 
406 	mOpenWithMenu = new QMenu(QObject::tr("&Open With"), parent);
407 	return updateOpenWithMenu();
408 }
409 
updateOpenWithMenu()410 QMenu* DkActionManager::updateOpenWithMenu() {
411 
412 	mOpenWithMenu->clear();
413 
414 	QVector<QAction* > appActions = mAppManager->getActions();
415 
416 	assignCustomShortcuts(appActions);
417 	mOpenWithMenu->addActions(appActions.toList());
418 
419 	if (!appActions.empty())
420 		mOpenWithMenu->addSeparator();
421 	mOpenWithMenu->addAction(mFileActions[menu_file_app_manager]);
422 
423 	return mOpenWithMenu;
424 }
425 
createSortMenu(QWidget * parent)426 QMenu * DkActionManager::createSortMenu(QWidget * parent) {
427 
428 	mSortMenu = new QMenu(QObject::tr("S&ort"), parent);
429 	mSortMenu->addAction(mSortActions[menu_sort_filename]);
430 	mSortMenu->addAction(mSortActions[menu_sort_date_created]);
431 	mSortMenu->addAction(mSortActions[menu_sort_date_modified]);
432 	mSortMenu->addAction(mSortActions[menu_sort_random]);
433 	mSortMenu->addSeparator();
434 	mSortMenu->addAction(mSortActions[menu_sort_ascending]);
435 	mSortMenu->addAction(mSortActions[menu_sort_descending]);
436 
437 	return mSortMenu;
438 }
439 
createViewMenu(QWidget * parent)440 QMenu* DkActionManager::createViewMenu(QWidget* parent /* = 0 */) {
441 
442 	mViewMenu = new QMenu(QObject::tr("&View"), parent);
443 
444 	mViewMenu->addAction(mViewActions[menu_view_frameless]);
445 	mViewMenu->addAction(mViewActions[menu_view_fullscreen]);
446 	mViewMenu->addSeparator();
447 
448 	mViewMenu->addAction(mViewActions[menu_view_new_tab]);
449 	mViewMenu->addAction(mViewActions[menu_view_close_tab]);
450 	mViewMenu->addAction(mViewActions[menu_view_close_all_tabs]);
451 
452 	if (DkSettingsManager::param().global().extendedTabs)
453 		mViewMenu->addAction(mViewActions[menu_view_first_tab]);
454 	mViewMenu->addAction(mViewActions[menu_view_previous_tab]);
455 	if (DkSettingsManager::param().global().extendedTabs)
456 		mViewMenu->addAction(mViewActions[menu_view_goto_tab]);
457 	mViewMenu->addAction(mViewActions[menu_view_next_tab]);
458 	if (DkSettingsManager::param().global().extendedTabs)
459 		mViewMenu->addAction(mViewActions[menu_view_last_tab]);
460 	mViewMenu->addSeparator();
461 
462 	mViewMenu->addAction(mViewActions[menu_view_reset]);
463 	mViewMenu->addAction(mViewActions[menu_view_100]);
464 	mViewMenu->addAction(mViewActions[menu_view_fit_frame]);
465 	mViewMenu->addAction(mViewActions[menu_view_zoom_in]);
466 	mViewMenu->addAction(mViewActions[menu_view_zoom_out]);
467 	mViewMenu->addSeparator();
468 
469 	mViewMenu->addAction(mViewActions[menu_view_tp_pattern]);
470 	mViewMenu->addAction(mViewActions[menu_view_anti_aliasing]);
471 	mViewMenu->addSeparator();
472 
473 	mViewMenu->addAction(mViewActions[menu_view_opacity_change]);
474 	mViewMenu->addAction(mViewActions[menu_view_opacity_up]);
475 	mViewMenu->addAction(mViewActions[menu_view_opacity_down]);
476 	mViewMenu->addAction(mViewActions[menu_view_opacity_an]);
477 #ifdef Q_OS_WIN
478 	mViewMenu->addAction(mViewActions[menu_view_lock_window]);
479 #endif
480 	mViewMenu->addSeparator();
481 
482 	mViewMenu->addAction(mViewActions[menu_view_slideshow]);
483 	mViewMenu->addAction(mViewActions[menu_view_movie_pause]);
484 	mViewMenu->addAction(mViewActions[menu_view_movie_prev]);
485 	mViewMenu->addAction(mViewActions[menu_view_movie_next]);
486 	mViewMenu->addSeparator();
487 
488 	if (DkSettingsManager::param().app().currentAppMode == DkSettingsManager::param().mode_frameless) {
489 		mViewMenu->addAction(mViewActions[menu_view_monitors]);
490 		mViewMenu->addSeparator();
491 	}
492 
493 	mViewMenu->addAction(mViewActions[menu_view_gps_map]);
494 
495 	return mViewMenu;
496 }
497 
createEditMenu(QWidget * parent)498 QMenu* DkActionManager::createEditMenu(QWidget* parent /* = 0 */) {
499 
500 	mEditMenu = new QMenu(QObject::tr("&Edit"), parent);
501 
502 	mEditMenu->addAction(mEditActions[menu_edit_copy]);
503 	mEditMenu->addAction(mEditActions[menu_edit_copy_buffer]);
504 	mEditMenu->addAction(mEditActions[menu_edit_paste]);
505 	mEditMenu->addAction(mEditActions[menu_edit_delete]);
506 	mEditMenu->addSeparator();
507 	mEditMenu->addAction(mEditActions[menu_edit_rotate_ccw]);
508 	mEditMenu->addAction(mEditActions[menu_edit_rotate_cw]);
509 	mEditMenu->addAction(mEditActions[menu_edit_rotate_180]);
510 	mEditMenu->addSeparator();
511 	mEditMenu->addAction(mEditActions[menu_edit_undo]);
512 	mEditMenu->addAction(mEditActions[menu_edit_redo]);
513 	mEditMenu->addSeparator();
514 	mEditMenu->addAction(mEditActions[menu_edit_shortcuts]);
515 	mEditMenu->addAction(mEditActions[menu_edit_preferences]);
516 
517 	return mEditMenu;
518 }
519 
createManipulatorMenu(QWidget * parent)520 QMenu * DkActionManager::createManipulatorMenu(QWidget * parent) {
521 
522 	mManipulatorMenu = new QMenu(QObject::tr("&Adjustments"), parent);
523 
524 	for (auto action : mManipulators.actions())
525 		mManipulatorMenu->addAction(action);
526 
527 	mManipulatorMenu->addSeparator();
528 	mManipulatorMenu->addAction(mEditActions[menu_edit_transform]);
529 	mManipulatorMenu->addAction(mEditActions[menu_edit_crop]);
530 	mManipulatorMenu->addSeparator();
531 	mManipulatorMenu->addAction(mEditActions[menu_edit_image]);
532 
533 	return mManipulatorMenu;
534 }
535 
createPanelMenu(QWidget * parent)536 QMenu* DkActionManager::createPanelMenu(QWidget* parent) {
537 
538 	mPanelMenu = new QMenu(QObject::tr("&Panels"), parent);
539 
540 	QMenu* toolsMenu = mPanelMenu->addMenu(QObject::tr("Tool&bars"));
541 	toolsMenu->addAction(mPanelActions[menu_panel_menu]);
542 	toolsMenu->addAction(mPanelActions[menu_panel_toolbar]);
543 	toolsMenu->addAction(mPanelActions[menu_panel_statusbar]);
544 	toolsMenu->addAction(mPanelActions[menu_panel_transfertoolbar]);
545 
546 	mPanelMenu->addAction(mPanelActions[menu_panel_explorer]);
547 	mPanelMenu->addAction(mPanelActions[menu_panel_metadata_dock]);
548 	mPanelMenu->addAction(mPanelActions[menu_panel_exif]);
549 	mPanelMenu->addAction(mPanelActions[menu_panel_history]);
550 	mPanelMenu->addAction(mPanelActions[menu_panel_preview]);
551 	mPanelMenu->addAction(mPanelActions[menu_panel_thumbview]);
552 	mPanelMenu->addAction(mPanelActions[menu_panel_scroller]);
553 	mPanelMenu->addAction(mPanelActions[menu_panel_log]);
554 
555 	mPanelMenu->addSeparator();
556 
557 	mPanelMenu->addAction(mPanelActions[menu_panel_overview]);
558 	mPanelMenu->addAction(mPanelActions[menu_panel_player]);
559 	mPanelMenu->addAction(mPanelActions[menu_panel_info]);
560 	mPanelMenu->addAction(mPanelActions[menu_panel_histogram]);
561 	mPanelMenu->addAction(mPanelActions[menu_panel_comment]);
562 
563 	mPanelMenu->addSeparator();
564 	mPanelMenu->addAction(mPanelActions[menu_panel_toggle]);
565 
566 	return mPanelMenu;
567 }
568 
createToolsMenu(QWidget * parent)569 QMenu* DkActionManager::createToolsMenu(QWidget* parent /* = 0 */) {
570 
571 	mToolsMenu = new QMenu(QObject::tr("&Tools"), parent);
572 
573 #ifdef WITH_LIBTIFF
574 	mToolsMenu->addAction(mToolsActions[menu_tools_export_tiff]);
575 #endif
576 #ifdef WITH_QUAZIP
577 	mToolsMenu->addAction(mToolsActions[menu_tools_extract_archive]);
578 #endif
579 #ifdef WITH_OPENCV
580 	mToolsMenu->addAction(mToolsActions[menu_tools_mosaic]);
581 #endif
582 #ifdef Q_OS_WIN
583 	mToolsMenu->addAction(mToolsActions[menu_tools_wallpaper]);
584 	mToolsMenu->addSeparator();
585 #endif
586 	mToolsMenu->addAction(mToolsActions[menu_tools_batch]);
587 	mToolsMenu->addAction(mToolsActions[menu_tools_thumbs]);
588 	mToolsMenu->addAction(mToolsActions[menu_tools_train_format]);
589 
590 	return mToolsMenu;
591 }
592 
createHelpMenu(QWidget * parent)593 QMenu* DkActionManager::createHelpMenu(QWidget* parent) {
594 
595 	mHelpMenu = new QMenu(QObject::tr("&?"), parent);
596 
597 #ifndef Q_OS_LINUX
598 	mHelpMenu->addAction(mHelpActions[menu_help_update]);
599 #endif // !Q_OS_LINUX
600 	mHelpMenu->addAction(mHelpActions[menu_help_update_translation]);
601 	mHelpMenu->addSeparator();
602 	mHelpMenu->addAction(mHelpActions[menu_help_bug]);
603 	mHelpMenu->addAction(mHelpActions[menu_help_documentation]);
604 	mHelpMenu->addAction(mHelpActions[menu_help_about]);
605 
606 	return mHelpMenu;
607 }
608 
createSyncMenu(QWidget * parent)609 QMenu* DkActionManager::createSyncMenu(QWidget * parent) {
610 
611 	mSyncMenu = new QMenu(QObject::tr("&Sync"), parent);
612 
613 	// local host menu
614 	mLocalMenu = new DkTcpMenu(QObject::tr("&Synchronize"), mSyncMenu);
615 	mLocalMenu->showNoClientsFound(true);
616 
617 	// add connect all action
618 	mLocalMenu->addTcpAction(mSyncActions[menu_sync_connect_all]);
619 
620 	mSyncMenu->addMenu(mLocalMenu);
621 	mSyncMenu->addAction(mSyncActions[menu_sync_view]);
622 	mSyncMenu->addAction(mSyncActions[menu_sync_pos]);
623 	mSyncMenu->addAction(mSyncActions[menu_sync_arrange]);
624 	mSyncMenu->addAction(mSyncActions[menu_sync_all_actions]);
625 
626 	return mSyncMenu;
627 }
628 
createContextMenu(QWidget * parent)629 QMenu* DkActionManager::createContextMenu(QWidget* parent) {
630 
631 
632 	mContextMenu = new QMenu(parent);
633 
634 	mContextMenu->addAction(mEditActions[menu_edit_copy_buffer]);
635 	mContextMenu->addAction(mEditActions[menu_edit_copy]);
636 	mContextMenu->addAction(mEditActions[menu_edit_copy_color]);
637 	mContextMenu->addAction(mEditActions[menu_edit_paste]);
638 	mContextMenu->addSeparator();
639 
640 	mContextMenu->addAction(mViewActions[menu_view_frameless]);
641 	mContextMenu->addAction(mViewActions[menu_view_fullscreen]);
642 	mContextMenu->addAction(mPanelActions[menu_panel_menu]);
643 	mContextMenu->addSeparator();
644 
645 	if (DkSettingsManager::param().global().extendedTabs) {
646 		mContextMenu->addAction(mViewActions[menu_view_first_tab]);
647 		mContextMenu->addAction(mViewActions[menu_view_goto_tab]);
648 		mContextMenu->addAction(mViewActions[menu_view_last_tab]);
649 		mContextMenu->addSeparator();
650 	}
651 
652 	QMenu* panelMenu = mContextMenu->addMenu(QObject::tr("&Panels"));
653 	panelMenu->addAction(mPanelActions[menu_panel_toggle]);
654 	panelMenu->addAction(mPanelActions[menu_panel_explorer]);
655 	panelMenu->addAction(mPanelActions[menu_panel_metadata_dock]);
656 	panelMenu->addAction(mPanelActions[menu_panel_preview]);
657 	panelMenu->addAction(mPanelActions[menu_panel_thumbview]);
658 	panelMenu->addAction(mPanelActions[menu_panel_scroller]);
659 	panelMenu->addAction(mPanelActions[menu_panel_exif]);
660 	panelMenu->addAction(mPanelActions[menu_panel_overview]);
661 	panelMenu->addAction(mPanelActions[menu_panel_player]);
662 	panelMenu->addAction(mPanelActions[menu_panel_info]);
663 	panelMenu->addAction(mPanelActions[menu_panel_histogram]);
664 	panelMenu->addAction(mPanelActions[menu_panel_comment]);
665 
666 	mContextMenu->addMenu(sortMenu());
667 
668 	QMenu* viewContextMenu = mContextMenu->addMenu(QObject::tr("&View"));
669 	viewContextMenu->addAction(mViewActions[menu_view_fullscreen]);
670 	viewContextMenu->addAction(mViewActions[menu_view_reset]);
671 	viewContextMenu->addAction(mViewActions[menu_view_100]);
672 	viewContextMenu->addAction(mViewActions[menu_view_fit_frame]);
673 
674 	QMenu* editContextMenu = mContextMenu->addMenu(QObject::tr("&Edit"));
675 	editContextMenu->addAction(mEditActions[menu_edit_image]);
676 	editContextMenu->addSeparator();
677 	editContextMenu->addAction(mEditActions[menu_edit_undo]);
678 	editContextMenu->addAction(mEditActions[menu_edit_redo]);
679 	editContextMenu->addSeparator();
680 	editContextMenu->addAction(mEditActions[menu_edit_rotate_cw]);
681 	editContextMenu->addAction(mEditActions[menu_edit_rotate_ccw]);
682 	editContextMenu->addAction(mEditActions[menu_edit_rotate_180]);
683 	editContextMenu->addSeparator();
684 	editContextMenu->addAction(mEditActions[menu_edit_transform]);
685 	editContextMenu->addAction(mEditActions[menu_edit_crop]);
686 	editContextMenu->addAction(mEditActions[menu_edit_delete]);
687 
688 	mContextMenu->addMenu(mOpenWithMenu);
689 
690 	mContextMenu->addSeparator();
691 	mContextMenu->addAction(mEditActions[menu_edit_preferences]);
692 
693 	return mContextMenu;
694 }
695 
696 // TODO: fix that once and for all
697 //QMenu* DkActionManager::pluginMenu(QWidget* parent) const {
698 //
699 //	if (!mPluginMenu)
700 //		mPluginMenu = new QMenu(QObject::tr("&Plugins"), parent);
701 //
702 //	return mPluginMenu;
703 //}
704 
action(FileMenuActions action) const705 QAction* DkActionManager::action(FileMenuActions action) const {
706 	return mFileActions[action];
707 }
708 
action(SortMenuActions action) const709 QAction* DkActionManager::action(SortMenuActions action) const {
710 	return mSortActions[action];
711 }
712 
action(ViewMenuActions action) const713 QAction* DkActionManager::action(ViewMenuActions action) const {
714 	return mViewActions[action];
715 }
716 
action(EditMenuActions action) const717 QAction* DkActionManager::action(EditMenuActions action) const {
718 	return mEditActions[action];
719 }
720 
action(ToolsMenuActions action) const721 QAction* DkActionManager::action(ToolsMenuActions action) const {
722 	return mToolsActions[action];
723 }
724 
action(PanelMenuActions action) const725 QAction* DkActionManager::action(PanelMenuActions action) const {
726 	return mPanelActions[action];
727 }
728 
action(SyncMenuActions action) const729 QAction* DkActionManager::action(SyncMenuActions action) const {
730 	return mSyncActions[action];
731 }
732 
action(HelpMenuActions action) const733 QAction* DkActionManager::action(HelpMenuActions action) const {
734 	return mHelpActions[action];
735 }
736 
action(PluginMenuActions action) const737 QAction* DkActionManager::action(PluginMenuActions action) const {
738 	return mPluginActions[action];
739 }
740 
action(HiddenActions action) const741 QAction* DkActionManager::action(HiddenActions action) const {
742 	return mHiddenActions[action];
743 }
744 
action(PreviewActions action) const745 QAction* DkActionManager::action(PreviewActions action) const {
746 	return mPreviewActions[action];
747 }
748 
icon(FileIcons icon) const749 QIcon DkActionManager::icon(FileIcons icon) const {
750 	return mFileIcons[icon];
751 }
752 
icon(ViewIcons icon) const753 QIcon DkActionManager::icon(ViewIcons icon) const {
754 	return mViewIcons[icon];
755 }
756 
icon(EditIcons icon) const757 QIcon DkActionManager::icon(EditIcons icon) const {
758 	return mEditIcons[icon];
759 }
760 
fileActions() const761 QVector<QAction*> DkActionManager::fileActions() const {
762 	return mFileActions;
763 }
764 
sortActions() const765 QVector<QAction*> DkActionManager::sortActions() const {
766 	return mSortActions;
767 }
768 
openWithActions() const769 QVector<QAction*> DkActionManager::openWithActions() const {
770 
771 	if (!openWithMenu())
772 		return QVector<QAction*>();
773 
774 	QList<QAction* > openWithActionList = openWithMenu()->actions();
775 	QVector<QAction* > owas;
776 
777 	// the separator creates a NULL action?! - remove it here...
778 	for (auto a : openWithActionList)
779 		if (!a->text().isNull())
780 			owas << a;
781 
782 	return owas;
783 }
784 
viewActions() const785 QVector<QAction*> DkActionManager::viewActions() const {
786 	return mViewActions;
787 }
788 
editActions() const789 QVector<QAction*> DkActionManager::editActions() const {
790 	return mEditActions;
791 }
792 
toolsActions() const793 QVector<QAction*> DkActionManager::toolsActions() const {
794 	return mToolsActions;
795 }
796 
panelActions() const797 QVector<QAction*> DkActionManager::panelActions() const {
798 	return mPanelActions;
799 }
800 
syncActions() const801 QVector<QAction*> DkActionManager::syncActions() const {
802 	return mSyncActions;
803 }
804 
helpActions() const805 QVector<QAction*> DkActionManager::helpActions() const {
806 	return mHelpActions;
807 }
808 
pluginActions() const809 QVector<QAction*> DkActionManager::pluginActions() const {
810 	return mPluginActions;
811 }
812 
hiddenActions() const813 QVector<QAction*> DkActionManager::hiddenActions() const {
814 	return mHiddenActions;
815 }
816 
previewActions() const817 QVector<QAction*> DkActionManager::previewActions() const {
818 	return mPreviewActions;
819 }
820 
manipulatorActions() const821 QVector<QAction*> DkActionManager::manipulatorActions() const {
822 	return mManipulators.actions();
823 }
824 
appManager() const825 DkAppManager* DkActionManager::appManager() const {
826 	return mAppManager;
827 }
828 
pluginActionManager() const829 DkPluginActionManager* DkActionManager::pluginActionManager() const {
830 	return mPluginManager;
831 }
832 
fileMenu() const833 QMenu* DkActionManager::fileMenu() const {
834 	return mFileMenu;
835 }
836 
sortMenu() const837 QMenu* DkActionManager::sortMenu() const {
838 	return mSortMenu;
839 }
840 
openWithMenu() const841 QMenu* DkActionManager::openWithMenu() const {
842 	return mOpenWithMenu;
843 }
844 
viewMenu() const845 QMenu* DkActionManager::viewMenu() const {
846 	return mViewMenu;
847 }
848 
editMenu() const849 QMenu* DkActionManager::editMenu() const {
850 	return mEditMenu;
851 }
852 
toolsMenu() const853 QMenu* DkActionManager::toolsMenu() const {
854 	return mToolsMenu;
855 }
856 
panelMenu() const857 QMenu* DkActionManager::panelMenu() const {
858 	return mPanelMenu;
859 }
860 
helpMenu() const861 QMenu* DkActionManager::helpMenu() const {
862 	return mHelpMenu;
863 }
864 
contextMenu() const865 QMenu* DkActionManager::contextMenu() const {
866 	return mContextMenu;
867 }
868 
syncMenu() const869 QMenu* DkActionManager::syncMenu() const {
870 	return mSyncMenu;
871 }
872 
manipulatorMenu() const873 QMenu * DkActionManager::manipulatorMenu() const {
874 	return mManipulatorMenu;
875 }
876 
localMenu() const877 DkTcpMenu* DkActionManager::localMenu() const {
878 	return mLocalMenu;
879 }
880 
manipulatorManager() const881 DkManipulatorManager DkActionManager::manipulatorManager() const {
882 	return mManipulators;
883 }
884 
createMenus(QWidget * parent)885 void DkActionManager::createMenus(QWidget* parent) {
886 
887 	createSortMenu(parent);
888 	createOpenWithMenu(parent);
889 	createFileMenu(parent);
890 	createViewMenu(parent);
891 	createEditMenu(parent);
892 	createManipulatorMenu(parent);
893 	createToolsMenu(parent);
894 	createPanelMenu(parent);
895 	createSyncMenu(parent);
896 	createHelpMenu(parent);
897 	createContextMenu(parent);
898 }
899 
init()900 void DkActionManager::init() {
901 
902 	mAppManager = new DkAppManager(DkUtils::getMainWindow());
903 
904 #ifdef WITH_PLUGINS
905 	mPluginManager = new DkPluginActionManager(DkUtils::getMainWindow());
906 #endif
907 
908 	createIcons();
909 }
910 
createIcons()911 void DkActionManager::createIcons() {
912 
913 	mFileIcons.resize(icon_file_end);
914 	mFileIcons[icon_file_dir] = DkImage::loadIcon(":/nomacs/img/dir.svg");
915 	mFileIcons[icon_file_open] = DkImage::loadIcon(":/nomacs/img/open.svg");
916 	mFileIcons[icon_file_save] = DkImage::loadIcon(":/nomacs/img/save.svg");
917 	mFileIcons[icon_file_print] = DkImage::loadIcon(":/nomacs/img/print.svg");
918 	mFileIcons[icon_file_open_large] = QIcon(":/nomacs/img/open.svg");
919 	mFileIcons[icon_file_dir_large] = QIcon(":/nomacs/img/dir.svg");
920 	mFileIcons[icon_file_prev] = DkImage::loadIcon(":/nomacs/img/previous.svg");
921 	mFileIcons[icon_file_next] = DkImage::loadIcon(":/nomacs/img/next.svg");
922 	mFileIcons[icon_file_filter] = DkImage::loadIcon();
923 	mFileIcons[icon_file_filter].addPixmap(DkImage::loadIcon(":/nomacs/img/filter.svg"), QIcon::Normal, QIcon::On);
924 	mFileIcons[icon_file_filter].addPixmap(DkImage::loadIcon(":/nomacs/img/filter-disabled.svg"), QIcon::Normal, QIcon::Off);
925 	mFileIcons[icon_file_find] = DkImage::loadIcon(":/nomacs/img/find.svg");
926 
927 	mEditIcons.resize(icon_edit_end);
928 	mEditIcons[icon_edit_image] = DkImage::loadIcon(":/nomacs/img/sliders.svg");
929 	mEditIcons[icon_edit_rotate_cw] = DkImage::loadIcon(":/nomacs/img/rotate-cw.svg");
930 	mEditIcons[icon_edit_rotate_ccw] = DkImage::loadIcon(":/nomacs/img/rotate-cc.svg");
931 	mEditIcons[icon_edit_crop] = DkImage::loadIcon(":/nomacs/img/crop.svg");
932 	mEditIcons[icon_edit_resize] = DkImage::loadIcon(":/nomacs/img/resize.svg");
933 	mEditIcons[icon_edit_copy] = DkImage::loadIcon(":/nomacs/img/copy.svg");
934 	mEditIcons[icon_edit_paste] = DkImage::loadIcon(":/nomacs/img/paste.svg");
935 	mEditIcons[icon_edit_delete] = DkImage::loadIcon(":/nomacs/img/trash.svg");
936 
937 	mViewIcons.resize(icon_view_end);
938 	mViewIcons[icon_view_fullscreen] = DkImage::loadIcon(":/nomacs/img/fullscreen.svg");
939 	mViewIcons[icon_view_reset] = DkImage::loadIcon(":/nomacs/img/zoom-reset.svg");
940 	mViewIcons[icon_view_100] = DkImage::loadIcon(":/nomacs/img/zoom-100.svg");
941 	mViewIcons[icon_view_gps] = DkImage::loadIcon(":/nomacs/img/location.svg");
942 	mViewIcons[icon_view_zoom_in] = DkImage::loadIcon(":/nomacs/img/zoom-in.svg");
943 	mViewIcons[icon_view_zoom_out] = DkImage::loadIcon(":/nomacs/img/zoom-out.svg");
944 
945 	mViewIcons[icon_view_movie_play] = DkImage::loadIcon(":/nomacs/img/play.svg");
946 	mViewIcons[icon_view_movie_play].addPixmap(DkImage::loadIcon(":/nomacs/img/play.svg"), QIcon::Normal, QIcon::On);
947 	mViewIcons[icon_view_movie_play].addPixmap(DkImage::loadIcon(":/nomacs/img/pause.svg"), QIcon::Normal, QIcon::Off);
948 	mViewIcons[icon_view_movie_prev] = DkImage::loadIcon(":/nomacs/img/previous.svg");
949 	mViewIcons[icon_view_movie_next] = DkImage::loadIcon(":/nomacs/img/next.svg");
950 }
951 
createActions(QWidget * parent)952 void DkActionManager::createActions(QWidget* parent) {
953 
954 	// file actions
955 	mFileActions.resize(menu_file_end);
956 
957 	mFileActions[menu_file_open] = new QAction(mFileIcons[icon_file_open], QObject::tr("&Open"), parent);
958 	mFileActions[menu_file_open]->setShortcuts(QKeySequence::Open);
959 	mFileActions[menu_file_open]->setStatusTip(QObject::tr("Open an image"));
960 
961 	mFileActions[menu_file_open_dir] = new QAction(mFileIcons[icon_file_dir], QObject::tr("Open &Directory"), parent);
962 	mFileActions[menu_file_open_dir]->setShortcut(QKeySequence(shortcut_open_dir));
963 	mFileActions[menu_file_open_dir]->setStatusTip(QObject::tr("Open a directory and load its first image"));
964 
965 	mFileActions[menu_file_open_list] = new QAction(QObject::tr("&Open Tabs"), parent);
966 	mFileActions[menu_file_open_list]->setStatusTip(QObject::tr("Open a texfile containing a list of filepaths, and open tabs for them"));
967 
968 	mFileActions[menu_file_quick_launch] = new QAction(QObject::tr("&Quick Launch"), parent);
969 	mFileActions[menu_file_quick_launch]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
970 #ifdef Q_OS_WIN
971 	mFileActions[menu_file_quick_launch]->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
972 #else
973 	mFileActions[menu_file_quick_launch]->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
974 #endif
975 	mFileActions[menu_file_app_manager] = new QAction(QObject::tr("&Manage Applications"), parent);
976 	mFileActions[menu_file_app_manager]->setStatusTip(QObject::tr("Manage Applications which are Automatically Opened"));
977 	mFileActions[menu_file_app_manager]->setShortcut(QKeySequence(shortcut_app_manager));
978 
979 	mFileActions[menu_file_rename] = new QAction(QObject::tr("Re&name"), parent);
980 	mFileActions[menu_file_rename]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
981 	mFileActions[menu_file_rename]->setShortcut(QKeySequence(shortcut_rename));
982 	mFileActions[menu_file_rename]->setStatusTip(QObject::tr("Rename an image"));
983 
984 	mFileActions[menu_file_goto] = new QAction(QObject::tr("&Go To"), parent);
985 	mFileActions[menu_file_goto]->setShortcut(QKeySequence(shortcut_goto));
986 	mFileActions[menu_file_goto]->setStatusTip(QObject::tr("Go To an image"));
987 
988 	mFileActions[menu_file_save] = new QAction(mFileIcons[icon_file_save], QObject::tr("&Save"), parent);
989 	mFileActions[menu_file_save]->setShortcuts(QKeySequence::Save);
990 	mFileActions[menu_file_save]->setStatusTip(QObject::tr("Save an image"));
991 
992 	mFileActions[menu_file_save_as] = new QAction(QObject::tr("S&ave As"), parent);
993 	mFileActions[menu_file_save_as]->setShortcut(QKeySequence(shortcut_save_as));
994 	mFileActions[menu_file_save_as]->setStatusTip(QObject::tr("Save an image as"));
995 
996 	mFileActions[menu_file_save_copy] = new QAction(QObject::tr("Sa&ve a Copy"), parent);
997 	mFileActions[menu_file_save_copy]->setStatusTip(QObject::tr("Copy the Image"));
998 
999 	mFileActions[menu_file_save_list] = new QAction(QObject::tr("&Save Tabs"), parent);
1000 	mFileActions[menu_file_save_list]->setStatusTip(QObject::tr("Save a newline separated list of the filenames of the open tabs"));
1001 
1002 	mFileActions[menu_file_save_web] = new QAction(QObject::tr("&Save for Web"), parent);
1003 	mFileActions[menu_file_save_web]->setStatusTip(QObject::tr("Save an Image for Web Applications"));
1004 
1005 	mFileActions[menu_file_print] = new QAction(mFileIcons[icon_file_print], QObject::tr("&Print"), parent);
1006 	mFileActions[menu_file_print]->setShortcuts(QKeySequence::Print);
1007 	mFileActions[menu_file_print]->setStatusTip(QObject::tr("Print an image"));
1008 
1009 	mFileActions[menu_file_show_recent] = new QAction(QObject::tr("&Recent Files"), parent);
1010 	mFileActions[menu_file_show_recent]->setShortcut(QKeySequence(shortcut_recent_files));
1011 	mFileActions[menu_file_show_recent]->setCheckable(true);
1012 	mFileActions[menu_file_show_recent]->setChecked(false);
1013 	mFileActions[menu_file_show_recent]->setStatusTip(QObject::tr("Show Recent Files"));
1014 
1015 	mFileActions[menu_file_reload] = new QAction(QObject::tr("&Reload File"), parent);
1016 	mFileActions[menu_file_reload]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1017 	mFileActions[menu_file_reload]->setShortcut(QKeySequence(shortcut_reload));
1018 	mFileActions[menu_file_reload]->setStatusTip(QObject::tr("Reload File"));
1019 
1020 	mFileActions[menu_file_next] = new QAction(mFileIcons[icon_file_next], QObject::tr("Ne&xt File"), parent);
1021 	mFileActions[menu_file_next]->setShortcutContext(Qt::WidgetShortcut);
1022 	mFileActions[menu_file_next]->setShortcut(QKeySequence(shortcut_next_file));
1023 	mFileActions[menu_file_next]->setStatusTip(QObject::tr("Load next image"));
1024 
1025 	mFileActions[menu_file_prev] = new QAction(mFileIcons[icon_file_prev], QObject::tr("Pre&vious File"), parent);
1026 	mFileActions[menu_file_prev]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1027 	mFileActions[menu_file_prev]->setShortcut(QKeySequence(shortcut_prev_file));
1028 	mFileActions[menu_file_prev]->setStatusTip(QObject::tr("Load previous file"));
1029 
1030 	mFileActions[menu_file_new_instance] = new QAction(QObject::tr("St&art New Instance"), parent);
1031 	mFileActions[menu_file_new_instance]->setShortcut(QKeySequence(shortcut_new_instance));
1032 	mFileActions[menu_file_new_instance]->setStatusTip(QObject::tr("Open file in new instance"));
1033 
1034 	mFileActions[menu_file_private_instance] = new QAction(QObject::tr("St&art Private Instance"), parent);
1035 	mFileActions[menu_file_private_instance]->setShortcut(QKeySequence(shortcut_private_instance));
1036 	mFileActions[menu_file_private_instance]->setStatusTip(QObject::tr("Open private instance"));
1037 
1038 	mFileActions[menu_file_find] = new QAction(mFileIcons[icon_file_find], QObject::tr("&Find && Filter"), parent);
1039 	mFileActions[menu_file_find]->setShortcut(QKeySequence::Find);
1040 	mFileActions[menu_file_find]->setStatusTip(QObject::tr("Find an image"));
1041 
1042 	mFileActions[menu_file_recursive] = new QAction(QObject::tr("Scan Folder Re&cursive"), parent);
1043 	mFileActions[menu_file_recursive]->setStatusTip(QObject::tr("Step through Folder and Sub Folders"));
1044 	mFileActions[menu_file_recursive]->setCheckable(true);
1045 	mFileActions[menu_file_recursive]->setChecked(DkSettingsManager::param().global().scanSubFolders);
1046 
1047 	mFileActions[menu_file_exit] = new QAction(QObject::tr("&Exit"), parent);
1048 	mFileActions[menu_file_exit]->setStatusTip(QObject::tr("Exit"));
1049 
1050 	// sort actions
1051 	mSortActions.resize(menu_sort_end);
1052 
1053 	mSortActions[menu_sort_filename] = new QAction(QObject::tr("by &Filename"), parent);
1054 	mSortActions[menu_sort_filename]->setObjectName("menu_sort_filename");
1055 	mSortActions[menu_sort_filename]->setStatusTip(QObject::tr("Sort by Filename"));
1056 	mSortActions[menu_sort_filename]->setCheckable(true);
1057 	mSortActions[menu_sort_filename]->setChecked(DkSettingsManager::param().global().sortMode == DkSettings::sort_filename);
1058 
1059 	mSortActions[menu_sort_date_created] = new QAction(QObject::tr("by Date &Created"), parent);
1060 	mSortActions[menu_sort_date_created]->setObjectName("menu_sort_date_created");
1061 	mSortActions[menu_sort_date_created]->setStatusTip(QObject::tr("Sort by Date Created"));
1062 	mSortActions[menu_sort_date_created]->setCheckable(true);
1063 	mSortActions[menu_sort_date_created]->setChecked(DkSettingsManager::param().global().sortMode == DkSettings::sort_date_created);
1064 
1065 	mSortActions[menu_sort_date_modified] = new QAction(QObject::tr("by Date Modified"), parent);
1066 	mSortActions[menu_sort_date_modified]->setObjectName("menu_sort_date_modified");
1067 	mSortActions[menu_sort_date_modified]->setStatusTip(QObject::tr("Sort by Date Last Modified"));
1068 	mSortActions[menu_sort_date_modified]->setCheckable(true);
1069 	mSortActions[menu_sort_date_modified]->setChecked(DkSettingsManager::param().global().sortMode == DkSettings::sort_date_modified);
1070 
1071 	mSortActions[menu_sort_random] = new QAction(QObject::tr("Random"), parent);
1072 	mSortActions[menu_sort_random]->setObjectName("menu_sort_random");
1073 	mSortActions[menu_sort_random]->setStatusTip(QObject::tr("Sort in Random Order"));
1074 	mSortActions[menu_sort_random]->setCheckable(true);
1075 	mSortActions[menu_sort_random]->setChecked(DkSettingsManager::param().global().sortMode == DkSettings::sort_random);
1076 
1077 	mSortActions[menu_sort_ascending] = new QAction(QObject::tr("&Ascending"), parent);
1078 	mSortActions[menu_sort_ascending]->setObjectName("menu_sort_ascending");
1079 	mSortActions[menu_sort_ascending]->setStatusTip(QObject::tr("Sort in Ascending Order"));
1080 	mSortActions[menu_sort_ascending]->setCheckable(true);
1081 	mSortActions[menu_sort_ascending]->setChecked(DkSettingsManager::param().global().sortDir == Qt::AscendingOrder);
1082 
1083 	mSortActions[menu_sort_descending] = new QAction(QObject::tr("&Descending"), parent);
1084 	mSortActions[menu_sort_descending]->setObjectName("menu_sort_descending");
1085 	mSortActions[menu_sort_descending]->setStatusTip(QObject::tr("Sort in Descending Order"));
1086 	mSortActions[menu_sort_descending]->setCheckable(true);
1087 	mSortActions[menu_sort_descending]->setChecked(DkSettingsManager::param().global().sortDir == Qt::DescendingOrder);
1088 
1089 	// edit actions
1090 	mEditActions.resize(menu_edit_end);
1091 
1092 	mEditActions[menu_edit_rotate_cw] = new QAction(mEditIcons[icon_edit_rotate_cw], QObject::tr("9&0%1 Clockwise").arg(dk_degree_str), parent);
1093 	mEditActions[menu_edit_rotate_cw]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1094 	mEditActions[menu_edit_rotate_cw]->setShortcut(QKeySequence(shortcut_rotate_cw));
1095 	mEditActions[menu_edit_rotate_cw]->setStatusTip(QObject::tr("rotate the image 90%1 clockwise").arg(dk_degree_str));
1096 
1097 	mEditActions[menu_edit_rotate_ccw] = new QAction(mEditIcons[icon_edit_rotate_ccw], QObject::tr("&90%1 Counter Clockwise").arg(dk_degree_str), parent);
1098 	mEditActions[menu_edit_rotate_ccw]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1099 	mEditActions[menu_edit_rotate_ccw]->setShortcut(QKeySequence(shortcut_rotate_ccw));
1100 	mEditActions[menu_edit_rotate_ccw]->setStatusTip(QObject::tr("rotate the image 90%1 counter clockwise").arg(dk_degree_str));
1101 
1102 	mEditActions[menu_edit_rotate_180] = new QAction(QObject::tr("180%1").arg(dk_degree_str), parent);
1103 	mEditActions[menu_edit_rotate_180]->setStatusTip(QObject::tr("rotate the image by 180%1").arg(dk_degree_str));
1104 
1105 	mEditActions[menu_edit_undo] = new QAction(QObject::tr("&Undo"), parent);
1106 	mEditActions[menu_edit_undo]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1107 	mEditActions[menu_edit_undo]->setShortcut(QKeySequence::Undo);
1108 	mEditActions[menu_edit_undo]->setStatusTip(QObject::tr("Undo Last Action"));
1109 
1110 	mEditActions[menu_edit_redo] = new QAction(QObject::tr("&Redo"), parent);
1111 	mEditActions[menu_edit_redo]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1112 	mEditActions[menu_edit_redo]->setShortcut(QKeySequence::Redo);
1113 	mEditActions[menu_edit_redo]->setStatusTip(QObject::tr("Redo Last Action"));
1114 
1115 	mEditActions[menu_edit_copy] = new QAction(mEditIcons[icon_edit_copy], QObject::tr("&Copy"), parent);
1116 	mEditActions[menu_edit_copy]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1117 	mEditActions[menu_edit_copy]->setShortcut(QKeySequence::Copy);
1118 	mEditActions[menu_edit_copy]->setStatusTip(QObject::tr("copy image"));
1119 
1120 	mEditActions[menu_edit_copy_buffer] = new QAction(QObject::tr("Copy &Buffer"), parent);
1121 	mEditActions[menu_edit_copy_buffer]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1122 	mEditActions[menu_edit_copy_buffer]->setShortcut(shortcut_copy_buffer);
1123 	mEditActions[menu_edit_copy_buffer]->setStatusTip(QObject::tr("copy image"));
1124 
1125 	mEditActions[menu_edit_copy_color] = new QAction(QObject::tr("Copy Co&lor"), parent);
1126 	mEditActions[menu_edit_copy_color]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1127 	mEditActions[menu_edit_copy_color]->setShortcut(shortcut_copy_color);
1128 	mEditActions[menu_edit_copy_color]->setStatusTip(QObject::tr("copy pixel color value as HEX"));
1129 
1130 	QList<QKeySequence> pastScs;
1131 	pastScs.append(QKeySequence::Paste);
1132 	pastScs.append(shortcut_paste);
1133 	mEditActions[menu_edit_paste] = new QAction(mEditIcons[icon_edit_paste], QObject::tr("&Paste"), parent);
1134 	mEditActions[menu_edit_paste]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1135 	mEditActions[menu_edit_paste]->setShortcuts(pastScs);
1136 	mEditActions[menu_edit_paste]->setStatusTip(QObject::tr("paste image"));
1137 
1138 	mEditActions[menu_edit_delete] = new QAction(mEditIcons[icon_edit_delete], QObject::tr("&Delete"), parent);
1139 	mEditActions[menu_edit_delete]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1140 	mEditActions[menu_edit_delete]->setShortcut(QKeySequence::Delete);
1141 	mEditActions[menu_edit_delete]->setStatusTip(QObject::tr("delete current fileInfo"));
1142 
1143 	mEditActions[menu_edit_shortcuts] = new QAction(QObject::tr("&Keyboard Shortcuts"), parent);
1144 	mEditActions[menu_edit_shortcuts]->setShortcut(QKeySequence(shortcut_shortcuts));
1145 	mEditActions[menu_edit_shortcuts]->setStatusTip(QObject::tr("lets you customize your keyboard shortcuts"));
1146 
1147 	mEditActions[menu_edit_preferences] = new QAction(QObject::tr("&Settings"), parent);
1148 	mEditActions[menu_edit_preferences]->setShortcut(QKeySequence(shortcut_settings));
1149 	mEditActions[menu_edit_preferences]->setStatusTip(QObject::tr("settings"));
1150 
1151 	// image adjustments menu
1152 	mEditActions[menu_edit_image] = new QAction(mEditIcons[icon_edit_image], QObject::tr("Image &Adjustments"), parent);
1153 	mEditActions[menu_edit_image]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1154 	mEditActions[menu_edit_image]->setShortcut(QKeySequence(shortcut_edit_image));
1155 	mEditActions[menu_edit_image]->setStatusTip(QObject::tr("open image manipulation toolbox"));
1156 	mEditActions[menu_edit_image]->setCheckable(true);
1157 
1158 	mEditActions[menu_edit_transform] = new QAction(mEditIcons[icon_edit_resize], QObject::tr("R&esize Image"), parent);
1159 	mEditActions[menu_edit_transform]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1160 	mEditActions[menu_edit_transform]->setShortcut(shortcut_transform);
1161 	mEditActions[menu_edit_transform]->setStatusTip(QObject::tr("resize the current image"));
1162 
1163 	mEditActions[menu_edit_crop] = new QAction(mEditIcons[icon_edit_crop], QObject::tr("Cr&op Image"), parent);
1164 	mEditActions[menu_edit_crop]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1165 	mEditActions[menu_edit_crop]->setShortcut(shortcut_crop);
1166 	mEditActions[menu_edit_crop]->setStatusTip(QObject::tr("cut the current image"));
1167 	mEditActions[menu_edit_crop]->setCheckable(true);
1168 	mEditActions[menu_edit_crop]->setChecked(false);
1169 
1170 	// panel actions
1171 	mPanelActions.resize(menu_panel_end);
1172 	mPanelActions[menu_panel_menu] = new QAction(QObject::tr("Show &Menu"), parent);
1173 	mPanelActions[menu_panel_menu]->setStatusTip(QObject::tr("Hides the Menu and Shows it Again on ALT"));
1174 	mPanelActions[menu_panel_menu]->setCheckable(true);
1175 
1176 	mPanelActions[menu_panel_toolbar] = new QAction(QObject::tr("Tool&bar"), parent);
1177 	mPanelActions[menu_panel_toolbar]->setShortcut(QKeySequence(shortcut_show_toolbar));
1178 	mPanelActions[menu_panel_toolbar]->setStatusTip(QObject::tr("Show Toolbar"));
1179 	mPanelActions[menu_panel_toolbar]->setCheckable(true);
1180 
1181 	mPanelActions[menu_panel_statusbar] = new QAction(QObject::tr("&Statusbar"), parent);
1182 	mPanelActions[menu_panel_statusbar]->setShortcut(QKeySequence(shortcut_show_statusbar));
1183 	mPanelActions[menu_panel_statusbar]->setStatusTip(QObject::tr("Show Statusbar"));
1184 	mPanelActions[menu_panel_statusbar]->setCheckable(true);
1185 
1186 	mPanelActions[menu_panel_transfertoolbar] = new QAction(QObject::tr("&Pseudocolor Function"), parent);
1187 	mPanelActions[menu_panel_transfertoolbar]->setShortcut(QKeySequence(shortcut_show_transfer));
1188 	mPanelActions[menu_panel_transfertoolbar]->setStatusTip(QObject::tr("Show Pseudocolor Function"));
1189 	mPanelActions[menu_panel_transfertoolbar]->setCheckable(true);
1190 	mPanelActions[menu_panel_transfertoolbar]->setChecked(false);
1191 
1192 	mPanelActions[menu_panel_overview] = new QAction(QObject::tr("O&verview"), parent);
1193 	mPanelActions[menu_panel_overview]->setShortcut(QKeySequence(shortcut_show_overview));
1194 	mPanelActions[menu_panel_overview]->setStatusTip(QObject::tr("Shows the Zoom Overview"));
1195 	mPanelActions[menu_panel_overview]->setCheckable(true);
1196 	mPanelActions[menu_panel_overview]->setChecked(DkSettingsManager::param().app().showOverview.testBit(DkSettingsManager::param().app().currentAppMode));
1197 
1198 	mPanelActions[menu_panel_player] = new QAction(QObject::tr("Pla&yer"), parent);
1199 	mPanelActions[menu_panel_player]->setShortcut(QKeySequence(shortcut_show_player));
1200 	mPanelActions[menu_panel_player]->setStatusTip(QObject::tr("Shows the Slide Show Player"));
1201 	mPanelActions[menu_panel_player]->setCheckable(true);
1202 
1203 	mPanelActions[menu_panel_toggle] = new QAction(QObject::tr("&Hide All Panels"), parent);
1204 	mPanelActions[menu_panel_toggle]->setShortcut(QKeySequence(shortcut_toggle_panels));
1205 	mPanelActions[menu_panel_toggle]->setStatusTip(QObject::tr("Hide all panels"));
1206 	mPanelActions[menu_panel_toggle]->setCheckable(true);
1207 	mPanelActions[menu_panel_toggle]->setChecked(DkSettingsManager::param().app().hideAllPanels);
1208 
1209 	mPanelActions[menu_panel_explorer] = new QAction(QObject::tr("File &Explorer"), parent);
1210 	mPanelActions[menu_panel_explorer]->setShortcut(QKeySequence(shortcut_show_explorer));
1211 	mPanelActions[menu_panel_explorer]->setStatusTip(QObject::tr("Show File Explorer"));
1212 	mPanelActions[menu_panel_explorer]->setCheckable(true);
1213 
1214 	mPanelActions[menu_panel_metadata_dock] = new QAction(QObject::tr("Metadata &Info"), parent);
1215 	mPanelActions[menu_panel_metadata_dock]->setShortcut(QKeySequence(shortcut_show_metadata_dock));
1216 	mPanelActions[menu_panel_metadata_dock]->setStatusTip(QObject::tr("Show Metadata Info"));
1217 	mPanelActions[menu_panel_metadata_dock]->setCheckable(true);
1218 
1219 	mPanelActions[menu_panel_preview] = new QAction(QObject::tr("&Thumbnails"), parent);
1220 	mPanelActions[menu_panel_preview]->setShortcut(QKeySequence(shortcut_open_preview));
1221 	mPanelActions[menu_panel_preview]->setStatusTip(QObject::tr("Show Thumbnails"));
1222 	mPanelActions[menu_panel_preview]->setCheckable(true);
1223 
1224 	mPanelActions[menu_panel_thumbview] = new QAction(QObject::tr("&Thumbnail Preview"), parent);
1225 	mPanelActions[menu_panel_thumbview]->setShortcut(QKeySequence(shortcut_open_thumbview));
1226 	mPanelActions[menu_panel_thumbview]->setStatusTip(QObject::tr("Show Thumbnails Preview"));
1227 	mPanelActions[menu_panel_thumbview]->setCheckable(true);
1228 
1229 	mPanelActions[menu_panel_scroller] = new QAction(QObject::tr("&Folder Scrollbar"), parent);
1230 	mPanelActions[menu_panel_scroller]->setStatusTip(QObject::tr("Show Folder Scrollbar"));
1231 	mPanelActions[menu_panel_scroller]->setCheckable(true);
1232 
1233 	mPanelActions[menu_panel_exif] = new QAction(QObject::tr("&Metadata Ribbon"), parent);
1234 	mPanelActions[menu_panel_exif]->setShortcut(QKeySequence(shortcut_show_exif));
1235 	mPanelActions[menu_panel_exif]->setStatusTip(QObject::tr("Shows the Metadata Panel"));
1236 	mPanelActions[menu_panel_exif]->setCheckable(true);
1237 
1238 	mPanelActions[menu_panel_info] = new QAction(QObject::tr("File &Info"), parent);
1239 	mPanelActions[menu_panel_info]->setShortcut(QKeySequence(shortcut_show_info));
1240 	mPanelActions[menu_panel_info]->setStatusTip(QObject::tr("Shows the Info Panel"));
1241 	mPanelActions[menu_panel_info]->setCheckable(true);
1242 
1243 	mPanelActions[menu_panel_histogram] = new QAction(QObject::tr("&Histogram"), parent);
1244 	mPanelActions[menu_panel_histogram]->setShortcut(QKeySequence(shortcut_show_histogram));
1245 	mPanelActions[menu_panel_histogram]->setStatusTip(QObject::tr("Shows the Histogram Panel"));
1246 	mPanelActions[menu_panel_histogram]->setCheckable(true);
1247 
1248 	mPanelActions[menu_panel_comment] = new QAction(QObject::tr("Image &Notes"), parent);
1249 	mPanelActions[menu_panel_comment]->setShortcut(QKeySequence(shortcut_show_comment));
1250 	mPanelActions[menu_panel_comment]->setStatusTip(QObject::tr("Shows Image Notes"));
1251 	mPanelActions[menu_panel_comment]->setCheckable(true);
1252 
1253 	mPanelActions[menu_panel_history] = new QAction(QObject::tr("Edit &History"), parent);
1254 	mPanelActions[menu_panel_history]->setStatusTip(QObject::tr("Shows the edit history"));
1255 	mPanelActions[menu_panel_history]->setShortcut(QKeySequence(shortcut_show_history));
1256 	mPanelActions[menu_panel_history]->setCheckable(true);
1257 
1258 	mPanelActions[menu_panel_log] = new QAction(QObject::tr("Show &Log"), parent);
1259 	mPanelActions[menu_panel_log]->setStatusTip(QObject::tr("Shows the log window"));
1260 	mPanelActions[menu_panel_log]->setShortcut(QKeySequence(shortcut_show_log));
1261 	mPanelActions[menu_panel_log]->setCheckable(true);
1262 
1263 	// view actions
1264 	mViewActions.resize(menu_view_end);
1265 
1266 	mViewActions[menu_view_new_tab] = new QAction(QObject::tr("New &Tab"), parent);
1267 	mViewActions[menu_view_new_tab]->setShortcut(QKeySequence(shortcut_new_tab));
1268 	mViewActions[menu_view_new_tab]->setStatusTip(QObject::tr("Open a new tab"));
1269 
1270 	mViewActions[menu_view_close_tab] = new QAction(QObject::tr("&Close Tab"), parent);
1271 	mViewActions[menu_view_close_tab]->setShortcut(QKeySequence(shortcut_close_tab));
1272 	mViewActions[menu_view_close_tab]->setStatusTip(QObject::tr("Close current tab"));
1273 
1274 	mViewActions[menu_view_close_all_tabs] = new QAction(QObject::tr("&Close All Tabs"), parent);
1275 	mViewActions[menu_view_close_all_tabs]->setStatusTip(QObject::tr("Close all open tabs"));
1276 
1277 	mViewActions[menu_view_fit_frame] = new QAction(QObject::tr("&Fit Window"), parent);
1278 	mViewActions[menu_view_fit_frame]->setShortcut(QKeySequence(shortcut_fit_frame));
1279 	mViewActions[menu_view_fit_frame]->setStatusTip(QObject::tr("Fit window to the image"));
1280 
1281 	mViewActions[menu_view_first_tab] = new QAction(QObject::tr("F&irst Tab"), parent);
1282 	mViewActions[menu_view_first_tab]->setStatusTip(QObject::tr("Switch to first tab"));
1283 
1284 	mViewActions[menu_view_previous_tab] = new QAction(QObject::tr("&Previous Tab"), parent);
1285 	mViewActions[menu_view_previous_tab]->setShortcut(QKeySequence(shortcut_previous_tab));
1286 	mViewActions[menu_view_previous_tab]->setStatusTip(QObject::tr("Switch to previous tab"));
1287 
1288 	mViewActions[menu_view_goto_tab] = new QAction(QObject::tr("&Go to Tab"), parent);
1289 	mViewActions[menu_view_goto_tab]->setStatusTip(QObject::tr("Go to tab by index"));
1290 
1291 	mViewActions[menu_view_next_tab] = new QAction(QObject::tr("&Next Tab"), parent);
1292 	mViewActions[menu_view_next_tab]->setShortcut(QKeySequence(shortcut_next_tab));
1293 	mViewActions[menu_view_next_tab]->setStatusTip(QObject::tr("Switch to next tab"));
1294 
1295 	mViewActions[menu_view_last_tab] = new QAction(QObject::tr("La&st Tab"), parent);
1296 	mViewActions[menu_view_last_tab]->setStatusTip(QObject::tr("Switch to last tab"));
1297 
1298 	QList<QKeySequence> scs;
1299 	scs.append(shortcut_full_screen_ff);
1300 	scs.append(shortcut_full_screen_ad);
1301 	mViewActions[menu_view_fullscreen] = new QAction(mViewIcons[icon_view_fullscreen], QObject::tr("Fu&ll Screen"), parent);
1302 	mViewActions[menu_view_fullscreen]->setShortcuts(scs);
1303 	mViewActions[menu_view_fullscreen]->setStatusTip(QObject::tr("Full Screen"));
1304 
1305 	mViewActions[menu_view_reset] = new QAction(mViewIcons[icon_view_reset], QObject::tr("&Zoom to Fit"), parent);
1306 	mViewActions[menu_view_reset]->setShortcut(QKeySequence(shortcut_reset_view));
1307 	mViewActions[menu_view_reset]->setStatusTip(QObject::tr("Shows the initial view (no zooming)"));
1308 
1309 	mViewActions[menu_view_100] = new QAction(mViewIcons[icon_view_100], QObject::tr("Show &100%"), parent);
1310 	mViewActions[menu_view_100]->setShortcut(QKeySequence(shortcut_zoom_full));
1311 	mViewActions[menu_view_100]->setStatusTip(QObject::tr("Shows the image at 100%"));
1312 
1313 	mViewActions[menu_view_zoom_in] = new QAction(mViewIcons[icon_view_zoom_in], QObject::tr("Zoom &In"), parent);
1314 	mViewActions[menu_view_zoom_in]->setShortcut(QKeySequence::ZoomIn);
1315 	mViewActions[menu_view_zoom_in]->setStatusTip(QObject::tr("zoom in"));
1316 
1317 	mViewActions[menu_view_zoom_out] = new QAction(mViewIcons[icon_view_zoom_out], QObject::tr("&Zoom Out"), parent);
1318 	mViewActions[menu_view_zoom_out]->setShortcut(QKeySequence::ZoomOut);
1319 	mViewActions[menu_view_zoom_out]->setStatusTip(QObject::tr("zoom out"));
1320 
1321 	mViewActions[menu_view_anti_aliasing] = new QAction(QObject::tr("&Anti Aliasing"), parent);
1322 	mViewActions[menu_view_anti_aliasing]->setShortcut(QKeySequence(shortcut_anti_aliasing));
1323 	mViewActions[menu_view_anti_aliasing]->setStatusTip(QObject::tr("if checked images are smoother"));
1324 	mViewActions[menu_view_anti_aliasing]->setCheckable(true);
1325 	mViewActions[menu_view_anti_aliasing]->setChecked(DkSettingsManager::param().display().antiAliasing);
1326 
1327 	mViewActions[menu_view_tp_pattern] = new QAction(QObject::tr("&Transparency Pattern"), parent);
1328 	mViewActions[menu_view_tp_pattern]->setShortcut(QKeySequence(shortcut_tp_pattern));
1329 	mViewActions[menu_view_tp_pattern]->setStatusTip(QObject::tr("if checked, a pattern will be displayed for transparent objects"));
1330 	mViewActions[menu_view_tp_pattern]->setCheckable(true);
1331 	mViewActions[menu_view_tp_pattern]->setChecked(DkSettingsManager::param().display().tpPattern);
1332 
1333 	mViewActions[menu_view_frameless] = new QAction(QObject::tr("&Frameless"), parent);
1334 	mViewActions[menu_view_frameless]->setShortcut(QKeySequence(shortcut_frameless));
1335 	mViewActions[menu_view_frameless]->setStatusTip(QObject::tr("shows a frameless window"));
1336 	mViewActions[menu_view_frameless]->setCheckable(true);
1337 	mViewActions[menu_view_frameless]->setChecked(false);
1338 
1339 	mViewActions[menu_view_opacity_change] = new QAction(QObject::tr("&Change Opacity"), parent);
1340 	mViewActions[menu_view_opacity_change]->setShortcut(QKeySequence(shortcut_opacity_change));
1341 	mViewActions[menu_view_opacity_change]->setStatusTip(QObject::tr("change the window opacity"));
1342 
1343 	mViewActions[menu_view_opacity_up] = new QAction(QObject::tr("Opacity &Up"), parent);
1344 	mViewActions[menu_view_opacity_up]->setShortcut(QKeySequence(shortcut_opacity_up));
1345 	mViewActions[menu_view_opacity_up]->setStatusTip(QObject::tr("changes the window opacity"));
1346 
1347 	mViewActions[menu_view_opacity_down] = new QAction(QObject::tr("Opacity &Down"), parent);
1348 	mViewActions[menu_view_opacity_down]->setShortcut(QKeySequence(shortcut_opacity_down));
1349 	mViewActions[menu_view_opacity_down]->setStatusTip(QObject::tr("changes the window opacity"));
1350 
1351 	mViewActions[menu_view_opacity_an] = new QAction(QObject::tr("To&ggle Opacity"), parent);
1352 	mViewActions[menu_view_opacity_an]->setShortcut(QKeySequence(shortcut_an_opacity));
1353 	mViewActions[menu_view_opacity_an]->setStatusTip(QObject::tr("toggle the window opacity"));
1354 
1355 	mViewActions[menu_view_lock_window] = new QAction(QObject::tr("Lock &Window"), parent);
1356 	mViewActions[menu_view_lock_window]->setShortcut(QKeySequence(shortcut_lock_window));
1357 	mViewActions[menu_view_lock_window]->setStatusTip(QObject::tr("lock the window"));
1358 	mViewActions[menu_view_lock_window]->setCheckable(true);
1359 	mViewActions[menu_view_lock_window]->setChecked(false);
1360 
1361 	mViewActions[menu_view_slideshow] = new QAction(QObject::tr("&Toggle Slideshow"), parent);
1362 	mViewActions[menu_view_slideshow]->setStatusTip(QObject::tr("Start/Pause the slideshow"));
1363 	mViewActions[menu_view_slideshow]->setShortcut(QKeySequence(shortcut_view_slideshow));
1364 
1365 	mViewActions[menu_view_movie_pause] = new QAction(mViewIcons[icon_view_movie_play], QObject::tr("&Pause Movie"), parent);
1366 	mViewActions[menu_view_movie_pause]->setStatusTip(QObject::tr("pause the current movie"));
1367 	mViewActions[menu_view_movie_pause]->setCheckable(true);
1368 	mViewActions[menu_view_movie_pause]->setChecked(false);
1369 
1370 	mViewActions[menu_view_movie_prev] = new QAction(mViewIcons[icon_view_movie_prev], QObject::tr("P&revious Frame"), parent);
1371 	mViewActions[menu_view_movie_prev]->setStatusTip(QObject::tr("show previous frame"));
1372 
1373 	mViewActions[menu_view_movie_next] = new QAction(mViewIcons[icon_view_movie_next], QObject::tr("&Next Frame"), parent);
1374 	mViewActions[menu_view_movie_next]->setStatusTip(QObject::tr("show next frame"));
1375 
1376 	mViewActions[menu_view_monitors] = new QAction(QObject::tr("Choose &Monitor"), parent);
1377 	mViewActions[menu_view_monitors]->setStatusTip(QObject::tr("Choose the Monitor to run nomacs"));
1378 
1379 	mViewActions[menu_view_gps_map] = new QAction(mViewIcons[icon_view_gps], QObject::tr("Show Image Location"), parent);
1380 	mViewActions[menu_view_gps_map]->setStatusTip(QObject::tr("shows where the image was taken in Google maps"));
1381 	mViewActions[menu_view_gps_map]->setEnabled(false);
1382 
1383 	// tools actions
1384 	mToolsActions.resize(menu_tools_end);
1385 
1386 	mToolsActions[menu_tools_thumbs] = new QAction(QObject::tr("Compute &Thumbnails"), parent);
1387 	mToolsActions[menu_tools_thumbs]->setStatusTip(QObject::tr("compute all thumbnails of the current folder"));
1388 	mToolsActions[menu_tools_thumbs]->setEnabled(false);
1389 
1390 	mToolsActions[menu_tools_filter] = new QAction(mFileIcons[icon_file_filter], QObject::tr("&Filter"), parent);
1391 	mToolsActions[menu_tools_filter]->setStatusTip(QObject::tr("Find an image"));
1392 	mToolsActions[menu_tools_filter]->setCheckable(true);
1393 	mToolsActions[menu_tools_filter]->setChecked(false);
1394 
1395 	mToolsActions[menu_tools_export_tiff] = new QAction(QObject::tr("Export Multipage &TIFF"), parent);
1396 	mToolsActions[menu_tools_export_tiff]->setStatusTip(QObject::tr("Export TIFF pages to multiple tiff files"));
1397 
1398 	mToolsActions[menu_tools_extract_archive] = new QAction(QObject::tr("Extract From Archive"), parent);
1399 	mToolsActions[menu_tools_extract_archive]->setStatusTip(QObject::tr("Extract images from an archive (%1)").arg(DkSettingsManager::param().app().containerRawFilters));
1400 	mToolsActions[menu_tools_extract_archive]->setShortcut(QKeySequence(shortcut_extract));
1401 
1402 	mToolsActions[menu_tools_mosaic] = new QAction(QObject::tr("&Mosaic Image"), parent);
1403 	mToolsActions[menu_tools_mosaic]->setStatusTip(QObject::tr("Create a Mosaic Image"));
1404 
1405 	mToolsActions[menu_tools_batch] = new QAction(QObject::tr("Batch Processing"), parent);
1406 	mToolsActions[menu_tools_batch]->setStatusTip(QObject::tr("Apply actions to multiple images"));
1407 	mToolsActions[menu_tools_batch]->setShortcut(QKeySequence(shortcut_batch_processing));
1408 
1409 	mToolsActions[menu_tools_wallpaper] = new QAction(QObject::tr("&Wallpaper"), parent);
1410 	mToolsActions[menu_tools_wallpaper]->setStatusTip(QObject::tr("set the current image as wallpaper"));
1411 
1412 	mToolsActions[menu_tools_train_format] = new QAction(QObject::tr("Add Image Format"), parent);
1413 	mToolsActions[menu_tools_train_format]->setStatusTip(QObject::tr("Add a new image format to nomacs"));
1414 
1415 	// help menu
1416 	mHelpActions.resize(menu_help_end);
1417 	mHelpActions[menu_help_about] = new QAction(QObject::tr("&About Nomacs"), parent);
1418 	mHelpActions[menu_help_about]->setShortcut(QKeySequence(shortcut_show_help));
1419 	mHelpActions[menu_help_about]->setStatusTip(QObject::tr("about"));
1420 
1421 	mHelpActions[menu_help_documentation] = new QAction(QObject::tr("&Documentation"), parent);
1422 	mHelpActions[menu_help_documentation]->setStatusTip(QObject::tr("Online Documentation"));
1423 
1424 	mHelpActions[menu_help_bug] = new QAction(QObject::tr("&Report a Bug"), parent);
1425 	mHelpActions[menu_help_bug]->setStatusTip(QObject::tr("Report a Bug"));
1426 
1427 	mHelpActions[menu_help_update] = new QAction(QObject::tr("&Check for Updates"), parent);
1428 	mHelpActions[menu_help_update]->setStatusTip(QObject::tr("check for updates"));
1429 	mHelpActions[menu_help_update]->setDisabled(DkSettingsManager::param().sync().disableUpdateInteraction);
1430 
1431 	mHelpActions[menu_help_update_translation] = new QAction(QObject::tr("&Update Translation"), parent);
1432 	mHelpActions[menu_help_update_translation]->setStatusTip(QObject::tr("Checks for a new version of the translations of the current language"));
1433 	mHelpActions[menu_help_update_translation]->setDisabled(DkSettingsManager::param().sync().disableUpdateInteraction);
1434 
1435 	// sync actions
1436 	mSyncActions.resize(menu_sync_end);
1437 	mSyncActions[menu_sync_view] = new QAction(QObject::tr("Synchronize &View"), parent);
1438 	mSyncActions[menu_sync_view]->setShortcut(QKeySequence(shortcut_sync));
1439 	mSyncActions[menu_sync_view]->setStatusTip(QObject::tr("synchronize the current view"));
1440 	mSyncActions[menu_sync_view]->setEnabled(false);
1441 
1442 	mSyncActions[menu_sync_pos] = new QAction(QObject::tr("&Window Overlay"), parent);
1443 	mSyncActions[menu_sync_pos]->setShortcut(QKeySequence(shortcut_tab));
1444 	mSyncActions[menu_sync_pos]->setStatusTip(QObject::tr("toggle the window opacity"));
1445 	mSyncActions[menu_sync_pos]->setEnabled(false);
1446 
1447 	mSyncActions[menu_sync_arrange] = new QAction(QObject::tr("Arrange Instances"), parent);
1448 	mSyncActions[menu_sync_arrange]->setShortcut(QKeySequence(shortcut_arrange));
1449 	mSyncActions[menu_sync_arrange]->setStatusTip(QObject::tr("arrange connected instances"));
1450 	mSyncActions[menu_sync_arrange]->setEnabled(false);
1451 
1452 	mSyncActions[menu_sync_connect_all] = new QAction(QObject::tr("Connect &All"), parent);
1453 	mSyncActions[menu_sync_connect_all]->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1454 	mSyncActions[menu_sync_connect_all]->setShortcut(QKeySequence(shortcut_connect_all));
1455 	mSyncActions[menu_sync_connect_all]->setStatusTip(QObject::tr("connect all instances"));
1456 
1457 	mSyncActions[menu_sync_all_actions] = new QAction(QObject::tr("&Sync All Actions"), parent);
1458 	mSyncActions[menu_sync_all_actions]->setStatusTip(QObject::tr("Transmit All Signals Automatically."));
1459 	mSyncActions[menu_sync_all_actions]->setCheckable(true);
1460 	mSyncActions[menu_sync_all_actions]->setChecked(DkSettingsManager::param().sync().syncActions);
1461 
1462 	// plugin actions
1463 	mPluginActions.resize(menu_plugins_end);
1464 	mPluginActions[menu_plugin_manager] = new QAction(QObject::tr("&Plugin Manager"), parent);
1465 	mPluginActions[menu_plugin_manager]->setStatusTip(QObject::tr("manage installed plugins and download new ones"));
1466 
1467 	// preview actions
1468 	mPreviewActions.resize(actions_end);
1469 
1470 	mPreviewActions[preview_select_all] = new QAction(QObject::tr("Select &All"), parent);
1471 	mPreviewActions[preview_select_all]->setShortcut(QKeySequence::SelectAll);
1472 	mPreviewActions[preview_select_all]->setCheckable(true);
1473 
1474 	mPreviewActions[preview_zoom_in] = new QAction(DkImage::loadIcon(":/nomacs/img/zoom-in.svg"), QObject::tr("Zoom &In"), parent);
1475 	mPreviewActions[preview_zoom_in]->setShortcut(QKeySequence::ZoomIn);
1476 
1477 	mPreviewActions[preview_zoom_out] = new QAction(DkImage::loadIcon(":/nomacs/img/zoom-out.svg"), QObject::tr("Zoom &Out"), parent);
1478 	mPreviewActions[preview_zoom_out]->setShortcut(QKeySequence::ZoomOut);
1479 
1480 	mPreviewActions[preview_display_squares] = new QAction(DkImage::loadIcon(":/nomacs/img/rects.svg"), QObject::tr("Display &Squares"), parent);
1481 	mPreviewActions[preview_display_squares]->setCheckable(true);
1482 	mPreviewActions[preview_display_squares]->setChecked(DkSettingsManager::param().display().displaySquaredThumbs);
1483 
1484 	mPreviewActions[preview_show_labels] = new QAction(DkImage::loadIcon(":/nomacs/img/show-filename.svg"), QObject::tr("Show &Filename"), parent);
1485 	mPreviewActions[preview_show_labels]->setCheckable(true);
1486 	mPreviewActions[preview_show_labels]->setChecked(DkSettingsManager::param().display().showThumbLabel);
1487 
1488 	mPreviewActions[preview_filter] = new QAction(QObject::tr("&Filter"), parent);
1489 	mPreviewActions[preview_filter]->setShortcut(QKeySequence::Find);
1490 
1491 	mPreviewActions[preview_delete] = new QAction(DkImage::loadIcon(":/nomacs/img/trash.svg"), QObject::tr("&Delete"), parent);
1492 	mPreviewActions[preview_delete]->setShortcut(QKeySequence::Delete);
1493 
1494 	mPreviewActions[preview_copy] = new QAction(DkImage::loadIcon(":/nomacs/img/copy.svg"), QObject::tr("&Copy"), parent);
1495 	mPreviewActions[preview_copy]->setShortcut(QKeySequence::Copy);
1496 
1497 	mPreviewActions[preview_paste] = new QAction(DkImage::loadIcon(":/nomacs/img/paste.svg"), QObject::tr("&Paste"), parent);
1498 	mPreviewActions[preview_paste]->setShortcut(QKeySequence::Paste);
1499 
1500 	mPreviewActions[preview_rename] = new QAction(DkImage::loadIcon(":/nomacs/img/rename.svg"), QObject::tr("&Rename"), parent);
1501 	mPreviewActions[preview_rename]->setShortcut(QKeySequence(Qt::Key_F2));
1502 
1503 	mPreviewActions[preview_batch] = new QAction(DkImage::loadIcon(":/nomacs/img/batch-processing.svg"), QObject::tr("&Batch Process"), parent);
1504 	mPreviewActions[preview_batch]->setToolTip(QObject::tr("Adds selected files to batch processing."));
1505 	mPreviewActions[preview_batch]->setShortcut(QKeySequence(Qt::Key_B));
1506 
1507 	mPreviewActions[preview_print] = new QAction(DkImage::loadIcon(":/nomacs/img/print.svg"), QObject::tr("&Batch Print"), parent);
1508 	mPreviewActions[preview_print]->setToolTip(QObject::tr("Prints selected files."));
1509 	mPreviewActions[preview_print]->setShortcut(QKeySequence::Print);
1510 
1511 	// hidden actions
1512 	mHiddenActions.resize(sc_end);
1513 
1514 	mHiddenActions[sc_test_img] = new QAction(QObject::QObject::tr("Lena"), parent);
1515 	mHiddenActions[sc_test_img]->setStatusTip(QObject::QObject::tr("Show test image"));
1516 	mHiddenActions[sc_test_img]->setShortcut(QKeySequence(shortcut_test_img));
1517 
1518 	mHiddenActions[sc_test_rec] = new QAction(QObject::QObject::tr("All Images"), parent);
1519 	mHiddenActions[sc_test_rec]->setStatusTip(QObject::QObject::tr("Generates all images in the world"));
1520 	mHiddenActions[sc_test_rec]->setShortcut(QKeySequence(shortcut_test_rec));
1521 
1522 	mHiddenActions[sc_test_pong] = new QAction(QObject::QObject::tr("Pong"), parent);
1523 	mHiddenActions[sc_test_pong]->setStatusTip(QObject::tr("Start pong"));
1524 	mHiddenActions[sc_test_pong]->setShortcut(QKeySequence(shortcut_test_pong));
1525 
1526 	mHiddenActions[sc_first_file] = new QAction(QObject::tr("First File"), parent);
1527 	mHiddenActions[sc_first_file]->setStatusTip(QObject::tr("Jump to first file"));
1528 	mHiddenActions[sc_first_file]->setShortcut(QKeySequence(shortcut_first_file));
1529 
1530 	mHiddenActions[sc_last_file] = new QAction(QObject::tr("Last File"), parent);
1531 	mHiddenActions[sc_last_file]->setStatusTip(QObject::tr("Jump to the end of the current folder"));
1532 	mHiddenActions[sc_last_file]->setShortcut(QKeySequence(shortcut_last_file));
1533 
1534 	mHiddenActions[sc_skip_prev] = new QAction(QObject::tr("Skip Previous Images"), parent);
1535 	mHiddenActions[sc_skip_prev]->setStatusTip(QObject::tr("Jumps 10 images before the current image"));
1536 	mHiddenActions[sc_skip_prev]->setShortcut(QKeySequence(shortcut_skip_prev));
1537 
1538 	mHiddenActions[sc_skip_next] = new QAction(QObject::tr("Skip Next Images"), parent);
1539 	mHiddenActions[sc_skip_next]->setStatusTip(QObject::tr("Jumps 10 images after the current image"));
1540 	mHiddenActions[sc_skip_next]->setShortcut(QKeySequence(shortcut_skip_next));
1541 
1542 	mHiddenActions[sc_first_file_sync] = new QAction(QObject::tr("First File Sync"), parent);
1543 	mHiddenActions[sc_first_file_sync]->setStatusTip(QObject::tr("Jump to first file"));
1544 	mHiddenActions[sc_first_file_sync]->setShortcut(QKeySequence(shortcut_first_file_sync));
1545 
1546 	mHiddenActions[sc_last_file_sync] = new QAction(QObject::tr("Last File Sync"), parent);
1547 	mHiddenActions[sc_last_file_sync]->setStatusTip(QObject::tr("Jump to the end of the current folder"));
1548 	mHiddenActions[sc_last_file_sync]->setShortcut(QKeySequence(shortcut_last_file_sync));
1549 
1550 	mHiddenActions[sc_skip_prev_sync] = new QAction(QObject::tr("Skip Previous Images Sync"), parent);
1551 	mHiddenActions[sc_skip_prev_sync]->setStatusTip(QObject::tr("Jumps 10 images before the current image"));
1552 	mHiddenActions[sc_skip_prev_sync]->setShortcut(QKeySequence(shortcut_skip_prev_sync));
1553 
1554 	mHiddenActions[sc_skip_next_sync] = new QAction(QObject::tr("Skip Next Images Sync"), parent);
1555 	mHiddenActions[sc_skip_next_sync]->setStatusTip(QObject::tr("Jumps 10 images after the current image"));
1556 	mHiddenActions[sc_skip_next_sync]->setShortcut(QKeySequence(shortcut_skip_next_sync));
1557 
1558 	mHiddenActions[sc_delete_silent] = new QAction(QObject::tr("Delete File Silent"), parent);
1559 	mHiddenActions[sc_delete_silent]->setStatusTip(QObject::tr("Deletes a file without warning"));
1560 	mHiddenActions[sc_delete_silent]->setShortcut(QKeySequence(shortcut_delete_silent));
1561 
1562 	mHiddenActions[sc_star_rating_0] = new QAction(QObject::tr("Star Rating 0"), parent);
1563 	mHiddenActions[sc_star_rating_0]->setStatusTip(QObject::tr("Star rating which is saved to an image's metadata"));
1564 	mHiddenActions[sc_star_rating_0]->setShortcut(QKeySequence(shortcut_star_rating_0));
1565 
1566 	mHiddenActions[sc_star_rating_1] = new QAction(QObject::tr("Star Rating 1"), parent);
1567 	mHiddenActions[sc_star_rating_1]->setStatusTip(QObject::tr("Star rating which is saved to an image's metadata"));
1568 	mHiddenActions[sc_star_rating_1]->setShortcut(QKeySequence(shortcut_star_rating_1));
1569 
1570 	mHiddenActions[sc_star_rating_2] = new QAction(QObject::tr("Star Rating 2"), parent);
1571 	mHiddenActions[sc_star_rating_2]->setStatusTip(QObject::tr("Star rating which is saved to an image's metadata"));
1572 	mHiddenActions[sc_star_rating_2]->setShortcut(QKeySequence(shortcut_star_rating_2));
1573 
1574 	mHiddenActions[sc_star_rating_3] = new QAction(QObject::tr("Star Rating 3"), parent);
1575 	mHiddenActions[sc_star_rating_3]->setStatusTip(QObject::tr("Star rating which is saved to an image's metadata"));
1576 	mHiddenActions[sc_star_rating_3]->setShortcut(QKeySequence(shortcut_star_rating_3));
1577 
1578 	mHiddenActions[sc_star_rating_4] = new QAction(QObject::tr("Star Rating 4"), parent);
1579 	mHiddenActions[sc_star_rating_4]->setStatusTip(QObject::tr("Star rating which is saved to an image's metadata"));
1580 	mHiddenActions[sc_star_rating_4]->setShortcut(QKeySequence(shortcut_star_rating_4));
1581 
1582 	mHiddenActions[sc_star_rating_5] = new QAction(QObject::tr("Star Rating 5"), parent);
1583 	mHiddenActions[sc_star_rating_5]->setStatusTip(QObject::tr("Star rating which is saved to an image's metadata"));
1584 	mHiddenActions[sc_star_rating_5]->setShortcut(QKeySequence(shortcut_star_rating_5));
1585 
1586 	mHiddenActions[sc_pan_up] = new QAction(QObject::tr("Pan Image Up"), parent);
1587 	mHiddenActions[sc_pan_up]->setStatusTip(QObject::tr("Pans the image up if zoomed."));
1588 	mHiddenActions[sc_pan_up]->setShortcut(QKeySequence(shortcut_pan_up));
1589 
1590 	mHiddenActions[sc_pan_down] = new QAction(QObject::tr("Pan Image Down"), parent);
1591 	mHiddenActions[sc_pan_down]->setStatusTip(QObject::tr("Pans the image down if zoomed."));
1592 	mHiddenActions[sc_pan_down]->setShortcut(QKeySequence(shortcut_pan_down));
1593 
1594 	mHiddenActions[sc_pan_left] = new QAction(QObject::tr("Pan Image Left"), parent);
1595 	mHiddenActions[sc_pan_left]->setStatusTip(QObject::tr("Pans the image left if zoomed."));
1596 	mHiddenActions[sc_pan_left]->setShortcut(QKeySequence(shortcut_pan_left));
1597 
1598 	mHiddenActions[sc_pan_right] = new QAction(QObject::tr("Pan Image Right"), parent);
1599 	mHiddenActions[sc_pan_right]->setStatusTip(QObject::tr("Pans the image right if zoomed."));
1600 	mHiddenActions[sc_pan_right]->setShortcut(QKeySequence(shortcut_pan_right));
1601 
1602 	mManipulators.createManipulators(parent);
1603 
1604 	assignCustomShortcuts(allActions());
1605 
1606 	// automatically add status tip as tool tip
1607 	for (QAction* a : allActions()) {
1608 		a->setToolTip(a->statusTip());
1609 		a->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1610 	}
1611 
1612 	// trivial connects
1613 	QObject::connect(action(menu_panel_toggle), &QAction::triggered,
1614 		[](bool hide) { DkSettingsManager::param().app().hideAllPanels = hide; });
1615 
1616 	QObject::connect(action(menu_panel_statusbar), &QAction::triggered,
1617 		[](bool show) { DkStatusBarManager::instance().show(show); });
1618 
1619 	QObject::connect(action(menu_panel_toolbar), &QAction::triggered,
1620 		[](bool show) { DkToolBarManager::inst().showDefaultToolBar(show); });
1621 
1622 	QObject::connect(action(menu_sync_all_actions), &QAction::triggered,
1623 		[](bool sync) { DkSettingsManager::param().sync().syncActions = sync; });
1624 
1625 }
1626 
allActions() const1627 QVector<QAction*> DkActionManager::allActions() const {
1628 
1629 	QVector<QAction*> all;
1630 	all += fileActions();
1631 	all += sortActions();
1632 	all += openWithActions();
1633 	all += viewActions();
1634 	all += editActions();
1635 	all += manipulatorActions();
1636 	all += toolsActions();
1637 	all += panelActions();
1638 	all += syncActions();
1639 	all += pluginActions();
1640 	all += helpActions();
1641 	all += previewActions();
1642 
1643 	all += hiddenActions();
1644 
1645 	return all;
1646 }
1647 
assignCustomShortcuts(QVector<QAction * > actions) const1648 void DkActionManager::assignCustomShortcuts(QVector<QAction*> actions) const {
1649 
1650 	DefaultSettings settings;
1651 	settings.beginGroup("CustomShortcuts");
1652 
1653 	for (QAction* a : actions) {
1654 
1655 		if (!a) {
1656 			qWarning() << "NULL action detected!";
1657 			continue;
1658 		}
1659 
1660 		QString at = a->text().remove("&");
1661 		QString val = settings.value(at, "no-shortcut").toString();
1662 
1663 		if (val != "no-shortcut")
1664 			a->setShortcut(val);
1665 
1666 		// assign widget shortcuts to all of them
1667 		a->setShortcutContext(Qt::WidgetWithChildrenShortcut);
1668 	}
1669 
1670 	settings.endGroup();
1671 }
1672 
enableImageActions(bool enable) const1673 void DkActionManager::enableImageActions(bool enable) const {
1674 
1675 	action(DkActionManager::menu_file_save)->setEnabled(enable);
1676 	action(DkActionManager::menu_file_save_as)->setEnabled(enable);
1677 	action(DkActionManager::menu_file_save_copy)->setEnabled(enable);
1678 	action(DkActionManager::menu_file_save_list)->setEnabled(enable);
1679 	action(DkActionManager::menu_file_save_web)->setEnabled(enable);
1680 	action(DkActionManager::menu_file_rename)->setEnabled(enable);
1681 	action(DkActionManager::menu_file_print)->setEnabled(enable);
1682 	action(DkActionManager::menu_file_reload)->setEnabled(enable);
1683 	action(DkActionManager::menu_file_prev)->setEnabled(enable);
1684 	action(DkActionManager::menu_file_next)->setEnabled(enable);
1685 	action(DkActionManager::menu_file_goto)->setEnabled(enable);
1686 	action(DkActionManager::menu_file_find)->setEnabled(enable);
1687 
1688 	action(DkActionManager::menu_edit_rotate_cw)->setEnabled(enable);
1689 	action(DkActionManager::menu_edit_rotate_ccw)->setEnabled(enable);
1690 	action(DkActionManager::menu_edit_rotate_180)->setEnabled(enable);
1691 	action(DkActionManager::menu_edit_delete)->setEnabled(enable);
1692 	action(DkActionManager::menu_edit_transform)->setEnabled(enable);
1693 	action(DkActionManager::menu_edit_crop)->setEnabled(enable);
1694 	action(DkActionManager::menu_edit_copy)->setEnabled(enable);
1695 	action(DkActionManager::menu_edit_copy_buffer)->setEnabled(enable);
1696 	action(DkActionManager::menu_edit_copy_color)->setEnabled(enable);
1697 	action(DkActionManager::menu_edit_undo)->setEnabled(enable);
1698 	action(DkActionManager::menu_edit_redo)->setEnabled(enable);
1699 
1700 
1701 	action(DkActionManager::menu_panel_info)->setEnabled(enable);
1702 #ifdef WITH_OPENCV
1703 	action(DkActionManager::menu_panel_histogram)->setEnabled(enable);
1704 #else
1705 	action(DkActionManager::menu_panel_histogram)->setEnabled(false);
1706 #endif
1707 	action(DkActionManager::menu_panel_scroller)->setEnabled(enable);
1708 	action(DkActionManager::menu_panel_comment)->setEnabled(enable);
1709 	action(DkActionManager::menu_panel_preview)->setEnabled(enable);
1710 	action(DkActionManager::menu_panel_exif)->setEnabled(enable);
1711 	action(DkActionManager::menu_panel_overview)->setEnabled(enable);
1712 	action(DkActionManager::menu_panel_player)->setEnabled(enable);
1713 	//action(DkActionManager::menu_panel_thumbview)->setEnabled(enable);	// if we don't disable the thumbnail preview, we can toggle it with SHIFT+T
1714 
1715 	action(DkActionManager::menu_view_slideshow)->setEnabled(enable);
1716 	action(DkActionManager::menu_view_fullscreen)->setEnabled(enable);
1717 	action(DkActionManager::menu_view_reset)->setEnabled(enable);
1718 	action(DkActionManager::menu_view_100)->setEnabled(enable);
1719 	action(DkActionManager::menu_view_fit_frame)->setEnabled(enable);
1720 	action(DkActionManager::menu_view_zoom_in)->setEnabled(enable);
1721 	action(DkActionManager::menu_view_zoom_out)->setEnabled(enable);
1722 	action(DkActionManager::menu_view_tp_pattern)->setEnabled(enable);
1723 	action(DkActionManager::menu_view_anti_aliasing)->setEnabled(enable);
1724 
1725 	action(DkActionManager::menu_tools_wallpaper)->setEnabled(enable);
1726 	action(DkActionManager::menu_tools_thumbs)->setEnabled(enable);
1727 
1728 	// hidden actions
1729 	action(DkActionManager::sc_skip_prev)->setEnabled(enable);
1730 	action(DkActionManager::sc_skip_prev_sync)->setEnabled(enable);
1731 	action(DkActionManager::sc_skip_next)->setEnabled(enable);
1732 	action(DkActionManager::sc_skip_next_sync)->setEnabled(enable);
1733 	action(DkActionManager::sc_first_file)->setEnabled(enable);
1734 	action(DkActionManager::sc_first_file_sync)->setEnabled(enable);
1735 	action(DkActionManager::sc_last_file)->setEnabled(enable);
1736 	action(DkActionManager::sc_last_file_sync)->setEnabled(enable);
1737 
1738 	// disable open with actions
1739 	for (QAction* a : DkActionManager::instance().appManager()->getActions())
1740 		a->setEnabled(enable);
1741 }
1742 
enableMovieActions(bool enable) const1743 void DkActionManager::enableMovieActions(bool enable) const {
1744 
1745 	DkSettingsManager::param().app().showMovieToolBar = enable;
1746 
1747 	action(DkActionManager::menu_view_movie_pause)->setEnabled(enable);
1748 	action(DkActionManager::menu_view_movie_prev)->setEnabled(enable);
1749 	action(DkActionManager::menu_view_movie_next)->setEnabled(enable);
1750 
1751 	action(DkActionManager::menu_view_movie_pause)->setChecked(false);
1752 
1753 	DkToolBarManager::inst().showMovieToolBar(enable);
1754 }
1755 
1756 // DkGlobalProgress --------------------------------------------------------------------
DkGlobalProgress()1757 DkGlobalProgress::DkGlobalProgress() : showProgress(true) {
1758 #ifdef Q_OS_WIN
1759 	mProgress = new QWinTaskbarProgress(this);
1760 #endif
1761 }
1762 
~DkGlobalProgress()1763 DkGlobalProgress::~DkGlobalProgress() {}
1764 
instance()1765 DkGlobalProgress& DkGlobalProgress::instance() {
1766 
1767 	static DkGlobalProgress inst;
1768 	return inst;
1769 }
1770 
start()1771 void DkGlobalProgress::start() {
1772 
1773 #ifdef Q_OS_WIN
1774 
1775 	if (!mProgress) {
1776 		qWarning() << "global progress bar is empty...";
1777 		return;
1778 	}
1779 
1780 	mProgress->setVisible(true);
1781 	mProgress->setValue(0);
1782 #endif
1783 
1784 }
1785 
stop()1786 void DkGlobalProgress::stop() {
1787 
1788 	if (!mProgress)
1789 		return;
1790 
1791 #ifdef Q_OS_WIN
1792 	mProgress->setVisible(false);
1793 	mProgress->setValue(0);
1794 #endif
1795 }
1796 
setProgressValue(int value)1797 void DkGlobalProgress::setProgressValue(int value) {
1798 
1799 #ifdef Q_OS_WIN
1800 	if (showProgress)
1801 		mProgress->setValue(value);
1802 #endif
1803 }
1804 
progressObject() const1805 QObject* DkGlobalProgress::progressObject() const {
1806 	return mProgress;
1807 }
1808 
1809 #ifdef Q_OS_WIN32
setProgressBar(QWinTaskbarProgress * progress)1810 void DkGlobalProgress::setProgressBar(QWinTaskbarProgress* progress) {
1811 	mProgress = progress;
1812 }
1813 
progressBar()1814 QWinTaskbarProgress* DkGlobalProgress::progressBar() {
1815 	return mProgress;
1816 }
1817 #else
progressBar() const1818 QProgressDialog* DkGlobalProgress::progressBar() const {
1819 	return 0;
1820 }
1821 #endif
1822 
1823 
1824 }
1825