juk.cpp 20.3 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
#include <kcmdlineargs.h>
#include <kstatusbar.h>
#include <kdebug.h>
#include <kmessagebox.h>
Scott Wheeler's avatar
Scott Wheeler committed
24
#include <kiconloader.h>
25 26 27

#include <qslider.h>

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

39 40
using namespace ActionCollection;

41 42 43 44
////////////////////////////////////////////////////////////////////////////////
// public members
////////////////////////////////////////////////////////////////////////////////

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

53
    readSettings();
54

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

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

69 70
    m_player->setPlaylistInterface(m_splitter);

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

    m_sliderAction->slotUpdateOrientation();
75 76 77 78
}

JuK::~JuK()
{
79

80 81
}

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

87 88 89 90
////////////////////////////////////////////////////////////////////////////////
// public slots
////////////////////////////////////////////////////////////////////////////////

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

void JuK::slotGuessTagInfoFromInternet()
{
    m_splitter->slotGuessTagInfo(TagGuesser::MusicBrainz);
99 100
}

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

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

112 113 114 115
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////

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

121
    // create status bar
122

123
    m_statusLabel = new StatusLabel(statusBar());
124

125
    statusBar()->addWidget(m_statusLabel, 1);
126

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

134 135
    PlayerManager::instance()->setStatusLabel(m_statusLabel);

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

Scott Wheeler's avatar
Scott Wheeler committed
139 140
    new KAction(i18n("&Rename File"), "filesaveas", "CTRL+r", m_splitter,
		SLOT(slotRenameFile()), actions(), "renameFile");
141

142
    m_splitter->setFocus();
143

144
    resize(750, 500);
145 146
}

147 148
void JuK::setupActions()
{
149
    //////////////////////////////////////////////////
150
    // file menu
151
    //////////////////////////////////////////////////
152

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

156 157 158 159 160 161
    // 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).

162 163 164 165 166 167 168 169 170
    newMenu->insert(createSplitterAction(
			i18n("Empty Playlist..."), SLOT(slotCreatePlaylist()),
			"newPlaylist", "window_new", "CTRL+n"));
    newMenu->insert(createSplitterAction(
			i18n("Playlist From Folder..."), SLOT(slotCreatePlaylistFromDir()),
			"newDirectoryPlaylist", "file_open", "CTRL+d"));
    newMenu->insert(createSplitterAction(
			i18n("Search Playlist"), SLOT(slotAdvancedSearch()),
			"newSearchPlaylist", "find", "CTRL+f"));
Scott Wheeler's avatar
Scott Wheeler committed
171

172
    createSplitterAction(i18n("Open..."),         SLOT(slotOpen()),              "file_open", "fileopen", "CTRL+o");
Scott Wheeler's avatar
Scott Wheeler committed
173
    createSplitterAction(i18n("Add &Folder..."),  SLOT(slotOpenDirectory()),     "openDirectory", "fileopen");
174 175
    createSplitterAction(i18n("&Rename..."),      SLOT(slotRenamePlaylist()),    "renamePlaylist", "lineedit");
    createSplitterAction(i18n("D&uplicate..."),   SLOT(slotDuplicatePlaylist()), "duplicatePlaylist", "editcopy");
176 177 178 179
    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");
180
    createSplitterAction(i18n("Edit Search..."),  SLOT(slotEditSearch()),        "editSearch", "editclear");
181

182
    KStdAction::quit(this, SLOT(slotQuit()), actions());
183

184
    //////////////////////////////////////////////////
185
    // edit menu
186 187
    //////////////////////////////////////////////////

188 189 190 191
    KStdAction::cut(kapp,   SLOT(cut()),   actions());
    KStdAction::copy(kapp,  SLOT(copy()),  actions());
    KStdAction::paste(kapp, SLOT(paste()), actions());
    KStdAction::clear(kapp, SLOT(clear()), actions());
192

193
    KStdAction::selectAll(kapp, SLOT(selectAll()), actions());
194

195
    //////////////////////////////////////////////////
196
    // view menu
197
    //////////////////////////////////////////////////
198

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

206
    createSplitterAction(i18n("Refresh Items"), SLOT(slotRefresh()), "refresh", "reload");
207

208
    //////////////////////////////////////////////////
209
    // play menu
210 211
    //////////////////////////////////////////////////

Scott Wheeler's avatar
Scott Wheeler committed
212
    m_randomPlayAction = new KToggleAction(i18n("&Random Play"), 0,
213
					   actions(), "randomPlay");
Scott Wheeler's avatar
Scott Wheeler committed
214

215 216 217
    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
218

219 220 221 222
    // m_backAction = new KToolBarPopupAction(i18n("Previous &Track"), "player_start", 0,
    //                                        this, SLOT(back()), actions(), "back");

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

224
    new KAction(i18n("Previous &Track"), "player_start", 0, m_player, SLOT(back()),    actions(), "back");
225
    new KAction(i18n("&Next Track"),     "player_end",   0, m_player, SLOT(forward()), actions(), "forward");
226

227 228 229
    new KToggleAction(i18n("&Loop Playlist"), 0, 0, actions(), "loopPlaylist");

    // the following are not visible by default
230

231 232 233 234 235 236 237
    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");
    
238

239
    //////////////////////////////////////////////////
240
    // tagger menu
241 242
    //////////////////////////////////////////////////

243
    createSplitterAction(i18n("&Save"), SLOT(slotSaveTag()),
Scott Wheeler's avatar
Scott Wheeler committed
244 245 246
			 "saveItem",   "filesave", "CTRL+t");
    createSplitterAction(i18n("&Delete"), SLOT(slotDeleteSelectedItems()),
			 "removeItem", "editdelete");
247

248 249
    KActionMenu *guessMenu = new KActionMenu(i18n("&Guess Tag Information"),
					     QString::null, actions(),
Scott Wheeler's avatar
Scott Wheeler committed
250
					     "guessTag");
Scott Wheeler's avatar
Scott Wheeler committed
251
    guessMenu->setIconSet(SmallIconSet("wizard"));
252

253
    guessMenu->insert(
Scott Wheeler's avatar
Scott Wheeler committed
254 255
	new KAction(i18n("From &Filename"), "fileimport", "CTRL+f",
		    this, SLOT(slotGuessTagInfoFromFile()), actions(), "guessTagFile"));
256
#if HAVE_MUSICBRAINZ
257
    guessMenu->insert(
Scott Wheeler's avatar
Scott Wheeler committed
258 259
	new KAction(i18n("From &Internet"), "connect_established", "CTRL+i",
		    this, SLOT(slotGuessTagInfoFromInternet()), actions(), "guessTagInternet"));
260
#endif
Scott Wheeler's avatar
Scott Wheeler committed
261

262
    //////////////////////////////////////////////////
263
    // settings menu
264 265
    //////////////////////////////////////////////////

266
    setStandardToolBarMenuEnabled(true);
267

Scott Wheeler's avatar
Scott Wheeler committed
268 269 270 271 272 273 274 275 276 277 278 279
    m_toggleSplashAction =
	new KToggleAction(i18n("Show Splash Screen on Startup"), "launch",
			  KShortcut(), actions(), "showSplashScreen");
    m_toggleSystemTrayAction =
	new KToggleAction(i18n("&Dock in System Tray"),
			  KShortcut(), actions(), "toggleSystemTray");
    m_toggleDockOnCloseAction = 
	new KToggleAction(i18n("&Stay in System Tray on Close"),
			  KShortcut(), actions(), "dockOnClose");
    m_togglePopupsAction =
	new KToggleAction(i18n("Popup &Track Announcement"), "info",
			  KShortcut(), this, 0, actions(), "togglePopups");
280

Scott Wheeler's avatar
Scott Wheeler committed
281 282
    connect(m_toggleSystemTrayAction, SIGNAL(toggled(bool)),
	    this, SLOT(slotToggleSystemTray(bool)));
283

Scott Wheeler's avatar
Scott Wheeler committed
284

285
    m_outputSelectAction = PlayerManager::playerSelectAction(actions());
286

287
    if(m_outputSelectAction)
288
        m_outputSelectAction->setCurrentItem(0);
289

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

293
    new KAction(i18n("&File Renamer..."), 0, 0, this, SLOT(slotConfigureFileRenamer()),
294
		actions(), "fileRenamerConfig");
295

296
    KStdAction::keyBindings(this, SLOT(slotEditKeys()), actions());
297

298
    //////////////////////////////////////////////////
299
    // just in the toolbar
300 301
    //////////////////////////////////////////////////

302
    m_sliderAction = new SliderAction(i18n("Track Position"), actions(),
Scott Wheeler's avatar
Scott Wheeler committed
303
				      "trackPositionAction");
304 305

    createGUI();
306 307
}

308 309 310 311 312 313
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
314 315 316 317
    connect(m_showSearchAction, SIGNAL(toggled(bool)),
	    m_splitter, SLOT(slotSetSearchVisible(bool)));
    connect(m_showEditorAction, SIGNAL(toggled(bool)),
	    m_splitter, SLOT(slotSetEditorVisible(bool)));
318 319
    connect(m_showHistoryAction, SIGNAL(toggled(bool)),
	    m_splitter, SLOT(slotSetHistoryVisible(bool)));
320
    connect(this, SIGNAL(dockWindowPositionChanged(QDockWindow *)),
Scott Wheeler's avatar
Scott Wheeler committed
321 322 323
	    m_sliderAction, SLOT(slotUpdateOrientation(QDockWindow *)));
    connect(m_splitter, SIGNAL(signalPlaylistChanged()),
	    this, SLOT(slotPlaylistChanged()));
324 325
}

326
void JuK::setupSystemTray()
327
{
328
    if(m_toggleSystemTrayAction && m_toggleSystemTrayAction->isChecked()) {
Scott Wheeler's avatar
Scott Wheeler committed
329 330
	m_systemTray = new SystemTray(this, "systemTray");
	m_systemTray->show();
331

Scott Wheeler's avatar
Scott Wheeler committed
332
	m_toggleDockOnCloseAction->setEnabled(true);
333
	m_togglePopupsAction->setEnabled(true);
334

Scott Wheeler's avatar
Scott Wheeler committed
335
	connect(m_systemTray, SIGNAL(quitSelected()), this, SLOT(slotQuit()));
336
    }
337
    else {
Scott Wheeler's avatar
Scott Wheeler committed
338 339
	m_systemTray = 0;
	m_toggleDockOnCloseAction->setEnabled(false);
340
	m_togglePopupsAction->setEnabled(false);
341
    }
342 343
}

344 345 346
void JuK::setupGlobalAccels()
{
    m_accel = new KGlobalAccel(this);
347

348 349 350 351 352 353 354 355 356
    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()));
357
    KeyDialog::insert(m_accel, "ShowHide",    i18n("Show / Hide"),  this,                  SLOT(slotShowHide()));
358

359 360 361 362 363
    m_accel->setConfigGroup("Shortcuts");
    m_accel->readSettings();
    m_accel->updateConnections();
}

364 365 366 367
void JuK::processArgs()
{
    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
    QStringList files;
368

369
    for(int i = 0; i < args->count(); i++)
370
        files.append(args->arg(i));
371

372
    m_splitter->open(files);
373 374
}

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

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

396 397
void JuK::readConfig()
{
398
    // Automagically save and m_restore many window settings.
399 400
    setAutoSaveSettings();

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

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

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

422 423 424
        bool showEditor = config->readBoolEntry("ShowEditor", false);
        m_showEditorAction->setChecked(showEditor);
        m_splitter->slotSetEditorVisible(showEditor);
425

426 427 428
	// 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.
429

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

436 437
        bool dockInSystemTray = config->readBoolEntry("DockInSystemTray", true);
        m_toggleSystemTrayAction->setChecked(dockInSystemTray);
438

439 440
        bool dockOnClose = config->readBoolEntry("DockOnClose", true);
        m_toggleDockOnCloseAction->setChecked(dockOnClose);
441

442 443
        bool showPopups = config->readBoolEntry("TrackPopup", false);
        m_togglePopupsAction->setChecked(showPopups);
444

445 446
        if(m_outputSelectAction)
            m_outputSelectAction->setCurrentItem(config->readNumEntry("MediaSystem", 0));
447
    }
448

449
    m_toggleSplashAction->setChecked(m_showSplash);
450 451 452 453
}

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

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

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

483
bool JuK::queryExit()
484
{
485 486
    m_startDocked = !isVisible();

487
    hide();
488
    action("stop")->activate();
489 490 491
    delete m_systemTray;
    m_systemTray = 0;

492
    Cache::instance()->save();
493
    saveConfig();
494
    delete m_splitter;
495
    return true;
496 497
}

498 499
bool JuK::queryClose()
{
500 501 502 503 504
    if(!m_shuttingDown &&
       !kapp->sessionSaving() &&
       m_systemTray &&
       m_toggleDockOnCloseAction->isChecked())
    {
505
	KMessageBox::information(this,
Scott Wheeler's avatar
Scott Wheeler committed
506 507 508
	    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");
509 510 511 512 513 514 515
	hide();
	return false;
    }
    else
	return true;
}

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

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

    if(pix.isNull())
530
	action = new KAction(text, shortcut, actions(), name);
531
    else
532
	action = new KAction(text, pix, shortcut, actions(), name);
533 534

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

536 537 538
    return action;
}

539 540 541 542
////////////////////////////////////////////////////////////////////////////////
// private slot definitions
////////////////////////////////////////////////////////////////////////////////

543 544 545 546 547
void JuK::slotShowHide()
{
    setShown(!isShown());
}

548
void JuK::slotPlaylistChanged()
549
{
550 551 552
    updatePlaylistInfo();
}

553 554 555 556 557
void JuK::slotQuit()
{
    kapp->quit();
}

558 559 560 561
////////////////////////////////////////////////////////////////////////////////
// settings menu
////////////////////////////////////////////////////////////////////////////////

562
void JuK::slotToggleSystemTray(bool enabled)
563
{
564
    if(enabled && !m_systemTray)
565
	setupSystemTray();
566 567 568
    else if(!enabled && m_systemTray) {
	delete m_systemTray;
	m_systemTray = 0;
569
	m_toggleDockOnCloseAction->setEnabled(false);
570
	m_togglePopupsAction->setEnabled(false);
571 572 573
    }
}

574 575
void JuK::slotEditKeys()
{
576
    KeyDialog::configure(m_accel, actions(), this);
577 578
}

579 580
void JuK::slotConfigureTagGuesser()
{
581
    TagGuesserConfigDlg(this).exec();
582 583
}

584 585
void JuK::slotConfigureFileRenamer()
{
586
    FileRenamerConfigDlg(this).exec();
587 588
}

589
#include "juk.moc"