File indexing completed on 2024-04-14 15:01:05

0001 /**
0002  * Copyright (C) 2005 by Koos Vriezen <koos ! vriezen ? gmail ! com>
0003  *
0004  *  This library is free software; you can redistribute it and/or
0005  *  modify it under the terms of the GNU Library General Public
0006  *  License version 2 as published by the Free Software Foundation.
0007  *
0008  *  This library is distributed in the hope that it will be useful,
0009  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0010  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0011  *  Library General Public License for more details.
0012  *
0013  *  You should have received a copy of the GNU Library General Public License
0014  *  along with this library; see the file COPYING.LIB.  If not, write to
0015  *  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
0016  *  Boston, MA 02110-1301, USA.
0017  **/
0018 
0019 #ifndef KMPLAYER_CONTROLPANEL_H
0020 #define KMPLAYER_CONTROLPANEL_H
0021 
0022 #include "config-kmplayer.h"
0023 
0024 #include <qwidget.h>
0025 #include <qmenu.h>
0026 #include <qpushbutton.h>
0027 
0028 class QSlider;
0029 //class QPushButton;
0030 class QAction;
0031 class QWidgetAction;
0032 class QBoxLayout;
0033 class QStringList;
0034 
0035 namespace KMPlayer {
0036 
0037 class View;
0038 
0039 /*
0040  * A button from the controlpanel
0041  */
0042 class KMPLAYER_NO_EXPORT KMPlayerMenuButton : public QPushButton {
0043     Q_OBJECT
0044 public:
0045     KMPlayerMenuButton (QWidget *, QBoxLayout *, const char **, int = 0);
0046     KDE_NO_CDTOR_EXPORT ~KMPlayerMenuButton () {}
0047 signals:
0048     void mouseEntered ();
0049 protected:
0050     void enterEvent (QEvent *);
0051 };
0052 
0053 /*
0054  * The pop down menu from the controlpanel
0055  */
0056 class KMPLAYER_EXPORT KMPlayerPopupMenu : public QMenu {
0057     Q_OBJECT
0058 public:
0059     KMPlayerPopupMenu(QWidget*, const QString& title) KDE_NO_CDTOR_EXPORT;
0060     KDE_NO_CDTOR_EXPORT ~KMPlayerPopupMenu () {}
0061 signals:
0062     void mouseLeft ();
0063 protected:
0064     void leaveEvent(QEvent*) KDE_NO_EXPORT;
0065 };
0066 
0067 /*
0068  * The volume bar from the controlpanel
0069  */
0070 class KMPLAYER_EXPORT VolumeBar : public QWidget {
0071     Q_OBJECT
0072 public:
0073     VolumeBar(QWidget* parent, View* view) KDE_NO_CDTOR_EXPORT;
0074     ~VolumeBar() KDE_NO_CDTOR_EXPORT;
0075     KDE_NO_EXPORT int value () const { return m_value; }
0076     void setValue (int v);
0077 signals:
0078     void volumeChanged (int); // 0 - 100
0079 protected:
0080     void wheelEvent(QWheelEvent* e) KDE_NO_EXPORT;
0081     void paintEvent(QPaintEvent*) KDE_NO_EXPORT;
0082     void mousePressEvent(QMouseEvent* e) KDE_NO_EXPORT;
0083     void mouseMoveEvent(QMouseEvent* e) KDE_NO_EXPORT;
0084 private:
0085     View * m_view;
0086     int m_value;
0087 };
0088 
0089 /*
0090  * The controlpanel GUI
0091  */
0092 class KMPLAYER_EXPORT ControlPanel : public QWidget {
0093     Q_OBJECT
0094 public:
0095     enum Button {
0096         button_config = 0, button_playlist,
0097         button_back, button_play, button_forward,
0098         button_stop, button_pause, button_record,
0099         button_broadcast, button_language,
0100         button_red, button_green, button_yellow, button_blue,
0101         button_last
0102     };
0103     ControlPanel(QWidget* parent, View* view) KDE_NO_CDTOR_EXPORT;
0104     KDE_NO_CDTOR_EXPORT ~ControlPanel () {}
0105     void showPositionSlider (bool show);
0106     void enableSeekButtons (bool enable);
0107     void enableRecordButtons (bool enable);
0108     void enableFullscreenButton(bool enable);
0109     void setPlaying (bool play);
0110     void setRecording (bool record) KDE_NO_EXPORT;
0111     void setAutoControls (bool b);
0112     void setPalette (const QPalette &) KDE_NO_EXPORT;
0113     int preferredHeight () KDE_NO_EXPORT;
0114     KDE_NO_EXPORT bool autoControls () const { return m_auto_controls; }
0115     KDE_NO_EXPORT QSlider * positionSlider () const { return m_posSlider; }
0116     KDE_NO_EXPORT QSlider * contrastSlider () const { return m_contrastSlider; }
0117     KDE_NO_EXPORT QSlider * brightnessSlider () const { return m_brightnessSlider; }
0118     KDE_NO_EXPORT QSlider * hueSlider () const { return m_hueSlider; }
0119     KDE_NO_EXPORT QSlider * saturationSlider () const { return m_saturationSlider; }
0120     QPushButton * button (Button b) const { return m_buttons [(int) b]; }
0121     KDE_NO_EXPORT QPushButton * broadcastButton () const { return m_buttons[button_broadcast]; }
0122     KDE_NO_EXPORT VolumeBar * volumeBar () const { return m_volume; }
0123     KDE_NO_EXPORT View * view () const { return m_view; }
0124     QAction *playersAction;
0125     QAction *videoConsoleAction;
0126     QAction *playlistAction;
0127     QAction *zoomAction;
0128     QAction *zoom50Action;
0129     QAction *zoom100Action;
0130     QAction *zoom150Action;
0131     QAction *fullscreenAction;
0132     QAction *colorAction;
0133     QAction *configureAction;
0134     QAction *bookmarkAction;
0135     QAction *languageAction;
0136     QWidgetAction *scaleLabelAction;
0137     QWidgetAction *scaleAction;
0138     QSlider *scale_slider;
0139     KMPlayerPopupMenu *popupMenu;
0140     KMPlayerPopupMenu *bookmarkMenu;
0141     KMPlayerPopupMenu *zoomMenu;
0142     KMPlayerPopupMenu *playerMenu;
0143     KMPlayerPopupMenu *colorMenu;
0144     KMPlayerPopupMenu *languageMenu;
0145     KMPlayerPopupMenu *audioMenu;
0146     KMPlayerPopupMenu *subtitleMenu;
0147 public slots:
0148     void setLanguages(const QStringList& al, const QStringList& sl) KDE_NO_EXPORT;
0149     void actionToggled(QAction*) KDE_NO_EXPORT;
0150     void showPopupMenu() KDE_NO_EXPORT;
0151     void showLanguageMenu() KDE_NO_EXPORT;
0152     void setPlayingProgress(int position, int length) KDE_NO_EXPORT;
0153     void setLoadingProgress(int pos) KDE_NO_EXPORT;
0154 protected:
0155     void timerEvent(QTimerEvent* e) KDE_NO_EXPORT;
0156     void setupPositionSlider(bool show) KDE_NO_EXPORT;
0157 private slots:
0158     void buttonMouseEntered() KDE_NO_EXPORT;
0159     void buttonClicked() KDE_NO_EXPORT;
0160     void menuMouseLeft() KDE_NO_EXPORT;
0161 private:
0162     enum { progress_loading, progress_playing } m_progress_mode;
0163     int m_progress_length;
0164     int m_popup_timer;
0165     int m_popdown_timer;
0166     int m_button_monitored;
0167     View * m_view;
0168     QBoxLayout * m_buttonbox;
0169     QSlider * m_posSlider;
0170     QSlider * m_contrastSlider;
0171     QSlider * m_brightnessSlider;
0172     QSlider * m_hueSlider;
0173     QSlider * m_saturationSlider;
0174     QPushButton * m_buttons [button_last];
0175     VolumeBar * m_volume;
0176     bool m_auto_controls; // depending on source caps
0177     bool m_popup_clicked;
0178 };
0179 
0180 }
0181 
0182 #endif // KMPLAYER_CONTROLPANEL_H