Commit f826cc34 authored by Michael Pyne's avatar Michael Pyne

Improve the UI for the recently-added album random play feature. Now there is

a toggle sub-menu allowing you to select one of the three different forms of
random play (None, Normal, by Album).  The system tray icon has also been
updated.

svn path=/trunk/kdemultimedia/juk/; revision=327361
parent 0e7b80af
......@@ -104,7 +104,14 @@ void JuK::setupActions()
KStdAction::clear(kapp, SLOT(clear()), actions());
KStdAction::selectAll(kapp, SLOT(selectAll()), actions());
m_randomPlayAction = new KToggleAction(i18n("&Random Play"), 0, actions(), "randomPlay");
KToggleAction *ka = new KRadioAction(i18n("&Album Random Play"), 0, actions(), "albumRandomPlay");
ka->setExclusiveGroup("randomPlayGroup");
ka = new KRadioAction(i18n("Option for disabled random play mode", "&Disabled"), 0, actions(), "disableRandomPlay");
ka->setExclusiveGroup("randomPlayGroup");
m_randomPlayAction = new KRadioAction(i18n("&Random Play"), 0, actions(), "randomPlay");
m_randomPlayAction->setExclusiveGroup("randomPlayGroup");
new KAction(i18n("&Play"), "player_play", 0, m_player, SLOT(play()), actions(), "play");
new KAction(i18n("P&ause"), "player_pause", 0, m_player, SLOT(pause()), actions(), "pause");
......@@ -113,8 +120,6 @@ void JuK::setupActions()
new KToolBarPopupAction(i18n("Previous &Track"), "player_start", KShortcut(), m_player, SLOT(back()), actions(), "back");
new KAction(i18n("&Next Track"), "player_end", KShortcut(), m_player, SLOT(forward()), actions(), "forward");
new KToggleAction(i18n("&Loop Playlist"), 0, KShortcut(), actions(), "loopPlaylist");
KToggleAction *ka = new KToggleAction(i18n("Album Random Play"), 0, actions(), "albumRandomPlay");
connect (m_randomPlayAction, SIGNAL(toggled(bool)), ka, SLOT(setEnabled(bool)));
// the following are not visible by default
......@@ -249,12 +254,15 @@ void JuK::readConfig()
m_sliderAction->volumeSlider()->setVolume(volume);
}
bool randomPlay = playerConfig.readBoolEntry("RandomPlay", false);
m_randomPlayAction->setChecked(randomPlay);
ActionCollection::action<KToggleAction>("albumRandomPlay")->setEnabled(randomPlay);
// Default to no random play
bool albumRandomPlay = playerConfig.readBoolEntry("AlbumRandomPlay", false);
ActionCollection::action<KToggleAction>("albumRandomPlay")->setChecked(albumRandomPlay);
ActionCollection::action<KToggleAction>("disableRandomPlay")->setChecked(true);
QString randomPlayMode = playerConfig.readEntry("RandomPlay", "Disabled");
if(randomPlayMode == "true" || randomPlayMode == "Normal")
m_randomPlayAction->setChecked(true);
else if(randomPlayMode == "AlbumRandomPlay")
ActionCollection::action<KToggleAction>("albumRandomPlay")->setChecked(true);
bool loopPlaylist = playerConfig.readBoolEntry("LoopPlaylist", false);
ActionCollection::action<KToggleAction>("loopPlaylist")->setChecked(loopPlaylist);
......@@ -290,7 +298,12 @@ void JuK::saveConfig()
playerConfig.writeEntry("LoopPlaylist", a->isChecked());
a = ActionCollection::action<KToggleAction>("albumRandomPlay");
playerConfig.writeEntry("AlbumRandomPlay", a->isChecked() && a->isEnabled());
if(a->isChecked())
playerConfig.writeEntry("RandomPlay", "AlbumRandomPlay");
else if(m_randomPlayAction->isChecked())
playerConfig.writeEntry("RandomPlay", "Normal");
else
playerConfig.writeEntry("RandomPlay", "Disabled");
// general settings
......
<!DOCTYPE kpartgui>
<kpartgui name="juk">
<kpartgui name="juk" version="3">
<MenuBar>
<Menu name="file" noMerge="1"><text>&amp;File</text>
<Action name="file_new"/>
......@@ -34,8 +34,12 @@
<Action name="viewModeMenu"/>
</Menu>
<Menu name="player"><text>&amp;Player</text>
<Action name="randomPlay"/>
<Action name="albumRandomPlay"/>
<Menu name="randomPlayMenu"><text>&amp;Random Play</text>
<Action name="disableRandomPlay"/>
<Action name="randomPlay"/>
<Action name="albumRandomPlay"/>
</Menu>
<Action name="loopPlaylist"/>
<Separator/>
......
......@@ -395,9 +395,9 @@ void Playlist::playFirst()
void Playlist::playNext()
{
bool random = action("randomPlay") && action<KToggleAction>("randomPlay")->isChecked();
bool loop = action("loopPlaylist") && action<KToggleAction>("loopPlaylist")->isChecked();
bool albumRandom = action("albumRandomPlay") && action<KToggleAction>("albumRandomPlay")->isChecked();
bool random = albumRandom || (action("randomPlay") && action<KToggleAction>("randomPlay")->isChecked());
Playlist *list = m_playingItem ? m_playingItem->playlist() : this;
......
......@@ -95,7 +95,14 @@ SystemTray::SystemTray(QWidget *parent, const char *name) : KSystemTray(parent,
cm->insertSeparator();
action("randomPlay")->plug(cm);
// Pity the actionCollection doesn't keep track of what sub-menus it has.
KActionMenu *menu = new KActionMenu(i18n("&Random Play"), this);
menu->insert(action("disableRandomPlay"));
menu->insert(action("randomPlay"));
menu->insert(action("albumRandomPlay"));
menu->plug(cm);
action("togglePopups")->plug(cm);
if(PlayerManager::instance()->playing())
......@@ -236,6 +243,9 @@ bool SystemTray::buttonsToLeft() const
QRect bounds = KGlobalSettings::desktopGeometry(center);
int middle = bounds.center().x();
kdDebug() << "Current geometry is " << geometry() << endl;
kdDebug() << "Current global position is " << mapToGlobal(pos()) << endl;
// This seems to accurately guess what side of the icon that
// KPassivePopup will popup on.
return((center.x() - (width() / 2)) < middle);
......
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