File indexing completed on 2024-04-21 15:38:23

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