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 {
69  return d->mFont;
70 }
The documentation to the global Okular namespace.
Definition: action.h:16
Here is example of how you can add custom settings per-backend:
QString i18n(const char *text, const TYPE &arg...)
KSharedConfigPtr config()
TextDocumentSettingsWidget(QWidget *parent=nullptr)
TextDocumentSettingsWidget.
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Mar 23 2023 04:04:24 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.