diff options
-rw-r--r-- | src/application.cpp | 38 | ||||
-rw-r--r-- | src/rekonq.kcfg | 28 | ||||
-rw-r--r-- | src/settings/appearancewidget.cpp | 74 | ||||
-rw-r--r-- | src/settings/appearancewidget.h | 12 | ||||
-rw-r--r-- | src/settings/settings_appearance.ui | 300 |
5 files changed, 285 insertions, 167 deletions
diff --git a/src/application.cpp b/src/application.cpp index e849afc1..fb52dc51 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -433,30 +433,26 @@ void Application::updateConfiguration() QWebSettings *defaultSettings = QWebSettings::globalSettings(); - // =========== Fonts ============== - QFont standardFont = ReKonfig::standardFont(); - defaultSettings->setFontFamily(QWebSettings::StandardFont, standardFont.family()); - defaultSettings->setFontSize(QWebSettings::DefaultFontSize, standardFont.pointSize()); - - QFont fixedFont = ReKonfig::fixedFont(); - defaultSettings->setFontFamily(QWebSettings::FixedFont, fixedFont.family()); - defaultSettings->setFontSize(QWebSettings::DefaultFixedFontSize, fixedFont.pointSize()); - - QFont serifFont = ReKonfig::serifFont(); - defaultSettings->setFontFamily(QWebSettings::SerifFont, serifFont.family()); - - QFont sansSerifFont = ReKonfig::sansSerifFont(); - defaultSettings->setFontFamily(QWebSettings::SansSerifFont, sansSerifFont.family()); - - QFont cursiveFont = ReKonfig::cursiveFont(); - defaultSettings->setFontFamily(QWebSettings::CursiveFont, cursiveFont.family()); + // =========== Fonts ============== + defaultSettings->setFontFamily(QWebSettings::StandardFont, ReKonfig::standardFontFamily() ); + defaultSettings->setFontFamily(QWebSettings::FixedFont, ReKonfig::fixedFontFamily() ); + defaultSettings->setFontFamily(QWebSettings::SerifFont, ReKonfig::serifFontFamily() ); + defaultSettings->setFontFamily(QWebSettings::SansSerifFont, ReKonfig::sansSerifFontFamily() ); + defaultSettings->setFontFamily(QWebSettings::CursiveFont, ReKonfig::cursiveFontFamily()); + defaultSettings->setFontFamily(QWebSettings::FantasyFont, ReKonfig::fantasyFontFamily()); + + // compute font size + // (I have to admit I know nothing about these DPI questions..: copied from kwebkitpart, as someone suggested) + // font size in pixels = font size in inches × screen dpi + int defaultFontSize = ReKonfig::defaultFontSize(); + int minimumFontSize = ReKonfig::minFontSize(); - QFont fantasyFont = ReKonfig::fantasyFont(); - defaultSettings->setFontFamily(QWebSettings::FantasyFont, fantasyFont.family()); + float toPix = mainWindow()->currentTab()->view()->logicalDpiY()/72.0; - int minimumFontSize = ReKonfig::minFontSize(); - defaultSettings->setFontSize(QWebSettings::MinimumFontSize, minimumFontSize); + defaultSettings->setFontSize(QWebSettings::DefaultFontSize, qRound(defaultFontSize * toPix) ); + defaultSettings->setFontSize(QWebSettings::MinimumFontSize, qRound(minimumFontSize * toPix) ); + // ================ WebKit ============================ defaultSettings->setAttribute(QWebSettings::AutoLoadImages, ReKonfig::autoLoadImages()); defaultSettings->setAttribute(QWebSettings::DnsPrefetchEnabled, ReKonfig::dnsPrefetch()); diff --git a/src/rekonq.kcfg b/src/rekonq.kcfg index 5800121b..b934c6d5 100644 --- a/src/rekonq.kcfg +++ b/src/rekonq.kcfg @@ -9,6 +9,7 @@ <include>QtWebKit</include> <include>QDateTime</include> <include>KUrl</include> +<include>KGlobalSettings</include> <kcfgfile name="rekonqrc" /> @@ -100,23 +101,26 @@ <!-- Fonts Settings --> <group name="Fonts"> - <entry name="standardFont" type="Font"> - <default code="true">QFont(QWebSettings::globalSettings()->fontFamily(QWebSettings::StandardFont))</default> + <entry name="standardFontFamily" type="String"> + <default code="true">KGlobalSettings::generalFont().family()</default> </entry> - <entry name="fixedFont" type="Font"> - <default code="true">QFont(QWebSettings::globalSettings()->fontFamily(QWebSettings::FixedFont))</default> + <entry name="fixedFontFamily" type="String"> + <default code="true">KGlobalSettings::fixedFont().family()</default> </entry> - <entry name="serifFont" type="Font"> - <default code="true">QFont(QWebSettings::globalSettings()->fontFamily(QWebSettings::SerifFont))</default> + <entry name="serifFontFamily" type="String"> + <default code="true">QWebSettings::globalSettings()->fontFamily(QWebSettings::SerifFont)</default> </entry> - <entry name="sansSerifFont" type="Font"> - <default code="true">QFont(QWebSettings::globalSettings()->fontFamily(QWebSettings::SansSerifFont))</default> + <entry name="sansSerifFontFamily" type="String"> + <default code="true">QWebSettings::globalSettings()->fontFamily(QWebSettings::SansSerifFont)</default> </entry> - <entry name="cursiveFont" type="Font"> - <default code="true">QFont(QWebSettings::globalSettings()->fontFamily(QWebSettings::CursiveFont))</default> + <entry name="cursiveFontFamily" type="String"> + <default code="true">QWebSettings::globalSettings()->fontFamily(QWebSettings::CursiveFont)</default> </entry> - <entry name="fantasyFont" type="Font"> - <default code="true">QFont(QWebSettings::globalSettings()->fontFamily(QWebSettings::FantasyFont))</default> + <entry name="fantasyFontFamily" type="String"> + <default code="true">QWebSettings::globalSettings()->fontFamily(QWebSettings::FantasyFont)</default> + </entry> + <entry name="defaultFontSize" type="Int"> + <default>16</default> </entry> <entry name="minFontSize" type="Int"> <default>8</default> diff --git a/src/settings/appearancewidget.cpp b/src/settings/appearancewidget.cpp index 40f53a85..20793d0a 100644 --- a/src/settings/appearancewidget.cpp +++ b/src/settings/appearancewidget.cpp @@ -28,8 +28,8 @@ #include "appearancewidget.h" #include "appearancewidget.moc" -// KDE Includes -#include <KFontRequester> +// Auto Includes +#include "rekonq.h" AppearanceWidget::AppearanceWidget(QWidget *parent) @@ -37,16 +37,33 @@ AppearanceWidget::AppearanceWidget(QWidget *parent) , _changed(false) { setupUi(this); - - KFontRequester *fixedFontRequester = new KFontRequester(this, true); - fixedFontRequester->setObjectName( QL1S("kcfg_fixedFont") ); - - gridLayout->addWidget(fixedFontRequester, 1, 1, 1, 1); + + fixedFontChooser->setOnlyFixed(true); + + standardFontChooser->setCurrentFont( QFont( ReKonfig::standardFontFamily() ) ); + fixedFontChooser->setCurrentFont( QFont( ReKonfig::fixedFontFamily() ) ); + serifFontChooser->setCurrentFont( QFont( ReKonfig::serifFontFamily() ) ); + sansSerifFontChooser->setCurrentFont( QFont( ReKonfig::sansSerifFontFamily() ) ); + cursiveFontChooser->setCurrentFont( QFont( ReKonfig::cursiveFontFamily() ) ); + fantasyFontChooser->setCurrentFont( QFont( ReKonfig::fantasyFontFamily() ) ); + + connect(standardFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(slotStandardFont(const QFont &))); + connect(fixedFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(slotFixedFont(const QFont &))); + connect(serifFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(slotSerifFont(const QFont &))); + connect(sansSerifFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(slotSansSerifFont(const QFont &))); + connect(cursiveFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(slotCursiveFont(const QFont &))); + connect(fantasyFontChooser, SIGNAL(currentFontChanged(const QFont &)), this, SLOT(slotFantasyFont(const QFont &))); } void AppearanceWidget::save() { + ReKonfig::setStandardFontFamily(reFont[0]); + ReKonfig::setFixedFontFamily(reFont[1]); + ReKonfig::setSerifFontFamily(reFont[2]); + ReKonfig::setSansSerifFontFamily(reFont[3]); + ReKonfig::setCursiveFontFamily(reFont[4]); + ReKonfig::setFantasyFontFamily(reFont[5]); } @@ -58,4 +75,47 @@ bool AppearanceWidget::changed() void AppearanceWidget::hasChanged() { + _changed = true; +} + + +void AppearanceWidget::slotStandardFont(const QFont &f) +{ + reFont[0] = f.family(); + hasChanged(); +} + + +void AppearanceWidget::slotFixedFont(const QFont &f) +{ + reFont[1] = f.family(); + hasChanged(); +} + + +void AppearanceWidget::slotSerifFont(const QFont &f) +{ + reFont[2] = f.family(); + hasChanged(); +} + + +void AppearanceWidget::slotSansSerifFont(const QFont &f) +{ + reFont[3] = f.family(); + hasChanged(); +} + + +void AppearanceWidget::slotCursiveFont(const QFont &f) +{ + reFont[4] = f.family(); + hasChanged(); +} + + +void AppearanceWidget::slotFantasyFont(const QFont &f) +{ + reFont[5] = f.family(); + hasChanged(); } diff --git a/src/settings/appearancewidget.h b/src/settings/appearancewidget.h index 5c7ddc6d..ea3de6a1 100644 --- a/src/settings/appearancewidget.h +++ b/src/settings/appearancewidget.h @@ -53,9 +53,19 @@ signals: private slots: void hasChanged(); - + + void slotStandardFont(const QFont &); + void slotFixedFont(const QFont &); + void slotSerifFont(const QFont &); + void slotSansSerifFont(const QFont &); + void slotCursiveFont(const QFont &); + void slotFantasyFont(const QFont &); + private: bool _changed; + + QString reFont[6]; + }; #endif // APPEARANCE_WIDGET_H diff --git a/src/settings/settings_appearance.ui b/src/settings/settings_appearance.ui index e0da6970..7ec23484 100644 --- a/src/settings/settings_appearance.ui +++ b/src/settings/settings_appearance.ui @@ -6,143 +6,186 @@ <rect> <x>0</x> <y>0</y> - <width>529</width> - <height>429</height> + <width>351</width> + <height>455</height> </rect> </property> <property name="windowTitle"> <string>Appearance</string> </property> - <layout class="QVBoxLayout" name="verticalLayout_2"> + <layout class="QVBoxLayout" name="verticalLayout_3"> <item> <widget class="QGroupBox" name="groupBox"> <property name="title"> <string>Fonts</string> </property> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0"> - <widget class="QLabel" name="label"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>150</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>Standard font:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="KFontRequester" name="kcfg_standardFont"/> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="label_2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>150</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>Fixed font:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="6" column="0"> - <widget class="QLabel" name="label_4"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>150</width> - <height>0</height> - </size> - </property> - <property name="text"> - <string>Minimal font size:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="6" column="1"> - <widget class="KIntNumInput" name="kcfg_minFontSize"/> - </item> - <item row="2" column="1"> - <widget class="KFontRequester" name="kcfg_serifFont"/> - </item> - <item row="3" column="1"> - <widget class="KFontRequester" name="kcfg_sansSerifFont"/> - </item> - <item row="4" column="1"> - <widget class="KFontRequester" name="kcfg_cursiveFont"/> - </item> - <item row="5" column="1"> - <widget class="KFontRequester" name="kcfg_fantasyFont"/> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="label_3"> - <property name="text"> - <string>Serif font:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QLabel" name="label_6"> - <property name="text"> - <string>Sans Serif font:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Standard font:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="KFontComboBox" name="standardFontChooser"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Fixed font:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="KFontComboBox" name="fixedFontChooser"/> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Serif font:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="KFontComboBox" name="serifFontChooser"/> + </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_6"> + <property name="text"> + <string>Sans Serif font:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="KFontComboBox" name="sansSerifFontChooser"/> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="label_7"> + <property name="text"> + <string>Cursive font:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="KFontComboBox" name="cursiveFontChooser"/> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="label_8"> + <property name="text"> + <string>Fantasy font:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="KFontComboBox" name="fantasyFontChooser"/> + </item> + </layout> </item> - <item row="4" column="0"> - <widget class="QLabel" name="label_7"> - <property name="text"> - <string>Cursive font:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + <item> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> </property> </widget> </item> - <item row="5" column="0"> - <widget class="QLabel" name="label_8"> - <property name="text"> - <string>Fantasy font:</string> - </property> - <property name="alignment"> - <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> - </property> - </widget> + <item> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="0"> + <widget class="QLabel" name="label_9"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Default font size:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="KIntNumInput" name="kcfg_defaultFontSize"/> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_4"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>150</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Minimal font size:</string> + </property> + <property name="alignment"> + <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="KIntNumInput" name="kcfg_minFontSize"/> + </item> + </layout> </item> </layout> </widget> @@ -223,9 +266,14 @@ <header>kurlrequester.h</header> </customwidget> <customwidget> - <class>KFontRequester</class> - <extends>QWidget</extends> - <header>kfontrequester.h</header> + <class>KFontComboBox</class> + <extends>KComboBox</extends> + <header>kfontcombobox.h</header> + </customwidget> + <customwidget> + <class>KComboBox</class> + <extends>QComboBox</extends> + <header>kcombobox.h</header> </customwidget> <customwidget> <class>KIntNumInput</class> |