File indexing completed on 2024-04-21 04:54:05

0001 /*
0002     SPDX-FileCopyrightText: 2005 Koos Vriezen <koos ! vriezen ? gmail ! com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-only
0005 */
0006 
0007 #ifndef KMPLAYER_CONTROLPANEL_H
0008 #define KMPLAYER_CONTROLPANEL_H
0009 
0010 #include "config-kmplayer.h"
0011 #include "kmplayercommon_export.h"
0012 
0013 #include <QWidget>
0014 #include <QMenu>
0015 #include <QPushButton>
0016 
0017 class QSlider;
0018 //class QPushButton;
0019 class QAction;
0020 class QWidgetAction;
0021 class QBoxLayout;
0022 class QStringList;
0023 
0024 namespace KMPlayer {
0025 
0026 class View;
0027 
0028 /*
0029  * A button from the controlpanel
0030  */
0031 class KMPlayerMenuButton : public QPushButton
0032 {
0033     Q_OBJECT
0034 public:
0035     KMPlayerMenuButton (QWidget *, QBoxLayout *, const char **, int = 0);
0036     ~KMPlayerMenuButton () override {}
0037 Q_SIGNALS:
0038     void mouseEntered ();
0039 protected:
0040     void enterEvent (QEvent *) override;
0041 };
0042 
0043 /*
0044  * The pop down menu from the controlpanel
0045  */
0046 class KMPLAYERCOMMON_EXPORT KMPlayerPopupMenu : public QMenu
0047 {
0048     Q_OBJECT
0049 public:
0050     KMPlayerPopupMenu(QWidget*, const QString& title);
0051     ~KMPlayerPopupMenu () override {}
0052 Q_SIGNALS:
0053     void mouseLeft ();
0054 protected:
0055     void leaveEvent(QEvent*) override KMPLAYERCOMMON_NO_EXPORT;
0056 };
0057 
0058 /*
0059  * The volume bar from the controlpanel
0060  */
0061 class KMPLAYERCOMMON_EXPORT VolumeBar : public QWidget
0062 {
0063     Q_OBJECT
0064 public:
0065     VolumeBar(QWidget* parent, View* view);
0066     ~VolumeBar() override;
0067     KMPLAYERCOMMON_NO_EXPORT int value () const { return m_value; }
0068     void setValue (int v);
0069 Q_SIGNALS:
0070     void volumeChanged (int); // 0 - 100
0071 protected:
0072     void wheelEvent(QWheelEvent* e) override KMPLAYERCOMMON_NO_EXPORT;
0073     void paintEvent(QPaintEvent*) override KMPLAYERCOMMON_NO_EXPORT;
0074     void mousePressEvent(QMouseEvent* e) override KMPLAYERCOMMON_NO_EXPORT;
0075     void mouseMoveEvent(QMouseEvent* e) override KMPLAYERCOMMON_NO_EXPORT;
0076 private:
0077     View * m_view;
0078     int m_value;
0079 };
0080 
0081 /*
0082  * The controlpanel GUI
0083  */
0084 class KMPLAYERCOMMON_EXPORT ControlPanel : public QWidget
0085 {
0086     Q_OBJECT
0087 public:
0088     enum Button {
0089         button_config = 0, button_playlist,
0090         button_back, button_play, button_forward,
0091         button_stop, button_pause, button_record,
0092         button_broadcast, button_language,
0093         button_red, button_green, button_yellow, button_blue,
0094         button_last
0095     };
0096     ControlPanel(QWidget* parent, View* view);
0097     ~ControlPanel () override {}
0098     void showPositionSlider (bool show);
0099     void enableSeekButtons (bool enable);
0100     void enableRecordButtons (bool enable);
0101     void enableFullscreenButton(bool enable);
0102     void setPlaying (bool play);
0103     void setRecording (bool record) KMPLAYERCOMMON_NO_EXPORT;
0104     void setAutoControls (bool b);
0105     void setPalette (const QPalette &) KMPLAYERCOMMON_NO_EXPORT;
0106     int preferredHeight () KMPLAYERCOMMON_NO_EXPORT;
0107     KMPLAYERCOMMON_NO_EXPORT bool autoControls () const { return m_auto_controls; }
0108     KMPLAYERCOMMON_NO_EXPORT QSlider * positionSlider () const { return m_posSlider; }
0109     KMPLAYERCOMMON_NO_EXPORT QSlider * contrastSlider () const { return m_contrastSlider; }
0110     KMPLAYERCOMMON_NO_EXPORT QSlider * brightnessSlider () const { return m_brightnessSlider; }
0111     KMPLAYERCOMMON_NO_EXPORT QSlider * hueSlider () const { return m_hueSlider; }
0112     KMPLAYERCOMMON_NO_EXPORT QSlider * saturationSlider () const { return m_saturationSlider; }
0113     QPushButton * button (Button b) const { return m_buttons [(int) b]; }
0114     KMPLAYERCOMMON_NO_EXPORT QPushButton * broadcastButton () const { return m_buttons[button_broadcast]; }
0115     KMPLAYERCOMMON_NO_EXPORT VolumeBar * volumeBar () const { return m_volume; }
0116     KMPLAYERCOMMON_NO_EXPORT View * view () const { return m_view; }
0117     QAction *playersAction;
0118     QAction *videoConsoleAction;
0119     QAction *playlistAction;
0120     QAction *zoomAction;
0121     QAction *zoom50Action;
0122     QAction *zoom100Action;
0123     QAction *zoom150Action;
0124     QAction *fullscreenAction;
0125     QAction *colorAction;
0126     QAction *configureAction;
0127     QAction *bookmarkAction;
0128     QAction *languageAction;
0129     QWidgetAction *scaleLabelAction;
0130     QWidgetAction *scaleAction;
0131     QSlider *scale_slider;
0132     KMPlayerPopupMenu *popupMenu;
0133     KMPlayerPopupMenu *bookmarkMenu;
0134     KMPlayerPopupMenu *zoomMenu;
0135     KMPlayerPopupMenu *playerMenu;
0136     KMPlayerPopupMenu *colorMenu;
0137     KMPlayerPopupMenu *languageMenu;
0138     KMPlayerPopupMenu *audioMenu;
0139     KMPlayerPopupMenu *subtitleMenu;
0140 public Q_SLOTS:
0141     void setLanguages(const QStringList& al, const QStringList& sl) KMPLAYERCOMMON_NO_EXPORT;
0142     void actionToggled(QAction*) KMPLAYERCOMMON_NO_EXPORT;
0143     void showPopupMenu() KMPLAYERCOMMON_NO_EXPORT;
0144     void showLanguageMenu() KMPLAYERCOMMON_NO_EXPORT;
0145     void setPlayingProgress(int position, int length) KMPLAYERCOMMON_NO_EXPORT;
0146     void setLoadingProgress(int pos) KMPLAYERCOMMON_NO_EXPORT;
0147 protected:
0148     void timerEvent(QTimerEvent* e) override KMPLAYERCOMMON_NO_EXPORT;
0149     void setupPositionSlider(bool show) KMPLAYERCOMMON_NO_EXPORT;
0150 private Q_SLOTS:
0151     void buttonMouseEntered() KMPLAYERCOMMON_NO_EXPORT;
0152     void buttonClicked() KMPLAYERCOMMON_NO_EXPORT;
0153     void menuMouseLeft() KMPLAYERCOMMON_NO_EXPORT;
0154 private:
0155     enum { progress_loading, progress_playing } m_progress_mode;
0156     int m_progress_length;
0157     int m_popup_timer;
0158     int m_popdown_timer;
0159     int m_button_monitored;
0160     View * m_view;
0161     QBoxLayout * m_buttonbox;
0162     QSlider * m_posSlider;
0163     QSlider * m_contrastSlider;
0164     QSlider * m_brightnessSlider;
0165     QSlider * m_hueSlider;
0166     QSlider * m_saturationSlider;
0167     QPushButton * m_buttons [button_last];
0168     VolumeBar * m_volume;
0169     bool m_auto_controls; // depending on source caps
0170     bool m_popup_clicked;
0171 };
0172 
0173 }
0174 
0175 #endif // KMPLAYER_CONTROLPANEL_H