3 Copyright (C) 2008 jlh (jlh at gmx dot ch)
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2 of the License, version 3 of
8 the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 The GNU General Public License version 2 is included with the source of
20 this program under the file name COPYING. You can also get a copy on
24 #include <QSystemTrayIcon>
25 #include <QMessageBox>
33 TrayIcon::TrayIcon(QObject
*p
) : QSystemTrayIcon(p
) {
34 if (!QSystemTrayIcon::isSystemTrayAvailable()) {
35 QMessageBox::critical(NULL
, PROGRAM_NAME
" - Error",
36 PROGRAM_NAME
" cannot start, because it requires a system tray. None was detected. "
37 "(TODO: Make this work even without a system tray.)");
38 emit
requestQuitNoConfirmation();
44 // current call submenu
45 subMenu
= new QMenu("Call with unknown");
46 startAction
= subMenu
->addAction("&Start recording", this, SIGNAL(startRecording()));
47 stopAction
= subMenu
->addAction("S&top recording", this, SIGNAL(stopRecording()));
48 stopAndDeleteAction
= subMenu
->addAction("Stop recording and &delete file", this, SIGNAL(stopRecordingAndDelete()));
52 menu
->addAction("&About " PROGRAM_NAME
, this, SIGNAL(requestAbout()));
53 currentCallAction
= menu
->addMenu(subMenu
);
54 currentCallAction
->setVisible(false);
55 menu
->addAction("Open &preferences...", this, SIGNAL(requestOpenPreferences()));
56 menu
->addAction("&Browse previous calls", this, SIGNAL(requestBrowseCalls()));
58 menu
->addAction("&Exit", this, SIGNAL(requestQuit()));
61 setToolTip(PROGRAM_NAME
);
63 connect(this, SIGNAL(activated(QSystemTrayIcon::ActivationReason
)), this, SLOT(activate(QSystemTrayIcon::ActivationReason
)));
68 TrayIcon::~TrayIcon() {
73 void TrayIcon::setColor(bool color
) {
74 setIcon(QIcon(color
? ":/icon.png" : ":/icongray.png"));
78 void TrayIcon::activate(QSystemTrayIcon::ActivationReason
) {
79 contextMenu()->popup(QCursor::pos());
82 void TrayIcon::startedCall(const QString
&skypeName
) {
83 currentCallAction
->setText("Call with " + skypeName
);
84 currentCallAction
->setVisible(true);
85 startAction
->setEnabled(true);
86 stopAction
->setEnabled(false);
87 stopAndDeleteAction
->setEnabled(false);
90 void TrayIcon::stoppedCall() {
91 currentCallAction
->setVisible(false);
94 void TrayIcon::startedRecording() {
95 startAction
->setEnabled(false);
96 stopAction
->setEnabled(true);
97 stopAndDeleteAction
->setEnabled(true);
100 void TrayIcon::stoppedRecording() {
101 startAction
->setEnabled(true);
102 stopAction
->setEnabled(false);
103 stopAndDeleteAction
->setEnabled(false);