Debian Codegraph @

src/album/widgets/noresultwidget.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 "noresultwidget.h"
22 #include <DApplicationHelper>
23 #include "imageengine/imageengineapi.h"
24 #include <QGraphicsDropShadowEffect>
25 #include <QPainter>
26 #include <QDebug>
27
28 NoResultWidget::NoResultWidget(QWidget *parent): QWidget(parent)
29 {
30 initNoSearchResultView();
31 }
32
33 NoResultWidget::~NoResultWidget()
34 {
35
36 }
37
38 void NoResultWidget::initNoSearchResultView()
39 {
40 QHBoxLayout *pHBoxLayout = new QHBoxLayout(this);
41 this->setLayout(pHBoxLayout);
42
43 pNoResult = new DLabel();
44 pNoResult->setText(tr("No results"));
45 pNoResult->setAlignment(Qt::AlignCenter);
46 pHBoxLayout->addWidget(pNoResult);
47
48 pNoResult->setFont(DFontSizeManager::instance()->get(DFontSizeManager::T4));
49 DPalette palette = DApplicationHelper::instance()->palette(pNoResult);
50 QColor color_TTT = palette.color(DPalette::ToolTipText);
51 DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType();
52 if (themeType == DGuiApplicationHelper::LightType) {
53 color_TTT.setAlphaF(0.3);
54 palette.setBrush(DPalette::Text, color_TTT);
55 pNoResult->setForegroundRole(DPalette::Text);
56 pNoResult->setPalette(palette);
57 } else if (themeType == DGuiApplicationHelper::DarkType) {
58 color_TTT.setAlphaF(0.4);
59 palette.setBrush(DPalette::Text, color_TTT);
60 pNoResult->setForegroundRole(DPalette::Text);
61 pNoResult->setPalette(palette);
62 }
63 }
64
65 void NoResultWidget::changeTheme()
66 {
67 DPalette pale = DApplicationHelper::instance()->palette(pNoResult);
68 pale.setBrush(DPalette::Text, pale.color(DPalette::ToolTipText));
69 pNoResult->setPalette(pale);
70
71 DPalette pa = DApplicationHelper::instance()->palette(pNoResult);
72 QColor color_TTT = pa.color(DPalette::ToolTipText);
73 DPalette pat = DApplicationHelper::instance()->palette(pNoResult);
74 QColor color_BT = pat.color(DPalette::BrightText);
75
76 DGuiApplicationHelper::ColorType themeType = DGuiApplicationHelper::instance()->themeType();
77 if (themeType == DGuiApplicationHelper::LightType) {
78 color_TTT.setAlphaF(0.3);
79 pa.setBrush(DPalette::Text, color_TTT);
80 pNoResult->setPalette(pa);
81 } else if (themeType == DGuiApplicationHelper::DarkType) {
82 color_TTT.setAlphaF(0.4);
83 pa.setBrush(DPalette::Text, color_TTT);
84 pNoResult->setPalette(pa);
85 }
86 }