File indexing completed on 2024-04-28 04:32:46
0001 /* 0002 SPDX-FileCopyrightText: 2013 Azat Khuzhin <a3at.mail@gmail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef _OKULAR_TEXTDOCUMENTSETTINGS_H_ 0008 #define _OKULAR_TEXTDOCUMENTSETTINGS_H_ 0009 0010 #include "okularcore_export.h" 0011 0012 #include <KConfigSkeleton> 0013 #include <QFont> 0014 #include <QObject> 0015 #include <QWidget> 0016 0017 namespace Okular 0018 { 0019 class TextDocumentSettingsWidgetPrivate; 0020 class TextDocumentSettingsPrivate; 0021 0022 /** 0023 * Here is example of how you can add custom settings per-backend: 0024 * 0025 * In .h header: 0026 * \code 0027 * class KIntSpinBox; 0028 * ... 0029 * 0030 * class YourGenerator 0031 * { 0032 * ... 0033 * public: 0034 * bool reparseConfig(); 0035 * void addPages( KConfigDialog* dlg ); 0036 * ... 0037 * private: 0038 * QString customArgument; 0039 * KIntSpinBox *customArgumentWidget; 0040 * ... 0041 * } 0042 * \endcode 0043 * 0044 * In .cpp module: 0045 * \code 0046 * #include <KIntSpinBox> 0047 * ... 0048 * bool YourGenerator::reparseConfig() 0049 * { 0050 * ... Do something with customArgumentWidget and customArgument ... 0051 * } 0052 * void YourGenerator::addPages( KConfigDialog* dlg ) 0053 * { 0054 * Okular::TextDocumentSettingsWidget *widget = new Okular::TextDocumentSettingsWidget(); 0055 * 0056 * KIntSpinBox *customArgumentWidget = new KIntSpinBox( dlg ); 0057 * customArgumentWidget->setObjectName( QString::fromUtf8( "kcfg_CustomArgument" ) ); 0058 * widget->addRow( "Custom argument", customArgumentWidget ); 0059 * 0060 * Okular::TextDocumentSettings *settings = generalSettings(); 0061 * settings->addItemString( "CustomArgument", customArgument ); 0062 * 0063 * dlg->addPage( widget, settings, ... ); 0064 * } 0065 * \endcode 0066 */ 0067 0068 /** 0069 * TextDocumentSettingsWidget 0070 * 0071 * Contain default settings for text based documents. 0072 * (all generators that inherited from TextDocumentGenerator) 0073 * Generator can add settings to this object individually. 0074 * 0075 * @since 0.17 (KDE 4.11) 0076 */ 0077 class OKULARCORE_EXPORT TextDocumentSettingsWidget : public QWidget 0078 { 0079 Q_OBJECT 0080 0081 public: 0082 explicit TextDocumentSettingsWidget(QWidget *parent = nullptr); 0083 ~TextDocumentSettingsWidget() override; 0084 0085 void addRow(const QString &labelText, QWidget *widget); 0086 0087 private: 0088 friend class TextDocumentGenerator; 0089 0090 TextDocumentSettingsWidgetPrivate *d_ptr; 0091 Q_DECLARE_PRIVATE(TextDocumentSettingsWidget) 0092 Q_DISABLE_COPY(TextDocumentSettingsWidget) 0093 }; 0094 0095 /** 0096 * TextDocumentSettings 0097 * 0098 * Contain default settings/config skeleton 0099 * To save/restore settings. 0100 * 0101 * @since 0.17 (KDE 4.11) 0102 */ 0103 class OKULARCORE_EXPORT TextDocumentSettings : public KConfigSkeleton 0104 { 0105 Q_OBJECT 0106 0107 public: 0108 QFont font() const; 0109 0110 private: 0111 friend class TextDocumentGenerator; 0112 0113 TextDocumentSettings(const QString &config, QObject *parent); 0114 0115 TextDocumentSettingsPrivate *d_ptr; 0116 Q_DECLARE_PRIVATE(TextDocumentSettings) 0117 Q_DISABLE_COPY(TextDocumentSettings) 0118 }; 0119 0120 } 0121 0122 #endif