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

List:       kde-core-devel
Subject:    Small KApplication cleanups
From:       Urs Wolfer <uwolfer () kde ! org>
Date:       2007-12-23 10:39:41
Message-ID: 200712231139.44351.uwolfer () kde ! org
[Download RAW message or body]

[Attachment #2 (multipart/mixed)]


Hi all

While looking into kapplication.cpp, I have seen some things that are not 
really nice or not required anymore. Please see the attached patch.

Key points:
* cleaner icon loading code
* remove not anymore needed KDE 3 workarounds (I was not able to reproduce the 
described issues anymore)

If there are no objections, I will commit these small changes tomorrow.

Bye
urs

["kapplication_cleanups.patch" (text/x-diff)]

Index: kapplication.cpp
===================================================================
--- kapplication.cpp	(revision 752016)
+++ kapplication.cpp	(working copy)
@@ -29,7 +29,6 @@
 #define QT_NO_TRANSLATION
 #include <QtCore/QDir>
 #include <QtCore/QFile>
-#include <QtGui/QIcon>
 #include <QtGui/QSessionManager>
 #include <QtGui/QStyleFactory>
 #include <QtCore/QTimer>
@@ -48,7 +47,7 @@
 #include "kglobalsettings.h"
 #include "kdebug.h"
 #include "kglobal.h"
-#include "kiconloader.h"
+#include "kicon.h"
 #include "klocale.h"
 #include "ksessionmanager.h"
 #include "kstandarddirs.h"
@@ -121,10 +120,6 @@
 static QByteArray* startup_id_tmp;
 #endif
 
-// duplicated from patched Qt, so that there won't be unresolved symbols if Qt gets
-// replaced by unpatched one
-KDEUI_EXPORT bool qt_qclipboard_bailout_hack = false;
-
 template class QList<KSessionManager*>;
 
 #ifdef Q_WS_X11
@@ -605,12 +600,10 @@
 #ifdef Q_WS_MAC
   if (q->type() == KApplication::GuiClient) {
       QSystemTrayIcon *trayIcon;
-      QPixmap pixmap = KIconLoader::global()->loadIcon( KCmdLineArgs::appName(),
-              KIconLoader::NoGroup, KIconLoader::SizeEnormous, \
                KIconLoader::DefaultState, QStringList(), false );
-      if (!pixmap.isNull() && QSystemTrayIcon::isSystemTrayAvailable())
+      if (QSystemTrayIcon::isSystemTrayAvailable())
       {
           trayIcon = new QSystemTrayIcon(q);
-          trayIcon->setIcon(QIcon(pixmap));
+          trayIcon->setIcon(KIcon(KCmdLineArgs::appName()));
           /* it's counter-intuitive, but once you do setIcon it's already set the
              dock icon... ->show actually shows an icon in the menu bar too  :P */
           // trayIcon->show();
@@ -831,7 +824,7 @@
     if (args && args->isSet("style"))
     {
         extern QString kde_overrideStyle; // see KGlobalSettings. Should we have a \
                static setter?
-        QString reqStyle(args->getOption("style").toLower());
+        QString reqStyle(args->getOption("style"));
         if (QStyleFactory::keys().contains(reqStyle, Qt::CaseInsensitive))
             kde_overrideStyle = reqStyle;
         else
@@ -842,16 +835,10 @@
     if ( q->type() != KApplication::Tty ) {
         if (args && args->isSet("icon"))
         {
-            QPixmap largeIcon = DesktopIcon(args->getOption("icon"));
-            QIcon icon =  q->windowIcon();
-            icon.addPixmap(largeIcon, QIcon::Normal, QIcon::On);
-            q->setWindowIcon(icon);
+            q->setWindowIcon(KIcon(args->getOption("icon")));
         }
         else {
-            QIcon icon = q->windowIcon();
-            QPixmap largeIcon = DesktopIcon(componentData.componentName());
-            icon.addPixmap(largeIcon, QIcon::Normal, QIcon::On);
-            q->setWindowIcon(icon);
+            q->setWindowIcon(KIcon(componentData.componentName()));
         }
     }
 
@@ -940,45 +927,6 @@
 #ifdef Q_WS_X11
 bool KApplication::x11EventFilter( XEvent *_event )
 {
-    switch ( _event->type ) {
-        case ClientMessage:
-        {
-#if KDE_IS_VERSION( 3, 90, 90 )
-#ifdef __GNUC__
-#warning This should be already in Qt, check.
-#endif
-#endif
-        // Workaround for focus stealing prevention not working when dragging e.g. \
                text from KWrite
-        // to KDesktop -> the dialog asking for filename doesn't get activated. This \
                is because
-        // Qt-3.2.x doesn't have concept of qt_x_user_time at all, and Qt-3.3.0b1 \
                passes the timestamp
-        // in the XdndDrop message in incorrect field (and doesn't update \
                qt_x_user_time either).
-        // Patch already sent, future Qt version should have this fixed.
-            if( _event->xclient.message_type == kde_xdnd_drop )
-                { // if the message is XdndDrop
-                if( _event->xclient.data.l[ 1 ] == 1 << 24     // and it's broken \
                the way it's in Qt-3.2.x
-                    && _event->xclient.data.l[ 2 ] == 0
-                    && _event->xclient.data.l[ 4 ] == 0
-                    && _event->xclient.data.l[ 3 ] != 0 )
-                    {
-                    if( QX11Info::appUserTime() == 0
-                        || NET::timestampCompare( _event->xclient.data.l[ 3 ], \
                QX11Info::appUserTime() ) > 0 )
-                        { // and the timestamp looks reasonable
-                        QX11Info::setAppUserTime(_event->xclient.data.l[ 3 ]); // \
                update our qt_x_user_time from it
-                        }
-                    }
-                else // normal DND, only needed until Qt updates qt_x_user_time from \
                XdndDrop
-                    {
-                    if( QX11Info::appUserTime() == 0
-                        || NET::timestampCompare( _event->xclient.data.l[ 2 ], \
                QX11Info::appUserTime() ) > 0 )
-                        { // the timestamp looks reasonable
-                        QX11Info::setAppUserTime(_event->xclient.data.l[ 2 ]); // \
                update our qt_x_user_time from it
-                        }
-                    }
-                }
-        }
-	default: break;
-    }
-
     if (x11Filter) {
         foreach (const QWidget *w, *x11Filter) {
             if (((KAppX11HackWidget*) w)->publicx11Event(_event))


["signature.asc" (application/pgp-signature)]

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

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