Commit cf7dc3d5 authored by Scott Wheeler's avatar Scott Wheeler

Make it possible to turn off system tray docking.

svn path=/trunk/kdemultimedia/juk/; revision=205249
parent 9ae1e54d
......@@ -51,16 +51,16 @@ JuK::JuK(QWidget *parent, const char *name) : KMainWindow(parent, name, WDestruc
setupLayout();
setupActions();
setupPlayer();
setupSystemTray();
readConfig();
setupSystemTray();
processArgs();
SplashScreen::finishedLoading();
}
JuK::~JuK()
{
delete(playTimer);
}
////////////////////////////////////////////////////////////////////////////////
......@@ -130,7 +130,9 @@ void JuK::setupActions()
new KAction(i18n("Delete"), "editdelete", 0, splitter, SLOT(removeSelectedItems()), actionCollection(), "removeItem");
// settings menu
restoreOnLoadAction = new KToggleAction(i18n("Restored Playlists on Load"), 0, actionCollection(), "restoreOnLoad");
restoreOnLoadAction = new KToggleAction(i18n("Restored playlists on load"), 0, actionCollection(), "restoreOnLoad");
toggleSystemTrayAction = new KToggleAction(i18n("Dock in system tray"), 0, actionCollection(), "toggleSystemTray");
connect(toggleSystemTrayAction, SIGNAL(toggled(bool)), this, SLOT(toggleSystemTray(bool)));
new KAction(i18n("Genre List Editor"), 0, this, SLOT(showGenreListEditor()), actionCollection(), "showGenreListEditor");
connect(splitter, SIGNAL(playlistChanged()), this, SLOT(playlistChanged()));
......@@ -147,15 +149,24 @@ void JuK::setupActions()
}
void JuK::setupSystemTray()
{
systemTray = new SystemTray(this, "systemTray");
systemTray->show();
connect(systemTray, SIGNAL(play()), this, SLOT(playFile()));
connect(systemTray, SIGNAL(stop()), this, SLOT(stopFile()));
connect(systemTray, SIGNAL(pause()), this, SLOT(pauseFile()));
connect(systemTray, SIGNAL(back()), this, SLOT(backFile()));
connect(systemTray, SIGNAL(forward()), this, SLOT(forwardFile()));
{
if(toggleSystemTrayAction && toggleSystemTrayAction->isChecked()) {
systemTray = new SystemTray(this, "systemTray");
systemTray->show();
connect(systemTray, SIGNAL(play()), this, SLOT(playFile()));
connect(systemTray, SIGNAL(stop()), this, SLOT(stopFile()));
connect(systemTray, SIGNAL(pause()), this, SLOT(pauseFile()));
connect(systemTray, SIGNAL(back()), this, SLOT(backFile()));
connect(systemTray, SIGNAL(forward()), this, SLOT(forwardFile()));
if(player.paused())
systemTray->slotPause();
else if(player.playing())
systemTray->slotPlay();
}
else
systemTray = 0;
}
void JuK::setupPlayer()
......@@ -192,6 +203,19 @@ void JuK::processArgs()
splitter->open(files);
}
/**
* These are settings that need to be know before setting up the GUI.
*/
void JuK::readSettings()
{
KConfig *config = KGlobal::config();
{ // general settings
KConfigGroupSaver saver(config, "Settings");
restore = config->readBoolEntry("RestoreOnLoad", true);
}
}
void JuK::readConfig()
{
// Automagically save and restore many window settings.
......@@ -215,18 +239,15 @@ void JuK::readConfig()
showEditorAction->setChecked(showEditor);
splitter->setEditorVisible(showEditor);
}
if(restoreOnLoadAction)
restoreOnLoadAction->setChecked(restore);
}
void JuK::readSettings()
{
KConfig *config = KGlobal::config();
{ // general settings
KConfigGroupSaver saver(config, "Settings");
restore = config->readBoolEntry("RestoreOnLoad", true);
bool dockInSystemTray = config->readBoolEntry("DockInSystemTray", true);
toggleSystemTrayAction->setChecked(dockInSystemTray);
}
if(restoreOnLoadAction)
restoreOnLoadAction->setChecked(restore);
}
void JuK::saveConfig()
......@@ -247,6 +268,8 @@ void JuK::saveConfig()
KConfigGroupSaver saver(config, "Settings");
if(restoreOnLoadAction)
config->writeEntry("RestoreOnLoad", restoreOnLoadAction->isChecked());
if(toggleSystemTrayAction)
config->writeEntry("DockInSystemTray", toggleSystemTrayAction->isChecked());
}
}
......@@ -301,7 +324,8 @@ void JuK::playFile()
pauseAction->setEnabled(true);
stopAction->setEnabled(true);
playTimer->start(pollInterval);
systemTray->slotPlay();
if(systemTray)
systemTray->slotPlay();
}
}
else if(player.playing())
......@@ -315,7 +339,8 @@ void JuK::pauseFile()
playTimer->stop();
player.pause();
pauseAction->setEnabled(false);
systemTray->slotPause();
if(systemTray)
systemTray->slotPause();
}
void JuK::stopFile()
......@@ -334,8 +359,9 @@ void JuK::stopFile()
splitter->stop();
statusLabel->clear();
systemTray->slotStop();
if(systemTray)
systemTray->slotStop();
}
void JuK::backFile()
......@@ -358,6 +384,16 @@ void JuK::showGenreListEditor()
editor->exec();
}
void JuK::toggleSystemTray(bool enabled)
{
if(enabled && !systemTray)
setupSystemTray();
else if(!enabled && systemTray) {
delete(systemTray);
systemTray = 0;
}
}
////////////////////////////////////////////////////////////////////////////////
// additional player slots
////////////////////////////////////////////////////////////////////////////////
......@@ -446,7 +482,8 @@ void JuK::playFile(const QString &file)
statusLabel->setPlayingItemInfo(splitter->playingTrack(), splitter->playingArtist(), splitter->playingList());
systemTray->slotPlay();
if(systemTray)
systemTray->slotPlay();
}
else
stopFile();
......
......@@ -52,13 +52,15 @@ private:
void setupActions();
void setupPlayer();
void setupSystemTray();
void processArgs();
void readConfig();
/**
* This is only separate from readConfig() because it is useful to call it
* before we construct the splitter.
* readSettings() is separate from readConfig() in that it contains settings
* that need to be read before the GUI is setup.
*/
void readSettings();
void readConfig();
void saveConfig();
virtual bool queryClose();
......@@ -79,6 +81,7 @@ private slots:
// settings menu
void showGenreListEditor();
void toggleSystemTray(bool enabled);
// additional player slots
void trackPositionSliderClick();
......@@ -118,6 +121,7 @@ private:
KToggleAction *restoreOnLoadAction;
SliderAction *sliderAction;
KToggleAction *randomPlayAction;
KToggleAction *toggleSystemTrayAction;
KAction *playAction;
KAction *pauseAction;
......
......@@ -46,6 +46,7 @@
<Menu name="settings" noMerge="1"><text>&amp;Settings</text>
<Action name="showGenreListEditor"/>
<Action name="restoreOnLoad"/>
<Action name="toggleSystemTray"/>
</Menu>
</MenuBar>
......
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