File indexing completed on 2024-04-28 12:39:55

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 _KMPLAYERCONFIG_H_
0008 #define _KMPLAYERCONFIG_H_
0009 
0010 #include "config-kmplayer.h"
0011 
0012 #include <QObject>
0013 #include <QColor>
0014 #include <QFont>
0015 #include <QStringList>
0016 #include <QMap>
0017 
0018 #include <KSharedConfig>
0019 
0020 #include "kmplayercommon_export.h"
0021 
0022 class KSharedConfig;
0023 class QFrame;
0024 
0025 namespace KMPlayer {
0026 
0027 class PartBase;
0028 class Preferences;
0029 class View;
0030 
0031 class OutputDriver
0032 {
0033 public:
0034     const char * driver;
0035     const QString description;
0036 };
0037 
0038 class ColorSetting
0039 {
0040 public:
0041     QString title;
0042     QString option;
0043     QColor color;
0044     QColor newcolor;
0045     enum Target {
0046         playlist_background = 0, playlist_foreground, playlist_active,
0047         console_background, console_foreground,
0048         video_background, area_background,
0049         infowindow_background, infowindow_foreground,
0050         last_target
0051     } target;
0052 };
0053 
0054 class FontSetting
0055 {
0056 public:
0057     QString title;
0058     QString option; // for ini file
0059     QFont font;
0060     QFont newfont;
0061     enum Target {
0062         playlist, infowindow, last_target
0063     } target;
0064 };
0065 
0066 template <class T>
0067 struct Deleter {
0068     void operator ()(T * t) {
0069         delete t;
0070     }
0071 };
0072 
0073 /*
0074  * Base class for all dynamic preferance pages
0075  */
0076 class KMPLAYERCOMMON_EXPORT PreferencesPage
0077 {
0078 public:
0079     virtual ~PreferencesPage () {}
0080     virtual void write (KSharedConfigPtr) = 0;
0081     virtual void read (KSharedConfigPtr) = 0;
0082     virtual void sync (bool fromUI) = 0;
0083     virtual void prefLocation (QString & item, QString & icon, QString & tab) = 0;
0084     virtual QFrame * prefPage (QWidget * parent) = 0;
0085     PreferencesPage * next;
0086 };
0087 
0088 /*
0089  * Class for storing all actual settings and reading/writing them
0090  */
0091 class KMPLAYERCOMMON_EXPORT Settings : public QObject
0092 {
0093     Q_OBJECT
0094 public:
0095     Settings (PartBase *, KSharedConfigPtr part);
0096     ~Settings () override;
0097     bool createDialog () KMPLAYERCOMMON_NO_EXPORT;
0098     void show (const char * pagename = nullptr);
0099     void addPage (PreferencesPage *);
0100     void removePage (PreferencesPage *);
0101     void applyColorSetting (bool only_changed_ones) KMPLAYERCOMMON_NO_EXPORT;
0102     Preferences *configDialog() const { return configdialog; }
0103     View * defaultView ();
0104     KSharedConfigPtr kconfig () { return m_config; }
0105 
0106     QStringList urllist;
0107     QStringList sub_urllist;
0108     int volume;
0109     int contrast;
0110     int brightness;
0111     int hue;
0112     int saturation;
0113     int prefbitrate;
0114     int maxbitrate;
0115     bool usearts : 1;
0116     bool no_intro : 1;
0117     bool sizeratio : 1;
0118     bool remembersize : 1;
0119     bool autoresize : 1;
0120     bool docksystray : 1;
0121     bool loop : 1;
0122     bool framedrop : 1;
0123     bool autoadjustvolume : 1;
0124     bool autoadjustcolors : 1;
0125     bool showcnfbutton : 1;
0126     bool showplaylistbutton : 1;
0127     bool showrecordbutton : 1;
0128     bool showbroadcastbutton : 1;
0129     bool autohideslider : 1;
0130     bool clicktoplay : 1;
0131     bool grabhref : 1;
0132 // postproc thingies
0133     bool postprocessing : 1;
0134     bool disableppauto : 1;
0135     bool pp_default : 1;    // -vf pp=de
0136     bool pp_fast : 1;   // -vf pp=fa
0137     bool pp_custom : 1; // coming up
0138 
0139     bool pp_custom_hz : 1;      // horizontal deblocking
0140     bool pp_custom_hz_aq : 1;   //  - autoquality
0141     bool pp_custom_hz_ch : 1;   //  - chrominance
0142 
0143     bool pp_custom_vt : 1;          // vertical deblocking
0144     bool pp_custom_vt_aq : 1;       //  - autoquality
0145     bool pp_custom_vt_ch : 1;       //  - chrominance
0146 
0147     bool pp_custom_dr : 1;          // dering filter
0148     bool pp_custom_dr_aq : 1;       //  - autoquality
0149     bool pp_custom_dr_ch : 1;       //  - chrominance
0150 
0151     bool pp_custom_al : 1;  // pp=al
0152     bool pp_custom_al_f : 1;//  - fullrange
0153 
0154     bool pp_custom_tn : 1;  // pp=tn
0155     int pp_custom_tn_s : 1; //  - noise reducer strength (1 <= x <= 3)
0156 
0157     bool pp_lin_blend_int : 1;  // linear blend deinterlacer
0158     bool pp_lin_int : 1;        // - interpolating -
0159     bool pp_cub_int : 1;        // cubic - -
0160     bool pp_med_int : 1;        // median interlacer
0161     bool pp_ffmpeg_int : 1;     // ffmpeg interlacer
0162 // end of postproc
0163     // recording
0164     bool recordcopy : 1;
0165     enum Recorder { MEncoder = 0, FFMpeg, MPlayerDumpstream };
0166     Recorder recorder;
0167     enum ReplayOption { ReplayNo = 0, ReplayFinished, ReplayAfter };
0168     ReplayOption replayoption;
0169     int replaytime;
0170     QString mencoderarguments;
0171     QString ffmpegarguments;
0172     QString recordfile;
0173     int seektime;
0174     int videodriver;
0175     int audiodriver;
0176     OutputDriver * audiodrivers;
0177     OutputDriver * videodrivers;
0178     ColorSetting colors [ColorSetting::last_target];
0179     FontSetting fonts [FontSetting::last_target];
0180     QString dvddevice;
0181     QString vcddevice;
0182     QMap <QString, QString> backends;
0183     PreferencesPage * pagelist;
0184 Q_SIGNALS:
0185     void configChanged ();
0186 public Q_SLOTS:
0187     void readConfig () KMPLAYERCOMMON_NO_EXPORT;
0188     void writeConfig ();
0189 private Q_SLOTS:
0190     void okPressed () KMPLAYERCOMMON_NO_EXPORT;
0191     void getHelp () KMPLAYERCOMMON_NO_EXPORT;
0192 private:
0193     Preferences * configdialog;
0194     KSharedConfigPtr m_config;
0195     PartBase * m_player;
0196 };
0197 
0198 } // namespace
0199 
0200 #endif //_KMPLAYERCONFIG_H_