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

List:       kde-commits
Subject:    playground/base/plasma/applets/incomingmsg
From:       Christian Weilbach <christian () whiletaker ! homeip ! net>
Date:       2008-08-22 3:44:43
Message-ID: 1219376683.894921.5919.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 850701 by weilbach:

Add a config interface so one can explicetly chose which running apps should be used \
for notification.


 M  +1 -0      CMakeLists.txt  
 M  +122 -16   plasma-incomingmsg.cpp  
 M  +11 -2     plasma-incomingmsg.h  
 A             widget.ui  


--- trunk/playground/base/plasma/applets/incomingmsg/CMakeLists.txt #850700:850701
@@ -17,6 +17,7 @@
 set(incomingmsg_SRCS plasma-incomingmsg.cpp)
 
 # Now make sure all files get to the right place
+kde4_add_ui_files(incomingmsg_SRCS widget.ui)
 kde4_add_plugin(plasma_applet_incomingmsg ${incomingmsg_SRCS})
 
 target_link_libraries(plasma_applet_incomingmsg
--- trunk/playground/base/plasma/applets/incomingmsg/plasma-incomingmsg.cpp \
#850700:850701 @@ -46,22 +46,83 @@
 #include <KLocale>
 
 IncomingMsg::IncomingMsg(QObject *parent, const QVariantList &args)
-    : Plasma::Applet(parent, args)
+    : Plasma::Applet(parent, args), mLayout(0),
+      mKMailLayout(0),mXChatLayout(0),mKopeteLayout(0),
+      mPidginLayout(0),
+      mKMailIconLabel(0),mXChatIconLabel(0),mKopeteIconLabel(0),
+      mPidginIconLabel(0),
+      mKMailLabel(0),mXChatLabel(0),mKopeteLabel(0),
+      mPidginLabel(0)
 {
     // this will get us the standard applet background, for free!
    setBackgroundHints(DefaultBackground);
-   resize(280, 30);
-   setMinimumSize(280, 30);
+   resize(300, 20);
+   setMinimumSize(200, 20);
 }
 
 IncomingMsg::~IncomingMsg()
 {
+   delete mKMailLayout;
+   delete mKMailIconLabel;
+   delete mKMailLabel;
+
+   delete mXChatLayout;
+   delete mXChatIconLabel;
+   delete mXChatLabel;
+
+   delete mKopeteLayout;
+   delete mKopeteIconLabel;
+   delete mKopeteLabel;
+
+   delete mPidginLayout;
+   delete mPidginIconLabel;
+   delete mPidginLabel;
 }
 
 void IncomingMsg::init()
 {
    /* initialize layout */
+   setHasConfigurationInterface(true);
+   KConfigGroup cg = config();
+   mShowKMail = cg.readEntry("showKMail", true);
+   mShowXChat = cg.readEntry("showXChat", true);
+   mShowKopete = cg.readEntry("showKopete", true);
+   mShowPidgin = cg.readEntry("showPidgin", true);
+
+   initLayout();
+}
+
+void IncomingMsg::initLayout(){
+   delete mKMailLayout;
+   mKMailLayout=0;
+   delete mKMailIconLabel;
+   mKMailIconLabel=0;
+   delete mKMailLabel;
+   mKMailLabel=0;
+
+   delete mXChatLayout;
+   mXChatLayout=0;
+   delete mXChatIconLabel;
+   mXChatIconLabel=0;
+   delete mXChatLabel;
+   mXChatLabel=0;
+
+   delete mKopeteLayout;
+   mKopeteLayout=0;
+   delete mKopeteIconLabel;
+   mKopeteIconLabel=0;
+   delete mKopeteLabel;
+   mKopeteLabel=0;
+
+   delete mPidginLayout;
+   mPidginLayout=0;
+   delete mPidginIconLabel;
+   mPidginIconLabel=0;
+   delete mPidginLabel;
+   mPidginLabel=0;
+
    mLayout = new QGraphicsLinearLayout(Qt::Vertical);
+//    setGeometry(QRectF(geometry().x(),geometry().y(),0,0));
 
    /* test for the evolution dbus interface */
    // TODO find out why evolution does not expose dbus on a kde session here
@@ -100,6 +161,7 @@
 //    }
 
    /* test for the kmail dbus interface */
+   if(mShowKMail){
    QDBusInterface kmailDBusTest( "org.kde.kmail", "/KMail", \
"org.freedesktop.DBus.Introspectable" );  QDBusReply<QString>kmailReply = \
kmailDBusTest.call( "Introspect" );  if(!kmailReply.isValid())
@@ -131,12 +193,14 @@
            mLayout->addItem(mKMailLayout);
        }
    }
+   }
 
    /* test for the xchat dbus interface */
    // do not really understand how this interface works
    // got this working code from \
http://arstechnica.com/reviews/hardware/tux-droid-review.ars/3  // we need to hook it \
up first. this first call is not only for interface testing but also for  // setup.
+   if(mShowXChat){
    QDBusInterface xchatDBusTest( "org.xchat.service","/org/xchat/Remote", \
"org.xchat.plugin" );  QDBusReply<void> xchatReply = xchatDBusTest.call( "HookPrint", \
"Channel Msg Hilight", 0, 0 );  if(!xchatReply.isValid())
@@ -167,8 +231,10 @@
            mLayout->addItem(mXChatLayout);
        }
    }
+   }
 
    /* test for the kopete dbus interface */
+   if(mShowKopete){
    QDBusInterface kopeteDBusTest( "org.kde.kopete", "/kopete", \
"org.freedesktop.DBus.Introspectable" );  QDBusReply<QString>kopeteReply = \
kopeteDBusTest.call( "Introspect" );  if(!kopeteReply.isValid())
@@ -200,9 +266,11 @@
            mLayout->addItem(mKopeteLayout);
        }
    }
+   }
 
    /* test for the pidgin dbus interface */
    // FIXME introspect does not work here with qdbus trying sth. else
+   if(mShowPidgin){
    QDBusInterface pidginDBusTest( "im.pidgin.purple.PurpleService", \
"/im/pidgin/purple/PurpleObject",   "im.pidgin.purple.PurpleInterface" );
    QDBusReply<QString> pidginReply = pidginDBusTest.call( "PurpleBuddyGetName", \
int(0) ); @@ -230,30 +298,68 @@
 
            mPidginLayout->addItem(mPidginIconLabel);
            mPidginLayout->addItem(mPidginLabel);
-           mPidginLayout->setAlignment(mPidginLabel, Qt::AlignLeft);
+            mPidginLayout->setAlignment(mPidginLabel, Qt::AlignLeft);
 
-           mLayout->addItem(mPidginLayout);
-       }
-   }
+            mLayout->addItem(mPidginLayout);
+        }
+    }
+    }
 
-   if(!mLayout->count()){
-       Plasma::Label *errorLabel = new Plasma::Label();
-       errorLabel->setText( i18n( "No running messaging apps found. Supported apps \
                are %1, %2, %3, %4.",
-                                   QString("KMail"), QString("XChat"), \
                QString("Kopete"),
-                                   QString( "Pidgin" ) ) );
-       mLayout->addItem(errorLabel);
-   }
+    if(!mLayout->count()){
+        Plasma::Label *errorLabel = new Plasma::Label();
+        errorLabel->setText( i18n( "No running messaging apps found. Supported apps \
are %1, %2, %3, %4.", +                                    QString("KMail"), \
QString("XChat"), QString("Kopete"), +                                    \
QString("Pidgin") ) ); +        mLayout->addItem(errorLabel);
+    }
 
-   setLayout(mLayout);
+    setLayout(mLayout);
 }
 
+void IncomingMsg::createConfigurationInterface(KConfigDialog *dialog)
+{
+    QWidget *widget = new QWidget();
+    ui.setupUi(widget);
+    dialog->setMainWidget( widget );
+
+    KConfigGroup cg = config();
+    ui.showKMail->setChecked(cg.readEntry("showKMail", true));
+    ui.showXChat->setChecked(cg.readEntry("showXChat", true));
+    ui.showKopete->setChecked(cg.readEntry("showKopete", true));
+    ui.showPidgin->setChecked(cg.readEntry("showPidgin", true));
+
+    dialog->setButtons(KDialog::Ok | KDialog::Cancel ); // | KDialog::Apply
+    connect(dialog, SIGNAL(applyClicked()), this, SLOT(configAccepted()));
+    connect(dialog, SIGNAL(okClicked()), this, SLOT(configAccepted()));
+
+    dialog->addPage(widget, dialog->windowTitle(), icon());
+}
+
+
+void IncomingMsg::configAccepted()
+{
+    mShowKMail = ui.showKMail->isChecked();
+    mShowXChat = ui.showXChat->isChecked();
+    mShowKopete = ui.showKopete->isChecked();
+    mShowPidgin = ui.showPidgin->isChecked();
+
+
+    KConfigGroup cg = config();
+    cg.writeEntry("showKMail", ui.showKMail->isChecked());
+    cg.writeEntry("showXChat", ui.showXChat->isChecked());
+    cg.writeEntry("showKopete", ui.showKopete->isChecked());
+    cg.writeEntry("showPidgin", ui.showPidgin->isChecked());
+
+    initLayout();
+}
+
 void IncomingMsg::constraintsEvent(Plasma::Constraints constraints)
 {
     setBackgroundHints(Plasma::Applet::DefaultBackground);
     QRectF layoutRectF = mLayout->geometry();
     QRectF appletRectF = geometry();
     if( layoutRectF.height()>appletRectF.height() ){
-        appletRectF.setHeight(layoutRectF.height()+20);
+        appletRectF.setHeight(layoutRectF.height()+30);
         setGeometry( appletRectF );
     }
 }
--- trunk/playground/base/plasma/applets/incomingmsg/plasma-incomingmsg.h \
#850700:850701 @@ -26,6 +26,8 @@
 #include <Plasma/Applet>
 #include <Plasma/Svg>
 
+#include "ui_widget.h"
+
 class QGraphicsLinearLayout;
 
 namespace Plasma {
@@ -44,8 +46,14 @@
       ~IncomingMsg();
 
       void init();
+   protected:
+      void createConfigurationInterface(KConfigDialog *parent);
+      void constraintsEvent(Plasma::Constraints);
 
+   protected slots:
+      void configAccepted();
    private:
+      void initLayout();
       // text labels
       Plasma::Label *mLabel, 
                     *mEvolutionLabel, *mEvolutionIconLabel,
@@ -60,9 +68,10 @@
                             *mXChatLayout,
                             *mKopeteLayout,
                             *mPidginLayout;
+      bool mShowKMail, mShowXChat, mShowKopete,
+            mShowPidgin;
 
-    protected:
-      void constraintsEvent(Plasma::Constraints);
+      Ui::incomingmsgConfig ui;
 
     private slots:
       void slotNewEvolutionMail();


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

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