This repository has been archived by the owner on Oct 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Phototonic.cpp
3649 lines (3141 loc) · 144 KB
/
Phototonic.cpp
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (C) 2013-2015 Ofer Kashayov <oferkv@live.com>
* This file is part of Phototonic Image Viewer.
*
* Phototonic is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Phototonic is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Phototonic. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DirCompleter.h"
#include "Phototonic.h"
#include "Settings.h"
#include "CopyMoveDialog.h"
#include "ResizeDialog.h"
#include "CropDialog.h"
#include "ColorsDialog.h"
#include "ExternalAppsDialog.h"
#include "ProgressDialog.h"
#include "RangeInputDialog.h"
#include "ImagePreview.h"
#include "FileListWidget.h"
#include "GuideWidget.h"
#include "RenameDialog.h"
#include "Trashcan.h"
#include "MessageBox.h"
Phototonic::Phototonic(QStringList argumentsList, int filesStartAt, QWidget *parent) : QMainWindow(parent) {
Settings::appSettings = new QSettings("phototonic", "phototonic");
setDockOptions(QMainWindow::AllowNestedDocks);
readSettings();
createThumbsViewer();
createActions();
createMenus();
createToolBars();
createStatusBar();
createFileSystemDock();
createBookmarksDock();
createImagePreviewDock();
createImageTagsDock();
createImageViewer();
updateExternalApps();
loadShortcuts();
setupDocks();
connect(qApp, SIGNAL(focusChanged(QWidget * , QWidget * )), this, SLOT(updateActions()));
restoreGeometry(Settings::appSettings->value(Settings::optionGeometry).toByteArray());
restoreState(Settings::appSettings->value(Settings::optionWindowState).toByteArray());
defaultApplicationIcon = QIcon(":/images/phototonic.png");
setWindowIcon(defaultApplicationIcon);
stackedLayout = new QStackedLayout;
QWidget *stackedLayoutWidget = new QWidget;
stackedLayout->addWidget(thumbsViewer);
stackedLayout->addWidget(imageViewer);
stackedLayoutWidget->setLayout(stackedLayout);
setCentralWidget(stackedLayoutWidget);
processStartupArguments(argumentsList, filesStartAt);
copyMoveToDialog = nullptr;
colorsDialog = nullptr;
cropDialog = nullptr;
initComplete = true;
thumbsViewer->isBusy = false;
currentHistoryIdx = -1;
needHistoryRecord = true;
interfaceDisabled = false;
refreshThumbs(true);
if (Settings::layoutMode == ThumbViewWidget) {
thumbsViewer->setFocus(Qt::OtherFocusReason);
}
}
void Phototonic::processStartupArguments(QStringList argumentsList, int filesStartAt) {
if (argumentsList.size() > filesStartAt) {
QFileInfo firstArgument(argumentsList.at(filesStartAt));
if (firstArgument.isDir()) {
// Confusingly we need the absoluteFile and not absolutePath if it's a directory
Settings::currentDirectory = firstArgument.absoluteFilePath();
} else if (argumentsList.size() > filesStartAt + 1) {
loadStartupFileList(argumentsList, filesStartAt);
return;
} else {
Settings::currentDirectory = firstArgument.absolutePath();
QString cliFileName = Settings::currentDirectory + QDir::separator() + firstArgument.fileName();
loadImageFromCliArguments(cliFileName);
QTimer::singleShot(1000, this, SLOT(updateIndexByViewerImage()));
}
} else {
if (Settings::startupDir == Settings::SpecifiedDir) {
Settings::currentDirectory = Settings::specifiedStartDir;
} else if (Settings::startupDir == Settings::RememberLastDir) {
Settings::currentDirectory = Settings::appSettings->value(Settings::optionLastDir).toString();
}
}
selectCurrentViewDir();
}
QIcon &Phototonic::getDefaultWindowIcon() {
return defaultApplicationIcon;
}
void Phototonic::loadStartupFileList(QStringList argumentsList, int filesStartAt) {
Settings::filesList.clear();
for (int i = filesStartAt; i < argumentsList.size(); i++) {
QFile currentFileFullPath(argumentsList[i]);
QFileInfo currentFileInfo(currentFileFullPath);
if (!Settings::filesList.contains(currentFileInfo.absoluteFilePath())) {
Settings::filesList << currentFileInfo.absoluteFilePath();
}
}
fileSystemTree->clearSelection();
fileListWidget->itemAt(0, 0)->setSelected(true);
Settings::isFileListLoaded = true;
}
bool Phototonic::event(QEvent *event) {
if (event->type() == QEvent::ActivationChange ||
(Settings::layoutMode == ThumbViewWidget && event->type() == QEvent::MouseButtonRelease)) {
thumbsViewer->loadVisibleThumbs();
}
return QMainWindow::event(event);
}
void Phototonic::createThumbsViewer() {
metadataCache = std::make_shared<MetadataCache>();
thumbsViewer = new ThumbsViewer(this, metadataCache);
thumbsViewer->thumbsSortFlags = (QDir::SortFlags) Settings::appSettings->value(
Settings::optionThumbsSortFlags).toInt();
thumbsViewer->thumbsSortFlags |= QDir::IgnoreCase;
connect(thumbsViewer->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)),
this, SLOT(updateActions()));
imageInfoDock = new QDockWidget(tr("Image Info"), this);
imageInfoDock->setObjectName("Image Info");
imageInfoDock->setWidget(thumbsViewer->infoView);
connect(imageInfoDock->toggleViewAction(), SIGNAL(triggered()), this, SLOT(setImageInfoDockVisibility()));
connect(imageInfoDock, SIGNAL(visibilityChanged(bool)), this, SLOT(setImageInfoDockVisibility()));
}
void Phototonic::addMenuSeparator(QWidget *widget) {
QAction *separator = new QAction(this);
separator->setSeparator(true);
widget->addAction(separator);
}
void Phototonic::createImageViewer() {
imageViewer = new ImageViewer(this, metadataCache);
connect(saveAction, SIGNAL(triggered()), imageViewer, SLOT(saveImage()));
connect(saveAsAction, SIGNAL(triggered()), imageViewer, SLOT(saveImageAs()));
connect(copyImageAction, SIGNAL(triggered()), imageViewer, SLOT(copyImage()));
connect(pasteImageAction, SIGNAL(triggered()), imageViewer, SLOT(pasteImage()));
connect(applyCropAndRotationAction, SIGNAL(triggered()), imageViewer, SLOT(applyCropAndRotation()));
connect(imageViewer, &ImageViewer::toolsUpdated, this, &Phototonic::onToolsUpdated);
imageViewer->ImagePopUpMenu = new QMenu();
// Widget actions
imageViewer->addAction(slideShowAction);
imageViewer->addAction(nextImageAction);
imageViewer->addAction(prevImageAction);
imageViewer->addAction(firstImageAction);
imageViewer->addAction(lastImageAction);
imageViewer->addAction(randomImageAction);
imageViewer->addAction(zoomInAction);
imageViewer->addAction(zoomOutAction);
imageViewer->addAction(origZoomAction);
imageViewer->addAction(resetZoomAction);
imageViewer->addAction(rotateRightAction);
imageViewer->addAction(rotateLeftAction);
imageViewer->addAction(freeRotateRightAction);
imageViewer->addAction(freeRotateLeftAction);
imageViewer->addAction(flipHorizontalAction);
imageViewer->addAction(flipVerticalAction);
imageViewer->addAction(cropAction);
imageViewer->addAction(applyCropAndRotationAction);
imageViewer->addAction(resizeAction);
imageViewer->addAction(saveAction);
imageViewer->addAction(saveAsAction);
imageViewer->addAction(copyImageAction);
imageViewer->addAction(pasteImageAction);
imageViewer->addAction(deleteAction);
imageViewer->addAction(deletePermanentlyAction);
imageViewer->addAction(renameAction);
imageViewer->addAction(CloseImageAction);
imageViewer->addAction(fullScreenAction);
imageViewer->addAction(settingsAction);
imageViewer->addAction(mirrorDisabledAction);
imageViewer->addAction(mirrorDualAction);
imageViewer->addAction(mirrorTripleAction);
imageViewer->addAction(mirrorDualVerticalAction);
imageViewer->addAction(mirrorQuadAction);
imageViewer->addAction(keepTransformAction);
imageViewer->addAction(keepZoomAction);
imageViewer->addAction(refreshAction);
imageViewer->addAction(colorsAction);
imageViewer->addAction(moveRightAction);
imageViewer->addAction(moveLeftAction);
imageViewer->addAction(moveUpAction);
imageViewer->addAction(moveDownAction);
imageViewer->addAction(showClipboardAction);
imageViewer->addAction(copyToAction);
imageViewer->addAction(moveToAction);
imageViewer->addAction(resizeAction);
imageViewer->addAction(viewImageAction);
imageViewer->addAction(exitAction);
imageViewer->addAction(showViewerToolbarAction);
imageViewer->addAction(externalAppsAction);
// Actions
addMenuSeparator(imageViewer->ImagePopUpMenu);
imageViewer->ImagePopUpMenu->addAction(nextImageAction);
imageViewer->ImagePopUpMenu->addAction(prevImageAction);
imageViewer->ImagePopUpMenu->addAction(firstImageAction);
imageViewer->ImagePopUpMenu->addAction(lastImageAction);
imageViewer->ImagePopUpMenu->addAction(randomImageAction);
imageViewer->ImagePopUpMenu->addAction(slideShowAction);
addMenuSeparator(imageViewer->ImagePopUpMenu);
zoomSubMenu = new QMenu(tr("Zoom"));
zoomSubMenuAction = new QAction(tr("Zoom"), this);
zoomSubMenuAction->setIcon(QIcon::fromTheme("edit-find", QIcon(":/images/zoom.png")));
zoomSubMenuAction->setMenu(zoomSubMenu);
imageViewer->ImagePopUpMenu->addAction(zoomSubMenuAction);
zoomSubMenu->addAction(zoomInAction);
zoomSubMenu->addAction(zoomOutAction);
zoomSubMenu->addAction(origZoomAction);
zoomSubMenu->addAction(resetZoomAction);
addMenuSeparator(zoomSubMenu);
zoomSubMenu->addAction(keepZoomAction);
MirroringSubMenu = new QMenu(tr("Mirroring"));
mirrorSubMenuAction = new QAction(tr("Mirroring"), this);
mirrorSubMenuAction->setMenu(MirroringSubMenu);
mirroringActionGroup = new QActionGroup(this);
mirroringActionGroup->addAction(mirrorDisabledAction);
mirroringActionGroup->addAction(mirrorDualAction);
mirroringActionGroup->addAction(mirrorTripleAction);
mirroringActionGroup->addAction(mirrorDualVerticalAction);
mirroringActionGroup->addAction(mirrorQuadAction);
MirroringSubMenu->addActions(mirroringActionGroup->actions());
guideSubMenu = new QMenu(tr("Guides"));
guideSubMenuAction = new QAction(tr("Guides"), this);
guideSubMenuAction->setMenu(guideSubMenu);
guideAddVerticalAction = new QAction(tr("Add vertical guide"), this);
guideAddHorizontalAction = new QAction(tr("Add horizontal guide"), this);
guideSubMenu->addAction(guideAddVerticalAction);
guideSubMenu->addAction(guideAddHorizontalAction);
connect(guideAddVerticalAction, &QAction::triggered, this, &Phototonic::addVerticalGuide);
connect(guideAddHorizontalAction, &QAction::triggered, this, &Phototonic::addHorizontalGuide);
transformSubMenu = new QMenu(tr("Transform"));
transformSubMenuAction = new QAction(tr("Transform"), this);
transformSubMenuAction->setMenu(transformSubMenu);
imageViewer->ImagePopUpMenu->addAction(resizeAction);
imageViewer->ImagePopUpMenu->addAction(applyCropAndRotationAction);
imageViewer->ImagePopUpMenu->addAction(transformSubMenuAction);
transformSubMenu->addAction(colorsAction);
transformSubMenu->addAction(rotateRightAction);
transformSubMenu->addAction(rotateLeftAction);
transformSubMenu->addAction(freeRotateRightAction);
transformSubMenu->addAction(freeRotateLeftAction);
transformSubMenu->addAction(flipHorizontalAction);
transformSubMenu->addAction(flipVerticalAction);
transformSubMenu->addAction(cropAction);
addMenuSeparator(transformSubMenu);
transformSubMenu->addAction(keepTransformAction);
imageViewer->ImagePopUpMenu->addAction(mirrorSubMenuAction);
imageViewer->ImagePopUpMenu->addAction(guideSubMenuAction);
addMenuSeparator(imageViewer->ImagePopUpMenu);
imageViewer->ImagePopUpMenu->addAction(copyToAction);
imageViewer->ImagePopUpMenu->addAction(moveToAction);
imageViewer->ImagePopUpMenu->addAction(saveAction);
imageViewer->ImagePopUpMenu->addAction(saveAsAction);
imageViewer->ImagePopUpMenu->addAction(renameAction);
imageViewer->ImagePopUpMenu->addAction(deleteAction);
imageViewer->ImagePopUpMenu->addAction(deletePermanentlyAction);
imageViewer->ImagePopUpMenu->addAction(openWithMenuAction);
addMenuSeparator(imageViewer->ImagePopUpMenu);
viewSubMenu = new QMenu(tr("View"));
viewSubMenuAction = new QAction(tr("View"), this);
viewSubMenuAction->setMenu(viewSubMenu);
imageViewer->ImagePopUpMenu->addAction(viewSubMenuAction);
viewSubMenu->addAction(fullScreenAction);
viewSubMenu->addAction(showClipboardAction);
viewSubMenu->addAction(showViewerToolbarAction);
viewSubMenu->addAction(refreshAction);
imageViewer->ImagePopUpMenu->addAction(copyImageAction);
imageViewer->ImagePopUpMenu->addAction(pasteImageAction);
imageViewer->ImagePopUpMenu->addAction(CloseImageAction);
imageViewer->ImagePopUpMenu->addAction(exitAction);
addMenuSeparator(imageViewer->ImagePopUpMenu);
imageViewer->ImagePopUpMenu->addAction(settingsAction);
imageViewer->setContextMenuPolicy(Qt::DefaultContextMenu);
Settings::isFullScreen = Settings::appSettings->value(Settings::optionFullScreenMode).toBool();
fullScreenAction->setChecked(Settings::isFullScreen);
thumbsViewer->setImageViewer(imageViewer);
thumbsViewer->imagePreview->setImageViewer(imageViewer);
}
void Phototonic::createActions() {
thumbsGoToTopAction = new QAction(tr("Top"), this);
thumbsGoToTopAction->setObjectName("thumbsGoTop");
thumbsGoToTopAction->setIcon(QIcon::fromTheme("go-top", QIcon(":/images/top.png")));
connect(thumbsGoToTopAction, SIGNAL(triggered()), this, SLOT(goTop()));
thumbsGoToBottomAction = new QAction(tr("Bottom"), this);
thumbsGoToBottomAction->setObjectName("thumbsGoBottom");
thumbsGoToBottomAction->setIcon(QIcon::fromTheme("go-bottom", QIcon(":/images/bottom.png")));
connect(thumbsGoToBottomAction, SIGNAL(triggered()), this, SLOT(goBottom()));
CloseImageAction = new QAction(tr("Close Viewer"), this);
CloseImageAction->setObjectName("closeImage");
connect(CloseImageAction, SIGNAL(triggered()), this, SLOT(hideViewer()));
fullScreenAction = new QAction(tr("Full Screen"), this);
fullScreenAction->setObjectName("fullScreen");
fullScreenAction->setCheckable(true);
connect(fullScreenAction, SIGNAL(triggered()), this, SLOT(toggleFullScreen()));
settingsAction = new QAction(tr("Preferences"), this);
settingsAction->setObjectName("settings");
settingsAction->setIcon(QIcon::fromTheme("preferences-system", QIcon(":/images/settings.png")));
connect(settingsAction, SIGNAL(triggered()), this, SLOT(showSettings()));
exitAction = new QAction(tr("Exit"), this);
exitAction->setObjectName("exit");
connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
thumbsZoomInAction = new QAction(tr("Enlarge Thumbnails"), this);
thumbsZoomInAction->setObjectName("thumbsZoomIn");
connect(thumbsZoomInAction, SIGNAL(triggered()), this, SLOT(thumbsZoomIn()));
thumbsZoomInAction->setIcon(QIcon::fromTheme("zoom-in", QIcon(":/images/zoom_in.png")));
if (thumbsViewer->thumbSize == THUMB_SIZE_MAX) {
thumbsZoomInAction->setEnabled(false);
}
thumbsZoomOutAction = new QAction(tr("Shrink Thumbnails"), this);
thumbsZoomOutAction->setObjectName("thumbsZoomOut");
connect(thumbsZoomOutAction, SIGNAL(triggered()), this, SLOT(thumbsZoomOut()));
thumbsZoomOutAction->setIcon(QIcon::fromTheme("zoom-out", QIcon(":/images/zoom_out.png")));
if (thumbsViewer->thumbSize == THUMB_SIZE_MIN) {
thumbsZoomOutAction->setEnabled(false);
}
cutAction = new QAction(tr("Cut"), this);
cutAction->setObjectName("cut");
cutAction->setIcon(QIcon::fromTheme("edit-cut", QIcon(":/images/cut.png")));
connect(cutAction, SIGNAL(triggered()), this, SLOT(cutThumbs()));
cutAction->setEnabled(false);
copyAction = new QAction(tr("Copy"), this);
copyAction->setObjectName("copy");
copyAction->setIcon(QIcon::fromTheme("edit-copy", QIcon(":/images/copy.png")));
connect(copyAction, SIGNAL(triggered()), this, SLOT(copyThumbs()));
copyAction->setEnabled(false);
setClassicThumbsAction = new QAction(tr("Show classic thumbnails"), this);
setClassicThumbsAction->setCheckable(true);
setClassicThumbsAction->setChecked(Settings::thumbsLayout == ThumbsViewer::Classic);
setClassicThumbsAction->setObjectName("setClassicThumbs");
connect(setClassicThumbsAction, SIGNAL(triggered()), this, SLOT(setClassicThumbs()));
setSquareThumbsAction = new QAction(tr("Show square thumbnails"), this);
setSquareThumbsAction->setCheckable(true);
setSquareThumbsAction->setChecked(Settings::thumbsLayout == ThumbsViewer::Squares);
setSquareThumbsAction->setObjectName("setSquareThumbs");
connect(setSquareThumbsAction, SIGNAL(triggered()), this, SLOT(setSquareThumbs()));
setCompactThumbsAction = new QAction(tr("Show compact thumbnails"), this);
setCompactThumbsAction->setCheckable(true);
setCompactThumbsAction->setChecked(Settings::thumbsLayout == ThumbsViewer::Compact);
setCompactThumbsAction->setObjectName("setCompactThumbs");
connect(setCompactThumbsAction, SIGNAL(triggered()), this, SLOT(setCompactThumbs()));
copyToAction = new QAction(tr("Copy to..."), this);
copyToAction->setObjectName("copyTo");
connect(copyToAction, SIGNAL(triggered()), this, SLOT(copyImagesTo()));
moveToAction = new QAction(tr("Move to..."), this);
moveToAction->setObjectName("moveTo");
connect(moveToAction, SIGNAL(triggered()), this, SLOT(moveImagesTo()));
deleteAction = new QAction(tr("Move to Trash"), this);
deleteAction->setObjectName("moveToTrash");
deleteAction->setIcon(style()->standardIcon(QStyle::SP_TrashIcon));
connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteOperation()));
deletePermanentlyAction = new QAction(tr("Delete"), this);
deletePermanentlyAction->setObjectName("delete");
deletePermanentlyAction->setIcon(QIcon::fromTheme("edit-delete", QIcon(":/images/delete.png")));
connect(deletePermanentlyAction, SIGNAL(triggered()), this, SLOT(deletePermanentlyOperation()));
saveAction = new QAction(tr("Save"), this);
saveAction->setObjectName("save");
saveAction->setIcon(QIcon::fromTheme("document-save", QIcon(":/images/save.png")));
saveAsAction = new QAction(tr("Save As"), this);
saveAsAction->setObjectName("saveAs");
saveAsAction->setIcon(QIcon::fromTheme("document-save-as", QIcon(":/images/save_as.png")));
copyImageAction = new QAction(tr("Copy Image"), this);
copyImageAction->setObjectName("copyImage");
pasteImageAction = new QAction(tr("Paste Image"), this);
pasteImageAction->setObjectName("pasteImage");
renameAction = new QAction(tr("Rename"), this);
renameAction->setObjectName("rename");
connect(renameAction, SIGNAL(triggered()), this, SLOT(rename()));
removeMetadataAction = new QAction(tr("Remove Metadata"), this);
removeMetadataAction->setObjectName("removeMetadata");
connect(removeMetadataAction, SIGNAL(triggered()), this, SLOT(removeMetadata()));
selectAllAction = new QAction(tr("Select All"), this);
selectAllAction->setObjectName("selectAll");
connect(selectAllAction, SIGNAL(triggered()), this, SLOT(selectAllThumbs()));
selectByBrightnesAction = new QAction(tr("Select by Brightness"), this);
selectByBrightnesAction->setObjectName("selectByBrightness");
connect(selectByBrightnesAction, SIGNAL(triggered()), this, SLOT(selectByBrightness()));
aboutAction = new QAction(tr("About"), this);
aboutAction->setObjectName("about");
connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
// Sort actions
sortByNameAction = new QAction(tr("Sort by Name"), this);
sortByNameAction->setObjectName("name");
sortByTimeAction = new QAction(tr("Sort by Time"), this);
sortByTimeAction->setObjectName("time");
sortBySizeAction = new QAction(tr("Sort by Size"), this);
sortBySizeAction->setObjectName("size");
sortByTypeAction = new QAction(tr("Sort by Type"), this);
sortByTypeAction->setObjectName("type");
sortBySimilarityAction = new QAction(tr("Sort by Similarity"), this);
sortBySimilarityAction->setObjectName("similarity");
sortReverseAction = new QAction(tr("Reverse Order"), this);
sortReverseAction->setObjectName("reverse");
sortByNameAction->setCheckable(true);
sortByTimeAction->setCheckable(true);
sortBySizeAction->setCheckable(true);
sortByTypeAction->setCheckable(true);
sortBySimilarityAction->setCheckable(true);
sortReverseAction->setCheckable(true);
connect(sortByNameAction, SIGNAL(triggered()), this, SLOT(sortThumbnails()));
connect(sortByTimeAction, SIGNAL(triggered()), this, SLOT(sortThumbnails()));
connect(sortBySizeAction, SIGNAL(triggered()), this, SLOT(sortThumbnails()));
connect(sortByTypeAction, SIGNAL(triggered()), this, SLOT(sortThumbnails()));
connect(sortBySimilarityAction, SIGNAL(triggered()), this, SLOT(sortThumbnails()));
connect(sortReverseAction, SIGNAL(triggered()), this, SLOT(sortThumbnails()));
if (thumbsViewer->thumbsSortFlags & QDir::Time) {
sortByTimeAction->setChecked(true);
} else if (thumbsViewer->thumbsSortFlags & QDir::Size) {
sortBySizeAction->setChecked(true);
} else if (thumbsViewer->thumbsSortFlags & QDir::Type) {
sortByTypeAction->setChecked(true);
} else {
sortByNameAction->setChecked(true);
}
sortReverseAction->setChecked(thumbsViewer->thumbsSortFlags & QDir::Reversed);
showHiddenFilesAction = new QAction(tr("Show Hidden Files"), this);
showHiddenFilesAction->setObjectName("showHidden");
showHiddenFilesAction->setCheckable(true);
showHiddenFilesAction->setChecked(Settings::showHiddenFiles);
connect(showHiddenFilesAction, SIGNAL(triggered()), this, SLOT(showHiddenFiles()));
smallToolbarIconsAction = new QAction(tr("Small Toolbar Icons"), this);
smallToolbarIconsAction->setObjectName("smallToolbarIcons");
smallToolbarIconsAction->setCheckable(true);
smallToolbarIconsAction->setChecked(Settings::smallToolbarIcons);
connect(smallToolbarIconsAction, SIGNAL(triggered()), this, SLOT(setToolbarIconSize()));
lockDocksAction = new QAction(tr("Hide Dock Title Bars"), this);
lockDocksAction->setObjectName("lockDocks");
lockDocksAction->setCheckable(true);
lockDocksAction->setChecked(Settings::hideDockTitlebars);
connect(lockDocksAction, SIGNAL(triggered()), this, SLOT(lockDocks()));
showViewerToolbarAction = new QAction(tr("Show Toolbar"), this);
showViewerToolbarAction->setObjectName("showViewerToolbars");
showViewerToolbarAction->setCheckable(true);
showViewerToolbarAction->setChecked(Settings::showViewerToolbar);
connect(showViewerToolbarAction, SIGNAL(triggered()), this, SLOT(toggleImageViewerToolbar()));
refreshAction = new QAction(tr("Reload"), this);
refreshAction->setObjectName("refresh");
refreshAction->setIcon(QIcon::fromTheme("view-refresh", QIcon(":/images/refresh.png")));
connect(refreshAction, SIGNAL(triggered()), this, SLOT(reload()));
includeSubDirectoriesAction = new QAction(tr("Include Sub-directories"), this);
includeSubDirectoriesAction->setObjectName("subFolders");
includeSubDirectoriesAction->setIcon(QIcon(":/images/tree.png"));
includeSubDirectoriesAction->setCheckable(true);
connect(includeSubDirectoriesAction, SIGNAL(triggered()), this, SLOT(setIncludeSubDirs()));
pasteAction = new QAction(tr("Paste Here"), this);
pasteAction->setObjectName("paste");
pasteAction->setIcon(QIcon::fromTheme("edit-paste", QIcon(":/images/paste.png")));
connect(pasteAction, SIGNAL(triggered()), this, SLOT(pasteThumbs()));
pasteAction->setEnabled(false);
createDirectoryAction = new QAction(tr("New Directory"), this);
createDirectoryAction->setObjectName("createDir");
connect(createDirectoryAction, SIGNAL(triggered()), this, SLOT(createSubDirectory()));
createDirectoryAction->setIcon(QIcon::fromTheme("folder-new", QIcon(":/images/new_folder.png")));
setSaveDirectoryAction = new QAction(tr("Set Save Directory"), this);
setSaveDirectoryAction->setObjectName("setSaveDir");
connect(setSaveDirectoryAction, SIGNAL(triggered()), this, SLOT(setSaveDirectory()));
setSaveDirectoryAction->setIcon(QIcon::fromTheme("folder-visiting", QIcon(":/images/folder-visiting.png")));
goBackAction = new QAction(tr("Back"), this);
goBackAction->setObjectName("goBack");
goBackAction->setIcon(QIcon::fromTheme("go-previous", QIcon(":/images/back.png")));
connect(goBackAction, SIGNAL(triggered()), this, SLOT(goBack()));
goBackAction->setEnabled(false);
goFrwdAction = new QAction(tr("Forward"), this);
goFrwdAction->setObjectName("goFrwd");
goFrwdAction->setIcon(QIcon::fromTheme("go-next", QIcon(":/images/next.png")));
connect(goFrwdAction, SIGNAL(triggered()), this, SLOT(goForward()));
goFrwdAction->setEnabled(false);
goUpAction = new QAction(tr("Go Up"), this);
goUpAction->setObjectName("up");
goUpAction->setIcon(QIcon::fromTheme("go-up", QIcon(":/images/up.png")));
connect(goUpAction, SIGNAL(triggered()), this, SLOT(goUp()));
goHomeAction = new QAction(tr("Home"), this);
goHomeAction->setObjectName("home");
connect(goHomeAction, SIGNAL(triggered()), this, SLOT(goHome()));
goHomeAction->setIcon(QIcon::fromTheme("go-home", QIcon(":/images/home.png")));
slideShowAction = new QAction(tr("Slide Show"), this);
slideShowAction->setObjectName("toggleSlideShow");
connect(slideShowAction, SIGNAL(triggered()), this, SLOT(toggleSlideShow()));
slideShowAction->setIcon(QIcon::fromTheme("media-playback-start", QIcon(":/images/play.png")));
nextImageAction = new QAction(tr("Next Image"), this);
nextImageAction->setObjectName("nextImage");
nextImageAction->setIcon(QIcon::fromTheme("go-next", QIcon(":/images/next.png")));
connect(nextImageAction, SIGNAL(triggered()), this, SLOT(loadNextImage()));
prevImageAction = new QAction(tr("Previous Image"), this);
prevImageAction->setObjectName("prevImage");
prevImageAction->setIcon(QIcon::fromTheme("go-previous", QIcon(":/images/back.png")));
connect(prevImageAction, SIGNAL(triggered()), this, SLOT(loadPreviousImage()));
firstImageAction = new QAction(tr("First Image"), this);
firstImageAction->setObjectName("firstImage");
firstImageAction->setIcon(QIcon::fromTheme("go-first", QIcon(":/images/first.png")));
connect(firstImageAction, SIGNAL(triggered()), this, SLOT(loadFirstImage()));
lastImageAction = new QAction(tr("Last Image"), this);
lastImageAction->setObjectName("lastImage");
lastImageAction->setIcon(QIcon::fromTheme("go-last", QIcon(":/images/last.png")));
connect(lastImageAction, SIGNAL(triggered()), this, SLOT(loadLastImage()));
randomImageAction = new QAction(tr("Random Image"), this);
randomImageAction->setObjectName("randomImage");
connect(randomImageAction, SIGNAL(triggered()), this, SLOT(loadRandomImage()));
viewImageAction = new QAction(tr("View Image"), this);
viewImageAction->setObjectName("open");
viewImageAction->setIcon(QIcon::fromTheme("document-open", QIcon(":/images/open.png")));
connect(viewImageAction, SIGNAL(triggered()), this, SLOT(viewImage()));
showClipboardAction = new QAction(tr("Load Clipboard"), this);
showClipboardAction->setObjectName("showClipboard");
showClipboardAction->setIcon(QIcon::fromTheme("insert-image", QIcon(":/images/new.png")));
connect(showClipboardAction, SIGNAL(triggered()), this, SLOT(newImage()));
openWithSubMenu = new QMenu(tr("Open With..."));
openWithMenuAction = new QAction(tr("Open With..."), this);
openWithMenuAction->setObjectName("openWithMenu");
openWithMenuAction->setMenu(openWithSubMenu);
externalAppsAction = new QAction(tr("External Applications"), this);
externalAppsAction->setIcon(QIcon::fromTheme("preferences-other", QIcon(":/images/settings.png")));
externalAppsAction->setObjectName("chooseApp");
connect(externalAppsAction, SIGNAL(triggered()), this, SLOT(chooseExternalApp()));
addBookmarkAction = new QAction(tr("Add Bookmark"), this);
addBookmarkAction->setObjectName("addBookmark");
addBookmarkAction->setIcon(QIcon(":/images/new_bookmark.png"));
connect(addBookmarkAction, SIGNAL(triggered()), this, SLOT(addNewBookmark()));
removeBookmarkAction = new QAction(tr("Delete Bookmark"), this);
removeBookmarkAction->setObjectName("deleteBookmark");
removeBookmarkAction->setIcon(QIcon::fromTheme("edit-delete", QIcon(":/images/delete.png")));
zoomOutAction = new QAction(tr("Zoom Out"), this);
zoomOutAction->setObjectName("zoomOut");
connect(zoomOutAction, SIGNAL(triggered()), this, SLOT(zoomOut()));
zoomOutAction->setIcon(QIcon::fromTheme("zoom-out", QIcon(":/images/zoom_out.png")));
zoomInAction = new QAction(tr("Zoom In"), this);
zoomInAction->setObjectName("zoomIn");
connect(zoomInAction, SIGNAL(triggered()), this, SLOT(zoomIn()));
zoomInAction->setIcon(QIcon::fromTheme("zoom-in", QIcon(":/images/zoom_out.png")));
resetZoomAction = new QAction(tr("Reset Zoom"), this);
resetZoomAction->setObjectName("resetZoom");
resetZoomAction->setIcon(QIcon::fromTheme("zoom-fit-best", QIcon(":/images/zoom.png")));
connect(resetZoomAction, SIGNAL(triggered()), this, SLOT(resetZoom()));
origZoomAction = new QAction(tr("Original Size"), this);
origZoomAction->setObjectName("origZoom");
origZoomAction->setIcon(QIcon::fromTheme("zoom-original", QIcon(":/images/zoom1.png")));
connect(origZoomAction, SIGNAL(triggered()), this, SLOT(origZoom()));
keepZoomAction = new QAction(tr("Keep Zoom"), this);
keepZoomAction->setObjectName("keepZoom");
keepZoomAction->setCheckable(true);
connect(keepZoomAction, SIGNAL(triggered()), this, SLOT(keepZoom()));
rotateLeftAction = new QAction(tr("Rotate 90 degree CCW"), this);
rotateLeftAction->setObjectName("rotateLeft");
rotateLeftAction->setIcon(QIcon::fromTheme("object-rotate-left", QIcon(":/images/rotate_left.png")));
connect(rotateLeftAction, SIGNAL(triggered()), this, SLOT(rotateLeft()));
rotateRightAction = new QAction(tr("Rotate 90 degree CW"), this);
rotateRightAction->setObjectName("rotateRight");
rotateRightAction->setIcon(QIcon::fromTheme("object-rotate-right", QIcon(":/images/rotate_right.png")));
connect(rotateRightAction, SIGNAL(triggered()), this, SLOT(rotateRight()));
rotateToolAction = new QAction(tr("Rotate with mouse"), this);
rotateToolAction->setObjectName("rotateRight");
rotateToolAction->setIcon(QIcon::fromTheme("rotation-allowed", QIcon(":/images/rotate.png")));
rotateToolAction->setCheckable(true);
connect(rotateToolAction, SIGNAL(triggered()), this, SLOT(toggleRotateEnabled()));
flipHorizontalAction = new QAction(tr("Flip Horizontally"), this);
flipHorizontalAction->setObjectName("flipH");
flipHorizontalAction->setIcon(QIcon::fromTheme("object-flip-horizontal", QIcon(":/images/flipH.png")));
connect(flipHorizontalAction, SIGNAL(triggered()), this, SLOT(flipHorizontal()));
flipVerticalAction = new QAction(tr("Flip Vertically"), this);
flipVerticalAction->setObjectName("flipV");
flipVerticalAction->setIcon(QIcon::fromTheme("object-flip-vertical", QIcon(":/images/flipV.png")));
connect(flipVerticalAction, SIGNAL(triggered()), this, SLOT(flipVertical()));
cropAction = new QAction(tr("Cropping"), this);
cropAction->setObjectName("crop");
cropAction->setIcon(QIcon(":/images/crop.png"));
connect(cropAction, SIGNAL(triggered()), this, SLOT(cropImage()));
applyCropAndRotationAction = new QAction(tr("Apply Crop and Rotation"), this);
applyCropAndRotationAction->setObjectName("applyCropAndRotation");
applyCropAndRotationAction->setIcon(QIcon(":/images/crop.png"));
resizeAction = new QAction(tr("Scale Image"), this);
resizeAction->setObjectName("resize");
resizeAction->setIcon(QIcon::fromTheme("transform-scale", QIcon(":/images/scale.png")));
connect(resizeAction, SIGNAL(triggered()), this, SLOT(scaleImage()));
freeRotateLeftAction = new QAction(tr("Rotate 1 degree CCW"), this);
freeRotateLeftAction->setObjectName("freeRotateLeft");
connect(freeRotateLeftAction, SIGNAL(triggered()), this, SLOT(freeRotateLeft()));
freeRotateRightAction = new QAction(tr("Rotate 1 degree CW"), this);
freeRotateRightAction->setObjectName("freeRotateRight");
connect(freeRotateRightAction, SIGNAL(triggered()), this, SLOT(freeRotateRight()));
colorsAction = new QAction(tr("Colors"), this);
colorsAction->setObjectName("colors");
connect(colorsAction, SIGNAL(triggered()), this, SLOT(showColorsDialog()));
colorsAction->setIcon(QIcon(":/images/colors.png"));
findDupesAction = new QAction(tr("Find Duplicate Images"), this);
findDupesAction->setObjectName("findDupes");
findDupesAction->setIcon(QIcon(":/images/duplicates.png"));
findDupesAction->setCheckable(true);
connect(findDupesAction, SIGNAL(triggered()), this, SLOT(findDuplicateImages()));
mirrorDisabledAction = new QAction(tr("Disable Mirror"), this);
mirrorDisabledAction->setObjectName("mirrorDisabled");
mirrorDualAction = new QAction(tr("Dual Mirror"), this);
mirrorDualAction->setObjectName("mirrorDual");
mirrorTripleAction = new QAction(tr("Triple Mirror"), this);
mirrorTripleAction->setObjectName("mirrorTriple");
mirrorDualVerticalAction = new QAction(tr("Dual Vertical Mirror"), this);
mirrorDualVerticalAction->setObjectName("mirrorVDual");
mirrorQuadAction = new QAction(tr("Quad Mirror"), this);
mirrorQuadAction->setObjectName("mirrorQuad");
mirrorDisabledAction->setCheckable(true);
mirrorDualAction->setCheckable(true);
mirrorTripleAction->setCheckable(true);
mirrorDualVerticalAction->setCheckable(true);
mirrorQuadAction->setCheckable(true);
connect(mirrorDisabledAction, SIGNAL(triggered()), this, SLOT(setMirrorDisabled()));
connect(mirrorDualAction, SIGNAL(triggered()), this, SLOT(setMirrorDual()));
connect(mirrorTripleAction, SIGNAL(triggered()), this, SLOT(setMirrorTriple()));
connect(mirrorDualVerticalAction, SIGNAL(triggered()), this, SLOT(setMirrorVDual()));
connect(mirrorQuadAction, SIGNAL(triggered()), this, SLOT(setMirrorQuad()));
mirrorDisabledAction->setChecked(true);
keepTransformAction = new QAction(tr("Keep Transformations"), this);
keepTransformAction->setObjectName("keepTransform");
keepTransformAction->setCheckable(true);
connect(keepTransformAction, SIGNAL(triggered()), this, SLOT(keepTransformClicked()));
moveLeftAction = new QAction(tr("Move Image Left"), this);
moveLeftAction->setObjectName("moveLeft");
connect(moveLeftAction, SIGNAL(triggered()), this, SLOT(moveLeft()));
moveRightAction = new QAction(tr("Move Image Right"), this);
moveRightAction->setObjectName("moveRight");
connect(moveRightAction, SIGNAL(triggered()), this, SLOT(moveRight()));
moveUpAction = new QAction(tr("Move Image Up"), this);
moveUpAction->setObjectName("moveUp");
connect(moveUpAction, SIGNAL(triggered()), this, SLOT(moveUp()));
moveDownAction = new QAction(tr("Move Image Down"), this);
moveDownAction->setObjectName("moveDown");
connect(moveDownAction, SIGNAL(triggered()), this, SLOT(moveDown()));
invertSelectionAction = new QAction(tr("Invert Selection"), this);
invertSelectionAction->setObjectName("invertSelection");
connect(invertSelectionAction, SIGNAL(triggered()), thumbsViewer, SLOT(invertSelection()));
// There could be a Batch submenu if we had any more items to put there
batchSubMenu = new QMenu(tr("Batch"));
batchSubMenuAction = new QAction(tr("Batch"), this);
batchSubMenuAction->setMenu(batchSubMenu);
batchTransformAction = new QAction(tr("Repeat Rotate and Crop"), this);
batchTransformAction->setObjectName("batchTransform");
connect(batchTransformAction, SIGNAL(triggered()), this, SLOT(batchTransform()));
batchSubMenu->addAction(batchTransformAction);
filterImagesFocusAction = new QAction(tr("Filter by Name"), this);
filterImagesFocusAction->setObjectName("filterImagesFocus");
connect(filterImagesFocusAction, SIGNAL(triggered()), this, SLOT(filterImagesFocus()));
setPathFocusAction = new QAction(tr("Edit Current Path"), this);
setPathFocusAction->setObjectName("setPathFocus");
connect(setPathFocusAction, SIGNAL(triggered()), this, SLOT(setPathFocus()));
}
void Phototonic::createMenus() {
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(includeSubDirectoriesAction);
fileMenu->addAction(createDirectoryAction);
fileMenu->addAction(setSaveDirectoryAction);
fileMenu->addAction(showClipboardAction);
fileMenu->addAction(addBookmarkAction);
fileMenu->addSeparator();
fileMenu->addAction(exitAction);
editMenu = menuBar()->addMenu(tr("&Edit"));
editMenu->addAction(cutAction);
editMenu->addAction(copyAction);
editMenu->addAction(copyToAction);
editMenu->addAction(moveToAction);
editMenu->addAction(pasteAction);
editMenu->addAction(renameAction);
editMenu->addAction(removeMetadataAction);
editMenu->addAction(deleteAction);
editMenu->addAction(deletePermanentlyAction);
editMenu->addSeparator();
editMenu->addAction(selectAllAction);
editMenu->addAction(selectByBrightnesAction);
editMenu->addAction(sortBySimilarityAction);
editMenu->addAction(invertSelectionAction);
editMenu->addAction(batchSubMenuAction);
addAction(filterImagesFocusAction);
addAction(setPathFocusAction);
editMenu->addSeparator();
editMenu->addAction(externalAppsAction);
editMenu->addAction(settingsAction);
goMenu = menuBar()->addMenu(tr("&Go"));
goMenu->addAction(goBackAction);
goMenu->addAction(goFrwdAction);
goMenu->addAction(goUpAction);
goMenu->addAction(goHomeAction);
goMenu->addSeparator();
goMenu->addAction(prevImageAction);
goMenu->addAction(nextImageAction);
goMenu->addSeparator();
goMenu->addAction(thumbsGoToTopAction);
goMenu->addAction(thumbsGoToBottomAction);
viewMenu = menuBar()->addMenu(tr("&View"));
viewMenu->addAction(slideShowAction);
viewMenu->addSeparator();
thumbLayoutsGroup = new QActionGroup(this);
thumbLayoutsGroup->addAction(setClassicThumbsAction);
thumbLayoutsGroup->addAction(setSquareThumbsAction);
thumbLayoutsGroup->addAction(setCompactThumbsAction);
viewMenu->addActions(thumbLayoutsGroup->actions());
viewMenu->addSeparator();
viewMenu->addAction(thumbsZoomInAction);
viewMenu->addAction(thumbsZoomOutAction);
sortMenu = viewMenu->addMenu(tr("Thumbnails Sorting"));
sortTypesGroup = new QActionGroup(this);
sortTypesGroup->addAction(sortByNameAction);
sortTypesGroup->addAction(sortByTimeAction);
sortTypesGroup->addAction(sortBySizeAction);
sortTypesGroup->addAction(sortByTypeAction);
sortTypesGroup->addAction(sortBySimilarityAction);
sortMenu->addActions(sortTypesGroup->actions());
sortMenu->addSeparator();
sortMenu->addAction(sortReverseAction);
viewMenu->addSeparator();
viewMenu->addAction(showHiddenFilesAction);
viewMenu->addSeparator();
viewMenu->addAction(refreshAction);
viewMenu->addSeparator();
viewMenu->addAction(findDupesAction);
// thumbs viewer context menu
thumbsViewer->addAction(viewImageAction);
thumbsViewer->addAction(openWithMenuAction);
thumbsViewer->addAction(cutAction);
thumbsViewer->addAction(copyAction);
thumbsViewer->addAction(pasteAction);
addMenuSeparator(thumbsViewer);
thumbsViewer->addAction(copyToAction);
thumbsViewer->addAction(moveToAction);
thumbsViewer->addAction(renameAction);
thumbsViewer->addAction(removeMetadataAction);
thumbsViewer->addAction(deleteAction);
thumbsViewer->addAction(deletePermanentlyAction);
addMenuSeparator(thumbsViewer);
thumbsViewer->addAction(selectAllAction);
thumbsViewer->addAction(selectByBrightnesAction);
thumbsViewer->addAction(invertSelectionAction);
thumbsViewer->addAction(batchSubMenuAction);
thumbsViewer->setContextMenuPolicy(Qt::ActionsContextMenu);
menuBar()->setVisible(true);
}
void Phototonic::createToolBars() {
/* Edit */
editToolBar = addToolBar(tr("Edit Toolbar"));
editToolBar->setObjectName("Edit");
editToolBar->addAction(cutAction);
editToolBar->addAction(copyAction);
editToolBar->addAction(pasteAction);
editToolBar->addAction(deleteAction);
editToolBar->addAction(deletePermanentlyAction);
editToolBar->addAction(showClipboardAction);
connect(editToolBar->toggleViewAction(), SIGNAL(triggered()), this, SLOT(setEditToolBarVisibility()));
/* Navigation */
goToolBar = addToolBar(tr("Navigation Toolbar"));
goToolBar->setObjectName("Navigation");
goToolBar->addAction(goBackAction);
goToolBar->addAction(goFrwdAction);
goToolBar->addAction(goUpAction);
goToolBar->addAction(goHomeAction);
goToolBar->addAction(refreshAction);
/* path bar */
pathLineEdit = new QLineEdit;
pathLineEdit->setCompleter(new DirCompleter(pathLineEdit));
pathLineEdit->setMinimumWidth(200);
pathLineEdit->setMaximumWidth(600);
connect(pathLineEdit, SIGNAL(returnPressed()), this, SLOT(goPathBarDir()));
goToolBar->addWidget(pathLineEdit);
goToolBar->addAction(includeSubDirectoriesAction);
goToolBar->addAction(findDupesAction);
connect(goToolBar->toggleViewAction(), SIGNAL(triggered()), this, SLOT(setGoToolBarVisibility()));
/* View */
viewToolBar = addToolBar(tr("View Toolbar"));
viewToolBar->setObjectName("View");
viewToolBar->addAction(thumbsZoomInAction);
viewToolBar->addAction(thumbsZoomOutAction);
viewToolBar->addAction(slideShowAction);
/* filter bar */
QAction *filterAct = new QAction(tr("Filter"), this);
filterAct->setIcon(QIcon::fromTheme("edit-find", QIcon(":/images/zoom.png")));
connect(filterAct, SIGNAL(triggered()), this, SLOT(setThumbsFilter()));
filterLineEdit = new QLineEdit;
filterLineEdit->setMinimumWidth(100);
filterLineEdit->setMaximumWidth(200);
connect(filterLineEdit, SIGNAL(returnPressed()), this, SLOT(setThumbsFilter()));
connect(filterLineEdit, SIGNAL(textChanged(
const QString&)), this, SLOT(clearThumbsFilter()));
filterLineEdit->setClearButtonEnabled(true);
filterLineEdit->addAction(filterAct, QLineEdit::LeadingPosition);
viewToolBar->addSeparator();
viewToolBar->addWidget(filterLineEdit);
viewToolBar->addAction(settingsAction);
connect(viewToolBar->toggleViewAction(), SIGNAL(triggered()), this, SLOT(setViewToolBarVisibility()));
/* image */
imageToolBar = new QToolBar(tr("Image Toolbar"));
imageToolBar->setObjectName("Image");
imageToolBar->addAction(prevImageAction);
imageToolBar->addAction(nextImageAction);
imageToolBar->addAction(firstImageAction);
imageToolBar->addAction(lastImageAction);
imageToolBar->addAction(slideShowAction);
imageToolBar->addSeparator();
imageToolBar->addAction(saveAction);
imageToolBar->addAction(saveAsAction);
imageToolBar->addAction(deleteAction);
imageToolBar->addAction(deletePermanentlyAction);
imageToolBar->addSeparator();
imageToolBar->addAction(zoomInAction);
imageToolBar->addAction(zoomOutAction);
imageToolBar->addAction(resetZoomAction);
imageToolBar->addAction(origZoomAction);
imageToolBar->addSeparator();
imageToolBar->addAction(resizeAction);
imageToolBar->addAction(rotateRightAction);
imageToolBar->addAction(rotateLeftAction);
imageToolBar->addAction(rotateToolAction);
imageToolBar->addAction(flipHorizontalAction);
imageToolBar->addAction(flipVerticalAction);
imageToolBar->addAction(cropAction);
imageToolBar->addAction(colorsAction);
imageToolBar->setVisible(false);
connect(imageToolBar->toggleViewAction(), SIGNAL(triggered()), this, SLOT(setImageToolBarVisibility()));
setToolbarIconSize();
}
void Phototonic::setClassicThumbs() {
Settings::thumbsLayout = ThumbsViewer::Classic;
refreshThumbs(false);
}
void Phototonic::toggleRotateEnabled()
{
Settings::mouseRotateEnabled = rotateToolAction->isChecked();
}
void Phototonic::onToolsUpdated()
{
rotateToolAction->setChecked(Settings::mouseRotateEnabled);
}
void Phototonic::setSquareThumbs() {
Settings::thumbsLayout = ThumbsViewer::Squares;
refreshThumbs(false);
}
void Phototonic::setCompactThumbs() {
Settings::thumbsLayout = ThumbsViewer::Compact;
refreshThumbs(false);
}
void Phototonic::setToolbarIconSize() {
if (initComplete) {
Settings::smallToolbarIcons = smallToolbarIconsAction->isChecked();
}
int iconSize = Settings::smallToolbarIcons ? 16 : 24;
QSize iconQSize(iconSize, iconSize);
editToolBar->setIconSize(iconQSize);
goToolBar->setIconSize(iconQSize);
viewToolBar->setIconSize(iconQSize);
imageToolBar->setIconSize(iconQSize);
}
void Phototonic::createStatusBar() {
statusLabel = new QLabel(tr("Initializing..."));
statusBar()->addWidget(statusLabel);
busyMovie = new QMovie(":/images/busy.gif");
busyLabel = new QLabel(this);
busyLabel->setMovie(busyMovie);
busyMovie->setParent(busyLabel);
statusBar()->addWidget(busyLabel);
busyLabel->setVisible(false);
statusBar()->setStyleSheet("QStatusBar::item { border: 0px solid black }; ");
}
void Phototonic::onFileListSelected() {
if (initComplete && fileListWidget->itemAt(0, 0)->isSelected()) {
Settings::isFileListLoaded = true;