Debian Codegraph @

kysdk-qtwidgets/src/ksliderframe.cpp

raw
1 /*
2 *
3 *
4 * Copyright (C) 2023, KylinSoft Co., Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this library. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Authors: Sisheng He <[email protected]>
20 *
21 */
22 #include "ksliderframe.h"
23
24 #include <QDebug>
25 namespace kdk
26 {
27
28 class KSliderFramePrivate : public QObject
29 {
30 Q_OBJECT
31 Q_DECLARE_PUBLIC(KSliderFrame)
32 public:
33 KSliderFramePrivate(KSliderFrame *parent);
34
35 private:
36 KSliderFrame *q_ptr;
37
38 KSlider *m_pSlider;
39 QLabel *m_pLeftLabel;
40 QLabel *m_pRightLabel;
41 KLabel *m_pSettingName;
42 QHBoxLayout *m_pMainLayout;
43 };
44
45 KSliderFramePrivate::KSliderFramePrivate(KSliderFrame *parent)
46 : q_ptr(parent)
47 {
48 Q_Q(KSliderFrame);
49
50 m_pSettingName = new KLabel(q);
51 m_pSettingName->setFixedWidth(SETTING_LABEL_WIDTH);
52
53 m_pSlider = new KSlider(q);
54 m_pLeftLabel = new QLabel(q);
55 m_pLeftLabel->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
56 m_pRightLabel = new QLabel(q);
57 m_pRightLabel->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
58
59 m_pMainLayout = new QHBoxLayout(q);
60 m_pMainLayout->setContentsMargins(16, 0, 16, 0);
61 m_pMainLayout->addWidget(m_pSettingName);
62 m_pMainLayout->addSpacing(8);
63 m_pMainLayout->addWidget(m_pLeftLabel);
64 m_pMainLayout->addWidget(m_pSlider);
65 m_pMainLayout->addWidget(m_pRightLabel);
66
67 q->setLayout(m_pMainLayout);
68 }
69
70 KSliderFrame::KSliderFrame(QString title, bool hasNode, QWidget *parent, BorderRadiusStyle style, Qt::Orientation orientation)
71 : KBaseFrame(parent, style, true)
72 , d_ptr(new KSliderFramePrivate(this))
73 {
74 Q_D(KSliderFrame);
75 setObjectName("KSliderFrame");
76
77 d->m_pSettingName->setText(title);
78 d->m_pSlider->setNodeVisible(hasNode);
79 d->m_pSlider->setOrientation(orientation);
80 }
81
82 KSliderFrame::~KSliderFrame()
83 {
84 }
85
86 QLabel *KSliderFrame::leftLabel()
87 {
88 Q_D(KSliderFrame);
89 return d->m_pLeftLabel;
90 }
91
92 QLabel *KSliderFrame::rightLabel()
93 {
94 Q_D(KSliderFrame);
95 return d->m_pRightLabel;
96 }
97
98 KSlider *KSliderFrame::slider()
99 {
100 Q_D(KSliderFrame);
101 return d->m_pSlider;
102 }
103
104 QHBoxLayout *KSliderFrame::mainHLayout()
105 {
106 Q_D(KSliderFrame);
107 return d->m_pMainLayout;
108 }
109
110 KLabel *KSliderFrame::titleLabel()
111 {
112 Q_D(KSliderFrame);
113 return d->m_pSettingName;
114 }
115 }
116
117 #include "ksliderframe.moc"
118 #include "moc_ksliderframe.cpp"