forked from Boms/photoqt-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.h
275 lines (201 loc) · 7.63 KB
/
mainwindow.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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
/*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include "widgets/aboutwidget.h"
#include "graphics/graphicsview.h"
#include "globalvariables.h"
#include "globalsettings.h"
#include "thumbnails/thumbnails.h"
#include "graphics/graphicsitem.h"
#include "settings/settings.h"
#include "widgets/dropdownmenu.h"
#include "widgets/filehandling.h"
#include "widgets/detailswidget.h"
#include "slideshow/slideshowsettings.h"
#include "slideshow/slideshowbar.h"
#include "widgets/startupwidget.h"
#include "wallpaper/wallpaper.h"
#include "graphics/imagereader.h"
#include "setupwidgets.h"
#include "graphics/graphicsviewlay.h"
#include "filterimages/filterimagessetup.h"
#include "filterimages/filterimagesdisplay.h"
#include "manipulation/scale.h"
#include "widgets/quicksettings.h"
#include <QDesktopWidget>
#include <QFile>
#include <QDir>
#include <QTextStream>
#include <QDateTime>
#include <QMessageBox>
#include <QtSql>
#include <QGraphicsPixmapItem>
#include <QPainter>
#include <QLabel>
#include <QGraphicsView>
#include <QVBoxLayout>
#include <QImageReader>
#include <QTimer>
#include <QShortcut>
#include <QSystemTrayIcon>
#include <QMenu>
#include <QScreen>
class MainWindow : public QMainWindow {
Q_OBJECT
private:
void setupTrayIcon();
public:
explicit MainWindow(QWidget *parent = 0, bool verbose = false);
~MainWindow();
// Global variables and settings
GlobalVariables *globVar;
GlobalSettings *globSet;
// Which widgets have been setup
SetupWidgets *setupWidgets;
// The timer is started at startup to wait until window is completely set up
QTimer *startUpTimer;
// The layout of viewBig
ViewBigLay *viewBigLay;
private:
// The current screenshot
QList<QPixmap> screenshots;
QLabel *bglabel;
// The graphicsscenes and -views
QGraphicsScene sceneBig;
GraphicsView *viewBig;
Thumbnails *viewThumbs;
// The big main graphic item
GraphicsItem *graphItem;
GraphicsItem *cropItem;
// The settings dialog
Settings *set;
// All "normal" key shortcuts
QMap<QString,QList<QVariant> > allKeySHdo;
QMap<QString,QShortcut* > allKeySH;
// All system key shortcuts. These function as normal shrtcuts, unless a widget like the settings or open dialogs are open, then they are applied to these widgets. Therefore some shortcuts have always to be set up (just not always connected to a normal shortcut)
QMap<QString,QList<QVariant> > systemKeySHdo;
QMap<QString,QShortcut* > systemKeySH;
// The main dropdown menu top right corner
DropDownMenu *menu;
// The tray icon
QSystemTrayIcon *trayIcon;
// The tray icon menu
QMenu *trayIconMenu;
// The filehandling widget
FileHandling *filehandling;
// Showing some about information
About *about;
// The two slideshow widgets
SlideShow *slideshow;
SlideShowBar *slideshowbar;
// Showing some exif information
Details *details;
// The timer that ensures only one instance of Photo is running a time
QTimer *globalRunningProgTimer;
// This widget is shown after an update/fresh install
StartUpWidget *startup;
// Wallpaper settings
Wallpaper *wallpaper;
// Image filtering
FilterImagesSetup *filterImagesSetup;
FilterImagesDisplay *filterImagesDisplay;
Scale *scaleimage;
QuickSettings *quickset;
// imagereader combining QImageReader and GraphicsMagic
ImageReader *imageReader;
void firstStartSetup();
// Show the startup widget (after update/fresh install)
void showStartupUpdateInstallMsg();
// Load a new image from the open file dialog
void loadNewImgFromOpen(QString path, bool hideImageFilterLabel = true);
// Open a new file
void openFile();
// Re-center image to last position (called from drawImage())
void restoreScrollbarValues();
// This function slips the current big image vertically/horizontally
void rotateFlip(bool rotateNotFlipped, QString direction, int rotateSpecificAmount = 0);
// Set the background of Photo
void setBackground();
// Zoom the current image; if a string is set, the boolean is ignored
void zoom(bool zoomin, QString ignoreBoolean = "");
// Setup a widget
void setupWidget(QString what);
private slots:
// Adjust all the geometries (QRects and stuff)
void adjustGeometries();
// This is called, whenever the settings have changed, and updates all sub-widgets
// This function is needed together with the updateSettings() function to avoid a crash on startup
void applySettings(QMap<QString,bool> applySet = QMap<QString,bool>(), bool justApplyAllOfThem = false);
// If a widget (like open or settings) is opened, all other functions are suspended
void blockFunc(bool);
// Draw the big main image
void drawImage();
// Some images store a orientation in their exif data
void getOrientationFromExif(int degree, bool flipHor);
// Go to specific image
void gotoImageAtPos(int p);
// Timeout of the global timer (see above)
void globalRunningProgTimerTimeout();
// A click on the main image graphicsview
void gotViewBigClick(QPoint pos);
// Load a new image in current dir from the thumbnail view
void loadNewImgFromThumbs(QString path);
// A menuitem has been clicked
void menuClicked(QString txt, int close);
// The mouse has been moved over the main image view (called from viewBig)
void mouseMoved(int x, int y);
// Move in the current directory (1=right, 0=left)
void moveInDirectory(int direction);
// After a file has been manipulated (renamed, deleted, moved), the current dir is reloaded
void reloadDir(QString t);
// Restore default settings
void restoreDefaultSettings();
// Filter images
void removeImageFilter();
void setImageFilter(QString dir, QStringList filter);
// After the settings/about window is closed we might have to call openFile().
// We cannot use one of the already existing functions, since this call is only to
// be done if the settings window has been open and closed!
void settingsAboutClosed() { if(globVar->currentfile == "") openFile(); }
// Setup the shortcuts
void setupShortcuts();
// Called by shortcuts to execute something
void shortcutDO(QString todo = "", bool mouseSH = false);
// After the user closed the startup widget
void startupInstallUpdateMsgClosed();
// On startup, this timer calls drawImage() as soon as the mainwindow finished setup
void startuptimer();
// Start and Stop a slideshow
void startSlideShow();
void stopSlideShow();
// A system shortcut has been called (needed for widgets like about or settings)
void systemShortcutDO(QString todo);
// Take screenshots (called at startup, and when PhotoQt is minimised to system tray and re-opened)
void takeScreenshots();
// Click on a tray icon menu item
void trayAcDo(QSystemTrayIcon::ActivationReason rsn = QSystemTrayIcon::Trigger);
// Update the main image scene rect (called from graphicsitem.cpp)
void updateSceneBigRect();
// The settings have been updated, so the map is passed to suib-widgets
void updateSettings(QMap<QString,QVariant>);
protected:
void closeEvent(QCloseEvent *);
void resizeEvent(QResizeEvent *);
void keyReleaseEvent(QKeyEvent *);
};
#endif // MAINWINDOW_H