| 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 |
#include "albumview.h" |
| 22 |
#include "utils/baseutils.h" |
| 23 |
#include "utils/imageutils.h" |
| 24 |
#include "controller/exporter.h" |
| 25 |
#include "dtkcore_global.h" |
| 26 |
#include "dialogs/albumdeletedialog.h" |
| 27 |
#include "dbmanager/dbmanager.h" |
| 28 |
#include <DNotifySender> |
| 29 |
#include <QMimeData> |
| 30 |
#include <DTableView> |
| 31 |
#include <dgiovolumemanager.h> |
| 32 |
#include <dgiofile.h> |
| 33 |
#include <dgiofileinfo.h> |
| 34 |
#include <dgiovolume.h> |
| 35 |
#include <DFontSizeManager> |
| 36 |
#include "utils/unionimage.h" |
| 37 |
#include <QDirIterator> |
| 38 |
#include <DComboBox> |
| 39 |
#include "widgets/dialogs/imgdeletedialog.h" |
| 40 |
#include "imageengine/imageengineapi.h" |
| 41 |
#include <QShortcut> |
| 42 |
#include <DWarningButton> |
| 43 |
#include <QGraphicsOpacityEffect> |
| 44 |
#include <DToast> |
| 45 |
#include "dmessagemanager.h" |
| 46 |
#include "dialogs/albumcreatedialog.h" |
| 47 |
#include <QScrollBar> //add 3975 |
| 48 |
#include <QMutex> |
| 49 |
#include <DMessageBox> |
| 50 |
|
| 51 |
#include "imageengine/imageengineapi.h" |
| 52 |
#include "imageengine/imageenginethread.h" |
| 53 |
#include "ac-desktop-define.h" |
| 54 |
#include "mainwindow.h" |
| 55 |
#include "leftlistview.h" |
| 56 |
#include "ac-desktop-define.h" |
| 57 |
#include "batchoperatewidget.h" |
| 58 |
#include "noresultwidget.h" |
| 59 |
#include "imagedataservice.h" |
| 60 |
|
| 61 |
static QMutex m_mutex; |
| 62 |
|
| 63 |
namespace { |
| 64 |
const int ITEM_SPACING = 0; |
| 65 |
const int LEFT_VIEW_WIDTH = 180; |
| 66 |
const int LEFT_VIEW_LISTITEM_WIDTH = 160; |
| 67 |
const int LEFT_VIEW_LISTITEM_HEIGHT = 40; |
| 68 |
const int OPE_MODE_ADDNEWALBUM = 0; |
| 69 |
const int OPE_MODE_RENAMEALBUM = 1; |
| 70 |
const int OPE_MODE_ADDRENAMEALBUM = 2; |
| 71 |
const QString BUTTON_STR_RECOVERY = "恢复"; |
| 72 |
const QString BUTTON_STR_DETELE = "删除"; |
| 73 |
const QString BUTTON_STR_DETELEALL = "全部删除"; |
| 74 |
const int RIGHT_VIEW_WIDTH = 1119; |
| 75 |
const int RIGHT_VIEW_IMPORT = 0; |
| 76 |
const int RIGHT_VIEW_THUMBNAIL_LIST = 1; |
| 77 |
const int RIGHT_VIEW_TRASH_LIST = 2; |
| 78 |
const int RIGHT_VIEW_FAVORITE_LIST = 3; |
| 79 |
const int RIGHT_VIEW_SEARCH = 4; |
| 80 |
const int RIGHT_VIEW_PHONE = 5; |
| 81 |
const int RIGHT_VIEW_TIMELINE_IMPORT = 6; |
| 82 |
|
| 83 |
static QMap<QString, const char *> i18nMap { |
| 84 |
{"data", "Data Disk"} |
| 85 |
}; |
| 86 |
const QString ddeI18nSym = QStringLiteral("_dde_"); |
| 87 |
|
| 88 |
static std::initializer_list<std::pair<QString, QString>> opticalmediakeys { |
| 89 |
{"optical", "Optical"}, |
| 90 |
{"optical_cd", "CD-ROM"}, |
| 91 |
{"optical_cd_r", "CD-R"}, |
| 92 |
{"optical_cd_rw", "CD-RW"}, |
| 93 |
{"optical_dvd", "DVD-ROM"}, |
| 94 |
{"optical_dvd_r", "DVD-R"}, |
| 95 |
{"optical_dvd_rw", "DVD-RW"}, |
| 96 |
{"optical_dvd_ram", "DVD-RAM"}, |
| 97 |
{"optical_dvd_plus_r", "DVD+R"}, |
| 98 |
{"optical_dvd_plus_rw", "DVD+RW"}, |
| 99 |
{"optical_dvd_plus_r_dl", "DVD+R/DL"}, |
| 100 |
{"optical_dvd_plus_rw_dl", "DVD+RW/DL"}, |
| 101 |
{"optical_bd", "BD-ROM"}, |
| 102 |
{"optical_bd_r", "BD-R"}, |
| 103 |
{"optical_bd_re", "BD-RE"}, |
| 104 |
{"optical_hddvd", "HD DVD-ROM"}, |
| 105 |
{"optical_hddvd_r", "HD DVD-R"}, |
| 106 |
{"optical_hddvd_rw", "HD DVD-RW"}, |
| 107 |
{"optical_mo", "MO"} |
| 108 |
}; |
| 109 |
static QVector<std::pair<QString, QString>> opticalmediakv(opticalmediakeys); |
| 110 |
static QMap<QString, QString> opticalmediamap(opticalmediakeys); |
| 111 |
|
| 112 |
} //namespace |
| 113 |
|
| 114 |
using namespace utils::common; |
| 115 |
Q_DECLARE_METATYPE(QExplicitlySharedDataPointer<DGioMount>) |
| 116 |
|
| 117 |
AlbumView::AlbumView() |
| 118 |
: m_iAlubmPicsNum(0), m_currentAlbum(COMMON_STR_RECENT_IMPORTED) |
| 119 |
, m_currentType(COMMON_STR_RECENT_IMPORTED), m_selPicNum(0), m_itemClicked(false) |
| 120 |
, m_pRightStackWidget(nullptr), m_pLeftListView(nullptr), m_pStatusBar(nullptr) |
| 121 |
, m_pRightWidget(nullptr), m_pRightPhoneThumbnailList(nullptr), m_pwidget(nullptr) |
| 122 |
, m_pRightTrashThumbnailList(nullptr) |
| 123 |
, pImportTimeLineWidget(nullptr), m_waitDeviceScandialog(nullptr) |
| 124 |
, m_pImportView(nullptr), m_pImpTimeLineView(nullptr) |
| 125 |
, m_pFavoriteTitle(nullptr), m_pFavoritePicTotal(nullptr), m_pPhoneTitle(nullptr) |
| 126 |
, m_pPhonePicTotal(nullptr), m_pSearchView(nullptr), m_vfsManager(nullptr) |
| 127 |
, m_diskManager(nullptr) |
| 128 |
, m_importByPhoneWidget(nullptr), m_importByPhoneComboBox(nullptr) |
| 129 |
, m_importAllByPhoneBtn(nullptr), m_importSelectByPhoneBtn(nullptr), m_mountPicNum(0) |
| 130 |
, pPhoneWidget(nullptr), phonetopwidget(nullptr) |
| 131 |
, isIgnore(true), m_waitDailog_timer(nullptr) |
| 132 |
{ |
| 133 |
m_iAlubmPicsNum = DBManager::instance()->getImgsCount(); |
| 134 |
m_vfsManager = new DGioVolumeManager; |
| 135 |
m_diskManager = new DDiskManager(this); |
| 136 |
m_diskManager->setWatchChanges(true); |
| 137 |
durlAndNameMap.clear(); |
| 138 |
m_allTrashInfos.clear(); |
| 139 |
|
| 140 |
iniWaitDiolag(); |
| 141 |
setAcceptDrops(true); |
| 142 |
|
| 143 |
initLeftView(); |
| 144 |
initRightView(); |
| 145 |
|
| 146 |
DWidget *leftwidget = new DWidget; |
| 147 |
leftwidget->setFixedWidth(180); |
| 148 |
|
| 149 |
QVBoxLayout *pvLayout = new QVBoxLayout(); |
| 150 |
pvLayout->setContentsMargins(0, 0, 0, 0); |
| 151 |
leftwidget->setLayout(pvLayout); |
| 152 |
pvLayout->addWidget(m_pLeftListView); |
| 153 |
|
| 154 |
QHBoxLayout *pLayout = new QHBoxLayout(); |
| 155 |
pLayout->setContentsMargins(0, 0, 0, 0); |
| 156 |
pLayout->setSpacing(0); |
| 157 |
pLayout->addWidget(leftwidget); |
| 158 |
pLayout->addWidget(m_pRightWidget); |
| 159 |
this->setLayout(pLayout); |
| 160 |
|
| 161 |
initConnections(); |
| 162 |
m_pwidget = new DWidget(this); |
| 163 |
m_pwidget->setAttribute(Qt::WA_TransparentForMouseEvents); |
| 164 |
|
| 165 |
m_spinner = new DSpinner(this); |
| 166 |
m_spinner->setFixedSize(40, 40); |
| 167 |
m_spinner->hide(); |
| 168 |
} |
| 169 |
|
| 170 |
AlbumView::~AlbumView() |
| 171 |
{ |
| 172 |
emit dApp->signalM->sigDevStop(""); |
| 173 |
m_customThumbnailList->stopLoadAndClear(); |
| 174 |
m_pRightPhoneThumbnailList->stopLoadAndClear(); |
| 175 |
m_pRightTrashThumbnailList->stopLoadAndClear(); |
| 176 |
m_favoriteThumbnailList->stopLoadAndClear(); |
| 177 |
|
| 178 |
ImageEngineImportObject::clearAndStopThread(); |
| 179 |
ImageMountGetPathsObject::clearAndStopThread(); |
| 180 |
ImageMountImportPathsObject::clearAndStopThread(); |
| 181 |
m_pImpTimeLineView->getFatherStatusBar(nullptr); |
| 182 |
// if (m_vfsManager) { |
| 183 |
// delete m_vfsManager; |
| 184 |
// m_vfsManager = nullptr; |
| 185 |
// } |
| 186 |
} |
| 187 |
|
| 188 |
bool AlbumView::imageImported(bool success) |
| 189 |
{ |
| 190 |
Q_UNUSED(success); |
| 191 |
emit dApp->signalM->closeWaitDialog(); |
| 192 |
return true; |
| 193 |
} |
| 194 |
|
| 195 |
QString sizeString(const QString &str) |
| 196 |
{ |
| 197 |
int begin_pos = str.indexOf('.'); |
| 198 |
|
| 199 |
if (begin_pos < 0) |
| 200 |
return str; |
| 201 |
|
| 202 |
QString size = str; |
| 203 |
|
| 204 |
while (size.count() - 1 > begin_pos) { |
| 205 |
if (!size.endsWith('0')) |
| 206 |
return size; |
| 207 |
|
| 208 |
size = size.left(size.count() - 1); |
| 209 |
} |
| 210 |
|
| 211 |
return size.left(size.count() - 1); |
| 212 |
} |
| 213 |
|
| 214 |
QString formatSize(qint64 num, bool withUnitVisible = true, int precision = 1, int forceUnit = -1, QStringList unitList = QStringList()) |
| 215 |
{ |
| 216 |
if (num < 0) { |
| 217 |
qWarning() << "Negative number passed to formatSize():" << num; |
| 218 |
num = 0; |
| 219 |
} |
| 220 |
|
| 221 |
bool isForceUnit = (forceUnit >= 0); |
| 222 |
QStringList list; |
| 223 |
qreal fileSize(num); |
| 224 |
|
| 225 |
if (unitList.size() == 0) { |
| 226 |
list << " B" << " KB" << " MB" << " GB" << " TB"; // should we use KiB since we use 1024 here? |
| 227 |
} else { |
| 228 |
list = unitList; |
| 229 |
} |
| 230 |
|
| 231 |
QStringListIterator i(list); |
| 232 |
QString unit = i.hasNext() ? i.next() : QStringLiteral(" B"); |
| 233 |
|
| 234 |
int index = 0; |
| 235 |
while (i.hasNext()) { |
| 236 |
if (fileSize < 1024 && !isForceUnit) { |
| 237 |
break; |
| 238 |
} |
| 239 |
|
| 240 |
if (isForceUnit && index == forceUnit) { |
| 241 |
break; |
| 242 |
} |
| 243 |
|
| 244 |
unit = i.next(); |
| 245 |
fileSize /= 1024; |
| 246 |
index++; |
| 247 |
} |
| 248 |
QString unitString = withUnitVisible ? unit : QString(); |
| 249 |
return QString("%1%2").arg(sizeString(QString::number(fileSize, 'f', precision)), unitString); |
| 250 |
} |
| 251 |
|
| 252 |
void AlbumView::initConnections() |
| 253 |
{ |
| 254 |
qRegisterMetaType<DBImgInfoList>("DBImgInfoList &"); |
| 255 |
// 添加重复照片提示 |
| 256 |
connect(dApp->signalM, &SignalManager::RepeatImportingTheSamePhotos, this, &AlbumView::onRepeatImportingTheSamePhotos); |
| 257 |
connect(m_pLeftListView, &LeftListView::itemClicked, this, &AlbumView::leftTabClicked); |
| 258 |
connect(m_pLeftListView, &LeftListView::sigLeftTabClicked, this, &AlbumView::leftTabClicked); |
| 259 |
connect(m_pLeftListView, &LeftListView::updateCurrentItemType, this, &AlbumView::setCurrentItemType); |
| 260 |
connect(dApp->signalM, &SignalManager::sigCreateNewAlbumFromDialog, this, &AlbumView::onCreateNewAlbumFromDialog); |
| 261 |
#if 1 |
| 262 |
connect(dApp->signalM, &SignalManager::sigCreateNewAlbumFrom, this, &AlbumView::onCreateNewAlbumFrom); |
| 263 |
connect(m_customThumbnailList, &ThumbnailListView::sigMouseMove, this, &AlbumView::ongMouseMove); |
| 264 |
connect(m_favoriteThumbnailList, &ThumbnailListView::sigMouseMove, this, &AlbumView::ongMouseMove); |
| 265 |
// 解决最近删除页面ctrl+all选择所有图片,恢复按钮为灰色的问题 |
| 266 |
connect(m_pRightTrashThumbnailList, &ThumbnailListView::sigSelectAll, this, &AlbumView::onSelectAll); |
| 267 |
#endif |
| 268 |
connect(dApp->signalM, &SignalManager::sigLoadOnePhoto, this, &AlbumView::updateRightView); |
| 269 |
connect(dApp->signalM, &SignalManager::imagesInserted, this, &AlbumView::updateRightView); |
| 270 |
//todo |
| 271 |
connect(dApp->signalM, &SignalManager::imagesRemoved, this, &AlbumView::updateRightView); |
| 272 |
connect(dApp->signalM, &SignalManager::insertedIntoAlbum, this, &AlbumView::onInsertedIntoAlbum); |
| 273 |
connect(dApp->signalM, &SignalManager::removedFromAlbum, this, &AlbumView::updateAlbumView); |
| 274 |
//最近删除中数据有变化,刷新缓存 |
| 275 |
connect(dApp->signalM, &SignalManager::imagesTrashInserted, this, &AlbumView::onTrashInfosChanged); |
| 276 |
connect(dApp->signalM, &SignalManager::imagesTrashRemoved, this, &AlbumView::onTrashInfosChanged); |
| 277 |
connect(m_customThumbnailList, &ThumbnailListView::openImage, this, &AlbumView::onOpenImageCustom); |
| 278 |
connect(m_favoriteThumbnailList, &ThumbnailListView::openImage, this, &AlbumView::onOpenImageFav); |
| 279 |
connect(m_pLeftListView, &LeftListView::sigSlideShow, this, &AlbumView::onSlideShowCustom); |
| 280 |
connect(m_customThumbnailList, &ThumbnailListView::sigSlideShow, this, &AlbumView::onSlideShowCustom); |
| 281 |
connect(m_favoriteThumbnailList, &ThumbnailListView::sigSlideShow, this, &AlbumView::onSlideShowFav); |
| 282 |
connect(dApp->signalM, &SignalManager::sigUpdataAlbumRightTitle, this, &AlbumView::onUpdataAlbumRightTitle); |
| 283 |
connect(dApp->signalM, &SignalManager::sigUpdateImageLoader, this, &AlbumView::updateRightView); |
| 284 |
connect(dApp->signalM, &SignalManager::sigUpdateTrashImageLoader, this, &AlbumView::updateRightView); |
| 285 |
#ifndef tablet_PC |
| 286 |
connect(m_vfsManager, &DGioVolumeManager::mountAdded, this, &AlbumView::onVfsMountChangedAdd); |
| 287 |
connect(m_vfsManager, &DGioVolumeManager::mountRemoved, this, &AlbumView::onVfsMountChangedRemove); |
| 288 |
connect(m_vfsManager, &DGioVolumeManager::volumeAdded, [](QExplicitlySharedDataPointer<DGioVolume> vol) { |
| 289 |
if (vol->volumeMonitorName().contains(QRegularExpression("(MTP|GPhoto2|Afc)$"))) { |
| 290 |
vol->mount(); |
| 291 |
} |
| 292 |
}); |
| 293 |
#endif |
| 294 |
connect(m_diskManager, &DDiskManager::fileSystemAdded, this, &AlbumView::onFileSystemAdded); |
| 295 |
connect(m_diskManager, &DDiskManager::blockDeviceAdded, this, &AlbumView::onBlockDeviceAdded); |
| 296 |
connect(m_importAllByPhoneBtn, &DPushButton::clicked, this, &AlbumView::importAllBtnClicked); |
| 297 |
connect(m_importSelectByPhoneBtn, &DPushButton::clicked, this, &AlbumView::importSelectBtnClicked); |
| 298 |
connect(m_pStatusBar->m_pSlider, &DSlider::valueChanged, dApp->signalM, &SignalManager::emitSliderValueChg); |
| 299 |
connect(m_pLeftListView->m_pCustomizeListView, &LeftListWidget::signalDropEvent, this, &AlbumView::onLeftListDropEvent); |
| 300 |
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &AlbumView::onThemeTypeChanged); |
| 301 |
#if 1 |
| 302 |
connect(m_pRightPhoneThumbnailList, &ThumbnailListView::customContextMenuRequested, this, &AlbumView::onRightPhoneCustomContextMenuRequested); |
| 303 |
connect(m_pRightPhoneThumbnailList, &ThumbnailListView::sigMouseRelease, this, &AlbumView::onRightPhoneThumbnailListMouseRelease); |
| 304 |
connect(m_pImpTimeLineView, &ImportTimeLineView::sigUpdatePicNum, this, &AlbumView::updatePicNum); |
| 305 |
//筛选显示,当先列表中内容为无结果 |
| 306 |
connect(m_pImpTimeLineView, &ImportTimeLineView::sigNoPicOrNoVideo, this, &AlbumView::slotNoPicOrNoVideo); |
| 307 |
//缩略图选中项发生变化 |
| 308 |
//已导入 |
| 309 |
connect(m_pImpTimeLineView->getListView()->selectionModel(), &QItemSelectionModel::selectionChanged, |
| 310 |
this, &AlbumView::sltSelectionChanged); |
| 311 |
//自定义相册 |
| 312 |
connect(m_customThumbnailList->selectionModel(), &QItemSelectionModel::selectionChanged, |
| 313 |
this, &AlbumView::sltSelectionChanged); |
| 314 |
//我的收藏 |
| 315 |
connect(m_favoriteThumbnailList->selectionModel(), &QItemSelectionModel::selectionChanged, |
| 316 |
this, &AlbumView::sltSelectionChanged); |
| 317 |
//设备 |
| 318 |
connect(m_pRightPhoneThumbnailList->selectionModel(), &QItemSelectionModel::selectionChanged, |
| 319 |
this, &AlbumView::sltSelectionChanged); |
| 320 |
//最近删除 |
| 321 |
connect(m_pRightTrashThumbnailList->selectionModel(), &QItemSelectionModel::selectionChanged, |
| 322 |
this, &AlbumView::sltSelectionChanged); |
| 323 |
#endif |
| 324 |
connect(m_pRightTrashThumbnailList, &ThumbnailListView::trashRecovery, this, &AlbumView::onTrashRecoveryBtnClicked); |
| 325 |
connect(m_pImportView->m_pImportBtn, &DPushButton::clicked, this, &AlbumView::onImportViewImportBtnClicked); |
| 326 |
connect(dApp->signalM, &SignalManager::sigImportFailedToView, this, &AlbumView::onImportFailedToView); |
| 327 |
connect(m_importByPhoneComboBox, &DComboBox::currentTextChanged, this, &AlbumView::importComboBoxChange); |
| 328 |
connect(dApp->signalM, &SignalManager::sigShortcutKeyDelete, this, &AlbumView::onKeyDelete); |
| 329 |
connect(dApp->signalM, &SignalManager::sigShortcutKeyF2, this, &AlbumView::onKeyF2); |
| 330 |
//2020年03月26日15:12:23 |
| 331 |
connect(dApp->signalM, &SignalManager::waitDevicescan, this, &AlbumView::importDialog); |
| 332 |
connect(m_waitDailog_timer, &QTimer::timeout, this, &AlbumView::onWaitDailogTimeout); |
| 333 |
//在外部绑定内部按钮事件 |
| 334 |
connect(m_waitDeviceScandialog->m_closeDeviceScan, &DPushButton::clicked, this, &AlbumView::onWaitDialogClose); |
| 335 |
connect(m_waitDeviceScandialog->m_ignoreDeviceScan, &DPushButton::clicked, this, &AlbumView::onWaitDialogIgnore); |
| 336 |
connect(m_pLeftListView->m_pMountListWidget, &DListWidget::clicked, this, &AlbumView::onLeftListViewMountListWidgetClicked); |
| 337 |
connect(m_waitDeviceScandialog, &Waitdevicedialog::closed, this, &AlbumView::onWaitDialogClose); |
| 338 |
|
| 339 |
connect(ImageEngineApi::instance(), &ImageEngineApi::sigMountFileListLoadReady, this, &AlbumView::sltLoadMountFileList, Qt::QueuedConnection); |
| 340 |
} |
| 341 |
|
| 342 |
void AlbumView::initLeftView() |
| 343 |
{ |
| 344 |
m_pLeftListView = new LeftListView(this); |
| 345 |
m_pLeftListView->setFocusPolicy(Qt::NoFocus); |
| 346 |
m_pLeftListView->m_pPhotoLibListView->setCurrentRow(0); |
| 347 |
|
| 348 |
//init externalDevice |
| 349 |
#ifndef tablet_PC |
| 350 |
m_mounts = getVfsMountList(); |
| 351 |
initExternalDevice(); |
| 352 |
updateDeviceLeftList(); |
| 353 |
#endif |
| 354 |
} |
| 355 |
|
| 356 |
void AlbumView::onCreateNewAlbumFromDialog(const QString &newalbumname) |
| 357 |
{ |
| 358 |
qDebug() << __FUNCTION__ << "---111111111111111"; |
| 359 |
int index = m_pLeftListView->m_pCustomizeListView->count(); |
| 360 |
QString albumName = newalbumname; |
| 361 |
QStringList allAlbumNames = DBManager::instance()->getAllAlbumNames(); |
| 362 |
bool isExsit = false; |
| 363 |
for (int i = 0; i < m_pLeftListView->m_pCustomizeListView->count(); i++) { |
| 364 |
QListWidgetItem *item = m_pLeftListView->m_pCustomizeListView->item(i); |
| 365 |
AlbumLeftTabItem *pTabItem = dynamic_cast<AlbumLeftTabItem *>(m_pLeftListView->m_pCustomizeListView->itemWidget(item)); |
| 366 |
if (pTabItem) { |
| 367 |
QString str = pTabItem->m_albumNameStr; |
| 368 |
if (str == albumName) { |
| 369 |
isExsit = true; |
| 370 |
m_pLeftListView->m_pCustomizeListView->setCurrentRow(i); |
| 371 |
break; |
| 372 |
} |
| 373 |
} |
| 374 |
} |
| 375 |
|
| 376 |
if (!isExsit) { |
| 377 |
QListWidgetItem *pListWidgetItem = new QListWidgetItem(m_pLeftListView->m_pCustomizeListView, ablumType);//hj add data to listwidgetitem to Distinguish item's type |
| 378 |
m_pLeftListView->m_pCustomizeListView->insertItem(index, pListWidgetItem); |
| 379 |
pListWidgetItem->setSizeHint(QSize(LEFT_VIEW_LISTITEM_WIDTH, LEFT_VIEW_LISTITEM_HEIGHT)); |
| 380 |
AlbumLeftTabItem *pAlbumLeftTabItem = new AlbumLeftTabItem(albumName, COMMON_STR_CREATEALBUM); |
| 381 |
m_pLeftListView->m_pCustomizeListView->setItemWidget(pListWidgetItem, pAlbumLeftTabItem); |
| 382 |
m_pLeftListView->m_pCustomizeListView->setCurrentRow(index); |
| 383 |
} |
| 384 |
|
| 385 |
m_pLeftListView->onUpdateLeftListview(); |
| 386 |
//清除其他已选中的项 |
| 387 |
QModelIndex index2; |
| 388 |
emit m_pLeftListView->m_pCustomizeListView->pressed(index2); |
| 389 |
} |
| 390 |
|
| 391 |
void AlbumView::onCreateNewAlbumFrom(const QString &albumname) |
| 392 |
{ |
| 393 |
int index = m_pLeftListView->m_pCustomizeListView->count(); |
| 394 |
QListWidgetItem *pListWidgetItem = new QListWidgetItem(); |
| 395 |
pListWidgetItem->setSizeHint(QSize(LEFT_VIEW_LISTITEM_WIDTH, LEFT_VIEW_LISTITEM_HEIGHT)); |
| 396 |
QString albumName = albumname; |
| 397 |
AlbumLeftTabItem *pAlbumLeftTabItem = new AlbumLeftTabItem(albumName); |
| 398 |
m_pLeftListView->m_pCustomizeListView->insertItem(index, pListWidgetItem); |
| 399 |
m_pLeftListView->m_pCustomizeListView->setItemWidget(pListWidgetItem, pAlbumLeftTabItem); |
| 400 |
m_pLeftListView->onUpdateLeftListview(); |
| 401 |
} |
| 402 |
|
| 403 |
void AlbumView::iniWaitDiolag() |
| 404 |
{ |
| 405 |
m_waitDeviceScandialog = new Waitdevicedialog(this); |
| 406 |
m_waitDailog_timer = new QTimer(this); |
| 407 |
m_waitDeviceScandialog->m_closeDeviceScan = new DPushButton(tr("Cancel")); |
| 408 |
m_waitDeviceScandialog->m_ignoreDeviceScan = new DPushButton(tr("Ignore")); |
| 409 |
m_waitDeviceScandialog->waitTips = new DLabel(tr("Loading...")); |
| 410 |
m_waitDeviceScandialog->iniwaitdialog(); |
| 411 |
if (!m_waitDeviceScandialog) { |
| 412 |
return; |
| 413 |
} |
| 414 |
m_waitDeviceScandialog->setFixedSize(QSize(422, 183)); |
| 415 |
m_waitDeviceScandialog->move(749, 414); |
| 416 |
} |
| 417 |
void AlbumView::initRightView() |
| 418 |
{ |
| 419 |
m_pRightStackWidget = new DStackedWidget(); |
| 420 |
m_pRightWidget = new DWidget(); |
| 421 |
|
| 422 |
// Import View |
| 423 |
m_pImportView = new ImportView(); |
| 424 |
QList<QLabel *> labelList = m_pImportView->findChildren<QLabel *>(); |
| 425 |
labelList[1]->setFixedHeight(22); |
| 426 |
labelList[1]->setText(tr("Or drag photos here")); |
| 427 |
|
| 428 |
//初始化自定义相册列表 |
| 429 |
initCustomAlbumWidget(); |
| 430 |
//初始化最近删除列表 |
| 431 |
initTrashWidget(); |
| 432 |
//初始化收藏列表 |
| 433 |
initFavoriteWidget(); |
| 434 |
//Search View |
| 435 |
m_pSearchView = new SearchView; |
| 436 |
//初始化设备列表 |
| 437 |
initPhoneWidget(); |
| 438 |
|
| 439 |
//add start 3975 |
| 440 |
m_pStatusBar = new StatusBar(this); |
| 441 |
m_pStatusBar->raise(); |
| 442 |
m_pStatusBar->setFixedWidth(this->width() - m_pLeftListView->width()); |
| 443 |
m_pStatusBar->move(m_pLeftListView->width(), this->height() - m_pStatusBar->height()); |
| 444 |
|
| 445 |
pImportTimeLineWidget = new DWidget(); |
| 446 |
pImportTimeLineWidget->setBackgroundRole(DPalette::Window); |
| 447 |
QVBoxLayout *importLineLayout = new QVBoxLayout(pImportTimeLineWidget); |
| 448 |
importLineLayout->setContentsMargins(0, 0, 0, 0); |
| 449 |
pImportTimeLineWidget->setLayout(importLineLayout); |
| 450 |
|
| 451 |
m_pImpTimeLineView = new ImportTimeLineView(m_pRightStackWidget); |
| 452 |
m_pImpTimeLineView->setContentsMargins(0, 0, 0, 0); |
| 453 |
m_pImpTimeLineView->getFatherStatusBar(m_pStatusBar->m_pSlider); |
| 454 |
importLineLayout->addWidget(m_pImpTimeLineView); |
| 455 |
//add end 3975 |
| 456 |
// Add View |
| 457 |
m_pRightStackWidget->addWidget(m_pImportView); // 空白导入界面 |
| 458 |
m_pRightStackWidget->addWidget(m_pCustomAlbumWidget); // 自定义相册界面 |
| 459 |
m_pRightStackWidget->addWidget(m_pTrashWidget); // 最近删除 |
| 460 |
m_pRightStackWidget->addWidget(m_pFavoriteWidget); // 我的收藏 |
| 461 |
m_pRightStackWidget->addWidget(m_pSearchView); // 搜索界面页面 |
| 462 |
m_pRightStackWidget->addWidget(pPhoneWidget); // 设备界面 |
| 463 |
m_pRightStackWidget->addWidget(pImportTimeLineWidget); // 已导入界面 |
| 464 |
|
| 465 |
// Statusbar |
| 466 |
QVBoxLayout *pVBoxLayout = new QVBoxLayout(); |
| 467 |
pVBoxLayout->setContentsMargins(0, 0, 0, m_pStatusBar->height()); |
| 468 |
pVBoxLayout->addWidget(m_pRightStackWidget); |
| 469 |
m_pRightWidget->setLayout(pVBoxLayout); |
| 470 |
|
| 471 |
if (0 < DBManager::instance()->getImgsCount()) { |
| 472 |
m_customThumbnailList->setFrameShape(DTableView::NoFrame); |
| 473 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_TIMELINE_IMPORT); |
| 474 |
m_pStatusBar->show(); |
| 475 |
} else { |
| 476 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_IMPORT); |
| 477 |
m_pStatusBar->setVisible(false); |
| 478 |
} |
| 479 |
} |
| 480 |
//初始化最近删除列表 |
| 481 |
void AlbumView::initTrashWidget() |
| 482 |
{ |
| 483 |
//最近删除页 |
| 484 |
m_pTrashWidget = new DWidget(); |
| 485 |
DPalette palcolor3 = DApplicationHelper::instance()->palette(m_pTrashWidget); |
| 486 |
palcolor3.setBrush(DPalette::Base, palcolor3.color(DPalette::Window)); |
| 487 |
m_pTrashWidget->setPalette(palcolor3); |
| 488 |
QVBoxLayout *p_Trash = new QVBoxLayout(); |
| 489 |
//左侧距离分界线20px,8+缩略图spacing+缩略图边框 |
| 490 |
p_Trash->setContentsMargins(8, 0, 0, 0); |
| 491 |
m_pTrashWidget->setLayout(p_Trash); |
| 492 |
//最近删除列表 |
| 493 |
m_pRightTrashThumbnailList = new ThumbnailListView(ThumbnailDelegate::AlbumViewTrashType, COMMON_STR_TRASH); |
| 494 |
m_pRightTrashThumbnailList->setFrameShape(DTableView::NoFrame); |
| 495 |
m_pRightTrashThumbnailList->setObjectName("RightTrashThumbnail"); |
| 496 |
m_pRightTrashThumbnailList->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); |
| 497 |
m_pRightTrashThumbnailList->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
| 498 |
m_pRightTrashThumbnailList->setContentsMargins(0, 0, 0, 0); |
| 499 |
p_Trash->addWidget(m_pRightTrashThumbnailList); |
| 500 |
|
| 501 |
//初始化筛选无结果窗口 |
| 502 |
m_trashNoResultWidget = new NoResultWidget(this); |
| 503 |
p_Trash->addWidget(m_trashNoResultWidget); |
| 504 |
m_trashNoResultWidget->setVisible(false); |
| 505 |
|
| 506 |
//筛选显示,当先列表中内容为无结果 |
| 507 |
connect(m_pRightTrashThumbnailList, &ThumbnailListView::sigNoPicOrNoVideo, this, &AlbumView::slotNoPicOrNoVideo); |
| 508 |
//重新更改了最近删除的顶部布局 2020-4-17 xiaolong |
| 509 |
QHBoxLayout *Layout1 = new QHBoxLayout(); |
| 510 |
Layout1->setContentsMargins(20, 0, 19, 0); |
| 511 |
|
| 512 |
m_TrashDescritionLab = new DLabel(); |
| 513 |
DFontSizeManager::instance()->bind(m_TrashDescritionLab, DFontSizeManager::T6, QFont::Medium); |
| 514 |
QPalette pal = DApplicationHelper::instance()->palette(m_TrashDescritionLab); |
| 515 |
QColor color_BT = pal.color(DPalette::BrightText); |
| 516 |
DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType(); |
| 517 |
if (themeType == DGuiApplicationHelper::LightType) { |
| 518 |
color_BT.setAlphaF(0.5); |
| 519 |
pal.setBrush(DPalette::Text, color_BT); |
| 520 |
} else if (themeType == DGuiApplicationHelper::DarkType) { |
| 521 |
color_BT.setAlphaF(0.75); |
| 522 |
pal.setBrush(DPalette::Text, color_BT); |
| 523 |
} |
| 524 |
m_TrashDescritionLab->setForegroundRole(DPalette::Text); |
| 525 |
m_TrashDescritionLab->setPalette(pal); |
| 526 |
m_TrashDescritionLab->setText(tr("The files will be permanently deleted after the days shown on it")); |
| 527 |
Layout1->addWidget(m_TrashDescritionLab); |
| 528 |
|
| 529 |
m_trashBatchOperateWidget = new BatchOperateWidget(m_pRightTrashThumbnailList, BatchOperateWidget::AlbumViewTrashType, m_pTrashWidget); |
| 530 |
Layout1->addStretch(100); |
| 531 |
// hlayoutDateLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); |
| 532 |
// hlayoutDateLabel->setContentsMargins(0, 0, 19, 0); |
| 533 |
Layout1->addWidget(m_trashBatchOperateWidget); |
| 534 |
|
| 535 |
//最近删除标题,不使用布局 |
| 536 |
m_TrashTitleLab = new DLabel(m_pTrashWidget); |
| 537 |
DFontSizeManager::instance()->bind(m_TrashTitleLab, DFontSizeManager::T3, QFont::DemiBold); |
| 538 |
m_TrashTitleLab->setFixedHeight(trash_title_height); |
| 539 |
m_TrashTitleLab->setForegroundRole(DPalette::TextTitle); |
| 540 |
m_TrashTitleLab->setText(tr("Trash")); |
| 541 |
m_TrashTitleLab->setFixedWidth(150);//BUG#93470 手动调大控件长度 |
| 542 |
|
| 543 |
m_TrashTitleWidget = new DWidget(m_pTrashWidget); |
| 544 |
m_TrashTitleWidget->setLayout(Layout1); |
| 545 |
DPalette ppal_light3 = DApplicationHelper::instance()->palette(m_TrashTitleWidget); |
| 546 |
ppal_light3.setBrush(DPalette::Background, ppal_light3.color(DPalette::Base)); |
| 547 |
QGraphicsOpacityEffect *opacityEffect_light3 = new QGraphicsOpacityEffect; |
| 548 |
opacityEffect_light3->setOpacity(0.95); |
| 549 |
m_TrashTitleWidget->setPalette(ppal_light3); |
| 550 |
m_TrashTitleWidget->setGraphicsEffect(opacityEffect_light3); |
| 551 |
m_TrashTitleWidget->setAutoFillBackground(true); |
| 552 |
m_TrashTitleWidget->move(0, 0); |
| 553 |
m_TrashTitleWidget->setFixedSize(this->width() - LEFT_VIEW_WIDTH, trash_title_height); |
| 554 |
} |
| 555 |
//初始化自定义相册列表 |
| 556 |
void AlbumView::initCustomAlbumWidget() |
| 557 |
{ |
| 558 |
m_pCustomAlbumWidget = new DWidget(); //add 3975 |
| 559 |
DPalette palcolor = DApplicationHelper::instance()->palette(m_pCustomAlbumWidget); |
| 560 |
palcolor.setBrush(DPalette::Base, palcolor.color(DPalette::Window)); |
| 561 |
m_pCustomAlbumWidget->setPalette(palcolor); |
| 562 |
QVBoxLayout *p_all = new QVBoxLayout(); |
| 563 |
p_all->setContentsMargins(8, 0, 0, 0); |
| 564 |
m_pCustomAlbumWidget->setLayout(p_all); |
| 565 |
|
| 566 |
//自定义相册标题的外层布局 |
| 567 |
QHBoxLayout *pHLayout = new QHBoxLayout(); |
| 568 |
pHLayout->setContentsMargins(20, 0, 19, 0); |
| 569 |
|
| 570 |
m_customAlbumTitleLabel = new DLabel(m_pCustomAlbumWidget); |
| 571 |
DFontSizeManager::instance()->bind(m_customAlbumTitleLabel, DFontSizeManager::T3, QFont::DemiBold); |
| 572 |
m_customAlbumTitleLabel->setForegroundRole(DPalette::TextTitle); |
| 573 |
m_customAlbumTitleLabel->setFixedHeight(custom_title_height); |
| 574 |
m_customAlbumTitleLabel->setFixedWidth(525); |
| 575 |
m_customAlbumTitleLabel->setAttribute(Qt::WA_TransparentForMouseEvents, true); |
| 576 |
m_customAlbumTitleLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); |
| 577 |
// m_customAlbumTitleLabel->move(m_pCustomAlbumWidget->width() / 2 - m_customAlbumTitleLabel->width() / 2, 0); |
| 578 |
|
| 579 |
m_pRightPicTotal = new DLabel(); |
| 580 |
m_pRightPicTotal->setFocusPolicy(Qt::NoFocus); |
| 581 |
m_pRightPicTotal->setFixedHeight(20); |
| 582 |
m_pRightPicTotal->setAttribute(Qt::WA_TransparentForMouseEvents, true); |
| 583 |
DFontSizeManager::instance()->bind(m_pRightPicTotal, DFontSizeManager::T6, QFont::Medium); |
| 584 |
DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType(); |
| 585 |
DPalette pal = DApplicationHelper::instance()->palette(m_pRightPicTotal); |
| 586 |
QColor color_BT = pal.color(DPalette::BrightText); |
| 587 |
if (themeType == DGuiApplicationHelper::LightType) { |
| 588 |
color_BT.setAlphaF(0.5); |
| 589 |
pal.setBrush(DPalette::Text, color_BT); |
| 590 |
} else if (themeType == DGuiApplicationHelper::DarkType) { |
| 591 |
color_BT.setAlphaF(0.75); |
| 592 |
pal.setBrush(DPalette::Text, color_BT); |
| 593 |
} |
| 594 |
m_pRightPicTotal->setForegroundRole(DPalette::Text); |
| 595 |
m_pRightPicTotal->setPalette(pal); |
| 596 |
// 调整布局,适配维语 |
| 597 |
pHLayout->addWidget(m_pRightPicTotal); |
| 598 |
pHLayout->addStretch(); |
| 599 |
|
| 600 |
m_customThumbnailList = new ThumbnailListView(ThumbnailDelegate::AlbumViewCustomType, COMMON_STR_CUSTOM); |
| 601 |
//筛选显示,当先列表中内容为无结果 |
| 602 |
connect(m_customThumbnailList, &ThumbnailListView::sigNoPicOrNoVideo, this, &AlbumView::slotNoPicOrNoVideo); |
| 603 |
m_customThumbnailList->setFrameShape(DTableView::NoFrame); |
| 604 |
m_customThumbnailList->setViewportMargins(0, 0, 0, 0); |
| 605 |
m_customThumbnailList->setContentsMargins(0, 0, 0, 0); |
| 606 |
p_all->addWidget(m_customThumbnailList); |
| 607 |
//初始化筛选无结果窗口 |
| 608 |
m_customNoResultWidget = new NoResultWidget(this); |
| 609 |
p_all->addWidget(m_customNoResultWidget); |
| 610 |
m_customNoResultWidget->setVisible(false); |
| 611 |
|
| 612 |
m_customBatchOperateWidget = new BatchOperateWidget(m_customThumbnailList, BatchOperateWidget::NullType, m_customAlbumTitle); |
| 613 |
pHLayout->addStretch(100); |
| 614 |
// hlayoutDateLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); |
| 615 |
// hlayoutDateLabel->setContentsMargins(0, 0, 19, 0); |
| 616 |
pHLayout->addWidget(m_customBatchOperateWidget); |
| 617 |
|
| 618 |
|
| 619 |
m_customAlbumTitle = new DWidget(m_pCustomAlbumWidget); |
| 620 |
m_customAlbumTitle->setFocusPolicy(Qt::ClickFocus); |
| 621 |
m_customAlbumTitle->setLayout(pHLayout); |
| 622 |
|
| 623 |
DPalette ppal_light = DApplicationHelper::instance()->palette(m_customAlbumTitle); |
| 624 |
ppal_light.setBrush(DPalette::Background, ppal_light.color(DPalette::Base)); |
| 625 |
QGraphicsOpacityEffect *opacityEffect_light = new QGraphicsOpacityEffect; |
| 626 |
opacityEffect_light->setOpacity(0.95); |
| 627 |
m_customAlbumTitle->setPalette(ppal_light); |
| 628 |
m_customAlbumTitle->setGraphicsEffect(opacityEffect_light); |
| 629 |
m_customAlbumTitle->setAutoFillBackground(true); |
| 630 |
m_customAlbumTitle->move(0, 0); |
| 631 |
m_customAlbumTitle->setFixedSize(this->width() - LEFT_VIEW_WIDTH, custom_title_height); |
| 632 |
} |
| 633 |
//初始化收藏列表 |
| 634 |
void AlbumView::initFavoriteWidget() |
| 635 |
{ |
| 636 |
//add end 3975 |
| 637 |
// Favorite View |
| 638 |
m_pFavoriteWidget = new DWidget(); //add 3975 |
| 639 |
m_pFavoriteWidget->setFocusPolicy(Qt::ClickFocus); |
| 640 |
//add start 3975 |
| 641 |
DPalette palcolor2 = DApplicationHelper::instance()->palette(m_pFavoriteWidget); |
| 642 |
palcolor2.setBrush(DPalette::Base, palcolor2.color(DPalette::Window)); |
| 643 |
m_pFavoriteWidget->setPalette(palcolor2); |
| 644 |
QVBoxLayout *p_Favorite = new QVBoxLayout(); |
| 645 |
//左侧距离分界线20px,8+缩略图spacing+缩略图边框 |
| 646 |
p_Favorite->setContentsMargins(8, 0, 0, 0); |
| 647 |
m_pFavoriteWidget->setLayout(p_Favorite); |
| 648 |
|
| 649 |
m_favoriteThumbnailList = new ThumbnailListView(ThumbnailDelegate::AlbumViewFavoriteType, COMMON_STR_FAVORITES); |
| 650 |
//筛选显示,当先列表中内容为无结果 |
| 651 |
connect(m_favoriteThumbnailList, &ThumbnailListView::sigNoPicOrNoVideo, this, &AlbumView::slotNoPicOrNoVideo); |
| 652 |
m_favoriteThumbnailList->setFrameShape(DTableView::NoFrame); |
| 653 |
m_favoriteThumbnailList->setObjectName("RightFavoriteThumbnail"); |
| 654 |
m_favoriteThumbnailList->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); |
| 655 |
m_favoriteThumbnailList->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
| 656 |
m_favoriteThumbnailList->setContentsMargins(0, 0, 0, 0); |
| 657 |
p_Favorite->addWidget(m_favoriteThumbnailList); |
| 658 |
//初始化筛选无结果窗口 |
| 659 |
m_favoriteNoResultWidget = new NoResultWidget(this); |
| 660 |
p_Favorite->addWidget(m_favoriteNoResultWidget); |
| 661 |
m_favoriteNoResultWidget->setVisible(false); |
| 662 |
|
| 663 |
//我的收藏悬浮标题 |
| 664 |
QHBoxLayout *lNumberLayout = new QHBoxLayout(); |
| 665 |
lNumberLayout->setContentsMargins(20, 0, 19, 0); |
| 666 |
|
| 667 |
m_pFavoriteTitle = new DLabel(m_pFavoriteWidget); |
| 668 |
m_pFavoriteTitle->setFixedHeight(favorite_title_height); |
| 669 |
DFontSizeManager::instance()->bind(m_pFavoriteTitle, DFontSizeManager::T3, QFont::DemiBold); |
| 670 |
m_pFavoriteTitle->setForegroundRole(DPalette::TextTitle); |
| 671 |
m_pFavoriteTitle->setText(tr("Favorites")); |
| 672 |
m_pFavoriteTitle->setFixedWidth(150); //BUG#93470 手动调大控件长度 |
| 673 |
|
| 674 |
m_pFavoritePicTotal = new DLabel(); |
| 675 |
m_pFavoritePicTotal->setFixedHeight(20); |
| 676 |
DFontSizeManager::instance()->bind(m_pFavoritePicTotal, DFontSizeManager::T6, QFont::Medium); |
| 677 |
m_pFavoritePicTotal->setForegroundRole(DPalette::TextTips); |
| 678 |
|
| 679 |
QPalette pal = DApplicationHelper::instance()->palette(m_pFavoritePicTotal); |
| 680 |
QColor color_BT = pal.color(DPalette::BrightText); |
| 681 |
DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType(); |
| 682 |
if (themeType == DGuiApplicationHelper::LightType) { |
| 683 |
color_BT.setAlphaF(0.5); |
| 684 |
pal.setBrush(DPalette::Text, color_BT); |
| 685 |
} else if (themeType == DGuiApplicationHelper::DarkType) { |
| 686 |
color_BT.setAlphaF(0.75); |
| 687 |
pal.setBrush(DPalette::Text, color_BT); |
| 688 |
} |
| 689 |
m_pFavoritePicTotal->setForegroundRole(DPalette::Text); |
| 690 |
m_pFavoritePicTotal->setPalette(pal); |
| 691 |
lNumberLayout->addWidget(m_pFavoritePicTotal); |
| 692 |
|
| 693 |
m_FavoriteTitleWidget = new DWidget(m_pFavoriteWidget); |
| 694 |
m_FavoriteTitleWidget->setFocusPolicy(Qt::NoFocus); |
| 695 |
m_FavoriteTitleWidget->setLayout(lNumberLayout); |
| 696 |
|
| 697 |
m_favoriteBatchOperateWidget = new BatchOperateWidget(m_favoriteThumbnailList, BatchOperateWidget::NullType, m_FavoriteTitleWidget); |
| 698 |
lNumberLayout->addStretch(100); |
| 699 |
lNumberLayout->addWidget(m_favoriteBatchOperateWidget, 0, Qt::AlignRight | Qt::AlignVCenter); |
| 700 |
|
| 701 |
DPalette ppal_light2 = DApplicationHelper::instance()->palette(m_FavoriteTitleWidget); |
| 702 |
ppal_light2.setBrush(DPalette::Background, ppal_light2.color(DPalette::Base)); |
| 703 |
QGraphicsOpacityEffect *opacityEffect_light2 = new QGraphicsOpacityEffect; |
| 704 |
opacityEffect_light2->setOpacity(0.95); |
| 705 |
m_FavoriteTitleWidget->setPalette(ppal_light2); |
| 706 |
m_FavoriteTitleWidget->setGraphicsEffect(opacityEffect_light2); |
| 707 |
m_FavoriteTitleWidget->setAutoFillBackground(true); |
| 708 |
m_FavoriteTitleWidget->move(0, 0); |
| 709 |
m_FavoriteTitleWidget->setFixedSize(this->width() - m_pLeftListView->width() - 20, favorite_title_height); |
| 710 |
//add end 3975 |
| 711 |
} |
| 712 |
//初始化设备列表 |
| 713 |
void AlbumView::initPhoneWidget() |
| 714 |
{ |
| 715 |
// Phone View |
| 716 |
pPhoneWidget = new DWidget(); |
| 717 |
pPhoneWidget->setBackgroundRole(DPalette::Window); |
| 718 |
QHBoxLayout *thumbnailListLayout = new QHBoxLayout(pPhoneWidget); |
| 719 |
thumbnailListLayout->setContentsMargins(8, 0, 0, 0); |
| 720 |
|
| 721 |
m_pPhoneTitle = new DLabel(); |
| 722 |
m_pPhoneTitle->setFixedHeight(36); |
| 723 |
if (QLocale::system().language() == QLocale::Tibetan) { |
| 724 |
m_pPhoneTitle->setFixedHeight(36 + 25); |
| 725 |
} |
| 726 |
DFontSizeManager::instance()->bind(m_pPhoneTitle, DFontSizeManager::T3, QFont::DemiBold); |
| 727 |
m_pPhoneTitle->setForegroundRole(DPalette::TextTitle); |
| 728 |
|
| 729 |
//给m_pPhonePicTotal布局,外接设备界面 |
| 730 |
QHBoxLayout *PhonePicTotalLayout = new QHBoxLayout(); |
| 731 |
PhonePicTotalLayout->setContentsMargins(0, 0, 0, 0); |
| 732 |
|
| 733 |
m_pPhonePicTotal = new DLabel(); |
| 734 |
m_pPhonePicTotal->setFixedHeight(20); |
| 735 |
if (QLocale::system().language() == QLocale::Tibetan) { |
| 736 |
m_pPhonePicTotal->setFixedHeight(20 + 10); |
| 737 |
} |
| 738 |
DFontSizeManager::instance()->bind(m_pPhonePicTotal, DFontSizeManager::T6, QFont::Medium); |
| 739 |
m_pPhonePicTotal->setForegroundRole(DPalette::TextTips); |
| 740 |
QPalette pal = DApplicationHelper::instance()->palette(m_pPhonePicTotal); |
| 741 |
QColor color_BT = pal.color(DPalette::BrightText); |
| 742 |
DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType(); |
| 743 |
if (themeType == DGuiApplicationHelper::LightType) { |
| 744 |
color_BT.setAlphaF(0.5); |
| 745 |
pal.setBrush(DPalette::Text, color_BT); |
| 746 |
} else if (themeType == DGuiApplicationHelper::DarkType) { |
| 747 |
color_BT.setAlphaF(0.75); |
| 748 |
pal.setBrush(DPalette::Text, color_BT); |
| 749 |
} |
| 750 |
m_pPhonePicTotal->setForegroundRole(DPalette::Text); |
| 751 |
m_pPhonePicTotal->setPalette(pal); |
| 752 |
|
| 753 |
m_pRightPhoneThumbnailList = new ThumbnailListView(ThumbnailDelegate::AlbumViewPhoneType, ALBUM_PATHTYPE_BY_PHONE); |
| 754 |
m_pRightPhoneThumbnailList->setListViewUseFor(ThumbnailListView::Mount); |
| 755 |
m_pRightPhoneThumbnailList->setFrameShape(DTableView::NoFrame); |
| 756 |
m_pRightPhoneThumbnailList->setViewportMargins(0, 0, 0, 0); |
| 757 |
thumbnailListLayout->addWidget(m_pRightPhoneThumbnailList); |
| 758 |
|
| 759 |
PhonePicTotalLayout->addWidget(m_pPhonePicTotal); |
| 760 |
PhonePicTotalLayout->addStretch(); |
| 761 |
|
| 762 |
QVBoxLayout *pPhoneVBoxLayout = new QVBoxLayout(); |
| 763 |
pPhoneVBoxLayout->setContentsMargins(20, 0, 0, 0); |
| 764 |
pPhoneVBoxLayout->addSpacing(4); |
| 765 |
pPhoneVBoxLayout->addWidget(m_pPhoneTitle); |
| 766 |
pPhoneVBoxLayout->addSpacing(22); |
| 767 |
pPhoneVBoxLayout->addLayout(PhonePicTotalLayout); |
| 768 |
pPhoneVBoxLayout->addSpacing(-1); |
| 769 |
|
| 770 |
|
| 771 |
//手机相片导入窗体 |
| 772 |
m_importByPhoneWidget = new DWidget; |
| 773 |
QHBoxLayout *mainImportLayout = new QHBoxLayout; |
| 774 |
DLabel *importLabel = new DLabel(); |
| 775 |
importLabel->setText(tr("Import to:")); |
| 776 |
DFontSizeManager::instance()->bind(importLabel, DFontSizeManager::T6, QFont::Medium); |
| 777 |
importLabel->setForegroundRole(DPalette::TextTitle); |
| 778 |
importLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); |
| 779 |
|
| 780 |
m_importByPhoneComboBox = new DComboBox; |
| 781 |
m_importByPhoneComboBox->setFixedSize(QSize(213, 36)); |
| 782 |
m_importByPhoneComboBox->setEnabled(false); |
| 783 |
m_importAllByPhoneBtn = new DPushButton(tr("Import All")); |
| 784 |
DFontSizeManager::instance()->bind(m_importAllByPhoneBtn, DFontSizeManager::T6); |
| 785 |
m_importAllByPhoneBtn->setFixedSize(100, 36); |
| 786 |
DPalette importAllByPhoneBtnPa = DApplicationHelper::instance()->palette(m_importAllByPhoneBtn); |
| 787 |
importAllByPhoneBtnPa.setBrush(DPalette::Highlight, QColor(0, 0, 0, 0)); |
| 788 |
m_importAllByPhoneBtn->setPalette(importAllByPhoneBtnPa); |
| 789 |
m_importAllByPhoneBtn->setEnabled(false); |
| 790 |
|
| 791 |
m_importSelectByPhoneBtn = new DSuggestButton(tr("Import")); |
| 792 |
DFontSizeManager::instance()->bind(m_importSelectByPhoneBtn, DFontSizeManager::T6); |
| 793 |
|
| 794 |
m_importSelectByPhoneBtn->setFixedSize(QSize(100, 36)); |
| 795 |
m_importSelectByPhoneBtn->setEnabled(false); |
| 796 |
mainImportLayout->addWidget(importLabel); |
| 797 |
mainImportLayout->addSpacing(8); |
| 798 |
mainImportLayout->addWidget(m_importByPhoneComboBox); |
| 799 |
mainImportLayout->addSpacing(15); |
| 800 |
mainImportLayout->addWidget(m_importAllByPhoneBtn); |
| 801 |
mainImportLayout->addSpacing(5); |
| 802 |
mainImportLayout->addWidget(m_importSelectByPhoneBtn); |
| 803 |
m_importByPhoneWidget->setLayout(mainImportLayout); |
| 804 |
|
| 805 |
QHBoxLayout *allHLayout = new QHBoxLayout; |
| 806 |
allHLayout->setContentsMargins(0, 0, 0, 0); |
| 807 |
allHLayout->addLayout(pPhoneVBoxLayout, 1); |
| 808 |
allHLayout->addStretch(); |
| 809 |
allHLayout->addWidget(m_importByPhoneWidget, 1); |
| 810 |
m_pRightPhoneThumbnailList->setParent(pPhoneWidget); |
| 811 |
phonetopwidget = new DWidget(pPhoneWidget); |
| 812 |
QGraphicsOpacityEffect *opacityEffect_lightphone = new QGraphicsOpacityEffect; |
| 813 |
opacityEffect_lightphone->setOpacity(0.95); |
| 814 |
phonetopwidget->setGraphicsEffect(opacityEffect_lightphone); |
| 815 |
phonetopwidget->setAutoFillBackground(true); |
| 816 |
phonetopwidget->setFixedSize(pPhoneWidget->width() - 15, 81);//BUG#93779 -15把右侧滚动条露出来 |
| 817 |
phonetopwidget->setLayout(allHLayout); |
| 818 |
phonetopwidget->move(0, 0); |
| 819 |
phonetopwidget->raise(); |
| 820 |
} |
| 821 |
|
| 822 |
void AlbumView::resetLabelCount(int photosCount, int videosCount, DLabel *lable) |
| 823 |
{ |
| 824 |
QString photosStr; |
| 825 |
if (photosCount == 1) { |
| 826 |
photosStr = StatusBar::tr("1 photo"); |
| 827 |
} else if (photosCount > 1) { |
| 828 |
photosStr = StatusBar::tr("%n photos", "", photosCount); |
| 829 |
} |
| 830 |
|
| 831 |
QString videosStr; |
| 832 |
if (videosCount == 1) { |
| 833 |
videosStr = StatusBar::tr("1 video"); |
| 834 |
} else if (videosCount > 1) { |
| 835 |
videosStr = StatusBar::tr("%n videos", "", videosCount); |
| 836 |
} |
| 837 |
|
| 838 |
if (photosCount > 0 && videosCount == 0) { |
| 839 |
lable->setText(photosStr); |
| 840 |
} else if (photosCount == 0 && videosCount > 0) { |
| 841 |
lable->setText(videosStr); |
| 842 |
} else if (photosCount > 0 && videosCount > 0) { |
| 843 |
lable->setText(photosStr + " " + videosStr); |
| 844 |
} |
| 845 |
} |
| 846 |
|
| 847 |
void AlbumView::updateRightView() |
| 848 |
{ |
| 849 |
if (!m_customAlbumTitleLabel) { |
| 850 |
return; |
| 851 |
} |
| 852 |
m_customAlbumTitleLabel->setVisible(true); |
| 853 |
m_pRightPicTotal->setVisible(true); |
| 854 |
if (!m_spinner) { |
| 855 |
return; |
| 856 |
} |
| 857 |
m_spinner->hide(); |
| 858 |
m_spinner->stop(); |
| 859 |
m_curThumbnaiItemList_info.clear(); |
| 860 |
m_curThumbnaiItemList_str.clear(); |
| 861 |
if (COMMON_STR_RECENT_IMPORTED == m_currentType) { |
| 862 |
updateRightImportView(); |
| 863 |
} else if (COMMON_STR_TRASH == m_currentType) { |
| 864 |
updateRightTrashView(); |
| 865 |
setAcceptDrops(false); |
| 866 |
emit sigSearchEditIsDisplay(false); |
| 867 |
} else if (COMMON_STR_FAVORITES == m_currentType) { |
| 868 |
updateRightMyFavoriteView(); |
| 869 |
} else if (COMMON_STR_CUSTOM == m_currentType) { |
| 870 |
updateRightCustomAlbumView(); |
| 871 |
} else if (ALBUM_PATHTYPE_BY_PHONE == m_currentType) { |
| 872 |
m_itemClicked = true; |
| 873 |
updateRightMountView(); |
| 874 |
setAcceptDrops(false); |
| 875 |
emit sigSearchEditIsDisplay(false); |
| 876 |
} |
| 877 |
updatePicNum(); |
| 878 |
} |
| 879 |
|
| 880 |
void AlbumView::updateAlbumView(const QString &album) |
| 881 |
{ |
| 882 |
if (m_currentType == album) { |
| 883 |
updateRightMyFavoriteView(); |
| 884 |
} |
| 885 |
//更新我的收藏时不刷新自定义相册 |
| 886 |
if (m_currentType == COMMON_STR_CUSTOM && album != COMMON_STR_FAVORITES) { |
| 887 |
updateRightCustomAlbumView(); |
| 888 |
} |
| 889 |
} |
| 890 |
|
| 891 |
void AlbumView::updateDeviceLeftList() |
| 892 |
{ |
| 893 |
bool tempB = false; |
| 894 |
m_mounts.count() > 0 ? tempB = true : tempB = false; |
| 895 |
// 有设备接入时,左边栏显示设备item |
| 896 |
m_pLeftListView->m_pMountListWidget->setVisible(tempB); |
| 897 |
m_pLeftListView->m_pMountWidget->setVisible(tempB); |
| 898 |
m_pLeftListView->m_pMountListWidget->setFixedHeight(m_pLeftListView->m_pMountListWidget->count() * 40); |
| 899 |
} |
| 900 |
|
| 901 |
void AlbumView::setCurrentItemType(int type) |
| 902 |
{ |
| 903 |
m_currentItemType = static_cast<AblumType>(type); |
| 904 |
} |
| 905 |
|
| 906 |
// 更新已导入列表 |
| 907 |
void AlbumView::updateRightImportView() |
| 908 |
{ |
| 909 |
m_iAlubmPicsNum = DBManager::instance()->getImgsCount(); |
| 910 |
|
| 911 |
if (0 < m_iAlubmPicsNum) { |
| 912 |
m_pImpTimeLineView->clearAndStartLayout(); |
| 913 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_TIMELINE_IMPORT); |
| 914 |
m_pStatusBar->setVisible(true); |
| 915 |
} else { |
| 916 |
m_pImpTimeLineView->clearAndStartLayout(); |
| 917 |
m_pImportView->setAlbumname(QString()); |
| 918 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_IMPORT); |
| 919 |
m_pStatusBar->setVisible(false); |
| 920 |
} |
| 921 |
emit sigSearchEditIsDisplay(true); |
| 922 |
setAcceptDrops(true); |
| 923 |
} |
| 924 |
|
| 925 |
// 更新个人收藏列表 |
| 926 |
void AlbumView::updateRightMyFavoriteView() |
| 927 |
{ |
| 928 |
using namespace utils::image; |
| 929 |
DBImgInfoList infos; |
| 930 |
infos = DBManager::instance()->getInfosByAlbum(m_currentAlbum, AlbumDBType::Favourite); |
| 931 |
m_curThumbnaiItemList_info << infos; |
| 932 |
m_favoriteThumbnailList->clearAll(); |
| 933 |
//插入上方空白项 |
| 934 |
m_favoriteThumbnailList->insertBlankOrTitleItem(ItemTypeBlank, "", "", favorite_title_height); |
| 935 |
m_favoriteThumbnailList->insertThumbnailByImgInfos(infos); |
| 936 |
//重置数量显示 |
| 937 |
resetLabelCount(m_favoriteThumbnailList->getAppointTypeItemCount(ItemTypePic) |
| 938 |
, m_favoriteThumbnailList->getAppointTypeItemCount(ItemTypeVideo), m_pFavoritePicTotal); |
| 939 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_FAVORITE_LIST); |
| 940 |
m_FavoriteTitleWidget->setVisible(infos.size() > 0); |
| 941 |
m_pStatusBar->setVisible(true); |
| 942 |
emit sigSearchEditIsDisplay(true); |
| 943 |
setAcceptDrops(false); |
| 944 |
} |
| 945 |
|
| 946 |
// 更新外接设备右侧视图 |
| 947 |
void AlbumView::updateRightMountView() |
| 948 |
{ |
| 949 |
qDebug() << "------" << __FUNCTION__ << ""; |
| 950 |
if (!isVisible()) { |
| 951 |
qDebug() << "提前退出更新右侧视图"; |
| 952 |
return; |
| 953 |
} |
| 954 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_PHONE); |
| 955 |
if (!m_pLeftListView) { |
| 956 |
return; |
| 957 |
} |
| 958 |
QString strPath; |
| 959 |
if (m_pLeftListView->m_pMountListWidget->currentItem()) { |
| 960 |
strPath = m_pLeftListView->m_pMountListWidget->currentItem()->data(Qt::UserRole).toString(); |
| 961 |
if (!strPath.contains("/media/") && !strPath.contains("DCIM")) { |
| 962 |
findPicturePathByPhone(strPath); |
| 963 |
} |
| 964 |
} |
| 965 |
//先关闭之前循环的线程 |
| 966 |
ImageEngineApi::instance()->setThreadShouldStop(); |
| 967 |
//发送信号到子线程加载文件信息 |
| 968 |
emit ImageEngineApi::instance()->sigLoadMountFileList(strPath); |
| 969 |
//TODO 保存每个挂载设备的加载状态 |
| 970 |
if (mountLoadStatus.contains(strPath) && mountLoadStatus[strPath]) { |
| 971 |
return; |
| 972 |
} |
| 973 |
mountLoadStatus[strPath] = true; |
| 974 |
//显示等待加载窗口 |
| 975 |
emit dApp->signalM->waitDevicescan(); |
| 976 |
} |
| 977 |
|
| 978 |
// 更新新建相册列表 |
| 979 |
void AlbumView::updateRightCustomAlbumView() |
| 980 |
{ |
| 981 |
qDebug() << "---------" << __FUNCTION__ << "---"; |
| 982 |
//bug78951 更新时需清空 |
| 983 |
m_curThumbnaiItemList_info.clear(); |
| 984 |
using namespace utils::image; |
| 985 |
DBImgInfoList infos; |
| 986 |
infos = DBManager::instance()->getInfosByAlbum(m_currentAlbum); |
| 987 |
//先清除所有 |
| 988 |
m_customThumbnailList->clearAll(); |
| 989 |
//添加上方空白栏 |
| 990 |
m_customThumbnailList->insertBlankOrTitleItem(ItemTypeBlank, "", "", custom_title_height); |
| 991 |
//添加图片信息 |
| 992 |
m_customThumbnailList->insertThumbnailByImgInfos(infos); |
| 993 |
m_curThumbnaiItemList_info << infos; |
| 994 |
// m_iAlubmPicsNum = DBManager::instance()->getImgsCountByAlbum(m_currentAlbum); |
| 995 |
m_iAlubmPicsNum = infos.size(); |
| 996 |
if (0 < m_iAlubmPicsNum) { |
| 997 |
m_customAlbumTitleLabel->setText(m_currentAlbum); |
| 998 |
QFontMetrics elideFont(m_customAlbumTitleLabel->font()); |
| 999 |
m_customAlbumTitleLabel->setText(elideFont.elidedText(m_currentAlbum, Qt::ElideRight, 525)); |
| 1000 |
//重置数量显示 |
| 1001 |
resetLabelCount(m_customThumbnailList->getAppointTypeItemCount(ItemTypePic) |
| 1002 |
, m_customThumbnailList->getAppointTypeItemCount(ItemTypeVideo), m_pRightPicTotal); |
| 1003 |
m_customThumbnailList->m_imageType = m_currentAlbum; |
| 1004 |
m_customThumbnailList->stopLoadAndClear(); |
| 1005 |
//todo |
| 1006 |
// m_pRightThumbnailList->loadFilesFromLocal(infos); |
| 1007 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_THUMBNAIL_LIST); |
| 1008 |
m_pStatusBar->show(); |
| 1009 |
} else { |
| 1010 |
m_customThumbnailList->stopLoadAndClear(); |
| 1011 |
//todo |
| 1012 |
// m_pRightThumbnailList->loadFilesFromLocal(infos); |
| 1013 |
m_pImportView->setAlbumname(m_currentAlbum); |
| 1014 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_IMPORT); |
| 1015 |
m_pStatusBar->setVisible(false); |
| 1016 |
} |
| 1017 |
|
| 1018 |
emit sigSearchEditIsDisplay(true); |
| 1019 |
setAcceptDrops(true); |
| 1020 |
} |
| 1021 |
|
| 1022 |
void AlbumView::updateRightTrashView() |
| 1023 |
{ |
| 1024 |
using namespace utils::image; |
| 1025 |
if (m_allTrashInfos.isEmpty()) { |
| 1026 |
m_allTrashInfos = DBManager::instance()->getAllTrashInfos(); |
| 1027 |
} |
| 1028 |
QDateTime currentTime = QDateTime::currentDateTime(); |
| 1029 |
DBImgInfoList list; |
| 1030 |
for (int i = m_allTrashInfos.size() - 1; i >= 0; i--) { |
| 1031 |
DBImgInfo pinfo = m_allTrashInfos.at(i); |
| 1032 |
if (!QFileInfo(pinfo.filePath).exists()) { |
| 1033 |
m_allTrashInfos.removeAt(i); |
| 1034 |
} else if (utils::base::daysDifferenceBetweenTime(pinfo.importTime, currentTime) >= 30) { |
| 1035 |
list << pinfo; |
| 1036 |
m_allTrashInfos.removeAt(i); |
| 1037 |
} |
| 1038 |
} |
| 1039 |
//清理删除时间过长图片 |
| 1040 |
if (!list.isEmpty()) { |
| 1041 |
ImageEngineApi::instance()->cleanUpTrash(list); |
| 1042 |
} |
| 1043 |
|
| 1044 |
m_pRightTrashThumbnailList->clearAll(); |
| 1045 |
m_pRightTrashThumbnailList->insertBlankOrTitleItem(ItemTypeBlank, "", "", trash_title_height); |
| 1046 |
m_pRightTrashThumbnailList->insertThumbnailByImgInfos(m_allTrashInfos); |
| 1047 |
m_curThumbnaiItemList_info << m_allTrashInfos; |
| 1048 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_TRASH_LIST); |
| 1049 |
m_trashBatchOperateWidget->setVisible(m_allTrashInfos.size() > 0); |
| 1050 |
m_pStatusBar->setVisible(true); |
| 1051 |
m_pRightTrashThumbnailList->stopLoadAndClear(); |
| 1052 |
} |
| 1053 |
|
| 1054 |
void AlbumView::leftTabClicked() |
| 1055 |
{ |
| 1056 |
emit dApp->signalM->SearchEditClear(); |
| 1057 |
//若点击当前的item,则不做任何处理 |
| 1058 |
if (m_currentAlbum == m_pLeftListView->getItemCurrentName() |
| 1059 |
&& m_currentItemType == m_pLeftListView->getItemDataType()) { |
| 1060 |
SearchReturnUpdate(); |
| 1061 |
return; |
| 1062 |
} |
| 1063 |
m_currentAlbum = m_pLeftListView->getItemCurrentName(); |
| 1064 |
m_currentType = m_pLeftListView->getItemCurrentType(); |
| 1065 |
m_currentItemType = static_cast<AblumType>(m_pLeftListView->getItemDataType()); |
| 1066 |
qDebug() << "------" << __FUNCTION__ << ""; |
| 1067 |
updateRightView(); |
| 1068 |
} |
| 1069 |
|
| 1070 |
bool AlbumView::imageGeted(QStringList &filelist, QString path) |
| 1071 |
{ |
| 1072 |
m_phoneNameAndPathlist[path] = filelist; |
| 1073 |
m_pictrueallPathlist.clear(); |
| 1074 |
for (auto list : m_phoneNameAndPathlist) { |
| 1075 |
m_pictrueallPathlist << list; |
| 1076 |
} |
| 1077 |
qDebug() << "zy------AlbumView::imageGeted loadImageDateToMemory"; |
| 1078 |
ImageEngineApi::instance()->loadImageDateToMemory(m_phoneNameAndPathlist[path], path); |
| 1079 |
if (m_itemClicked == true) { |
| 1080 |
m_curThumbnaiItemList_str.clear(); |
| 1081 |
qDebug() << "------" << __FUNCTION__ << ""; |
| 1082 |
updateRightMountView(); |
| 1083 |
} |
| 1084 |
return true; |
| 1085 |
} |
| 1086 |
|
| 1087 |
void AlbumView::onTrashRecoveryBtnClicked() |
| 1088 |
{ |
| 1089 |
QStringList paths; |
| 1090 |
paths = m_pRightTrashThumbnailList->selectedPaths(); |
| 1091 |
ImageEngineApi::instance()->recoveryImagesFromTrash(paths); |
| 1092 |
} |
| 1093 |
|
| 1094 |
void AlbumView::onOpenImageFav(int row, const QString &path, bool bFullScreen) |
| 1095 |
{ |
| 1096 |
SignalManager::ViewInfo info; |
| 1097 |
info.album = ""; |
| 1098 |
info.lastPanel = nullptr; |
| 1099 |
info.fullScreen = bFullScreen; |
| 1100 |
auto imagelist = m_favoriteThumbnailList->getFileList(row); |
| 1101 |
if (imagelist.size() > 0) { |
| 1102 |
info.paths << imagelist; |
| 1103 |
info.path = path; |
| 1104 |
} else { |
| 1105 |
info.paths.clear(); |
| 1106 |
} |
| 1107 |
info.dBImgInfos = m_favoriteThumbnailList->getAllFileInfo(row); |
| 1108 |
info.viewType = m_currentAlbum; |
| 1109 |
info.viewMainWindowID = VIEW_MAINWINDOW_ALBUM; |
| 1110 |
emit dApp->signalM->viewImage(info); |
| 1111 |
emit dApp->signalM->showImageView(VIEW_MAINWINDOW_ALBUM); |
| 1112 |
} |
| 1113 |
|
| 1114 |
void AlbumView::onOpenImageCustom(int row, const QString &path, bool bFullScreen) |
| 1115 |
{ |
| 1116 |
SignalManager::ViewInfo info; |
| 1117 |
info.album = m_currentAlbum; |
| 1118 |
info.lastPanel = nullptr; |
| 1119 |
info.fullScreen = bFullScreen; |
| 1120 |
auto imagelist = m_customThumbnailList->getFileList(row); |
| 1121 |
if (imagelist.size() > 0) { |
| 1122 |
info.paths << imagelist; |
| 1123 |
info.path = path; |
| 1124 |
} else { |
| 1125 |
info.paths.clear(); |
| 1126 |
} |
| 1127 |
info.dBImgInfos = m_customThumbnailList->getAllFileInfo(row); |
| 1128 |
info.viewType = m_currentAlbum; |
| 1129 |
info.viewMainWindowID = VIEW_MAINWINDOW_ALBUM; |
| 1130 |
emit dApp->signalM->viewImage(info); |
| 1131 |
emit dApp->signalM->showImageView(VIEW_MAINWINDOW_ALBUM); |
| 1132 |
} |
| 1133 |
|
| 1134 |
void AlbumView::onSlideShowFav(const QString &path) |
| 1135 |
{ |
| 1136 |
SignalManager::ViewInfo info; |
| 1137 |
info.album = ""; |
| 1138 |
info.lastPanel = nullptr; |
| 1139 |
|
| 1140 |
auto photolist = m_favoriteThumbnailList->selectedPaths(); |
| 1141 |
if (photolist.size() > 1) { |
| 1142 |
//如果选中数目大于1,则幻灯片播放选中项 |
| 1143 |
info.paths = photolist; |
| 1144 |
info.path = photolist.at(0); |
| 1145 |
} else { |
| 1146 |
//如果选中项只有一项,则幻灯片播放全部 |
| 1147 |
info.paths = m_favoriteThumbnailList->getFileList(); |
| 1148 |
info.path = path; |
| 1149 |
} |
| 1150 |
info.fullScreen = true; |
| 1151 |
info.slideShow = true; |
| 1152 |
info.viewType = m_currentAlbum; |
| 1153 |
info.viewMainWindowID = VIEW_MAINWINDOW_ALBUM; |
| 1154 |
emit dApp->signalM->startSlideShow(info); |
| 1155 |
emit dApp->signalM->showSlidePanel(VIEW_MAINWINDOW_ALBUM); |
| 1156 |
} |
| 1157 |
|
| 1158 |
void AlbumView::onSlideShowCustom(const QString &path) |
| 1159 |
{ |
| 1160 |
SignalManager::ViewInfo info; |
| 1161 |
info.album = ""; |
| 1162 |
info.lastPanel = nullptr; |
| 1163 |
|
| 1164 |
auto photolist = m_customThumbnailList->selectedPaths(); |
| 1165 |
if (photolist.size() > 1) { |
| 1166 |
//如果选中数目大于1,则幻灯片播放选中项 |
| 1167 |
info.paths = photolist; |
| 1168 |
info.path = photolist.at(0); |
| 1169 |
} else { |
| 1170 |
//如果选中项只有一项,则幻灯片播放全部 |
| 1171 |
info.paths = m_customThumbnailList->getFileList(); |
| 1172 |
info.path = path; |
| 1173 |
} |
| 1174 |
info.fullScreen = true; |
| 1175 |
info.slideShow = true; |
| 1176 |
info.viewType = m_currentAlbum; |
| 1177 |
info.viewMainWindowID = VIEW_MAINWINDOW_ALBUM; |
| 1178 |
emit dApp->signalM->startSlideShow(info); |
| 1179 |
emit dApp->signalM->showSlidePanel(VIEW_MAINWINDOW_ALBUM); |
| 1180 |
} |
| 1181 |
|
| 1182 |
void AlbumView::dragEnterEvent(QDragEnterEvent *e) |
| 1183 |
{ |
| 1184 |
if (!utils::base::checkMimeUrls(e->mimeData()->urls())) { |
| 1185 |
return; |
| 1186 |
} |
| 1187 |
e->setDropAction(Qt::CopyAction); |
| 1188 |
e->accept(); |
| 1189 |
} |
| 1190 |
|
| 1191 |
void AlbumView::dropEvent(QDropEvent *event) |
| 1192 |
{ |
| 1193 |
QList<QUrl> urls = event->mimeData()->urls(); |
| 1194 |
if (urls.isEmpty()) { |
| 1195 |
return; |
| 1196 |
} |
| 1197 |
ImageEngineApi::instance()->ImportImagesFromUrlList(urls, m_currentAlbum, this); |
| 1198 |
event->accept(); |
| 1199 |
} |
| 1200 |
|
| 1201 |
void AlbumView::dragMoveEvent(QDragMoveEvent *event) |
| 1202 |
{ |
| 1203 |
event->accept(); |
| 1204 |
} |
| 1205 |
|
| 1206 |
void AlbumView::dragLeaveEvent(QDragLeaveEvent *e) |
| 1207 |
{ |
| 1208 |
Q_UNUSED(e); |
| 1209 |
} |
| 1210 |
|
| 1211 |
void AlbumView::onKeyDelete() |
| 1212 |
{ |
| 1213 |
if (!isVisible()) return; |
| 1214 |
if (RIGHT_VIEW_SEARCH == m_pRightStackWidget->currentIndex()) return; |
| 1215 |
bool bMoveToTrash = false; |
| 1216 |
QStringList paths; |
| 1217 |
paths.clear(); |
| 1218 |
if (COMMON_STR_RECENT_IMPORTED == m_currentType) { |
| 1219 |
paths = m_pImpTimeLineView->selectPaths(); |
| 1220 |
m_pImpTimeLineView->getListView()->clearSelection(); |
| 1221 |
if (0 < paths.length()) { |
| 1222 |
bMoveToTrash = true; |
| 1223 |
} |
| 1224 |
} else if (COMMON_STR_TRASH == m_currentType) { |
| 1225 |
paths = m_pRightTrashThumbnailList->selectedPaths(); |
| 1226 |
if (0 < paths.length()) { |
| 1227 |
int imgCount = 0; |
| 1228 |
int videoCount = 0; |
| 1229 |
DBImgInfo info; |
| 1230 |
for (int i = 0; i < paths.size(); i++) { |
| 1231 |
ImageEngineApi::instance()->getImageData(paths.at(i), info); |
| 1232 |
if (info.itemType == ItemTypePic) { |
| 1233 |
imgCount++; |
| 1234 |
} else if (info.itemType == ItemTypeVideo) { |
| 1235 |
videoCount++; |
| 1236 |
} |
| 1237 |
} |
| 1238 |
ImgDeleteDialog *dialog = new ImgDeleteDialog(this, imgCount, videoCount); |
| 1239 |
dialog->setObjectName("deteledialog"); |
| 1240 |
if (dialog->exec() > 0) { |
| 1241 |
m_pRightTrashThumbnailList->clearSelection(); |
| 1242 |
ImageEngineApi::instance()->moveImagesToTrash(paths, true); |
| 1243 |
} |
| 1244 |
} |
| 1245 |
} else if (COMMON_STR_FAVORITES == m_currentType) { |
| 1246 |
paths = m_favoriteThumbnailList->selectedPaths(); |
| 1247 |
if (0 < paths.length()) { |
| 1248 |
m_favoriteThumbnailList->clearSelection(); |
| 1249 |
DBManager::instance()->removeFromAlbum(COMMON_STR_FAVORITES, paths, AlbumDBType::Favourite); |
| 1250 |
} |
| 1251 |
} else if (COMMON_STR_CUSTOM == m_currentType) { |
| 1252 |
paths = m_customThumbnailList->selectedPaths(); |
| 1253 |
// 如果没有选中的照片,或相册中的照片数为0,则删除相册 |
| 1254 |
if (0 == paths.length() || 0 == DBManager::instance()->getItemsCountByAlbum(m_currentAlbum, ItemTypeNull)) { |
| 1255 |
QListWidgetItem *item = m_pLeftListView->m_pCustomizeListView->currentItem(); |
| 1256 |
AlbumLeftTabItem *pTabItem = dynamic_cast<AlbumLeftTabItem *>(m_pLeftListView->m_pCustomizeListView->itemWidget(item)); |
| 1257 |
m_deleteDialog = new AlbumDeleteDialog; |
| 1258 |
connect(m_deleteDialog, &AlbumDeleteDialog::deleteAlbum, this, [ = ]() { |
| 1259 |
QString str = pTabItem->m_albumNameStr; |
| 1260 |
QStringList album_paths = DBManager::instance()->getPathsByAlbum(pTabItem->m_albumNameStr); |
| 1261 |
ImageEngineApi::instance()->moveImagesToTrash(album_paths); |
| 1262 |
DBManager::instance()->removeAlbum(pTabItem->m_albumNameStr); |
| 1263 |
|
| 1264 |
if (1 < m_pLeftListView->m_pCustomizeListView->count()) { |
| 1265 |
delete item; |
| 1266 |
m_currentItemType = ablumType; |
| 1267 |
} else { |
| 1268 |
m_pLeftListView->updateCustomizeListView(); |
| 1269 |
m_pLeftListView->updatePhotoListView(); |
| 1270 |
m_currentItemType = photosType; |
| 1271 |
} |
| 1272 |
//刷新右侧视图 |
| 1273 |
leftTabClicked(); |
| 1274 |
m_pLeftListView->onUpdateLeftListview(); |
| 1275 |
emit dApp->signalM->sigAlbDelToast(str); |
| 1276 |
}); |
| 1277 |
m_deleteDialog->show(); |
| 1278 |
} else { |
| 1279 |
bMoveToTrash = true; |
| 1280 |
} |
| 1281 |
} else if (ALBUM_PATHTYPE_BY_PHONE == m_currentType) { |
| 1282 |
// 外部设备中的照片不删除 |
| 1283 |
} else { |
| 1284 |
|
| 1285 |
} |
| 1286 |
// 删除选中照片 |
| 1287 |
if (bMoveToTrash) { |
| 1288 |
ImageEngineApi::instance()->moveImagesToTrash(paths); |
| 1289 |
} |
| 1290 |
} |
| 1291 |
|
| 1292 |
void AlbumView::onKeyF2() |
| 1293 |
{ |
| 1294 |
if (COMMON_STR_CUSTOM != m_currentType) return; |
| 1295 |
AlbumLeftTabItem *item = dynamic_cast<AlbumLeftTabItem *>(m_pLeftListView->m_pCustomizeListView->itemWidget(m_pLeftListView->m_pCustomizeListView->currentItem())); |
| 1296 |
item->m_opeMode = OPE_MODE_RENAMEALBUM; |
| 1297 |
item->editAlbumEdit(); |
| 1298 |
} |
| 1299 |
|
| 1300 |
//挂载设备改变 |
| 1301 |
void AlbumView::onVfsMountChangedAdd(QExplicitlySharedDataPointer<DGioMount> mount) |
| 1302 |
{ |
| 1303 |
qDebug() << "zy------onVfsMountChangedAdd activeThreadCount = " << QThreadPool::globalInstance()->activeThreadCount(); |
| 1304 |
qDebug() << "zy------AlbumView::onVfsMountChangedAdd() name:" << mount->name(); |
| 1305 |
|
| 1306 |
//TODO: |
| 1307 |
//Support android phone, iPhone, and usb devices. Not support ftp, smb mount, non removeable disk now |
| 1308 |
QString uri = mount->getRootFile()->uri(); |
| 1309 |
QString scheme = QUrl(uri).scheme(); |
| 1310 |
if ((scheme == "file" /*&& mount->canEject()*/) || //usb device |
| 1311 |
(scheme == "gphoto2") || //phone photo |
| 1312 |
//(scheme == "afc") || //iPhone document |
| 1313 |
(scheme == "mtp")) { //android file |
| 1314 |
|
| 1315 |
qDebug() << "mount.name" << mount->name() << " scheme type:" << scheme; |
| 1316 |
for (auto mountLoop : m_mounts) { |
| 1317 |
QString uriLoop = mountLoop->getRootFile()->uri(); |
| 1318 |
if (uri == uriLoop) { |
| 1319 |
qDebug() << "Already has this device in mount list. uri:" << uriLoop; |
| 1320 |
return; |
| 1321 |
} |
| 1322 |
} |
| 1323 |
QExplicitlySharedDataPointer<DGioFile> LocationFile = mount->getDefaultLocationFile(); |
| 1324 |
QString strPath = LocationFile->path(); |
| 1325 |
if (strPath.isEmpty()) { |
| 1326 |
qDebug() << "onVfsMountChangedAdd() strPath.isEmpty()"; |
| 1327 |
} |
| 1328 |
mountLoadStatus[strPath] = false; |
| 1329 |
QString rename = ""; |
| 1330 |
rename = durlAndNameMap[QUrl(mount->getRootFile()->uri())]; |
| 1331 |
if ("" == rename) { |
| 1332 |
rename = mount->name(); |
| 1333 |
} |
| 1334 |
//判断路径是否存在 |
| 1335 |
bool bFind = false; |
| 1336 |
QDir dir(strPath); |
| 1337 |
if (!dir.exists()) { |
| 1338 |
qDebug() << "onLoadMountImagesStart() !dir.exists()"; |
| 1339 |
bFind = false; |
| 1340 |
} else { |
| 1341 |
bFind = true; |
| 1342 |
} |
| 1343 |
//U盘和硬盘挂载都是/media下的,此处判断若path不包含/media/,再调用findPicturePathByPhone函数搜索DCIM文件目录 |
| 1344 |
if (!strPath.contains("/media/")) { |
| 1345 |
bFind = findPicturePathByPhone(strPath); |
| 1346 |
} |
| 1347 |
isIgnore = true; |
| 1348 |
updateExternalDevice(mount, strPath); |
| 1349 |
m_mounts = getVfsMountList(); |
| 1350 |
updateDeviceLeftList(); |
| 1351 |
if (bFind) { |
| 1352 |
updateRightMountView(); |
| 1353 |
} |
| 1354 |
} |
| 1355 |
} |
| 1356 |
|
| 1357 |
//卸载外接设备 |
| 1358 |
void AlbumView::onVfsMountChangedRemove(QExplicitlySharedDataPointer<DGioMount> mount) |
| 1359 |
{ |
| 1360 |
m_mounts = getVfsMountList(); |
| 1361 |
if (m_waitDeviceScandialog) { |
| 1362 |
m_waitDeviceScandialog->close(); |
| 1363 |
} |
| 1364 |
qDebug() << "zy------onVfsMountChangedRemove activeThreadCount = " << QThreadPool::globalInstance()->activeThreadCount(); |
| 1365 |
qDebug() << "zy------AlbumView::onVfsMountChangedRemove"; |
| 1366 |
QString uri = mount->getRootFile()->uri(); |
| 1367 |
QString strPath = mount->getDefaultLocationFile()->path(); |
| 1368 |
if (!strPath.contains("/media/")) { |
| 1369 |
findPicturePathByPhone(strPath); |
| 1370 |
} |
| 1371 |
for (int i = 0; i < m_pLeftListView->m_pMountListWidget->count(); i++) { |
| 1372 |
QListWidgetItem *pListWidgetItem = m_pLeftListView->m_pMountListWidget->item(i); |
| 1373 |
AlbumLeftTabItem *pAlbumLeftTabItem = dynamic_cast<AlbumLeftTabItem *>(m_pLeftListView->m_pMountListWidget->itemWidget(pListWidgetItem)); |
| 1374 |
if (!pAlbumLeftTabItem || !pListWidgetItem) |
| 1375 |
break; |
| 1376 |
QString rename = ""; |
| 1377 |
QUrl qurl(mount->getRootFile()->uri()); |
| 1378 |
rename = durlAndNameMap[qurl]; |
| 1379 |
if ("" == rename) { |
| 1380 |
rename = mount->name(); |
| 1381 |
} |
| 1382 |
if (rename == pAlbumLeftTabItem->m_albumNameStr /*&& |
| 1383 |
strPath == pListWidgetItem->data(Qt::UserRole).toString()*/ |
| 1384 |
/*pAlbumLeftTabItem->m_mountPath.contains(strPath)*/) { |
| 1385 |
if (1 < m_pLeftListView->m_pMountListWidget->count()) { |
| 1386 |
m_pLeftListView->m_pMountListWidget->takeItem(m_pLeftListView->m_pMountListWidget->row(pListWidgetItem)); |
| 1387 |
delete pListWidgetItem; |
| 1388 |
m_currentItemType = devType; |
| 1389 |
} else { |
| 1390 |
m_pLeftListView->m_pMountListWidget->clear(); |
| 1391 |
m_pLeftListView->updatePhotoListView(); |
| 1392 |
m_currentItemType = photosType; |
| 1393 |
} |
| 1394 |
emit dApp->signalM->sigDevStop(strPath); |
| 1395 |
m_phoneNameAndPathlist.remove(strPath); |
| 1396 |
durlAndNameMap.erase(durlAndNameMap.find(qurl)); |
| 1397 |
break; |
| 1398 |
} |
| 1399 |
} |
| 1400 |
leftTabClicked(); |
| 1401 |
m_mounts = getVfsMountList(); |
| 1402 |
updateDeviceLeftList(); |
| 1403 |
} |
| 1404 |
|
| 1405 |
void AlbumView::getAllDeviceName() |
| 1406 |
{ |
| 1407 |
QStringList blDevList = DDiskManager::blockDevices(QVariantMap()); |
| 1408 |
for (const QString &blks : blDevList) { |
| 1409 |
QSharedPointer<DBlockDevice> blk(DDiskManager::createBlockDevice(blks)); |
| 1410 |
QScopedPointer<DDiskDevice> drv1(DDiskManager::createDiskDevice(blk->drive())); |
| 1411 |
|
| 1412 |
if (!blk->hasFileSystem() && !drv1->mediaCompatibility().join(" ").contains("optical") && !blk->isEncrypted()) { |
| 1413 |
continue; |
| 1414 |
} |
| 1415 |
if ((blk->hintIgnore() && !blk->isEncrypted()) || blk->cryptoBackingDevice().length() > 1) { |
| 1416 |
continue; |
| 1417 |
} |
| 1418 |
DBlockDevice *pblk = blk.data(); |
| 1419 |
QByteArrayList mps = blk->mountPoints(); |
| 1420 |
qulonglong size = blk->size(); |
| 1421 |
QString label = blk->idLabel(); |
| 1422 |
QString fs = blk->idType(); |
| 1423 |
QString udispname = ""; |
| 1424 |
|
| 1425 |
if (label.startsWith(ddeI18nSym)) { |
| 1426 |
QString i18nKey = label.mid(ddeI18nSym.size(), label.size() - ddeI18nSym.size()); |
| 1427 |
udispname = qApp->translate("DeepinStorage", i18nMap.value(i18nKey, i18nKey.toUtf8().constData())); |
| 1428 |
goto runend1; |
| 1429 |
} |
| 1430 |
|
| 1431 |
if (mps.contains(QByteArray("/\0", 2))) { |
| 1432 |
udispname = tr("System Disk"); |
| 1433 |
goto runend1; |
| 1434 |
} |
| 1435 |
if (label.length() == 0) { |
| 1436 |
QScopedPointer<DDiskDevice> drv(DDiskManager::createDiskDevice(pblk->drive())); |
| 1437 |
if (!drv->mediaAvailable() && drv->mediaCompatibility().join(" ").contains("optical")) { |
| 1438 |
QString maxmediacompat; |
| 1439 |
for (auto i = opticalmediakv.rbegin(); i != opticalmediakv.rend(); ++i) { |
| 1440 |
if (drv->mediaCompatibility().contains(i->first)) { |
| 1441 |
maxmediacompat = i->second; |
| 1442 |
break; |
| 1443 |
} |
| 1444 |
} |
| 1445 |
udispname = QCoreApplication::translate("DeepinStorage", "%1 Drive").arg(maxmediacompat); |
| 1446 |
goto runend1; |
| 1447 |
} |
| 1448 |
if (drv->opticalBlank()) { |
| 1449 |
udispname = QCoreApplication::translate("DeepinStorage", "Blank %1 Disc").arg(opticalmediamap[drv->media()]); |
| 1450 |
goto runend1; |
| 1451 |
} |
| 1452 |
if (pblk->isEncrypted() && !blk) { |
| 1453 |
udispname = QCoreApplication::translate("DeepinStorage", "%1 Encrypted").arg(formatSize(qint64(size))); |
| 1454 |
goto runend1; |
| 1455 |
} |
| 1456 |
udispname = QCoreApplication::translate("DeepinStorage", "%1 Volume").arg(formatSize(qint64(size))); |
| 1457 |
goto runend1; |
| 1458 |
} |
| 1459 |
udispname = label; |
| 1460 |
runend1: |
| 1461 |
blk->mount({}); |
| 1462 |
QByteArrayList qbl = blk->mountPoints(); |
| 1463 |
QString mountPoint = "file://"; |
| 1464 |
QList<QByteArray>::iterator qb = qbl.begin(); |
| 1465 |
while (qb != qbl.end()) { |
| 1466 |
mountPoint += (*qb); |
| 1467 |
++qb; |
| 1468 |
} |
| 1469 |
qDebug() << "mountPoint:" << mountPoint; |
| 1470 |
QUrl qurl(mountPoint); |
| 1471 |
durlAndNameMap[qurl] = udispname; |
| 1472 |
} |
| 1473 |
} |
| 1474 |
|
| 1475 |
//获取外部设备列表 |
| 1476 |
const QList<QExplicitlySharedDataPointer<DGioMount>> AlbumView::getVfsMountList() |
| 1477 |
{ |
| 1478 |
getAllDeviceName(); |
| 1479 |
QList<QExplicitlySharedDataPointer<DGioMount> > result; |
| 1480 |
const QList<QExplicitlySharedDataPointer<DGioMount> > mounts = m_vfsManager->getMounts(); |
| 1481 |
for (auto mount : mounts) { |
| 1482 |
//TODO: |
| 1483 |
//Support android phone, iPhone, and usb devices. Not support ftp, smb, non removeable disk now |
| 1484 |
QString scheme = QUrl(mount->getRootFile()->uri()).scheme(); |
| 1485 |
if ((scheme == "file" /*&& mount->canEject()*/) || //usb device |
| 1486 |
(scheme == "gphoto2") || //phone photo |
| 1487 |
//(scheme == "afc") || //iPhone document |
| 1488 |
(scheme == "mtp")) { //android file |
| 1489 |
qDebug() << "getVfsMountList() mount.name" << mount->name() << " scheme type:" << scheme; |
| 1490 |
result.append(mount); |
| 1491 |
} else { |
| 1492 |
qDebug() << mount->name() << " scheme type:" << scheme << "is not supported by album."; |
| 1493 |
} |
| 1494 |
} |
| 1495 |
return result; |
| 1496 |
} |
| 1497 |
|
| 1498 |
void AlbumView::importComboBoxChange(QString strText) |
| 1499 |
{ |
| 1500 |
Q_UNUSED(strText); |
| 1501 |
if (1 == m_importByPhoneComboBox->currentIndex()) { |
| 1502 |
AlbumCreateDialog *dialog = new AlbumCreateDialog(this); |
| 1503 |
dialog->show(); |
| 1504 |
qDebug() << "xxxxxxxxxx" << window()->x(); |
| 1505 |
dialog->move(window()->x() + (window()->width() - dialog->width()) / 2, window()->y() + (window()->height() - dialog->height()) / 2); |
| 1506 |
connect(dialog, &AlbumCreateDialog::albumAdded, this, [ = ] { |
| 1507 |
DBManager::instance()->insertIntoAlbum(dialog->getCreateAlbumName(), QStringList(" ")); |
| 1508 |
onCreateNewAlbumFrom(dialog->getCreateAlbumName()); |
| 1509 |
updateImportComboBox(); |
| 1510 |
m_importByPhoneComboBox->setCurrentIndex(m_importByPhoneComboBox->count() - 1); |
| 1511 |
}); |
| 1512 |
connect(dialog, &AlbumCreateDialog::sigClose, this, [ = ] { |
| 1513 |
m_importByPhoneComboBox->setCurrentIndex(0); |
| 1514 |
}); |
| 1515 |
} |
| 1516 |
} |
| 1517 |
|
| 1518 |
void AlbumView::initExternalDevice() |
| 1519 |
{ |
| 1520 |
for (auto mount : m_mounts) { |
| 1521 |
#if 1 |
| 1522 |
QListWidgetItem *pListWidgetItem = new QListWidgetItem(/*m_pLeftListView->m_pMountListWidget*/); |
| 1523 |
//pListWidgetItem缓存文件挂载路径 |
| 1524 |
QExplicitlySharedDataPointer<DGioFile> LocationFile = mount->getDefaultLocationFile(); |
| 1525 |
QString strPath = LocationFile->path(); |
| 1526 |
QString rename = ""; |
| 1527 |
rename = durlAndNameMap[QUrl(mount->getRootFile()->uri())]; |
| 1528 |
if ("" == rename) { |
| 1529 |
rename = mount->name(); |
| 1530 |
} |
| 1531 |
mountLoadStatus.clear(); |
| 1532 |
mountLoadStatus.insert(strPath, false); |
| 1533 |
//判断路径是否存在 |
| 1534 |
bool bFind = false; |
| 1535 |
QDir dir(strPath); |
| 1536 |
if (!dir.exists()) { |
| 1537 |
delete pListWidgetItem; |
| 1538 |
pListWidgetItem = nullptr; |
| 1539 |
qDebug() << "onLoadMountImagesStart() !dir.exists()"; |
| 1540 |
dApp->signalM->sigLoadMountImagesEnd(rename); |
| 1541 |
} else { |
| 1542 |
bFind = true; |
| 1543 |
} |
| 1544 |
//U盘和硬盘挂载都是/media下的,此处判断若path不包含/media/,在调用findPicturePathByPhone函数搜索DCIM文件目录 |
| 1545 |
if (!strPath.contains("/media/")) { |
| 1546 |
bFind = findPicturePathByPhone(strPath); |
| 1547 |
if (!bFind) { |
| 1548 |
qDebug() << "onLoadMountImagesStart() !bFind"; |
| 1549 |
dApp->signalM->sigLoadMountImagesEnd(rename); |
| 1550 |
} |
| 1551 |
} |
| 1552 |
if (pListWidgetItem) { |
| 1553 |
m_pLeftListView->m_pMountListWidget->addItem(pListWidgetItem); |
| 1554 |
pListWidgetItem->setData(Qt::UserRole, strPath); |
| 1555 |
pListWidgetItem->setData(Qt::UserRole + 1, rename); |
| 1556 |
qDebug() << "------" << __FUNCTION__ << "---strPath = " << strPath << " ---rename = " << rename; |
| 1557 |
QVariant value = QVariant::fromValue(mount); |
| 1558 |
pListWidgetItem->setData(Qt::UserRole + 2, value); |
| 1559 |
pListWidgetItem->setSizeHint(QSize(LEFT_VIEW_LISTITEM_WIDTH, LEFT_VIEW_LISTITEM_HEIGHT)); |
| 1560 |
AlbumLeftTabItem *pAlbumLeftTabItem; |
| 1561 |
|
| 1562 |
if (strPath.contains("/media/")) { |
| 1563 |
pAlbumLeftTabItem = new AlbumLeftTabItem(rename, ALBUM_PATHTYPE_BY_U); |
| 1564 |
} else { |
| 1565 |
pAlbumLeftTabItem = new AlbumLeftTabItem(rename, ALBUM_PATHTYPE_BY_PHONE); |
| 1566 |
} |
| 1567 |
|
| 1568 |
pAlbumLeftTabItem->setExternalDevicesMountPath(strPath); |
| 1569 |
connect(pAlbumLeftTabItem, &AlbumLeftTabItem::unMountExternalDevices, this, &AlbumView::onUnMountSignal); |
| 1570 |
if (!m_pLeftListView) { |
| 1571 |
return; |
| 1572 |
} |
| 1573 |
m_pLeftListView->m_pMountListWidget->setItemWidget(pListWidgetItem, pAlbumLeftTabItem); |
| 1574 |
if (m_itemClicked == true) { |
| 1575 |
m_pLeftListView->m_pMountListWidget->setCurrentItem(pListWidgetItem); |
| 1576 |
} |
| 1577 |
if (bFind) { |
| 1578 |
//todo |
| 1579 |
// ImageEngineApi::instance()->getImageFilesFromMount(rename, strPath, this); |
| 1580 |
} |
| 1581 |
} |
| 1582 |
#endif |
| 1583 |
} |
| 1584 |
} |
| 1585 |
|
| 1586 |
void AlbumView::updateExternalDevice(QExplicitlySharedDataPointer<DGioMount> mount, QString strPath) |
| 1587 |
{ |
| 1588 |
qDebug() << "------" << __FUNCTION__ << "---strPath = " << strPath; |
| 1589 |
QListWidgetItem *pListWidgetItem = new QListWidgetItem(m_pLeftListView->m_pMountListWidget, devType); |
| 1590 |
//pListWidgetItem缓存文件挂载路径 |
| 1591 |
if (pListWidgetItem) { |
| 1592 |
pListWidgetItem->setData(Qt::UserRole, strPath); |
| 1593 |
pListWidgetItem->setSizeHint(QSize(LEFT_VIEW_LISTITEM_WIDTH, LEFT_VIEW_LISTITEM_HEIGHT)); |
| 1594 |
} |
| 1595 |
AlbumLeftTabItem *pAlbumLeftTabItem; |
| 1596 |
QString rename = ""; |
| 1597 |
rename = durlAndNameMap[QUrl(mount->getRootFile()->uri())]; |
| 1598 |
if ("" == rename) { |
| 1599 |
rename = mount->name(); |
| 1600 |
} |
| 1601 |
if (pListWidgetItem) { |
| 1602 |
pListWidgetItem->setData(Qt::UserRole + 1, rename); |
| 1603 |
QVariant value = QVariant::fromValue(mount); |
| 1604 |
pListWidgetItem->setData(Qt::UserRole + 2, value); |
| 1605 |
} |
| 1606 |
if (strPath.contains("/media/")) { |
| 1607 |
pAlbumLeftTabItem = new AlbumLeftTabItem(rename, ALBUM_PATHTYPE_BY_U); |
| 1608 |
} else { |
| 1609 |
pAlbumLeftTabItem = new AlbumLeftTabItem(rename, ALBUM_PATHTYPE_BY_PHONE); |
| 1610 |
} |
| 1611 |
pAlbumLeftTabItem->setExternalDevicesMountPath(strPath); |
| 1612 |
pAlbumLeftTabItem->oriAlbumStatus(); |
| 1613 |
connect(pAlbumLeftTabItem, &AlbumLeftTabItem::unMountExternalDevices, this, &AlbumView::onUnMountSignal); |
| 1614 |
if (!m_pLeftListView) { |
| 1615 |
return; |
| 1616 |
} |
| 1617 |
m_itemClicked = true; |
| 1618 |
if (pListWidgetItem) { |
| 1619 |
m_pLeftListView->m_pMountListWidget->addItem(pListWidgetItem); |
| 1620 |
m_pLeftListView->m_pMountListWidget->setItemWidget(pListWidgetItem, pAlbumLeftTabItem); |
| 1621 |
m_pLeftListView->m_pMountListWidget->setCurrentItem(pListWidgetItem); |
| 1622 |
// 设置当前的相册名及类型,正确跳转其他页面 |
| 1623 |
m_currentAlbum = rename; |
| 1624 |
m_currentType = AblumType::devType; |
| 1625 |
} |
| 1626 |
//右侧视图同时切换 |
| 1627 |
m_pRightPhoneThumbnailList->stopLoadAndClear(true); //清除已有数据 |
| 1628 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_PHONE); |
| 1629 |
m_pStatusBar->setVisible(true); |
| 1630 |
m_mounts = getVfsMountList(); |
| 1631 |
} |
| 1632 |
|
| 1633 |
void AlbumView::onUpdataAlbumRightTitle(const QString &titlename) |
| 1634 |
{ |
| 1635 |
m_currentAlbum = titlename; |
| 1636 |
updateRightView(); |
| 1637 |
} |
| 1638 |
|
| 1639 |
void AlbumView::SearchReturnUpdate() |
| 1640 |
{ |
| 1641 |
if (RIGHT_VIEW_SEARCH == m_pRightStackWidget->currentIndex()) { |
| 1642 |
if (COMMON_STR_TRASH == m_currentAlbum) { |
| 1643 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_TRASH_LIST); |
| 1644 |
//最近删除内没有图片,隐藏批量处理按钮 |
| 1645 |
DBImgInfoList infos = DBManager::instance()->getAllTrashInfos(); |
| 1646 |
m_trashBatchOperateWidget->setVisible(infos.size() > 0); |
| 1647 |
} else if (COMMON_STR_FAVORITES == m_currentAlbum) { |
| 1648 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_FAVORITE_LIST); |
| 1649 |
DBImgInfoList infos = DBManager::instance()->getInfosByAlbum(m_currentAlbum, AlbumDBType::Favourite); |
| 1650 |
//收藏内没有图片,隐藏批量处理按钮 |
| 1651 |
m_FavoriteTitleWidget->setVisible(infos.size() > 0); |
| 1652 |
} else if (COMMON_STR_RECENT_IMPORTED == m_currentAlbum) { |
| 1653 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_TIMELINE_IMPORT); |
| 1654 |
} else { |
| 1655 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_THUMBNAIL_LIST); |
| 1656 |
//更新搜索结果为空,清除搜索界面没有切换到初始状态 xiaolong 2020/05/22 |
| 1657 |
updateRightCustomAlbumView(); |
| 1658 |
} |
| 1659 |
m_pStatusBar->setVisible(true); |
| 1660 |
} |
| 1661 |
} |
| 1662 |
|
| 1663 |
//搜索手机中存储相机照片文件的路径,采用两级文件目录深度,找"DCIM"文件目录 |
| 1664 |
//经过调研,安卓手机在path/外部存储设备/DCIM下,iPhone在patn/DCIM下 |
| 1665 |
bool AlbumView::findPicturePathByPhone(QString &path) |
| 1666 |
{ |
| 1667 |
QDir dir(path); |
| 1668 |
if (!dir.exists()) return false; |
| 1669 |
QFileInfoList fileInfoList = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); |
| 1670 |
QFileInfo tempFileInfo; |
| 1671 |
foreach (tempFileInfo, fileInfoList) { |
| 1672 |
//针对ptp模式 |
| 1673 |
if (tempFileInfo.fileName().compare(ALBUM_PATHNAME_BY_PHONE) == 0) { |
| 1674 |
path = tempFileInfo.absoluteFilePath(); |
| 1675 |
return true; |
| 1676 |
} else { //针对MTP模式 |
| 1677 |
// return true; |
| 1678 |
QDir subDir; |
| 1679 |
subDir.setPath(tempFileInfo.absoluteFilePath()); |
| 1680 |
QFileInfoList subFileInfoList = subDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot); |
| 1681 |
QFileInfo subTempFileInfo; |
| 1682 |
foreach (subTempFileInfo, subFileInfoList) { |
| 1683 |
if (subTempFileInfo.fileName().compare(ALBUM_PATHNAME_BY_PHONE) == 0) { |
| 1684 |
path = subTempFileInfo.absoluteFilePath(); |
| 1685 |
return true; |
| 1686 |
} |
| 1687 |
} |
| 1688 |
} |
| 1689 |
} |
| 1690 |
return false; |
| 1691 |
} |
| 1692 |
|
| 1693 |
void AlbumView::updateImportComboBox() |
| 1694 |
{ |
| 1695 |
m_importByPhoneComboBox->clear(); |
| 1696 |
m_importByPhoneComboBox->addItem(tr("Gallery")); |
| 1697 |
m_importByPhoneComboBox->addItem(tr("New album")); |
| 1698 |
QStringList allAlbumNames = DBManager::instance()->getAllAlbumNames(); |
| 1699 |
for (auto albumName : allAlbumNames) { |
| 1700 |
m_importByPhoneComboBox->addItem(albumName); |
| 1701 |
} |
| 1702 |
m_importByPhoneComboBox->setCurrentText(tr("Gallery")); //默认选中 |
| 1703 |
} |
| 1704 |
|
| 1705 |
//手机照片全部导入 |
| 1706 |
void AlbumView::importAllBtnClicked() |
| 1707 |
{ |
| 1708 |
QStringList allPaths = m_pRightPhoneThumbnailList->getFileList(); |
| 1709 |
QString albumNameStr = m_importByPhoneComboBox->currentText(); |
| 1710 |
if (m_importByPhoneComboBox->currentIndex() == 0) |
| 1711 |
albumNameStr = ""; |
| 1712 |
ImageEngineApi::instance()->importImageFilesFromMount(albumNameStr, allPaths, this); |
| 1713 |
for (int i = 0; i < m_pLeftListView->m_pMountListWidget->count(); i++) { |
| 1714 |
QListWidgetItem *pListWidgetItem = m_pLeftListView->m_pMountListWidget->item(i); |
| 1715 |
AlbumLeftTabItem *pAlbumLeftTabItem = dynamic_cast<AlbumLeftTabItem *>(m_pLeftListView->m_pMountListWidget->itemWidget(pListWidgetItem)); |
| 1716 |
if (!pAlbumLeftTabItem) continue; |
| 1717 |
if (albumNameStr == pAlbumLeftTabItem->m_albumNameStr) { |
| 1718 |
m_pLeftListView->m_pMountListWidget->setCurrentRow(i); |
| 1719 |
break; |
| 1720 |
} |
| 1721 |
} |
| 1722 |
} |
| 1723 |
|
| 1724 |
//手机照片导入选中 |
| 1725 |
void AlbumView::importSelectBtnClicked() |
| 1726 |
{ |
| 1727 |
QStringList selectPaths = m_pRightPhoneThumbnailList->selectedPaths(); |
| 1728 |
QString albumNameStr = m_importByPhoneComboBox->currentText(); |
| 1729 |
if (m_importByPhoneComboBox->currentIndex() == 0) |
| 1730 |
albumNameStr = ""; |
| 1731 |
ImageEngineApi::instance()->importImageFilesFromMount(albumNameStr, selectPaths, this); |
| 1732 |
for (int i = 0; i < m_pLeftListView->m_pMountListWidget->count(); i++) { |
| 1733 |
QListWidgetItem *pListWidgetItem = m_pLeftListView->m_pMountListWidget->item(i); |
| 1734 |
AlbumLeftTabItem *pAlbumLeftTabItem = dynamic_cast<AlbumLeftTabItem *>(m_pLeftListView->m_pMountListWidget->itemWidget(pListWidgetItem)); |
| 1735 |
if (!pAlbumLeftTabItem) continue; |
| 1736 |
if (albumNameStr == pAlbumLeftTabItem->m_albumNameStr) { |
| 1737 |
m_pLeftListView->m_pMountListWidget->setCurrentRow(i); |
| 1738 |
break; |
| 1739 |
} |
| 1740 |
} |
| 1741 |
} |
| 1742 |
|
| 1743 |
bool AlbumView::imageMountImported(QStringList &filelist) |
| 1744 |
{ |
| 1745 |
Q_UNUSED(filelist); |
| 1746 |
emit dApp->signalM->closeWaitDialog(); |
| 1747 |
return true; |
| 1748 |
} |
| 1749 |
|
| 1750 |
void AlbumView::needUnMount(const QString &path) |
| 1751 |
{ |
| 1752 |
QStringList blDevList = DDiskManager::blockDevices(QVariantMap()); |
| 1753 |
qDebug() << "blDevList:" << blDevList; |
| 1754 |
QSharedPointer<DBlockDevice> blkget; |
| 1755 |
QString mountPoint = ""; |
| 1756 |
for (const QString &blks : blDevList) { |
| 1757 |
QSharedPointer<DBlockDevice> blk(DDiskManager::createBlockDevice(blks)); |
| 1758 |
QScopedPointer<DDiskDevice> drv(DDiskManager::createDiskDevice(blk->drive())); |
| 1759 |
if (!blk->hasFileSystem() && !drv->mediaCompatibility().join(" ").contains("optical") && !blk->isEncrypted()) { |
| 1760 |
continue; |
| 1761 |
} |
| 1762 |
if ((blk->hintIgnore() && !blk->isEncrypted()) || blk->cryptoBackingDevice().length() > 1) { |
| 1763 |
continue; |
| 1764 |
} |
| 1765 |
QByteArrayList qbl = blk->mountPoints(); |
| 1766 |
mountPoint = "file://"; |
| 1767 |
QList<QByteArray>::iterator qb = qbl.begin(); |
| 1768 |
while (qb != qbl.end()) { |
| 1769 |
mountPoint += (*qb); |
| 1770 |
++qb; |
| 1771 |
} |
| 1772 |
if (mountPoint.contains(path, Qt::CaseSensitive)) { |
| 1773 |
blkget = blk; |
| 1774 |
break; |
| 1775 |
} else { |
| 1776 |
mountPoint = ""; |
| 1777 |
} |
| 1778 |
} |
| 1779 |
if (m_waitDeviceScandialog) { |
| 1780 |
m_waitDeviceScandialog->close(); |
| 1781 |
} |
| 1782 |
for (int i = 0; i < m_pLeftListView->m_pMountListWidget->count(); i++) { |
| 1783 |
QListWidgetItem *pListWidgetItem = m_pLeftListView->m_pMountListWidget->item(i); |
| 1784 |
if (!pListWidgetItem) |
| 1785 |
continue; |
| 1786 |
QExplicitlySharedDataPointer<DGioMount> mount = |
| 1787 |
qvariant_cast<QExplicitlySharedDataPointer<DGioMount>>(pListWidgetItem->data(Qt::UserRole + 2)); |
| 1788 |
QString strPath = mount->getDefaultLocationFile()->path(); |
| 1789 |
if (!strPath.contains("/media/")) { |
| 1790 |
findPicturePathByPhone(strPath); |
| 1791 |
} |
| 1792 |
if (strPath == path) { |
| 1793 |
if (1 < m_pLeftListView->m_pMountListWidget->count()) { |
| 1794 |
QWidget *wdg = m_pLeftListView->m_pMountListWidget->itemWidget(pListWidgetItem); |
| 1795 |
m_pLeftListView->m_pMountListWidget->removeItemWidget(pListWidgetItem); |
| 1796 |
wdg->deleteLater(); |
| 1797 |
m_pLeftListView->m_pMountListWidget->takeItem(m_pLeftListView->m_pMountListWidget->row(pListWidgetItem)); |
| 1798 |
delete pListWidgetItem; |
| 1799 |
} else { |
| 1800 |
m_pLeftListView->m_pMountListWidget->clear(); |
| 1801 |
m_pLeftListView->updatePhotoListView(); |
| 1802 |
} |
| 1803 |
emit dApp->signalM->sigDevStop(strPath); |
| 1804 |
m_phoneNameAndPathlist.remove(strPath); |
| 1805 |
QUrl qurl(mount->getRootFile()->uri()); |
| 1806 |
durlAndNameMap.erase(durlAndNameMap.find(qurl)); |
| 1807 |
|
| 1808 |
QExplicitlySharedDataPointer<DGioFile> LocationFile = mount->getDefaultLocationFile(); |
| 1809 |
if (LocationFile->path().compare(path) == 0 && mount->canUnmount() && !blkget.isNull()) { //增加blkget为空判断,某些情况下卸载设备会导致程序闪退 |
| 1810 |
QScopedPointer<DDiskDevice> drv(DDiskManager::createDiskDevice(blkget->drive())); |
| 1811 |
QScopedPointer<DBlockDevice> cbblk(DDiskManager::createBlockDevice(blkget->cryptoBackingDevice())); |
| 1812 |
bool err = false; |
| 1813 |
if (!blkget->mountPoints().empty()) { |
| 1814 |
blkget->unmount({}); |
| 1815 |
err |= blkget->lastError().isValid(); |
| 1816 |
} |
| 1817 |
if (blkget->cryptoBackingDevice().length() > 1) { |
| 1818 |
cbblk->lock({}); |
| 1819 |
err |= cbblk->lastError().isValid(); |
| 1820 |
drv.reset(DDiskManager::createDiskDevice(cbblk->drive())); |
| 1821 |
} |
| 1822 |
drv->powerOff({}); |
| 1823 |
err |= drv->lastError().isValid(); |
| 1824 |
if (err) { |
| 1825 |
DDialog msgbox(this); |
| 1826 |
msgbox.setFixedWidth(400); |
| 1827 |
msgbox.setIcon(DMessageBox::standardIcon(DMessageBox::Critical)); |
| 1828 |
msgbox.setTextFormat(Qt::AutoText); |
| 1829 |
msgbox.setMessage(tr("Disk is busy, cannot eject now")); |
| 1830 |
msgbox.insertButton(1, tr("OK"), false, DDialog::ButtonNormal); |
| 1831 |
auto ret = msgbox.exec(); |
| 1832 |
Q_UNUSED(ret); |
| 1833 |
return; |
| 1834 |
} |
| 1835 |
break; |
| 1836 |
} |
| 1837 |
break; |
| 1838 |
} |
| 1839 |
} |
| 1840 |
m_mounts = getVfsMountList(); |
| 1841 |
updateDeviceLeftList(); |
| 1842 |
} |
| 1843 |
|
| 1844 |
//卸载外部设备 |
| 1845 |
void AlbumView::onUnMountSignal(const QString &unMountPath) |
| 1846 |
{ |
| 1847 |
m_pRightPhoneThumbnailList->stopLoadAndClear(); |
| 1848 |
needUnMount(unMountPath); |
| 1849 |
} |
| 1850 |
|
| 1851 |
void AlbumView::onLeftListDropEvent(QModelIndex dropIndex) |
| 1852 |
{ |
| 1853 |
qDebug() << "AlbumView::onLeftListDropEvent()"; |
| 1854 |
ThumbnailListView *currentViewList; |
| 1855 |
QStringList dropItemPaths; |
| 1856 |
AlbumLeftTabItem *item = dynamic_cast<AlbumLeftTabItem *>(m_pLeftListView->m_pCustomizeListView->itemWidget(m_pLeftListView->m_pCustomizeListView->item(dropIndex.row()))); |
| 1857 |
QString dropLeftTabListName = item->m_albumNameStr; |
| 1858 |
qDebug() << "currentAlbum: " << m_currentAlbum << " ;dropLeftTabListName: " << dropLeftTabListName; |
| 1859 |
//向自己的相册或“已导入”相册拖拽无效 |
| 1860 |
//“已导入”相册在leftlistwidget.cpp中也屏蔽过 |
| 1861 |
if (COMMON_STR_FAVORITES == m_currentAlbum) { |
| 1862 |
currentViewList = m_favoriteThumbnailList; |
| 1863 |
dropItemPaths = currentViewList->getDagItemPath(); |
| 1864 |
} else if (COMMON_STR_TRASH == m_currentAlbum) { |
| 1865 |
currentViewList = m_pRightTrashThumbnailList; |
| 1866 |
dropItemPaths = currentViewList->getDagItemPath(); |
| 1867 |
} else if (COMMON_STR_RECENT_IMPORTED == m_currentAlbum) { |
| 1868 |
dropItemPaths = m_pImpTimeLineView->selectPaths(); |
| 1869 |
} else { |
| 1870 |
currentViewList = m_customThumbnailList; |
| 1871 |
dropItemPaths = currentViewList->getDagItemPath(); |
| 1872 |
} |
| 1873 |
qDebug() << "dropItemPaths: " << dropItemPaths; |
| 1874 |
//向其他相册拖拽,动作添加 |
| 1875 |
DBManager::instance()->insertIntoAlbum(item->m_albumNameStr, dropItemPaths); |
| 1876 |
//LMH0509,为了解决24887 【相册】【5.6.9.13】拖动已导入相册中的图片到新建相册,相册崩溃 |
| 1877 |
QModelIndex index; |
| 1878 |
emit m_pLeftListView->m_pCustomizeListView->pressed(index); |
| 1879 |
m_pLeftListView->m_pCustomizeListView->setCurrentRow(dropIndex.row()); |
| 1880 |
} |
| 1881 |
|
| 1882 |
void AlbumView::updatePicNum() |
| 1883 |
{ |
| 1884 |
int photoSelctCount = 0; |
| 1885 |
int videoSelctCount = 0; |
| 1886 |
if (RIGHT_VIEW_SEARCH == m_pRightStackWidget->currentIndex()) { |
| 1887 |
photoSelctCount = m_pSearchView->m_pThumbnailListView->getAppointTypeSelectItemCount(ItemTypePic); |
| 1888 |
videoSelctCount = m_pSearchView->m_pThumbnailListView->getAppointTypeSelectItemCount(ItemTypeVideo); |
| 1889 |
} else { |
| 1890 |
if (m_currentAlbum == COMMON_STR_TRASH) { |
| 1891 |
photoSelctCount = m_pRightTrashThumbnailList->getAppointTypeSelectItemCount(ItemTypePic); |
| 1892 |
videoSelctCount = m_pRightTrashThumbnailList->getAppointTypeSelectItemCount(ItemTypeVideo); |
| 1893 |
} else if (m_currentAlbum == COMMON_STR_FAVORITES) { |
| 1894 |
photoSelctCount = m_favoriteThumbnailList->getAppointTypeSelectItemCount(ItemTypePic); |
| 1895 |
videoSelctCount = m_favoriteThumbnailList->getAppointTypeSelectItemCount(ItemTypeVideo); |
| 1896 |
} else if (m_currentAlbum == COMMON_STR_RECENT_IMPORTED) { |
| 1897 |
photoSelctCount = m_pImpTimeLineView->getListView()->getAppointTypeSelectItemCount(ItemTypePic); |
| 1898 |
videoSelctCount = m_pImpTimeLineView->getListView()->getAppointTypeSelectItemCount(ItemTypeVideo); |
| 1899 |
} else if (RIGHT_VIEW_PHONE == m_pRightStackWidget->currentIndex()) { |
| 1900 |
photoSelctCount = m_pRightPhoneThumbnailList->getAppointTypeSelectItemCount(ItemTypePic); |
| 1901 |
videoSelctCount = m_pRightPhoneThumbnailList->getAppointTypeSelectItemCount(ItemTypeVideo); |
| 1902 |
} else { |
| 1903 |
photoSelctCount = m_customThumbnailList->getAppointTypeSelectItemCount(ItemTypePic); |
| 1904 |
videoSelctCount = m_customThumbnailList->getAppointTypeSelectItemCount(ItemTypeVideo); |
| 1905 |
} |
| 1906 |
} |
| 1907 |
|
| 1908 |
if (photoSelctCount > 0 || videoSelctCount > 0) { |
| 1909 |
m_pStatusBar->resetSelectedStatue(photoSelctCount, videoSelctCount); |
| 1910 |
} else { |
| 1911 |
restorePicNum(); |
| 1912 |
} |
| 1913 |
} |
| 1914 |
|
| 1915 |
void AlbumView::restorePicNum() |
| 1916 |
{ |
| 1917 |
int photoCount = 0; |
| 1918 |
int videoCount = 0; |
| 1919 |
if (4 == m_pRightStackWidget->currentIndex()) { |
| 1920 |
photoCount = m_pSearchView->m_pThumbnailListView->getAppointTypeItemCount(ItemTypePic); |
| 1921 |
videoCount = m_pSearchView->m_pThumbnailListView->getAppointTypeItemCount(ItemTypeVideo); |
| 1922 |
} else { |
| 1923 |
if (COMMON_STR_RECENT_IMPORTED == m_currentAlbum) { |
| 1924 |
photoCount = m_pImpTimeLineView->getListView()->getAppointTypeItemCount(ItemTypePic); |
| 1925 |
videoCount = m_pImpTimeLineView->getListView()->getAppointTypeItemCount(ItemTypeVideo); |
| 1926 |
} else if (COMMON_STR_TRASH == m_currentAlbum) { |
| 1927 |
photoCount = m_pRightTrashThumbnailList->getAppointTypeItemCount(ItemTypePic); |
| 1928 |
videoCount = m_pRightTrashThumbnailList->getAppointTypeItemCount(ItemTypeVideo); |
| 1929 |
} else if (COMMON_STR_FAVORITES == m_currentAlbum) { |
| 1930 |
photoCount = m_favoriteThumbnailList->getAppointTypeItemCount(ItemTypePic); |
| 1931 |
videoCount = m_favoriteThumbnailList->getAppointTypeItemCount(ItemTypeVideo); |
| 1932 |
} else if (RIGHT_VIEW_PHONE == m_pRightStackWidget->currentIndex()) { |
| 1933 |
photoCount = m_pRightPhoneThumbnailList->getAppointTypeItemCount(ItemTypePic); |
| 1934 |
videoCount = m_pRightPhoneThumbnailList->getAppointTypeItemCount(ItemTypeVideo); |
| 1935 |
} else { |
| 1936 |
photoCount = m_customThumbnailList->getAppointTypeItemCount(ItemTypePic); |
| 1937 |
videoCount = m_customThumbnailList->getAppointTypeItemCount(ItemTypeVideo); |
| 1938 |
} |
| 1939 |
} |
| 1940 |
if ((photoCount + videoCount) <= 0) { |
| 1941 |
m_pStatusBar->setVisible(false); |
| 1942 |
} else { |
| 1943 |
m_pStatusBar->setVisible(true); |
| 1944 |
} |
| 1945 |
|
| 1946 |
m_pStatusBar->resetUnselectedStatue(photoCount, videoCount); |
| 1947 |
} |
| 1948 |
|
| 1949 |
void AlbumView::paintEvent(QPaintEvent *event) |
| 1950 |
{ |
| 1951 |
QWidget::paintEvent(event); |
| 1952 |
if (nullptr != pPhoneWidget) { |
| 1953 |
phonetopwidget->setFixedWidth(pPhoneWidget->width() - 15);//BUG#93779 -15把右侧滚动条露出来 |
| 1954 |
} |
| 1955 |
} |
| 1956 |
|
| 1957 |
void AlbumView::importDialog() |
| 1958 |
{ |
| 1959 |
//导入取消窗口 |
| 1960 |
m_waitDeviceScandialog->show(); |
| 1961 |
m_waitDailog_timer->start(2000); |
| 1962 |
this->setDisabled(true); |
| 1963 |
m_waitDeviceScandialog->setEnabled(true); |
| 1964 |
} |
| 1965 |
|
| 1966 |
void AlbumView::onWaitDialogClose() |
| 1967 |
{ |
| 1968 |
//响应关闭事件,直接关闭线程 |
| 1969 |
ImageEngineApi::instance()->setThreadShouldStop(); |
| 1970 |
m_waitDeviceScandialog->close(); |
| 1971 |
this->setEnabled(true); |
| 1972 |
} |
| 1973 |
|
| 1974 |
void AlbumView::onWaitDialogIgnore() |
| 1975 |
{ |
| 1976 |
isIgnore = false; |
| 1977 |
m_waitDeviceScandialog->hide(); |
| 1978 |
this->setEnabled(true); |
| 1979 |
} |
| 1980 |
|
| 1981 |
void AlbumView::onRepeatImportingTheSamePhotos(QStringList importPaths, QStringList duplicatePaths, const QString &albumName) |
| 1982 |
{ |
| 1983 |
Q_UNUSED(importPaths) |
| 1984 |
if (m_currentAlbum == albumName && dApp->getMainWindow()->getCurrentViewType() == 2) { |
| 1985 |
m_customThumbnailList->selectDuplicatePhotos(duplicatePaths); |
| 1986 |
} |
| 1987 |
} |
| 1988 |
|
| 1989 |
void AlbumView::ongMouseMove() |
| 1990 |
{ |
| 1991 |
updatePicNum(); |
| 1992 |
} |
| 1993 |
|
| 1994 |
void AlbumView::onSelectAll() |
| 1995 |
{ |
| 1996 |
updatePicNum(); |
| 1997 |
} |
| 1998 |
|
| 1999 |
void AlbumView::onInsertedIntoAlbum(const QString &albumname, QStringList pathlist) |
| 2000 |
{ |
| 2001 |
qDebug() << "添加到目的相册:" << albumname; |
| 2002 |
Q_UNUSED(pathlist); |
| 2003 |
if (m_currentAlbum != albumname) { |
| 2004 |
return; |
| 2005 |
} |
| 2006 |
if (m_currentType == COMMON_STR_CUSTOM) //如果需要更新的为当前界面 |
| 2007 |
updateRightView(); |
| 2008 |
} |
| 2009 |
|
| 2010 |
void AlbumView::onFileSystemAdded(const QString &dbusPath) |
| 2011 |
{ |
| 2012 |
DBlockDevice *blDev = DDiskManager::createBlockDevice(dbusPath); |
| 2013 |
blDev->mount({}); |
| 2014 |
} |
| 2015 |
|
| 2016 |
void AlbumView::onBlockDeviceAdded(const QString &blks) |
| 2017 |
{ |
| 2018 |
QSharedPointer<DBlockDevice> blk(DDiskManager::createBlockDevice(blks)); |
| 2019 |
QScopedPointer<DDiskDevice> drv1(DDiskManager::createDiskDevice(blk->drive())); |
| 2020 |
if (!blk->hasFileSystem() && !drv1->mediaCompatibility().join(" ").contains("optical") && !blk->isEncrypted()) { |
| 2021 |
return; |
| 2022 |
} |
| 2023 |
if ((blk->hintIgnore() && !blk->isEncrypted()) || blk->cryptoBackingDevice().length() > 1) { |
| 2024 |
return; |
| 2025 |
} |
| 2026 |
DBlockDevice *pblk = blk.data(); |
| 2027 |
QByteArrayList mps = blk->mountPoints(); |
| 2028 |
qulonglong size = blk->size(); |
| 2029 |
QString label = blk->idLabel(); |
| 2030 |
QString fs = blk->idType(); |
| 2031 |
QString udispname = ""; |
| 2032 |
if (label.startsWith(ddeI18nSym)) { |
| 2033 |
QString i18nKey = label.mid(ddeI18nSym.size(), label.size() - ddeI18nSym.size()); |
| 2034 |
udispname = qApp->translate("DeepinStorage", i18nMap.value(i18nKey, i18nKey.toUtf8().constData())); |
| 2035 |
goto runend; |
| 2036 |
} |
| 2037 |
|
| 2038 |
if (mps.contains(QByteArray("/\0", 2))) { |
| 2039 |
udispname = QCoreApplication::translate("PathManager", "System Disk"); |
| 2040 |
goto runend; |
| 2041 |
} |
| 2042 |
if (label.length() == 0) { |
| 2043 |
QScopedPointer<DDiskDevice> drv(DDiskManager::createDiskDevice(pblk->drive())); |
| 2044 |
if (!drv->mediaAvailable() && drv->mediaCompatibility().join(" ").contains("optical")) { |
| 2045 |
QString maxmediacompat; |
| 2046 |
for (auto i = opticalmediakv.rbegin(); i != opticalmediakv.rend(); ++i) { |
| 2047 |
if (drv->mediaCompatibility().contains(i->first)) { |
| 2048 |
maxmediacompat = i->second; |
| 2049 |
break; |
| 2050 |
} |
| 2051 |
} |
| 2052 |
udispname = QCoreApplication::translate("DeepinStorage", "%1 Drive").arg(maxmediacompat); |
| 2053 |
goto runend; |
| 2054 |
} |
| 2055 |
if (drv->opticalBlank()) { |
| 2056 |
udispname = QCoreApplication::translate("DeepinStorage", "Blank %1 Disc").arg(opticalmediamap[drv->media()]); |
| 2057 |
goto runend; |
| 2058 |
} |
| 2059 |
if (pblk->isEncrypted() && !blk) { |
| 2060 |
udispname = QCoreApplication::translate("DeepinStorage", "%1 Encrypted").arg(formatSize(qint64(size))); |
| 2061 |
goto runend; |
| 2062 |
} |
| 2063 |
udispname = QCoreApplication::translate("DeepinStorage", "%1 Volume").arg(formatSize(qint64(size))); |
| 2064 |
goto runend; |
| 2065 |
} |
| 2066 |
udispname = label; |
| 2067 |
|
| 2068 |
runend: |
| 2069 |
blk->mount({}); |
| 2070 |
QByteArrayList qbl = blk->mountPoints(); |
| 2071 |
QString mountPoint = "file://"; |
| 2072 |
QList<QByteArray>::iterator qb = qbl.begin(); |
| 2073 |
while (qb != qbl.end()) { |
| 2074 |
mountPoint += (*qb); |
| 2075 |
++qb; |
| 2076 |
} |
| 2077 |
QUrl qurl(mountPoint); |
| 2078 |
durlAndNameMap[qurl] = udispname; |
| 2079 |
return; |
| 2080 |
} |
| 2081 |
|
| 2082 |
void AlbumView::onThemeTypeChanged(DGuiApplicationHelper::ColorType themeType) |
| 2083 |
{ |
| 2084 |
//add start 3975 |
| 2085 |
DPalette palcolor = DApplicationHelper::instance()->palette(m_pCustomAlbumWidget); |
| 2086 |
palcolor.setBrush(DPalette::Base, palcolor.color(DPalette::Window)); |
| 2087 |
m_pCustomAlbumWidget->setPalette(palcolor); |
| 2088 |
|
| 2089 |
DPalette ppal_light = DApplicationHelper::instance()->palette(m_customAlbumTitle); |
| 2090 |
ppal_light.setBrush(DPalette::Background, ppal_light.color(DPalette::Base)); |
| 2091 |
m_customAlbumTitle->setPalette(ppal_light); |
| 2092 |
|
| 2093 |
DPalette palcolor2 = DApplicationHelper::instance()->palette(m_pFavoriteWidget); |
| 2094 |
palcolor2.setBrush(DPalette::Base, palcolor2.color(DPalette::Window)); |
| 2095 |
m_pFavoriteWidget->setPalette(palcolor2); |
| 2096 |
|
| 2097 |
DPalette ppal_light2 = DApplicationHelper::instance()->palette(m_FavoriteTitleWidget); |
| 2098 |
ppal_light2.setBrush(DPalette::Background, ppal_light2.color(DPalette::Base)); |
| 2099 |
m_FavoriteTitleWidget->setPalette(ppal_light2); |
| 2100 |
|
| 2101 |
DPalette palcolor3 = DApplicationHelper::instance()->palette(m_pTrashWidget); |
| 2102 |
palcolor3.setBrush(DPalette::Base, palcolor3.color(DPalette::Window)); |
| 2103 |
m_pTrashWidget->setPalette(palcolor3); |
| 2104 |
|
| 2105 |
DPalette ppal_light3 = DApplicationHelper::instance()->palette(m_TrashTitleWidget); |
| 2106 |
ppal_light3.setBrush(DPalette::Background, ppal_light3.color(DPalette::Base)); |
| 2107 |
m_TrashTitleWidget->setPalette(ppal_light3); |
| 2108 |
//add end 3975 |
| 2109 |
|
| 2110 |
DPalette pal = DApplicationHelper::instance()->palette(m_pFavoritePicTotal); |
| 2111 |
QColor color_BT = pal.color(DPalette::BrightText); |
| 2112 |
if (themeType == DGuiApplicationHelper::LightType) { |
| 2113 |
color_BT.setAlphaF(0.5); |
| 2114 |
pal.setBrush(DPalette::Text, color_BT); |
| 2115 |
} else if (themeType == DGuiApplicationHelper::DarkType) { |
| 2116 |
color_BT.setAlphaF(0.75); |
| 2117 |
pal.setBrush(DPalette::Text, color_BT); |
| 2118 |
} |
| 2119 |
m_pFavoritePicTotal->setForegroundRole(DPalette::Text); |
| 2120 |
m_pFavoritePicTotal->setPalette(pal); |
| 2121 |
m_pRightPicTotal->setForegroundRole(DPalette::Text); |
| 2122 |
m_pRightPicTotal->setPalette(pal); |
| 2123 |
m_TrashDescritionLab->setForegroundRole(DPalette::Text); |
| 2124 |
m_TrashDescritionLab->setPalette(pal); |
| 2125 |
// 设备相册界面标题 |
| 2126 |
DPalette phonePal = DApplicationHelper::instance()->palette(m_pPhonePicTotal); |
| 2127 |
QColor phone_Color_BT = phonePal.color(DPalette::BrightText); |
| 2128 |
if (themeType == DGuiApplicationHelper::LightType) { |
| 2129 |
phone_Color_BT.setAlphaF(0.5); |
| 2130 |
phonePal.setBrush(DPalette::Text, phone_Color_BT); |
| 2131 |
} else if (themeType == DGuiApplicationHelper::DarkType) { |
| 2132 |
phone_Color_BT.setAlphaF(0.75); |
| 2133 |
phonePal.setBrush(DPalette::Text, phone_Color_BT); |
| 2134 |
} |
| 2135 |
m_pPhonePicTotal->setForegroundRole(DPalette::Text); |
| 2136 |
m_pPhonePicTotal->setPalette(phonePal); |
| 2137 |
} |
| 2138 |
|
| 2139 |
void AlbumView::onRightPhoneCustomContextMenuRequested() |
| 2140 |
{ |
| 2141 |
QStringList paths = m_pRightPhoneThumbnailList->selectedPaths(); |
| 2142 |
if (0 < paths.length()) { |
| 2143 |
m_importSelectByPhoneBtn->setEnabled(true); |
| 2144 |
} else { |
| 2145 |
m_importSelectByPhoneBtn->setEnabled(false); |
| 2146 |
} |
| 2147 |
|
| 2148 |
updatePicNum(); |
| 2149 |
} |
| 2150 |
|
| 2151 |
void AlbumView::onRightPhoneThumbnailListMouseRelease() |
| 2152 |
{ |
| 2153 |
QStringList paths = m_pRightPhoneThumbnailList->selectedPaths(); |
| 2154 |
if (0 < paths.length()) { |
| 2155 |
m_importSelectByPhoneBtn->setEnabled(true); |
| 2156 |
} else { |
| 2157 |
m_importSelectByPhoneBtn->setEnabled(false); |
| 2158 |
} |
| 2159 |
|
| 2160 |
updatePicNum(); |
| 2161 |
} |
| 2162 |
|
| 2163 |
void AlbumView::onImportViewImportBtnClicked() |
| 2164 |
{ |
| 2165 |
m_customAlbumTitleLabel->setVisible(false); |
| 2166 |
m_pRightPicTotal->setVisible(false); |
| 2167 |
emit dApp->signalM->startImprot(); |
| 2168 |
m_pImportView->onImprotBtnClicked(); |
| 2169 |
} |
| 2170 |
|
| 2171 |
void AlbumView::onImportFailedToView() |
| 2172 |
{ |
| 2173 |
if (isVisible()) { |
| 2174 |
m_spinner->hide(); |
| 2175 |
m_spinner->stop(); |
| 2176 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_IMPORT); |
| 2177 |
m_pStatusBar->setVisible(false); |
| 2178 |
} |
| 2179 |
} |
| 2180 |
|
| 2181 |
void AlbumView::onWaitDailogTimeout() |
| 2182 |
{ |
| 2183 |
m_waitDeviceScandialog->m_ignoreDeviceScan->setEnabled(true); |
| 2184 |
m_waitDeviceScandialog->m_closeDeviceScan->setEnabled(true); |
| 2185 |
m_waitDailog_timer->stop(); |
| 2186 |
} |
| 2187 |
|
| 2188 |
void AlbumView::onLeftListViewMountListWidgetClicked(const QModelIndex &index) |
| 2189 |
{ |
| 2190 |
Q_UNUSED(index); |
| 2191 |
return; |
| 2192 |
// m_pRightPhoneThumbnailList->stopLoadAndClear(false); |
| 2193 |
// m_pLeftListView->setFocus(); |
| 2194 |
// qDebug() << "------" << __FUNCTION__ << ""; |
| 2195 |
// updateRightView(); |
| 2196 |
} |
| 2197 |
|
| 2198 |
void AlbumView::sltLoadMountFileList(const QString &path, QStringList fileList) |
| 2199 |
{ |
| 2200 |
//线程已处理完成数据,通知等待窗口计时自动隐藏 |
| 2201 |
QTimer::singleShot(1500, this, [ = ] { |
| 2202 |
m_waitDeviceScandialog->close(); |
| 2203 |
}); |
| 2204 |
QString strPath; |
| 2205 |
QString phoneTitle; |
| 2206 |
if (m_pLeftListView->m_pMountListWidget->currentItem()) { |
| 2207 |
strPath = m_pLeftListView->m_pMountListWidget->currentItem()->data(Qt::UserRole).toString(); |
| 2208 |
if (!strPath.contains("/media/") && !strPath.contains("DCIM")) { |
| 2209 |
findPicturePathByPhone(strPath); |
| 2210 |
} |
| 2211 |
phoneTitle = m_pLeftListView->m_pMountListWidget->currentItem()->data(Qt::UserRole + 1).toString(); |
| 2212 |
} |
| 2213 |
if (path != strPath) { |
| 2214 |
return; |
| 2215 |
} |
| 2216 |
ImageDataService::instance()->readThumbnailByPaths(fileList); |
| 2217 |
//更新外部设备页面标题等状态 |
| 2218 |
m_importByPhoneComboBox->setEnabled(true); |
| 2219 |
m_importAllByPhoneBtn->setEnabled(true); |
| 2220 |
updateImportComboBox(); |
| 2221 |
m_pPhoneTitle->setText(phoneTitle); |
| 2222 |
QFontMetrics elideFont(m_pPhoneTitle->font()); |
| 2223 |
m_pPhoneTitle->setText(elideFont.elidedText(phoneTitle, Qt::ElideRight, 525)); |
| 2224 |
if (m_iAlubmPicsNum > 0) { |
| 2225 |
m_pRightPhoneThumbnailList->m_imageType = ALBUM_PATHTYPE_BY_PHONE; |
| 2226 |
QStringList paths = m_pRightPhoneThumbnailList->selectedPaths(); |
| 2227 |
if (0 < paths.length()) { |
| 2228 |
m_importSelectByPhoneBtn->setEnabled(true); |
| 2229 |
} else { |
| 2230 |
m_importSelectByPhoneBtn->setEnabled(false); |
| 2231 |
} |
| 2232 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_PHONE); |
| 2233 |
m_pStatusBar->setVisible(true); |
| 2234 |
} else { |
| 2235 |
m_importByPhoneComboBox->setEnabled(false); |
| 2236 |
m_importAllByPhoneBtn->setEnabled(false); |
| 2237 |
m_importSelectByPhoneBtn->setEnabled(false); |
| 2238 |
m_pPhoneTitle->setText(m_currentAlbum); |
| 2239 |
// QFontMetrics elideFont(m_pPhoneTitle->font()); |
| 2240 |
m_pPhoneTitle->setText(elideFont.elidedText(m_currentAlbum, Qt::ElideRight, 525)); |
| 2241 |
m_pRightPhoneThumbnailList->m_imageType = ALBUM_PATHTYPE_BY_PHONE; |
| 2242 |
m_pRightStackWidget->setCurrentIndex(RIGHT_VIEW_PHONE); |
| 2243 |
m_pStatusBar->setVisible(true); |
| 2244 |
} |
| 2245 |
setAcceptDrops(false); |
| 2246 |
|
| 2247 |
using namespace utils::image; |
| 2248 |
DBImgInfoList infos; |
| 2249 |
for (int i = 0; i < fileList.size(); i++) { |
| 2250 |
DBImgInfo info; |
| 2251 |
if (utils::base::isVideo(fileList.at(i))) { |
| 2252 |
info.itemType = ItemType::ItemTypeVideo; |
| 2253 |
} |
| 2254 |
info.filePath = fileList.at(i); |
| 2255 |
infos.append(info); |
| 2256 |
} |
| 2257 |
//先清除所有 |
| 2258 |
m_pRightPhoneThumbnailList->clearAll(); |
| 2259 |
//添加上方空白栏 |
| 2260 |
m_pRightPhoneThumbnailList->insertBlankOrTitleItem(ItemTypeBlank, "", "", m_importByPhoneWidget->height()); |
| 2261 |
//添加图片信息 |
| 2262 |
m_pRightPhoneThumbnailList->insertThumbnailByImgInfos(infos); |
| 2263 |
|
| 2264 |
//重置数量显示 |
| 2265 |
resetLabelCount(m_pRightPhoneThumbnailList->getAppointTypeItemCount(ItemTypePic) |
| 2266 |
, m_pRightPhoneThumbnailList->getAppointTypeItemCount(ItemTypeVideo), m_pPhonePicTotal); |
| 2267 |
|
| 2268 |
m_pStatusBar->m_pAllPicNumLabel->setText(m_pPhonePicTotal->text()); |
| 2269 |
} |
| 2270 |
//筛选显示,当先列表中内容为无结果 |
| 2271 |
void AlbumView::slotNoPicOrNoVideo(bool isNoResult) |
| 2272 |
{ |
| 2273 |
if (sender() == m_customThumbnailList) { |
| 2274 |
m_customNoResultWidget->setVisible(isNoResult); |
| 2275 |
m_customThumbnailList->setVisible(!isNoResult); |
| 2276 |
m_customAlbumTitleLabel->setVisible(!isNoResult); |
| 2277 |
m_pRightPicTotal->setVisible(!isNoResult); |
| 2278 |
} else if (sender() == m_favoriteThumbnailList) { |
| 2279 |
m_favoriteNoResultWidget->setVisible(isNoResult); |
| 2280 |
m_favoriteThumbnailList->setVisible(!isNoResult); |
| 2281 |
m_pFavoriteTitle->setVisible(!isNoResult); |
| 2282 |
m_pFavoritePicTotal->setVisible(!isNoResult); |
| 2283 |
} else if (sender() == m_pRightTrashThumbnailList) { |
| 2284 |
m_trashNoResultWidget->setVisible(isNoResult); |
| 2285 |
m_pRightTrashThumbnailList->setVisible(!isNoResult); |
| 2286 |
m_TrashTitleLab->setVisible(!isNoResult); |
| 2287 |
m_TrashDescritionLab->setVisible(!isNoResult); |
| 2288 |
} |
| 2289 |
if (isNoResult) { |
| 2290 |
m_pStatusBar->m_pAllPicNumLabel->setText(QObject::tr("No results")); |
| 2291 |
} else { |
| 2292 |
updatePicNum(); |
| 2293 |
} |
| 2294 |
} |
| 2295 |
|
| 2296 |
void AlbumView::sltSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) |
| 2297 |
{ |
| 2298 |
Q_UNUSED(selected) |
| 2299 |
Q_UNUSED(deselected) |
| 2300 |
updatePicNum(); |
| 2301 |
} |
| 2302 |
|
| 2303 |
void AlbumView::onTrashInfosChanged() |
| 2304 |
{ |
| 2305 |
//最近删除数据变化,先刷新数据 |
| 2306 |
m_allTrashInfos = DBManager::instance()->getAllTrashInfos(); |
| 2307 |
updateRightView(); |
| 2308 |
} |
| 2309 |
|
| 2310 |
void AlbumView::resizeEvent(QResizeEvent *e) |
| 2311 |
{ |
| 2312 |
qDebug() << "------" << __FUNCTION__ << ""; |
| 2313 |
m_spinner->move(width() / 2 + 60, (height()) / 2 - 20); |
| 2314 |
// m_pImpTimeLineView->setFixedSize(width() - 181, height()); |
| 2315 |
m_pwidget->setFixedSize(this->width(), this->height() - 23); |
| 2316 |
m_pwidget->move(0, 0); |
| 2317 |
//我的收藏 |
| 2318 |
if (nullptr != m_FavoriteTitleWidget) { |
| 2319 |
m_FavoriteTitleWidget->setFixedSize(this->width() - m_pLeftListView->width() - magin_offset, favorite_title_height); |
| 2320 |
m_pFavoriteTitle->move(m_FavoriteTitleWidget->width() / 2 - m_pFavoriteTitle->width() / 2, 0); |
| 2321 |
m_pFavoriteTitle->raise(); |
| 2322 |
} |
| 2323 |
//最近删除 |
| 2324 |
if (nullptr != m_TrashTitleWidget) { |
| 2325 |
m_TrashTitleWidget->setFixedSize(this->width() - m_pLeftListView->width() - magin_offset, trash_title_height); |
| 2326 |
m_TrashTitleLab->move(m_TrashTitleWidget->width() / 2 - m_TrashTitleLab->width() / 2, 0); |
| 2327 |
m_TrashTitleLab->raise(); |
| 2328 |
} |
| 2329 |
//设备 |
| 2330 |
if (nullptr != pPhoneWidget) { |
| 2331 |
phonetopwidget->setFixedWidth(pPhoneWidget->width() - 15);//BUG#93779 -15把右侧滚动条露出来 |
| 2332 |
} |
| 2333 |
//自定义相册 |
| 2334 |
if (nullptr != m_customAlbumTitle) { |
| 2335 |
m_customAlbumTitle->setFixedSize(this->width() - m_pLeftListView->width() - magin_offset, custom_title_height); |
| 2336 |
m_customAlbumTitleLabel->move(m_customAlbumTitle->width() / 2 - m_customAlbumTitleLabel->width() / 2, 0); |
| 2337 |
m_customAlbumTitleLabel->raise(); |
| 2338 |
} |
| 2339 |
|
| 2340 |
//add end 3975 |
| 2341 |
m_pStatusBar->setFixedWidth(this->width() - m_pLeftListView->width()); |
| 2342 |
m_pStatusBar->move(m_pLeftListView->width(), this->height() - m_pStatusBar->height()); |
| 2343 |
m_pStatusBar->raise(); |
| 2344 |
QWidget::resizeEvent(e); |
| 2345 |
} |
| 2346 |
|
| 2347 |
void AlbumView::showEvent(QShowEvent *e) |
| 2348 |
{ |
| 2349 |
//我的收藏 |
| 2350 |
if (nullptr != m_FavoriteTitleWidget) { |
| 2351 |
m_FavoriteTitleWidget->setFixedSize(this->width() - m_pLeftListView->width() - magin_offset, favorite_title_height); |
| 2352 |
m_pFavoriteTitle->move(m_FavoriteTitleWidget->width() / 2 - m_pFavoriteTitle->width() / 2, 0); |
| 2353 |
m_pFavoriteTitle->raise(); |
| 2354 |
} |
| 2355 |
//最近删除 |
| 2356 |
if (nullptr != m_TrashTitleWidget) { |
| 2357 |
m_TrashTitleWidget->setFixedSize(this->width() - m_pLeftListView->width() - magin_offset, trash_title_height); |
| 2358 |
m_TrashTitleLab->move(m_TrashTitleWidget->width() / 2 - m_TrashTitleLab->width() / 2, 0); |
| 2359 |
m_TrashTitleLab->raise(); |
| 2360 |
} |
| 2361 |
//自定义相册 |
| 2362 |
if (nullptr != m_customAlbumTitle) { |
| 2363 |
m_customAlbumTitle->setFixedSize(this->width() - m_pLeftListView->width() - magin_offset, custom_title_height); |
| 2364 |
m_customAlbumTitleLabel->move(m_customAlbumTitle->width() / 2 - m_customAlbumTitleLabel->width() / 2, 0); |
| 2365 |
m_customAlbumTitleLabel->raise();//图层上移 |
| 2366 |
} |
| 2367 |
//设备 |
| 2368 |
if (nullptr != pPhoneWidget) { |
| 2369 |
// m_pRightPhoneThumbnailList->setFixedSize(pPhoneWidget->size()); |
| 2370 |
phonetopwidget->setFixedWidth(pPhoneWidget->width() - 15);//BUG#93779 -15把右侧滚动条露出来 |
| 2371 |
} |
| 2372 |
QWidget::showEvent(e); |
| 2373 |
} |
| 2374 |
|