reimplement confirmation on exit if there are downloads in progress
[kdenetwork.git] / krfb / trayicon.cpp
blobad06f34d7ce1a9045f86de33dc7aa02743832394
1 /***************************************************************************
2 trayicon.cpp
3 -------------------
4 begin : Tue Dec 11 2001
5 copyright : (C) 2001-2002 by Tim Jansen
6 email : tim@tjansen.de
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #include "trayicon.h"
20 #include <kstandardaction.h>
21 #include <klocale.h>
22 #include <kdialog.h>
23 #include <kmenu.h>
24 #include <kglobal.h>
25 #include <kactioncollection.h>
26 #include <kaboutapplicationdialog.h>
28 #include "manageinvitationsdialog.h"
29 #include "invitedialog.h"
32 TrayIcon::TrayIcon(KDialog *d) :
33 KSystemTrayIcon(d),
34 quitting(false)
36 setIcon(KIcon("eyes-closed24"));
38 setToolTip(i18n("Desktop Sharing - disconnected"));
40 // manageInvitationsAction = new KAction(i18n("Manage &Invitations"), &actionCollection);
41 // actionCollection.addAction("manage_invitations", manageInvitationsAction);
42 // connect(manageInvitationsAction, SIGNAL(triggered(bool)), SLOT(showManageInvitations()));
43 // contextMenu()->addAction(actionCollection.action("manage_invitations"));
45 // contextMenu()->addSeparator();
47 enableControlAction = new KToggleAction(i18n("Enable Remote Control"), actionCollection());
48 enableControlAction->setCheckedState(KGuiItem(i18n("Disable Remote Control")));
49 enableControlAction->setEnabled(false);
50 actionCollection()->addAction("enable_control", enableControlAction);
51 connect(enableControlAction, SIGNAL(toggled(bool)), SIGNAL(enableDesktopControl(bool)));
52 contextMenu()->addAction(actionCollection()->action("enable_control"));
54 contextMenu()->addSeparator();
55 contextMenu()->addAction(KStandardAction::aboutApp(this, SLOT(showAbout()), actionCollection()));
57 show();
60 TrayIcon::~TrayIcon(){
63 void TrayIcon::showAbout() {
64 KAboutApplicationDialog(KGlobal::mainComponent().aboutData()).exec();
67 void TrayIcon::prepareQuit() {
68 quitting = true;
71 void TrayIcon::showConnectedMessage(const QString &host) {
73 setIcon(KIcon("eyes-open24"));
74 KPassivePopup::message(i18n("Desktop Sharing"),
75 i18n("The remote user has been authenticated and is now connected."),
76 KIcon("eyes-open24").pixmap(22),
77 this);
78 setToolTip(i18n("Desktop Sharing - connected with %1", host));
81 void TrayIcon::showDisconnectedMessage() {
82 if (quitting)
83 return;
85 setToolTip(i18n("Desktop Sharing - disconnected"));
86 setIcon(KIcon("eyes-closed24"));
87 KPassivePopup *p = KPassivePopup::message(i18n("Desktop Sharing"),
88 i18n("The remote user has closed the connection."),
89 KIcon("eyes-closed24").pixmap(22),
90 this);
91 connect(p, SIGNAL(hidden()), this, SIGNAL(diconnectedMessageDisplayed()));
94 void TrayIcon::setDesktopControlSetting(bool b) {
95 enableControlAction->setEnabled(true);
96 enableControlAction->setChecked(b);
99 void TrayIcon::showManageInvitations()
101 ManageInvitationsDialog invMngDlg(0);
102 invMngDlg.exec();
105 #include "trayicon.moc"