26 #include <KAboutApplicationDialog>
27 #include <KActionCollection>
32 #include <KStandardAction>
39 ClientActions(
RfbClient *client, KMenu *menu, QAction *before);
40 virtual ~ClientActions();
45 QAction *m_disconnectAction;
46 QAction *m_enableControlAction;
50 ClientActions::ClientActions(
RfbClient* client, KMenu* menu, QAction* before)
53 m_title = m_menu->addTitle(client->
name(), before);
55 m_disconnectAction =
new KAction(i18n(
"Disconnect"), m_menu);
56 m_menu->insertAction(before, m_disconnectAction);
58 QObject::connect(m_disconnectAction, SIGNAL(triggered()), client, SLOT(closeConnection()));
61 m_enableControlAction =
new KToggleAction(i18n(
"Enable Remote Control"), m_menu);
63 m_menu->insertAction(before, m_enableControlAction);
65 QObject::connect(m_enableControlAction, SIGNAL(triggered(
bool)),
66 client, SLOT(setControlEnabled(
bool)));
67 QObject::connect(client, SIGNAL(controlEnabledChanged(
bool)),
68 m_enableControlAction, SLOT(setChecked(
bool)));
70 m_enableControlAction = NULL;
73 m_separator = m_menu->insertSeparator(before);
76 ClientActions::~ClientActions()
80 m_menu->removeAction(m_title);
83 m_menu->removeAction(m_disconnectAction);
84 delete m_disconnectAction;
86 if (m_enableControlAction) {
87 m_menu->removeAction(m_enableControlAction);
88 delete m_enableControlAction;
91 m_menu->removeAction(m_separator);
100 setIconByPixmap(KIcon(
"krfb").pixmap(22, 22, KIcon::Disabled));
102 setToolTipTitle(i18n(
"Desktop Sharing - disconnected"));
103 setCategory(KStatusNotifierItem::ApplicationStatus);
110 m_aboutAction = KStandardAction::aboutApp(
this, SLOT(
showAbout()), actionCollection());
111 contextMenu()->addAction(m_aboutAction);
118 if (m_clientActions.isEmpty()) {
119 setIconByName(
"krfb");
120 setToolTipTitle(i18n(
"Desktop Sharing - connected with %1", client->
name()));
121 setStatus(KStatusNotifierItem::Active);
123 setToolTipTitle(i18n(
"Desktop Sharing - connected"));
126 m_clientActions[client] =
new ClientActions(client, contextMenu(), m_aboutAction);
133 ClientActions *actions = m_clientActions.take(client);
136 if (m_clientActions.isEmpty()) {
137 setIconByPixmap(KIcon(
"krfb").pixmap(22, 22, KIcon::Disabled));
138 setToolTipTitle(i18n(
"Desktop Sharing - disconnected"));
139 setStatus(KStatusNotifierItem::Passive);
140 }
else if (m_clientActions.size() == 1) {
141 RfbClient *client = m_clientActions.constBegin().key();
142 setToolTipTitle(i18n(
"Desktop Sharing - connected with %1", client->
name()));
148 KDialog *dlg =
new KAboutApplicationDialog(KGlobal::mainComponent().aboutData());
149 dlg->setAttribute(Qt::WA_DeleteOnClose,
true);
153 #include "trayicon.moc"
void onClientConnected(RfbClient *client)
static bool controlCanBeEnabled()
void onClientDisconnected(RfbClient *client)
static RfbServerManager * instance()
virtual QString name() const
Returns a name for the client, to be shown to the user.
TrayIcon(QWidget *mainWindow)