Fix Bug 358840 - kmail composer: menu item "send" missing
[kdepim.git] / knotes / configdialog / knotedisplayconfigwidget.cpp
blob639c3970cb9fadacdf4974930a82c2c78277b819
1 /*
2 Copyright (c) 2013-2015 Montel Laurent <montel@kde.org>
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License, version 2, as
6 published by the Free Software Foundation.
8 This program is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
13 You should have received a copy of the GNU General Public License along
14 with this program; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 #include "knotedisplayconfigwidget.h"
19 #include "config-kdepim.h"
21 #include "NoteShared/NoteDisplayAttribute"
23 #include <KLocalizedString>
24 #include <KColorButton>
25 #include <QSpinBox>
27 #include <QGridLayout>
28 #include <QLabel>
29 #include <QCheckBox>
31 KNoteDisplayConfigWidget::KNoteDisplayConfigWidget(bool defaults, QWidget *parent)
32 : QWidget(parent),
33 kcfg_FgColor(0),
34 kcfg_BgColor(0),
35 kcfg_ShowInTaskbar(0),
36 kcfg_RememberDesktop(0),
37 kcfg_Width(0),
38 kcfg_Height(0)
40 QGridLayout *layout = new QGridLayout(this);
41 if (!defaults) {
42 layout->setMargin(0);
45 QLabel *label_FgColor = new QLabel(i18n("&Text color:"), this);
46 label_FgColor->setObjectName(QStringLiteral("label_FgColor"));
47 layout->addWidget(label_FgColor, 0, 0);
49 kcfg_FgColor = new KColorButton(this);
50 kcfg_FgColor->setObjectName(QStringLiteral("kcfg_FgColor"));
51 label_FgColor->setBuddy(kcfg_FgColor);
52 layout->addWidget(kcfg_FgColor, 0, 1);
54 QLabel *label_BgColor = new QLabel(i18n("&Background color:"),
55 this);
56 label_BgColor->setObjectName(QStringLiteral("label_BgColor"));
57 layout->addWidget(label_BgColor, 1, 0);
59 kcfg_BgColor = new KColorButton(this);
60 kcfg_BgColor->setObjectName(QStringLiteral("kcfg_BgColor"));
61 label_BgColor->setBuddy(kcfg_BgColor);
62 layout->addWidget(kcfg_BgColor, 1, 1);
64 kcfg_ShowInTaskbar =
65 new QCheckBox(i18n("&Show note in taskbar"), this);
66 kcfg_ShowInTaskbar->setObjectName(QStringLiteral("kcfg_ShowInTaskbar"));
67 #if KDEPIM_HAVE_X11
68 kcfg_RememberDesktop =
69 new QCheckBox(i18n("&Remember desktop"), this);
70 kcfg_RememberDesktop->setObjectName(QStringLiteral("kcfg_RememberDesktop"));
71 #endif
72 if (defaults) {
73 QLabel *label_Width = new QLabel(i18n("Default &width:"), this);
75 layout->addWidget(label_Width, 2, 0);
77 kcfg_Width = new QSpinBox(this);
78 kcfg_Width->setObjectName(QStringLiteral("kcfg_Width"));
79 label_Width->setBuddy(kcfg_Width);
80 kcfg_Width->setRange(50, 2000);
81 kcfg_Width->setSingleStep(10);
82 layout->addWidget(kcfg_Width, 2, 1);
84 QLabel *label_Height = new QLabel(i18n("Default &height:"),
85 this);
86 layout->addWidget(label_Height, 3, 0);
88 kcfg_Height = new QSpinBox(this);
89 kcfg_Height->setObjectName(QStringLiteral("kcfg_Height"));
90 kcfg_Height->setRange(50, 2000);
91 kcfg_Height->setSingleStep(10);
92 label_Height->setBuddy(kcfg_Height);
93 layout->addWidget(kcfg_Height, 3, 1);
95 layout->addWidget(kcfg_ShowInTaskbar, 4, 0);
96 #if KDEPIM_HAVE_X11
97 layout->addWidget(kcfg_RememberDesktop, 5, 0);
98 #endif
99 } else {
100 layout->addWidget(kcfg_ShowInTaskbar, 2, 0);
101 #if KDEPIM_HAVE_X11
102 layout->addWidget(kcfg_RememberDesktop, 3, 0);
103 #endif
105 layout->setRowStretch(4, 1);
108 KNoteDisplayConfigWidget::~KNoteDisplayConfigWidget()
113 void KNoteDisplayConfigWidget::load(NoteShared::NoteDisplayAttribute *attr)
115 if (attr) {
116 kcfg_FgColor->setColor(attr->foregroundColor());
117 kcfg_BgColor->setColor(attr->backgroundColor());
118 kcfg_ShowInTaskbar->setChecked(attr->showInTaskbar());
119 if (kcfg_RememberDesktop) {
120 kcfg_RememberDesktop->setChecked(attr->rememberDesktop());
122 if (kcfg_Height) {
123 kcfg_Height->setValue(attr->size().height());
125 if (kcfg_Width) {
126 kcfg_Width->setValue(attr->size().width());
131 void KNoteDisplayConfigWidget::save(NoteShared::NoteDisplayAttribute *attr)
133 if (attr) {
134 attr->setForegroundColor(kcfg_FgColor->color());
135 attr->setBackgroundColor(kcfg_BgColor->color());
136 attr->setShowInTaskbar(kcfg_ShowInTaskbar->isChecked());
137 if (kcfg_RememberDesktop) {
138 attr->setRememberDesktop(kcfg_RememberDesktop->isChecked());
140 if (kcfg_Height && kcfg_Width) {
141 attr->setSize(QSize(kcfg_Width->value(), kcfg_Height->value()));