this should work again...(old one did not anymore)
[kdenetwork.git] / krfb / trayicon.cpp
blob0b9c659e284bfaf1ff57129badc7ee305798d986
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("krfb").pixmap(22, 22, KIcon::Disabled));
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()
64 void TrayIcon::showAbout()
66 KAboutApplicationDialog(KGlobal::mainComponent().aboutData()).exec();
69 void TrayIcon::prepareQuit()
71 quitting = true;
74 void TrayIcon::showConnectedMessage(const QString &host)
77 setIcon(KIcon("krfb"));
78 KPassivePopup::message(i18n("Desktop Sharing"),
79 i18n("The remote user has been authenticated and is now connected."),
80 KIcon("krfb").pixmap(22, 22),
81 this);
82 setToolTip(i18n("Desktop Sharing - connected with %1", host));
85 void TrayIcon::showDisconnectedMessage()
87 if (quitting)
88 return;
90 setToolTip(i18n("Desktop Sharing - disconnected"));
91 setIcon(KIcon("krfb").pixmap(22, 22, KIcon::Disabled));
92 KPassivePopup *p = KPassivePopup::message(i18n("Desktop Sharing"),
93 i18n("The remote user has closed the connection."),
94 KIcon("krfb").pixmap(22, 22, KIcon::Disabled),
95 this);
96 connect(p, SIGNAL(hidden()), this, SIGNAL(diconnectedMessageDisplayed()));
99 void TrayIcon::setDesktopControlSetting(bool b)
101 enableControlAction->setEnabled(true);
102 enableControlAction->setChecked(b);
105 void TrayIcon::showManageInvitations()
107 ManageInvitationsDialog invMngDlg(0);
108 invMngDlg.exec();
111 #include "trayicon.moc"