Debian Codegraph @

kysdk-qtwidgets/src/kpushbuttonframe.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 "kpushbuttonframe.h"
23
24 #include <QDebug>
25
26 namespace kdk
27 {
28
29 class KPushButtonFramePrivate : public QObject
30 {
31 Q_OBJECT
32 Q_DECLARE_PUBLIC(KPushButtonFrame)
33 public:
34 KPushButtonFramePrivate(KPushButtonFrame *parent);
35
36 private:
37 KPushButtonFrame *q_ptr;
38 KPushButton *m_pPushButton;
39 KLabel *m_pSettingName;
40 QHBoxLayout *m_pMainLayout;
41 };
42
43 KPushButtonFramePrivate::KPushButtonFramePrivate(KPushButtonFrame *parent)
44 : q_ptr(parent)
45 {
46 Q_Q(KPushButtonFrame);
47 setParent(parent);
48 m_pMainLayout = new QHBoxLayout(q);
49 m_pMainLayout->setContentsMargins(16, 0, 16, 0);
50 m_pMainLayout->setSpacing(16);
51
52 m_pSettingName = new KLabel(q);
53
54 m_pPushButton = new KPushButton();
55 m_pPushButton->setFixedWidth(100);
56
57 m_pMainLayout->addWidget(m_pSettingName);
58 m_pMainLayout->addStretch();
59 m_pMainLayout->addWidget(m_pPushButton);
60 q->setLayout(m_pMainLayout);
61 }
62
63 KPushButtonFrame::KPushButtonFrame(const QString title, QWidget *parent, BorderRadiusStyle style)
64 : KBaseFrame(parent, style, true)
65 , d_ptr(new KPushButtonFramePrivate(this))
66 {
67 Q_D(KPushButtonFrame);
68 setObjectName("KPushButtonFrame");
69
70 d->m_pSettingName->setText(title);
71 }
72
73 KPushButtonFrame::~KPushButtonFrame()
74 {
75 }
76
77 KPushButton *KPushButtonFrame::pushButton()
78 {
79 Q_D(KPushButtonFrame);
80 return d->m_pPushButton;
81 }
82
83 QHBoxLayout *KPushButtonFrame::mainHLayout()
84 {
85 Q_D(KPushButtonFrame);
86 return d->m_pMainLayout;
87 }
88
89 KLabel *KPushButtonFrame::titleLabel()
90 {
91 Q_D(KPushButtonFrame);
92 return d->m_pSettingName;
93 }
94
95 }
96
97 #include "kpushbuttonframe.moc"
98 #include "moc_kpushbuttonframe.cpp"