mirror of
https://git.jami.net/savoirfairelinux/jami-daemon.git
synced 2025-08-07 22:02:12 +08:00
[#2701] Cleaning a little bit and implement the systray as custom class
This commit is contained in:
31
.gitignore
vendored
31
.gitignore
vendored
@ -118,9 +118,40 @@ sflphone-client-gnome/stamp-h1
|
||||
/sflphone-client-gnome/tests/check_global
|
||||
/sflphone-client-gnome/src/dbus/marshaller.c
|
||||
/sflphone-client-gnome/src/dbus/marshaller.h
|
||||
/sflphone-client-gnome/ltmain.sh
|
||||
|
||||
# Ignore sflphone_kde stuff
|
||||
/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
|
||||
## libiax2
|
||||
|
@ -16,10 +16,11 @@ ENDIF(${CMAKE_BUILD_TYPE} MATCHES Release)
|
||||
|
||||
SET ( KDE4_KABC_LIBS -lkabc )
|
||||
|
||||
SET( sflphone_client_kde_SRCS
|
||||
SET( sflphone_client_kde_SRCS
|
||||
SFLPhoneView.cpp
|
||||
SFLPhone.cpp
|
||||
SFLPhoneapplication.cpp
|
||||
SFLPhoneTray.cpp
|
||||
main.cpp
|
||||
sflphone_const.h
|
||||
Account.cpp
|
||||
|
@ -72,12 +72,8 @@ bool SFLPhone::initialize()
|
||||
statusBarWidget = new QLabel();
|
||||
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();
|
||||
|
||||
iconChanged = false;
|
||||
@ -98,6 +94,7 @@ bool SFLPhone::initialize()
|
||||
(new AccountWizard())->show();
|
||||
}
|
||||
|
||||
initialized_ = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -211,47 +208,26 @@ void SFLPhone::quitButton()
|
||||
if(view->listWidget_callList->count() > 0 && instance.getRegistrationCount() <= 1)
|
||||
{
|
||||
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();
|
||||
instance.Unregister(getpid());
|
||||
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)
|
||||
{
|
||||
{/*
|
||||
notification = new KNotification ( QString("test_notification"), this );
|
||||
notification->setText("messageText") ;
|
||||
notification->setPixmap( QPixmap( this->windowIcon().pixmap(32, 32) ));
|
||||
notification->setActions( QStringList( i18n( "Open chat" ) ) );
|
||||
notification->addContext( QString::fromLatin1("call") , "caller" ) ;
|
||||
connect(notification, SIGNAL(activated(unsigned int )), this , SLOT(sendNotif()) );
|
||||
notification->sendEvent();
|
||||
}
|
||||
|
||||
void SFLPhone::on_trayIcon_messageClicked()
|
||||
{
|
||||
qDebug() << "on_trayIcon_messageClicked";
|
||||
putForeground();
|
||||
notification->sendEvent();*/
|
||||
/* KNotification::event(QString("test_notification"),
|
||||
QString("Allo"),
|
||||
this->windowIcon().pixmap(32, 32),
|
||||
parentWidget(),
|
||||
KNotification::CloseOnTimeout,
|
||||
KGlobal::mainComponent());*/
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
qDebug() << "on_view_statusMessageChangeAsked : " + message;
|
||||
@ -375,11 +326,11 @@ QList <QAction *> SFLPhone::getCallActions()
|
||||
void SFLPhone::on_view_incomingCall(const Call * call)
|
||||
{
|
||||
ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
|
||||
trayIconSignal();
|
||||
if(configurationManager.popupMode())
|
||||
//trayIconSignal();
|
||||
/*if(configurationManager.popupMode())
|
||||
{
|
||||
putForeground();
|
||||
}
|
||||
}*/
|
||||
if(configurationManager.getNotify())
|
||||
{
|
||||
sendNotif(call->getPeerName().isEmpty() ? call->getPeerPhoneNumber() : call->getPeerName());
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "AccountWizard.h"
|
||||
#include "Contact.h"
|
||||
#include "SFLPhoneView.h"
|
||||
#include "SFLPhoneTray.h"
|
||||
|
||||
class SFLPhoneView;
|
||||
|
||||
@ -93,7 +94,7 @@ private:
|
||||
SFLPhoneView * view;
|
||||
QMenu *trayIconMenu;
|
||||
bool iconChanged;
|
||||
KSystemTrayIcon *trayIcon;
|
||||
SFLPhoneTray *trayIcon;
|
||||
KNotification *notification;
|
||||
QLabel * statusBarWidget;
|
||||
|
||||
@ -111,15 +112,14 @@ public:
|
||||
bool initialize();
|
||||
void setupActions();
|
||||
void sendNotif(QString caller);
|
||||
void putForeground();
|
||||
void trayIconSignal();
|
||||
SFLPhoneView * getView();
|
||||
QList<QAction *> getCallActions();
|
||||
|
||||
|
||||
private slots:
|
||||
void on_trayIcon_activated(KSystemTrayIcon::ActivationReason reason);
|
||||
void on_trayIcon_messageClicked();
|
||||
/*void on_trayIcon_activated(KSystemTrayIcon::ActivationReason reason);
|
||||
void on_trayIcon_messageClicked();*/
|
||||
void on_view_statusMessageChangeAsked(const QString & message);
|
||||
void on_view_windowTitleChangeAsked(const QString & message);
|
||||
void on_view_enabledActionsChangeAsked(const bool * enabledActions);
|
||||
|
108
sflphone-client-kde/src/SFLPhoneTray.cpp
Normal file
108
sflphone-client-kde/src/SFLPhoneTray.cpp
Normal file
@ -0,0 +1,108 @@
|
||||
/************************************** *************************************
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
*/
|
51
sflphone-client-kde/src/SFLPhoneTray.h
Normal file
51
sflphone-client-kde/src/SFLPhoneTray.h
Normal file
@ -0,0 +1,51 @@
|
||||
/***************************************************************************
|
||||
* 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
|
Reference in New Issue
Block a user