Okular

textdocumentsettings.cpp
1 /*
2  SPDX-FileCopyrightText: 2013 Azat Khuzhin <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #include "textdocumentsettings.h"
8 #include "textdocumentsettings_p.h"
9 #include "ui_textdocumentsettings.h"
10 
11 #include <KFontRequester>
12 #include <KLocalizedString>
13 
14 using namespace Okular;
15 
16 /**
17  * TextDocumentSettingsWidget
18  */
19 
21  : QWidget(parent)
22  , d_ptr(new TextDocumentSettingsWidgetPrivate(new Ui_TextDocumentSettings()))
23 {
25 
26  d->mUi->setupUi(this);
27 
28  // @notice I think this will be useful in future.
29 #define ADD_WIDGET(property, widget, objectName, labelName) \
30  d->property = new widget(this); \
31  d->property->setObjectName(QString::fromUtf8(objectName)); \
32  addRow(labelName, d->property);
33 
34  ADD_WIDGET(mFont, KFontRequester, "kcfg_Font", i18n("&Default Font:"));
35 #undef ADD_WIDGET
36 }
37 
38 TextDocumentSettingsWidget::~TextDocumentSettingsWidget()
39 {
41 
42  delete d->mUi;
43  delete d;
44 }
45 
46 void TextDocumentSettingsWidget::addRow(const QString &labelText, QWidget *widget)
47 {
49 
50  d->mUi->formLayout->addRow(labelText, widget);
51 }
52 
53 /**
54  * TextDocumentSettings
55  */
56 
57 TextDocumentSettings::TextDocumentSettings(const QString &config, QObject *parent)
58  : KConfigSkeleton(config, parent)
59  , d_ptr(new TextDocumentSettingsPrivate(this))
60 {
62 
63  addItemFont(QStringLiteral("Font"), d->mFont);
64 }
65 
66 QFont TextDocumentSettings::font() const
67 {
68  Q_D(const TextDocumentSettings);
69  return d->mFont;
70 }
Here is example of how you can add custom settings per-backend:
global.h
Definition: action.h:16
TextDocumentSettingsWidget(QWidget *parent=nullptr)
TextDocumentSettingsWidget.
QString i18n(const char *text, const TYPE &arg...)
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Dec 6 2021 22:32:18 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.