| 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 ALBUMVIEW_H |
| 22 |
#define ALBUMVIEW_H |
| 23 |
|
| 24 |
#include "thumbnail/thumbnaillistview.h" |
| 25 |
#include "dbmanager/dbmanager.h" |
| 26 |
#include "controller/signalmanager.h" |
| 27 |
#include "widgets/albumlefttabitem.h" |
| 28 |
#include "importview/importview.h" |
| 29 |
#include "searchview/searchview.h" |
| 30 |
#include "widgets/statusbar.h" |
| 31 |
#include "importtimelineview/importtimelineview.h" |
| 32 |
#include "leftlistview.h" |
| 33 |
#include "waitdevicedialog.h" |
| 34 |
#include "dialogs/albumdeletedialog.h" |
| 35 |
|
| 36 |
#include <QWidget> |
| 37 |
#include <QSplitter> |
| 38 |
#include <QUrl> |
| 39 |
#include <DListWidget> |
| 40 |
#include <QListWidgetItem> |
| 41 |
#include <QVBoxLayout> |
| 42 |
#include <DLineEdit> |
| 43 |
#include <DStackedWidget> |
| 44 |
#include <DPushButton> |
| 45 |
#include <dgiomount.h> |
| 46 |
#include <DApplicationHelper> |
| 47 |
#include <DSpinner> |
| 48 |
#include <DSuggestButton> |
| 49 |
#include <DDialog> |
| 50 |
#include <ddiskmanager.h> |
| 51 |
#include <dblockdevice.h> |
| 52 |
#include <ddiskdevice.h> |
| 53 |
#include "leftlistwidget.h" |
| 54 |
#include <QRunnable> |
| 55 |
#include <QThreadPool> |
| 56 |
|
| 57 |
//#define GIO_COMPILATION |
| 58 |
#undef signals |
| 59 |
extern "C" { |
| 60 |
#include <gio/gio.h> |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
#define signals public |
| 65 |
|
| 66 |
DWIDGET_USE_NAMESPACE |
| 67 |
DCORE_USE_NAMESPACE |
| 68 |
|
| 69 |
class DGioVolumeManager; |
| 70 |
class AlbumView; |
| 71 |
class AlbumView : public QWidget, public ImageEngineImportObject, public ImageMountGetPathsObject, public ImageMountImportPathsObject |
| 72 |
{ |
| 73 |
Q_OBJECT |
| 74 |
|
| 75 |
public: |
| 76 |
enum MenuItemId { |
| 77 |
IdStartSlideShow, |
| 78 |
IdCreateAlbum, |
| 79 |
IdRenameAlbum, |
| 80 |
IdExport, |
| 81 |
IdDeleteAlbum, |
| 82 |
}; |
| 83 |
|
| 84 |
enum AblumType { |
| 85 |
photosType, |
| 86 |
ablumType, |
| 87 |
devType |
| 88 |
}; |
| 89 |
|
| 90 |
AlbumView(); |
| 91 |
~AlbumView() override; |
| 92 |
|
| 93 |
bool imageImported(bool success) override; |
| 94 |
bool imageGeted(QStringList &filelist, QString path) override; |
| 95 |
bool imageMountImported(QStringList &filelist) override; |
| 96 |
|
| 97 |
void iniWaitDiolag(); |
| 98 |
void SearchReturnUpdate(); |
| 99 |
void restorePicNum(); |
| 100 |
void updatePicNum(); |
| 101 |
void updateRightView(); |
| 102 |
void updateAlbumView(const QString &album); |
| 103 |
void updateDeviceLeftList(); |
| 104 |
void setCurrentItemType(int type); |
| 105 |
void leftTabClicked(); |
| 106 |
private: |
| 107 |
void initConnections(); |
| 108 |
void initLeftView(); |
| 109 |
void initRightView(); |
| 110 |
//初始化最近删除 |
| 111 |
void initTrashWidget(); |
| 112 |
//初始化自定义相册列表 |
| 113 |
void initCustomAlbumWidget(); |
| 114 |
//初始化收藏列表 |
| 115 |
void initFavoriteWidget(); |
| 116 |
//初始化设备列表 |
| 117 |
void initPhoneWidget(); |
| 118 |
//显示照片与视频总数 |
| 119 |
void resetLabelCount(int photosCount, int videosCount, DLabel *lable); |
| 120 |
|
| 121 |
void updateRightCustomAlbumView(); |
| 122 |
void updateRightTrashView(); |
| 123 |
void updateRightImportView(); |
| 124 |
void updateRightMyFavoriteView(); |
| 125 |
void updateRightMountView(); |
| 126 |
//打开图片 |
| 127 |
void onOpenImageFav(int row, const QString &path, bool bFullScreen); |
| 128 |
//打开图片 |
| 129 |
void onOpenImageCustom(int row, const QString &path, bool bFullScreen); |
| 130 |
//幻灯片播放 |
| 131 |
void onSlideShowFav(const QString &path); |
| 132 |
//幻灯片播放 |
| 133 |
void onSlideShowCustom(const QString &path); |
| 134 |
|
| 135 |
void dragEnterEvent(QDragEnterEvent *e) override; |
| 136 |
void dropEvent(QDropEvent *event) override; |
| 137 |
void dragMoveEvent(QDragMoveEvent *event) override; |
| 138 |
void dragLeaveEvent(QDragLeaveEvent *e) override; |
| 139 |
void resizeEvent(QResizeEvent *e) override; |
| 140 |
void showEvent(QShowEvent *e) override; |
| 141 |
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; |
| 142 |
|
| 143 |
void onVfsMountChangedAdd(QExplicitlySharedDataPointer<DGioMount> mount); |
| 144 |
void onVfsMountChangedRemove(QExplicitlySharedDataPointer<DGioMount> mount); //拔掉外设移除 |
| 145 |
const QList<QExplicitlySharedDataPointer<DGioMount> > getVfsMountList(); |
| 146 |
|
| 147 |
void initExternalDevice(); |
| 148 |
void updateExternalDevice(QExplicitlySharedDataPointer<DGioMount> mount, QString strPath = QString()); |
| 149 |
bool findPicturePathByPhone(QString &path); |
| 150 |
void updateImportComboBox(); |
| 151 |
void importAllBtnClicked(); |
| 152 |
void importSelectBtnClicked(); |
| 153 |
|
| 154 |
void initLeftMenu(); |
| 155 |
void importComboBoxChange(QString strText); |
| 156 |
void getAllDeviceName(); |
| 157 |
|
| 158 |
signals: |
| 159 |
void sigSearchEditIsDisplay(bool bIsDisp); |
| 160 |
void sigLoadMountImagesStart(QString mountName, QString path); |
| 161 |
|
| 162 |
private slots: |
| 163 |
void onTrashRecoveryBtnClicked(); |
| 164 |
void onUpdataAlbumRightTitle(const QString &titlename); |
| 165 |
void onUnMountSignal(const QString &unMountPath); //手动卸载设备 |
| 166 |
void onCreateNewAlbumFromDialog(const QString &newalbumname); |
| 167 |
void onCreateNewAlbumFrom(const QString &albumname); |
| 168 |
void onLeftListDropEvent(QModelIndex dropIndex); |
| 169 |
void onKeyDelete(); |
| 170 |
void onKeyF2(); |
| 171 |
void needUnMount(const QString &path); |
| 172 |
void importDialog(); |
| 173 |
void onWaitDialogClose(); |
| 174 |
void onWaitDialogIgnore(); |
| 175 |
// change lambda to normal slt |
| 176 |
void onRepeatImportingTheSamePhotos(QStringList importPaths, QStringList duplicatePaths, const QString &albumName); |
| 177 |
void ongMouseMove(); |
| 178 |
void onSelectAll(); |
| 179 |
void onInsertedIntoAlbum(const QString &albumname, QStringList pathlist); |
| 180 |
void onFileSystemAdded(const QString &dbusPath); |
| 181 |
void onBlockDeviceAdded(const QString &blks); |
| 182 |
void onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType); |
| 183 |
void onRightPhoneCustomContextMenuRequested(); |
| 184 |
void onRightPhoneThumbnailListMouseRelease(); |
| 185 |
void onImportViewImportBtnClicked(); |
| 186 |
void onImportFailedToView(); |
| 187 |
void onWaitDailogTimeout(); |
| 188 |
void onLeftListViewMountListWidgetClicked(const QModelIndex &index); |
| 189 |
|
| 190 |
//接收到设备中文件列表加载完成信号 |
| 191 |
void sltLoadMountFileList(const QString &path, QStringList fileList); |
| 192 |
//筛选显示,当先列表中内容为无结果 |
| 193 |
void slotNoPicOrNoVideo(bool isNoResult); |
| 194 |
//缩略图选中项改变 |
| 195 |
void sltSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected); |
| 196 |
//最近删除中有变化 |
| 197 |
void onTrashInfosChanged(); |
| 198 |
public: |
| 199 |
int m_iAlubmPicsNum; |
| 200 |
QString m_currentAlbum; |
| 201 |
QString m_currentType; |
| 202 |
AblumType m_currentItemType = photosType; |
| 203 |
int m_selPicNum; |
| 204 |
bool m_itemClicked; |
| 205 |
|
| 206 |
DStackedWidget *m_pRightStackWidget; |
| 207 |
LeftListView *m_pLeftListView; |
| 208 |
StatusBar *m_pStatusBar; |
| 209 |
DWidget *m_pRightWidget; |
| 210 |
|
| 211 |
ThumbnailListView *m_pRightPhoneThumbnailList; //设备相关列表 |
| 212 |
QMap<QString, QStringList> m_phoneNameAndPathlist; |
| 213 |
//LMH0424 |
| 214 |
QStringList m_pictrueallPathlist; |
| 215 |
|
| 216 |
DWidget *m_pwidget; |
| 217 |
|
| 218 |
ThumbnailListView *m_customThumbnailList = nullptr; //自定义 |
| 219 |
DBImgInfoList m_allTrashInfos; //最近删除中的数据 |
| 220 |
ThumbnailListView *m_pRightTrashThumbnailList = nullptr; //最近删除 |
| 221 |
ThumbnailListView *m_favoriteThumbnailList = nullptr; //我的收藏 |
| 222 |
|
| 223 |
DWidget *pImportTimeLineWidget; |
| 224 |
Waitdevicedialog *m_waitDeviceScandialog; |
| 225 |
ImportView *m_pImportView; |
| 226 |
// 已导入窗体 |
| 227 |
ImportTimeLineView *m_pImpTimeLineView; |
| 228 |
|
| 229 |
const static int custom_title_height = 60; |
| 230 |
const static int favorite_title_height = 60; |
| 231 |
const static int trash_title_height = 60; |
| 232 |
const static int magin_offset = 20;//标题不居中偏移 |
| 233 |
private: |
| 234 |
//自定义相册标题 |
| 235 |
DLabel *m_customAlbumTitleLabel = nullptr; |
| 236 |
DLabel *m_pRightPicTotal = nullptr; |
| 237 |
BatchOperateWidget *m_customBatchOperateWidget = nullptr; |
| 238 |
DWidget *m_customAlbumTitle = nullptr; //自定义相册悬浮标题 |
| 239 |
DWidget *m_pCustomAlbumWidget = nullptr; //自定义相册右侧展示界面外层窗口 |
| 240 |
NoResultWidget *m_customNoResultWidget = nullptr; |
| 241 |
//我的收藏标题栏 |
| 242 |
DWidget *m_pFavoriteWidget = nullptr; |
| 243 |
DWidget *m_FavoriteTitleWidget = nullptr; |
| 244 |
DLabel *m_pFavoriteTitle; |
| 245 |
DLabel *m_pFavoritePicTotal; |
| 246 |
BatchOperateWidget *m_favoriteBatchOperateWidget = nullptr; |
| 247 |
NoResultWidget *m_favoriteNoResultWidget = nullptr; |
| 248 |
//外部设备 |
| 249 |
DLabel *m_pPhoneTitle; |
| 250 |
DLabel *m_pPhonePicTotal; |
| 251 |
SearchView *m_pSearchView; |
| 252 |
DGioVolumeManager *m_vfsManager; |
| 253 |
DDiskManager *m_diskManager; |
| 254 |
//最近删除标题 |
| 255 |
DLabel *m_TrashTitleLab = nullptr; |
| 256 |
DLabel *m_TrashDescritionLab = nullptr; |
| 257 |
DWidget *m_TrashTitleWidget = nullptr; |
| 258 |
BatchOperateWidget *m_trashBatchOperateWidget = nullptr; |
| 259 |
DWidget *m_pTrashWidget = nullptr; //最近删除外层界面 |
| 260 |
NoResultWidget *m_trashNoResultWidget = nullptr; |
| 261 |
//手机照片导入窗体 |
| 262 |
DWidget *m_importByPhoneWidget; |
| 263 |
DComboBox *m_importByPhoneComboBox; |
| 264 |
DPushButton *m_importAllByPhoneBtn; |
| 265 |
DSuggestButton *m_importSelectByPhoneBtn; |
| 266 |
QList<QExplicitlySharedDataPointer<DGioMount>> m_mounts; //外部设备挂载 |
| 267 |
|
| 268 |
DBImgInfoList m_curThumbnaiItemList_info; |
| 269 |
QStringList m_curThumbnaiItemList_str; |
| 270 |
int m_mountPicNum; |
| 271 |
|
| 272 |
QMap<QUrl, QString> durlAndNameMap; |
| 273 |
DSpinner *m_spinner = nullptr; |
| 274 |
//add start 3975 |
| 275 |
AlbumDeleteDialog *m_deleteDialog = nullptr; |
| 276 |
//add end 3975 |
| 277 |
DWidget *pPhoneWidget; |
| 278 |
DWidget *phonetopwidget; |
| 279 |
bool isIgnore; |
| 280 |
QTimer *m_waitDailog_timer; |
| 281 |
QMap<QString, bool> mountLoadStatus; |
| 282 |
}; |
| 283 |
|
| 284 |
#endif // ALBUMVIEW_H |