Debian Codegraph @

src/album/module/view/viewpanel.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 VIEWPANEL_H
22 #define VIEWPANEL_H
23
24 #include "module/modulepanel.h"
25 #include "dbmanager/dbmanager.h"
26 #include "controller/viewerthememanager.h"
27 #include "danchors.h"
28 #include "thumbnailwidget.h"
29 #include "lockwidget.h"
30 #include "contents/ttbcontent.h"
31
32 #include <QFileInfo>
33 #include <QJsonObject>
34 #include <QDirIterator>
35 #include <DMenu>
36 #include <DDesktopServices>
37
38 DWIDGET_USE_NAMESPACE
39
40 class ImageButton;
41 class ImageView;
42 class NavigationWidget;
43 class QFileSystemWatcher;
44 class QLabel;
45 class QStackedWidget;
46 class SlideEffectPlayer;
47
48 class ViewPanel : public ModulePanel, public ImageEngineObject
49 {
50 Q_OBJECT
51 public:
52 explicit ViewPanel(QWidget *parent = nullptr);
53 ~ViewPanel() Q_DECL_OVERRIDE;
54
55 QString moduleName() override;
56 // QWidget *toolbarBottomContent() override;
57 // QWidget *toolbarTopLeftContent() override;
58 void bottomTopLeftContent() ;
59 // QWidget *toolbarTopMiddleContent() override;
60 int getPicCount()
61 {
62 if (m_ttbc == nullptr) {
63 return -1;
64 }
65 return m_ttbc->itemLoadedSize();
66 }
67 // ImageView *getImageView();
68
69
70 signals:
71 void updateCollectButton();
72 void imageChanged(const QString &path);
73 void ttbcDeleteImage();
74 void viewImageFrom(QString dir);
75 void mouseMoved();
76 void updateTopLeftWidthChanged(int width);
77 void imgloader();
78 void sigResize();
79
80 public slots:
81 void onDeleteByMenu();
82 void onGotoPanel(ModulePanel *p);
83 void onShowExtensionPanel();
84 void onHideExtensionPanel();
85 void onHideImageView();
86 bool onSigViewImage(const SignalManager::ViewInfo &info);
87 void onMouseHoverMoved();
88 void onESCKeyActivated();
89 // void onImagesInserted();
90 // void onViewImageNoNeedReload(int &fileindex);
91 void onRotateClockwise();
92 void onRotateCounterClockwise();
93 void onRemoved();
94 void onResetTransform(bool fitWindow);
95 void onDoubleClicked();
96 void onViewBClicked();
97 void onViewBImageChanged(const QString &path);
98 void onFileDelete();
99
100 protected:
101 bool eventFilter(QObject *obj, QEvent *e) Q_DECL_OVERRIDE;
102 void mousePressEvent(QMouseEvent *e) Q_DECL_OVERRIDE;
103 void resizeEvent(QResizeEvent *e) Q_DECL_OVERRIDE;
104 void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
105 void wheelEvent(QWheelEvent *e) Q_DECL_OVERRIDE;
106 void keyPressEvent(QKeyEvent *e)Q_DECL_OVERRIDE;
107
108 private:
109 //------------------
110 void loadFilesFromLocal(QStringList files);
111 bool imageLocalLoaded(QStringList &filelist) override;
112 bool imageFromDBLoaded(QStringList &filelist) override
113 {
114 Q_UNUSED(filelist)
115 return false;
116 }
117 bool imageLoaded(QString filepath) override
118 {
119 Q_UNUSED(filepath)
120 return false;
121 }
122 //------------------
123 void initConnect();
124 void initFileSystemWatcher();
125 void initPopupMenu();
126 void initShortcut();
127 void initStack();
128 void initViewContent();
129 // void popupPrintDialog(const QString &path);
130
131 // Floating component
132 void initFloatingComponent();
133 void initScaleLabel();
134 void initNavigation();
135
136 // Menu control
137 void appendAction(int id, const QString &text, const QString &shortcut = "");
138 void appendAction_darkmenu(int id, const QString &text, const QString &shortcut = "");
139 DMenu *createAblumMenu();
140 #ifndef LITE_DIV
141 DMenu *createAlbumMenu();
142 #endif
143 void onMenuItemClicked(QAction *action);
144 void updateMenuContent();
145
146 // View control
147 void onViewImage(const QStringList &vinfo);
148 void openImage(const QString &path, bool bjudge = true);
149 void removeCurrentImage();
150 void rotateImage(bool clockWise);
151 // Geometry
152 void toggleFullScreen();
153 void showNormal();
154 void showFullScreen();
155 void backToLastPanel();
156
157 private slots:
158 // void onThemeChanged(ViewerThemeManager::AppTheme theme);
159 void feedBackCurrentIndex(int index, const QString &path);
160
161 private:
162 int m_hideCursorTid;
163 int m_iSlideShowTimerId;
164 bool m_isInfoShowed;
165 bool m_isMaximized = false;
166
167 bool m_printDialogVisible = false;
168 int m_topLeftContentWidth = 0;
169 ImageView *m_viewB = nullptr;
170 ThumbnailWidget *m_emptyWidget = nullptr;
171 QMenu *m_menu = nullptr;
172 QStackedWidget *m_stack = nullptr;
173 LockWidget *m_lockWidget = nullptr;
174
175 // Floating component
176 DAnchors<NavigationWidget> m_nav;
177 SignalManager::ViewInfo m_vinfo;
178 TTBContent *m_ttbc = nullptr;
179 int m_current = -1;
180 #ifdef LITE_DIV
181 QScopedPointer<QDirIterator> m_imageDirIterator;
182 void eatImageDirIterator();
183 #endif
184 QString m_currentImageLastDir = "";
185 //------------------
186 QStringList m_filepathlist;
187 QString m_currentpath = "";
188 //------------------
189 QTimer *m_deletetimer = nullptr; //删除图片定时器
190 bool m_bFirstFullScreen; //是否全屏进入
191
192 //平板需求,工具栏显隐控制
193 bool m_showorhide = true;
194 };
195 #endif // VIEWPANEL_H