juk.cpp 21.1 KB
Newer Older
1 2 3 4 5
/***************************************************************************
                          juk.cpp  -  description
                             -------------------
    begin                : Mon Feb  4 23:40:41 EST 2002
    copyright            : (C) 2002 by Scott Wheeler
6
    email                : wheeler@kde.org
7
***************************************************************************/
8 9 10 11 12 13 14 15 16 17

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

18 19
#include <config.h>

20 21 22 23 24 25 26
#include <kcmdlineargs.h>
#include <kstatusbar.h>
#include <kdebug.h>
#include <kmessagebox.h>

#include <qslider.h>

27 28 29 30 31 32 33
#include "juk.h"
#include "slideraction.h"
#include "statuslabel.h"
#include "splashscreen.h"
#include "systemtray.h"
#include "keydialog.h"
#include "tagguesserconfigdlg.h"
34
#include "filerenamerconfigdlg.h"
35
#include "actioncollection.h"
36
#include "cache.h"
37

38 39
using namespace ActionCollection;

40 41 42 43
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////

Scott Wheeler's avatar
Scott Wheeler committed
44 45
JuK::JuK(QWidget *parent, const char *name) :
    KMainWindow(parent, name, WDestructiveClose),
46
    m_player(PlayerManager::instance()),
47
    m_shuttingDown(false)
48
{
49 50
    // Expect segfaults if you change this order.

51
    readSettings();
52

53
    if(m_showSplash && !m_startDocked) {
54 55 56 57
	SplashScreen::instance()->show();
	kapp->processEvents();
    }

58
    setupActions();
59 60
    setupLayout();
    setupSplitterConnections();
61
    slotPlaylistChanged();
62
    readConfig();
63
    setupSystemTray();
64
    setupGlobalAccels();
65
    processArgs();
66

67 68
    m_player->setPlaylistInterface(m_splitter);

69
    SplashScreen::finishedLoading();
Scott Wheeler's avatar
Scott Wheeler committed
70
    QTimer::singleShot(0, CollectionList::instance(), SLOT(slotCheckCache()));
71 72

    m_sliderAction->slotUpdateOrientation();
73 74 75 76
}

JuK::~JuK()
{
77

78 79
}

80 81 82 83 84
KActionCollection *JuK::actionCollection() const
{
    return ActionCollection::actions();
}

85 86 87 88
////////////////////////////////////////////////////////////////////////////////
// public slots
////////////////////////////////////////////////////////////////////////////////

89
void JuK::slotGuessTagInfoFromFile()
90
{
91 92 93 94 95 96
    m_splitter->slotGuessTagInfo(TagGuesser::FileName);
}

void JuK::slotGuessTagInfoFromInternet()
{
    m_splitter->slotGuessTagInfo(TagGuesser::MusicBrainz);
97 98
}

99 100 101 102 103
void JuK::openFile(const QString &file)
{
    m_splitter->open(file);
}

104 105 106 107 108 109
void JuK::openFile(const QStringList &files)
{
    for(QStringList::ConstIterator it = files.begin(); it != files.end(); ++it)
	openFile(*it);
}

110 111 112 113
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////

114 115
void JuK::setupLayout()
{
116
    m_splitter = new PlaylistSplitter(this, "playlistSplitter");
117
    setCentralWidget(m_splitter);
118

119
    // create status bar
120

121
    m_statusLabel = new StatusLabel(statusBar());
122

123
    statusBar()->addWidget(m_statusLabel, 1);
124

Scott Wheeler's avatar
Scott Wheeler committed
125 126
    connect(m_splitter, SIGNAL(signalSelectedPlaylistCountChanged(int)),
	    m_statusLabel, SLOT(setPlaylistCount(int)));
127 128
    connect(m_splitter, SIGNAL(signalSelectedPlaylistTimeChanged(int)),
	    m_statusLabel, SLOT(setPlaylistTime(int)));
Scott Wheeler's avatar
Scott Wheeler committed
129 130
    connect(m_statusLabel, SIGNAL(jumpButtonClicked()),
	    m_splitter, SLOT(slotSelectPlaying()));
131

132 133
    PlayerManager::instance()->setStatusLabel(m_statusLabel);

134 135
    // Needs to be here because m_splitter is not called before setupActions
    // (because PlaylistSplitter itself accesses the actionCollection)
136

137
    new KAction(i18n("&Rename File"), 0, "CTRL+r", m_splitter, SLOT(slotRenameFile()),
138
                actions(), "renameFile"); // 4
139

140
    m_splitter->setFocus();
141

142
    resize(750, 500);
143 144
}

145 146
void JuK::setupActions()
{
147
    //////////////////////////////////////////////////
148
    // file menu
149
    //////////////////////////////////////////////////
150

Scott Wheeler's avatar
Scott Wheeler committed
151
    KActionMenu *newMenu = new KActionMenu(i18n("&New"), "filenew",
152
					   actions(), "file_new");
Scott Wheeler's avatar
Scott Wheeler committed
153

154 155 156 157 158 159
    // This connection will call the
    // PlaylistSplitter::slotCreatePlaylist(const QString &) slot - this is
    // possible because the QString parameter has a default value, so the
    // slot can be called without arguments (as required by the signal's
    // signature).

Scott Wheeler's avatar
Scott Wheeler committed
160 161 162
    newMenu->insert(createSplitterAction(i18n("Empty Playlist..."),
					 SLOT(slotCreatePlaylist()), 0, 0, 0));

163
    newMenu->insert(createSplitterAction(i18n("Playlist From Folder..."),
Scott Wheeler's avatar
Scott Wheeler committed
164 165
					 SLOT(slotCreatePlaylistFromDir()), 0, 0, 0));

166
    createSplitterAction(i18n("Open..."),         SLOT(slotOpen()),              "file_open", "fileopen", "CTRL+o");
Scott Wheeler's avatar
Scott Wheeler committed
167
    createSplitterAction(i18n("Add &Folder..."),  SLOT(slotOpenDirectory()),     "openDirectory", "fileopen");
168 169 170 171 172 173
    createSplitterAction(i18n("&Rename..."),      SLOT(slotRenamePlaylist()),    "renamePlaylist");
    createSplitterAction(i18n("D&uplicate..."),   SLOT(slotDuplicatePlaylist()), "duplicatePlaylist");
    createSplitterAction(i18n("Save"),            SLOT(slotSavePlaylist()),      "file_save", "filesave", "CTRL+s");
    createSplitterAction(i18n("Save As..."),      SLOT(slotSaveAsPlaylist()),    "file_save_as", "filesaveas");
    createSplitterAction(i18n("R&emove"),         SLOT(slotDeletePlaylist()),    "deleteItemPlaylist", "edittrash");
    createSplitterAction(i18n("Reload"),          SLOT(slotReloadPlaylist()),    "reloadPlaylist", "reload");
174

175
    KStdAction::quit(this, SLOT(slotQuit()), actions());
176

177
    //////////////////////////////////////////////////
178
    // edit menu
179 180
    //////////////////////////////////////////////////

181 182 183 184
    KStdAction::cut(kapp,   SLOT(cut()),   actions());
    KStdAction::copy(kapp,  SLOT(copy()),  actions());
    KStdAction::paste(kapp, SLOT(paste()), actions());
    KStdAction::clear(kapp, SLOT(clear()), actions());
185

186
    KStdAction::selectAll(kapp, SLOT(selectAll()), actions());
187

188
    createSplitterAction(
189
	i18n("Advanced Search"), SLOT(slotAdvancedSearch()), "advancedSearch", "find", "s");
190

191
    //////////////////////////////////////////////////
192
    // view menu
193
    //////////////////////////////////////////////////
194

Scott Wheeler's avatar
Scott Wheeler committed
195
    m_showSearchAction = new KToggleAction(i18n("Show &Search Bar"), "filefind",
196
					   0, actions(), "showSearch");
Scott Wheeler's avatar
Scott Wheeler committed
197
    m_showEditorAction = new KToggleAction(i18n("Show &Tag Editor"), "edit",
198
					   0, actions(), "showEditor");
199
    m_showHistoryAction = new KToggleAction(i18n("Show &History"), "history",
200
					   0, actions(), "showHistory");
201

202
    createSplitterAction(i18n("Refresh Items"), SLOT(slotRefresh()), "refresh", "reload");
203

204
    //////////////////////////////////////////////////
205
    // play menu
206 207
    //////////////////////////////////////////////////

Scott Wheeler's avatar
Scott Wheeler committed
208
    m_randomPlayAction = new KToggleAction(i18n("&Random Play"), 0,
209
					   actions(), "randomPlay");
Scott Wheeler's avatar
Scott Wheeler committed
210

211 212 213
    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");
    new KAction(i18n("&Stop"),  "player_stop",  0, m_player, SLOT(stop()),  actions(), "stop");
Scott Wheeler's avatar
Scott Wheeler committed
214

215 216 217 218
    // m_backAction = new KToolBarPopupAction(i18n("Previous &Track"), "player_start", 0,
    //                                        this, SLOT(back()), actions(), "back");

    // TODO: switch this back to being a popup action
219

220 221
    new KAction(i18n("Previous& Track"), "player_start", 0, m_player, SLOT(back()),    actions(), "back");
    new KAction(i18n("&Next Track"),     "player_end",   0, m_player, SLOT(forward()), actions(), "forward");
222

223 224 225
    new KToggleAction(i18n("&Loop Playlist"), 0, 0, actions(), "loopPlaylist");

    // the following are not visible by default
226

227 228 229 230 231 232 233
    new KAction(i18n("Mute"),         "mute",        0, m_player, SLOT(mute()),        actions(), "mute");
    new KAction(i18n("Volume Up"),    "volumeUp",    0, m_player, SLOT(volumeUp()),    actions(), "volumeUp");
    new KAction(i18n("Volume Down"),  "volumeDown",  0, m_player, SLOT(volumeDown()),  actions(), "volumeDown");
    new KAction(i18n("Play / Pause"), "playPause",   0, m_player, SLOT(playPause()),   actions(), "playPause");
    new KAction(i18n("Seek Forward"), "seekForward", 0, m_player, SLOT(seekForward()), actions(), "seekForward");
    new KAction(i18n("Seek Back"),    "seekBack",    0, m_player, SLOT(seekBack()),    actions(), "seekBack");
    
234

235
    //////////////////////////////////////////////////
236
    // tagger menu
237 238
    //////////////////////////////////////////////////

239
    createSplitterAction(i18n("&Save"), SLOT(slotSaveTag()),
Scott Wheeler's avatar
Scott Wheeler committed
240 241 242
			 "saveItem",   "filesave", "CTRL+t");
    createSplitterAction(i18n("&Delete"), SLOT(slotDeleteSelectedItems()),
			 "removeItem", "editdelete");
243

244 245
    KActionMenu *guessMenu = new KActionMenu(i18n("&Guess Tag Information"),
					     QString::null, actions(),
Scott Wheeler's avatar
Scott Wheeler committed
246
					     "guessTag");
247

248 249 250
    guessMenu->insert(
	new KAction(i18n("From &Filename"), 0, "CTRL+f", this, SLOT(slotGuessTagInfoFromFile()),
		    actions(), "guessTagFile"));
251
#if HAVE_MUSICBRAINZ
252 253 254
    guessMenu->insert(
	new KAction(i18n("From &Internet"), 0, "CTRL+i", this, SLOT(slotGuessTagInfoFromInternet()),
		    actions(), "guessTagInternet"));
255
#endif
Scott Wheeler's avatar
Scott Wheeler committed
256

257
    //////////////////////////////////////////////////
258
    // settings menu
259 260
    //////////////////////////////////////////////////

261
    setStandardToolBarMenuEnabled(true);
262

Stephan Binner's avatar
Stephan Binner committed
263
    m_toggleSplashAction = new KToggleAction(i18n("Show Splash Screen on Startup"),
264
					     0, actions(), "showSplashScreen");
Scott Wheeler's avatar
Scott Wheeler committed
265 266

    m_toggleSystemTrayAction = new KToggleAction(i18n("&Dock in System Tray"),
267
						 0, actions(), "toggleSystemTray");
Scott Wheeler's avatar
Scott Wheeler committed
268 269

    m_toggleDockOnCloseAction = new KToggleAction(i18n("&Stay in System Tray on Close"),
270
						  0, actions(), "dockOnClose");
271

272
    m_togglePopupsAction = new KToggleAction(i18n("Popup &Track Announcement"),
273
					     0, this, 0, actions(), "togglePopups");
274

Scott Wheeler's avatar
Scott Wheeler committed
275 276
    connect(m_toggleSystemTrayAction, SIGNAL(toggled(bool)),
	    this, SLOT(slotToggleSystemTray(bool)));
277

Scott Wheeler's avatar
Scott Wheeler committed
278

279
    m_outputSelectAction = PlayerManager::playerSelectAction(actions());
280

281
    if(m_outputSelectAction)
282
        m_outputSelectAction->setCurrentItem(0);
283

Scott Wheeler's avatar
Scott Wheeler committed
284
    new KAction(i18n("&Tag Guesser..."), 0, 0, this, SLOT(slotConfigureTagGuesser()),
285
		actions(), "tagGuesserConfig");
286

287
    new KAction(i18n("&File Renamer..."), 0, 0, this, SLOT(slotConfigureFileRenamer()),
288
		actions(), "fileRenamerConfig");
289

290
    KStdAction::keyBindings(this, SLOT(slotEditKeys()), actions());
291

292
    //////////////////////////////////////////////////
293
    // just in the toolbar
294 295
    //////////////////////////////////////////////////

296
    m_sliderAction = new SliderAction(i18n("Track Position"), actions(),
Scott Wheeler's avatar
Scott Wheeler committed
297
				      "trackPositionAction");
298 299

    createGUI();
300 301
}

302 303 304 305 306 307
void JuK::setupSplitterConnections()
{
    QValueListConstIterator<SplitterConnection> it = m_splitterConnections.begin();
    for(; it != m_splitterConnections.end(); ++it)
        connect((*it).first, SIGNAL(activated()), m_splitter, (*it).second);

Scott Wheeler's avatar
Scott Wheeler committed
308 309 310 311
    connect(m_showSearchAction, SIGNAL(toggled(bool)),
	    m_splitter, SLOT(slotSetSearchVisible(bool)));
    connect(m_showEditorAction, SIGNAL(toggled(bool)),
	    m_splitter, SLOT(slotSetEditorVisible(bool)));
312 313
    connect(m_showHistoryAction, SIGNAL(toggled(bool)),
	    m_splitter, SLOT(slotSetHistoryVisible(bool)));
314
    connect(this, SIGNAL(dockWindowPositionChanged(QDockWindow *)),
Scott Wheeler's avatar
Scott Wheeler committed
315 316 317
	    m_sliderAction, SLOT(slotUpdateOrientation(QDockWindow *)));
    connect(m_splitter, SIGNAL(signalPlaylistChanged()),
	    this, SLOT(slotPlaylistChanged()));
318 319
}

320
void JuK::setupSystemTray()
321
{
322
    if(m_toggleSystemTrayAction && m_toggleSystemTrayAction->isChecked()) {
323 324
        m_systemTray = new SystemTray(this, "systemTray");
        m_systemTray->show();
325

326
        connect(this, SIGNAL(signalNewSong(const QString&)),
Scott Wheeler's avatar
Scott Wheeler committed
327
		m_systemTray, SLOT(slotNewSong(const QString&)));
328

329
        m_toggleDockOnCloseAction->setEnabled(true);
330
	m_togglePopupsAction->setEnabled(true);
331

332
        connect(m_systemTray, SIGNAL(quitSelected()), this, SLOT(slotQuit()));
333
    }
334
    else {
335 336
        m_systemTray = 0;
        m_toggleDockOnCloseAction->setEnabled(false);
337
	m_togglePopupsAction->setEnabled(false);
338
    }
339 340
}

341 342 343
void JuK::setupGlobalAccels()
{
    m_accel = new KGlobalAccel(this);
344

345 346 347 348 349 350 351 352 353
    KeyDialog::insert(m_accel, "PlayPause",   i18n("Play / Pause"), action("playPause"),   SLOT(activate()));
    KeyDialog::insert(m_accel, "Stop",        i18n("Stop Playing"), action("stop"),        SLOT(activate()));
    KeyDialog::insert(m_accel, "Back",        i18n("Back"),         action("back"),        SLOT(activate()));
    KeyDialog::insert(m_accel, "Forward",     i18n("Forward"),      action("forward"),     SLOT(activate()));
    KeyDialog::insert(m_accel, "SeekBack",    i18n("Seek Back"),    action("seekBack"),    SLOT(activate()));
    KeyDialog::insert(m_accel, "SeekForward", i18n("Seek Forward"), action("seekForward"), SLOT(activate()));
    KeyDialog::insert(m_accel, "VolumeUp",    i18n("Volume Up"),    action("volumeUp"),    SLOT(activate()));
    KeyDialog::insert(m_accel, "VolumeDown",  i18n("Volume Down"),  action("volumeDown"),  SLOT(activate()));
    KeyDialog::insert(m_accel, "Mute",        i18n("Mute"),         action("mute"),        SLOT(activate()));
354
    KeyDialog::insert(m_accel, "ShowHide",    i18n("Show / Hide"),  this,                  SLOT(slotShowHide()));
355

356 357 358 359 360
    m_accel->setConfigGroup("Shortcuts");
    m_accel->readSettings();
    m_accel->updateConnections();
}

361 362 363 364
void JuK::processArgs()
{
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    QStringList files;
365

366
    for(int i = 0; i < args->count(); i++)
367
        files.append(args->arg(i));
368

369
    m_splitter->open(files);
370 371
}

372 373 374
void JuK::keyPressEvent(QKeyEvent *e)
{
    if (e->key() >= Qt::Key_Back && e->key() <= Qt::Key_MediaLast)
375
        e->accept();
376 377 378
    KMainWindow::keyPressEvent(e);
}

379 380 381 382 383 384 385 386 387
/**
 * 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");
388
        m_showSplash = config->readBoolEntry("ShowSplashScreen", true);
389
        m_startDocked = config->readBoolEntry("StartDocked", false);
390 391 392
    }
}

393 394
void JuK::readConfig()
{
395
    // Automagically save and m_restore many window settings.
396 397
    setAutoSaveSettings();

398
    KConfig *config = KGlobal::config();
399
    { // player settings
400
        KConfigGroupSaver saver(config, "Player");
401 402
        if(m_sliderAction->volumeSlider()) {
	    int maxVolume = m_sliderAction->volumeSlider()->maxValue();
Scott Wheeler's avatar
Scott Wheeler committed
403
	    int volume = config->readNumEntry("Volume", maxVolume);
404
            m_sliderAction->volumeSlider()->setVolume(volume);
405
        }
406 407
        bool randomPlay = config->readBoolEntry("RandomPlay", false);
        m_randomPlayAction->setChecked(randomPlay);
408

409
        bool loopPlaylist = config->readBoolEntry("LoopPlaylist", false);
410
        ActionCollection::action<KToggleAction>("loopPlaylist")->setChecked(loopPlaylist);
411
    }
412
    { // view settings
413
        KConfigGroupSaver saver(config, "View");
414 415 416 417 418

        bool showSearch = config->readBoolEntry("ShowSearch", true);
        m_showSearchAction->setChecked(showSearch);
        m_splitter->slotSetSearchVisible(showSearch);

419 420 421
        bool showEditor = config->readBoolEntry("ShowEditor", false);
        m_showEditorAction->setChecked(showEditor);
        m_splitter->slotSetEditorVisible(showEditor);
422

423 424 425
	// The history list will actually be created by the playlist restoration
	// code, but we want to remember the checkbox's setting and hope that
	// it's in synch with the code that does the real work.
426

427 428
	bool showHistory = config->readBoolEntry("ShowHistory", false);
	m_showHistoryAction->setChecked(showHistory);
429
    }
430 431
    { // general settings
        KConfigGroupSaver saver(config, "Settings");
432

433 434
        bool dockInSystemTray = config->readBoolEntry("DockInSystemTray", true);
        m_toggleSystemTrayAction->setChecked(dockInSystemTray);
435

436 437
        bool dockOnClose = config->readBoolEntry("DockOnClose", true);
        m_toggleDockOnCloseAction->setChecked(dockOnClose);
438

439 440
        bool showPopups = config->readBoolEntry("TrackPopup", false);
        m_togglePopupsAction->setChecked(showPopups);
441

442 443
        if(m_outputSelectAction)
            m_outputSelectAction->setCurrentItem(config->readNumEntry("MediaSystem", 0));
444
    }
445

446
    m_toggleSplashAction->setChecked(m_showSplash);
447 448 449 450
}

void JuK::saveConfig()
{
451
    KConfig *config = KGlobal::config();
452
    { // player settings
453
        KConfigGroupSaver saver(config, "Player");
454
	config->writeEntry("Volume", m_sliderAction->volumeSlider()->volume());
455 456 457 458
	config->writeEntry("RandomPlay", m_randomPlayAction->isChecked());

	KToggleAction *a = ActionCollection::action<KToggleAction>("loopPlaylist");
	config->writeEntry("LoopPlaylist", a->isChecked());
459
    }
460 461
    { // view settings
        KConfigGroupSaver saver(config, "View");
462

463
        config->writeEntry("ShowEditor", m_showEditorAction->isChecked());
464
        config->writeEntry("ShowSearch", m_showSearchAction->isChecked());
465
	config->writeEntry("ShowHistory", m_showHistoryAction->isChecked());
466
    }
467 468
    { // general settings
        KConfigGroupSaver saver(config, "Settings");
469
        config->writeEntry("ShowSplashScreen", m_toggleSplashAction->isChecked());
470
        config->writeEntry("StartDocked", m_startDocked);
471 472 473 474 475
        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());
476
    }
477
    config->sync();
478 479
}

480
bool JuK::queryExit()
481
{
482 483
    m_startDocked = !isVisible();

484
    hide();
485
    action("stop")->activate();
486 487 488
    delete m_systemTray;
    m_systemTray = 0;

489
    Cache::instance()->save();
490
    saveConfig();
491
    delete m_splitter;
492
    return true;
493 494
}

495 496
bool JuK::queryClose()
{
497 498 499 500 501
    if(!m_shuttingDown &&
       !kapp->sessionSaving() &&
       m_systemTray &&
       m_toggleDockOnCloseAction->isChecked())
    {
502
	KMessageBox::information(this,
Scott Wheeler's avatar
Scott Wheeler committed
503 504 505
	    i18n("<qt>Closing the main window will keep JuK running in the system tray. "
		 "Use Quit from the File menu to quit the application.</qt>"),
	    i18n("Docking in System Tray"), "hideOnCloseInfo");
506 507 508 509 510 511 512
	hide();
	return false;
    }
    else
	return true;
}

513 514
void JuK::updatePlaylistInfo()
{
Scott Wheeler's avatar
Scott Wheeler committed
515
    m_statusLabel->setPlaylistInfo(m_splitter->visiblePlaylistName(),
516 517
				   m_splitter->selectedPlaylistCount(),
				   m_splitter->selectedPlaylistTotalTime());
518 519
}

Scott Wheeler's avatar
Scott Wheeler committed
520 521 522
KAction *JuK::createSplitterAction(const QString &text, const char *slot,
				   const char *name, const QString &pix,
				   const KShortcut &shortcut)
523 524 525 526
{
    KAction *action;

    if(pix.isNull())
527
	action = new KAction(text, shortcut, actions(), name);
528
    else
529
	action = new KAction(text, pix, shortcut, actions(), name);
530 531

    m_splitterConnections.append(SplitterConnection(action, slot));
532

533 534 535
    return action;
}

536 537 538 539
////////////////////////////////////////////////////////////////////////////////
// private slot definitions
////////////////////////////////////////////////////////////////////////////////

540 541 542 543 544
void JuK::slotShowHide()
{
    setShown(!isShown());
}

545
void JuK::slotPlaylistChanged()
546
{
547 548 549 550
    if(m_splitter->collectionListSelected() ||
       !m_splitter->hasListSelected() ||
       m_splitter->readOnlyListSelected())
    {
551 552 553
        action("file_save")->setEnabled(false);
        action("file_save_as")->setEnabled(false);
        action("renamePlaylist")->setEnabled(false);
554
        action("reloadPlaylist")->setEnabled(m_splitter->collectionListSelected());
555
        action("deleteItemPlaylist")->setEnabled(false);
556 557
    }
    else {
558 559 560 561
        action("file_save")->setEnabled(true);
        action("file_save_as")->setEnabled(true);
        action("renamePlaylist")->setEnabled(true);
        action("deleteItemPlaylist")->setEnabled(true);
562 563

	if(m_splitter->fileBasedListSelected() || m_splitter->dynamicListSelected())
564
	    action("reloadPlaylist")->setEnabled(true);
565
	else
566
	    action("reloadPlaylist")->setEnabled(false);
567
    }
568
    if(m_splitter->hasListSelected())
569
        action("duplicatePlaylist")->setEnabled(true);
570
    else
571
        action("duplicatePlaylist")->setEnabled(false);
572

573 574 575
    updatePlaylistInfo();
}

576 577 578 579 580
void JuK::slotQuit()
{
    kapp->quit();
}

581 582 583 584
////////////////////////////////////////////////////////////////////////////////
// settings menu
////////////////////////////////////////////////////////////////////////////////

585
void JuK::slotToggleSystemTray(bool enabled)
586
{
587
    if(enabled && !m_systemTray)
588
	setupSystemTray();
589 590 591
    else if(!enabled && m_systemTray) {
	delete m_systemTray;
	m_systemTray = 0;
592
	m_toggleDockOnCloseAction->setEnabled(false);
593
	m_togglePopupsAction->setEnabled(false);
594 595 596
    }
}

597 598
void JuK::slotEditKeys()
{
599
    KeyDialog::configure(m_accel, actions(), this);
600 601
}

602 603
void JuK::slotConfigureTagGuesser()
{
604
    TagGuesserConfigDlg(this).exec();
605 606
}

607 608
void JuK::slotConfigureFileRenamer()
{
609
    FileRenamerConfigDlg(this).exec();
610 611
}

612
#include "juk.moc"