Okular

textdocumentsettings.cpp
1 /***************************************************************************
2  * Copyright (C) 2013 by Azat Khuzhin <[email protected]> *
3  * *
4  * This program is free software; you can redistribute it and/or modify *
5  * it under the terms of the GNU General Public License as published by *
6  * the Free Software Foundation; either version 2 of the License, or *
7  * (at your option) any later version. *
8  ***************************************************************************/
9 
10 
11 #include "textdocumentsettings.h"
12 #include "textdocumentsettings_p.h"
13 #include "ui_textdocumentsettings.h"
14 
15 #include <KFontRequester>
16 #include <KLocalizedString>
17 
18 
19 
20 using namespace Okular;
21 
27  : QWidget( parent )
28  , d_ptr( new TextDocumentSettingsWidgetPrivate( new Ui_TextDocumentSettings() ) )
29 {
31 
32  d->mUi->setupUi( this );
33 
34  // @notice I think this will be useful in future.
35 #define ADD_WIDGET( property, widget, objectName, labelName ) \
36  d->property = new widget( this ); \
37  d->property->setObjectName( QString::fromUtf8( objectName ) ); \
38  addRow( labelName, d->property );
39 
40  ADD_WIDGET( mFont, KFontRequester, "kcfg_Font", i18n("&Default Font:") );
41 #undef ADD_WIDGET
42 }
43 
44 TextDocumentSettingsWidget::~TextDocumentSettingsWidget()
45 {
47 
48  delete d->mUi;
49  delete d;
50 }
51 
52 void TextDocumentSettingsWidget::addRow( const QString& labelText, QWidget *widget )
53 {
55 
56  d->mUi->formLayout->addRow( labelText, widget );
57 }
58 
59 
64 TextDocumentSettings::TextDocumentSettings( const QString& config, QObject *parent )
65  : KConfigSkeleton( config, parent )
66  , d_ptr( new TextDocumentSettingsPrivate(this) )
67 {
68  Q_D( TextDocumentSettings );
69 
70  addItemFont( QStringLiteral("Font"), d->mFont );
71 }
72 
73 QFont TextDocumentSettings::font() const
74 {
75  Q_D( const TextDocumentSettings );
76  return d->mFont;
77 }
Here is example of how you can add custom settings per-backend:
global.h
Definition: action.h:19
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-2020 The KDE developers.
Generated on Thu Jul 9 2020 22:35:31 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.