remotes/origin/epub-qtextdoc
commit
14703512b6
23 changed files with 494 additions and 41 deletions
@ -0,0 +1,13 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<ui version="4.0"> |
||||
<class>TextDocumentSettings</class> |
||||
<widget class="QWidget" name="TextDocumentSettings"> |
||||
<layout class="QFormLayout" name="formLayout"> |
||||
<property name="fieldGrowthPolicy"> |
||||
<enum>QFormLayout::ExpandingFieldsGrow</enum> |
||||
</property> |
||||
</layout> |
||||
</widget> |
||||
<resources/> |
||||
<connections/> |
||||
</ui> |
||||
@ -0,0 +1,84 @@ |
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 by Azat Khuzhin <a3at.mail@gmail.com> * |
||||
* * |
||||
* This program is free software; you can redistribute it and/or modify * |
||||
* it under the terms of the GNU General Public License as published by * |
||||
* the Free Software Foundation; either version 2 of the License, or * |
||||
* (at your option) any later version. * |
||||
***************************************************************************/ |
||||
|
||||
|
||||
#include "textdocumentsettings.h" |
||||
#include "textdocumentsettings_p.h" |
||||
#include "ui_textdocumentsettings.h" |
||||
|
||||
#include <KFontRequester> |
||||
#include <KLocale> |
||||
|
||||
#include <QLabel> |
||||
|
||||
|
||||
using namespace Okular; |
||||
|
||||
/**
|
||||
* TextDocumentSettingsWidget |
||||
*/ |
||||
|
||||
TextDocumentSettingsWidget::TextDocumentSettingsWidget( QWidget *parent ) |
||||
: QWidget( parent ) |
||||
, d_ptr( new TextDocumentSettingsWidgetPrivate( new Ui_TextDocumentSettings() ) ) |
||||
{ |
||||
Q_D( TextDocumentSettingsWidget ); |
||||
|
||||
d->mUi->setupUi( this ); |
||||
|
||||
// @notice I think this will be usefull in future.
|
||||
#define ADD_WIDGET( property, widget, objectName, labelName ) \ |
||||
d->property = new widget( this ); \
|
||||
d->property->setObjectName( QString::fromUtf8( objectName ) ); \
|
||||
addRow( labelName, d->property ); |
||||
|
||||
ADD_WIDGET( mFont, KFontRequester, "kcfg_Font", "&Default Font:" ); |
||||
#undef ADD_WIDGET |
||||
} |
||||
|
||||
TextDocumentSettingsWidget::~TextDocumentSettingsWidget() |
||||
{ |
||||
Q_D( TextDocumentSettingsWidget ); |
||||
|
||||
delete d->mUi; |
||||
} |
||||
|
||||
void TextDocumentSettingsWidget::addRow( const QString& labelText, QWidget *widget ) |
||||
{ |
||||
Q_D( TextDocumentSettingsWidget ); |
||||
|
||||
d->mUi->formLayout->addRow( labelText, widget ); |
||||
} |
||||
|
||||
QFont TextDocumentSettingsWidget::font() const |
||||
{ |
||||
Q_D( const TextDocumentSettingsWidget ); |
||||
|
||||
return d->mFont->font(); |
||||
} |
||||
|
||||
|
||||
/**
|
||||
* TextDocumentSettings |
||||
*/ |
||||
|
||||
TextDocumentSettings::TextDocumentSettings( const QString& config, QObject *parent ) |
||||
: KConfigSkeleton( config, parent ) |
||||
, d_ptr( new TextDocumentSettingsPrivate() ) |
||||
{ |
||||
Q_D( TextDocumentSettings ); |
||||
|
||||
addItemFont( "Font", d->mFont ); |
||||
} |
||||
|
||||
QFont TextDocumentSettings::font() const |
||||
{ |
||||
Q_D( const TextDocumentSettings ); |
||||
return d->mFont; |
||||
} |
||||
@ -0,0 +1,127 @@ |
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 by Azat Khuzhin <a3at.mail@gmail.com> * |
||||
* * |
||||
* This program is free software; you can redistribute it and/or modify * |
||||
* it under the terms of the GNU General Public License as published by * |
||||
* the Free Software Foundation; either version 2 of the License, or * |
||||
* (at your option) any later version. * |
||||
***************************************************************************/ |
||||
|
||||
|
||||
#ifndef _OKULAR_TEXTDOCUMENTSETTINGS_H_ |
||||
#define _OKULAR_TEXTDOCUMENTSETTINGS_H_ |
||||
|
||||
|
||||
#include "okular_export.h" |
||||
|
||||
#include <QFont> |
||||
#include <QWidget> |
||||
#include <QObject> |
||||
#include <KConfigSkeleton> |
||||
|
||||
namespace Okular { |
||||
|
||||
class TextDocumentSettingsWidgetPrivate; |
||||
class TextDocumentSettingsPrivate; |
||||
|
||||
/**
|
||||
* Here is example of how you can add custom settings per-backend: |
||||
* |
||||
* In .h header: |
||||
* {code} |
||||
* class KIntSpinBox; |
||||
* ... |
||||
* |
||||
* class YourGenerator |
||||
* { |
||||
* ... |
||||
* public: |
||||
* bool reparseConfig(); |
||||
* void addPages( KConfigDialog* dlg ); |
||||
* ... |
||||
* private: |
||||
* QString customArgument; |
||||
* KIntSpinBox *customArgumentWidget; |
||||
* ... |
||||
* } |
||||
* {/code} |
||||
* |
||||
* In .cpp module: |
||||
* {code} |
||||
* #include <KIntSpinBox> |
||||
* ... |
||||
* bool YourGenerator::reparseConfig() |
||||
* { |
||||
* ... Do something with customArgumentWidget and customArgument ... |
||||
* } |
||||
* void YourGenerator::addPages( KConfigDialog* dlg ) |
||||
* { |
||||
* Okular::TextDocumentSettingsWidget *widget = generalSettingsWidget(); |
||||
* widget->setParent( dlg ); |
||||
* |
||||
* KIntSpinBox *customArgumentWidget = new KIntSpinBox( dlg ); |
||||
* customArgumentWidget->setObjectName( QString::fromUtf8( "kcfg_CustomArgument" ) ); |
||||
* widget->addRow( "Custom argument", customArgumentWidget ); |
||||
* |
||||
* Okular::TextDocumentSettings *settings = generalSettings(); |
||||
* settings->addItemString( "CustomArgument", customArgument ); |
||||
* |
||||
* dlg->addPage( widget, settings, ... ); |
||||
* } |
||||
* {/code} |
||||
*/ |
||||
|
||||
/**
|
||||
* TextDocumentSettingsWidget |
||||
* |
||||
* Contain default settings for text based documents. |
||||
* (all generators that inherited from TextDocumentGenerator) |
||||
* Generator can add settings to this object individually. |
||||
* |
||||
* @since 0.17 (KDE 4.11) |
||||
*/ |
||||
class OKULAR_EXPORT TextDocumentSettingsWidget : public QWidget |
||||
{ |
||||
public: |
||||
virtual ~TextDocumentSettingsWidget(); |
||||
|
||||
void addRow( const QString& labelText, QWidget *widget ); |
||||
|
||||
QFont font() const; |
||||
|
||||
private: |
||||
friend class TextDocumentGenerator; |
||||
|
||||
TextDocumentSettingsWidget( QWidget *parent = 0 ); |
||||
|
||||
TextDocumentSettingsWidgetPrivate *d_ptr; |
||||
Q_DECLARE_PRIVATE( TextDocumentSettingsWidget ) |
||||
Q_DISABLE_COPY( TextDocumentSettingsWidget ) |
||||
}; |
||||
|
||||
/**
|
||||
* TextDocumentSettings |
||||
* |
||||
* Contain default settings/config skeleton |
||||
* To save/restore settings. |
||||
* |
||||
* @since 0.17 (KDE 4.11) |
||||
*/ |
||||
class OKULAR_EXPORT TextDocumentSettings : public KConfigSkeleton |
||||
{ |
||||
public: |
||||
QFont font() const; |
||||
|
||||
private: |
||||
friend class TextDocumentGenerator; |
||||
|
||||
TextDocumentSettings( const QString& config, QObject *parent ); |
||||
|
||||
TextDocumentSettingsPrivate *d_ptr; |
||||
Q_DECLARE_PRIVATE( TextDocumentSettings ) |
||||
Q_DISABLE_COPY( TextDocumentSettings ) |
||||
}; |
||||
|
||||
} |
||||
|
||||
#endif |
||||
@ -0,0 +1,42 @@ |
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 by Azat Khuzhin <a3at.mail@gmail.com> * |
||||
* * |
||||
* This program is free software; you can redistribute it and/or modify * |
||||
* it under the terms of the GNU General Public License as published by * |
||||
* the Free Software Foundation; either version 2 of the License, or * |
||||
* (at your option) any later version. * |
||||
***************************************************************************/ |
||||
|
||||
|
||||
#ifndef _OKULAR_TEXTDOCUMENTSETTINGS_P_H_ |
||||
#define _OKULAR_TEXTDOCUMENTSETTINGS_P_H_ |
||||
|
||||
class KFontRequester; |
||||
class Ui_TextDocumentSettings; |
||||
|
||||
namespace Okular { |
||||
|
||||
class TextDocumentSettingsWidgetPrivate |
||||
{ |
||||
public: |
||||
/**
|
||||
* @note the private class won't take ownership of the ui, so you |
||||
* must delete it yourself |
||||
*/ |
||||
TextDocumentSettingsWidgetPrivate(Ui_TextDocumentSettings *ui) |
||||
: mUi(ui) |
||||
{} |
||||
|
||||
KFontRequester *mFont; |
||||
Ui_TextDocumentSettings *mUi; |
||||
}; |
||||
|
||||
class TextDocumentSettingsPrivate |
||||
{ |
||||
public: |
||||
QFont mFont; |
||||
}; |
||||
|
||||
} |
||||
|
||||
#endif |
||||
Loading…
Reference in new issue