File: ukccplugin.cpp

package info (click to toggle)
ukui-panel 4.0.0.6-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,148 kB
  • sloc: cpp: 28,423; xml: 476; sh: 51; makefile: 18
file content (154 lines) | stat: -rw-r--r-- 3,791 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/*
 *
 *  * Copyright (C) 2023, KylinSoft Co., Ltd.
 *  *
 *  * This program is free software: you can redistribute it and/or modify
 *  * it under the terms of the GNU General Public License as published by
 *  * the Free Software Foundation, either version 3 of the License, or
 *  * (at your option) any later version.
 *  *
 *  * This program is distributed in the hope that it will be useful,
 *  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  * GNU General Public License for more details.
 *  *
 *  * You should have received a copy of the GNU General Public License
 *  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *  *
 *  * Authors: Nicole <buxiaoqing@kylinos.cn>
 *
 */

#include "ukccplugin.h"

#include <ukcc/widgets/switchbutton.h>

UkccPlugin::UkccPlugin() : mFirstLoad(true)
{
    QTranslator *translator = new QTranslator(this);
    translator->load(QLocale(), "ukccpanel", "_", UKCCPANEL_TRANSLATION_DIR);
    QApplication::installTranslator(translator);

    pluginName = tr("Panel");
    pluginType = SYSTEM;
}

UkccPlugin::~UkccPlugin()
{

}

QString UkccPlugin::plugini18nName()
{
    return pluginName;
}

int UkccPlugin::pluginTypes()
{
    return PERSONALIZED;
}

QWidget *UkccPlugin::pluginUi()
{
    // 需要加上这个判断标志位,否则每次点击都会新建一个QWidget(只加载一次)
    if (mFirstLoad) {
        widget = new QWidget;
        mFirstLoad = false;
        initUI();
    }
    return widget;
}

bool UkccPlugin::isEnable() const
{
    return true;
}

const QString UkccPlugin::name() const
{
    return QStringLiteral("ukccpanel");
}

bool UkccPlugin::isShowOnHomePage() const
{
    //任务栏不需要显示在控制面板首页上
    return false;
}

QIcon UkccPlugin::icon() const
{
    return QIcon("/usr/share/ukui-panel/panel/img/ukui-panel-symbolic.svg");
}

QString UkccPlugin::translationPath() const
{
    return "/usr/share/ukui-panel/plugin-ukccpanel/translation/ukccpanel_%1.ts";
}

void UkccPlugin::initSearchText()
{
    //~ contents_path /ukccpanel/Panel
    tr("Panel");
    //~ contents_path /ukccpanel/Always show  icon in panel
    tr("Always show  icon in panel");
}

void UkccPlugin::initUI()
{
    // 整体布局
    mverticalLayout = new QVBoxLayout(widget);
    mverticalLayout->setSpacing(8);
    mverticalLayout->setContentsMargins(0, 0, 0, 0);

    generalSettings();
    displayBtnOnPanel();

    mverticalLayout->addStretch();

}

void UkccPlugin::setFrame_Noframe(QFrame *frame)
{
    frame->setMinimumSize(QSize(550, 60));
    frame->setMaximumSize(QSize(16777215, 60));
    frame->setFrameShape(QFrame::NoFrame);
}


void UkccPlugin::generalSettings()
{

    CustomTitleLabel = new TitleLabel(widget);
    CustomTitleLabel->setText(tr("Panel"));
    mverticalLayout->addWidget(CustomTitleLabel);

    m_generalSettingsFrame = new GeneralSettings(widget);
    mverticalLayout->addWidget(m_generalSettingsFrame);

    QSpacerItem *spaceitem = new QSpacerItem(40, 40, QSizePolicy::Fixed);
    mverticalLayout->addSpacerItem(spaceitem);
}


void UkccPlugin::displayBtnOnPanel()
{
    m_panelDisplayLabel = new TitleLabel(widget);
    m_panelDisplayLabel->setText(tr("Always show  icon in panel"));
    mverticalLayout->addWidget(m_panelDisplayLabel);

    m_alwaysDisplayonPanelFrame = new AlwaysDisplayonPanel(widget);
    mverticalLayout->addWidget(m_alwaysDisplayonPanelFrame);
}

QFrame *UkccPlugin::setLine(QFrame *frame)
{
    QFrame *line = new QFrame(frame);
    line->setMinimumSize(QSize(0, 1));
    line->setMaximumSize(QSize(16777215, 1));
    line->setLineWidth(0);
    line->setFrameShape(QFrame::HLine);
    line->setFrameShadow(QFrame::Sunken);
    return line;
}