[SCM] ktp-text-ui packaging branch, master, updated. debian/15.12.1-1-1918-gdf4b0ec

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:19:13 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-text-ui.git;a=commitdiff;h=b2c3b1d

The following commit has been merged in the master branch:
commit b2c3b1de5c62c2f60caeea4660d057d72ba98283
Author: Florian Reinhard <florian.reinhard at googlemail.com>
Date:   Thu Mar 31 00:12:07 2011 +0200

    Make font family and size configureable.
    
    REVIEW: 100979
    BUG: 265704
---
 config/chatwindowconfig.ui | 201 ++++++++++++++++++++++++++++++---------------
 config/main-window.cpp     |  33 ++++++++
 config/main-window.h       |   3 +
 lib/adium-theme-view.cpp   |  61 ++++++++++++++
 lib/adium-theme-view.h     |  10 ++-
 lib/chat-window-style.cpp  |  14 ++++
 lib/chat-window-style.h    |   2 +
 7 files changed, 255 insertions(+), 69 deletions(-)

diff --git a/config/chatwindowconfig.ui b/config/chatwindowconfig.ui
index a24b789..a783e92 100644
--- a/config/chatwindowconfig.ui
+++ b/config/chatwindowconfig.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>400</width>
-    <height>303</height>
+    <width>500</width>
+    <height>400</height>
    </rect>
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
@@ -22,83 +22,143 @@
     </widget>
    </item>
    <item>
-    <layout class="QHBoxLayout" name="horizontalLayout">
-     <item>
-      <layout class="QGridLayout" name="gridLayout">
-       <item row="1" column="1">
-        <widget class="KComboBox" name="styleComboBox"/>
-       </item>
-       <item row="1" column="0">
-        <widget class="QLabel" name="styleLabel">
-         <property name="text">
-          <string>Message Style:</string>
-         </property>
-         <property name="alignment">
-          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-         </property>
-         <property name="buddy">
-          <cstring>styleComboBox</cstring>
-         </property>
-        </widget>
-       </item>
-       <item row="2" column="1">
-        <widget class="KComboBox" name="variantComboBox"/>
-       </item>
-       <item row="2" column="0">
-        <widget class="QLabel" name="variantLabel">
-         <property name="text">
-          <string>Variant:</string>
-         </property>
-         <property name="alignment">
-          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-         </property>
-         <property name="buddy">
-          <cstring>variantComboBox</cstring>
-         </property>
-        </widget>
-       </item>
-       <item row="3" column="1">
-        <widget class="QCheckBox" name="showUserIcons">
-         <property name="text">
-          <string>Show User Icons</string>
-         </property>
-        </widget>
-       </item>
-       <item row="5" column="1">
-        <widget class="QCheckBox" name="showHeader">
-         <property name="text">
-          <string>Show Header</string>
-         </property>
-        </widget>
-       </item>
-       <item row="6" column="0">
-        <widget class="QLabel" name="fontLabel">
-         <property name="text">
-          <string>Select Font: </string>
-         </property>
-         <property name="alignment">
-          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
-         </property>
-        </widget>
-       </item>
-       <item row="6" column="1">
-        <widget class="KFontComboBox" name="kfontcombobox"/>
-       </item>
-      </layout>
+    <layout class="QGridLayout" name="gridLayout">
+     <item row="0" column="1">
+      <widget class="QGroupBox" name="customFontBox">
+       <property name="title">
+        <string>Use Custom Font Settings</string>
+       </property>
+       <property name="checkable">
+        <bool>true</bool>
+       </property>
+       <layout class="QFormLayout" name="formLayout">
+        <property name="fieldGrowthPolicy">
+         <enum>QFormLayout::ExpandingFieldsGrow</enum>
+        </property>
+        <item row="1" column="0">
+         <widget class="QLabel" name="fontFamilyLabel">
+          <property name="text">
+           <string>Select 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="fontFamily"/>
+        </item>
+        <item row="2" column="0">
+         <widget class="QLabel" name="fontSizeLabel">
+          <property name="text">
+           <string>Select Size: </string>
+          </property>
+          <property name="alignment">
+           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="1">
+         <widget class="KIntNumInput" name="fontSize">
+          <property name="minimum">
+           <number>1</number>
+          </property>
+          <property name="maximum">
+           <number>128</number>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </widget>
      </item>
-     <item>
+     <item row="0" column="2">
       <spacer name="horizontalSpacer">
        <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
        <property name="sizeHint" stdset="0">
         <size>
-         <width>40</width>
-         <height>20</height>
+         <width>0</width>
+         <height>0</height>
         </size>
        </property>
       </spacer>
      </item>
+     <item row="0" column="0">
+      <widget class="QGroupBox" name="groupBox">
+       <property name="title">
+        <string>Style</string>
+       </property>
+       <layout class="QFormLayout" name="formLayout_3">
+        <item row="0" column="0">
+         <widget class="QLabel" name="styleLabel">
+          <property name="text">
+           <string>Message Style:</string>
+          </property>
+          <property name="alignment">
+           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+          </property>
+          <property name="buddy">
+           <cstring>styleComboBox</cstring>
+          </property>
+         </widget>
+        </item>
+        <item row="0" column="1">
+         <widget class="KComboBox" name="styleComboBox">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="sizeAdjustPolicy">
+           <enum>QComboBox::AdjustToContents</enum>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="0">
+         <widget class="QLabel" name="variantLabel">
+          <property name="text">
+           <string>Variant:</string>
+          </property>
+          <property name="alignment">
+           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+          </property>
+          <property name="buddy">
+           <cstring>variantComboBox</cstring>
+          </property>
+         </widget>
+        </item>
+        <item row="1" column="1">
+         <widget class="KComboBox" name="variantComboBox">
+          <property name="sizePolicy">
+           <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+            <horstretch>0</horstretch>
+            <verstretch>0</verstretch>
+           </sizepolicy>
+          </property>
+          <property name="sizeAdjustPolicy">
+           <enum>QComboBox::AdjustToContents</enum>
+          </property>
+         </widget>
+        </item>
+        <item row="2" column="1">
+         <widget class="QCheckBox" name="showUserIcons">
+          <property name="text">
+           <string>Show User Icons</string>
+          </property>
+         </widget>
+        </item>
+        <item row="3" column="1">
+         <widget class="QCheckBox" name="showHeader">
+          <property name="text">
+           <string>Show Header</string>
+          </property>
+         </widget>
+        </item>
+       </layout>
+      </widget>
+     </item>
     </layout>
    </item>
   </layout>
@@ -115,6 +175,11 @@
    <header>kcombobox.h</header>
   </customwidget>
   <customwidget>
+   <class>KIntNumInput</class>
+   <extends>QWidget</extends>
+   <header>knuminput.h</header>
+  </customwidget>
+  <customwidget>
    <class>AdiumThemeView</class>
    <extends>QWidget</extends>
    <header>adium-theme-view.h</header>
diff --git a/config/main-window.cpp b/config/main-window.cpp
index d74de0b..bb0b274 100644
--- a/config/main-window.cpp
+++ b/config/main-window.cpp
@@ -50,11 +50,17 @@ MainWindow::MainWindow(QWidget *parent, const QVariantList& args)
     ui->chatView->initialise(m_demoChatHeader);
 
     ui->showHeader->setChecked(ui->chatView->isHeaderDisplayed());
+    ui->customFontBox->setChecked(ui->chatView->isCustomFont());
+    ui->fontFamily->setCurrentFont(QFont(ui->chatView->fontFamily()));
+    ui->fontSize->setValue(ui->chatView->fontSize());
 
     connect(ui->chatView, SIGNAL(loadFinished(bool)), SLOT(sendDemoMessages()));
     connect(ui->styleComboBox, SIGNAL(activated(int)), SLOT(onStyleSelected(int)));
     connect(ui->variantComboBox, SIGNAL(activated(QString)), SLOT(onVariantSelected(QString)));
     connect(ui->showHeader, SIGNAL(clicked(bool)), SLOT(onShowHeaderChanged(bool)));
+    connect(ui->customFontBox, SIGNAL(clicked(bool)), SLOT(onFontGroupChanged(bool)));
+    connect(ui->fontFamily, SIGNAL(currentFontChanged(QFont)), SLOT(onFontFamilyChanged(QFont)));
+    connect(ui->fontSize, SIGNAL(valueChanged(int)), SLOT(onFontSizeChanged(int)));
 }
 
 MainWindow::~MainWindow()
@@ -140,6 +146,30 @@ void MainWindow::onShowHeaderChanged(bool showHeader)
     changed();
 }
 
+void MainWindow::onFontGroupChanged(bool useCustomFont)
+{
+    kDebug();
+    ui->chatView->setUseCustomFont(useCustomFont);
+    ui->chatView->initialise(m_demoChatHeader);
+    changed();
+}
+
+void MainWindow::onFontFamilyChanged(QFont fontFamily)
+{
+    kDebug() << fontFamily.family();
+    ui->chatView->setFontFamily(fontFamily.family());
+    ui->chatView->initialise(m_demoChatHeader);
+    changed();
+}
+
+void MainWindow::onFontSizeChanged(int fontSize)
+{
+    kDebug() << fontSize;
+    ui->chatView->setFontSize(fontSize);
+    ui->chatView->initialise(m_demoChatHeader);
+    changed();
+}
+
 void MainWindow::sendDemoMessages()
 {
     //add a fake message
@@ -178,6 +208,9 @@ void MainWindow::save()
     appearanceConfig.writeEntry("styleName", ui->styleComboBox->itemData(ui->styleComboBox->currentIndex()).toString());
     appearanceConfig.writeEntry("styleVariant", ui->variantComboBox->currentText());
     appearanceConfig.writeEntry("displayHeader", ui->showHeader->isChecked());
+    appearanceConfig.writeEntry("useCustomFont", ui->customFontBox->isChecked());
+    appearanceConfig.writeEntry("fontFamily", ui->fontFamily->currentFont().family());
+    appearanceConfig.writeEntry("fontSize", ui->fontSize->value());
 
     appearanceConfig.sync();
     config->sync();
diff --git a/config/main-window.h b/config/main-window.h
index 1eb2030..e95bf93 100644
--- a/config/main-window.h
+++ b/config/main-window.h
@@ -57,6 +57,9 @@ private slots:
     void onStyleSelected(int index);
     void onVariantSelected(const QString&);
     void onShowHeaderChanged(bool);
+    void onFontGroupChanged(bool);
+    void onFontFamilyChanged(QFont);
+    void onFontSizeChanged(int);
 };
 
 #endif // MAINWINDOW_H
diff --git a/lib/adium-theme-view.cpp b/lib/adium-theme-view.cpp
index b7a88f8..56d82da 100644
--- a/lib/adium-theme-view.cpp
+++ b/lib/adium-theme-view.cpp
@@ -28,6 +28,7 @@
 
 #include <QtCore/QFile>
 #include <QtCore/QTextCodec>
+#include <QtGui/QFontDatabase>
 #include <QtWebKit/QWebFrame>
 #include <QtWebKit/QWebElement>
 #include <QtWebKit/QWebInspector>
@@ -83,6 +84,10 @@ AdiumThemeView::AdiumThemeView(QWidget *parent)
     //special HTML debug mode. Debugging/Profiling only (or theme creating) should have no visible way to turn this flag on.
     m_webInspector = appearanceConfig.readEntry("debug", false);
 
+    m_useCustomFont = appearanceConfig.readEntry("useCustomFont", false);
+    m_fontFamily = appearanceConfig.readEntry("fontFamily", QWebSettings::globalSettings()->fontFamily(QWebSettings::StandardFont));
+    m_fontSize = appearanceConfig.readEntry("fontSize", QWebSettings::globalSettings()->fontSize(QWebSettings::DefaultFontSize));
+
     // don't let QWebView handle the links, we do
     page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
 
@@ -105,6 +110,30 @@ void AdiumThemeView::initialise(const AdiumThemeHeaderInfo &chatInfo)
         headerHtml = replaceHeaderKeywords(m_chatStyle->getHeaderHtml(), chatInfo);
     } //otherwise leave as blank.
 
+    // set fontFamily and fontSize
+    if (m_useCustomFont) {
+        // use user specified fontFamily and Size
+        settings()->setFontFamily(QWebSettings::StandardFont, m_fontFamily);
+        settings()->setFontSize(QWebSettings::DefaultFontSize, m_fontSize);
+
+        // since some themes are pretty odd and hardcode fonts to the css we need to override that
+        // with some extra css. this may not work for all themes!
+        extraStyleHtml.append (
+            QString("
* {font-family:\"%1\" !important;font-size:%2pt !important};")
+                .arg( m_fontFamily )
+                .arg( m_fontSize )
+        );
+    } else {
+        // FIXME: we should inform the user if the chatStyle want's to use a fontFamily which is not present on the system
+        QFontDatabase fontDB = QFontDatabase();
+        kDebug() << "Theme font installed: " << m_chatStyle->defaultFontFamily()
+                 << fontDB.families().contains(m_chatStyle->defaultFontFamily());
+
+        // use theme fontFamily/Size, if not existent, it falls back to systems default font
+        settings()->setFontFamily(QWebSettings::StandardFont, m_chatStyle->defaultFontFamily());
+        settings()->setFontSize(QWebSettings::DefaultFontSize, m_chatStyle->defaultFontSize());
+    }
+
     //The templateHtml is in a horrific NSString format.
     //Want to use this rather than roll our own, as that way we can get templates from themes too
     //"%@" is each argument.
@@ -178,6 +207,38 @@ void AdiumThemeView::setChatStyle(ChatWindowStyle *chatStyle)
     }
 }
 
+QString AdiumThemeView::fontFamily()
+{
+    return m_fontFamily;
+}
+
+void AdiumThemeView::setFontFamily(QString fontFamily)
+{
+    kDebug();
+    m_fontFamily = fontFamily;
+}
+
+int AdiumThemeView::fontSize()
+{
+    return m_fontSize;
+}
+
+void AdiumThemeView::setFontSize(int fontSize)
+{
+    kDebug();
+    m_fontSize = fontSize;
+}
+
+void AdiumThemeView::setUseCustomFont(bool useCustomFont)
+{
+    kDebug();
+    m_useCustomFont = useCustomFont;
+}
+
+bool AdiumThemeView::isCustomFont() const
+{
+    return m_useCustomFont;
+}
 
 bool AdiumThemeView::isHeaderDisplayed() const
 {
diff --git a/lib/adium-theme-view.h b/lib/adium-theme-view.h
index 920e062..2a54794 100644
--- a/lib/adium-theme-view.h
+++ b/lib/adium-theme-view.h
@@ -49,7 +49,12 @@ public:
     ChatWindowStyle *chatStyle() const;
     /** Set the theme to use. Display will only change once initialise() is called.*/
     void setChatStyle(ChatWindowStyle* chatStyle);
-
+    void setUseCustomFont(bool);
+    QString fontFamily();
+    int fontSize();
+    void setFontFamily(QString fontFamily);
+    void setFontSize(int fontSize);
+    bool isCustomFont() const;
     bool isHeaderDisplayed() const;
     /** Set whether a header is displayed at the top of the window.
      * Output will only change once initialise() is called. */
@@ -66,6 +71,9 @@ private:
     QString m_variantPath;
     QString m_variantName;
     KEmoticons m_emoticons;
+    bool m_useCustomFont;
+    QString m_fontFamily;
+    int m_fontSize;
     QString replaceHeaderKeywords(QString htmlTemplate, const AdiumThemeHeaderInfo&);
     QString replaceContentKeywords(QString& htmlTemplate, const AdiumThemeContentInfo&);
     QString replaceStatusKeywords(QString& htmlTemplate, const AdiumThemeStatusInfo&);
diff --git a/lib/chat-window-style.cpp b/lib/chat-window-style.cpp
index 33f6c35..7186759 100644
--- a/lib/chat-window-style.cpp
+++ b/lib/chat-window-style.cpp
@@ -38,6 +38,8 @@ public:
     QString baseHref;
     StyleVariants variantsList;
     QString defaultVariantName;
+    QString defaultFontFamily;
+    int     defaultFontSize;
 
     QString templateHtml;
     QString headerHtml;
@@ -137,6 +139,16 @@ QString ChatWindowStyle::defaultVariantName()
     return d->defaultVariantName;
 }
 
+QString ChatWindowStyle::defaultFontFamily()
+{
+    return d->defaultFontFamily;
+}
+
+int ChatWindowStyle::defaultFontSize()
+{
+    return d->defaultFontSize;
+}
+
 QString ChatWindowStyle::getStyleBaseHref() const
 {
     return d->baseHref;
@@ -287,6 +299,8 @@ void ChatWindowStyle::readStyleFiles()
 
     ChatStylePlistFileReader plistReader(infoPlistFile);
     d->defaultVariantName = plistReader.defaultVariant();
+    d->defaultFontFamily  = plistReader.defaultFontFamily();
+    d->defaultFontSize    = plistReader.defaultFontSize();
 
     // Load template file
     if (QFile::exists(templateFile)) {
diff --git a/lib/chat-window-style.h b/lib/chat-window-style.h
index 3ca12a8..41a0c15 100644
--- a/lib/chat-window-style.h
+++ b/lib/chat-window-style.h
@@ -140,6 +140,8 @@ public:
     void reload();
 
     QString defaultVariantName();
+    QString defaultFontFamily();
+    int defaultFontSize();
 private:
     /**
      * Read style HTML files from disk

-- 
ktp-text-ui packaging



More information about the pkg-kde-commits mailing list