| 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 "timelineview.h" |
| 22 |
#include "utils/baseutils.h" |
| 23 |
#include "utils/imageutils.h" |
| 24 |
#include "imageengine/imageengineapi.h" |
| 25 |
#include "mainwindow.h" |
| 26 |
#include "ac-desktop-define.h" |
| 27 |
|
| 28 |
#include <QScrollBar> |
| 29 |
#include <QScroller> |
| 30 |
#include <QMimeData> |
| 31 |
#include <QGraphicsOpacityEffect> |
| 32 |
#include <QDesktopWidget> |
| 33 |
|
| 34 |
#include <DPushButton> |
| 35 |
#include <DTableView> |
| 36 |
#include <dgiovolumemanager.h> |
| 37 |
#include <dgiofile.h> |
| 38 |
#include <dgiofileinfo.h> |
| 39 |
#include <dgiovolume.h> |
| 40 |
|
| 41 |
#include "batchoperatewidget.h" |
| 42 |
#include "noresultwidget.h" |
| 43 |
|
| 44 |
namespace { |
| 45 |
const int VIEW_IMPORT = 0; |
| 46 |
const int VIEW_TIMELINE = 1; |
| 47 |
const int VIEW_SEARCH = 2; |
| 48 |
const int TITLEHEIGHT = 0; |
| 49 |
const int TIMELINE_TITLEHEIGHT = 36; |
| 50 |
const int SUSPENSION_WIDGET_HEIGHT = 87;//悬浮控件高度 |
| 51 |
} //namespace |
| 52 |
|
| 53 |
TimeLineView::TimeLineView() |
| 54 |
: m_mainLayout(nullptr) |
| 55 |
, allnum(0) |
| 56 |
, m_oe(nullptr), m_oet(nullptr) |
| 57 |
, fatherwidget(nullptr), m_pStackedWidget(nullptr) |
| 58 |
, m_pStatusBar(nullptr), pSearchView(nullptr), pImportView(nullptr), pTimeLineViewWidget(nullptr) |
| 59 |
, m_pwidget(nullptr), m_selPicNum(0), m_spinner(nullptr) |
| 60 |
{ |
| 61 |
setAcceptDrops(true); |
| 62 |
QVBoxLayout *pMainBoxLayout = new QVBoxLayout(this); |
| 63 |
pMainBoxLayout->setMargin(0); |
| 64 |
this->setLayout(pMainBoxLayout); |
| 65 |
|
| 66 |
fatherwidget = new QWidget(this); |
| 67 |
pMainBoxLayout->addWidget(fatherwidget); |
| 68 |
m_oe = new QGraphicsOpacityEffect(this); |
| 69 |
m_oet = new QGraphicsOpacityEffect(this); |
| 70 |
m_oe->setOpacity(0.5); |
| 71 |
m_oet->setOpacity(0.75); |
| 72 |
|
| 73 |
m_pStackedWidget = new QStackedWidget(this); |
| 74 |
pTimeLineViewWidget = new QWidget(); |
| 75 |
pImportView = new ImportView(); |
| 76 |
pSearchView = new SearchView(); |
| 77 |
m_pStackedWidget->addWidget(pImportView); |
| 78 |
m_pStackedWidget->addWidget(pTimeLineViewWidget); |
| 79 |
m_pStackedWidget->addWidget(pSearchView); |
| 80 |
|
| 81 |
m_pStatusBar = new StatusBar(this); |
| 82 |
m_pStatusBar->raise(); |
| 83 |
m_pStatusBar->setFixedWidth(this->width()); |
| 84 |
m_pStatusBar->move(0, this->height() - m_pStatusBar->height()); |
| 85 |
QVBoxLayout *pVBoxLayout = new QVBoxLayout(); |
| 86 |
pVBoxLayout->setContentsMargins(2, 0, 0, 0); |
| 87 |
pVBoxLayout->addWidget(m_pStackedWidget); |
| 88 |
fatherwidget->setLayout(pVBoxLayout); |
| 89 |
|
| 90 |
initTimeLineViewWidget(); |
| 91 |
initConnections(); |
| 92 |
m_pwidget = new QWidget(this); |
| 93 |
m_pwidget->setAttribute(Qt::WA_TransparentForMouseEvents); |
| 94 |
m_spinner = new DSpinner(this); |
| 95 |
m_spinner->setFixedSize(40, 40); |
| 96 |
m_spinner->hide(); |
| 97 |
} |
| 98 |
|
| 99 |
bool TimeLineView::imageImported(bool success) |
| 100 |
{ |
| 101 |
Q_UNUSED(success); |
| 102 |
emit dApp->signalM->closeWaitDialog(); |
| 103 |
return true; |
| 104 |
} |
| 105 |
|
| 106 |
void TimeLineView::initConnections() |
| 107 |
{ |
| 108 |
qRegisterMetaType<DBImgInfoList>("DBImgInfoList &"); |
| 109 |
connect(dApp->signalM, &SignalManager::sigLoadOnePhoto, this, &TimeLineView::clearAndStartLayout); |
| 110 |
connect(dApp->signalM, &SignalManager::imagesInserted, this, &TimeLineView::clearAndStartLayout); |
| 111 |
connect(dApp->signalM, &SignalManager::sigUpdateImageLoader, this, &TimeLineView::updataLayout); |
| 112 |
connect(m_pStatusBar->m_pSlider, &DSlider::valueChanged, dApp->signalM, &SignalManager::emitSliderValueChg); |
| 113 |
// connect(pSearchView->m_pThumbnailListView, &ThumbnailListView::clicked, this, &TimeLineView::updatePicNum); |
| 114 |
connect(DApplicationHelper::instance(), &DApplicationHelper::themeTypeChanged, this, &TimeLineView::themeChangeSlot); |
| 115 |
connect(pImportView->m_pImportBtn, &DPushButton::clicked, this, &TimeLineView::onImportViewImportBtnClicked); |
| 116 |
connect(dApp->signalM, &SignalManager::sigImportFailedToView, this, &TimeLineView::onImportFailedToView); |
| 117 |
connect(dApp->signalM, &SignalManager::sigShortcutKeyDelete, this, &TimeLineView::onKeyDelete); |
| 118 |
// 重复导入图片选中 |
| 119 |
connect(dApp->signalM, &SignalManager::RepeatImportingTheSamePhotos, this, &TimeLineView::onRepeatImportingTheSamePhotos); |
| 120 |
connect(m_timeLineThumbnailListView, &ThumbnailListView::sigSelectAll, this, [ = ]() { |
| 121 |
m_suspensionChose->setText(QObject::tr("Unselect")); |
| 122 |
}); |
| 123 |
//缩略图选中项发生变化 |
| 124 |
connect(m_timeLineThumbnailListView->selectionModel(), &QItemSelectionModel::selectionChanged, |
| 125 |
this, &TimeLineView::sltSelectionChanged); |
| 126 |
connect(pSearchView->m_pThumbnailListView->selectionModel(), &QItemSelectionModel::selectionChanged, |
| 127 |
this, &TimeLineView::sltSelectionChanged); |
| 128 |
} |
| 129 |
|
| 130 |
void TimeLineView::themeChangeSlot(DGuiApplicationHelper::ColorType themeType) |
| 131 |
{ |
| 132 |
DPalette pa1 = DApplicationHelper::instance()->palette(m_dateNumItemWidget); |
| 133 |
pa1.setBrush(DPalette::Background, pa1.color(DPalette::Base)); |
| 134 |
m_dateNumItemWidget->setForegroundRole(DPalette::Background); |
| 135 |
m_dateNumItemWidget->setPalette(pa1); |
| 136 |
DPalette pa = DApplicationHelper::instance()->palette(m_dateLabel); |
| 137 |
pa.setBrush(DPalette::Text, pa.color(DPalette::ToolTipText)); |
| 138 |
m_dateLabel->setForegroundRole(DPalette::Text); |
| 139 |
m_dateLabel->setPalette(pa); |
| 140 |
|
| 141 |
DPalette pal1 = DApplicationHelper::instance()->palette(m_numLabel); |
| 142 |
QColor color_BT1 = pal1.color(DPalette::BrightText); |
| 143 |
if (themeType == DGuiApplicationHelper::LightType) { |
| 144 |
color_BT1.setAlphaF(0.5); |
| 145 |
pal1.setBrush(DPalette::Text, color_BT1); |
| 146 |
m_numLabel->setForegroundRole(DPalette::Text); |
| 147 |
m_numLabel->setPalette(pal1); |
| 148 |
} else if (themeType == DGuiApplicationHelper::DarkType) { |
| 149 |
color_BT1.setAlphaF(0.75); |
| 150 |
pal1.setBrush(DPalette::Text, color_BT1); |
| 151 |
m_numLabel->setForegroundRole(DPalette::Text); |
| 152 |
m_numLabel->setPalette(pal1); |
| 153 |
} |
| 154 |
} |
| 155 |
|
| 156 |
ThumbnailListView *TimeLineView::getThumbnailListView() |
| 157 |
{ |
| 158 |
return m_timeLineThumbnailListView; |
| 159 |
} |
| 160 |
|
| 161 |
void TimeLineView::clearAllSelection() |
| 162 |
{ |
| 163 |
m_timeLineThumbnailListView->clearSelection(); |
| 164 |
} |
| 165 |
|
| 166 |
void TimeLineView::updataLayout(QStringList updatePathList) |
| 167 |
{ |
| 168 |
Q_UNUSED(updatePathList) |
| 169 |
m_spinner->hide(); |
| 170 |
m_spinner->stop(); |
| 171 |
} |
| 172 |
|
| 173 |
void TimeLineView::initTimeLineViewWidget() |
| 174 |
{ |
| 175 |
m_mainLayout = new QVBoxLayout(); |
| 176 |
m_mainLayout->setContentsMargins(0, 0, 0, m_pStatusBar->height()); |
| 177 |
pTimeLineViewWidget->setLayout(m_mainLayout); |
| 178 |
|
| 179 |
DPalette palcolor = DApplicationHelper::instance()->palette(pTimeLineViewWidget); |
| 180 |
palcolor.setBrush(DPalette::Base, palcolor.color(DPalette::Window)); |
| 181 |
pTimeLineViewWidget->setPalette(palcolor); |
| 182 |
|
| 183 |
m_timeLineThumbnailListView = new ThumbnailListView(ThumbnailDelegate::TimeLineViewType, COMMON_STR_VIEW_TIMELINE, pTimeLineViewWidget); |
| 184 |
m_timeLineThumbnailListView->setEditTriggers(QAbstractItemView::NoEditTriggers); |
| 185 |
m_timeLineThumbnailListView->setContextMenuPolicy(Qt::CustomContextMenu); |
| 186 |
m_timeLineThumbnailListView->setContentsMargins(0, 0, 0, 0); |
| 187 |
m_timeLineThumbnailListView->setFrameShape(DTableView::NoFrame); |
| 188 |
m_mainLayout->addWidget(m_timeLineThumbnailListView); |
| 189 |
|
| 190 |
//初始化筛选无结果窗口 |
| 191 |
m_noResultWidget = new NoResultWidget(pTimeLineViewWidget); |
| 192 |
m_mainLayout->addWidget(m_noResultWidget); |
| 193 |
m_noResultWidget->setVisible(false); |
| 194 |
|
| 195 |
connect(m_timeLineThumbnailListView, &ThumbnailListView::sigShowEvent, this, &TimeLineView::clearAndStartLayout); |
| 196 |
//滑动列表,刷新上方悬浮标题 |
| 197 |
connect(m_timeLineThumbnailListView, &ThumbnailListView::sigTimeLineDataAndNum, this, &TimeLineView::slotTimeLineDataAndNum); |
| 198 |
//打开图片 |
| 199 |
connect(m_timeLineThumbnailListView, &ThumbnailListView::openImage, this, &TimeLineView::onOpenImage); |
| 200 |
//幻灯片播放 |
| 201 |
connect(m_timeLineThumbnailListView, &ThumbnailListView::sigSlideShow, this, &TimeLineView::onSlideShow); |
| 202 |
//筛选显示,当先列表中内容为无结果 |
| 203 |
connect(m_timeLineThumbnailListView, &ThumbnailListView::sigNoPicOrNoVideo, this, &TimeLineView::slotNoPicOrNoVideo); |
| 204 |
|
| 205 |
// connect(m_timeLineThumbnailListView, &ThumbnailListView::sigMouseMove, this, &TimeLineView::updatePicNum); |
| 206 |
connect(m_timeLineThumbnailListView, &ThumbnailListView::sigMoveToTrash, this, &TimeLineView::onKeyDelete);//跳转 |
| 207 |
|
| 208 |
//添加悬浮title |
| 209 |
m_dateNumItemWidget = new QWidget(pTimeLineViewWidget); |
| 210 |
m_dateNumItemWidget->setFocusPolicy(Qt::ClickFocus); |
| 211 |
m_dateNumItemWidget->setPalette(palcolor); |
| 212 |
QVBoxLayout *titleViewLayout = new QVBoxLayout(); |
| 213 |
titleViewLayout->setContentsMargins(18, 0, 0, 0); |
| 214 |
m_dateNumItemWidget->setLayout(titleViewLayout); |
| 215 |
|
| 216 |
//时间线 |
| 217 |
QHBoxLayout *hDateLayout = new QHBoxLayout(); |
| 218 |
m_dateLabel = new DLabel(); |
| 219 |
hDateLayout->addWidget(m_dateLabel); |
| 220 |
DFontSizeManager::instance()->bind(m_dateLabel, DFontSizeManager::T3, QFont::Medium); |
| 221 |
QFont ft3 = DFontSizeManager::instance()->get(DFontSizeManager::T3); |
| 222 |
ft3.setFamily("SourceHanSansSC"); |
| 223 |
ft3.setWeight(QFont::DemiBold); |
| 224 |
DPalette color = DApplicationHelper::instance()->palette(m_dateLabel); |
| 225 |
color.setBrush(DPalette::Text, color.color(DPalette::ToolTipText)); |
| 226 |
|
| 227 |
//bug76892藏语占用更大高度 |
| 228 |
if (QLocale::system().language() == QLocale::Tibetan) { |
| 229 |
m_dateLabel->setFixedHeight(TIMELINE_TITLEHEIGHT + 25); |
| 230 |
} else { |
| 231 |
m_dateLabel->setFixedHeight(TIMELINE_TITLEHEIGHT); |
| 232 |
} |
| 233 |
m_dateLabel->setFont(ft3); |
| 234 |
m_dateLabel->setForegroundRole(DPalette::Text); |
| 235 |
m_dateLabel->setPalette(color); |
| 236 |
|
| 237 |
//右侧批量操作控件 |
| 238 |
m_batchOperateWidget = new BatchOperateWidget(m_timeLineThumbnailListView, BatchOperateWidget::NullType, this); |
| 239 |
//进入批量状态 |
| 240 |
connect(m_batchOperateWidget, &BatchOperateWidget::signalBatchSelectChanged, this, &TimeLineView::slotBatchSelectChanged); |
| 241 |
hDateLayout->addStretch(1); |
| 242 |
hDateLayout->setAlignment(Qt::AlignRight | Qt::AlignVCenter); |
| 243 |
hDateLayout->setContentsMargins(0, 0, 19, 0); |
| 244 |
hDateLayout->addWidget(m_batchOperateWidget); |
| 245 |
|
| 246 |
//时间线下的计数 |
| 247 |
QHBoxLayout *hNumLayout = new QHBoxLayout(); |
| 248 |
m_numLabel = new DLabel(); |
| 249 |
hNumLayout->addWidget(m_numLabel); |
| 250 |
if (QLocale::system().language() == QLocale::Uighur) { |
| 251 |
m_numLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); |
| 252 |
} |
| 253 |
DFontSizeManager::instance()->bind(m_numLabel, DFontSizeManager::T6, QFont::Medium); |
| 254 |
QFont ft6 = DFontSizeManager::instance()->get(DFontSizeManager::T6); |
| 255 |
ft6.setFamily("SourceHanSansSC"); |
| 256 |
ft6.setWeight(QFont::Medium); |
| 257 |
DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType(); |
| 258 |
DPalette pal = DApplicationHelper::instance()->palette(m_numLabel); |
| 259 |
QColor color_BT = pal.color(DPalette::BrightText); |
| 260 |
if (themeType == DGuiApplicationHelper::LightType) { |
| 261 |
color_BT.setAlphaF(0.5); |
| 262 |
pal.setBrush(DPalette::Text, color_BT); |
| 263 |
m_numLabel->setForegroundRole(DPalette::Text); |
| 264 |
m_numLabel->setPalette(pal); |
| 265 |
} else if (themeType == DGuiApplicationHelper::DarkType) { |
| 266 |
color_BT.setAlphaF(0.75); |
| 267 |
pal.setBrush(DPalette::Text, color_BT); |
| 268 |
m_numLabel->setForegroundRole(DPalette::Text); |
| 269 |
m_numLabel->setPalette(pal); |
| 270 |
} |
| 271 |
|
| 272 |
m_numLabel->setFixedHeight(TIMELINE_TITLEHEIGHT); |
| 273 |
m_numLabel->setFont(ft6); |
| 274 |
m_numLabel->setForegroundRole(DPalette::Text); |
| 275 |
m_numLabel->setPalette(pal); |
| 276 |
|
| 277 |
titleViewLayout->addLayout(hDateLayout); |
| 278 |
titleViewLayout->addLayout(hNumLayout); |
| 279 |
titleViewLayout->addStretch(100); |
| 280 |
|
| 281 |
//右侧选择文字 |
| 282 |
m_suspensionChose = new DCommandLinkButton(QObject::tr("Select")); |
| 283 |
m_suspensionChose->setFocusPolicy(Qt::NoFocus); |
| 284 |
AC_SET_OBJECT_NAME(m_suspensionChose, Time_Line_Choose_Button); |
| 285 |
AC_SET_ACCESSIBLE_NAME(m_suspensionChose, Time_Line_Choose_Button); |
| 286 |
DFontSizeManager::instance()->bind(m_suspensionChose, DFontSizeManager::T5); |
| 287 |
m_suspensionChose->setFont(DFontSizeManager::instance()->get(DFontSizeManager::T5)); |
| 288 |
m_suspensionChose->setFixedHeight(TIMELINE_TITLEHEIGHT); |
| 289 |
m_suspensionChose->resize(36, 27); |
| 290 |
m_suspensionChose->setVisible(false); |
| 291 |
|
| 292 |
hNumLayout->addStretch(1); |
| 293 |
hNumLayout->addSpacerItem(new QSpacerItem(0, 27)); |
| 294 |
hNumLayout->setAlignment(Qt::AlignLeft | Qt::AlignTop); |
| 295 |
hNumLayout->setContentsMargins(0, 0, 19, 0); |
| 296 |
hNumLayout->addWidget(m_suspensionChose); |
| 297 |
connect(m_suspensionChose, &DCommandLinkButton::clicked, this, &TimeLineView::on_DCommandLinkButton); |
| 298 |
|
| 299 |
DPalette ppal_light = DApplicationHelper::instance()->palette(m_dateNumItemWidget); |
| 300 |
ppal_light.setBrush(DPalette::Background, ppal_light.color(DPalette::Base)); |
| 301 |
QGraphicsOpacityEffect *opacityEffect_light = new QGraphicsOpacityEffect; |
| 302 |
opacityEffect_light->setOpacity(0.95); |
| 303 |
m_dateNumItemWidget->setPalette(ppal_light); |
| 304 |
m_dateNumItemWidget->setGraphicsEffect(opacityEffect_light); |
| 305 |
m_dateNumItemWidget->setAutoFillBackground(true); |
| 306 |
m_dateNumItemWidget->setContentsMargins(0, 0, 0, 0); |
| 307 |
m_dateNumItemWidget->setGeometry(0, 0, this->width() - 15, SUSPENSION_WIDGET_HEIGHT); |
| 308 |
} |
| 309 |
|
| 310 |
void TimeLineView::updateStackedWidget() |
| 311 |
{ |
| 312 |
if (0 < DBManager::instance()->getImgsCount()) { |
| 313 |
m_pStackedWidget->setCurrentIndex(VIEW_TIMELINE); |
| 314 |
m_pStatusBar->setVisible(true); |
| 315 |
} else { |
| 316 |
m_pStackedWidget->setCurrentIndex(VIEW_IMPORT); |
| 317 |
m_pStatusBar->setVisible(false); |
| 318 |
} |
| 319 |
} |
| 320 |
|
| 321 |
void TimeLineView::clearAndStartLayout() |
| 322 |
{ |
| 323 |
//由于绘制需要使用listview的宽度,但是加载的时候listview还没有显示出来,宽度是不对的,所以在显示出来后用信号通知加载,记载完成后断开信号, |
| 324 |
//后面的listview就有了正确的宽度,该信号槽就不需要再连接 |
| 325 |
disconnect(m_timeLineThumbnailListView, &ThumbnailListView::sigShowEvent, this, &TimeLineView::clearAndStartLayout); |
| 326 |
qDebug() << "------" << __FUNCTION__ << ""; |
| 327 |
m_spinner->hide(); |
| 328 |
m_spinner->stop(); |
| 329 |
//获取所有时间线 |
| 330 |
m_timelines = DBManager::instance()->getAllTimelines(); |
| 331 |
updateStackedWidget(); |
| 332 |
addTimelineLayout(); |
| 333 |
} |
| 334 |
|
| 335 |
void TimeLineView::slotTimeLineDataAndNum(QString data, QString num, QString text) |
| 336 |
{ |
| 337 |
if (!data.isEmpty()) { |
| 338 |
m_dateLabel->setText(data); |
| 339 |
} |
| 340 |
if (!num.isEmpty()) { |
| 341 |
m_numLabel->setText(num); |
| 342 |
} |
| 343 |
m_suspensionChose->setText(text); |
| 344 |
} |
| 345 |
|
| 346 |
void TimeLineView::onImportViewImportBtnClicked() |
| 347 |
{ |
| 348 |
emit dApp->signalM->startImprot(); |
| 349 |
pImportView->onImprotBtnClicked(); |
| 350 |
} |
| 351 |
|
| 352 |
void TimeLineView::onImportFailedToView() |
| 353 |
{ |
| 354 |
if (isVisible()) { |
| 355 |
m_spinner->hide(); |
| 356 |
m_spinner->stop(); |
| 357 |
updateStackedWidget(); |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
void TimeLineView::onRepeatImportingTheSamePhotos(QStringList importPaths, QStringList duplicatePaths, const QString &albumName) |
| 362 |
{ |
| 363 |
Q_UNUSED(importPaths) |
| 364 |
// 导入的照片重复照片提示 |
| 365 |
if (duplicatePaths.size() > 0 && albumName.length() < 1 && dApp->getMainWindow()->getCurrentViewType() == 1) { |
| 366 |
m_timeLineThumbnailListView->selectDuplicatePhotos(duplicatePaths); |
| 367 |
} |
| 368 |
} |
| 369 |
|
| 370 |
void TimeLineView::onOpenImage(int row, const QString &path, bool bFullScreen) |
| 371 |
{ |
| 372 |
SignalManager::ViewInfo info; |
| 373 |
info.album = ""; |
| 374 |
info.lastPanel = nullptr; |
| 375 |
info.fullScreen = bFullScreen; |
| 376 |
auto imagelist = m_timeLineThumbnailListView->getFileList(row); |
| 377 |
if (imagelist.size() > 0) { |
| 378 |
info.paths << imagelist; |
| 379 |
info.path = path; |
| 380 |
} else { |
| 381 |
info.paths.clear(); |
| 382 |
} |
| 383 |
info.dBImgInfos = m_timeLineThumbnailListView->getAllFileInfo(row); |
| 384 |
info.viewType = utils::common::VIEW_TIMELINE_SRN; |
| 385 |
info.viewMainWindowID = VIEW_MAINWINDOW_TIMELINE; |
| 386 |
emit dApp->signalM->viewImage(info); |
| 387 |
emit dApp->signalM->showImageView(VIEW_MAINWINDOW_TIMELINE); |
| 388 |
} |
| 389 |
|
| 390 |
void TimeLineView::onSlideShow(QString path) |
| 391 |
{ |
| 392 |
SignalManager::ViewInfo info; |
| 393 |
info.album = ""; |
| 394 |
info.lastPanel = nullptr; |
| 395 |
auto photolist = m_timeLineThumbnailListView->selectedPaths(); |
| 396 |
if (photolist.size() > 1) { |
| 397 |
//如果选中数目大于1,则幻灯片播放选中项 |
| 398 |
info.paths = photolist; |
| 399 |
info.path = photolist.at(0); |
| 400 |
} else { |
| 401 |
//如果选中项只有一项,则幻灯片播放全部 |
| 402 |
info.paths = m_timeLineThumbnailListView->getFileList(m_timeLineThumbnailListView->getRow(path)); |
| 403 |
info.path = path; |
| 404 |
} |
| 405 |
info.fullScreen = true; |
| 406 |
info.slideShow = true; |
| 407 |
info.viewType = utils::common::VIEW_TIMELINE_SRN; |
| 408 |
info.viewMainWindowID = VIEW_MAINWINDOW_TIMELINE; |
| 409 |
emit dApp->signalM->startSlideShow(info); |
| 410 |
emit dApp->signalM->showSlidePanel(VIEW_MAINWINDOW_TIMELINE); |
| 411 |
} |
| 412 |
|
| 413 |
void TimeLineView::slotBatchSelectChanged(bool isBatchSelect) |
| 414 |
{ |
| 415 |
m_suspensionChose->setVisible(isBatchSelect); |
| 416 |
} |
| 417 |
|
| 418 |
void TimeLineView::sltSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected) |
| 419 |
{ |
| 420 |
Q_UNUSED(selected) |
| 421 |
Q_UNUSED(deselected) |
| 422 |
updatePicNum(); |
| 423 |
} |
| 424 |
|
| 425 |
void TimeLineView:: addTimelineLayout() |
| 426 |
{ |
| 427 |
m_timeLineThumbnailListView->clearAll(); |
| 428 |
for (int timelineIndex = 0; timelineIndex < m_timelines.size(); timelineIndex++) { |
| 429 |
//获取当前时间照片 |
| 430 |
DBImgInfoList ImgInfoList = DBManager::instance()->getInfosByTimeline(m_timelines.at(timelineIndex)); |
| 431 |
|
| 432 |
//加时间线标题 |
| 433 |
QString data, num; |
| 434 |
QStringList datelist = m_timelines.at(timelineIndex).split("."); |
| 435 |
if (datelist.count() > 2) { |
| 436 |
data = QString(QObject::tr("%1/%2/%3")).arg(datelist[0]).arg(datelist[1]).arg(datelist[2]); |
| 437 |
} |
| 438 |
int photoCount = 0; |
| 439 |
int videoCount = 0; |
| 440 |
for (int i = 0; i < ImgInfoList.size(); i++) { |
| 441 |
if (ImgInfoList.at(i).itemType == ItemTypePic) { |
| 442 |
photoCount++; |
| 443 |
} else if (ImgInfoList.at(i).itemType == ItemTypeVideo) { |
| 444 |
videoCount++; |
| 445 |
} |
| 446 |
} |
| 447 |
if (photoCount == 1 && videoCount == 0) { |
| 448 |
num = tr("1 photo"); |
| 449 |
} else if (photoCount == 0 && videoCount == 1) { |
| 450 |
num = tr("1 video"); |
| 451 |
} else if (photoCount > 1 && videoCount == 0) { |
| 452 |
num = tr("%n photos", "", photoCount); |
| 453 |
} else if (photoCount == 0 && videoCount > 1) { |
| 454 |
num = tr("%n videos", "", videoCount); |
| 455 |
} else if (photoCount > 1 && videoCount > 1) { |
| 456 |
num = tr("%n items", "", (photoCount + videoCount)); |
| 457 |
} |
| 458 |
|
| 459 |
if (timelineIndex == 0) { |
| 460 |
m_dateLabel->setText(data); |
| 461 |
m_numLabel->setText(num); |
| 462 |
//加空白栏 |
| 463 |
m_timeLineThumbnailListView->insertBlankOrTitleItem(ItemTypeBlank, data, num, SUSPENSION_WIDGET_HEIGHT); |
| 464 |
} else { |
| 465 |
//加时间线标题 |
| 466 |
m_timeLineThumbnailListView->insertBlankOrTitleItem(ItemTypeTimeLineTitle, data, num, 90); |
| 467 |
} |
| 468 |
//加当前时间下的图片 |
| 469 |
m_timeLineThumbnailListView->insertThumbnailByImgInfos(ImgInfoList); |
| 470 |
} |
| 471 |
} |
| 472 |
|
| 473 |
void TimeLineView::on_AddLabel(QString date, QString num) |
| 474 |
{ |
| 475 |
if ((nullptr != m_dateNumItemWidget)) { |
| 476 |
QList<QLabel *> labelList = m_dateNumItemWidget->findChildren<QLabel *>(); |
| 477 |
labelList[0]->setText(date); |
| 478 |
labelList[1]->setText(num); |
| 479 |
m_dateNumItemWidget->setVisible(true); |
| 480 |
m_dateNumItemWidget->move(0, TITLEHEIGHT); |
| 481 |
} |
| 482 |
} |
| 483 |
|
| 484 |
void TimeLineView::on_DCommandLinkButton() |
| 485 |
{ |
| 486 |
bool isSelect = false; |
| 487 |
if (QObject::tr("Select") == m_suspensionChose->text()) { |
| 488 |
m_suspensionChose->setText(QObject::tr("Unselect")); |
| 489 |
isSelect = true; |
| 490 |
} else { |
| 491 |
m_suspensionChose->setText(QObject::tr("Select")); |
| 492 |
} |
| 493 |
QString date_str = m_dateLabel->text(); |
| 494 |
//选中当前时间内的所有图片 |
| 495 |
m_timeLineThumbnailListView->timeLimeFloatBtnClicked(date_str, isSelect); |
| 496 |
} |
| 497 |
|
| 498 |
void TimeLineView::resizeEvent(QResizeEvent *ev) |
| 499 |
{ |
| 500 |
Q_UNUSED(ev); |
| 501 |
m_spinner->move(width() / 2 - 20, (height() - 50) / 2 - 20); |
| 502 |
m_dateNumItemWidget->setGeometry(0, 0, width() - 15, SUSPENSION_WIDGET_HEIGHT); |
| 503 |
m_pwidget->setFixedSize(this->width(), this->height() - 23); |
| 504 |
m_pwidget->move(0, 0); |
| 505 |
m_pStatusBar->setFixedWidth(this->width()); |
| 506 |
m_pStatusBar->move(0, this->height() - m_pStatusBar->height()); |
| 507 |
} |
| 508 |
|
| 509 |
void TimeLineView::dragEnterEvent(QDragEnterEvent *e) |
| 510 |
{ |
| 511 |
if (!utils::base::checkMimeUrls(e->mimeData()->urls())) { |
| 512 |
return; |
| 513 |
} |
| 514 |
e->setDropAction(Qt::CopyAction); |
| 515 |
e->accept(); |
| 516 |
} |
| 517 |
|
| 518 |
void TimeLineView::dropEvent(QDropEvent *event) |
| 519 |
{ |
| 520 |
QList<QUrl> urls = event->mimeData()->urls(); |
| 521 |
if (urls.isEmpty()) { |
| 522 |
return; |
| 523 |
} |
| 524 |
ImageEngineApi::instance()->ImportImagesFromUrlList(urls, nullptr, this); |
| 525 |
event->accept(); |
| 526 |
} |
| 527 |
|
| 528 |
void TimeLineView::dragMoveEvent(QDragMoveEvent *event) |
| 529 |
{ |
| 530 |
event->accept(); |
| 531 |
} |
| 532 |
|
| 533 |
void TimeLineView::dragLeaveEvent(QDragLeaveEvent *e) |
| 534 |
{ |
| 535 |
Q_UNUSED(e); |
| 536 |
} |
| 537 |
|
| 538 |
void TimeLineView::mousePressEvent(QMouseEvent *e) |
| 539 |
{ |
| 540 |
if (QApplication::keyboardModifiers() != Qt::ControlModifier && e->button() == Qt::LeftButton) { |
| 541 |
m_timeLineThumbnailListView->clearSelection(); |
| 542 |
// updatePicNum(); |
| 543 |
updateChoseText(); |
| 544 |
} |
| 545 |
DWidget::mousePressEvent(e); |
| 546 |
} |
| 547 |
|
| 548 |
void TimeLineView::slotNoPicOrNoVideo(bool isNoResult) |
| 549 |
{ |
| 550 |
qDebug() << __FUNCTION__ << "---" << isNoResult; |
| 551 |
m_noResultWidget->setVisible(isNoResult); |
| 552 |
m_timeLineThumbnailListView->setVisible(!isNoResult); |
| 553 |
if (isNoResult) { |
| 554 |
m_pStatusBar->m_pAllPicNumLabel->setText(QObject::tr("No results")); |
| 555 |
} else { |
| 556 |
updatePicNum(); |
| 557 |
} |
| 558 |
// m_suspensionChose->setVisible(!isNoResult); |
| 559 |
m_dateLabel->setVisible(!isNoResult); |
| 560 |
m_numLabel->setVisible(!isNoResult); |
| 561 |
} |
| 562 |
|
| 563 |
void TimeLineView::updatePicNum() |
| 564 |
{ |
| 565 |
int photoSelctCount = 0; |
| 566 |
int videoSelctCount = 0; |
| 567 |
if (VIEW_TIMELINE == m_pStackedWidget->currentIndex()) { |
| 568 |
photoSelctCount = m_timeLineThumbnailListView->getAppointTypeSelectItemCount(ItemTypePic); |
| 569 |
videoSelctCount = m_timeLineThumbnailListView->getAppointTypeSelectItemCount(ItemTypeVideo); |
| 570 |
} else if (VIEW_SEARCH == m_pStackedWidget->currentIndex()) { |
| 571 |
photoSelctCount = pSearchView->m_pThumbnailListView->getAppointTypeSelectItemCount(ItemTypePic); |
| 572 |
videoSelctCount = pSearchView->m_pThumbnailListView->getAppointTypeSelectItemCount(ItemTypeVideo); |
| 573 |
} |
| 574 |
|
| 575 |
if (photoSelctCount > 0 || videoSelctCount > 0) { |
| 576 |
m_pStatusBar->resetSelectedStatue(photoSelctCount, videoSelctCount); |
| 577 |
} else { |
| 578 |
restorePicNum(); |
| 579 |
} |
| 580 |
} |
| 581 |
|
| 582 |
void TimeLineView::updateChoseText() |
| 583 |
{ |
| 584 |
#ifdef tablet_PC |
| 585 |
return; |
| 586 |
#endif |
| 587 |
} |
| 588 |
|
| 589 |
void TimeLineView::restorePicNum() |
| 590 |
{ |
| 591 |
int photoCount = 0; |
| 592 |
int videoCount = 0; |
| 593 |
if (VIEW_TIMELINE == m_pStackedWidget->currentIndex()) { |
| 594 |
photoCount = m_timeLineThumbnailListView->getAppointTypeItemCount(ItemTypePic); |
| 595 |
videoCount = m_timeLineThumbnailListView->getAppointTypeItemCount(ItemTypeVideo); |
| 596 |
} else if (VIEW_SEARCH == m_pStackedWidget->currentIndex()) { |
| 597 |
photoCount = pSearchView->m_pThumbnailListView->getAppointTypeItemCount(ItemTypePic); |
| 598 |
videoCount = pSearchView->m_pThumbnailListView->getAppointTypeItemCount(ItemTypeVideo); |
| 599 |
} |
| 600 |
m_pStatusBar->resetUnselectedStatue(photoCount, videoCount); |
| 601 |
} |
| 602 |
|
| 603 |
void TimeLineView::onKeyDelete() |
| 604 |
{ |
| 605 |
if (!isVisible()) return; |
| 606 |
if (VIEW_SEARCH == m_pStackedWidget->currentIndex()) return; |
| 607 |
|
| 608 |
QStringList paths; |
| 609 |
paths.clear(); |
| 610 |
|
| 611 |
//获取当前所有选中的 |
| 612 |
paths = m_timeLineThumbnailListView->selectedPaths(); |
| 613 |
if (0 >= paths.length()) { |
| 614 |
return; |
| 615 |
} |
| 616 |
|
| 617 |
if (m_timeLineThumbnailListView->isAllSelected()) { |
| 618 |
m_pStackedWidget->setCurrentIndex(VIEW_IMPORT); |
| 619 |
} |
| 620 |
|
| 621 |
m_timeLineThumbnailListView->clearSelection(); |
| 622 |
//清除选择之后同步状态给悬浮选择按钮 |
| 623 |
m_suspensionChose->setText(QObject::tr("Select")); |
| 624 |
ImageEngineApi::instance()->moveImagesToTrash(paths); |
| 625 |
} |