1
0
mirror of https://github.com/KDE/krfb synced 2026-07-01 07:41:17 -07:00
Files
krfb/trayicon.cpp
Laurent Montel a514fc0a63 Kapplication-> Qapplication
svn path=/trunk/KDE/kdenetwork/krfb/; revision=654537
2007-04-16 13:13:27 +00:00

119 lines
3.9 KiB
C++

/***************************************************************************
trayicon.cpp
-------------------
begin : Tue Dec 11 2001
copyright : (C) 2001-2002 by Tim Jansen
email : tim@tjansen.de
***************************************************************************/
/***************************************************************************
* *
* 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 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "trayicon.h"
#include <kstandardaction.h>
#include <klocale.h>
#include <kdialog.h>
#include <kmenu.h>
#include <kglobal.h>
#include <kaboutapplicationdialog.h>
#include "manageinvitationsdialog.h"
#include "invitedialog.h"
TrayIcon::TrayIcon(KDialog *d) :
KSystemTrayIcon(d),
actionCollection(this),
quitting(false)
{
setIcon(KIcon("eyes-closed24"));
setToolTip(i18n("Desktop Sharing - disconnected"));
// manageInvitationsAction = new KAction(i18n("Manage &Invitations"), &actionCollection);
// actionCollection.addAction("manage_invitations", manageInvitationsAction);
// connect(manageInvitationsAction, SIGNAL(triggered(bool)), SLOT(showManageInvitations()));
// contextMenu()->addAction(actionCollection.action("manage_invitations"));
// contextMenu()->addSeparator();
enableControlAction = new KToggleAction(i18n("Enable Remote Control"), &actionCollection);
enableControlAction->setCheckedState(KGuiItem(i18n("Disable Remote Control")));
enableControlAction->setEnabled(false);
actionCollection.addAction("enable_control", enableControlAction);
connect(enableControlAction, SIGNAL(toggled(bool)), SIGNAL(enableDesktopControl(bool)));
contextMenu()->addAction(actionCollection.action("enable_control"));
contextMenu()->addSeparator();
aboutAction = KStandardAction::aboutApp(this, SLOT(showAbout()), &actionCollection);
actionCollection.addAction("about", aboutAction);
contextMenu()->addAction(actionCollection.action("about"));
show();
}
TrayIcon::~TrayIcon(){
}
void TrayIcon::showAbout() {
KAboutApplicationDialog(KGlobal::mainComponent().aboutData()).exec();
}
void TrayIcon::prepareQuit() {
quitting = true;
}
void TrayIcon::showConnectedMessage(const QString &host) {
setIcon(KIcon("eyes-open24"));
KPassivePopup::message(i18n("Desktop Sharing"),
i18n("The remote user has been authenticated and is now connected."),
KIcon("eyes-open24").pixmap(22),
this);
setToolTip(i18n("Desktop Sharing - connected with %1", host));
}
void TrayIcon::showDisconnectedMessage() {
if (quitting)
return;
setToolTip(i18n("Desktop Sharing - disconnected"));
setIcon(KIcon("eyes-closed24"));
KPassivePopup *p = KPassivePopup::message(i18n("Desktop Sharing"),
i18n("The remote user has closed the connection."),
KIcon("eyes-closed24").pixmap(22),
this);
connect(p, SIGNAL(hidden()), this, SIGNAL(diconnectedMessageDisplayed()));
}
void TrayIcon::setDesktopControlSetting(bool b) {
enableControlAction->setEnabled(true);
enableControlAction->setChecked(b);
}
void TrayIcon::activated(QSystemTrayIcon::ActivationReason reason)
{
if (reason == QSystemTrayIcon::Trigger)
{
contextMenu()->popup(QCursor::pos());
}
else
KSystemTrayIcon::activated(reason);
}
void TrayIcon::showManageInvitations()
{
ManageInvitationsDialog invMngDlg(0);
invMngDlg.exec();
}
#include "trayicon.moc"