| 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 "mainwindow.h" |
| 22 |
#include "config.h" |
| 23 |
#include "controller/commandline.h" |
| 24 |
#include "dialogs/albumcreatedialog.h" |
| 25 |
#include "utils/unionimage.h" |
| 26 |
#include "imageengine/imageengineapi.h" |
| 27 |
#include "accessibledefine.h" |
| 28 |
#include "viewerthememanager.h" |
| 29 |
#include "ac-desktop-define.h" |
| 30 |
|
| 31 |
#include <QGraphicsDropShadowEffect> |
| 32 |
#include <QJsonArray> |
| 33 |
#include <QJsonDocument> |
| 34 |
#include <QProcess> |
| 35 |
#include <QDesktopWidget> |
| 36 |
#include <QShortcut> |
| 37 |
#include <QDir> |
| 38 |
|
| 39 |
#include <dgiovolumemanager.h> |
| 40 |
#include <dgiofile.h> |
| 41 |
#include <dgiofileinfo.h> |
| 42 |
#include <dgiovolume.h> |
| 43 |
#include <DTableView> |
| 44 |
#include <DApplicationHelper> |
| 45 |
#include <DFileDialog> |
| 46 |
#include <DApplication> |
| 47 |
#include <DMessageManager> |
| 48 |
#include <DFloatingMessage> |
| 49 |
#include <DWidgetUtil> |
| 50 |
#include <DStandardPaths> |
| 51 |
|
| 52 |
#include "imagedataservice.h" |
| 53 |
#include "movieservice.h" |
| 54 |
|
| 55 |
bool bfirstopen = true; |
| 56 |
bool bfirstandviewimage = false; |
| 57 |
namespace { |
| 58 |
const int VIEW_ALLPIC = 0; |
| 59 |
const int VIEW_TIMELINE = 1; |
| 60 |
const int VIEW_ALBUM = 2; |
| 61 |
const int VIEW_SEARCH = 3; |
| 62 |
const int VIEW_IMAGE = 4; |
| 63 |
const int VIEW_SLIDE = 5; |
| 64 |
|
| 65 |
//const QString TITLEBAR_NEWALBUM = "新建相册"; |
| 66 |
//const QString TITLEBAR_IMPORT = "导入照片"; |
| 67 |
//const QString TITLEBAR_NEWALBUM = "New album"; |
| 68 |
//const QString TITLEBAR_IMPORT = "Import photos"; |
| 69 |
|
| 70 |
}//namespace |
| 71 |
|
| 72 |
using namespace utils::common; |
| 73 |
MainWindow::MainWindow() |
| 74 |
: m_iCurrentView(VIEW_ALLPIC) |
| 75 |
, m_bTitleMenuImportClicked(false) |
| 76 |
, m_bImport(false) |
| 77 |
, m_titleBtnWidget(nullptr) |
| 78 |
, m_pTitleBarMenu(nullptr) |
| 79 |
, m_pCenterWidget(nullptr) |
| 80 |
, m_pAlbumview(nullptr) |
| 81 |
, m_pAlbumWidget(nullptr) |
| 82 |
, m_pAllPicView(nullptr) |
| 83 |
, m_pTimeLineView(nullptr) |
| 84 |
, m_pTimeLineWidget(nullptr) |
| 85 |
, m_pSearchView(nullptr) |
| 86 |
, m_pSearchEdit(nullptr) |
| 87 |
, m_commandLine(nullptr) |
| 88 |
, m_pDBManager(nullptr) |
| 89 |
, m_backIndex(0) |
| 90 |
, m_backIndex_fromSlide(0) |
| 91 |
, m_pSliderPos(2) |
| 92 |
, btnGroup(nullptr) |
| 93 |
, m_pAllPicBtn(nullptr) |
| 94 |
, m_pTimeBtn(nullptr) |
| 95 |
, m_pAlbumBtn(nullptr) |
| 96 |
, m_waitdailog(nullptr) |
| 97 |
, m_importBar(nullptr) |
| 98 |
, m_waitlabel(nullptr) |
| 99 |
, m_countLabel(nullptr) |
| 100 |
, m_settings(nullptr) |
| 101 |
, m_fileInotify(nullptr) |
| 102 |
{ |
| 103 |
this->setObjectName("drawMainWindow"); |
| 104 |
initShortcutKey(); //初始化各种快捷键 |
| 105 |
initUI(); |
| 106 |
initTitleBar(); //初始化顶部状态栏 |
| 107 |
initCentralWidget(); |
| 108 |
initNoPhotoNormalTabOrder(); |
| 109 |
initInstallFilter(); |
| 110 |
//性能优化,此句在构造时不需要执行,增加启动时间,放在showevent之后队列执行 |
| 111 |
loadZoomRatio(); |
| 112 |
m_bVector << true << true << true; |
| 113 |
connect(dApp->signalM, &SignalManager::showImageView, this, &MainWindow::onShowImageView); |
| 114 |
|
| 115 |
//平板模式下屏蔽最大化最小化及关闭按钮 |
| 116 |
#ifdef tablet_PC |
| 117 |
setWindowFlags(windowFlags() & ~(Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint)); |
| 118 |
#endif |
| 119 |
} |
| 120 |
|
| 121 |
MainWindow::~MainWindow() |
| 122 |
{ |
| 123 |
emit dApp->signalM->sigPauseOrStart(false); //唤醒外设后台挂载,防止析构时线程挂起卡住页面无法退出 |
| 124 |
ImageEngineApi::instance()->close(); |
| 125 |
QThreadPool::globalInstance()->clear(); |
| 126 |
QThreadPool::globalInstance()->waitForDone(); |
| 127 |
PrintHelper::getIntance()->deconstruction(); |
| 128 |
} |
| 129 |
|
| 130 |
void MainWindow::resizeEvent(QResizeEvent *e) |
| 131 |
{ |
| 132 |
Q_UNUSED(e); |
| 133 |
// qDebug() << "------" << __FUNCTION__ << "---size = " << this->size(); |
| 134 |
int m_SearchEditWidth = titlebar()->width() - m_titleBtnWidget->width() - TITLEBAR_BLANK_WIDTH; |
| 135 |
if (m_SearchEditWidth <= 350) { |
| 136 |
m_pSearchEdit->setFixedSize(m_SearchEditWidth - 20, 36); |
| 137 |
} else { |
| 138 |
m_SearchEditWidth = 350; |
| 139 |
m_pSearchEdit->setFixedSize(m_SearchEditWidth, 36); |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
bool MainWindow::eventFilter(QObject *obj, QEvent *event) |
| 144 |
{ |
| 145 |
// 键盘交互处理 |
| 146 |
if (event->type() == QEvent::KeyPress) { |
| 147 |
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); |
| 148 |
// tab键 交互处理 |
| 149 |
if (keyEvent->key() == Qt::Key_Tab) { |
| 150 |
if (initAllViewTabKeyOrder(obj)) { |
| 151 |
return true; |
| 152 |
} |
| 153 |
} |
| 154 |
// enter键 交互处理 |
| 155 |
else if (keyEvent->key() == Qt::Key_Enter || keyEvent->key() == Qt::Key_Return) { |
| 156 |
initEnterkeyAction(obj); |
| 157 |
} |
| 158 |
// 右键 交互处理 |
| 159 |
else if (keyEvent->key() == Qt::Key_Right) { |
| 160 |
if (initRightKeyOrder(obj)) { |
| 161 |
return true; |
| 162 |
} |
| 163 |
} |
| 164 |
// 左键 交互处理 |
| 165 |
else if (keyEvent->key() == Qt::Key_Left) { |
| 166 |
if (initLeftKeyOrder(obj)) { |
| 167 |
return true; |
| 168 |
} |
| 169 |
} |
| 170 |
// 向下键 交互处理 |
| 171 |
else if (keyEvent->key() == Qt::Key_Down) { |
| 172 |
if (initDownKeyOrder()) { |
| 173 |
return true; |
| 174 |
} |
| 175 |
} |
| 176 |
// 向上键 交互处理 |
| 177 |
else if (keyEvent->key() == Qt::Key_Up) { |
| 178 |
if (initUpKeyOrder()) { |
| 179 |
return true; |
| 180 |
} |
| 181 |
} |
| 182 |
} |
| 183 |
return QWidget::eventFilter(obj, event); |
| 184 |
} |
| 185 |
|
| 186 |
//初始化所有连接 |
| 187 |
void MainWindow::initConnections() |
| 188 |
{ |
| 189 |
qRegisterMetaType<DBImgInfoList>("DBImgInfoList &"); |
| 190 |
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, &MainWindow::setWaitDialogColor); |
| 191 |
//主界面切换(所有照片、时间线、相册) |
| 192 |
connect(btnGroup, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked), this, &MainWindow::onButtonClicked); |
| 193 |
// connect(dApp->signalM, &SignalManager::updatePicView, btnGroup, static_cast<void(QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked)); |
| 194 |
//图片导入槽函数 |
| 195 |
connect(this, &MainWindow::sigImageImported, this, &MainWindow::onImageImported); |
| 196 |
connect(dApp->signalM, &SignalManager::createAlbum, this, &MainWindow::onCreateAlbum); |
| 197 |
#if 1 |
| 198 |
connect(dApp->signalM, &SignalManager::viewCreateAlbum, this, &MainWindow::onViewCreateAlbum); |
| 199 |
#endif |
| 200 |
connect(m_pSearchEdit, &DSearchEdit::returnPressed, this, &MainWindow::onSearchEditFinished); |
| 201 |
//connect(m_pSearchEdit, &DSearchEdit::textChanged, this, &MainWindow::onSearchEditTextChanged); |
| 202 |
connect(m_pTitleBarMenu, &DMenu::triggered, this, &MainWindow::onTitleBarMenuClicked); |
| 203 |
connect(this, &MainWindow::sigTitleMenuImportClicked, this, &MainWindow::onImprotBtnClicked); |
| 204 |
//当有图片添加时,搜索栏可用 |
| 205 |
connect(dApp->signalM, &SignalManager::imagesInserted, this, &MainWindow::onImagesInserted); |
| 206 |
//开始导入时,清空状态 |
| 207 |
connect(dApp->signalM, &SignalManager::startImprot, this, &MainWindow::onStartImprot); |
| 208 |
//更新等待进度条 |
| 209 |
connect(dApp->signalM, &SignalManager::progressOfWaitDialog, this, &MainWindow::onProgressOfWaitDialog); |
| 210 |
//更新等待窗口文本信息 |
| 211 |
connect(dApp->signalM, &SignalManager::popupWaitDialog, this, &MainWindow::onPopupWaitDialog); |
| 212 |
//关闭等待窗口 |
| 213 |
connect(dApp->signalM, &SignalManager::closeWaitDialog, this, &MainWindow::onCloseWaitDialog); |
| 214 |
//图片移除,判断是否更新搜索框 |
| 215 |
connect(dApp->signalM, &SignalManager::imagesRemoved, this, &MainWindow::onImagesRemoved); |
| 216 |
//隐藏图片视图 |
| 217 |
connect(dApp->signalM, &SignalManager::hideImageView, this, &MainWindow::onHideImageView); |
| 218 |
//幻灯片显示 |
| 219 |
connect(dApp->signalM, &SignalManager::showSlidePanel, this, &MainWindow::onShowSlidePanel); |
| 220 |
//隐藏幻灯片显示 |
| 221 |
connect(dApp->signalM, &SignalManager::hideSlidePanel, this, &MainWindow::onHideSlidePanel); |
| 222 |
//导出图片 |
| 223 |
connect(dApp->signalM, &SignalManager::exportImage, this, &MainWindow::onExportImage); |
| 224 |
// connect(dApp->signalM, &SignalManager::showImageInfo, this, &MainWindow::onShowImageInfo); |
| 225 |
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::newProcessInstance, this, &MainWindow::onNewAPPOpen); |
| 226 |
//右下角滑动条 |
| 227 |
connect(dApp->signalM, &SignalManager::sigMainwindowSliderValueChg, this, &MainWindow::onMainwindowSliderValueChg); |
| 228 |
connect(dApp->signalM, &SignalManager::sigAlbDelToast, this, &MainWindow::onAlbDelToast); |
| 229 |
// 添加到相册底部提示 |
| 230 |
connect(dApp->signalM, &SignalManager::sigAddDuplicatePhotos, this, &MainWindow::onAddDuplicatePhotos); |
| 231 |
connect(dApp->signalM, &SignalManager::RepeatImportingTheSamePhotos, this, &MainWindow::onRepeatImportingTheSamePhotos); |
| 232 |
// 添加到相册底部提示 |
| 233 |
connect(dApp->signalM, &SignalManager::sigAddToAlbToast, this, &MainWindow::onAddToAlbToast); |
| 234 |
//底部,弹出导入成功提示框 |
| 235 |
connect(dApp->signalM, &SignalManager::ImportSuccess, this, &MainWindow::onImportSuccess); |
| 236 |
connect(dApp->signalM, &SignalManager::SearchEditClear, this, &MainWindow::onSearchEditClear); |
| 237 |
//导入失败提示框 |
| 238 |
connect(dApp->signalM, &SignalManager::ImportFailed, this, &MainWindow::onImportFailed); |
| 239 |
//部分导入失败提示框 |
| 240 |
connect(dApp->signalM, &SignalManager::ImportSomeFailed, this, &MainWindow::onImportSomeFailed); |
| 241 |
//图片导出失败提示框 |
| 242 |
connect(dApp->signalM, &SignalManager::ImgExportFailed, this, &MainWindow::onImgExportFailed); |
| 243 |
//图片导出成功提示框 |
| 244 |
connect(dApp->signalM, &SignalManager::ImgExportSuccess, this, &MainWindow::onImgExportSuccess); |
| 245 |
//相册导出失败提示框 |
| 246 |
connect(dApp->signalM, &SignalManager::AlbExportFailed, this, &MainWindow::onAlbExportFailed); |
| 247 |
//相册导出成功提示框 |
| 248 |
connect(dApp->signalM, &SignalManager::AlbExportSuccess, this, &MainWindow::onAlbExportSuccess); |
| 249 |
//没找到图片或视频提示框 |
| 250 |
connect(dApp->signalM, &SignalManager::ImportDonotFindPicOrVideo, this, &MainWindow::onImportDonotFindPicOrVideo); |
| 251 |
} |
| 252 |
|
| 253 |
//初始化快捷键 |
| 254 |
void MainWindow::initShortcut() |
| 255 |
{ |
| 256 |
QShortcut *esc = new QShortcut(QKeySequence(Qt::Key_Escape), this); |
| 257 |
esc->setContext(Qt::WindowShortcut); |
| 258 |
connect(esc, &QShortcut::activated, this, &MainWindow::onEscShortcutActivated); |
| 259 |
|
| 260 |
// Album View画面按DEL快捷键 |
| 261 |
QShortcut *del = new QShortcut(QKeySequence(Qt::Key_Delete), this); |
| 262 |
del->setContext(Qt::ApplicationShortcut); |
| 263 |
connect(del, &QShortcut::activated, this, &MainWindow::onDelShortcutActivated); |
| 264 |
|
| 265 |
// Album View画面按F2快捷键 |
| 266 |
QShortcut *keyF2 = new QShortcut(QKeySequence(Qt::Key_F2), this); |
| 267 |
keyF2->setContext(Qt::ApplicationShortcut); |
| 268 |
connect(keyF2, &QShortcut::activated, this, &MainWindow::onKeyF2ShortcutActivated); |
| 269 |
|
| 270 |
//Ctrl+Up 缩略图放大 |
| 271 |
QShortcut *CtrlUp = new QShortcut(QKeySequence(CTRLUP_SHORTCUT), this); |
| 272 |
CtrlUp->setContext(Qt::ApplicationShortcut); |
| 273 |
connect(CtrlUp, &QShortcut::activated, this, &MainWindow::thumbnailZoomIn); |
| 274 |
|
| 275 |
QShortcut *ReCtrlUp = new QShortcut(QKeySequence(RECTRLUP_SHORTCUT), this); |
| 276 |
ReCtrlUp->setContext(Qt::ApplicationShortcut); |
| 277 |
connect(ReCtrlUp, &QShortcut::activated, this, &MainWindow::thumbnailZoomIn); |
| 278 |
|
| 279 |
//Ctrl+Down 缩略图缩小 |
| 280 |
QShortcut *CtrlDown = new QShortcut(QKeySequence(CTRLDOWN_SHORTCUT), this); |
| 281 |
CtrlDown->setContext(Qt::ApplicationShortcut); |
| 282 |
connect(CtrlDown, &QShortcut::activated, this, &MainWindow::thumbnailZoomOut); |
| 283 |
|
| 284 |
//Ctrl+Shift+/ 显示快捷键预览 |
| 285 |
QShortcut *CtrlShiftSlash = new QShortcut(QKeySequence(CTRLSHIFTSLASH_SHORTCUT), this); |
| 286 |
CtrlShiftSlash->setContext(Qt::ApplicationShortcut); |
| 287 |
connect(CtrlShiftSlash, &QShortcut::activated, this, &MainWindow::onCtrlShiftSlashShortcutActivated); |
| 288 |
|
| 289 |
//Ctrl+F/ 搜索 |
| 290 |
QShortcut *CtrlF = new QShortcut(QKeySequence(CTRLF_SHORTCUT), this); |
| 291 |
CtrlF->setContext(Qt::ApplicationShortcut); |
| 292 |
connect(CtrlF, &QShortcut::activated, this, &MainWindow::onCtrlFShortcutActivated); |
| 293 |
} |
| 294 |
|
| 295 |
//初始化UI |
| 296 |
void MainWindow::initUI() |
| 297 |
{ |
| 298 |
initWaitDialog(); |
| 299 |
setMinimumSize(880, 500); |
| 300 |
resize(1300, 848); |
| 301 |
loadWindowState(); |
| 302 |
} |
| 303 |
|
| 304 |
//初始化等待窗口 |
| 305 |
void MainWindow::initWaitDialog() |
| 306 |
{ |
| 307 |
m_waitdailog = new DDialog(this); |
| 308 |
|
| 309 |
m_waitdailog->setCloseButtonVisible(false); |
| 310 |
m_waitdailog->setWindowModality(Qt::WindowModal); |
| 311 |
m_waitdailog->setFixedSize(QSize(480, 93)); |
| 312 |
|
| 313 |
m_waitlabel = new DLabel(m_waitdailog); |
| 314 |
m_waitlabel->setFixedSize(400, 30);//160,30 |
| 315 |
m_waitlabel->move(40, 7); |
| 316 |
DFontSizeManager::instance()->bind(m_waitlabel, DFontSizeManager::T5, QFont::Medium); |
| 317 |
|
| 318 |
m_countLabel = new DLabel(m_waitdailog); |
| 319 |
m_countLabel->setFixedSize(350, 26); |
| 320 |
m_countLabel->move(40, 37); |
| 321 |
DFontSizeManager::instance()->bind(m_countLabel, DFontSizeManager::T6, QFont::DemiBold); |
| 322 |
|
| 323 |
m_importBar = new DProgressBar(m_waitdailog); |
| 324 |
m_importBar->setFixedSize(400, 6); |
| 325 |
m_importBar->move(40, 67); |
| 326 |
|
| 327 |
setWaitDialogColor(); |
| 328 |
|
| 329 |
} |
| 330 |
|
| 331 |
//初始化顶部状态栏 |
| 332 |
void MainWindow::initTitleBar() |
| 333 |
{ |
| 334 |
// TitleBar Button |
| 335 |
if (m_titleBtnWidget) { |
| 336 |
delete m_titleBtnWidget; |
| 337 |
m_titleBtnWidget = nullptr; |
| 338 |
} |
| 339 |
m_titleBtnWidget = new DWidget(); |
| 340 |
m_titleBtnWidget->setFocusPolicy(Qt::NoFocus); |
| 341 |
setFocusPolicy(Qt::NoFocus); |
| 342 |
AC_SET_OBJECT_NAME(m_titleBtnWidget, MainWindow_TitleBtn_Widget); |
| 343 |
AC_SET_ACCESSIBLE_NAME(m_titleBtnWidget, MainWindow_TitleBtn_Widget); |
| 344 |
btnGroup = new QButtonGroup(); |
| 345 |
btnGroup->setExclusive(true); |
| 346 |
QHBoxLayout *pTitleBtnLayout = new QHBoxLayout(); |
| 347 |
|
| 348 |
m_pAllPicBtn = new DPushButton(); |
| 349 |
m_pAllPicBtn->setFocusPolicy(Qt::TabFocus); |
| 350 |
AC_SET_OBJECT_NAME(m_pAllPicBtn, Main_All_Picture_Button); |
| 351 |
AC_SET_ACCESSIBLE_NAME(m_pAllPicBtn, Main_All_Picture_Button); |
| 352 |
|
| 353 |
// m_pAllPicBtn = new DSuggestButton(); |
| 354 |
m_pAllPicBtn->setFlat(true); |
| 355 |
// m_pAllPicBtn->setFixedSize(80, 36); |
| 356 |
m_pAllPicBtn->setMaximumSize(110, 36); |
| 357 |
m_pAllPicBtn->setCheckable(true); |
| 358 |
m_pAllPicBtn->setChecked(true); |
| 359 |
m_pAllPicBtn->setText(tr("All Photos")); |
| 360 |
btnGroup->addButton(m_pAllPicBtn, 0); |
| 361 |
DFontSizeManager::instance()->bind(m_pAllPicBtn, DFontSizeManager::T6); |
| 362 |
pTitleBtnLayout->addWidget(m_pAllPicBtn); |
| 363 |
|
| 364 |
m_pTimeBtn = new DPushButton(); |
| 365 |
m_pTimeBtn->setFocusPolicy(Qt::TabFocus); |
| 366 |
AC_SET_OBJECT_NAME(m_pTimeBtn, Main_Time_Line_Button); |
| 367 |
AC_SET_ACCESSIBLE_NAME(m_pTimeBtn, Main_Time_Line_Button); |
| 368 |
// m_pTimeBtn = new DSuggestButton(); |
| 369 |
m_pTimeBtn->setFlat(true); |
| 370 |
// m_pTimeBtn->setFixedSize(60, 36); |
| 371 |
m_pTimeBtn->setMaximumSize(110, 36); |
| 372 |
m_pTimeBtn->setCheckable(true); |
| 373 |
m_pTimeBtn->setText(tr("Timelines")); |
| 374 |
btnGroup->addButton(m_pTimeBtn, 1); |
| 375 |
DFontSizeManager::instance()->bind(m_pTimeBtn, DFontSizeManager::T6); |
| 376 |
pTitleBtnLayout->addSpacing(-6); |
| 377 |
pTitleBtnLayout->addWidget(m_pTimeBtn); |
| 378 |
|
| 379 |
m_pAlbumBtn = new DPushButton(); |
| 380 |
m_pAlbumBtn->setFocusPolicy(Qt::TabFocus); |
| 381 |
AC_SET_OBJECT_NAME(m_pAlbumBtn, Main_Album_Button); |
| 382 |
AC_SET_ACCESSIBLE_NAME(m_pAlbumBtn, Main_Album_Button); |
| 383 |
// m_pAlbumBtn = new DSuggestButton(); |
| 384 |
m_pAlbumBtn->setFlat(true); |
| 385 |
// m_pAlbumBtn->setFixedSize(60, 36); |
| 386 |
m_pAlbumBtn->setMaximumSize(90, 36); |
| 387 |
m_pAlbumBtn->setCheckable(true); |
| 388 |
m_pAlbumBtn->setText(tr("Albums")); |
| 389 |
btnGroup->addButton(m_pAlbumBtn, 2); |
| 390 |
DFontSizeManager::instance()->bind(m_pTimeBtn, DFontSizeManager::T6); |
| 391 |
pTitleBtnLayout->addSpacing(-6); |
| 392 |
pTitleBtnLayout->addWidget(m_pAlbumBtn); |
| 393 |
|
| 394 |
m_titleBtnWidget->setLayout(pTitleBtnLayout); |
| 395 |
|
| 396 |
// TitleBar Search |
| 397 |
m_pSearchEdit = new DSearchEdit(m_titleBtnWidget); |
| 398 |
m_pSearchEdit->lineEdit()->setFocusPolicy(Qt::ClickFocus); |
| 399 |
m_pSearchEdit->setMaximumSize(350, 36); |
| 400 |
if (0 < DBManager::instance()->getImgsCount()) { |
| 401 |
m_pSearchEdit->setEnabled(true); |
| 402 |
} else { |
| 403 |
m_pSearchEdit->setEnabled(false); |
| 404 |
} |
| 405 |
|
| 406 |
connect(m_pSearchEdit, &DSearchEdit::focusChanged, |
| 407 |
m_pSearchEdit, [ = ](bool onFocus) { |
| 408 |
if (!onFocus) { |
| 409 |
if (m_pSearchEdit->lineEdit()) { |
| 410 |
m_pSearchEdit->lineEdit()->clearFocus(); |
| 411 |
} |
| 412 |
m_pSearchEdit->clearFocus(); |
| 413 |
} |
| 414 |
}); |
| 415 |
|
| 416 |
// pTitleSearchLayout->addWidget(m_pSearchEdit); |
| 417 |
//m_titleSearchWidget->setLayout(pTitleSearchLayout); |
| 418 |
|
| 419 |
// TitleBar Menu |
| 420 |
m_pTitleBarMenu = new DMenu(); |
| 421 |
QAction *pNewAlbum = new QAction(this); |
| 422 |
addAction(pNewAlbum); |
| 423 |
pNewAlbum->setObjectName("New album"); |
| 424 |
|
| 425 |
pNewAlbum->setText(tr("New album")); |
| 426 |
pNewAlbum->setShortcut(QKeySequence(CTRLSHIFTN_SHORTCUT)); |
| 427 |
m_pTitleBarMenu->addAction(pNewAlbum); |
| 428 |
|
| 429 |
QAction *pImport = new QAction(this); |
| 430 |
AC_SET_OBJECT_NAME(pImport, Import_Image_View); |
| 431 |
addAction(pImport); |
| 432 |
|
| 433 |
pImport->setText(tr("Import photos")); |
| 434 |
pImport->setShortcut(QKeySequence(CTRLO_SHORTCUT)); |
| 435 |
m_pTitleBarMenu->addAction(pImport); |
| 436 |
m_pTitleBarMenu->addSeparator(); |
| 437 |
|
| 438 |
titlebar()->addWidget(m_titleBtnWidget, Qt::AlignLeft); |
| 439 |
#ifndef tablet_PC |
| 440 |
titlebar()->addWidget(m_pSearchEdit, Qt::AlignHCenter); |
| 441 |
#endif |
| 442 |
titlebar()->setIcon(QIcon::fromTheme("deepin-album")); |
| 443 |
titlebar()->setMenu(m_pTitleBarMenu); |
| 444 |
// titlebar()->setBlurBackground(true);// 0308 zy ui确认,取消标题栏透明效果 |
| 445 |
AC_SET_OBJECT_NAME(titlebar(), MainWindow_Titlebar); |
| 446 |
AC_SET_ACCESSIBLE_NAME(titlebar(), MainWindow_Titlebar); |
| 447 |
|
| 448 |
#ifdef tablet_PC |
| 449 |
m_pSearchEdit->hide(); |
| 450 |
#endif |
| 451 |
} |
| 452 |
|
| 453 |
//初始化中心界面 |
| 454 |
void MainWindow::initCentralWidget() |
| 455 |
{ |
| 456 |
m_pCenterWidget = new QStackedWidget(this); |
| 457 |
this->setCentralWidget(m_pCenterWidget); |
| 458 |
m_pCenterWidget->setFocusPolicy(Qt::NoFocus); |
| 459 |
AC_SET_OBJECT_NAME(m_pCenterWidget, MainWindow_Center_Widget); |
| 460 |
AC_SET_ACCESSIBLE_NAME(m_pCenterWidget, MainWindow_Center_Widget); |
| 461 |
m_pCenterWidget->lower(); |
| 462 |
|
| 463 |
m_pAllPicView = new AllPicView(); //所有照片界面 |
| 464 |
m_pTimeLineWidget = new QWidget(); |
| 465 |
//m_pTimeLineView = new TimeLineView(); //时间线界面 |
| 466 |
m_pAlbumWidget = new QWidget(); |
| 467 |
//m_pAlbumview = new AlbumView(); //相册界面 |
| 468 |
//m_pSearchView = new SearchView(); //搜索界面 |
| 469 |
m_pSearchViewWidget = new QWidget(); |
| 470 |
|
| 471 |
m_commandLine = CommandLine::instance(); |
| 472 |
m_commandLine->setThreads(this); |
| 473 |
m_slidePanel = new SlideShowPanel(); |
| 474 |
|
| 475 |
m_pCenterWidget->addWidget(m_pAllPicView); |
| 476 |
|
| 477 |
m_pCenterWidget->addWidget(m_pTimeLineWidget); |
| 478 |
//m_pCenterWidget->addWidget(m_pTimeLineView); |
| 479 |
m_pCenterWidget->addWidget(m_pAlbumWidget); |
| 480 |
//m_pCenterWidget->addWidget(m_pAlbumview); |
| 481 |
|
| 482 |
//m_pCenterWidget->addWidget(m_pSearchView); |
| 483 |
m_pCenterWidget->addWidget(m_pSearchViewWidget); |
| 484 |
m_pCenterWidget->addWidget(m_commandLine); |
| 485 |
m_pCenterWidget->addWidget(m_slidePanel); |
| 486 |
|
| 487 |
QStringList parselist; |
| 488 |
m_commandLine->processOption(parselist); |
| 489 |
if (parselist.length() > 0) { |
| 490 |
QStringList absoluteFilePaths; |
| 491 |
for (int i = 0; i < parselist.size(); i++) { |
| 492 |
QFileInfo inf(parselist.at(i)); |
| 493 |
absoluteFilePaths << inf.absoluteFilePath(); |
| 494 |
} |
| 495 |
ImageDataService::instance()->readThumbnailByPaths(absoluteFilePaths); |
| 496 |
ImageEngineApi::instance()->ImportImagesFromFileList(absoluteFilePaths, "", this); |
| 497 |
//暂不支持视频首帧查看,只支持导入,视频和图片分开处理 |
| 498 |
QString firstStr = absoluteFilePaths.at(0); |
| 499 |
if (utils::base::isVideo(firstStr)) { |
| 500 |
m_processOptionIsEmpty = true; |
| 501 |
m_pCenterWidget->setCurrentIndex(VIEW_ALLPIC); |
| 502 |
} else { |
| 503 |
m_processOptionIsEmpty = false; |
| 504 |
titlebar()->setVisible(false); |
| 505 |
setTitlebarShadowEnabled(false); |
| 506 |
//查看图片 |
| 507 |
m_commandLine->viewImage(firstStr, absoluteFilePaths); |
| 508 |
m_pCenterWidget->setCurrentIndex(VIEW_IMAGE); |
| 509 |
m_backIndex = VIEW_ALLPIC; |
| 510 |
} |
| 511 |
} else { |
| 512 |
//性能优化,此句在构造时不需要执行,增加启动时间 |
| 513 |
m_processOptionIsEmpty = true; |
| 514 |
m_pCenterWidget->setCurrentIndex(VIEW_ALLPIC); |
| 515 |
} |
| 516 |
} |
| 517 |
|
| 518 |
void MainWindow::initInstallFilter() |
| 519 |
{ |
| 520 |
foreach (auto widget, m_emptyAllViewTabOrder) { |
| 521 |
widget->installEventFilter(this); |
| 522 |
} |
| 523 |
m_pSearchEdit->lineEdit()->installEventFilter(this); |
| 524 |
} |
| 525 |
|
| 526 |
// 界面无图时 tab切换顺序 |
| 527 |
void MainWindow::initNoPhotoNormalTabOrder() |
| 528 |
{ |
| 529 |
// titlebar tab键循环时会focus,隐掉 |
| 530 |
m_emptyAllViewTabOrder.clear(); |
| 531 |
m_emptyAllViewTabOrder.insert(0, m_pAllPicBtn); |
| 532 |
m_emptyAllViewTabOrder.insert(1, m_pTimeBtn); |
| 533 |
m_emptyAllViewTabOrder.insert(2, m_pAlbumBtn); |
| 534 |
QWidget *optionButton = titlebar()->findChild<QWidget *>("DTitlebarDWindowOptionButton"); |
| 535 |
QWidget *minButton = titlebar()->findChild<QWidget *>("DTitlebarDWindowMinButton"); |
| 536 |
QWidget *maxButton = titlebar()->findChild<QWidget *>("DTitlebarDWindowMaxButton"); |
| 537 |
QWidget *closeButton = titlebar()->findChild<QWidget *>("DTitlebarDWindowCloseButton"); |
| 538 |
m_emptyAllViewTabOrder.insert(3, optionButton); |
| 539 |
m_emptyAllViewTabOrder.insert(4, minButton); |
| 540 |
m_emptyAllViewTabOrder.insert(5, maxButton); |
| 541 |
m_emptyAllViewTabOrder.insert(6, closeButton); |
| 542 |
m_emptyAllViewTabOrder.insert(7, m_pAllPicView->m_pImportView->m_pImportBtn); |
| 543 |
|
| 544 |
// allpicview |
| 545 |
if (m_iCurrentView == VIEW_ALLPIC && m_pAllPicView->m_pStackedWidget->currentIndex() == 0) { |
| 546 |
m_emptyAllViewTabOrder[7] = m_pAllPicView->m_pImportView->m_pImportBtn; |
| 547 |
} |
| 548 |
// timelineview |
| 549 |
else if (m_iCurrentView == VIEW_TIMELINE && m_pTimeLineView->m_pStackedWidget->currentIndex() == 0) { |
| 550 |
m_emptyAllViewTabOrder[7] = m_pTimeLineView->pImportView->m_pImportBtn; |
| 551 |
} |
| 552 |
// albumview |
| 553 |
else if (m_iCurrentView == VIEW_ALBUM && m_pAlbumview->m_pRightStackWidget->currentIndex() == 0) { |
| 554 |
m_emptyAllViewTabOrder[7] = m_pAlbumview->m_pImportView->m_pImportBtn; |
| 555 |
} |
| 556 |
for (int idx = 0; idx < m_emptyAllViewTabOrder.count(); idx++) { |
| 557 |
m_emptyAllViewTabOrder.at(idx)->setFocusPolicy(Qt::TabFocus); |
| 558 |
} |
| 559 |
for (int idx = 0; idx < m_emptyAllViewTabOrder.count() - 1; idx++) { |
| 560 |
this->setTabOrder(m_emptyAllViewTabOrder.at(idx), m_emptyAllViewTabOrder.at(idx + 1)); |
| 561 |
} |
| 562 |
} |
| 563 |
|
| 564 |
// allpicview界面存在图片时 tab切换顺序 |
| 565 |
void MainWindow::initAllpicViewTabOrder() |
| 566 |
{ |
| 567 |
if (!m_pAllPicView->getThumbnailListView()) |
| 568 |
return; |
| 569 |
m_AllpicViewTabOrder.clear(); |
| 570 |
m_AllpicViewTabOrder.insert(0, m_pAllPicBtn); |
| 571 |
m_AllpicViewTabOrder.insert(1, m_pTimeBtn); |
| 572 |
m_AllpicViewTabOrder.insert(2, m_pAlbumBtn); |
| 573 |
QWidget *optionButton = titlebar()->findChild<QWidget *>("DTitlebarDWindowOptionButton"); |
| 574 |
QWidget *minButton = titlebar()->findChild<QWidget *>("DTitlebarDWindowMinButton"); |
| 575 |
QWidget *maxButton = titlebar()->findChild<QWidget *>("DTitlebarDWindowMaxButton"); |
| 576 |
QWidget *closeButton = titlebar()->findChild<QWidget *>("DTitlebarDWindowCloseButton"); |
| 577 |
m_AllpicViewTabOrder.insert(3, m_pSearchEdit->lineEdit()); |
| 578 |
m_AllpicViewTabOrder.insert(4, optionButton); |
| 579 |
m_AllpicViewTabOrder.insert(5, minButton); |
| 580 |
m_AllpicViewTabOrder.insert(6, maxButton); |
| 581 |
m_AllpicViewTabOrder.insert(7, closeButton); |
| 582 |
m_AllpicViewTabOrder.insert(8, m_pAllPicView->getThumbnailListView()); |
| 583 |
|
| 584 |
if (m_AlbumViewTabOrder.count() > 0) { |
| 585 |
m_pAlbumBtn->setFocusPolicy(Qt::NoFocus); |
| 586 |
m_pAlbumview->m_pLeftListView->m_pPhotoLibListView->setFocusPolicy(Qt::NoFocus); |
| 587 |
} |
| 588 |
for (int j = 0; j < m_AllpicViewTabOrder.count(); j++) { |
| 589 |
if (m_AllpicViewTabOrder.at(j)) { |
| 590 |
m_AllpicViewTabOrder.at(j)->setFocusPolicy(Qt::TabFocus); |
| 591 |
} |
| 592 |
} |
| 593 |
m_pSearchEdit->lineEdit()->setFocusPolicy(Qt::StrongFocus); |
| 594 |
for (int k = 0; k < m_AllpicViewTabOrder.count() - 1; k++) { |
| 595 |
this->setTabOrder(m_AllpicViewTabOrder.at(k), m_AllpicViewTabOrder.at(k + 1)); |
| 596 |
} |
| 597 |
} |
| 598 |
|
| 599 |
void MainWindow::initTimeLineViewTabOrder() |
| 600 |
{ |
| 601 |
// 时间线listview空 |
| 602 |
if (!m_pTimeLineView->getThumbnailListView()) |
| 603 |
return; |
| 604 |
m_pTimeLineView->getThumbnailListView()->setFocusPolicy(Qt::TabFocus); |
| 605 |
m_TimelineViewTabOrder.clear(); |
| 606 |
m_TimelineViewTabOrder.insert(1, m_pTimeBtn); |
| 607 |
m_TimelineViewTabOrder.insert(2, m_pTimeLineView->getThumbnailListView()); |
| 608 |
for (int idx = 0; idx < m_emptyAllViewTabOrder.count(); idx++) { |
| 609 |
if (m_emptyAllViewTabOrder.at(idx) != nullptr) { |
| 610 |
m_emptyAllViewTabOrder.at(idx)->setFocusPolicy(Qt::NoFocus); |
| 611 |
} |
| 612 |
} |
| 613 |
|
| 614 |
#ifndef tablet_PC |
| 615 |
m_pSearchEdit->lineEdit()->setFocusPolicy(Qt::ClickFocus); |
| 616 |
#endif |
| 617 |
|
| 618 |
for (int idx = 0; idx < m_TimelineViewTabOrder.count(); idx++) { |
| 619 |
#ifndef tablet_PC |
| 620 |
m_TimelineViewTabOrder.at(idx)->setFocusPolicy(Qt::TabFocus); |
| 621 |
#else |
| 622 |
m_TimelineViewTabOrder.at(idx)->setFocusPolicy(Qt::NoFocus); |
| 623 |
#endif |
| 624 |
} |
| 625 |
|
| 626 |
this->setTabOrder(m_TimelineViewTabOrder.at(0), m_TimelineViewTabOrder.at(1)); |
| 627 |
} |
| 628 |
|
| 629 |
void MainWindow::initAlbumViewTabOrder() |
| 630 |
{ |
| 631 |
// 时间线listview空 |
| 632 |
if (!m_pAlbumview->m_pImpTimeLineView->getListView()) |
| 633 |
return; |
| 634 |
m_pAlbumview->m_pImpTimeLineView->getListView()->setFocusPolicy(Qt::TabFocus); |
| 635 |
m_AlbumViewTabOrder.clear(); |
| 636 |
m_AlbumViewTabOrder.insert(0, m_pAlbumBtn); |
| 637 |
m_AlbumViewTabOrder.insert(1, m_pAlbumview->m_pLeftListView->m_pPhotoLibListView); |
| 638 |
m_AlbumViewTabOrder.insert(2, m_pAlbumview->m_pImpTimeLineView->getListView()); |
| 639 |
for (int idx = 0; idx < m_emptyAllViewTabOrder.count(); idx++) { |
| 640 |
if (m_emptyAllViewTabOrder.at(idx) != nullptr) { |
| 641 |
m_emptyAllViewTabOrder.at(idx)->setFocusPolicy(Qt::NoFocus); |
| 642 |
} |
| 643 |
} |
| 644 |
|
| 645 |
#ifndef tablet_PC |
| 646 |
m_pSearchEdit->lineEdit()->setFocusPolicy(Qt::ClickFocus); |
| 647 |
#endif |
| 648 |
|
| 649 |
this->setTabOrder(m_AlbumViewTabOrder.at(0), m_AlbumViewTabOrder.at(1)); |
| 650 |
this->setTabOrder(m_AlbumViewTabOrder.at(1), m_AlbumViewTabOrder.at(2)); |
| 651 |
|
| 652 |
for (int idx = 0; idx < m_AlbumViewTabOrder.count(); idx++) { |
| 653 |
#ifndef tablet_PC |
| 654 |
m_AlbumViewTabOrder.at(idx)->setFocusPolicy(Qt::TabFocus); |
| 655 |
#else |
| 656 |
m_AlbumViewTabOrder.at(idx)->setFocusPolicy(Qt::NoFocus); |
| 657 |
#endif |
| 658 |
} |
| 659 |
} |
| 660 |
|
| 661 |
void MainWindow::initEnterkeyAction(QObject *obj) |
| 662 |
{ |
| 663 |
if (m_pAllPicView->m_pStackedWidget->currentIndex() == 0 || m_iCurrentView == VIEW_ALLPIC) { |
| 664 |
// 相册内没有图时,应用初始启动无图时enter键进入 |
| 665 |
QPushButton *pTempBtn = dynamic_cast<QPushButton *>(obj); |
| 666 |
if (pTempBtn && m_emptyAllViewTabOrder.contains(pTempBtn)) { |
| 667 |
emit pTempBtn->click(); |
| 668 |
} |
| 669 |
} |
| 670 |
if (m_iCurrentView == VIEW_ALBUM) { |
| 671 |
// 相册内没有图时,应用初始启动无图时enter键进入 |
| 672 |
QPushButton *pTempBtn = dynamic_cast<QPushButton *>(obj); |
| 673 |
if (pTempBtn && m_AlbumViewTabOrder.contains(pTempBtn)) { |
| 674 |
emit pTempBtn->click(); |
| 675 |
} else if (obj == m_pAlbumview->m_pLeftListView->m_pPhotoLibListView) { |
| 676 |
QModelIndex tempIndex = m_pAlbumview->m_pLeftListView->m_pPhotoLibListView->currentIndex(); |
| 677 |
emit m_pAlbumview->m_pLeftListView->m_pPhotoLibListView->pressed(tempIndex); |
| 678 |
} else if (obj == m_pAlbumview->m_pLeftListView->m_pMountListWidget) { |
| 679 |
QModelIndex tempIndex = m_pAlbumview->m_pLeftListView->m_pMountListWidget->currentIndex(); |
| 680 |
emit m_pAlbumview->m_pLeftListView->m_pMountListWidget->pressed(tempIndex); |
| 681 |
} else if (obj == m_pAlbumview->m_pLeftListView->m_pCustomizeListView) { |
| 682 |
QModelIndex tempIndex = m_pAlbumview->m_pLeftListView->m_pCustomizeListView->currentIndex(); |
| 683 |
emit m_pAlbumview->m_pLeftListView->m_pCustomizeListView->pressed(tempIndex); |
| 684 |
} |
| 685 |
} |
| 686 |
} |
| 687 |
|
| 688 |
bool MainWindow::initRightKeyOrder(QObject *obj) |
| 689 |
{ |
| 690 |
// 无图且当前界面非所有照片界面,屏蔽btngroup左右键切换 |
| 691 |
if (m_pAllPicView->m_pStackedWidget->currentIndex() == 0 && m_iCurrentView != VIEW_ALLPIC) { |
| 692 |
if (m_emptyAllViewTabOrder.contains(dynamic_cast<QWidget *>(obj))) { |
| 693 |
if (m_emptyAllViewTabOrder.indexOf(dynamic_cast<QWidget *>(obj)) < 3) { |
| 694 |
return true; |
| 695 |
} |
| 696 |
} |
| 697 |
} |
| 698 |
// 无图且当前界面是所有照片界面时,标题栏焦点可以左右键切换,其他界面不允许切换 |
| 699 |
else if (m_pAllPicView->m_pStackedWidget->currentIndex() == 0 && m_iCurrentView == VIEW_ALLPIC) { |
| 700 |
if (m_emptyAllViewTabOrder.contains(dynamic_cast<QWidget *>(obj))) { |
| 701 |
int index = m_emptyAllViewTabOrder.indexOf(dynamic_cast<QWidget *>(obj)); |
| 702 |
// 焦点范围限定在标题栏 |
| 703 |
QWidget *pTempWidget = dynamic_cast<QWidget *>(m_emptyAllViewTabOrder.at((index + 1) % (m_emptyAllViewTabOrder.count() - 1))); |
| 704 |
pTempWidget->setFocus(); |
| 705 |
return true; |
| 706 |
} |
| 707 |
} |
| 708 |
// 有图所有照片界面 |
| 709 |
else if (m_iCurrentView == VIEW_ALLPIC) { |
| 710 |
// 必须初始化tab order,因为第一次tab键不触发事件 |
| 711 |
initAllpicViewTabOrder(); |
| 712 |
if (m_AllpicViewTabOrder.contains(dynamic_cast<QWidget *>(obj)) && obj != m_pAllPicView->getThumbnailListView()) { |
| 713 |
int index = m_AllpicViewTabOrder.indexOf(dynamic_cast<QWidget *>(obj)); |
| 714 |
// 焦点范围限定在标题栏 |
| 715 |
QWidget *pTempWidget = dynamic_cast<QWidget *>(m_AllpicViewTabOrder.at((index + 1) % (m_AllpicViewTabOrder.count() - 1))); |
| 716 |
pTempWidget->setFocus(); |
| 717 |
return true; |
| 718 |
} |
| 719 |
} |
| 720 |
return false; |
| 721 |
} |
| 722 |
|
| 723 |
bool MainWindow::initLeftKeyOrder(QObject *obj) |
| 724 |
{ |
| 725 |
// 无图且当前界面非所有照片界面,屏蔽btngroup左右键切换 |
| 726 |
if (m_pAllPicView->m_pStackedWidget->currentIndex() == 0 && m_iCurrentView != VIEW_ALLPIC) { |
| 727 |
if (m_emptyAllViewTabOrder.contains(dynamic_cast<QWidget *>(obj))) { |
| 728 |
if (m_emptyAllViewTabOrder.indexOf(dynamic_cast<QWidget *>(obj)) < 3) { |
| 729 |
return true; |
| 730 |
} |
| 731 |
} |
| 732 |
} |
| 733 |
// 无图且当前界面是所有照片界面时,标题栏左右键切换 |
| 734 |
if (m_pAllPicView->m_pStackedWidget->currentIndex() == 0 && m_iCurrentView == VIEW_ALLPIC) { |
| 735 |
if (m_emptyAllViewTabOrder.contains(dynamic_cast<QWidget *>(obj))) { |
| 736 |
int wgtIndex = m_emptyAllViewTabOrder.indexOf(dynamic_cast<QWidget *>(obj)); |
| 737 |
// 焦点范围限定在标题栏 |
| 738 |
QWidget *pTempWidget = dynamic_cast<QWidget *>(m_emptyAllViewTabOrder.at((wgtIndex + m_emptyAllViewTabOrder.count() - 2) % (m_emptyAllViewTabOrder.count() - 1))); |
| 739 |
pTempWidget->setFocus(); |
| 740 |
return true; |
| 741 |
} |
| 742 |
} |
| 743 |
// 有图所有照片界面 |
| 744 |
else if (m_iCurrentView == VIEW_ALLPIC) { |
| 745 |
if (m_AllpicViewTabOrder.contains(dynamic_cast<QWidget *>(obj)) && obj != m_pAllPicView->getThumbnailListView()) { |
| 746 |
// 针对listview不能左右键切换 |
| 747 |
int wgtIndex = m_AllpicViewTabOrder.indexOf(dynamic_cast<QWidget *>(obj)); |
| 748 |
// 焦点范围限定在标题栏 |
| 749 |
QWidget *pTempWidget = dynamic_cast<QWidget *>(m_AllpicViewTabOrder.at((wgtIndex + m_AllpicViewTabOrder.count() - 2) % (m_AllpicViewTabOrder.count() - 1))); |
| 750 |
pTempWidget->setFocus(); |
| 751 |
return true; |
| 752 |
} |
| 753 |
} |
| 754 |
return false; |
| 755 |
} |
| 756 |
|
| 757 |
bool MainWindow::initDownKeyOrder() |
| 758 |
{ |
| 759 |
// 相册界面,左边栏焦点向下循环切换 |
| 760 |
if (m_iCurrentView == VIEW_ALBUM) { |
| 761 |
QList<LeftListWidget *> tempLeftListView; |
| 762 |
tempLeftListView.append(m_pAlbumview->m_pLeftListView->m_pPhotoLibListView); |
| 763 |
tempLeftListView.append(m_pAlbumview->m_pLeftListView->m_pMountListWidget); |
| 764 |
tempLeftListView.append(m_pAlbumview->m_pLeftListView->m_pCustomizeListView); |
| 765 |
for (int i = 0; i < tempLeftListView.count(); i++) { |
| 766 |
if (tempLeftListView.at(i)->hasFocus()) { |
| 767 |
if (tempLeftListView.at(i)->count() > 0 && tempLeftListView.at(i)->currentRow() == tempLeftListView.at(i)->count() - 1) { |
| 768 |
bool isNotEmpty = true; |
| 769 |
int cnt = 0; |
| 770 |
// 设备左边栏列表可能不存在,跳过 |
| 771 |
while (isNotEmpty) { |
| 772 |
if (tempLeftListView.at((i + 1 + cnt) % 3)->count() > 0) { |
| 773 |
tempLeftListView.at(i)->setCurrentRow(-1); |
| 774 |
tempLeftListView.at((i + 1 + cnt) % 3)->setFocus(); |
| 775 |
tempLeftListView.at((i + 1 + cnt) % 3)->setCurrentRow(0); |
| 776 |
isNotEmpty = false; |
| 777 |
} else { |
| 778 |
cnt ++; |
| 779 |
} |
| 780 |
} |
| 781 |
return true; |
| 782 |
} |
| 783 |
} |
| 784 |
} |
| 785 |
} |
| 786 |
return false; |
| 787 |
} |
| 788 |
|
| 789 |
bool MainWindow::initUpKeyOrder() |
| 790 |
{ |
| 791 |
// 相册界面,左边栏焦点向上循环切换 |
| 792 |
if (m_iCurrentView == VIEW_ALBUM) { |
| 793 |
QList<LeftListWidget *> tempLeftListView; |
| 794 |
tempLeftListView.append(m_pAlbumview->m_pLeftListView->m_pPhotoLibListView); |
| 795 |
tempLeftListView.append(m_pAlbumview->m_pLeftListView->m_pMountListWidget); |
| 796 |
tempLeftListView.append(m_pAlbumview->m_pLeftListView->m_pCustomizeListView); |
| 797 |
int showListViewCount = 0; |
| 798 |
foreach (auto listView, tempLeftListView) { |
| 799 |
if (listView->count() > 0) { |
| 800 |
showListViewCount ++; |
| 801 |
} |
| 802 |
} |
| 803 |
for (int i = 0; i < tempLeftListView.count(); i++) { |
| 804 |
if (tempLeftListView.at(i)->hasFocus()) { |
| 805 |
if (tempLeftListView.at(i)->count() > 0 && tempLeftListView.at(i)->currentRow() == 0) { |
| 806 |
bool isNotEmpty = true; |
| 807 |
int cnt = 0; |
| 808 |
// 设备左边栏列表可能不存在,跳过 |
| 809 |
while (isNotEmpty) { |
| 810 |
int loopListView = (i + showListViewCount - 1 + cnt) % 3; |
| 811 |
if (tempLeftListView.at(loopListView)->count() > 0) { |
| 812 |
tempLeftListView.at(i)->setCurrentRow(-1); |
| 813 |
tempLeftListView.at(loopListView)->setFocus(); |
| 814 |
tempLeftListView.at(loopListView)->setCurrentRow(tempLeftListView.at(loopListView)->count() - 1); |
| 815 |
isNotEmpty = false; |
| 816 |
} else { |
| 817 |
cnt ++; |
| 818 |
} |
| 819 |
} |
| 820 |
return true; |
| 821 |
} |
| 822 |
} |
| 823 |
} |
| 824 |
} |
| 825 |
return false; |
| 826 |
} |
| 827 |
|
| 828 |
bool MainWindow::initAllViewTabKeyOrder(QObject *obj) |
| 829 |
{ |
| 830 |
if (m_pAllPicView->m_pStackedWidget->currentIndex() == 0) { |
| 831 |
// 相册内没有图时,应用初始启动无图时显示m_pImportView, tab键切换 |
| 832 |
initNoPhotoNormalTabOrder(); |
| 833 |
} else if (m_iCurrentView == VIEW_ALLPIC) {// 相册中有图,且在所有照片界面时 |
| 834 |
// 所有照片界面 and listveiw tab键切换 |
| 835 |
initAllpicViewTabOrder(); |
| 836 |
// 当焦点在thumbnailListview中时,选中第一个 |
| 837 |
QWidget *pTempWidget = static_cast<QWidget *>(obj); |
| 838 |
int index = m_AllpicViewTabOrder.indexOf(pTempWidget); |
| 839 |
// 当焦点在thumbnaillistview之前的一个widget上时,再次tab,默认选中第一个图片 |
| 840 |
if (index == m_AllpicViewTabOrder.count() - 2) { |
| 841 |
//选中时先清除以前的选中状态 |
| 842 |
m_pAllPicView->getThumbnailListView()->clearSelection(); |
| 843 |
m_pAllPicView->getThumbnailListView()->setFocus(); |
| 844 |
m_pAllPicView->getThumbnailListView()->selectFirstPhoto(); |
| 845 |
return true; |
| 846 |
} |
| 847 |
// 当焦点在thumbnaillistview上时,第一个没选中/其他有选中,不可以tab键切换返回 |
| 848 |
if (obj == m_pAllPicView->getThumbnailListView()) { |
| 849 |
if (!m_pAllPicView->getThumbnailListView()->isFirstPhotoSelected() && !m_pAllPicView->getThumbnailListView()->isNoPhotosSelected()) { |
| 850 |
return true; |
| 851 |
} else { |
| 852 |
m_pAllPicView->getThumbnailListView()->clearSelection(); |
| 853 |
} |
| 854 |
} |
| 855 |
} else if (m_iCurrentView == VIEW_TIMELINE) { |
| 856 |
// 时间线界面 |
| 857 |
initTimeLineViewTabOrder(); |
| 858 |
ThumbnailListView *tempListView = m_pTimeLineView->getThumbnailListView(); |
| 859 |
if (obj == m_pTimeBtn && tempListView) { |
| 860 |
tempListView->setFocus(); |
| 861 |
//清除其他选中后再选中第一张 |
| 862 |
m_pTimeLineView->clearAllSelection(); |
| 863 |
tempListView->selectFirstPhoto(); |
| 864 |
return true; |
| 865 |
} else if (obj == tempListView) { |
| 866 |
tempListView->clearSelection(); |
| 867 |
m_pTimeBtn->setFocus(); |
| 868 |
return true; |
| 869 |
} |
| 870 |
} else if (m_iCurrentView == VIEW_ALBUM) { |
| 871 |
// 相册内没有图时,应用初始启动无图时显示m_pImportView, tab键切换 |
| 872 |
initAlbumViewTabOrder(); |
| 873 |
ThumbnailListView *tempListView = m_pAlbumview->m_pImpTimeLineView->getListView(); |
| 874 |
if (obj == m_AlbumViewTabOrder.at(1) && tempListView != nullptr) { |
| 875 |
tempListView->setFocus(); |
| 876 |
//清除其他选中后再选中第一张 |
| 877 |
m_pAlbumview->m_pImpTimeLineView->clearAllSelection(); |
| 878 |
tempListView->selectFirstPhoto(); |
| 879 |
m_pAlbumview->m_pLeftListView->m_pPhotoLibListView->setCurrentRow(-1); |
| 880 |
return true; |
| 881 |
} else if (obj == tempListView) { |
| 882 |
tempListView->clearSelection(); |
| 883 |
m_pAlbumBtn->setFocus(); |
| 884 |
return true; |
| 885 |
} else if (obj == m_AlbumViewTabOrder.at(0)) { |
| 886 |
tempListView->clearSelection(); |
| 887 |
m_pAlbumview->m_pLeftListView->m_pPhotoLibListView->setCurrentRow(0); |
| 888 |
} |
| 889 |
} |
| 890 |
return false; |
| 891 |
} |
| 892 |
//设置等待窗口颜色 |
| 893 |
void MainWindow::setWaitDialogColor() |
| 894 |
{ |
| 895 |
DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType(); |
| 896 |
if (themeType == DGuiApplicationHelper::LightType) { |
| 897 |
DPalette pa1; |
| 898 |
pa1 = m_waitlabel->palette(); |
| 899 |
pa1.setColor(DPalette::WindowText, QColor("#001A2E")); |
| 900 |
m_waitlabel->setPalette(pa1); |
| 901 |
|
| 902 |
DPalette pa2; |
| 903 |
pa2 = m_countLabel->palette(); |
| 904 |
pa2.setColor(DPalette::WindowText, QColor("#6A829F")); |
| 905 |
m_countLabel->setPalette(pa2); |
| 906 |
} |
| 907 |
if (themeType == DGuiApplicationHelper::DarkType) { |
| 908 |
DPalette pa1; |
| 909 |
pa1 = m_waitlabel->palette(); |
| 910 |
pa1.setColor(DPalette::WindowText, QColor("#A8B7D1")); |
| 911 |
m_waitlabel->setPalette(pa1); |
| 912 |
|
| 913 |
DPalette pa2; |
| 914 |
pa2 = m_countLabel->palette(); |
| 915 |
pa2.setColor(DPalette::WindowText, QColor("#6D7C88")); |
| 916 |
m_countLabel->setPalette(pa2); |
| 917 |
} |
| 918 |
} |
| 919 |
|
| 920 |
int MainWindow::getCurrentViewType() |
| 921 |
{ |
| 922 |
return m_iCurrentView; |
| 923 |
} |
| 924 |
|
| 925 |
//显示所有照片 |
| 926 |
void MainWindow::allPicBtnClicked() |
| 927 |
{ |
| 928 |
clearFocus(); |
| 929 |
emit dApp->signalM->hideExtensionPanel(); |
| 930 |
// m_pSearchEdit->clear(); |
| 931 |
m_pSearchEdit->clearEdit(); |
| 932 |
m_SearchKey.clear(); |
| 933 |
|
| 934 |
m_iCurrentView = VIEW_ALLPIC; |
| 935 |
m_pCenterWidget->setCurrentIndex(m_iCurrentView); |
| 936 |
m_pAllPicView->m_pStatusBar->m_pSlider->setValue(m_pSliderPos); |
| 937 |
m_pAllPicView->updateStackedWidget(); |
| 938 |
m_pAllPicView->updatePicNum(); |
| 939 |
// m_pAllPicView->getThumbnailListView()->setFocus(); |
| 940 |
|
| 941 |
m_pTimeBtn->setCheckable(true); |
| 942 |
m_pAlbumBtn->setCheckable(true); |
| 943 |
|
| 944 |
m_pAllPicBtn->setCheckable(true); |
| 945 |
m_pAllPicBtn->setChecked(true); |
| 946 |
initAllpicViewTabOrder(); |
| 947 |
if (m_AllpicViewTabOrder.count() > 0 && m_bVector.at(0)) { |
| 948 |
m_pAllPicView->m_pImportView->m_pImportBtn->installEventFilter(this); |
| 949 |
m_bVector[0] = false; |
| 950 |
} |
| 951 |
} |
| 952 |
|
| 953 |
//显示时间线照片 |
| 954 |
void MainWindow::timeLineBtnClicked() |
| 955 |
{ |
| 956 |
clearFocus(); |
| 957 |
if (nullptr == m_pTimeLineView) { |
| 958 |
m_pCenterWidget->removeWidget(m_pTimeLineWidget); |
| 959 |
int index = m_pCenterWidget->indexOf(m_pAllPicView) + 1; |
| 960 |
m_pTimeLineView = new TimeLineView(); |
| 961 |
m_pCenterWidget->insertWidget(index, m_pTimeLineView); |
| 962 |
// m_pTimeLineView->clearAndStartLayout(); |
| 963 |
} |
| 964 |
emit dApp->signalM->hideExtensionPanel(); |
| 965 |
m_pSearchEdit->clearEdit(); |
| 966 |
m_SearchKey.clear(); |
| 967 |
m_iCurrentView = VIEW_TIMELINE; |
| 968 |
m_pCenterWidget->setCurrentIndex(m_iCurrentView); |
| 969 |
m_pTimeLineView->m_pStatusBar->m_pSlider->setValue(m_pSliderPos); |
| 970 |
m_pTimeLineView->updateStackedWidget(); |
| 971 |
m_pTimeLineView->updatePicNum(); |
| 972 |
m_pTimeLineView->m_pwidget->setFocus(); |
| 973 |
|
| 974 |
m_pAllPicBtn->setCheckable(true); |
| 975 |
m_pAlbumBtn->setCheckable(true); |
| 976 |
m_pTimeBtn->setCheckable(true); |
| 977 |
m_pTimeBtn->setChecked(true); |
| 978 |
|
| 979 |
initTimeLineViewTabOrder(); |
| 980 |
if (m_TimelineViewTabOrder.count() > 0 && m_bVector.at(1)) { |
| 981 |
if (m_pTimeLineView->getThumbnailListView()) |
| 982 |
m_pTimeLineView->getThumbnailListView()->installEventFilter(this); |
| 983 |
// timelineview |
| 984 |
m_pTimeLineView->pImportView->m_pImportBtn->installEventFilter(this); |
| 985 |
m_bVector[1] = false; |
| 986 |
} |
| 987 |
} |
| 988 |
|
| 989 |
//显示相册 |
| 990 |
void MainWindow::albumBtnClicked() |
| 991 |
{ |
| 992 |
clearFocus(); |
| 993 |
if (nullptr == m_pAlbumview) { |
| 994 |
int index = 0; |
| 995 |
if (nullptr == m_pTimeLineView) { |
| 996 |
m_pCenterWidget->removeWidget(m_pTimeLineWidget); |
| 997 |
index = m_pCenterWidget->indexOf(m_pAllPicView) + 1; |
| 998 |
m_pTimeLineView = new TimeLineView(); |
| 999 |
m_pCenterWidget->insertWidget(index, m_pTimeLineView); |
| 1000 |
// m_pTimeLineView->clearAndStartLayout(); |
| 1001 |
} |
| 1002 |
m_pCenterWidget->removeWidget(m_pAlbumWidget); |
| 1003 |
index = m_pCenterWidget->indexOf(m_pTimeLineView) + 1; |
| 1004 |
m_pAlbumview = new AlbumView(); |
| 1005 |
connect(m_pAlbumview, &AlbumView::sigSearchEditIsDisplay, this, &MainWindow::onSearchEditIsDisplay); |
| 1006 |
m_pCenterWidget->insertWidget(index, m_pAlbumview); |
| 1007 |
} |
| 1008 |
emit dApp->signalM->hideExtensionPanel(); |
| 1009 |
m_pSearchEdit->clearEdit(); |
| 1010 |
m_SearchKey.clear(); |
| 1011 |
m_iCurrentView = VIEW_ALBUM; |
| 1012 |
qDebug() << "------" << __FUNCTION__ << "count = " << m_pCenterWidget->count(); |
| 1013 |
m_pCenterWidget->setCurrentIndex(m_iCurrentView); |
| 1014 |
|
| 1015 |
m_pAlbumview->SearchReturnUpdate(); |
| 1016 |
m_pAlbumview->m_pStatusBar->m_pSlider->setValue(m_pSliderPos); |
| 1017 |
qDebug() << "------" << __FUNCTION__ << ""; |
| 1018 |
m_pAlbumview->updateRightView(); |
| 1019 |
m_pAlbumview->m_pwidget->setFocus(); |
| 1020 |
|
| 1021 |
m_pAllPicBtn->setCheckable(true); |
| 1022 |
m_pTimeBtn->setCheckable(true); |
| 1023 |
m_pAlbumBtn->setCheckable(true); |
| 1024 |
m_pAlbumBtn->setChecked(true); |
| 1025 |
|
| 1026 |
initAlbumViewTabOrder(); |
| 1027 |
|
| 1028 |
// albumview left list view up and down key event filter |
| 1029 |
if (m_AlbumViewTabOrder.count() > 0 && m_bVector.at(2)) { |
| 1030 |
m_pAlbumview->m_pImportView->m_pImportBtn->installEventFilter(this); |
| 1031 |
if (m_pAlbumview->m_pImpTimeLineView->getListView()) |
| 1032 |
m_pAlbumview->m_pImpTimeLineView->getListView()->installEventFilter(this); |
| 1033 |
m_pAlbumview->m_pLeftListView->m_pPhotoLibListView->installEventFilter(this); |
| 1034 |
m_pAlbumview->m_pLeftListView->m_pMountListWidget->installEventFilter(this); |
| 1035 |
m_pAlbumview->m_pLeftListView->m_pCustomizeListView->installEventFilter(this); |
| 1036 |
m_bVector[2] = false; |
| 1037 |
} |
| 1038 |
} |
| 1039 |
|
| 1040 |
//标题菜单栏槽函数 |
| 1041 |
void MainWindow::onTitleBarMenuClicked(QAction *action) |
| 1042 |
{ |
| 1043 |
if (tr("New album") == action->text()) { |
| 1044 |
emit dApp->signalM->createAlbum(QStringList(" ")); |
| 1045 |
} |
| 1046 |
|
| 1047 |
else if (tr("Import photos") == action->text()) { |
| 1048 |
emit dApp->signalM->startImprot(); |
| 1049 |
emit sigTitleMenuImportClicked(); |
| 1050 |
} else { |
| 1051 |
|
| 1052 |
} |
| 1053 |
} |
| 1054 |
|
| 1055 |
//创建相册槽函数 |
| 1056 |
void MainWindow::onCreateAlbum(const QStringList &imagepaths) |
| 1057 |
{ |
| 1058 |
showCreateDialog(imagepaths); |
| 1059 |
} |
| 1060 |
#if 1 |
| 1061 |
void MainWindow::onViewCreateAlbum(QString imgpath, bool bmodel) |
| 1062 |
{ |
| 1063 |
AlbumCreateDialog *d = new AlbumCreateDialog(this); |
| 1064 |
d->setModal(bmodel); |
| 1065 |
d->show(); |
| 1066 |
d->move(this->x() + (this->width() - d->width()) / 2, this->y() + (this->height() - d->height()) / 2); |
| 1067 |
|
| 1068 |
#ifdef tablet_PC |
| 1069 |
ComDeepinImInterface::instance().setImActive(true);//拉起虚拟键盘 |
| 1070 |
QTimer::singleShot(200, []() { //平板未知问题,导致虚拟键盘会显示后瞬间消失,暂时这样规避 |
| 1071 |
ComDeepinImInterface::instance().setImActive(true); |
| 1072 |
}); |
| 1073 |
#endif |
| 1074 |
|
| 1075 |
connect(d, &AlbumCreateDialog::albumAdded, this, [ = ] { |
| 1076 |
emit dApp->signalM->hideExtensionPanel(); |
| 1077 |
DBManager::instance()->insertIntoAlbum(d->getCreateAlbumName(), imgpath.isEmpty() ? QStringList(" ") : QStringList(imgpath)); |
| 1078 |
emit dApp->signalM->sigCreateNewAlbumFrom(d->getCreateAlbumName()); |
| 1079 |
QIcon icon(":/images/logo/resources/images/other/icon_toast_sucess.svg"); |
| 1080 |
QString str = tr("Successfully added to “%1”"); |
| 1081 |
floatMessage(str.arg(d->getCreateAlbumName()), icon); |
| 1082 |
if (imgpath.count() > 0 && imgpath != " ") |
| 1083 |
{ |
| 1084 |
ImageEngineApi::instance()->setImgPathAndAlbumNames(DBManager::instance()->getAllPathAlbumNames()); |
| 1085 |
QStringList paths; |
| 1086 |
paths << imgpath; |
| 1087 |
emit SignalManager::instance()->sigSyncListviewModelData(paths, d->getCreateAlbumName(), 4); |
| 1088 |
} |
| 1089 |
}); |
| 1090 |
} |
| 1091 |
#endif |
| 1092 |
//创建相册弹出窗 |
| 1093 |
void MainWindow::showCreateDialog(QStringList imgpaths) |
| 1094 |
{ |
| 1095 |
AlbumCreateDialog *d = new AlbumCreateDialog(this); |
| 1096 |
d->show(); |
| 1097 |
d->move(this->x() + (this->width() - d->width()) / 2, this->y() + (this->height() - d->height()) / 2); |
| 1098 |
|
| 1099 |
#ifdef tablet_PC |
| 1100 |
ComDeepinImInterface::instance().setImActive(true);//拉起虚拟键盘 |
| 1101 |
QTimer::singleShot(200, []() { //平板未知问题,导致虚拟键盘会显示后瞬间消失,暂时这样规避 |
| 1102 |
ComDeepinImInterface::instance().setImActive(true); |
| 1103 |
}); |
| 1104 |
#endif |
| 1105 |
|
| 1106 |
connect(d, &AlbumCreateDialog::albumAdded, this, [ = ] { |
| 1107 |
//double insert problem from here ,first insert at AlbumCreateDialog::createAlbum(albumname) |
| 1108 |
if (nullptr == m_pAlbumview) |
| 1109 |
{ |
| 1110 |
int index = 0; |
| 1111 |
if (nullptr == m_pTimeLineView) { |
| 1112 |
m_pCenterWidget->removeWidget(m_pTimeLineWidget); |
| 1113 |
index = m_pCenterWidget->indexOf(m_pAllPicView) + 1; |
| 1114 |
m_pTimeLineView = new TimeLineView(); |
| 1115 |
m_pCenterWidget->insertWidget(index, m_pTimeLineView); |
| 1116 |
// m_pTimeLineView->clearAndStartLayout(); |
| 1117 |
} |
| 1118 |
m_pCenterWidget->removeWidget(m_pAlbumWidget); |
| 1119 |
index = m_pCenterWidget->indexOf(m_pTimeLineView) + 1; |
| 1120 |
m_pAlbumview = new AlbumView(); |
| 1121 |
connect(m_pAlbumview, &AlbumView::sigSearchEditIsDisplay, this, &MainWindow::onSearchEditIsDisplay); |
| 1122 |
m_pCenterWidget->insertWidget(index, m_pAlbumview); |
| 1123 |
emit dApp->signalM->sigCreateNewAlbumFromDialog(d->getCreateAlbumName()); |
| 1124 |
m_pAlbumBtn->setChecked(true); |
| 1125 |
m_pSearchEdit->clearEdit(); |
| 1126 |
m_SearchKey.clear(); |
| 1127 |
m_pAlbumview->m_pStatusBar->m_pSlider->setValue(m_pSliderPos); |
| 1128 |
} else |
| 1129 |
{ |
| 1130 |
emit dApp->signalM->sigCreateNewAlbumFromDialog(d->getCreateAlbumName()); |
| 1131 |
m_pAlbumBtn->setChecked(true); |
| 1132 |
m_pSearchEdit->clearEdit(); |
| 1133 |
m_SearchKey.clear(); |
| 1134 |
m_pAlbumview->m_pStatusBar->m_pSlider->setValue(m_pSliderPos); |
| 1135 |
} |
| 1136 |
m_backIndex = VIEW_ALBUM; |
| 1137 |
DBManager::instance()->insertIntoAlbum(d->getCreateAlbumName(), imgpaths); |
| 1138 |
emit dApp->signalM->insertedIntoAlbum(m_pAlbumview->m_currentAlbum, imgpaths); |
| 1139 |
emit dApp->signalM->hideImageView(); //该信号针对查看界面新建相册(快捷键 crtl+n),正常退出 |
| 1140 |
// 相册照片更新时的.更新路径相册名缓存,用于listview的setdata userrole + 2 |
| 1141 |
// " " 新建空的相册 |
| 1142 |
if (imgpaths.first() != " ") |
| 1143 |
{ |
| 1144 |
ImageEngineApi::instance()->setImgPathAndAlbumNames(); |
| 1145 |
emit SignalManager::instance()->sigSyncListviewModelData(imgpaths, d->getCreateAlbumName(), 4); |
| 1146 |
} |
| 1147 |
}); |
| 1148 |
} |
| 1149 |
|
| 1150 |
//搜索框 |
| 1151 |
void MainWindow::onSearchEditFinished() |
| 1152 |
{ |
| 1153 |
qDebug() << __FUNCTION__ << m_pSearchEdit->hasFocus(); |
| 1154 |
QString keywords = m_pSearchEdit->text(); |
| 1155 |
if (m_SearchKey == keywords) //两次搜索条件相同,跳过 |
| 1156 |
return; |
| 1157 |
m_SearchKey = keywords; |
| 1158 |
emit dApp->signalM->hideExtensionPanel(); |
| 1159 |
if (VIEW_ALLPIC == m_iCurrentView) { |
| 1160 |
if (keywords.isEmpty()) { |
| 1161 |
allPicBtnClicked(); |
| 1162 |
// donothing |
| 1163 |
} else { |
| 1164 |
emit dApp->signalM->sigSendKeywordsIntoALLPic(keywords, COMMON_STR_ALLPHOTOS); |
| 1165 |
m_pAllPicView->m_pStackedWidget->setCurrentIndex(2); |
| 1166 |
m_pAllPicView->restorePicNum(); |
| 1167 |
} |
| 1168 |
} else if (VIEW_TIMELINE == m_iCurrentView) { |
| 1169 |
if (keywords.isEmpty()) { |
| 1170 |
timeLineBtnClicked(); |
| 1171 |
// donothing |
| 1172 |
} else { |
| 1173 |
emit dApp->signalM->sigSendKeywordsIntoALLPic(keywords, COMMON_STR_TIMELINE); |
| 1174 |
m_pTimeLineView->m_pStackedWidget->setCurrentIndex(2); |
| 1175 |
m_pTimeLineView->restorePicNum(); |
| 1176 |
} |
| 1177 |
} else if (VIEW_ALBUM == m_iCurrentView) { |
| 1178 |
if (keywords.isEmpty()) { |
| 1179 |
albumBtnClicked(); |
| 1180 |
// donothing |
| 1181 |
} else { |
| 1182 |
if (COMMON_STR_RECENT_IMPORTED == m_pAlbumview->m_pLeftListView->getItemCurrentType()) { |
| 1183 |
emit dApp->signalM->sigSendKeywordsIntoALLPic(keywords, COMMON_STR_RECENT_IMPORTED); |
| 1184 |
} |
| 1185 |
//LMH0514,为了解决26092 【相册】【5.6.9.14】在我的收藏相册下无法搜索到收藏的照片,加入我的收藏枚举 |
| 1186 |
else if (COMMON_STR_FAVORITES == m_pAlbumview->m_pLeftListView->getItemCurrentType()) { |
| 1187 |
emit dApp->signalM->sigSendKeywordsIntoALLPic(keywords, COMMON_STR_FAVORITES); |
| 1188 |
} else if (COMMON_STR_CUSTOM == m_pAlbumview->m_pLeftListView->getItemCurrentType()) { |
| 1189 |
emit dApp->signalM->sigSendKeywordsIntoALLPic(keywords, m_pAlbumview->m_pLeftListView->getItemCurrentName()); |
| 1190 |
} |
| 1191 |
|
| 1192 |
m_pAlbumview->m_pRightStackWidget->setCurrentIndex(4); |
| 1193 |
m_pAlbumview->restorePicNum(); |
| 1194 |
} |
| 1195 |
} |
| 1196 |
} |
| 1197 |
|
| 1198 |
//标题菜单导入照片槽函数 |
| 1199 |
void MainWindow::onImprotBtnClicked() |
| 1200 |
{ |
| 1201 |
static QStringList sList; |
| 1202 |
for (const QString &i : UnionImage_NameSpace::unionImageSupportFormat()) |
| 1203 |
sList << ("*." + i); |
| 1204 |
//添加视频过滤 |
| 1205 |
for (const QString &i : utils::base::m_videoFiletypes) |
| 1206 |
sList << i; |
| 1207 |
QString filter = tr("All photos and videos"); |
| 1208 |
filter.append('('); |
| 1209 |
filter.append(sList.join(" ")); |
| 1210 |
filter.append(')'); |
| 1211 |
static QString cfgGroupName = QStringLiteral("General"), cfgLastOpenPath = QStringLiteral("LastOpenPath"); |
| 1212 |
QString pictureFolder = QStandardPaths::writableLocation(QStandardPaths::PicturesLocation); |
| 1213 |
QDir existChecker(pictureFolder); |
| 1214 |
if (!existChecker.exists()) { |
| 1215 |
pictureFolder = QDir::currentPath(); |
| 1216 |
} |
| 1217 |
pictureFolder = dApp->setter->value(cfgGroupName, cfgLastOpenPath, pictureFolder).toString(); |
| 1218 |
DFileDialog dialog(this); |
| 1219 |
dialog.setFileMode(DFileDialog::ExistingFiles); |
| 1220 |
dialog.setDirectory(pictureFolder); |
| 1221 |
dialog.setNameFilter(filter); |
| 1222 |
dialog.setOption(QFileDialog::HideNameFilterDetails); |
| 1223 |
dialog.setWindowTitle(tr("Import Photos and Videos")); |
| 1224 |
dialog.setAllowMixedSelection(true); |
| 1225 |
const int mode = dialog.exec(); |
| 1226 |
if (mode != QDialog::Accepted) { |
| 1227 |
return; |
| 1228 |
} |
| 1229 |
const QStringList &file_list = dialog.selectedFiles(); |
| 1230 |
if (file_list.isEmpty()) |
| 1231 |
return; |
| 1232 |
ImageDataService::instance()->readThumbnailByPaths(file_list); |
| 1233 |
if (m_iCurrentView == VIEW_ALBUM) { |
| 1234 |
if (m_pAlbumview->m_currentType == ALBUM_PATHTYPE_BY_PHONE || m_pAlbumview->m_currentItemType == 0) { |
| 1235 |
ImageEngineApi::instance()->ImportImagesFromFileList(file_list, "", this, true); |
| 1236 |
} else { |
| 1237 |
ImageEngineApi::instance()->ImportImagesFromFileList(file_list, m_pAlbumview->m_currentAlbum, this, true); |
| 1238 |
} |
| 1239 |
} else { |
| 1240 |
ImageEngineApi::instance()->ImportImagesFromFileList(file_list, "", this, true); |
| 1241 |
} |
| 1242 |
|
| 1243 |
} |
| 1244 |
|
| 1245 |
bool MainWindow::imageImported(bool success) |
| 1246 |
{ |
| 1247 |
emit dApp->signalM->closeWaitDialog(); |
| 1248 |
emit sigImageImported(success); |
| 1249 |
return true; |
| 1250 |
} |
| 1251 |
|
| 1252 |
////显示图片详细信息 |
| 1253 |
//void MainWindow::onShowImageInfo(const QString &path) |
| 1254 |
//{ |
| 1255 |
// ImgInfoDialog *dialog; |
| 1256 |
// if (m_propertyDialogs.contains(path)) { |
| 1257 |
// m_propertyDialogs.remove(path); |
| 1258 |
// dialog = new ImgInfoDialog(path); |
| 1259 |
// dialog->setObjectName("ImgInfoDialog"); |
| 1260 |
// m_propertyDialogs.insert(path, dialog); |
| 1261 |
// dialog->show(); |
| 1262 |
// dialog->move((this->width() - dialog->width() - 50 + mapToGlobal(QPoint(0, 0)).x()), 100 + mapToGlobal(QPoint(0, 0)).y()); |
| 1263 |
// dialog->setWindowState(Qt::WindowActive); |
| 1264 |
// connect(dialog, &ImgInfoDialog::closed, this, [ = ] { |
| 1265 |
// dialog->deleteLater(); |
| 1266 |
// m_propertyDialogs.remove(path); |
| 1267 |
// }); |
| 1268 |
// } else { |
| 1269 |
// dialog = new ImgInfoDialog(path, this); |
| 1270 |
// dialog->setObjectName("ImgInfoDialog"); |
| 1271 |
// m_propertyDialogs.insert(path, dialog); |
| 1272 |
// dialog->show(); |
| 1273 |
// dialog->move((this->width() - dialog->width() - 50 + mapToGlobal(QPoint(0, 0)).x()), 100 + mapToGlobal(QPoint(0, 0)).y()); |
| 1274 |
// dialog->setWindowState(Qt::WindowActive); |
| 1275 |
// connect(dialog, &ImgInfoDialog::closed, this, [ = ] { |
| 1276 |
// dialog->deleteLater(); |
| 1277 |
// m_propertyDialogs.remove(path); |
| 1278 |
// }); |
| 1279 |
// } |
| 1280 |
//} |
| 1281 |
|
| 1282 |
void MainWindow::floatMessage(const QString &str, const QIcon &icon) |
| 1283 |
{ |
| 1284 |
QString tempStr = str; |
| 1285 |
QWidget *pwidget = nullptr; |
| 1286 |
switch (m_pCenterWidget->currentIndex()) { |
| 1287 |
case 0: |
| 1288 |
pwidget = m_pAllPicView->m_pwidget; |
| 1289 |
break; |
| 1290 |
case 1: |
| 1291 |
pwidget = m_pTimeLineView->m_pwidget; |
| 1292 |
break; |
| 1293 |
case 2: |
| 1294 |
pwidget = m_pAlbumview->m_pwidget; |
| 1295 |
break; |
| 1296 |
case 4: |
| 1297 |
pwidget = m_commandLine; |
| 1298 |
break; |
| 1299 |
default: |
| 1300 |
pwidget = m_pAllPicView->m_pwidget; |
| 1301 |
break; |
| 1302 |
} |
| 1303 |
DFloatingMessage *pDFloatingMessage = new DFloatingMessage(DFloatingMessage::MessageType::TransientType, pwidget); |
| 1304 |
pDFloatingMessage->setBlurBackgroundEnabled(true); |
| 1305 |
pDFloatingMessage->setMessage(tempStr); |
| 1306 |
pDFloatingMessage->setIcon(icon); |
| 1307 |
pDFloatingMessage->raise(); |
| 1308 |
if (pwidget) { |
| 1309 |
if (icon.isNull()) { |
| 1310 |
QLabel *tempLabel = new QLabel(pDFloatingMessage); |
| 1311 |
tempLabel->setFixedWidth(8); |
| 1312 |
pDFloatingMessage->setWidget(tempLabel); |
| 1313 |
} |
| 1314 |
DMessageManager::instance()->sendMessage(pwidget, pDFloatingMessage); |
| 1315 |
} |
| 1316 |
} |
| 1317 |
|
| 1318 |
//外部使用相册打开图片 |
| 1319 |
void MainWindow::onNewAPPOpen(qint64 pid, const QStringList &arguments) |
| 1320 |
{ |
| 1321 |
qDebug() << __FUNCTION__ << "---"; |
| 1322 |
Q_UNUSED(pid); |
| 1323 |
QStringList paths; |
| 1324 |
if (arguments.length() > 1) { |
| 1325 |
//arguments第1个参数是进程名,图片paths参数需要从下标1开始 |
| 1326 |
for (int i = 1; i < arguments.size(); ++i) { |
| 1327 |
QString qpath = arguments.at(i); |
| 1328 |
//BUG#79815,添加文件URL解析(BUG是平板上的,为防止UOS的其它个别版本也改成传URL,干脆直接全部支持) |
| 1329 |
auto urlPath = QUrl(qpath); |
| 1330 |
if (urlPath.scheme() == "file") { |
| 1331 |
qpath = urlPath.toLocalFile(); |
| 1332 |
} |
| 1333 |
paths.append(qpath); |
| 1334 |
} |
| 1335 |
if (paths.count() > 0) { |
| 1336 |
QString firstStr = paths.at(0); |
| 1337 |
ImageEngineApi::instance()->ImportImagesFromFileList(paths, "", this); |
| 1338 |
if (utils::base::isVideo(firstStr)) { |
| 1339 |
if (m_pCenterWidget->currentIndex() == VIEW_IMAGE) { |
| 1340 |
onHideImageView(); |
| 1341 |
} |
| 1342 |
m_pCenterWidget->setCurrentIndex(VIEW_ALLPIC); |
| 1343 |
|
| 1344 |
//获取视频信息 |
| 1345 |
MovieInfo movieInfo = MovieService::instance()->getMovieInfo(QUrl::fromLocalFile(firstStr)); |
| 1346 |
//线程加载缩略图 |
| 1347 |
if (movieInfo.valid) { |
| 1348 |
ImageDataService::instance()->readThumbnailByPaths(paths); |
| 1349 |
} |
| 1350 |
} else { |
| 1351 |
SignalManager::ViewInfo info; |
| 1352 |
info.album = ""; |
| 1353 |
#ifndef LITE_DIV |
| 1354 |
info.inDatabase = false; |
| 1355 |
#endif |
| 1356 |
info.lastPanel = nullptr; |
| 1357 |
info.path = paths.at(0); |
| 1358 |
info.paths = paths; |
| 1359 |
emit dApp->signalM->viewImage(info); |
| 1360 |
//若外部打开图片退出时,不默认跳转到所有照片界面,则获取当前页面索引发送 |
| 1361 |
onShowImageView(VIEW_ALLPIC); |
| 1362 |
//更改为调用线程api |
| 1363 |
ImageEngineApi::instance()->loadImagesFromNewAPP(paths, this); |
| 1364 |
//线程加载缩略图 |
| 1365 |
ImageDataService::instance()->readThumbnailByPaths(paths); |
| 1366 |
} |
| 1367 |
} |
| 1368 |
m_pAllPicBtn->setChecked(true); |
| 1369 |
} |
| 1370 |
this->activateWindow(); |
| 1371 |
} |
| 1372 |
|
| 1373 |
QButtonGroup *MainWindow::getButG() |
| 1374 |
{ |
| 1375 |
return (nullptr != static_cast<QButtonGroup *>(btnGroup) ? btnGroup : nullptr); |
| 1376 |
} |
| 1377 |
|
| 1378 |
void MainWindow::closeEvent(QCloseEvent *event) |
| 1379 |
{ |
| 1380 |
saveWindowState(); |
| 1381 |
if (VIEW_IMAGE == m_pCenterWidget->currentIndex()) { |
| 1382 |
emit dApp->signalM->hideImageView(); |
| 1383 |
emit dApp->signalM->sigPauseOrStart(false); //唤醒外设后台挂载 |
| 1384 |
event->ignore(); |
| 1385 |
} else { |
| 1386 |
delete m_commandLine; |
| 1387 |
event->accept(); |
| 1388 |
} |
| 1389 |
} |
| 1390 |
|
| 1391 |
void MainWindow::showEvent(QShowEvent *event) |
| 1392 |
{ |
| 1393 |
// qDebug() << "------" << __FUNCTION__ << "---size = " << this->size(); |
| 1394 |
Q_UNUSED(event) |
| 1395 |
int m_SearchEditWidth = titlebar()->width() - m_titleBtnWidget->width() - TITLEBAR_BLANK_WIDTH; |
| 1396 |
if (m_SearchEditWidth <= 350) { |
| 1397 |
m_pSearchEdit->setFixedSize(m_SearchEditWidth - 20, 36); |
| 1398 |
} else { |
| 1399 |
m_SearchEditWidth = 350; |
| 1400 |
m_pSearchEdit->setFixedSize(m_SearchEditWidth, 36); |
| 1401 |
} |
| 1402 |
QMetaObject::invokeMethod(this, [ = ]() { |
| 1403 |
if (m_isFirstStart) { |
| 1404 |
if (nullptr == m_pSearchView) { |
| 1405 |
int index = m_pCenterWidget->indexOf(m_pSearchViewWidget); |
| 1406 |
m_pSearchView = new SearchView(); |
| 1407 |
m_pCenterWidget->insertWidget(index, m_pSearchView); |
| 1408 |
m_pCenterWidget->removeWidget(m_pSearchViewWidget); |
| 1409 |
} |
| 1410 |
if (m_processOptionIsEmpty) { |
| 1411 |
m_commandLine->viewImage("", {}); |
| 1412 |
} |
| 1413 |
|
| 1414 |
initShortcut(); |
| 1415 |
initConnections(); |
| 1416 |
|
| 1417 |
if (0 < DBManager::instance()->getImgsCount()) { |
| 1418 |
// dothing |
| 1419 |
} else { |
| 1420 |
m_pSearchEdit->setEnabled(false); |
| 1421 |
} |
| 1422 |
} |
| 1423 |
m_isFirstStart = false; |
| 1424 |
}, Qt::QueuedConnection); |
| 1425 |
} |
| 1426 |
|
| 1427 |
void MainWindow::saveWindowState() |
| 1428 |
{ |
| 1429 |
m_settings->setValue("album-geometry", saveGeometry()); |
| 1430 |
m_settings->setValue("album-isMaximized", isMaximized()); |
| 1431 |
m_settings->setValue("album-version", VERSION); |
| 1432 |
saveZoomRatio(); |
| 1433 |
} |
| 1434 |
|
| 1435 |
//加载主界面状态(上次退出时) |
| 1436 |
void MainWindow::loadWindowState() |
| 1437 |
{ |
| 1438 |
const QByteArray geometry = m_settings->value("album-geometry").toByteArray(); |
| 1439 |
const bool isMaximized = m_settings->value("album-isMaximized").toBool(); |
| 1440 |
// const QByteArray pos = settings.value("album-pos").toByteArray(); |
| 1441 |
if (!geometry.isEmpty()) { |
| 1442 |
if (m_settings->contains("album-version")) { |
| 1443 |
if (m_settings->value("album-version").toString().isEmpty()) { |
| 1444 |
restoreGeometry(geometry); |
| 1445 |
if (isMaximized) { |
| 1446 |
resize(1300, 848); |
| 1447 |
Dtk::Widget::moveToCenter(this); |
| 1448 |
} |
| 1449 |
} else if (compareVersion()) { |
| 1450 |
resize(1300, 848); |
| 1451 |
} else { |
| 1452 |
restoreGeometry(geometry); |
| 1453 |
if (isMaximized) { |
| 1454 |
resize(1300, 848); |
| 1455 |
Dtk::Widget::moveToCenter(this); |
| 1456 |
} |
| 1457 |
} |
| 1458 |
} else { |
| 1459 |
resize(1300, 848); |
| 1460 |
} |
| 1461 |
} |
| 1462 |
// settings.endGroup(); |
| 1463 |
getButG(); |
| 1464 |
} |
| 1465 |
|
| 1466 |
//保存缩放比例 |
| 1467 |
void MainWindow::saveZoomRatio() |
| 1468 |
{ |
| 1469 |
m_settings->setValue("album-zoomratio", m_pSliderPos); |
| 1470 |
} |
| 1471 |
|
| 1472 |
bool MainWindow::compareVersion() |
| 1473 |
{ |
| 1474 |
QString versionBuild(VERSION); |
| 1475 |
QStringList versionBuildList = versionBuild.split("."); |
| 1476 |
QStringList versionConfigList = m_settings->value("album-version").toString().split("."); |
| 1477 |
if (versionBuildList.size() == 4 && versionConfigList.size() == 4) { |
| 1478 |
for (int i = 0; i < 4; i++) { |
| 1479 |
if (versionBuildList.at(i).toInt() > versionConfigList.at(i).toInt()) { |
| 1480 |
return true; |
| 1481 |
} else if (versionConfigList.at(i).toInt() == versionBuildList.at(i).toInt()) { |
| 1482 |
continue; |
| 1483 |
} else { |
| 1484 |
return false; |
| 1485 |
} |
| 1486 |
} |
| 1487 |
return false; |
| 1488 |
} else { |
| 1489 |
return false; |
| 1490 |
} |
| 1491 |
} |
| 1492 |
|
| 1493 |
//加载缩放比例(上次退出时) |
| 1494 |
void MainWindow::loadZoomRatio() |
| 1495 |
{ |
| 1496 |
if (m_settings->contains("album-version")) { |
| 1497 |
if (m_settings->value("album-version").toString().isEmpty()) { |
| 1498 |
if (!m_settings->contains("album-zoomratio")) { |
| 1499 |
m_pSliderPos = 4; |
| 1500 |
} else { |
| 1501 |
m_pSliderPos = m_settings->value("album-zoomratio").toInt(); |
| 1502 |
} |
| 1503 |
} else if (compareVersion()) { |
| 1504 |
m_pSliderPos = 4; |
| 1505 |
} else { |
| 1506 |
if (!m_settings->contains("album-zoomratio")) { |
| 1507 |
m_pSliderPos = 4; |
| 1508 |
} else { |
| 1509 |
m_pSliderPos = m_settings->value("album-zoomratio").toInt(); |
| 1510 |
} |
| 1511 |
} |
| 1512 |
dApp->signalM->emitSliderValueChg(m_pSliderPos); |
| 1513 |
} else { |
| 1514 |
m_pSliderPos = 4; |
| 1515 |
} |
| 1516 |
|
| 1517 |
m_pAllPicView->m_pStatusBar->m_pSlider->setValue(m_pSliderPos); |
| 1518 |
dApp->signalM->emitSliderValueChg(m_pSliderPos); |
| 1519 |
qDebug() << "zy------MainWindow::loadZoomRatio end"; |
| 1520 |
} |
| 1521 |
|
| 1522 |
//初始化各种快捷键 |
| 1523 |
void MainWindow::initShortcutKey() |
| 1524 |
{ |
| 1525 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, VIEW_CONTEXT_MENU, ENTER_SHORTCUT); |
| 1526 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, FULLSCREEN_CONTEXT_MENU, F11_SHORTCUT); |
| 1527 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, SLIDESHOW_CONTEXT_MENU, F5_SHORTCUT); |
| 1528 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, COPYTOCLIPBOARD_CONTEXT_MENU, CTRLC_SHORTCUT); |
| 1529 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, DELETE_CONTEXT_MENU, DELETE_SHORTCUT); |
| 1530 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, THROWTOTRASH_CONTEXT_MENU, DELETE_SHORTCUT); |
| 1531 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, REMOVEFROMALBUM_CONTEXT_MENU, SHIFTDEL_SHORTCUT); |
| 1532 |
// ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, UNFAVORITE_CONTEXT_MENU, CTRLSHIFTK_SHORTCUT); |
| 1533 |
// ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, FAVORITE_CONTEXT_MENU, CTRLK_SHORTCUT); |
| 1534 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, FAVORITE_CONTEXT_MENU, SENTENCE_SHORTCUT); |
| 1535 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, ROTATECLOCKWISE_CONTEXT_MENU, CTRLR_SHORTCUT); |
| 1536 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, ROTATECOUNTERCLOCKWISE_CONTEXT_MENU, CTRLSHIFTR_SHORTCUT); |
| 1537 |
// ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, SETASWALLPAPER_CONTEXT_MENU, CTRLF8_SHORTCUT); |
| 1538 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, SETASWALLPAPER_CONTEXT_MENU, CTRLF9_SHORTCUT); |
| 1539 |
// ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, DISPLAYINFILEMANAGER_CONTEXT_MENU, CTRLD_SHORTCUT); |
| 1540 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, DISPLAYINFILEMANAGER_CONTEXT_MENU, ALTD_SHORTCUT); |
| 1541 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, ImageInfo_CONTEXT_MENU, CTRLI_SHORTCUT); |
| 1542 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, COMMON_STR_CREATEALBUM, CTRLSHIFTN_SHORTCUT); |
| 1543 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, COMMON_STR_RENAMEALBUM, F2_SHORTCUT); |
| 1544 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, SHOW_SHORTCUT_PREVIEW, CTRLSHIFTSLASH_SHORTCUT); |
| 1545 |
ConfigSetter::instance()->setValue(SHORTCUTVIEW_GROUP, EXPORT_CONTEXT_MENU, CTRLE_SHORTCUT); |
| 1546 |
|
| 1547 |
QString userConfigPath = DStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) |
| 1548 |
+ "/config.conf"; |
| 1549 |
m_settings = new QSettings(userConfigPath, QSettings::IniFormat, this); |
| 1550 |
} |
| 1551 |
|
| 1552 |
//缩略图放大 |
| 1553 |
void MainWindow::thumbnailZoomIn() |
| 1554 |
{ |
| 1555 |
if (VIEW_IMAGE == m_pCenterWidget->currentIndex()) { |
| 1556 |
emit dApp->signalM->sigCtrlADDKeyActivated(); |
| 1557 |
} else { |
| 1558 |
if (m_pSliderPos != m_pAllPicView->m_pStatusBar->m_pSlider->maximum()) { |
| 1559 |
m_pSliderPos = m_pSliderPos + 1; |
| 1560 |
if (m_pCenterWidget->currentIndex() == VIEW_ALLPIC) { |
| 1561 |
m_pAllPicView->m_pStatusBar->m_pSlider->setValue(m_pSliderPos); |
| 1562 |
} else if (m_pCenterWidget->currentIndex() == VIEW_TIMELINE) { |
| 1563 |
m_pTimeLineView->m_pStatusBar->m_pSlider->setValue(m_pSliderPos); |
| 1564 |
} else if (m_pCenterWidget->currentIndex() == VIEW_ALBUM) { |
| 1565 |
m_pAlbumview->m_pStatusBar->m_pSlider->setValue(m_pSliderPos); |
| 1566 |
} |
| 1567 |
|
| 1568 |
dApp->signalM->emitSliderValueChg(m_pSliderPos); |
| 1569 |
} |
| 1570 |
} |
| 1571 |
} |
| 1572 |
|
| 1573 |
//缩略图缩小 |
| 1574 |
void MainWindow::thumbnailZoomOut() |
| 1575 |
{ |
| 1576 |
if (VIEW_IMAGE == m_pCenterWidget->currentIndex()) { |
| 1577 |
emit dApp->signalM->sigCtrlSubtractKeyActivated(); |
| 1578 |
} else { |
| 1579 |
if (m_pSliderPos != m_pAllPicView->m_pStatusBar->m_pSlider->minimum()) { |
| 1580 |
m_pSliderPos = m_pSliderPos - 1; |
| 1581 |
if (m_pCenterWidget->currentIndex() == VIEW_ALLPIC) { |
| 1582 |
m_pAllPicView->m_pStatusBar->m_pSlider->setValue(m_pSliderPos); |
| 1583 |
} else if (m_pCenterWidget->currentIndex() == VIEW_TIMELINE) { |
| 1584 |
m_pTimeLineView->m_pStatusBar->m_pSlider->setValue(m_pSliderPos); |
| 1585 |
} else if (m_pCenterWidget->currentIndex() == VIEW_ALBUM) { |
| 1586 |
m_pAlbumview->m_pStatusBar->m_pSlider->setValue(m_pSliderPos); |
| 1587 |
} |
| 1588 |
|
| 1589 |
dApp->signalM->emitSliderValueChg(m_pSliderPos); |
| 1590 |
} |
| 1591 |
} |
| 1592 |
} |
| 1593 |
|
| 1594 |
QJsonObject MainWindow::createShorcutJson() |
| 1595 |
{ |
| 1596 |
//Translations |
| 1597 |
QJsonObject shortcut1; |
| 1598 |
shortcut1.insert("name", "Window sizing"); |
| 1599 |
shortcut1.insert("value", "Ctrl+Alt+F"); |
| 1600 |
QJsonObject shortcut2; |
| 1601 |
shortcut2.insert("name", tr("Fullscreen")); |
| 1602 |
shortcut2.insert("value", "F11"); |
| 1603 |
QJsonObject shortcut3; |
| 1604 |
shortcut3.insert("name", tr("Exit fullscreen/slideshow")); |
| 1605 |
shortcut3.insert("value", "Esc"); |
| 1606 |
QJsonObject shortcut4; |
| 1607 |
shortcut4.insert("name", "Close application"); |
| 1608 |
shortcut4.insert("value", "Alt+F4"); |
| 1609 |
QJsonObject shortcut5; |
| 1610 |
shortcut5.insert("name", tr("Help")); |
| 1611 |
shortcut5.insert("value", "F1"); |
| 1612 |
QJsonObject shortcut6; |
| 1613 |
shortcut6.insert("name", tr("Display shortcuts")); |
| 1614 |
shortcut6.insert("value", "Ctrl+Shift+?"); |
| 1615 |
QJsonObject shortcut7; |
| 1616 |
shortcut7.insert("name", tr("Display in file manager")); |
| 1617 |
shortcut7.insert("value", "Alt+D"); |
| 1618 |
QJsonObject shortcut8; |
| 1619 |
shortcut8.insert("name", tr("Slide show")); |
| 1620 |
shortcut8.insert("value", "F5"); |
| 1621 |
QJsonObject shortcut9; |
| 1622 |
shortcut9.insert("name", tr("View")); |
| 1623 |
shortcut9.insert("value", "Enter"); |
| 1624 |
QJsonObject shortcut10; |
| 1625 |
shortcut10.insert("name", tr("Export photos")); |
| 1626 |
shortcut10.insert("value", "Ctrl+E"); |
| 1627 |
QJsonObject shortcut11; |
| 1628 |
shortcut11.insert("name", tr("Import photos/videos")); |
| 1629 |
shortcut11.insert("value", "Ctrl+O"); |
| 1630 |
QJsonObject shortcut12; |
| 1631 |
shortcut12.insert("name", tr("Select all")); |
| 1632 |
shortcut12.insert("value", "Ctrl+A"); |
| 1633 |
QJsonObject shortcut13; |
| 1634 |
shortcut13.insert("name", tr("Copy")); |
| 1635 |
shortcut13.insert("value", "Ctrl+C"); |
| 1636 |
QJsonObject shortcut14; |
| 1637 |
shortcut14.insert("name", tr("Delete")); |
| 1638 |
shortcut14.insert("value", "Delete"); |
| 1639 |
QJsonObject shortcut15; |
| 1640 |
shortcut15.insert("name", tr("Photo/Video info")); |
| 1641 |
shortcut15.insert("value", "Ctrl+I"); |
| 1642 |
QJsonObject shortcut16; |
| 1643 |
shortcut16.insert("name", tr("Set as wallpaper")); |
| 1644 |
shortcut16.insert("value", "Ctrl+F9"); |
| 1645 |
QJsonObject shortcut17; |
| 1646 |
shortcut17.insert("name", tr("Rotate clockwise")); |
| 1647 |
shortcut17.insert("value", "Ctrl+R"); |
| 1648 |
QJsonObject shortcut18; |
| 1649 |
shortcut18.insert("name", tr("Rotate counterclockwise")); |
| 1650 |
shortcut18.insert("value", "Ctrl+Shift+R"); |
| 1651 |
QJsonObject shortcut19; |
| 1652 |
shortcut19.insert("name", " "); |
| 1653 |
shortcut19.insert("value", " "); |
| 1654 |
QJsonObject shortcut20; |
| 1655 |
shortcut20.insert("name", tr("Zoom in")); |
| 1656 |
shortcut20.insert("value", "Ctrl+'+'"); |
| 1657 |
QJsonObject shortcut21; |
| 1658 |
shortcut21.insert("name", tr("Zoom out")); |
| 1659 |
shortcut21.insert("value", "Ctrl+'-'"); |
| 1660 |
QJsonObject shortcut22; |
| 1661 |
shortcut22.insert("name", tr("Previous")); |
| 1662 |
shortcut22.insert("value", "Left"); |
| 1663 |
QJsonObject shortcut23; |
| 1664 |
shortcut23.insert("name", tr("Next")); |
| 1665 |
shortcut23.insert("value", "Right"); |
| 1666 |
QJsonObject shortcut24; |
| 1667 |
shortcut24.insert("name", tr("Favorite")); |
| 1668 |
shortcut24.insert("value", "."); |
| 1669 |
QJsonObject shortcut25; |
| 1670 |
shortcut25.insert("name", tr("Unfavorite")); |
| 1671 |
shortcut25.insert("value", "."); |
| 1672 |
QJsonObject shortcut26; |
| 1673 |
shortcut26.insert("name", tr("New album")); |
| 1674 |
shortcut26.insert("value", "Ctrl+Shift+N"); |
| 1675 |
QJsonObject shortcut27; |
| 1676 |
shortcut27.insert("name", tr("Rename album")); |
| 1677 |
shortcut27.insert("value", "F2"); |
| 1678 |
QJsonObject shortcut28; |
| 1679 |
shortcut28.insert("name", tr("Page up")); |
| 1680 |
shortcut28.insert("value", "PageUp"); |
| 1681 |
QJsonObject shortcut29; |
| 1682 |
shortcut29.insert("name", tr("Page down")); |
| 1683 |
shortcut29.insert("value", "PageDown"); |
| 1684 |
|
| 1685 |
|
| 1686 |
|
| 1687 |
QJsonArray shortcutArray1; |
| 1688 |
shortcutArray1.append(shortcut2); |
| 1689 |
shortcutArray1.append(shortcut8); |
| 1690 |
shortcutArray1.append(shortcut3); |
| 1691 |
shortcutArray1.append(shortcut9); |
| 1692 |
shortcutArray1.append(shortcut10); |
| 1693 |
shortcutArray1.append(shortcut11); |
| 1694 |
shortcutArray1.append(shortcut12); |
| 1695 |
shortcutArray1.append(shortcut13); |
| 1696 |
shortcutArray1.append(shortcut14); |
| 1697 |
shortcutArray1.append(shortcut15); |
| 1698 |
shortcutArray1.append(shortcut16); |
| 1699 |
shortcutArray1.append(shortcut17); |
| 1700 |
shortcutArray1.append(shortcut18); |
| 1701 |
shortcutArray1.append(shortcut7); |
| 1702 |
// shortcutArray1.append(shortcut19); |
| 1703 |
shortcutArray1.append(shortcut20); |
| 1704 |
shortcutArray1.append(shortcut21); |
| 1705 |
shortcutArray1.append(shortcut28); |
| 1706 |
shortcutArray1.append(shortcut29); |
| 1707 |
shortcutArray1.append(shortcut22); |
| 1708 |
shortcutArray1.append(shortcut23); |
| 1709 |
shortcutArray1.append(shortcut24); |
| 1710 |
shortcutArray1.append(shortcut25); |
| 1711 |
QJsonArray shortcutArray2; |
| 1712 |
shortcutArray2.append(shortcut26); |
| 1713 |
shortcutArray2.append(shortcut27); |
| 1714 |
QJsonArray shortcutArray3; |
| 1715 |
shortcutArray3.append(shortcut5); |
| 1716 |
shortcutArray3.append(shortcut6); |
| 1717 |
|
| 1718 |
// shortcutArray.append(shortcut1); |
| 1719 |
// shortcutArray.append(shortcut4); |
| 1720 |
|
| 1721 |
QJsonObject shortcut_group1; |
| 1722 |
// shortcut_group.insert("groupName", tr("热键")); |
| 1723 |
// shortcut_group.insert("groupName", tr("Hotkey")); |
| 1724 |
shortcut_group1.insert("groupName", tr("Photos")); |
| 1725 |
shortcut_group1.insert("groupItems", shortcutArray1); |
| 1726 |
QJsonObject shortcut_group2; |
| 1727 |
shortcut_group2.insert("groupName", tr("Albums")); |
| 1728 |
shortcut_group2.insert("groupItems", shortcutArray2); |
| 1729 |
QJsonObject shortcut_group3; |
| 1730 |
shortcut_group3.insert("groupName", tr("Settings")); |
| 1731 |
shortcut_group3.insert("groupItems", shortcutArray3); |
| 1732 |
|
| 1733 |
QJsonArray shortcutArrayall; |
| 1734 |
shortcutArrayall.append(shortcut_group1); |
| 1735 |
shortcutArrayall.append(shortcut_group2); |
| 1736 |
shortcutArrayall.append(shortcut_group3); |
| 1737 |
|
| 1738 |
QJsonObject main_shortcut; |
| 1739 |
main_shortcut.insert("shortcut", shortcutArrayall); |
| 1740 |
|
| 1741 |
return main_shortcut; |
| 1742 |
} |
| 1743 |
|
| 1744 |
void MainWindow::startMonitor() |
| 1745 |
{ |
| 1746 |
QStringList paths = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation); |
| 1747 |
if (paths.size() > 0) { |
| 1748 |
QString path = paths.at(0) + "/album"; |
| 1749 |
//添加文件夹是否存在判断,不存在则直接返回不进行监控 |
| 1750 |
QDir dir(path); |
| 1751 |
if (!dir.exists()) { |
| 1752 |
// dir.mkdir(path); |
| 1753 |
return; |
| 1754 |
} |
| 1755 |
m_fileInotify = new FileInotify(); |
| 1756 |
m_fileInotify->addWather(path); |
| 1757 |
m_fileInotify->start(); |
| 1758 |
} |
| 1759 |
} |
| 1760 |
|
| 1761 |
void MainWindow::wheelEvent(QWheelEvent *event) |
| 1762 |
{ |
| 1763 |
if (DApplication::keyboardModifiers() == Qt::ControlModifier) { |
| 1764 |
if (event->delta() > 0) { |
| 1765 |
thumbnailZoomIn(); |
| 1766 |
} else { |
| 1767 |
thumbnailZoomOut(); |
| 1768 |
} |
| 1769 |
event->accept(); |
| 1770 |
} |
| 1771 |
} |
| 1772 |
|
| 1773 |
void MainWindow::closeFromMenu() |
| 1774 |
{ |
| 1775 |
//这个函数是从overrideVfptrFun进来的,要指定obj对象 |
| 1776 |
instance().close(); |
| 1777 |
} |
| 1778 |
|
| 1779 |
void MainWindow::onButtonClicked(int id) |
| 1780 |
{ |
| 1781 |
if (0 == id) { |
| 1782 |
allPicBtnClicked(); |
| 1783 |
#ifdef tablet_PC |
| 1784 |
#else |
| 1785 |
m_pSearchEdit->setVisible(true); |
| 1786 |
#endif |
| 1787 |
} |
| 1788 |
int index = 0; |
| 1789 |
if (1 == id) { |
| 1790 |
if (nullptr == m_pTimeLineView) { |
| 1791 |
m_pCenterWidget->removeWidget(m_pTimeLineWidget); |
| 1792 |
index = m_pCenterWidget->indexOf(m_pAllPicView) + 1; |
| 1793 |
m_pTimeLineView = new TimeLineView(); |
| 1794 |
m_pCenterWidget->insertWidget(index, m_pTimeLineView); |
| 1795 |
// m_pTimeLineView->clearAndStartLayout(); |
| 1796 |
} |
| 1797 |
timeLineBtnClicked(); |
| 1798 |
#ifdef tablet_PC |
| 1799 |
#else |
| 1800 |
m_pSearchEdit->setVisible(true); |
| 1801 |
#endif |
| 1802 |
} |
| 1803 |
if (2 == id) { |
| 1804 |
if (nullptr == m_pAlbumview) { |
| 1805 |
if (nullptr == m_pTimeLineView) { |
| 1806 |
m_pCenterWidget->removeWidget(m_pTimeLineWidget); |
| 1807 |
index = m_pCenterWidget->indexOf(m_pAllPicView) + 1; |
| 1808 |
m_pTimeLineView = new TimeLineView(); |
| 1809 |
m_pCenterWidget->insertWidget(index, m_pTimeLineView); |
| 1810 |
// m_pTimeLineView->clearAndStartLayout(); |
| 1811 |
} |
| 1812 |
m_pCenterWidget->removeWidget(m_pAlbumWidget); |
| 1813 |
index = m_pCenterWidget->indexOf(m_pTimeLineView) + 1; |
| 1814 |
m_pAlbumview = new AlbumView(); |
| 1815 |
connect(m_pAlbumview, &AlbumView::sigSearchEditIsDisplay, this, &MainWindow::onSearchEditIsDisplay); |
| 1816 |
m_pCenterWidget->insertWidget(index, m_pAlbumview); |
| 1817 |
} |
| 1818 |
albumBtnClicked(); |
| 1819 |
// 如果是最近删除或者移动设备,则搜索框不显示 |
| 1820 |
if (2 == m_pAlbumview->m_pRightStackWidget->currentIndex() || 5 == m_pAlbumview->m_pRightStackWidget->currentIndex()) { |
| 1821 |
m_pSearchEdit->setVisible(false); |
| 1822 |
} else { |
| 1823 |
#ifdef tablet_PC |
| 1824 |
#else |
| 1825 |
m_pSearchEdit->setVisible(true); |
| 1826 |
#endif |
| 1827 |
} |
| 1828 |
} |
| 1829 |
} |
| 1830 |
|
| 1831 |
void MainWindow::onImageImported(bool success) |
| 1832 |
{ |
| 1833 |
if (success) { |
| 1834 |
if (nullptr == m_pAlbumview) |
| 1835 |
return ; |
| 1836 |
if (ALBUM_PATHTYPE_BY_PHONE == m_pAlbumview->m_pLeftListView->getItemCurrentType()) { |
| 1837 |
//2020/5/20 DJH 修复在设备界面本地导入会导致名称变换 type 写成了 album |
| 1838 |
//m_pAlbumview->m_currentAlbum = ALBUM_PATHTYPE_BY_PHONE; |
| 1839 |
m_pAlbumview->m_currentType = ALBUM_PATHTYPE_BY_PHONE; |
| 1840 |
} |
| 1841 |
} |
| 1842 |
} |
| 1843 |
|
| 1844 |
//void MainWindow::onSearchEditTextChanged(QString text) |
| 1845 |
//{ |
| 1846 |
// if (text.isEmpty()) { |
| 1847 |
// m_SearchKey.clear(); |
| 1848 |
// switch (m_iCurrentView) { |
| 1849 |
// case VIEW_ALLPIC: { |
| 1850 |
// m_pAllPicView->m_pStatusBar->m_pSlider->setValue(m_pSliderPos); |
| 1851 |
// m_pAllPicView->updateStackedWidget(); |
| 1852 |
// m_pAllPicView->updatePicNum(); |
| 1853 |
// } |
| 1854 |
// break; |
| 1855 |
// case VIEW_TIMELINE: { |
| 1856 |
// m_pTimeLineView->m_pStatusBar->m_pSlider->setValue(m_pSliderPos); |
| 1857 |
// m_pTimeLineView->updateStackedWidget(); |
| 1858 |
// m_pTimeLineView->updatePicNum(); |
| 1859 |
// } |
| 1860 |
// break; |
| 1861 |
// case VIEW_ALBUM: { |
| 1862 |
// m_pAlbumview->SearchReturnUpdate(); |
| 1863 |
// m_pAlbumview->m_pStatusBar->m_pSlider->setValue(m_pSliderPos); |
| 1864 |
// m_pAlbumview->updatePicNum(); |
| 1865 |
// } |
| 1866 |
// break; |
| 1867 |
// } |
| 1868 |
// } |
| 1869 |
//} |
| 1870 |
|
| 1871 |
void MainWindow::onImagesInserted() |
| 1872 |
{ |
| 1873 |
m_pSearchEdit->setEnabled(true); |
| 1874 |
} |
| 1875 |
|
| 1876 |
void MainWindow::onStartImprot() |
| 1877 |
{ |
| 1878 |
m_countLabel->setText(""); |
| 1879 |
m_importBar->setValue(0); |
| 1880 |
} |
| 1881 |
|
| 1882 |
void MainWindow::onProgressOfWaitDialog(int allfiles, int completefiles) |
| 1883 |
{ |
| 1884 |
QString countText = ""; |
| 1885 |
if (m_bImport) { |
| 1886 |
countText = QString(QObject::tr("%1/%2 items imported")).arg(completefiles).arg(allfiles); |
| 1887 |
} else { |
| 1888 |
countText = QString(QObject::tr("%1/%2 items deleted")).arg(completefiles).arg(allfiles); |
| 1889 |
} |
| 1890 |
|
| 1891 |
m_countLabel->setText(countText); |
| 1892 |
m_countLabel->show(); |
| 1893 |
m_importBar->setRange(0, allfiles); |
| 1894 |
m_importBar->setAlignment(Qt::AlignCenter); |
| 1895 |
m_importBar->setTextVisible(false); |
| 1896 |
m_importBar->setValue(completefiles); |
| 1897 |
} |
| 1898 |
|
| 1899 |
void MainWindow::onPopupWaitDialog(QString waittext, bool bneedprogress) |
| 1900 |
{ |
| 1901 |
if (bneedprogress == false) { |
| 1902 |
m_importBar->hide(); |
| 1903 |
m_countLabel->hide(); |
| 1904 |
m_waitlabel->setText(waittext); |
| 1905 |
m_waitlabel->move(40, 30); |
| 1906 |
m_waitlabel->show(); |
| 1907 |
m_waitdailog->show(); |
| 1908 |
} else { |
| 1909 |
if (waittext.compare(tr("Importing..."), Qt::CaseInsensitive)) { |
| 1910 |
m_bImport = true; |
| 1911 |
} else { |
| 1912 |
m_bImport = false; |
| 1913 |
} |
| 1914 |
m_waitlabel->move(40, 7); |
| 1915 |
m_waitlabel->setText(waittext); |
| 1916 |
m_importBar->show(); |
| 1917 |
m_waitlabel->show(); |
| 1918 |
m_waitdailog->show(); |
| 1919 |
} |
| 1920 |
} |
| 1921 |
|
| 1922 |
void MainWindow::onCloseWaitDialog() |
| 1923 |
{ |
| 1924 |
m_bImport = false; |
| 1925 |
m_countLabel->setText(""); |
| 1926 |
m_waitdailog->close(); |
| 1927 |
} |
| 1928 |
|
| 1929 |
void MainWindow::onImagesRemoved() |
| 1930 |
{ |
| 1931 |
if (0 < DBManager::instance()->getImgsCount()) { |
| 1932 |
m_pSearchEdit->setEnabled(true); |
| 1933 |
} else { |
| 1934 |
m_pSearchEdit->setEnabled(false); |
| 1935 |
} |
| 1936 |
} |
| 1937 |
|
| 1938 |
void MainWindow::onHideImageView() |
| 1939 |
{ |
| 1940 |
titlebar()->setVisible(true); //显示状态栏 |
| 1941 |
setTitlebarShadowEnabled(true); |
| 1942 |
m_pCenterWidget->setCurrentIndex(m_backIndex); |
| 1943 |
//外部打开图片,返回时默认跳转到所有照片界面 |
| 1944 |
if (m_backIndex == VIEW_ALLPIC) { |
| 1945 |
allPicBtnClicked(); |
| 1946 |
} |
| 1947 |
} |
| 1948 |
|
| 1949 |
void MainWindow::onShowSlidePanel(int index) |
| 1950 |
{ |
| 1951 |
m_backIndex_fromSlide = index; |
| 1952 |
titlebar()->setVisible(false); |
| 1953 |
setTitlebarShadowEnabled(false); |
| 1954 |
m_pCenterWidget->setCurrentIndex(VIEW_SLIDE); |
| 1955 |
} |
| 1956 |
|
| 1957 |
void MainWindow::onHideSlidePanel() |
| 1958 |
{ |
| 1959 |
emit dApp->signalM->hideExtensionPanel(); |
| 1960 |
if (VIEW_IMAGE != m_backIndex_fromSlide) { |
| 1961 |
titlebar()->setVisible(true); |
| 1962 |
setTitlebarShadowEnabled(true); |
| 1963 |
} |
| 1964 |
|
| 1965 |
m_pCenterWidget->setCurrentIndex(m_backIndex_fromSlide); |
| 1966 |
} |
| 1967 |
|
| 1968 |
void MainWindow::onExportImage(QStringList paths) |
| 1969 |
{ |
| 1970 |
Exporter::instance()->exportImage(paths); |
| 1971 |
} |
| 1972 |
|
| 1973 |
void MainWindow::onMainwindowSliderValueChg(int step) |
| 1974 |
{ |
| 1975 |
m_pSliderPos = step; |
| 1976 |
saveZoomRatio(); |
| 1977 |
} |
| 1978 |
|
| 1979 |
void MainWindow::onAlbDelToast(QString str1) |
| 1980 |
{ |
| 1981 |
QIcon icon(":/images/logo/resources/images/other/icon_toast_sucess_new.svg"); |
| 1982 |
QString str2 = tr("Album “%1” removed"); |
| 1983 |
QString str = str2.arg(str1); |
| 1984 |
floatMessage(str, icon); |
| 1985 |
} |
| 1986 |
|
| 1987 |
void MainWindow::onAddDuplicatePhotos() |
| 1988 |
{ |
| 1989 |
QIcon icon; |
| 1990 |
QString str = QObject::tr("The photo/video already exists"); |
| 1991 |
floatMessage(str, icon); |
| 1992 |
} |
| 1993 |
|
| 1994 |
void MainWindow::onRepeatImportingTheSamePhotos(QStringList importPaths, QStringList duplicatePaths, const QString &albumName) |
| 1995 |
{ |
| 1996 |
Q_UNUSED(albumName) |
| 1997 |
QIcon icon; |
| 1998 |
QString str = QObject::tr("%1 items imported, %2 items exist already").arg(importPaths.count()).arg(duplicatePaths.count()); |
| 1999 |
floatMessage(str, icon); |
| 2000 |
} |
| 2001 |
|
| 2002 |
void MainWindow::onAddToAlbToast(QString album) |
| 2003 |
{ |
| 2004 |
QIcon icon(":/images/logo/resources/images/other/icon_toast_sucess_new.svg"); |
| 2005 |
QString str2 = tr("Successfully added to “%1”"); |
| 2006 |
QString str = str2.arg(album); |
| 2007 |
floatMessage(str, icon); |
| 2008 |
} |
| 2009 |
|
| 2010 |
void MainWindow::onImportSuccess() |
| 2011 |
{ |
| 2012 |
QIcon icon(":/images/logo/resources/images/other/icon_toast_sucess_new.svg"); |
| 2013 |
QString str = tr("Import successful"); |
| 2014 |
floatMessage(str, icon); |
| 2015 |
} |
| 2016 |
|
| 2017 |
void MainWindow::onSearchEditClear() |
| 2018 |
{ |
| 2019 |
m_pSearchEdit->clearEdit(); |
| 2020 |
m_SearchKey.clear(); |
| 2021 |
} |
| 2022 |
|
| 2023 |
void MainWindow::onImportFailed() |
| 2024 |
{ |
| 2025 |
QIcon icon(":/images/logo/resources/images/other/warning_new.svg"); |
| 2026 |
QString str = tr("Import failed"); |
| 2027 |
floatMessage(str, icon); |
| 2028 |
} |
| 2029 |
|
| 2030 |
void MainWindow::onImportSomeFailed(int successful, int failed) |
| 2031 |
{ |
| 2032 |
QIcon icon(":/images/logo/resources/images/other/warning_new.svg"); |
| 2033 |
QString str = QObject::tr("%1 items imported, %2 items failed"); |
| 2034 |
QString str1 = QString::number(successful, 10); |
| 2035 |
QString str2 = QString::number(failed, 10); |
| 2036 |
QString res = str.arg(str1).arg(str2); |
| 2037 |
floatMessage(res, icon); |
| 2038 |
} |
| 2039 |
|
| 2040 |
void MainWindow::onImportDonotFindPicOrVideo() |
| 2041 |
{ |
| 2042 |
QIcon icon(":/images/logo/resources/images/other/warning_new.svg"); |
| 2043 |
QString str = tr("No photos or videos found"); |
| 2044 |
floatMessage(str, icon); |
| 2045 |
} |
| 2046 |
|
| 2047 |
void MainWindow::onImgExportFailed() |
| 2048 |
{ |
| 2049 |
QIcon icon(":/images/logo/resources/images/other/warning_new.svg"); |
| 2050 |
QString str = tr("Export failed"); |
| 2051 |
floatMessage(str, icon); |
| 2052 |
} |
| 2053 |
|
| 2054 |
void MainWindow::onImgExportSuccess() |
| 2055 |
{ |
| 2056 |
QIcon icon(":/images/logo/resources/images/other/icon_toast_sucess_new.svg"); |
| 2057 |
QString str = tr("Export successful"); |
| 2058 |
floatMessage(str, icon); |
| 2059 |
} |
| 2060 |
|
| 2061 |
void MainWindow::onAlbExportFailed() |
| 2062 |
{ |
| 2063 |
QIcon icon(":/images/logo/resources/images/other/warning_new.svg"); |
| 2064 |
QString str = tr("Export failed"); |
| 2065 |
floatMessage(str, icon); |
| 2066 |
} |
| 2067 |
|
| 2068 |
void MainWindow::onAlbExportSuccess() |
| 2069 |
{ |
| 2070 |
QIcon icon(":/images/logo/resources/images/other/icon_toast_sucess_new.svg"); |
| 2071 |
QString str = tr("Export successful"); |
| 2072 |
floatMessage(str, icon); |
| 2073 |
} |
| 2074 |
|
| 2075 |
void MainWindow::onEscShortcutActivated() |
| 2076 |
{ |
| 2077 |
if (window()->isFullScreen()) { |
| 2078 |
emit dApp->signalM->sigESCKeyActivated(); |
| 2079 |
emit dApp->signalM->sigESCKeyStopSlide(); |
| 2080 |
} else if (VIEW_IMAGE == m_pCenterWidget->currentIndex()) { |
| 2081 |
this->close(); |
| 2082 |
} |
| 2083 |
emit dApp->signalM->hideExtensionPanel(); |
| 2084 |
} |
| 2085 |
|
| 2086 |
void MainWindow::onDelShortcutActivated() |
| 2087 |
{ |
| 2088 |
emit dApp->signalM->sigShortcutKeyDelete(); |
| 2089 |
} |
| 2090 |
|
| 2091 |
void MainWindow::onKeyF2ShortcutActivated() |
| 2092 |
{ |
| 2093 |
emit dApp->signalM->sigShortcutKeyF2(); |
| 2094 |
} |
| 2095 |
|
| 2096 |
void MainWindow::onCtrlShiftSlashShortcutActivated() |
| 2097 |
{ |
| 2098 |
QRect rect = window()->geometry(); |
| 2099 |
QPoint pos(rect.x() + rect.width() / 2, rect.y() + rect.height() / 2); |
| 2100 |
QStringList shortcutString; |
| 2101 |
QJsonObject json = createShorcutJson(); |
| 2102 |
|
| 2103 |
QString param1 = "-j=" + QString(QJsonDocument(json).toJson()); |
| 2104 |
QString param2 = "-p=" + QString::number(pos.x()) + "," + QString::number(pos.y()); |
| 2105 |
shortcutString << param1 << param2; |
| 2106 |
|
| 2107 |
QProcess *shortcutViewProcess = new QProcess(this); |
| 2108 |
shortcutViewProcess->startDetached("deepin-shortcut-viewer", shortcutString); |
| 2109 |
|
| 2110 |
connect(shortcutViewProcess, SIGNAL(finished(int)), shortcutViewProcess, SLOT(deleteLater())); |
| 2111 |
} |
| 2112 |
|
| 2113 |
void MainWindow::onCtrlFShortcutActivated() |
| 2114 |
{ |
| 2115 |
m_pSearchEdit->lineEdit()->setFocus(); |
| 2116 |
} |
| 2117 |
|
| 2118 |
void MainWindow::onShowImageView(int index) |
| 2119 |
{ |
| 2120 |
m_backIndex = index; |
| 2121 |
titlebar()->setVisible(false); //隐藏顶部状态栏 |
| 2122 |
setTitlebarShadowEnabled(false); |
| 2123 |
m_pCenterWidget->setCurrentIndex(VIEW_IMAGE); |
| 2124 |
} |
| 2125 |
|
| 2126 |
void MainWindow::onSearchEditIsDisplay(bool bIsDisp) |
| 2127 |
{ |
| 2128 |
if (m_pCenterWidget->currentIndex() == VIEW_ALBUM) { |
| 2129 |
#ifdef tablet_PC |
| 2130 |
if (!bIsDisp) { |
| 2131 |
m_pSearchEdit->setVisible(bIsDisp); |
| 2132 |
} |
| 2133 |
#else |
| 2134 |
m_pSearchEdit->setVisible(bIsDisp); |
| 2135 |
#endif |
| 2136 |
} |
| 2137 |
} |