• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

knotes

  • sources
  • kde-4.14
  • kdepim
  • knotes
  • configdialog
knoteeditorconfigwidget.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2013-2015 Montel Laurent <montel@kde.org>
3 
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.
7 
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.
12 
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
16 */
17 
18 
19 #include "knoteeditorconfigwidget.h"
20 
21 #include "noteshared/attributes/notedisplayattribute.h"
22 
23 #include <KIntNumInput>
24 #include <KLocalizedString>
25 #include <KFontRequester>
26 #include <KDialog>
27 
28 #include <QGridLayout>
29 #include <QLabel>
30 #include <QCheckBox>
31 
32 KNoteEditorConfigWidget::KNoteEditorConfigWidget( bool defaults, QWidget *parent )
33  : QWidget( parent )
34 {
35  QGridLayout *layout = new QGridLayout( this );
36  layout->setSpacing( KDialog::spacingHint() );
37  layout->setMargin( defaults ? KDialog::marginHint() : 0 );
38 
39  QLabel *label_TabSize = new QLabel( i18n( "&Tab size:" ), this );
40  layout->addWidget( label_TabSize, 0, 0, 1, 2 );
41 
42  kcfg_TabSize = new KIntNumInput( this );
43  kcfg_TabSize->setObjectName( QLatin1String("kcfg_TabSize") );
44  kcfg_TabSize->setRange( 1, 40 );
45  kcfg_TabSize->setSliderEnabled( false );
46  label_TabSize->setBuddy( kcfg_TabSize );
47  layout->addWidget( kcfg_TabSize, 0, 2 );
48 
49  kcfg_AutoIndent = new QCheckBox( i18n( "Auto &indent" ),
50  this );
51  kcfg_AutoIndent->setObjectName( QLatin1String("kcfg_AutoIndent") );
52  layout->addWidget( kcfg_AutoIndent, 1, 0, 1, 2 );
53 
54  kcfg_RichText = new QCheckBox( i18n( "&Rich text" ), this );
55  kcfg_RichText->setObjectName( QLatin1String("kcfg_RichText") );
56  layout->addWidget( kcfg_RichText, 1, 2 );
57 
58  QLabel *label_Font = new QLabel( i18n( "Text font:" ), this );
59  layout->addWidget( label_Font, 3, 0 );
60 
61  kcfg_Font = new KFontRequester( this );
62  kcfg_Font->setObjectName( QLatin1String("kcfg_Font") );
63  kcfg_Font->setSizePolicy( QSizePolicy( QSizePolicy::Minimum,
64  QSizePolicy::Fixed ) );
65  layout->addWidget( kcfg_Font, 3, 1, 1, 2 );
66 
67  QLabel *label_TitleFont = new QLabel( i18n( "Title font:" ), this );
68  layout->addWidget( label_TitleFont, 2, 0 );
69 
70  kcfg_TitleFont = new KFontRequester( this );
71  kcfg_TitleFont->setObjectName( QLatin1String("kcfg_TitleFont") );
72  kcfg_TitleFont->setSizePolicy( QSizePolicy( QSizePolicy::Minimum,
73  QSizePolicy::Fixed ) );
74  layout->addWidget( kcfg_TitleFont, 2, 1, 1, 2 );
75  layout->setRowStretch(4,1);
76 }
77 
78 KNoteEditorConfigWidget::~KNoteEditorConfigWidget()
79 {
80 
81 }
82 
83 void KNoteEditorConfigWidget::load(NoteShared::NoteDisplayAttribute *attr, bool isRichText)
84 {
85  if (attr) {
86  kcfg_TabSize->setValue(attr->tabSize());
87  kcfg_AutoIndent->setChecked(attr->autoIndent());
88  kcfg_RichText->setChecked(isRichText);
89  kcfg_Font->setFont(attr->font());
90  kcfg_TitleFont->setFont(attr->titleFont());
91  }
92 }
93 
94 void KNoteEditorConfigWidget::save(NoteShared::NoteDisplayAttribute *attr, bool &isRichText)
95 {
96  if (attr) {
97  attr->setTabSize(kcfg_TabSize->value());
98  attr->setAutoIndent(kcfg_AutoIndent->isChecked());
99  isRichText = kcfg_RichText->isChecked();
100  attr->setFont(kcfg_Font->font());
101  attr->setTitleFont(kcfg_TitleFont->font());
102  }
103 }
QWidget::layout
QLayout * layout() const
QWidget
QGridLayout::addWidget
void addWidget(QWidget *widget, int row, int column, QFlags< Qt::AlignmentFlag > alignment)
QSizePolicy
QGridLayout
QGridLayout::setSpacing
void setSpacing(int spacing)
QLabel::setBuddy
void setBuddy(QWidget *buddy)
KNoteEditorConfigWidget::~KNoteEditorConfigWidget
~KNoteEditorConfigWidget()
Definition: knoteeditorconfigwidget.cpp:78
QGridLayout::setRowStretch
void setRowStretch(int row, int stretch)
KNoteEditorConfigWidget::save
void save(NoteShared::NoteDisplayAttribute *attr, bool &isRichText)
Definition: knoteeditorconfigwidget.cpp:94
knoteeditorconfigwidget.h
QCheckBox
QObject::setObjectName
void setObjectName(const QString &name)
QLayout::setMargin
void setMargin(int margin)
QAbstractButton::setChecked
void setChecked(bool)
KNoteEditorConfigWidget::load
void load(NoteShared::NoteDisplayAttribute *attr, bool isRichText)
Definition: knoteeditorconfigwidget.cpp:83
QLatin1String
KNoteEditorConfigWidget::KNoteEditorConfigWidget
KNoteEditorConfigWidget(bool defaults, QWidget *parent=0)
Definition: knoteeditorconfigwidget.cpp:32
QLabel
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:28 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

knotes

Skip menu "knotes"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal