Skip to content
Snippets Groups Projects
Commit 25d843a8 authored by Mathieu Leduc-Hamel's avatar Mathieu Leduc-Hamel
Browse files

[#2701] Cleaning a little bit and implement the systray as custom class

parent 23e707fb
No related branches found
No related tags found
No related merge requests found
...@@ -118,9 +118,40 @@ sflphone-client-gnome/stamp-h1 ...@@ -118,9 +118,40 @@ sflphone-client-gnome/stamp-h1
/sflphone-client-gnome/tests/check_global /sflphone-client-gnome/tests/check_global
/sflphone-client-gnome/src/dbus/marshaller.c /sflphone-client-gnome/src/dbus/marshaller.c
/sflphone-client-gnome/src/dbus/marshaller.h /sflphone-client-gnome/src/dbus/marshaller.h
/sflphone-client-gnome/ltmain.sh
# Ignore sflphone_kde stuff # Ignore sflphone_kde stuff
/sflphone-client-kde/build /sflphone-client-kde/build
/sflphone-client-kde/*.moc
/sflphone-client-kde/src/moc_*.cpp
/sflphone-client-kde/src/ui_*.h
/sflphone-client-kde/po/
/sflphone-client-kde/po/*
/sflphone-client-kde/doc/
/sflphone-client-kde/man/
/sflphone-client-kde/data/
/sflphone-client-kde/CMakeCache.txt
/sflphone-client-kde/CMakeLists.txt.user
/sflphone-client-kde/CTestTestfile.cmake
/sflphone-client-kde/*.cmake
/sflphone-client-kde/Makefile
/sflphone-client-kde/CMakeFiles/*
/sflphone-client-kde/CMakeTmp/
/sflphone-client-kde/qtcreator-build/
/sflphone-client-kde/src/Makefile
/sflphone-client-kde/src/CTestTestfile.cmake
/sflphone-client-kde/src/CMakeFiles/
/sflphone-client-kde/src/*.moc
/sflphone-client-kde/src/callmanager_dbus_interface.*
/sflphone-client-kde/src/configurationmanager_dbus_interface.*
/sflphone-client-kde/src/instance_dbus_interface.*
/sflphone-client-kde/src/sflphone-client-kde_automoc.cpp
/sflphone-client-kde/src/sflphone-client-kde_automoc.cpp.files
/sflphone-client-kde/src/cmake_install.cmake
/sflphone-client-kde/src/kcfg_settings.cpp
/sflphone-client-kde/src/kcfg_settings.h
/sflphone-client-kde/src/qrc_resources.cxx
# Ignore sub-modules stuff # Ignore sub-modules stuff
## libiax2 ## libiax2
......
...@@ -20,6 +20,7 @@ SET( sflphone_client_kde_SRCS ...@@ -20,6 +20,7 @@ SET( sflphone_client_kde_SRCS
SFLPhoneView.cpp SFLPhoneView.cpp
SFLPhone.cpp SFLPhone.cpp
SFLPhoneapplication.cpp SFLPhoneapplication.cpp
SFLPhoneTray.cpp
main.cpp main.cpp
sflphone_const.h sflphone_const.h
Account.cpp Account.cpp
......
...@@ -72,12 +72,8 @@ bool SFLPhone::initialize() ...@@ -72,12 +72,8 @@ bool SFLPhone::initialize()
statusBarWidget = new QLabel(); statusBarWidget = new QLabel();
statusBar()->addWidget(statusBarWidget); statusBar()->addWidget(statusBarWidget);
trayIconMenu = new QMenu(this);
trayIconMenu->addAction(action_quit);
trayIcon = new KSystemTrayIcon(this->windowIcon(), this);
trayIcon->setContextMenu(trayIconMenu);
trayIcon = new SFLPhoneTray(this->windowIcon(), this);
trayIcon->show(); trayIcon->show();
iconChanged = false; iconChanged = false;
...@@ -98,6 +94,7 @@ bool SFLPhone::initialize() ...@@ -98,6 +94,7 @@ bool SFLPhone::initialize()
(new AccountWizard())->show(); (new AccountWizard())->show();
} }
initialized_ = true;
return true; return true;
} }
...@@ -211,47 +208,26 @@ void SFLPhone::quitButton() ...@@ -211,47 +208,26 @@ void SFLPhone::quitButton()
if(view->listWidget_callList->count() > 0 && instance.getRegistrationCount() <= 1) if(view->listWidget_callList->count() > 0 && instance.getRegistrationCount() <= 1)
{ {
qDebug() << "Attempting to quit when still having some calls open."; qDebug() << "Attempting to quit when still having some calls open.";
// view->getErrorWindow()->showMessage(i18n("You still have some calls open. Please close all calls before quitting."));
} }
view->saveState(); view->saveState();
instance.Unregister(getpid()); instance.Unregister(getpid());
qApp->quit(); qApp->quit();
} }
void SFLPhone::putForeground()
{
activateWindow();
hide();
activateWindow();
show();
activateWindow();
}
void SFLPhone::trayIconSignal()
{
if(! isActiveWindow())
{
trayIcon->setIcon(QIcon(ICON_TRAY_NOTIF));
iconChanged = true;
}
}
void SFLPhone::sendNotif(QString caller) void SFLPhone::sendNotif(QString caller)
{ {/*
notification = new KNotification ( QString("test_notification"), this ); notification = new KNotification ( QString("test_notification"), this );
notification->setText("messageText") ; notification->setText("messageText") ;
notification->setPixmap( QPixmap( this->windowIcon().pixmap(32, 32) )); notification->setPixmap( QPixmap( this->windowIcon().pixmap(32, 32) ));
notification->setActions( QStringList( i18n( "Open chat" ) ) ); notification->setActions( QStringList( i18n( "Open chat" ) ) );
notification->addContext( QString::fromLatin1("call") , "caller" ) ; notification->addContext( QString::fromLatin1("call") , "caller" ) ;
connect(notification, SIGNAL(activated(unsigned int )), this , SLOT(sendNotif()) ); notification->sendEvent();*/
notification->sendEvent(); /* KNotification::event(QString("test_notification"),
} QString("Allo"),
this->windowIcon().pixmap(32, 32),
void SFLPhone::on_trayIcon_messageClicked() parentWidget(),
{ KNotification::CloseOnTimeout,
qDebug() << "on_trayIcon_messageClicked"; KGlobal::mainComponent());*/
putForeground();
} }
void SFLPhone::changeEvent(QEvent * event) void SFLPhone::changeEvent(QEvent * event)
...@@ -262,31 +238,6 @@ void SFLPhone::changeEvent(QEvent * event) ...@@ -262,31 +238,6 @@ void SFLPhone::changeEvent(QEvent * event)
} }
} }
void SFLPhone::on_trayIcon_activated(KSystemTrayIcon::ActivationReason reason)
{
qDebug() << "on_trayIcon_activated";
switch (reason) {
case KSystemTrayIcon::Trigger:
case KSystemTrayIcon::DoubleClick:
qDebug() << "Tray icon clicked.";
if(isActiveWindow())
{
qDebug() << "isactive -> hide()";
hide();
}
else
{
qDebug() << "isnotactive -> show()";
putForeground();
}
break;
default:
qDebug() << "Tray icon activated with unknown reason.";
break;
}
}
void SFLPhone::on_view_statusMessageChangeAsked(const QString & message) void SFLPhone::on_view_statusMessageChangeAsked(const QString & message)
{ {
qDebug() << "on_view_statusMessageChangeAsked : " + message; qDebug() << "on_view_statusMessageChangeAsked : " + message;
...@@ -375,11 +326,11 @@ QList <QAction *> SFLPhone::getCallActions() ...@@ -375,11 +326,11 @@ QList <QAction *> SFLPhone::getCallActions()
void SFLPhone::on_view_incomingCall(const Call * call) void SFLPhone::on_view_incomingCall(const Call * call)
{ {
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
trayIconSignal(); //trayIconSignal();
if(configurationManager.popupMode()) /*if(configurationManager.popupMode())
{ {
putForeground(); putForeground();
} }*/
if(configurationManager.getNotify()) if(configurationManager.getNotify())
{ {
sendNotif(call->getPeerName().isEmpty() ? call->getPeerPhoneNumber() : call->getPeerName()); sendNotif(call->getPeerName().isEmpty() ? call->getPeerPhoneNumber() : call->getPeerName());
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "AccountWizard.h" #include "AccountWizard.h"
#include "Contact.h" #include "Contact.h"
#include "SFLPhoneView.h" #include "SFLPhoneView.h"
#include "SFLPhoneTray.h"
class SFLPhoneView; class SFLPhoneView;
...@@ -93,7 +94,7 @@ private: ...@@ -93,7 +94,7 @@ private:
SFLPhoneView * view; SFLPhoneView * view;
QMenu *trayIconMenu; QMenu *trayIconMenu;
bool iconChanged; bool iconChanged;
KSystemTrayIcon *trayIcon; SFLPhoneTray *trayIcon;
KNotification *notification; KNotification *notification;
QLabel * statusBarWidget; QLabel * statusBarWidget;
...@@ -111,15 +112,14 @@ public: ...@@ -111,15 +112,14 @@ public:
bool initialize(); bool initialize();
void setupActions(); void setupActions();
void sendNotif(QString caller); void sendNotif(QString caller);
void putForeground();
void trayIconSignal(); void trayIconSignal();
SFLPhoneView * getView(); SFLPhoneView * getView();
QList<QAction *> getCallActions(); QList<QAction *> getCallActions();
private slots: private slots:
void on_trayIcon_activated(KSystemTrayIcon::ActivationReason reason); /*void on_trayIcon_activated(KSystemTrayIcon::ActivationReason reason);
void on_trayIcon_messageClicked(); void on_trayIcon_messageClicked();*/
void on_view_statusMessageChangeAsked(const QString & message); void on_view_statusMessageChangeAsked(const QString & message);
void on_view_windowTitleChangeAsked(const QString & message); void on_view_windowTitleChangeAsked(const QString & message);
void on_view_enabledActionsChangeAsked(const bool * enabledActions); void on_view_enabledActionsChangeAsked(const bool * enabledActions);
......
/************************************** *************************************
* Copyright (C) 2009 by Savoir-Faire Linux *
* Author : Jérémy Quentin *
* jeremy.quentin@savoirfairelinux.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include <QDebug>
#include "SFLPhoneTray.h"
SFLPhoneTray::SFLPhoneTray(QIcon icon, QWidget *parent)
: KSystemTrayIcon(icon, parent),
initialized_(false),
trayIconMenu(0)
{
}
SFLPhoneTray::~SFLPhoneTray()
{
}
bool SFLPhoneTray::initialize()
{
if ( initialized_ )
{
qDebug() << "Already initialized.";
return false;
}
trayIconMenu = new QMenu(parentWidget());
setContextMenu(trayIconMenu);
setupActions();
initialized_ = true;
return true;
}
void SFLPhoneTray::addAction(KAction *action)
{
trayIconMenu->addAction(action);
}
void SFLPhoneTray::setupActions()
{
qDebug() << "setupActions";
}
/*void SFLPhone::putForeground()
{
activateWindow();
hide();
activateWindow();
show();
activateWindow();
}
*/
/*void SFLPhone::trayIconSignal()
{
if(! parentWidget()->isActiveWindow())
{
setIcon(QIcon(ICON_TRAY_NOTIF));
iconChanged = true;
}
}*/
/*
void SFLPhone::on_trayIcon_activated(KSystemTrayIcon::ActivationReason reason)
{
qDebug() << "on_trayIcon_activated";
switch (reason) {
case KSystemTrayIcon::Trigger:
case KSystemTrayIcon::DoubleClick:
qDebug() << "Tray icon clicked.";
if(isActiveWindow())
{
qDebug() << "isactive -> hide()";
hide();
}
else
{
qDebug() << "isnotactive -> show()";
putForeground();
}
break;
default:
qDebug() << "Tray icon activated with unknown reason.";
break;
}
}
*/
/***************************************************************************
* Copyright (C) 2009 by Savoir-Faire Linux *
* Author : Jérémy Quentin *
* jeremy.quentin@savoirfairelinux.com *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#ifndef SFLPHONETRAY_H
#define SFLPHONETRAY_H
#include <KSystemTrayIcon>
#include <KAction>
#include <QMenu>
#include <QIcon>
class SFLPhoneTray : public KSystemTrayIcon
{
Q_OBJECT
public:
SFLPhoneTray(QIcon icon, QWidget *parent = 0);
~SFLPhoneTray();
bool initialize();
void setupActions();
void addAction(KAction *action);
private:
QMenu *trayIconMenu;
bool initialized_;
/*
private slots:
void activated(KSystemTrayIcon::ActivationReason reason);
void messageClicked();*/
void trayIconSignal();
};
#endif // SFLPHONETRAY_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment