Debian Codegraph @

src/album/mainwindow.h

raw
1 /*
2 * Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co., Ltd.
3 *
4 * Author: ZhangYong <[email protected]>
5 *
6 * Maintainer: ZhangYong <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 #ifndef MAINWINDOW_H
22 #define MAINWINDOW_H
23
24 #include "albumview/albumview.h"
25 #include "allpicview/allpicview.h"
26 #include "timelineview/timelineview.h"
27 #include "dbmanager/dbmanager.h"
28 #include "searchview/searchview.h"
29 #include "controller/commandline.h"
30 #include "controller/exporter.h"
31 #include "widgets/dialogs/imginfodialog.h"
32 #include "module/slideshow/slideshowpanel.h"
33 #include "fileinotify.h"
34
35 #include <DMainWindow>
36 #include <QListWidget>
37 #include <QListWidgetItem>
38 #include <QVBoxLayout>
39 #include <QHBoxLayout>
40 #include <QFrame>
41 //#include <DSegmentedControl>
42 #include <DTitlebar>
43 #include <QStackedWidget>
44 #include <DSearchEdit>
45 #include <DLabel>
46 #include <QStatusBar>
47 #include <DTabBar>
48 #include <QButtonGroup>
49 #include <DSuggestButton>
50 #include <DProgressBar>
51
52 #define DEFAULT_WINDOWS_WIDTH 1300
53 #define DEFAULT_WINDOWS_HEIGHT 640
54 #define MIX_WINDOWS_WIDTH 1300
55 #define MIX_WINDOWS_HEIGHT 848
56 #define TITLEBAR_BLANK_WIDTH 365
57 #define TITLEBAR_BTNWIDGET_WIDTH 240
58 #define TITLEBAR_ICON_WIDTH 50
59
60 DWIDGET_USE_NAMESPACE
61
62 extern bool bfirstopen;
63 extern bool bfirstandviewimage;
64 //namespace Ui {
65 //class MainWindow;
66 //}
67 class MainWindow : public DMainWindow, public ImageEngineImportObject
68 {
69 Q_OBJECT
70
71 public:
72 //增加单例接口,方便closeFromMenu调用
73 static MainWindow &instance()
74 {
75 static MainWindow w;
76 return w;
77 }
78
79 ~MainWindow() override;
80
81 bool imageImported(bool success) override;
82 void initConnections();
83 //初始化UI
84 void initUI();
85 void initWaitDialog();
86 void initShortcut();
87 void initShortcutKey();
88 void initTitleBar();
89 void initCentralWidget();
90 // install filter
91 void initInstallFilter();
92 // 设置初始启动,没有图片时的allpicview tab切换顺序
93 void initNoPhotoNormalTabOrder();
94 // 设置有图片时的allpicview tab tab切换顺序
95 void initAllpicViewTabOrder();
96 // 设置有图片时的allpicview tab tab切换顺序
97 void initTimeLineViewTabOrder();
98 // 设置有图片时的AlbumView tab tab切换顺序
99 void initAlbumViewTabOrder();
100 // enter key
101 void initEnterkeyAction(QObject *obj);
102 // right key
103 bool initRightKeyOrder(QObject *obj);
104 // left key
105 bool initLeftKeyOrder(QObject *obj);
106 // down key
107 bool initDownKeyOrder();
108 // up key
109 bool initUpKeyOrder();
110 // all view tab key order
111 bool initAllViewTabKeyOrder(QObject *obj);
112
113 void setWaitDialogColor();
114 int getCurrentViewType();
115 void showCreateDialog(QStringList imgpaths);
116 // void onShowImageInfo(const QString &path);
117 void loadZoomRatio();
118 void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
119 void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
120 QJsonObject createShorcutJson();
121 //开始监控
122 void startMonitor();
123 private:
124 explicit MainWindow(); //修改为单例后,构造函数也挪走了
125 void thumbnailZoomIn();
126 void thumbnailZoomOut();
127 void saveWindowState();
128 void loadWindowState();
129 void saveZoomRatio();
130 bool compareVersion();
131 // void viewImageClose();
132 void floatMessage(const QString &str, const QIcon &icon);
133 protected:
134 void wheelEvent(QWheelEvent *event) Q_DECL_OVERRIDE;
135 void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
136 bool eventFilter(QObject *obj, QEvent *event) Q_DECL_OVERRIDE;
137
138 signals:
139 void sigTitleMenuImportClicked();
140 bool sigImageImported(bool success);
141
142 public slots:
143 void allPicBtnClicked();
144 void timeLineBtnClicked();
145 void albumBtnClicked();
146 void onCreateAlbum(const QStringList &imagepaths);
147 void closeFromMenu();
148 void onButtonClicked(int id);
149 void onImageImported(bool success);
150 //void onSearchEditTextChanged(QString text);
151 void onImagesInserted();
152 void onStartImprot();
153 void onProgressOfWaitDialog(int allfiles, int completefiles);
154 void onPopupWaitDialog(QString waittext, bool bneedprogress);
155 void onCloseWaitDialog();
156 void onImagesRemoved();
157 void onHideImageView();
158 void onShowSlidePanel(int index);
159 void onHideSlidePanel();
160 void onExportImage(QStringList paths);
161 void onMainwindowSliderValueChg(int step);
162 void onAlbDelToast(QString str1);
163 void onAddDuplicatePhotos();
164 //成功与已存在数量
165 void onRepeatImportingTheSamePhotos(QStringList importPaths, QStringList duplicatePaths, const QString &albumName);
166 void onAddToAlbToast(QString album);
167 void onImportSuccess();
168 void onSearchEditClear();
169 void onImportFailed();
170 void onImportDonotFindPicOrVideo();
171 void onImportSomeFailed(int successful, int failed);
172 void onImgExportFailed();
173 void onImgExportSuccess();
174 void onAlbExportFailed();
175 void onAlbExportSuccess();
176 void onEscShortcutActivated();
177 void onDelShortcutActivated();
178 void onKeyF2ShortcutActivated();
179 void onCtrlShiftSlashShortcutActivated();
180 void onCtrlFShortcutActivated();
181 void onShowImageView(int index);
182 void onSearchEditIsDisplay(bool bIsDisp);
183
184
185 #if 1
186 void onViewCreateAlbum(QString imgpath, bool bmodel = true);
187 #endif
188 void onSearchEditFinished();
189 void onTitleBarMenuClicked(QAction *action);
190 void onImprotBtnClicked();
191 // void onUpdateCentralWidget();
192 void onNewAPPOpen(qint64 pid, const QStringList &arguments);
193 private:
194 int m_iCurrentView;
195 bool m_bTitleMenuImportClicked;
196 bool m_bImport = false;
197 QWidget *m_titleBtnWidget;
198 DMenu *m_pTitleBarMenu;
199 QStackedWidget *m_pCenterWidget = nullptr;
200 public:
201 AlbumView *m_pAlbumview; //相册照片界面视图
202 QWidget *m_pAlbumWidget;
203 AllPicView *m_pAllPicView; //所有照片界面视图
204 TimeLineView *m_pTimeLineView; //时间线界面视图
205 QWidget *m_pTimeLineWidget;
206 SearchView *m_pSearchView; //搜索界面视图
207 QWidget *m_pSearchViewWidget = nullptr;
208 SlideShowPanel *m_slidePanel; //幻灯片播放视图
209 DSearchEdit *m_pSearchEdit;
210 CommandLine *m_commandLine;
211 private:
212 DBManager *m_pDBManager;
213 QMap<QString, ImgInfoDialog *> m_propertyDialogs{};
214 int m_backIndex;
215 int m_backIndex_fromSlide;
216 int m_pSliderPos; //滑动条步进
217
218 QButtonGroup *btnGroup;
219 DPushButton *m_pAllPicBtn;
220 DPushButton *m_pTimeBtn;
221 DPushButton *m_pAlbumBtn;
222
223 DDialog *m_waitdailog;
224 DProgressBar *m_importBar;
225 DLabel *m_waitlabel;
226 DLabel *m_countLabel;
227
228 QString m_SearchKey; //搜索框查询信息
229
230 bool m_isFirstStart = true;
231 bool m_processOptionIsEmpty = false;
232 QSettings *m_settings;
233 // 所有照片空白界面时的taborder
234 QList<QWidget *> m_emptyAllViewTabOrder;
235 // 所有照片非空白界面时
236 QList<QWidget *> m_AllpicViewTabOrder;
237 // 时间线非空白界面时
238 QList<QWidget *> m_TimelineViewTabOrder;
239 // 相册非空白界面时
240 QList<QWidget *> m_AlbumViewTabOrder;
241 // isfirst init
242 QVector<bool> m_bVector;
243 FileInotify *m_fileInotify;//固定文件夹监控
244
245 public:
246 QButtonGroup *getButG();
247 };
248
249 #endif // MAINWINDOW_H