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

List:       kde-core-devel
Subject:    [PATCH] Themed KMessageBox Icons
From:       Ryan Cumming <ryan () completely ! kicks-ass ! org>
Date:       2002-08-26 1:09:03
[Download RAW message or body]

Hi,

This patch allows the icon theme to override the standard KMessageBox icons. 
If an icon theme does not provide themed message box icons, the defaults will 
be used.

As Maksim pointed out, this does not help Qt apps at all :(

Oh, and the obligatory screenshots are here:
http://completely.kicks-ass.org/messagebox-old.png
http://completely.kicks-ass.org/messagebox-new.png

-Ryan
["themed-messagebox.diff" (text/x-diff)]

Index: kmessagebox.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kmessagebox.cpp,v
retrieving revision 1.60
diff -u -r1.60 kmessagebox.cpp
--- kmessagebox.cpp	2002/07/22 21:22:30	1.60
+++ kmessagebox.cpp	2002/08/26 00:53:31
@@ -43,6 +43,7 @@
 #include <qlayout.h>
 #include <kstdguiitem.h>
 #include <kactivelabel.h>
+#include <kiconloader.h>
 
  /**
   * Easy MessageBox Dialog.
@@ -60,6 +61,34 @@
 
 static bool KMessageBox_queue = false;
 
+static QPixmap themedMessageBoxIcon(QMessageBox::Icon icon)
+{
+    QString icon_name;
+
+    switch(icon)
+    {
+    case QMessageBox::NoIcon:
+        return QPixmap();
+        break;
+    case QMessageBox::Information:
+        icon_name = "information";
+        break;
+    case QMessageBox::Warning:
+        icon_name = "warning";
+        break;
+    case QMessageBox::Critical:     
+        icon_name = "critical";
+        break;
+    }
+
+   QPixmap ret = KApplication::kApplication()->iconLoader()->loadIcon(icon_name, \
KIcon::NoGroup, KIcon::SizeMedium, KIcon::DefaultState, 0, true); +
+   if (ret.isNull())
+       return QMessageBox::standardIcon(icon);
+   else
+       return ret;
+}
+
 static int createKMessageBox(KDialogBase *dialog, QMessageBox::Icon icon, const \
QString &text, const QStringList &strlist, const QString &ask, bool *checkboxReturn, \
int options, const QString &details=QString::null)  {
     QVBox *topcontents = new QVBox (dialog);
@@ -71,7 +100,10 @@
     lay->setSpacing(KDialog::spacingHint()*2);
 
     QLabel *label1 = new QLabel( contents);
-    label1->setPixmap(QMessageBox::standardIcon(icon));
+
+    if (icon != QMessageBox::NoIcon)
+        label1->setPixmap(themedMessageBoxIcon(icon));
+
     lay->addWidget( label1, 0, Qt::AlignCenter );
     lay->addSpacing(KDialog::spacingHint());
     // Enforce <p>text</p> otherwise the word-wrap doesn't work well



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

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