File indexing completed on 2024-04-14 04:49:06
0001 /* 0002 SPDX-FileCopyrightText: 2002-2003 Koos Vriezen <koos.vriezen@gmail.com> 0003 0004 SPDX-License-Identifier: LGPL-2.0-only 0005 */ 0006 0007 #ifndef KMPLAYERVIEW_H 0008 #define KMPLAYERVIEW_H 0009 0010 #include "config-kmplayer.h" 0011 #include <QWidget> 0012 #include <QTextEdit> 0013 #include <QImage> 0014 #include <QList> 0015 #include <QUrl> 0016 0017 #include <KMediaPlayer/View> 0018 0019 #include "inhibitinterface.h" 0020 #include "kmplayercommon_export.h" 0021 0022 #define MOUSE_INVISIBLE_DELAY 2000 0023 0024 class QSlider; 0025 class QStatusBar; 0026 class QMainWindow; 0027 class QDockWidget; 0028 class KActionCollection; 0029 0030 namespace KMPlayer { 0031 0032 class View; 0033 class ViewArea; 0034 class ControlPanel; 0035 class Console; 0036 class PlayListView; 0037 class PlayListView; 0038 class TopPlayItem; 0039 0040 typedef QStatusBar StatusBar; 0041 0042 /* 0043 * The console GUI 0044 */ 0045 class TextEdit : public QTextEdit 0046 { 0047 public: 0048 TextEdit (QWidget * parent, View * view); 0049 protected: 0050 void contextMenuEvent (QContextMenuEvent * e) override; 0051 private: 0052 View * m_view; 0053 }; 0054 0055 /* 0056 * The infowindow GUI 0057 */ 0058 class InfoWindow : public QTextEdit 0059 { 0060 public: 0061 InfoWindow (QWidget * parent, View * view); 0062 View * view () const { return m_view; } 0063 protected: 0064 void contextMenuEvent (QContextMenuEvent * e) override; 0065 private: 0066 View * m_view; 0067 }; 0068 0069 class PictureWidget : public QWidget 0070 { 0071 View * m_view; 0072 public: 0073 PictureWidget (QWidget * parent, View * view); 0074 ~PictureWidget () override {} 0075 protected: 0076 void mousePressEvent (QMouseEvent *) override; 0077 void mouseMoveEvent (QMouseEvent *) override; 0078 }; 0079 0080 /* 0081 * The view containing ViewArea and playlist 0082 */ 0083 class KMPLAYERCOMMON_EXPORT View : public KMediaPlayer::View 0084 { 0085 Q_OBJECT 0086 public: 0087 enum ControlPanelMode { 0088 CP_Hide, CP_AutoHide, CP_Show, CP_Only /* no video widget */ 0089 }; 0090 enum StatusBarMode { 0091 SB_Hide, SB_Show, SB_Only /* no video widget */ 0092 }; 0093 0094 View(QWidget* parent); 0095 ~View() override; 0096 0097 void addText (const QString &, bool eol=false); 0098 void init(KActionCollection* ac, bool transparent) KMPLAYERCOMMON_NO_EXPORT; 0099 void initDock (QWidget *central); 0100 void reset() KMPLAYERCOMMON_NO_EXPORT; 0101 //void print(QPrinter *pPrinter); 0102 0103 TextEdit * console () const { return m_multiedit; } 0104 PictureWidget *picture () const KMPLAYERCOMMON_NO_EXPORT { return m_picture; } 0105 KMPLAYERCOMMON_NO_EXPORT ControlPanel * controlPanel () const {return m_control_panel;} 0106 KMPLAYERCOMMON_NO_EXPORT StatusBar * statusBar () const {return m_status_bar;} 0107 KMPLAYERCOMMON_NO_EXPORT PlayListView * playList () const { return m_playlist; } 0108 KMPLAYERCOMMON_NO_EXPORT InfoWindow * infoPanel () const { return m_infopanel; } 0109 KMPLAYERCOMMON_NO_EXPORT QMainWindow *dockArea () const { return m_dockarea; } 0110 KMPLAYERCOMMON_NO_EXPORT QDockWidget *dockPlaylist () const { return m_dock_playlist; } 0111 KMPLAYERCOMMON_NO_EXPORT ViewArea * viewArea () const { return m_view_area; } 0112 KMPLAYERCOMMON_NO_EXPORT bool keepSizeRatio () const { return m_keepsizeratio; } 0113 void setKeepSizeRatio (bool b); 0114 void setControlPanelMode (ControlPanelMode m); 0115 void setStatusBarMode (StatusBarMode m); 0116 void setEraseColor(const QColor&) KMPLAYERCOMMON_NO_EXPORT; 0117 KMPLAYERCOMMON_NO_EXPORT ControlPanelMode controlPanelMode () const { return m_controlpanel_mode; } 0118 KMPLAYERCOMMON_NO_EXPORT StatusBarMode statusBarMode () const { return m_statusbar_mode; } 0119 void delayedShowButtons(bool show) KMPLAYERCOMMON_NO_EXPORT; 0120 bool isFullScreen () const; 0121 int statusBarHeight() const KMPLAYERCOMMON_NO_EXPORT; 0122 KMPLAYERCOMMON_NO_EXPORT bool editMode () const { return m_edit_mode; } 0123 #ifndef KMPLAYER_WITH_CAIRO 0124 bool setPicture (const QString & path); 0125 #endif 0126 void setNoInfoMessages (bool b) { m_no_info = b; } 0127 void setViewOnly (); 0128 void setEditMode (TopPlayItem *, bool enable=true); 0129 void dragEnterEvent(QDragEnterEvent*) override KMPLAYERCOMMON_NO_EXPORT; 0130 void dropEvent(QDropEvent*) override KMPLAYERCOMMON_NO_EXPORT; 0131 KMPLAYERCOMMON_NO_EXPORT void emitPictureClicked () { Q_EMIT pictureClicked (); } 0132 /* raise video widget, might (auto) hides panel */ 0133 void videoStart() KMPLAYERCOMMON_NO_EXPORT; 0134 void playingStart() KMPLAYERCOMMON_NO_EXPORT; 0135 /* shows panel */ 0136 void playingStop() KMPLAYERCOMMON_NO_EXPORT; 0137 void mouseMoved(int x, int y) KMPLAYERCOMMON_NO_EXPORT; 0138 public Q_SLOTS: 0139 void fullScreen (); 0140 void updateLayout() KMPLAYERCOMMON_NO_EXPORT; 0141 void toggleShowPlaylist (); 0142 void toggleVideoConsoleWindow (); 0143 void setInfoMessage (const QString & msg); 0144 void setStatusMessage (const QString & msg); 0145 Q_SIGNALS: 0146 void urlDropped (const QList<QUrl>& urls); 0147 void pictureClicked (); 0148 void fullScreenChanged (); 0149 void windowVideoConsoleToggled (bool show); 0150 protected: 0151 void leaveEvent (QEvent *) override KMPLAYERCOMMON_NO_EXPORT; 0152 void timerEvent(QTimerEvent*) override KMPLAYERCOMMON_NO_EXPORT; 0153 private: 0154 QByteArray m_dock_state; 0155 // console output 0156 TextEdit * m_multiedit; 0157 PictureWidget *m_picture; 0158 // widget that layouts m_widgetstack for ratio setting and m_control_panel 0159 ViewArea * m_view_area; 0160 // playlist widget 0161 PlayListView * m_playlist; 0162 // infopanel widget 0163 InfoWindow * m_infopanel; 0164 QMainWindow *m_dockarea; 0165 QDockWidget *m_dock_playlist; 0166 QDockWidget *m_dock_infopanel; 0167 QString tmplog; 0168 QImage m_image; 0169 ControlPanel * m_control_panel; 0170 StatusBar * m_status_bar; 0171 ControlPanelMode m_controlpanel_mode; 0172 ControlPanelMode m_old_controlpanel_mode; 0173 StatusBarMode m_statusbar_mode; 0174 int controlbar_timer; 0175 int infopanel_timer; 0176 int m_restore_state_timer; 0177 int m_powerManagerStopSleep; 0178 OrgFreedesktopPowerManagementInhibitInterface m_inhibitIface; 0179 bool m_keepsizeratio; 0180 bool m_playing; 0181 bool m_sreensaver_disabled; 0182 bool m_tmplog_needs_eol; 0183 bool m_revert_fullscreen; 0184 bool m_no_info; 0185 bool m_edit_mode; 0186 }; 0187 0188 } // namespace 0189 0190 #endif // KMPLAYERVIEW_H