[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [Konversation] ff3af36: - Colors are working,
From:       Christian Muehlhaeuser <chris () chris ! de>
Date:       2010-07-01 13:26:57
Message-ID: 20100701132657.2C229BB5493 () projects ! kde ! org
[Download RAW message or body]

commit ff3af362c8974d8a91f42399d071f6cca97f5078
Author: Christian Muehlhaeuser <chris@chris.de>
Date:   Thu Oct 16 02:32:19 2003 +0000

    - Colors are working, now.
    - A black border gets drawn around the message.
    - Still some flickering left, which I'll fix asap.
    - Different colors for events, asap.
    
    svn path=/trunk/kdeextragear-2/konversation/; revision=259304

diff --git a/konversation/konversationapplication.cpp b/konversation/konversationapplication.cpp
index 6d3bfc1..d6d4ce8 100644
--- a/konversation/konversationapplication.cpp
+++ b/konversation/konversationapplication.cpp
@@ -398,6 +398,14 @@ void KonversationApplication::readOptions()
   {
     osd->setEnabled(true);
     osd->setFont(preferences.getOSDFont());
+
+    QString osdColor = config->readEntry("OSDColor");
+    if(osdColor.isEmpty())
+      preferences.setOSDColor(preferences.getOSDColor().name());
+    else
+      preferences.setOSDColor("#" + osdColor);
+
+    osd->setColor(preferences.getOSDColor());
   }
 
   // Server List
@@ -662,6 +670,7 @@ void KonversationApplication::saveOptions(bool updateGUI)
   config->writeEntry("ShowQuery",preferences.getOSDShowQuery());
   config->writeEntry("ShowChannelEvent",preferences.getOSDShowChannelEvent());
   config->writeEntry("OSDFont",preferences.getOSDFont().toString());
+  config->writeEntry("OSDColor",preferences.getOSDColor().name().mid(1));
 
   // Ignore List
   config->deleteGroup("Ignore List");
diff --git a/konversation/osd.cpp b/konversation/osd.cpp
index c9c6c37..a1f6271 100644
--- a/konversation/osd.cpp
+++ b/konversation/osd.cpp
@@ -20,6 +20,8 @@
 #include <qpixmap.h>
 #include <qbitmap.h>
 
+#include <kcolorcombo.h>
+
 OSDWidget::OSDWidget() : QWidget(NULL, "osd",
                                  WType_TopLevel | WStyle_StaysOnTop |
                                  WStyle_Customize | WStyle_NoBorder |
@@ -61,6 +63,11 @@ void OSDWidget::setFont(QFont newfont)
   font = newfont;
 }
 
+void OSDWidget::setColor(QColor newcolor)
+{
+  color = newcolor;
+}
+
 void OSDWidget::removeOSD()
 {
   // hide() and show() prevents flickering
@@ -71,22 +78,46 @@ void OSDWidget::removeOSD()
 void OSDWidget::paintEvent(QPaintEvent*)
 {
   QPainter paint;
+  QPixmap *buffer = new QPixmap(width(), height());
   QColor bg(0, 0, 0);
   QColor fg(255, 255, 255);
 
   qApp->syncX();
+
+  // Draw the OnScreenMessage
+  QPainter paintBuffer(buffer, this);
+  paintBuffer.setFont(font);
+
+  // Draw the border around the text
+  paintBuffer.setPen(black);
+  paintBuffer.drawText(0, 0, width()-1, height()-1, AlignLeft | WordBreak, this->text);
+  paintBuffer.drawText(2, 0, width()-1, height()-1, AlignLeft | WordBreak, this->text);
+  paintBuffer.drawText(0, 2, width()-1, height()-1, AlignLeft | WordBreak, this->text);
+  paintBuffer.drawText(2, 2, width()-1, height()-1, AlignLeft | WordBreak, this->text);
+
+  // Draw the text
+  paintBuffer.setPen(color);
+  paintBuffer.drawText(1, 1, width()-1, height()-1, AlignLeft | WordBreak, this->text);
+  paintBuffer.end();
+
+  // Masking for transparency
   QBitmap bm(size());
   bm.fill(bg);
   paint.begin(&bm, this);
-
-  // Draw the text. Coloring doesn't work right now. It's on my TODO
-  paint.setBrush(fg);
-  paint.setPen(fg);
+  paint.setPen(Qt::color0);
   paint.setFont(font);
-  paint.drawText(rect(), AlignLeft | WordBreak, this->text);
-
+  paint.drawText(0, 0, width()-1, height()-1, AlignLeft | WordBreak, this->text);
+  paint.drawText(1, 1, width()-1, height()-1, AlignLeft | WordBreak, this->text);
+  paint.drawText(2, 0, width()-1, height()-1, AlignLeft | WordBreak, this->text);
+  paint.drawText(0, 2, width()-1, height()-1, AlignLeft | WordBreak, this->text);
+  paint.drawText(2, 2, width()-1, height()-1, AlignLeft | WordBreak, this->text);
   paint.end();
+
+  // Let's make it real, flush the buffers
+  bitBlt(this, 0, 0, buffer);
   setMask(bm);
+
+  delete buffer;
 }
 
 #include "osd.moc"
diff --git a/konversation/osd.h b/konversation/osd.h
index f463fa3..4a59fb8 100644
--- a/konversation/osd.h
+++ b/konversation/osd.h
@@ -32,6 +32,7 @@ class OSDWidget : public QWidget
         OSDWidget();
         void showOSD(const QString &text);
         void setFont(QFont newfont);
+        void setColor(QColor newcolor);
       protected slots:
         void removeOSD();
 //        void dblClick();
@@ -41,6 +42,7 @@ class OSDWidget : public QWidget
         QString text;
         QTimer *timer;
         QFont font;
+        QColor color;
 };
 
 #endif
diff --git a/konversation/preferences.cpp b/konversation/preferences.cpp
index e8c1ec5..6a56f04 100644
--- a/konversation/preferences.cpp
+++ b/konversation/preferences.cpp
@@ -128,6 +128,7 @@ Preferences::Preferences()
   setOSDShowOwnNick(false);
   setOSDShowQuery(false);
   setOSDShowChannelEvent(false);
+  setOSDColor("#ffffff");
 
   setBackgroundImageName(QString::null);
 
@@ -537,6 +538,9 @@ QFont Preferences::getOSDFont() { return osdFont; }
 void Preferences::setOSDFont(QFont newFont) { osdFont=newFont; }
 void Preferences::setOSDFontRaw(const QString &rawFont) { osdFont.fromString(rawFont); }
 
+void Preferences::setOSDColor(const QString &newColor) { osdColor.setNamedColor(newColor); }
+QColor Preferences::getOSDColor() { return osdColor; }
+
 QFont Preferences::getTextFont() { return textFont; }
 QFont Preferences::getListFont() { return listFont; }
 void Preferences::setTextFont(QFont newFont) { textFont=newFont; }
diff --git a/konversation/preferences.h b/konversation/preferences.h
index 50fb481..e5e508f 100644
--- a/konversation/preferences.h
+++ b/konversation/preferences.h
@@ -202,6 +202,9 @@ class Preferences : public QObject
     void setOSDFont(QFont newFont);
     void setOSDFontRaw(const QString &rawFont);
 
+    void setOSDColor(const QString &color);
+    QColor getOSDColor();
+
     QStringList getButtonList();
     void setButtonList(QStringList newList);
 
@@ -432,6 +435,7 @@ class Preferences : public QObject
     bool OSDShowQuery;        // Message on query acticity
     bool OSDShowChannelEvent; // Message on channel join/part events
     QFont osdFont;            // Which font to use
+    QColor osdColor;
 
     QString backgroundImage;
 
diff --git a/konversation/prefspageosd.cpp b/konversation/prefspageosd.cpp
index 5a4d4a7..21f0a26 100644
--- a/konversation/prefspageosd.cpp
+++ b/konversation/prefspageosd.cpp
@@ -63,6 +63,10 @@ PrefsPageOSD::PrefsPageOSD(QFrame* newParent,Preferences* newPreferences) :
   osdPreviewLabel->setFrameStyle(QFrame::Panel | QFrame::Sunken);
   osdFontButton = new QPushButton(i18n("Choose..."), parentFrame, "osd_font_button");
 
+  osdColorLabel = new QLabel(i18n("Color:"), parentFrame);
+  osdColorChooser = new KColorCombo(parentFrame, "osd_color");
+  osdColorChooser->setColor(preferences->getOSDColor());
+
   // Take care of ghosting / unghosting close button checkboxes
   osdUsageChanged(preferences->getOSDUsage() ? 2 : 0);
 
@@ -75,7 +79,9 @@ PrefsPageOSD::PrefsPageOSD(QFrame* newParent,Preferences* newPreferences) :
   osdLayout->addWidget(osdFontLabel, ++row, 0);
   osdLayout->addWidget(osdPreviewLabel, row, 1);
   osdLayout->addWidget(osdFontButton, row, 2);
-  osdLayout->addMultiCellWidget(osdActionsBox, ++row, row + 2, 0, 1);
+  osdLayout->addWidget(osdColorLabel, ++row, 0);
+  osdLayout->addWidget(osdColorChooser, row, 1);
+  osdLayout->addMultiCellWidget(osdActionsBox, ++row, row + 2, 0, 2);
 
   row = row + 2;
   QHBox* spacer = new QHBox(parentFrame);
@@ -114,12 +120,14 @@ void PrefsPageOSD::applyPreferences()
   preferences->setOSDShowQuery(osdShowQuery->isChecked());
   preferences->setOSDShowChannelEvent(osdShowChannelEvent->isChecked());
   preferences->setOSDFont(osdFont);
+  preferences->setOSDColor(osdColorChooser->color().name());
 
   KonversationApplication *konvApp=static_cast<KonversationApplication *>(KApplication::kApplication());
   konvApp->osd->setEnabled(useOSDCheck->isChecked());
   if (preferences->getOSDUsage())
   {
     konvApp->osd->setFont(osdFont);
+    konvApp->osd->setColor(osdColorChooser->color());
   }
 
 }
diff --git a/konversation/prefspageosd.h b/konversation/prefspageosd.h
index 16883d0..a8945f8 100644
--- a/konversation/prefspageosd.h
+++ b/konversation/prefspageosd.h
@@ -17,6 +17,7 @@
 
 #include "prefspage.h"
 #include <qvgroupbox.h>
+#include <kcolorcombo.h>
 
 /*
   @author Christian Muehlhaeuser
@@ -53,6 +54,9 @@ class PrefsPageOSD : public PrefsPage
     QPushButton* osdFontButton;
     QLabel* osdFontLabel;
     QLabel* osdPreviewLabel;
+    QLabel* osdColorLabel;
+
+    KColorCombo* osdColorChooser;
 
     QVGroupBox* osdActionsBox;
 };
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic