3
// Copyright (C) 2000 Neil Stevens <multivac@fcmail.com>
4
// Copyright (C) 1999 Charles Samuels <charles@kde.org>
6
// Permission is hereby granted, free of charge, to any person obtaining a copy
7
// of this software and associated documentation files (the "Software"), to deal
8
// in the Software without restriction, including without limitation the rights
9
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
// copies of the Software, and to permit persons to whom the Software is
11
// furnished to do so, subject to the following conditions:
13
// The above copyright notice and this permission notice shall be included in
14
// all copies or substantial portions of the Software.
16
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
// THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20
// AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
// Except as contained in this notice, the name(s) of the author(s) shall not be
24
// used in advertising or otherwise to promote the sale, use or other dealings
25
// in this Software without prior written authorization from the author(s).
32
#include <noatunapp.h>
33
#include "noatunpref.h"
36
#include "kitsystemtray.h"
37
#include "noatunstdaction.h"
42
#include <kfiledialog.h>
44
#include <kiconloader.h>
46
#include <kpixmapeffect.h>
47
#include <kpopupmenu.h>
48
#include <kstdaction.h>
53
NoatunSystray *NoatunSystray::jasonkb = 0;
55
NoatunSystray::NoatunSystray()
61
KStdAction::quit(napp, SLOT(quit()), actionCollection());
62
KStdAction::open(napp, SLOT(fileOpen()), actionCollection());
63
KStdAction::preferences(napp, SLOT(preferences()), actionCollection());
64
mBack = NoatunStdAction::back(actionCollection(), "back");
65
mStop = NoatunStdAction::stop(actionCollection(), "stop");
66
mPlay = NoatunStdAction::playpause(actionCollection(), "play");
67
mForward = NoatunStdAction::forward(actionCollection(), "forward");
68
mPlaylist = NoatunStdAction::playlist(actionCollection(), "show_playlist");
69
mLoop = new KAction(i18n("L&oop Style"), 0,napp->player(), SLOT(loop()), actionCollection(), "loop_style");
70
NoatunStdAction::effects(actionCollection(), "effects");
71
NoatunStdAction::equalizer(actionCollection(), "equalizer");
73
createGUI("systrayui.rc");
75
mTray = new KitSystemTray("tray", this);
77
trayDefault = new QPixmap(SmallIcon("noatuntray"));
78
trayStatus = new QPixmap(SmallIcon("noatuntraystop"));
79
mTray->changeTitle(*trayDefault, "Noatun");
80
showingTrayStatus = false;
82
QTimer *t = new QTimer(this);
83
connect(t, SIGNAL(timeout(void)), this, SLOT(blinkTimer(void)) );
86
connect(napp->player(), SIGNAL(playing()), this, SLOT(slotPlaying()));
87
connect(napp->player(), SIGNAL(stopped()), this, SLOT(slotStopped()));
88
connect(napp->player(), SIGNAL(paused()), this, SLOT(slotPaused()));
89
connect(napp->player(), SIGNAL(loopTypeChange(int)), this, SLOT(changeLoopType(int)));
90
napp->player()->handleButtons();
92
changeLoopType(Player::None);
97
NoatunSystray::~NoatunSystray()
101
napp->player()->showInterfaces();
104
void NoatunSystray::init(void)
106
YHModule *module = new YHModule(this);
110
void NoatunSystray::setBlink(Blink b)
116
void NoatunSystray::setTip(bool b)
120
QToolTip::add(mTray, tipText);
122
QToolTip::remove(mTray);
125
void NoatunSystray::closeEvent(QCloseEvent*)
130
void NoatunSystray::slotPlaying()
132
mStop->setEnabled(true);
133
changeTray(SmallIcon("noatuntrayplay"));
134
setTipText(napp->player()->current()->title());
137
void NoatunSystray::slotStopped()
139
if(!napp->player()->current()) return;
140
changeTray(SmallIcon("noatuntraystop"));
141
setTipText(i18n("Stopped"));
144
void NoatunSystray::slotPaused()
146
changeTray(SmallIcon("noatuntraypause"));
147
setTipText(i18n("%1 - Paused").arg(napp->player()->current()->title()));
150
void NoatunSystray::changeLoopType(int t)
155
mLoop->setIconSet(QIconSet(SmallIcon("nloopnone")));
156
mLoop->setText(i18n("No looping"));
159
mLoop->setIconSet(QIconSet(SmallIcon("nloopsong")));
160
mLoop->setText(i18n("Song looping"));
162
case Player::Playlist:
163
mLoop->setIconSet(QIconSet(SmallIcon("nloopplaylist")));
164
mLoop->setText(i18n("Playlist looping"));
168
void NoatunSystray::changeTray(const QPixmap &pm)
171
trayStatus = new QPixmap(pm);
172
if(showingTrayStatus) blinkTimer();
175
void NoatunSystray::blinkTimer(void)
180
showingTrayStatus ^= true;
183
showingTrayStatus = true;
186
showingTrayStatus = false;
190
if(showingTrayStatus)
191
mTray->setPixmap(*trayStatus);
193
mTray->setPixmap(*trayDefault);
196
void NoatunSystray::setTipText(QString text)
199
if(tip) QToolTip::add(mTray, tipText);
202
#include "systray.moc"