krfb
trayicon.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "trayicon.h"
00019
00020 #include <kstandardaction.h>
00021 #include <klocale.h>
00022 #include <kdialog.h>
00023 #include <kmenu.h>
00024 #include <kglobal.h>
00025 #include <kactioncollection.h>
00026 #include <kaboutapplicationdialog.h>
00027
00028 #include "manageinvitationsdialog.h"
00029 #include "invitedialog.h"
00030
00031
00032 TrayIcon::TrayIcon(KDialog *d)
00033 : KSystemTrayIcon(d),
00034 quitting(false)
00035 {
00036 setIcon(KIcon("krfb").pixmap(22, 22, KIcon::Disabled));
00037
00038 setToolTip(i18n("Desktop Sharing - disconnected"));
00039
00040
00041
00042
00043
00044
00045
00046
00047 enableControlAction = new KToggleAction(i18n("Enable Remote Control"), actionCollection());
00048 enableControlAction->setCheckedState(KGuiItem(i18n("Disable Remote Control")));
00049 enableControlAction->setEnabled(false);
00050 actionCollection()->addAction("enable_control", enableControlAction);
00051 connect(enableControlAction, SIGNAL(toggled(bool)), SIGNAL(enableDesktopControl(bool)));
00052 contextMenu()->addAction(actionCollection()->action("enable_control"));
00053
00054 contextMenu()->addSeparator();
00055 contextMenu()->addAction(KStandardAction::aboutApp(this, SLOT(showAbout()), actionCollection()));
00056
00057 show();
00058 }
00059
00060 TrayIcon::~TrayIcon()
00061 {
00062 }
00063
00064 void TrayIcon::showAbout()
00065 {
00066 KAboutApplicationDialog(KGlobal::mainComponent().aboutData()).exec();
00067 }
00068
00069 void TrayIcon::prepareQuit()
00070 {
00071 quitting = true;
00072 }
00073
00074 void TrayIcon::showConnectedMessage(const QString &host)
00075 {
00076
00077 setIcon(KIcon("krfb"));
00078 KPassivePopup::message(i18n("Desktop Sharing"),
00079 i18n("The remote user has been authenticated and is now connected."),
00080 KIcon("krfb").pixmap(22, 22),
00081 this);
00082 setToolTip(i18n("Desktop Sharing - connected with %1", host));
00083 }
00084
00085 void TrayIcon::showDisconnectedMessage()
00086 {
00087 if (quitting)
00088 return;
00089
00090 setToolTip(i18n("Desktop Sharing - disconnected"));
00091 setIcon(KIcon("krfb").pixmap(22, 22, KIcon::Disabled));
00092 KPassivePopup *p = KPassivePopup::message(i18n("Desktop Sharing"),
00093 i18n("The remote user has closed the connection."),
00094 KIcon("krfb").pixmap(22, 22, KIcon::Disabled),
00095 this);
00096 connect(p, SIGNAL(hidden()), this, SIGNAL(diconnectedMessageDisplayed()));
00097 }
00098
00099 void TrayIcon::setDesktopControlSetting(bool b)
00100 {
00101 enableControlAction->setEnabled(true);
00102 enableControlAction->setChecked(b);
00103 }
00104
00105 void TrayIcon::showManageInvitations()
00106 {
00107 ManageInvitationsDialog invMngDlg(0);
00108 invMngDlg.exec();
00109 }
00110
00111 #include "trayicon.moc"