1 /**
2  * Copyright (C) 2002-2003 by Koos Vriezen <koos.vriezen@gmail.com>
3  *
4  *  This library is free software; you can redistribute it and/or
5  *  modify it under the terms of the GNU Library General Public
6  *  License version 2 as published by the Free Software Foundation.
7  *
8  *  This library is distributed in the hope that it will be useful,
9  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11  *  Library General Public License for more details.
12  *
13  *  You should have received a copy of the GNU Library General Public License
14  *  along with this library; see the file COPYING.LIB.  If not, write to
15  *  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
16  *  Boston, MA 02110-1301, USA.
17  **/
18 
19 #ifndef _KMPLAYERCONFIG_H_
20 #define _KMPLAYERCONFIG_H_
21 
22 #include "config-kmplayer.h"
23 
24 #include <qobject.h>
25 #include <QColor>
26 #include <QFont>
27 #include <qstringlist.h>
28 #include <qmap.h>
29 
30 #include <ksharedconfig.h>
31 
32 #include "kmplayer_def.h"
33 
34 class KSharedConfig;
35 class QFrame;
36 
37 namespace KMPlayer {
38 
39 class PartBase;
40 class Preferences;
41 class View;
42 
43 class KDE_NO_EXPORT OutputDriver {
44 public:
45     const char * driver;
46     const QString description;
47 };
48 
49 class KDE_NO_EXPORT ColorSetting {
50 public:
51     QString title;
52     QString option;
53     QColor color;
54     QColor newcolor;
55     enum Target {
56         playlist_background = 0, playlist_foreground, playlist_active,
57         console_background, console_foreground,
58         video_background, area_background,
59         infowindow_background, infowindow_foreground,
60         last_target
61     } target;
62 };
63 
64 class KDE_NO_EXPORT FontSetting {
65 public:
66     QString title;
67     QString option; // for ini file
68     QFont font;
69     QFont newfont;
70     enum Target {
71         playlist, infowindow, last_target
72     } target;
73 };
74 
75 template <class T>
76 struct Deleter {
operatorDeleter77     void operator ()(T * t) {
78         delete t;
79     }
80 };
81 
82 /*
83  * Base class for all dynamic preferance pages
84  */
85 class KMPLAYER_EXPORT PreferencesPage {
86 public:
~PreferencesPage()87     virtual ~PreferencesPage () {}
88     virtual void write (KSharedConfigPtr) = 0;
89     virtual void read (KSharedConfigPtr) = 0;
90     virtual void sync (bool fromUI) = 0;
91     virtual void prefLocation (QString & item, QString & icon, QString & tab) = 0;
92     virtual QFrame * prefPage (QWidget * parent) = 0;
93     PreferencesPage * next;
94 };
95 
96 /*
97  * Class for storing all actual settings and reading/writing them
98  */
99 class KMPLAYER_EXPORT Settings : public QObject {
100     Q_OBJECT
101 public:
102     Settings (PartBase *, KSharedConfigPtr part) KDE_NO_CDTOR_EXPORT;
103     ~Settings () KDE_NO_CDTOR_EXPORT;
104     bool createDialog () KDE_NO_EXPORT;
105     void show (const char * pagename = 0L);
106     void addPage (PreferencesPage *);
107     void removePage (PreferencesPage *);
108     void applyColorSetting (bool only_changed_ones) KDE_NO_EXPORT;
configDialog()109     Preferences *configDialog() const { return configdialog; }
110     View * defaultView ();
kconfig()111     KSharedConfigPtr kconfig () { return m_config; }
112 
113     QStringList urllist;
114     QStringList sub_urllist;
115     int volume;
116     int contrast;
117     int brightness;
118     int hue;
119     int saturation;
120     int prefbitrate;
121     int maxbitrate;
122     bool usearts : 1;
123     bool no_intro : 1;
124     bool sizeratio : 1;
125     bool remembersize : 1;
126     bool autoresize : 1;
127     bool docksystray : 1;
128     bool loop : 1;
129     bool framedrop : 1;
130     bool autoadjustvolume : 1;
131     bool autoadjustcolors : 1;
132     bool showcnfbutton : 1;
133     bool showplaylistbutton : 1;
134     bool showrecordbutton : 1;
135     bool showbroadcastbutton : 1;
136     bool autohideslider : 1;
137     bool clicktoplay : 1;
138     bool grabhref : 1;
139 // postproc thingies
140     bool postprocessing : 1;
141     bool disableppauto : 1;
142     bool pp_default : 1;	// -vf pp=de
143     bool pp_fast : 1;	// -vf pp=fa
144     bool pp_custom : 1;	// coming up
145 
146     bool pp_custom_hz : 1; 		// horizontal deblocking
147     bool pp_custom_hz_aq : 1;	//  - autoquality
148     bool pp_custom_hz_ch : 1;	//  - chrominance
149 
150     bool pp_custom_vt : 1;          // vertical deblocking
151     bool pp_custom_vt_aq : 1;       //  - autoquality
152     bool pp_custom_vt_ch : 1;       //  - chrominance
153 
154     bool pp_custom_dr : 1;          // dering filter
155     bool pp_custom_dr_aq : 1;       //  - autoquality
156     bool pp_custom_dr_ch : 1;       //  - chrominance
157 
158     bool pp_custom_al : 1;	// pp=al
159     bool pp_custom_al_f : 1;//  - fullrange
160 
161     bool pp_custom_tn : 1;  // pp=tn
162     int pp_custom_tn_s : 1; //  - noise reducer strength (1 <= x <= 3)
163 
164     bool pp_lin_blend_int : 1;	// linear blend deinterlacer
165     bool pp_lin_int : 1;		// - interpolating -
166     bool pp_cub_int : 1;		// cubic - -
167     bool pp_med_int : 1;		// median interlacer
168     bool pp_ffmpeg_int : 1;		// ffmpeg interlacer
169 // end of postproc
170     // recording
171     bool recordcopy : 1;
172     enum Recorder { MEncoder = 0, FFMpeg, MPlayerDumpstream };
173     Recorder recorder;
174     enum ReplayOption { ReplayNo = 0, ReplayFinished, ReplayAfter };
175     ReplayOption replayoption;
176     int replaytime;
177     QString mencoderarguments;
178     QString ffmpegarguments;
179     QString recordfile;
180     int seektime;
181     int videodriver;
182     int audiodriver;
183     OutputDriver * audiodrivers;
184     OutputDriver * videodrivers;
185     ColorSetting colors [ColorSetting::last_target];
186     FontSetting fonts [FontSetting::last_target];
187     QString dvddevice;
188     QString vcddevice;
189     QMap <QString, QString> backends;
190     PreferencesPage * pagelist;
191 signals:
192     void configChanged ();
193 public slots:
194     void readConfig () KDE_NO_EXPORT;
195     void writeConfig ();
196 private slots:
197     void okPressed () KDE_NO_EXPORT;
198     void getHelp () KDE_NO_EXPORT;
199 private:
200     Preferences * configdialog;
201     KSharedConfigPtr m_config;
202     PartBase * m_player;
203 };
204 
205 } // namespace
206 
207 #endif //_KMPLAYERCONFIG_H_
208