Commit 4a611637 authored by Scott Wheeler's avatar Scott Wheeler

Add the possibility to have track announcements via passive popups.

Patch from Stephen Douglas. Thanks Stephen!
CCMAIL:stephen_douglas@yahoo.com

svn path=/trunk/kdemultimedia/juk/; revision=213541
parent da9b4a47
......@@ -150,16 +150,19 @@ void JuK::setupActions()
m_toggleDockOnCloseAction = new KToggleAction(i18n("Stay in System Tray on Close"), 0, actionCollection(), "dockOnClose");
new KAction(i18n("Genre List Editor..."), 0, this, SLOT(slotShowGenreListEditor()), actionCollection(), "showGenreListEditor");
m_togglePopupsAction = new KToggleAction(i18n("Popup Track Announcement"), 0, this, 0, actionCollection(), "togglePopups");
KStdAction::keyBindings(this, SLOT(slotEditKeys()), actionCollection());
new KAction(i18n("Genre List Editor..."), 0, this, SLOT(slotShowGenreListEditor()), actionCollection(), "showGenreListEditor");
m_outputSelectAction = Player::playerSelectAction(actionCollection());
if(m_outputSelectAction) {
m_outputSelectAction->setCurrentItem(0);
connect(m_outputSelectAction, SIGNAL(activated(int)), this, SLOT(slotSetOutput(int)));
}
KStdAction::keyBindings(this, SLOT(slotEditKeys()), actionCollection());
// just in the toolbar
m_sliderAction = new SliderAction(i18n("Track Position"), actionCollection(), "trackPositionAction");
......@@ -287,14 +290,12 @@ void JuK::readConfig()
KConfig *config = KGlobal::config();
{ // m_player settings
KConfigGroupSaver saver(config, "Player");
if(m_sliderAction && m_sliderAction->getVolumeSlider()) {
if(m_sliderAction->getVolumeSlider()) {
int volume = config->readNumEntry("Volume", m_sliderAction->getVolumeSlider()->maxValue());
m_sliderAction->getVolumeSlider()->setValue(volume);
}
if(m_randomPlayAction) {
bool randomPlay = config->readBoolEntry("RandomPlay", false);
m_randomPlayAction->setChecked(randomPlay);
}
bool randomPlay = config->readBoolEntry("RandomPlay", false);
m_randomPlayAction->setChecked(randomPlay);
}
{ // view settings
KConfigGroupSaver saver(config, "View");
......@@ -311,13 +312,15 @@ void JuK::readConfig()
bool dockOnClose = config->readBoolEntry("DockOnClose", true);
m_toggleDockOnCloseAction->setChecked(dockOnClose);
bool showPopups = config->readBoolEntry("TrackPopup", false);
m_togglePopupsAction->setChecked(showPopups);
if(m_outputSelectAction)
m_outputSelectAction->setCurrentItem(config->readNumEntry("MediaSystem", 0));
}
if(m_restoreOnLoadAction)
m_restoreOnLoadAction->setChecked(m_restore);
m_restoreOnLoadAction->setChecked(m_restore);
}
......@@ -337,12 +340,10 @@ void JuK::saveConfig()
}
{ // general settings
KConfigGroupSaver saver(config, "Settings");
if(m_restoreOnLoadAction)
config->writeEntry("RestoreOnLoad", m_restoreOnLoadAction->isChecked());
if(m_toggleSystemTrayAction)
config->writeEntry("DockInSystemTray", m_toggleSystemTrayAction->isChecked());
if(m_toggleDockOnCloseAction)
config->writeEntry("DockOnClose", m_toggleDockOnCloseAction->isChecked());
config->writeEntry("RestoreOnLoad", m_restoreOnLoadAction->isChecked());
config->writeEntry("DockInSystemTray", m_toggleSystemTrayAction->isChecked());
config->writeEntry("DockOnClose", m_toggleDockOnCloseAction->isChecked());
config->writeEntry("TrackPopup", m_togglePopupsAction->isChecked());
if(m_outputSelectAction)
config->writeEntry("MediaSystem", m_outputSelectAction->currentItem());
}
......
......@@ -150,6 +150,7 @@ private:
KToggleAction *m_randomPlayAction;
KToggleAction *m_toggleSystemTrayAction;
KToggleAction *m_toggleDockOnCloseAction;
KToggleAction *m_togglePopupsAction;
KSelectAction *m_outputSelectAction;
KAction *m_playAction;
......
......@@ -52,8 +52,9 @@
<Action name="restoreOnLoad"/>
<Action name="toggleSystemTray"/>
<Action name="dockOnClose"/>
<Action name="togglePopups"/>
<Action name="outputSelect"/>
<Separator />
<Separator/>
<Action name="options_configure_keybinding"/>
</Menu>
</MenuBar>
......
......@@ -18,6 +18,12 @@
#include <kiconloader.h>
#include <kpopupmenu.h>
#include <klocale.h>
#include <kpassivepopup.h>
#include <kaction.h>
#include <kmainwindow.h>
#include <qhbox.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qtimer.h>
#include <qtooltip.h>
......@@ -28,22 +34,33 @@
// public methods
////////////////////////////////////////////////////////////////////////////////
SystemTray::SystemTray(QWidget *parent, const char *name) : KSystemTray(parent, name), m_blinkStatus(false)
SystemTray::SystemTray(KMainWindow *parent, const char *name) : KSystemTray(parent, name), m_blinkStatus(false), m_parent (parent), m_popup(0L)
{
m_blinkTimer = new QTimer(this, "blinktimer");
m_appPix = SmallIcon("juk");
m_playPix = SmallIcon("player_play");
m_pausePix = SmallIcon("player_pause");
m_appPix = SmallIcon("juk");
m_playPix = SmallIcon("player_play");
m_pausePix = SmallIcon("player_pause");
m_backPix = SmallIcon("player_start");
m_forwardPix = SmallIcon("player_end");
setPixmap(m_appPix);
KPopupMenu *cm = contextMenu();
cm->insertItem(m_playPix, i18n("Play"), this, SIGNAL(signalPlay()));
cm->insertItem(m_pausePix, i18n("Pause"), this, SIGNAL(signalPause()));
cm->insertItem(SmallIcon("player_stop"), i18n("Stop"), this, SIGNAL(signalStop()));
cm->insertItem(SmallIcon("player_start"), i18n("Back"), this, SIGNAL(signalBack()));
cm->insertItem(SmallIcon("player_end" ), i18n("Forward"), this, SIGNAL(signalForward()));
cm->insertItem(m_backPix, i18n("Back"), this, SIGNAL(signalBack()));
cm->insertItem(m_forwardPix, i18n("Forward"), this, SIGNAL(signalForward()));
cm->insertSeparator();
// Get a pointer to the togglePopups action, and if it exists, plug it into our popup menu
KToggleAction *togglePopupsAction = dynamic_cast<KToggleAction*>(m_parent->actionCollection()->action("togglePopups"));
if(togglePopupsAction)
togglePopupsAction->plug(cm);
}
SystemTray::~SystemTray()
......@@ -59,6 +76,8 @@ void SystemTray::slotNewSong(const QString& songName)
{
QToolTip::remove(this);
QToolTip::add(this, songName);
createPopup(songName, true);
}
void SystemTray::slotStop()
......@@ -66,6 +85,50 @@ void SystemTray::slotStop()
m_blinkTimer->stop();
setPixmap(m_appPix);
QToolTip::remove(this);
delete m_popup;
m_popup = 0;
}
////////////////////////////////////////////////////////////////////////////////
// private methods
////////////////////////////////////////////////////////////////////////////////
void SystemTray::createPopup(const QString &songName, bool addButtons)
{
// Get a pointer to the togglePopups action
KToggleAction *togglePopupsAction = dynamic_cast<KToggleAction*>(m_parent->actionCollection()->action("togglePopups"));
// If the action exists and it's checked, do our stuff
if(togglePopupsAction && togglePopupsAction->isChecked()) {
delete m_popup;
m_popup = new KPassivePopup(this);
QHBox *box = new QHBox(m_popup);
// The buttons are now optional - no real reason, but it might be useful later
if(addButtons) {
QPushButton *backButton = new QPushButton(m_backPix, 0, box, "popup_back");
backButton->setFlat(true);
connect(backButton, SIGNAL(clicked()), m_parent, SLOT(slotBack()));
}
QLabel *l = new QLabel(songName, box);
l->setMargin(3);
if(addButtons) {
QPushButton *forwardButton = new QPushButton (m_forwardPix, 0, box, "popup_forward");
forwardButton->setFlat(true);
connect(forwardButton, SIGNAL(clicked()), m_parent, SLOT(slotForward()));
}
m_popup->setView(box);
// We don't want an autodelete popup. There are times when it will need to be hidden before the timeout.
m_popup->setAutoDelete(false);
m_popup->show();
}
}
#include "systemtray.moc"
/***************************************************************************
systray.cpp - description
-------------------
copyright : (C) 2002 by Daniel Molkentin,
copyright : (C) 2002 by Daniel Molkentin,
email : molkentin@kde.org
***************************************************************************/
......@@ -22,21 +22,23 @@
class QTimer;
class QPimap;
class KPassivePopup;
class KMainWindow;
class SystemTray : public KSystemTray
{
Q_OBJECT
public:
SystemTray(QWidget *parent = 0, const char* name = 0);
public:
SystemTray(KMainWindow *parent = 0, const char *name = 0);
virtual ~SystemTray();
public slots:
void slotNewSong(const QString& songName);
void slotPlay() { setPixmap(m_playPix); }
void slotPause() { setPixmap(m_pausePix); }
void slotStop();
signals:
void signalPlay();
void signalStop();
......@@ -45,12 +47,20 @@ signals:
void signalBack();
private:
void createPopup(const QString &songName, bool addButtons = true);
QTimer *m_blinkTimer;
bool m_blinkStatus;
QPixmap m_playPix;
QPixmap m_pausePix;
QPixmap m_currentPix;
QPixmap m_backPix;
QPixmap m_forwardPix;
QPixmap m_appPix;
KMainWindow *m_parent;
KPassivePopup *m_popup;
QLabel *m_currentLabel;
};
#endif // SYSTEMTRAY_H
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment