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 | ||||
-rw-r--r-- | src/tabbar.cpp | 5 | ||||
-rw-r--r-- | src/urlbar/completionwidget.cpp | 6 | ||||
-rw-r--r-- | src/urlbar/completionwidget.h | 2 | ||||
-rw-r--r-- | src/urlbar/listitem.cpp | 2 | ||||
-rw-r--r-- | src/urlbar/listitem.h | 2 | ||||
-rw-r--r-- | src/webpage.cpp | 3 |
11 files changed, 299 insertions, 173 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> diff --git a/src/tabbar.cpp b/src/tabbar.cpp index 1274d813..5d6b7b2c 100644 --- a/src/tabbar.cpp +++ b/src/tabbar.cpp @@ -186,6 +186,11 @@ void TabBar::showTabPreview(int tab) void TabBar::mouseMoveEvent(QMouseEvent *event) { + if (count() == 1) + { + return; + } + if (event->buttons() & Qt::LeftButton) { // hide addNewTabButton when moving tabs diff --git a/src/urlbar/completionwidget.cpp b/src/urlbar/completionwidget.cpp index 9a5c9432..af9bdc45 100644 --- a/src/urlbar/completionwidget.cpp +++ b/src/urlbar/completionwidget.cpp @@ -74,7 +74,7 @@ void CompletionWidget::insertSearchList(const UrlSearchList &list, const QString { ListItem *suggestion = ListItemFactory::create(item, text, this); suggestion->setBackgroundRole(i % 2 ? QPalette::AlternateBase : QPalette::Base); - connect(suggestion, SIGNAL(itemClicked(ListItem *, Qt::MouseButton)), this, SLOT(itemChosen(ListItem *, Qt::MouseButton))); + connect(suggestion, SIGNAL(itemClicked(ListItem *, Qt::MouseButton, Qt::KeyboardModifiers)), this, SLOT(itemChosen(ListItem *, Qt::MouseButton, Qt::KeyboardModifiers))); connect(this, SIGNAL(nextItemSubChoice()), suggestion, SLOT(nextItemSubChoice())); suggestion->setObjectName(QString::number(i++)); layout()->addWidget(suggestion); @@ -265,9 +265,9 @@ void CompletionWidget::setVisible(bool visible) } -void CompletionWidget::itemChosen(ListItem *item, Qt::MouseButton button) +void CompletionWidget::itemChosen(ListItem *item, Qt::MouseButton button, Qt::KeyboardModifiers modifier) { - if (button == Qt::MidButton) + if (button == Qt::MidButton || modifier == Qt::ControlModifier) emit chosenUrl(item->url(), Rekonq::NewCurrentTab); else emit chosenUrl(item->url(), Rekonq::CurrentTab); diff --git a/src/urlbar/completionwidget.h b/src/urlbar/completionwidget.h index 2d33b59f..423499fe 100644 --- a/src/urlbar/completionwidget.h +++ b/src/urlbar/completionwidget.h @@ -64,7 +64,7 @@ public: void suggestUrls(const QString &text); private slots: - void itemChosen(ListItem *item, Qt::MouseButton = Qt::LeftButton); + void itemChosen(ListItem *item, Qt::MouseButton = Qt::LeftButton, Qt::KeyboardModifiers = Qt::NoModifier); signals: void chosenUrl(const KUrl &, Rekonq::OpenType); diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp index 5254c7dc..3114c16a 100644 --- a/src/urlbar/listitem.cpp +++ b/src/urlbar/listitem.cpp @@ -129,7 +129,7 @@ void ListItem::leaveEvent(QEvent *e) void ListItem::mousePressEvent(QMouseEvent *e) { - emit itemClicked(this, e->button()); + emit itemClicked(this, e->button(), e->modifiers()); QWidget::mousePressEvent(e); } diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h index c26a1893..dcb4f76d 100644 --- a/src/urlbar/listitem.h +++ b/src/urlbar/listitem.h @@ -66,7 +66,7 @@ public slots: virtual void nextItemSubChoice(); signals: - void itemClicked(ListItem *item, Qt::MouseButton); + void itemClicked(ListItem *item, Qt::MouseButton, Qt::KeyboardModifiers); protected: virtual void paintEvent(QPaintEvent *event); diff --git a/src/webpage.cpp b/src/webpage.cpp index 45059def..4a8c8b6b 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -113,6 +113,9 @@ static bool downloadResource (const KUrl& srcUrl, const KIO::MetaData& metaData do { destUrl = KFileDialog::getSaveFileName(fileName, QString(), parent); + + if(destUrl.isEmpty()) + return false; if (destUrl.isLocalFile()) { |