juk.h 4.93 KB
Newer Older
1 2 3 4 5
/***************************************************************************
                          juk.h  -  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 18 19 20 21 22 23 24 25

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef JUK_H
#define JUK_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <kaction.h>
26
#include <kglobalaccel.h>
27 28
#include <kstdaction.h>
#include <kmainwindow.h>
29
#include <kmenubar.h>
30

31
#include <qlabel.h>
32 33

#include "player.h"
34 35 36 37
#include "playlistsplitter.h"

class QTimer;
class QListViewItem;
38

39
class SliderAction;
40
class StatusLabel;
41
class SystemTray;
42 43 44

class JuK : public KMainWindow
{
45
    Q_OBJECT
46

47
public:
48
    JuK(QWidget* parent = 0, const char *name = 0);
49
    virtual ~JuK();
50

51
signals:
52 53
    void signalEdit();
    void signalNewSong(const QString& songTitle);
54

55 56 57
private:
    // private methods
    void setupLayout();
58
    void setupActions();
59
    void setupPlayer();
60
    void setupSystemTray();
61
    void setupGlobalAccels();
62

63
    void processArgs();
64

65 66
    void keyPressEvent(QKeyEvent *);

67
    /**
68 69
     * readSettings() is separate from readConfig() in that it contains settings
     * that need to be read before the GUI is setup.
70 71
     */
    void readSettings();
72
    void readConfig();
73
    void saveConfig();
74

75
    virtual bool queryExit();
76 77
    virtual bool queryClose();

78
    void invokeEditSlot(const char *slotName, const char *slot);
79
    QString playingString() const;
80 81 82 83 84 85 86
    void updatePlaylistInfo();

    /**
     * This is the main method to play stuff.  Everything else is just a wrapper
     * around this.
     */
    void play(const QString &file);
87

88
private slots:
89
    void slotPlaylistChanged();
90

91 92 93
    // file menu
    void slotQuit() { m_shuttingDown = true; kapp->quit(); }

94
    // edit menu
95 96 97 98 99 100
    void cut();
    void copy();
    void paste();
    void clear();
    void selectAll();

101 102 103 104 105 106
    // player menu
    void slotPlay();
    void slotPause();
    void slotStop();
    void slotBack();
    void slotForward();
107 108
    void slotSeekBack();
    void slotSeekForward();
109

110
    // settings menu
111 112 113
    void slotShowGenreListEditor();
    void slotToggleSystemTray(bool enabled);
    void slotSetOutput(int output);
114
    void slotEditKeys();
115
    void slotConfigureTagGuesser();
116

117 118 119 120
    // additional player slots
    void slotTrackPositionSliderClicked();
    void slotTrackPositionSliderReleased();
    void slotTrackPositionSliderUpdate(int position);
121 122 123 124
    void slotPlayPause();
    void slotVolumeUp();
    void slotVolumeDown();
    void slotVolumeMute();
125 126 127

    /**
     * This method is called to check our progress in the playing file.  It uses
128
     * m_playTimer to know when to call itself again.
129
     */
130
    void slotPollPlay();
131

132
    /**
133
     * This method is called by the slider to set the volume of the player.  Its
134
     * value is relative to the maxValue() of the volume slider.
135
     */
136
    void slotSetVolume(int volume);
137

138 139
    void slotPlaySelectedFile() { play(m_splitter->playSelectedFile()); }
    void slotPlayFirstFile() { play(m_splitter->playFirstFile()); }
140 141 142
    void slotToggleMenuBar() { menuBar()->isVisible() ? menuBar()->hide() : menuBar()->show(); }
    void slotToggleToolBar() { toolBar()->isVisible() ? toolBar()->hide() : toolBar()->show(); }

143 144
private:
    // layout objects
145 146 147
    PlaylistSplitter *m_splitter;
    StatusLabel *m_statusLabel;
    SystemTray *m_systemTray;
148 149

    // actions
150 151 152 153 154
    KToggleAction *m_showEditorAction;
    KToggleAction *m_restoreOnLoadAction;
    SliderAction *m_sliderAction;
    KToggleAction *m_randomPlayAction;
    KToggleAction *m_toggleSystemTrayAction;
155
    KToggleAction *m_toggleDockOnCloseAction;
156
    KToggleAction *m_togglePopupsAction;
157 158 159 160 161 162 163
    KSelectAction *m_outputSelectAction;

    KAction *m_playAction;
    KAction *m_pauseAction;
    KAction *m_stopAction;
    KAction *m_backAction;
    KAction *m_forwardAction;
164
    KToggleAction *m_loopPlaylistAction;
165 166 167 168 169 170 171 172

    KAction *m_savePlaylistAction;
    KAction *m_saveAsPlaylistAction;
    KAction *m_renamePlaylistAction;
    KAction *m_deleteItemPlaylistAction;

    QTimer *m_playTimer;
    Player *m_player;
173
    KGlobalAccel *m_accel;
174 175 176 177

    bool m_trackPositionDragging;
    bool m_noSeek;
    bool m_restore;
178
    bool m_shuttingDown;
179
    bool m_volmute;
180

181
    static const int m_pollInterval = 800;
182 183 184
};

#endif