File indexing completed on 2024-04-28 04:48:38

0001 /*
0002     SPDX-FileCopyrightText: 2004 Max Howell <max.howell@methylblue.com>
0003     SPDX-FileCopyrightText: 2007 Ian Monroe <ian@monroe.nu>
0004 
0005     SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 
0008 #ifndef DRAGONPLAYERMAINWINDOW_H
0009 #define DRAGONPLAYERMAINWINDOW_H
0010 
0011 #include "codeine.h"
0012 #include "loadView.h"
0013 #include "timeLabel.h"
0014 
0015 #include <KXmlGuiWindow>
0016 #include <QCheckBox>
0017 #include <QList>
0018 #include <QPointer>
0019 #include <QStackedWidget>
0020 #include <phonon/MediaSource>
0021 
0022 #include <optional>
0023 
0024 class KToggleAction;
0025 class QUrl;
0026 class QActionGroup;
0027 class QCloseEvent;
0028 class QLabel;
0029 class QMenu;
0030 class QSlider;
0031 
0032 class AudioView2;
0033 #include "audioView2.h"
0034 
0035 namespace Dragon
0036 {
0037 class FullScreenToolBarHandler;
0038 
0039 class MainWindow : public KXmlGuiWindow
0040 {
0041     Q_OBJECT
0042 
0043     MainWindow();
0044     ~MainWindow() override;
0045 
0046     static MainWindow *s_instance;
0047 
0048     friend class PlayerApplication;
0049     friend QWidget *mainWindow();
0050 
0051 public:
0052     void openRecentFile(const QUrl &);
0053     void showVolume(bool);
0054     bool volumeContains(const QPoint &mousePos);
0055 
0056 Q_SIGNALS:
0057     void fileChanged(QString);
0058 
0059 public Q_SLOTS:
0060     bool open(const QUrl &);
0061     void playDisc();
0062     void openFileDialog();
0063     void openStreamDialog();
0064     void play();
0065     void toggleVideoSettings(bool);
0066     void toggleVolumeSlider(bool);
0067     void restoreDefaultVideoSettings();
0068     void toggleLoadView();
0069 
0070 private Q_SLOTS:
0071     void setFullScreen(bool full);
0072     void engineMessage(const QString &);
0073     void init();
0074     void aboutToShowMenu();
0075     void streamSettingChange();
0076     void subChannelsChanged(QList<QAction *>);
0077     void audioChannelsChanged(QList<QAction *>);
0078     void mutedChanged(bool);
0079     void stop();
0080     // in stateChange.cpp
0081     void engineStateChanged(Phonon::State);
0082     void engineMediaChanged(Phonon::MediaSource);
0083     void engineSeekableChanged(bool);
0084     void engineMetaDataChanged();
0085     void engineHasVideoChanged(bool);
0086     void toggleUnique(bool);
0087 
0088 protected:
0089     void contextMenuEvent(QContextMenuEvent *event) override;
0090 
0091 private:
0092     bool load(const QUrl &);
0093     void setupActions();
0094     void updateSliders();
0095     void updateTitleBarText();
0096     bool isFresh();
0097 
0098     QMenu *menu(const char *name);
0099 
0100     void dragEnterEvent(QDragEnterEvent *) override;
0101     void dropEvent(QDropEvent *) override;
0102     void keyPressEvent(QKeyEvent *) override;
0103 
0104     void inhibitPowerSave();
0105     void releasePowerSave();
0106 
0107     //      virtual void saveProperties( KConfig* );
0108     //      virtual void readProperties( KConfig* );
0109 
0110     QStackedWidget *m_mainView;
0111     AudioView2 *m_audioView;
0112     LoadView *m_loadView;
0113     QWidget *m_currentWidget;
0114 
0115     QPointer<QDockWidget> m_leftDock;
0116     QPointer<QDockWidget> m_rightDock;
0117     QWidget *m_positionSlider;
0118     QPointer<QWidget> m_volumeSlider;
0119     QCheckBox *m_muteCheckBox;
0120     TimeLabel *m_timeLabel;
0121     QLabel *m_titleLabel;
0122     QList<QSlider *> m_sliders;
0123 
0124     KToggleAction *m_menuToggleAction;
0125 
0126     std::optional<int> m_screensaverDisableCookie;
0127     int m_stopSleepCookie;
0128     int m_stopScreenPowerMgmtCookie;
0129     int m_profileMaxDays;
0130 
0131     bool m_toolbarIsHidden;
0132     bool m_statusbarIsHidden;
0133     bool m_menuBarIsHidden;
0134     FullScreenToolBarHandler *m_FullScreenHandler;
0135 
0136     QActionGroup *m_aspectRatios;
0137     Q_DISABLE_COPY(MainWindow)
0138 
0139 protected:
0140     void closeEvent(QCloseEvent *event) override;
0141     void wheelEvent(QWheelEvent *event) override;
0142 };
0143 
0144 }
0145 
0146 #endif