Okular

textdocumentsettings.cpp
1/*
2 SPDX-FileCopyrightText: 2013 Azat Khuzhin <a3at.mail@gmail.com>
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
14using 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
38TextDocumentSettingsWidget::~TextDocumentSettingsWidget()
39{
41
42 delete d->mUi;
43 delete d;
44}
45
46void TextDocumentSettingsWidget::addRow(const QString &labelText, QWidget *widget)
47{
49
50 d->mUi->formLayout->addRow(labelText, widget);
51}
52
53/**
54 * TextDocumentSettings
55 */
56
57TextDocumentSettings::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
66QFont TextDocumentSettings::font() const
67{
69 return d->mFont;
70}
Here is example of how you can add custom settings per-backend:
TextDocumentSettingsWidget(QWidget *parent=nullptr)
TextDocumentSettingsWidget.
QString i18n(const char *text, const TYPE &arg...)
global.h
Definition action.h:17
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:35 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.