Debian Codegraph @

src/album/controller/signalmanager.cpp

raw
1 /*
2 * Copyright (C) 2020 ~ 2021 Uniontech Software Technology Co., Ltd.
3 *
4 * Author: ZhangYong <[email protected]>
5 *
6 * Maintainer: ZhangYong <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 #include "signalmanager.h"
22 #include "imginfodialog.h"
23 #include "videoinfodialog.h"
24 #include "application.h"
25 #include "mainwindow.h"
26
27 SignalManager *SignalManager::m_signalManager = nullptr;
28 SignalManager *SignalManager::instance()
29 {
30 if (m_signalManager == nullptr) {
31 m_signalManager = new SignalManager;
32 }
33
34 return m_signalManager;
35 }
36
37 void SignalManager::emitSliderValueChg(int value)
38 {
39 m_sliderValue = value;
40 emit sigMainwindowSliderValueChg(value);
41 }
42
43 int SignalManager::getSliderValue()
44 {
45 return m_sliderValue;
46 }
47
48 void SignalManager::showInfoDlg(const QString &path, ItemType type)
49 {
50 DBImgInfo data;
51 if (type == ItemTypeNull) {
52 ImageEngineApi::instance()->getImageData(path, data);
53 } else {
54 data.itemType = type;
55 }
56
57 if (data.itemType == ItemTypePic) {
58 ImgInfoDialog *dialog = new ImgInfoDialog(path, dApp->getMainWindow());
59 dialog->setObjectName("ImgInfoDialog");
60 dialog->show();
61 dialog->move((dApp->getMainWindow()->width() - dialog->width() - 50 + dApp->getMainWindow()->mapToGlobal(QPoint(0, 0)).x())
62 , 100 + dApp->getMainWindow()->mapToGlobal(QPoint(0, 0)).y());
63 dialog->setWindowState(Qt::WindowActive);
64 connect(dialog, &ImgInfoDialog::closed, this, [ = ] {
65 dialog->deleteLater();
66 });
67
68 connect(dialog, &ImgInfoDialog::visibleChanged, this, [ = ](bool visible) {
69 if (!visible) {
70 dialog->deleteLater();
71 }
72 });
73 } else if (data.itemType == ItemTypeVideo) {
74 VideoInfoDialog *dialog = new VideoInfoDialog(path, dApp->getMainWindow());
75 dialog->setObjectName("VideoInfoDialog");
76 dialog->show();
77 dialog->setWindowState(Qt::WindowActive);
78 connect(dialog, &VideoInfoDialog::closed, this, [ = ] {
79 dialog->deleteLater();
80 });
81
82 connect(dialog, &VideoInfoDialog::visibleChanged, this, [ = ](bool visible) {
83 if (!visible) {
84 dialog->deleteLater();
85 }
86 });
87 }
88 }
89
90 SignalManager::SignalManager(QObject *parent) : QObject(parent)
91 {
92
93 }