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>
27 #include <QGridLayout>
31 KNoteDisplayConfigWidget::KNoteDisplayConfigWidget(bool defaults
, QWidget
*parent
)
35 kcfg_ShowInTaskbar(0),
36 kcfg_RememberDesktop(0),
40 QGridLayout
*layout
= new QGridLayout(this);
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:"),
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);
65 new QCheckBox(i18n("&Show note in taskbar"), this);
66 kcfg_ShowInTaskbar
->setObjectName(QStringLiteral("kcfg_ShowInTaskbar"));
68 kcfg_RememberDesktop
=
69 new QCheckBox(i18n("&Remember desktop"), this);
70 kcfg_RememberDesktop
->setObjectName(QStringLiteral("kcfg_RememberDesktop"));
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:"),
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);
97 layout
->addWidget(kcfg_RememberDesktop
, 5, 0);
100 layout
->addWidget(kcfg_ShowInTaskbar
, 2, 0);
102 layout
->addWidget(kcfg_RememberDesktop
, 3, 0);
105 layout
->setRowStretch(4, 1);
108 KNoteDisplayConfigWidget::~KNoteDisplayConfigWidget()
113 void KNoteDisplayConfigWidget::load(NoteShared::NoteDisplayAttribute
*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());
123 kcfg_Height
->setValue(attr
->size().height());
126 kcfg_Width
->setValue(attr
->size().width());
131 void KNoteDisplayConfigWidget::save(NoteShared::NoteDisplayAttribute
*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()));