2 Kscd - A simple cd player for the KDE Project
6 Copyright (c) 1997 Bernd Johannes Wuebben <wuebben@math.cornell.edu>
7 Copyright (c) 2002 Aaron J. Seigo <aseigo@kde.org>
8 Copyright (c) 2004 Alexander Kern <alex.kern@gmx.de>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2, or (at your option)
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28 #include <QGridLayout>
31 #include <QCloseEvent>
36 // CDDB support via libkcddb
37 #include <libkcddb/kcddb.h>
38 #include <libkcddb/client.h>
41 #include <QPushButton>
43 #include <qapplication.h>
45 #include <qscrollbar.h>
47 #include <q3tabdialog.h>
52 #include "configWidget.h"
53 #include <kapplication.h>
54 #include <kconfigdialog.h>
55 #include <k3process.h>
56 #include <krandomsequence.h>
57 #include <kglobalaccel.h>
58 #include <ksessionmanager.h>
63 class KActionCollection
;
66 class KSCD
: public QWidget
, Ui::kscdPanelDlg
, public KSessionManager
{
69 Q_CLASSINFO("D-Bus Interface", "org.kde.KSCD")
71 public /*Q_SLOTS*/slots
:
72 Q_SCRIPTABLE
bool playing();
73 Q_SCRIPTABLE
void play() { playClicked(); }
74 Q_SCRIPTABLE
void stop() { stopClicked(); }
75 Q_SCRIPTABLE
void previous() { prevClicked(); }
76 Q_SCRIPTABLE
void next() { nextClicked(); }
77 Q_SCRIPTABLE
void jumpTo(int seconds
) { jumpToTime(seconds
); }
78 Q_SCRIPTABLE
void eject() { ejectClicked(); }
79 Q_SCRIPTABLE
void quit() { quitClicked(); }
80 Q_SCRIPTABLE
void toggleLoop() { loopClicked(); }
81 Q_SCRIPTABLE
void toggleShuffle() { randomClicked(); }
82 Q_SCRIPTABLE
void toggleTimeDisplay() { cycleplaytimemode(); }
83 Q_SCRIPTABLE
void cddbDialog() { CDDialogSelected(); }
84 Q_SCRIPTABLE
void optionDialog() { showConfig(); }
85 Q_SCRIPTABLE
void setTrack(int t
) { trackSelected(t
> 0 ? t
- 1 : 0); }
86 Q_SCRIPTABLE
void volumeDown() { decVolume(); }
87 Q_SCRIPTABLE
void volumeUp() { incVolume(); }
88 Q_SCRIPTABLE
void setVolume(int v
);
89 Q_SCRIPTABLE
void setDevice(const QString
& dev
);
90 Q_SCRIPTABLE
int getVolume() { return Prefs::volume(); }
91 Q_SCRIPTABLE
int currentTrack();
92 Q_SCRIPTABLE
int currentTrackLength();
93 Q_SCRIPTABLE
int currentPosition();
94 Q_SCRIPTABLE
int getStatus();
95 Q_SCRIPTABLE QString
currentTrackTitle();
96 Q_SCRIPTABLE QString
currentAlbum();
97 Q_SCRIPTABLE QString
currentArtist();
98 Q_SCRIPTABLE QStringList
trackList();
101 explicit KSCD(QWidget
*parent
= 0);
103 virtual bool saveState(QSessionManager
& sm
);
105 void setDocking(bool dock
);
106 void setDevicePaths();
109 void tooltipCurrentTrackChanged(const QString
&);
113 void writeSettings();
119 void jumpToTime(int);
121 void trackSelected(int);
125 void volChanged(int);
128 void titlelabeltimeout();
129 void togglequeryled();
130 void cycleplaytimemode();
131 void showVolumeInLabel();
132 void showArtistLabel(QString
);
133 void restoreArtistLabel();
135 void randomClicked();
136 void randomChanged(bool);
138 void loopChanged(bool);
140 void information(QAction
*action
);
143 // mostly start up stuff
147 void setLEDs(int seconds
);
148 void resetTimeSlider(bool enabled
);
150 void closeEvent(QCloseEvent
*e
);
151 void keyPressEvent(QKeyEvent
*e
);
152 bool event(QEvent
*e
);
154 void populateSongList();
155 void updateConfigDialog(configWidget
*widget
);
158 KConfigDialog
*configDialog
;
161 QTimer titlelabeltimer
;
162 QTimer queryledtimer
;
166 * Info from CDDB, and exploded versions thereof.
168 KCDDB::CDInfo cddbInfo
;
170 KActionCollection
*m_actions
;
171 KToggleAction
*m_togglePopupsAction
;
172 DockWidget
*m_dockWidget
;
178 void CDDialogSelected();
180 void setCDInfo(KCDDB::CDInfo
);
181 void lookupCDDBDone(KCDDB::Result
);
182 void trackChanged(unsigned);
183 void trackPosition(unsigned);
184 void discChanged(unsigned);
185 void discInformation(KCompactDisc::DiscInfo
);
186 void discStatusChanged(KCompactDisc::DiscStatus
);
188 void configureKeys();
191 void timeSliderPressed();
192 void timeSliderReleased();
193 void timeSliderMoved(int seconds
);