[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/network/kcall
From: George Kiagiadakis <gkiagiad () csd ! uoc ! gr>
Date: 2009-08-01 19:52:19
Message-ID: 1249156339.913216.24299.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 1005703 by gkiagia:
When the MainWindow is hidden or closed, make the systray icon active to \
let the user have some visual proof that kcall is still running. Equally, \
when the MainWindow is visible, make the systray icon passive, as it is not \
needed.
M +3 -8 kcallapplication.cpp
M +2 -3 kcallapplication.h
M +36 -2 systrayicon.cpp
M +3 -0 systrayicon.h
--- trunk/playground/network/kcall/kcallapplication.cpp #1005702:1005703
@@ -51,10 +51,7 @@
int KCallApplication::newInstance()
{
- if ( !d->mainWindow ) {
- d->mainWindow = new MainWindow;
- d->mainWindow->show();
- }
+ mainWindow()->show();
return 0;
}
@@ -63,14 +60,12 @@
return d->accountManager;
}
-void KCallApplication::showHideMainWindow()
+MainWindow *KCallApplication::mainWindow() const
{
if ( !d->mainWindow ) {
d->mainWindow = new MainWindow;
- d->mainWindow->show();
- } else {
- d->mainWindow->setVisible( !d->mainWindow->isVisible() );
}
+ return d->mainWindow;
}
#include "kcallapplication.moc"
--- trunk/playground/network/kcall/kcallapplication.h #1005702:1005703
@@ -20,6 +20,7 @@
#include <KUniqueApplication>
namespace Tp { class PendingOperation; }
class AccountManager;
+class MainWindow;
class KCallApplication : public KUniqueApplication
{
@@ -30,13 +31,11 @@
virtual int newInstance();
AccountManager *accountManager() const;
+ MainWindow *mainWindow() const;
static inline KCallApplication *instance()
{ return static_cast<KCallApplication*>(QCoreApplication::instance()); \
}
-public slots:
- void showHideMainWindow();
-
private:
struct Private;
Private *const d;
--- trunk/playground/network/kcall/systrayicon.cpp #1005702:1005703
@@ -16,6 +16,7 @@
*/
#include "systrayicon.h"
#include "kcallapplication.h"
+#include "mainwindow.h"
#include <QtCore/QSet>
#include <KLocalizedString>
#include <KDebug>
@@ -53,10 +54,12 @@
d->notificationItem->setIconByName("internet-telephony");
d->notificationItem->setAttentionIconByName("voicecall");
d->notificationItem->setCategory(Experimental::KNotificationItem::Communications);
- d->notificationItem->setStatus(Experimental::KNotificationItem::Passive);
+ d->notificationItem->setStatus(Experimental::KNotificationItem::Active);
connect(d->notificationItem, SIGNAL(activateRequested(bool, QPoint)),
SLOT(onActivateRequested(bool, QPoint)));
+
+ KCallApplication::instance()->mainWindow()->installEventFilter(this);
}
SystrayIcon::~SystrayIcon()
@@ -87,8 +90,39 @@
if ( d->currentRequest ) {
d->currentRequest->accept();
} else {
- KCallApplication::instance()->showHideMainWindow();
+ MainWindow *mw = KCallApplication::instance()->mainWindow();
+ //reinstall the event filter because the mainwindow is deleted on \
close, so in some cases + //a new mainwindow is returned here.
+ mw->removeEventFilter(this);
+ mw->installEventFilter(this);
+ if ( !mw->isVisible() ) {
+ mw->show();
+ mw->raise();
+ mw->activateWindow();
+ } else {
+ mw->hide();
+ }
}
}
+bool SystrayIcon::eventFilter(QObject *watched, QEvent *event)
+{
+ if ( watched != KCallApplication::instance()->mainWindow() ) {
+ return AbstractClientApprover::eventFilter(watched, event);
+ }
+
+ switch (event->type()) {
+ case QEvent::Show:
+ d->notificationItem->setStatus(Experimental::KNotificationItem::Passive);
+ break;
+ case QEvent::Hide:
+ case QEvent::Close:
+ d->notificationItem->setStatus(Experimental::KNotificationItem::Active);
+ break;
+ default:
+ break;
+ }
+ return false;
+}
+
#include "systrayicon.moc"
--- trunk/playground/network/kcall/systrayicon.h #1005702:1005703
@@ -33,6 +33,9 @@
private slots:
void onActivateRequested(bool active, const QPoint & pos);
+protected:
+ virtual bool eventFilter(QObject *watched, QEvent *event);
+
private:
struct Private;
Private *const d;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic