Debian Codegraph @

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