File indexing completed on 2024-04-14 15:01:04
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 #include <algorithm> 0020 #include <functional> 0021 #include <assert.h> 0022 0023 #include "config-kmplayer.h" 0024 #include <qcheckbox.h> 0025 #include <qtextedit.h> 0026 #include <qpushbutton.h> 0027 #include <qradiobutton.h> 0028 #include <qtabwidget.h> 0029 #include <qslider.h> 0030 #include <qspinbox.h> 0031 #include <qlabel.h> 0032 #include <qfileinfo.h> 0033 #include <QButtonGroup> 0034 #include <QListWidget> 0035 0036 #include <kurlrequester.h> 0037 #include <klineedit.h> 0038 #include <kstatusbar.h> 0039 0040 #include <kconfig.h> 0041 #include <kconfiggroup.h> 0042 #include <kurl.h> 0043 #include <kdebug.h> 0044 #include <klocalizedstring.h> 0045 #include <kcombobox.h> 0046 #include <kmessagebox.h> 0047 #include <kglobalsettings.h> 0048 #include <kcolorscheme.h> 0049 0050 #include "kmplayerconfig.h" 0051 #include "kmplayerpartbase.h" 0052 #include "kmplayerprocess.h" 0053 #include "playlistview.h" 0054 #include "viewarea.h" 0055 #include "pref.h" 0056 0057 using namespace KMPlayer; 0058 0059 static OutputDriver _ads[] = { 0060 { "alsa,oss,sdl,arts", i18n ("Auto") }, 0061 { "oss", i18n ("Open Sound System") }, 0062 { "sdl", i18n ("Simple DirectMedia Layer") }, 0063 { "alsa", i18n ("Advanced Linux Sound Architecture") }, 0064 { "arts", i18n ("Analog Real-Time Synthesizer") }, 0065 { "jack", i18n ("JACK Audio Connection Kit") }, 0066 { "openal", i18n ("OpenAL") }, 0067 { "esd", i18n ("Enlightened Sound Daemon") }, 0068 { "alsa5", i18n ("Advanced Linux Sound Architecture v0.5") }, 0069 { "alsa9", i18n ("Advanced Linux Sound Architecture v0.9") }, 0070 { "", i18n ("Use back-end defaults") }, 0071 { "pulse", i18n ("PulseAudio") }, 0072 { 0, QString () } 0073 }; 0074 0075 static OutputDriver _vds [] = { 0076 { "xv,sdl,x11", i18n ("Auto") }, 0077 { "x11", i18n ("X11Shm") }, 0078 { "xvidix", i18n ("XVidix") }, 0079 { "xvmc,xv", i18n ("XvMC") }, 0080 { "sdl", i18n ("SDL") }, 0081 { "gl", i18n ("OpenGL") }, 0082 { "gl2", i18n ("OpenGL MT") }, 0083 { "xv", i18n ("XVideo") }, 0084 { "vdpau", i18n ("Video Decode and Presentation API for Unix") }, 0085 { 0, QString () } 0086 }; 0087 0088 static const int ADRIVER_ARTS_INDEX = 4; 0089 0090 0091 KDE_NO_CDTOR_EXPORT Settings::Settings (PartBase * player, KSharedConfigPtr config) 0092 : pagelist (0L), configdialog (0L), m_config (config), m_player (player) { 0093 audiodrivers = _ads; 0094 videodrivers = _vds; 0095 colors [ColorSetting::playlist_background].title = i18n ("Playlist background"); 0096 colors [ColorSetting::playlist_background].option = "PlaylistBackground"; 0097 colors [ColorSetting::playlist_background].color = 0098 KColorScheme(QPalette::Active, KColorScheme::View).background().color(); 0099 colors [ColorSetting::playlist_foreground].title = i18n ("Playlist foreground"); 0100 colors [ColorSetting::playlist_foreground].option = "PlaylistForeground"; 0101 colors [ColorSetting::playlist_foreground].color = 0102 KColorScheme(QPalette::Active, KColorScheme::View).foreground().color(); 0103 colors [ColorSetting::console_background].title =i18n("Console background"); 0104 colors [ColorSetting::playlist_active].title = i18n("Playlist active item"); 0105 colors [ColorSetting::playlist_active].option = "PlaylistActive"; 0106 colors [ColorSetting::playlist_active].color = 0107 KColorScheme(QPalette::Active, KColorScheme::Selection).foreground().color(); 0108 colors [ColorSetting::console_background].option = "ConsoleBackground"; 0109 colors [ColorSetting::console_background].color = QColor (0, 0, 0); 0110 colors [ColorSetting::console_foreground].title = i18n ("Console foreground"); 0111 colors [ColorSetting::console_foreground].option = "ConsoleForeground"; 0112 colors [ColorSetting::console_foreground].color = QColor (0xB2, 0xB2, 0xB2); 0113 colors [ColorSetting::video_background].title = i18n ("Video background"); 0114 colors [ColorSetting::video_background].option = "VideoBackground"; 0115 colors [ColorSetting::video_background].color = QColor (0, 0, 0); 0116 colors [ColorSetting::area_background].title = i18n ("Viewing area background"); 0117 colors [ColorSetting::area_background].option = "ViewingAreaBackground"; 0118 colors [ColorSetting::area_background].color = QColor (0, 0, 0); 0119 colors [ColorSetting::infowindow_background].title = i18n ("Info window background"); 0120 colors [ColorSetting::infowindow_background].option ="InfoWindowBackground"; 0121 colors [ColorSetting::infowindow_background].color = 0122 KColorScheme(QPalette::Active, KColorScheme::View).background().color(); 0123 colors [ColorSetting::infowindow_foreground].title = i18n ("Info window foreground"); 0124 colors [ColorSetting::infowindow_foreground].option ="InfoWindowForeground"; 0125 colors [ColorSetting::infowindow_foreground].color = 0126 colors [ColorSetting::playlist_foreground].color; 0127 fonts [FontSetting::playlist].title = i18n ("Playlist"); 0128 fonts [FontSetting::playlist].option = "PlaylistFont"; 0129 fonts [FontSetting::playlist].font = KGlobalSettings::generalFont(); 0130 fonts [FontSetting::playlist].font.setItalic (true); 0131 fonts [FontSetting::infowindow].title = i18n ("Info window"); 0132 fonts [FontSetting::infowindow].option = "InfoWindowFont"; 0133 fonts [FontSetting::infowindow].font = KGlobalSettings::generalFont(); 0134 } 0135 0136 KDE_NO_CDTOR_EXPORT Settings::~Settings () { 0137 // configdialog should be destroyed when the view is destroyed 0138 //delete configdialog; 0139 } 0140 0141 KDE_EXPORT const char * strMPlayerGroup = "MPlayer"; 0142 const char * strGeneralGroup = "General Options"; 0143 static const char * strKeepSizeRatio = "Keep Size Ratio"; 0144 static const char * strRememberSize = "Remember Size"; 0145 static const char * strAutoResize = "Auto Resize"; 0146 static const char * strDockSysTray = "Dock in System Tray"; 0147 static const char * strNoIntro = "No Intro"; 0148 static const char * strVolume = "Volume"; 0149 static const char * strContrast = "Contrast"; 0150 static const char * strBrightness = "Brightness"; 0151 static const char * strHue = "Hue"; 0152 static const char * strSaturation = "Saturation"; 0153 static const char * strURLList = "URL List"; 0154 static const char * strSubURLList = "URL Sub Title List"; 0155 static const char * strPrefBitRate = "Preferred Bitrate"; 0156 static const char * strMaxBitRate = "Maximum Bitrate"; 0157 //static const char * strUseArts = "Use aRts"; 0158 static const char * strVoDriver = "Video Driver"; 0159 static const char * strAoDriver = "Audio Driver"; 0160 static const char * strLoop = "Loop"; 0161 static const char * strFrameDrop = "Frame Drop"; 0162 static const char * strAdjustVolume = "Auto Adjust Volume"; 0163 static const char * strAdjustColors = "Auto Adjust Colors"; 0164 static const char * strAddConfigButton = "Add Configure Button"; 0165 static const char * strAddPlaylistButton = "Add Playlist Button"; 0166 static const char * strAddRecordButton = "Add Record Button"; 0167 static const char * strAddBroadcastButton = "Add Broadcast Button"; 0168 //static const char * strAutoHideSlider = "Auto Hide Slider"; 0169 static const char * strSeekTime = "Forward/Backward Seek Time"; 0170 static const char * strDVDDevice = "DVD Device"; 0171 //static const char * strShowDVD = "Show DVD Menu"; 0172 //static const char * strShowVCD = "Show VCD Menu"; 0173 static const char * strVCDDevice = "VCD Device"; 0174 const char * strUrlBackend = "URL Backend"; 0175 static const char * strClickToPlay = "Click to Play"; 0176 static const char * strAllowHref = "Allow HREF"; 0177 // postproc thingies 0178 static const char * strPPGroup = "Post processing options"; 0179 static const char * strPostProcessing = "Post processing"; 0180 static const char * strDisablePPauto = "Automatically disable post processing"; 0181 static const char * strPP_Default = "Default preset"; 0182 static const char * strPP_Fast = "Fast preset"; 0183 static const char * strPP_Custom = "Custom preset"; 0184 0185 static const char * strCustom_Hz = "Horizontal deblocking"; 0186 static const char * strCustom_Hz_Aq = "Horizontal deblocking auto quality"; 0187 static const char * strCustom_Hz_Ch = "Horizontal deblocking chrominance"; 0188 0189 static const char * strCustom_Vt = "Vertical deblocking"; 0190 static const char * strCustom_Vt_Aq = "Vertical deblocking auto quality"; 0191 static const char * strCustom_Vt_Ch = "Vertical deblocking chrominance"; 0192 0193 static const char * strCustom_Dr = "Dering filter"; 0194 static const char * strCustom_Dr_Aq = "Dering auto quality"; 0195 static const char * strCustom_Dr_Ch = "Dering chrominance"; 0196 0197 static const char * strCustom_Al = "Autolevel"; 0198 static const char * strCustom_Al_F = "Autolevel full range"; 0199 0200 static const char * strCustom_Tn = "Temporal Noise Reducer"; 0201 static const char * strCustom_Tn_S = "Temporal Noise Reducer strength"; 0202 0203 static const char * strPP_Lin_Blend_Int = "Linear Blend Deinterlacer"; 0204 static const char * strPP_Lin_Int = "Linear Interpolating Deinterlacer"; 0205 static const char * strPP_Cub_Int = "Cubic Interpolating Deinterlacer"; 0206 static const char * strPP_Med_Int = "Median Interpolating Deinterlacer"; 0207 static const char * strPP_FFmpeg_Int = "FFmpeg Interpolating Deinterlacer"; 0208 // end of postproc 0209 // recording 0210 static const char * strRecordingGroup = "Recording"; 0211 static const char * strRecorder = "Recorder"; 0212 static const char * strMencoderArgs = "Mencoder Arguments"; 0213 static const char * strFFMpegArgs = "FFMpeg Arguments"; 0214 static const char * strRecordingFile = "Last Recording Output File"; 0215 static const char * strAutoPlayAfterRecording = "Auto Play After Recording"; 0216 static const char * strAutoPlayAfterTime = "Auto Play After Recording Time"; 0217 static const char * strRecordingCopy = "Recording Is Copy"; 0218 0219 KDE_NO_EXPORT void Settings::applyColorSetting (bool only_changed_ones) { 0220 View *view = static_cast <View *> (m_player->view ()); 0221 if (!view) return; 0222 for (int i = 0; i < int (ColorSetting::last_target); i++) 0223 if (!only_changed_ones || colors[i].color != colors[i].newcolor) { 0224 colors[i].color = colors[i].newcolor; 0225 QPalette palette; 0226 switch (ColorSetting::Target (i)) { 0227 case ColorSetting::playlist_background: 0228 palette.setColor (view->playList()->viewport ()->backgroundRole(), colors[i].color); 0229 view->playList()->viewport ()->setPalette (palette); 0230 break; 0231 case ColorSetting::playlist_foreground: 0232 palette.setColor (view->playList()->foregroundRole(), colors[i].color); 0233 view->playList()->setPalette (palette); 0234 break; 0235 case ColorSetting::playlist_active: 0236 view->playList()->setActiveForegroundColor (colors[i].color); 0237 break; 0238 case ColorSetting::console_background: 0239 palette.setColor (view->console()->backgroundRole(), colors[i].color); 0240 view->console()->setPalette (palette); 0241 break; 0242 case ColorSetting::console_foreground: 0243 palette.setColor (view->console()->foregroundRole(), colors[i].color); 0244 view->console()->setPalette (palette); 0245 break; 0246 case ColorSetting::video_background: 0247 //palette.setColor (view->viewer()->backgroundRole(), colors[i].color); 0248 //view->viewer()->setPalette (palette); 0249 break; 0250 case ColorSetting::area_background: 0251 palette.setColor (view->viewArea()->backgroundRole(), colors[i].color); 0252 view->viewArea()->setPalette (palette); 0253 break; 0254 case ColorSetting::infowindow_background: 0255 palette.setColor(view->infoPanel()->backgroundRole(), colors[i].color); 0256 view->infoPanel()->setPalette (palette); 0257 break; 0258 case ColorSetting::infowindow_foreground: 0259 palette.setColor(view->infoPanel()->foregroundRole(), colors[i].color); 0260 view->infoPanel()->setPalette (palette); 0261 break; 0262 default: 0263 ; 0264 } 0265 } 0266 for (int i = 0; i < int (FontSetting::last_target); i++) 0267 if (!only_changed_ones || fonts[i].font != fonts[i].newfont) { 0268 fonts[i].font = fonts[i].newfont; 0269 switch (FontSetting::Target (i)) { 0270 case FontSetting::playlist: 0271 view->playList ()->setFont (fonts[i].font); 0272 break; 0273 case FontSetting::infowindow: 0274 view->infoPanel ()->setFont (fonts[i].font); 0275 break; 0276 default: 0277 ; 0278 } 0279 } 0280 } 0281 0282 View * Settings::defaultView () { 0283 return static_cast <View *> (m_player->view ()); 0284 } 0285 0286 KDE_NO_EXPORT void Settings::readConfig () { 0287 KConfigGroup general (m_config, strGeneralGroup); 0288 no_intro = general.readEntry (strNoIntro, false); 0289 urllist = general.readEntry (strURLList, QStringList()); 0290 sub_urllist = general.readEntry (strSubURLList, QStringList()); 0291 prefbitrate = general.readEntry (strPrefBitRate, 512); 0292 maxbitrate = general.readEntry (strMaxBitRate, 1024); 0293 volume = general.readEntry (strVolume, 20); 0294 contrast = general.readEntry (strContrast, 0); 0295 brightness = general.readEntry (strBrightness, 0); 0296 hue = general.readEntry (strHue, 0); 0297 saturation = general.readEntry (strSaturation, 0); 0298 const QMap <QString, Source*>::const_iterator e = m_player->sources ().constEnd (); 0299 QMap <QString, Source *>::const_iterator i = m_player->sources().constBegin (); 0300 for (; i != e; ++i) 0301 backends[i.value()->name ()] = general.readEntry (i.value()->name ()); 0302 for (int i = 0; i < int (ColorSetting::last_target); i++) 0303 colors[i].newcolor = colors[i].color = general.readEntry (colors[i].option, colors[i].color); 0304 for (int i = 0; i < int (FontSetting::last_target); i++) 0305 fonts[i].newfont = fonts[i].font = general.readEntry (fonts[i].option, fonts[i].font); 0306 0307 KConfigGroup mplayer (m_config, strMPlayerGroup); 0308 sizeratio = mplayer.readEntry (strKeepSizeRatio, true); 0309 remembersize = mplayer.readEntry (strRememberSize, true); 0310 autoresize = mplayer.readEntry (strAutoResize, true); 0311 docksystray = mplayer.readEntry (strDockSysTray, true); 0312 loop = mplayer.readEntry (strLoop, false); 0313 framedrop = mplayer.readEntry (strFrameDrop, true); 0314 autoadjustvolume = mplayer.readEntry (strAdjustVolume, true); 0315 autoadjustcolors = mplayer.readEntry (strAdjustColors, true); 0316 showcnfbutton = mplayer.readEntry (strAddConfigButton, true); 0317 showrecordbutton = mplayer.readEntry (strAddRecordButton, true); 0318 showbroadcastbutton = mplayer.readEntry (strAddBroadcastButton, true); 0319 showplaylistbutton = mplayer.readEntry (strAddPlaylistButton, true); 0320 seektime = mplayer.readEntry (strSeekTime, 10); 0321 dvddevice = mplayer.readEntry (strDVDDevice, "/dev/dvd"); 0322 vcddevice = mplayer.readEntry (strVCDDevice, "/dev/cdrom"); 0323 videodriver = mplayer.readEntry (strVoDriver, 0); 0324 audiodriver = mplayer.readEntry (strAoDriver, 0); 0325 clicktoplay = mplayer.readEntry (strClickToPlay, false); 0326 grabhref = mplayer.readEntry (strAllowHref, false); 0327 0328 // recording 0329 KConfigGroup rec_cfg (m_config, strRecordingGroup); 0330 mencoderarguments = rec_cfg.readEntry (strMencoderArgs, QString ("-oac mp3lame -ovc lavc")); 0331 ffmpegarguments = rec_cfg.readEntry (strFFMpegArgs, QString ("-f avi -acodec mp3 -vcodec mpeg4")); 0332 recordfile = rec_cfg.readPathEntry(strRecordingFile, QDir::homePath () + "/record.avi"); 0333 recorder = Recorder (rec_cfg.readEntry (strRecorder, int (MEncoder))); 0334 replayoption = ReplayOption (rec_cfg.readEntry (strAutoPlayAfterRecording, int (ReplayFinished))); 0335 replaytime = rec_cfg.readEntry (strAutoPlayAfterTime, 60); 0336 recordcopy = rec_cfg.readEntry(strRecordingCopy, true); 0337 0338 // postproc 0339 KConfigGroup pp_cfg (m_config, strPPGroup); 0340 postprocessing = pp_cfg.readEntry (strPostProcessing, false); 0341 disableppauto = pp_cfg.readEntry (strDisablePPauto, true); 0342 0343 pp_default = pp_cfg.readEntry (strPP_Default, true); 0344 pp_fast = pp_cfg.readEntry (strPP_Fast, false); 0345 pp_custom = pp_cfg.readEntry (strPP_Custom, false); 0346 // default these to default preset 0347 pp_custom_hz = pp_cfg.readEntry (strCustom_Hz, true); 0348 pp_custom_hz_aq = pp_cfg.readEntry (strCustom_Hz_Aq, true); 0349 pp_custom_hz_ch = pp_cfg.readEntry (strCustom_Hz_Ch, false); 0350 0351 pp_custom_vt = pp_cfg.readEntry (strCustom_Vt, true); 0352 pp_custom_vt_aq = pp_cfg.readEntry (strCustom_Vt_Aq, true); 0353 pp_custom_vt_ch = pp_cfg.readEntry (strCustom_Vt_Ch, false); 0354 0355 pp_custom_dr = pp_cfg.readEntry (strCustom_Dr, true); 0356 pp_custom_dr_aq = pp_cfg.readEntry (strCustom_Dr_Aq, true); 0357 pp_custom_dr_ch = pp_cfg.readEntry (strCustom_Dr_Ch, false); 0358 0359 pp_custom_al = pp_cfg.readEntry (strCustom_Al, true); 0360 pp_custom_al_f = pp_cfg.readEntry (strCustom_Al_F, false); 0361 0362 pp_custom_tn = pp_cfg.readEntry (strCustom_Tn, true); 0363 pp_custom_tn_s = pp_cfg.readEntry (strCustom_Tn_S, 0); 0364 0365 pp_lin_blend_int = pp_cfg.readEntry (strPP_Lin_Blend_Int, false); 0366 pp_lin_int = pp_cfg.readEntry (strPP_Lin_Int, false); 0367 pp_cub_int = pp_cfg.readEntry (strPP_Cub_Int, false); 0368 pp_med_int = pp_cfg.readEntry (strPP_Med_Int, false); 0369 pp_ffmpeg_int = pp_cfg.readEntry (strPP_FFmpeg_Int, false); 0370 0371 for (PreferencesPage * p = pagelist; p; p = p->next) 0372 p->read (m_config); 0373 emit configChanged (); 0374 } 0375 0376 KDE_NO_EXPORT bool Settings::createDialog () { 0377 if (configdialog) return false; 0378 configdialog = new Preferences (m_player, this); 0379 const MediaManager::ProcessInfoMap::const_iterator e = m_player->mediaManager()->processInfos ().constEnd (); 0380 for (MediaManager::ProcessInfoMap::const_iterator i = m_player->mediaManager()->processInfos ().constBegin(); i != e; ++i) { 0381 ProcessInfo *p = i.value (); 0382 if (p->supports ("urlsource")) { 0383 QString lbl = p->label.remove (QChar ('&')); 0384 configdialog->m_SourcePageURL->backend->addItem(lbl); 0385 } 0386 } 0387 assert(configdialog->m_SourcePageURL->backend->count() > 0); 0388 connect (configdialog, SIGNAL (accepted ()), 0389 this, SLOT (okPressed ())); 0390 connect (configdialog->button(QDialogButtonBox::Apply), SIGNAL(clicked ()), 0391 this, SLOT (okPressed ())); 0392 /*if (KApplication::kApplication()) 0393 connect (configdialog, SIGNAL (helpClicked ()), 0394 this, SLOT (getHelp ()));*/ 0395 return true; 0396 } 0397 0398 void Settings::addPage (PreferencesPage * page) { 0399 for (PreferencesPage * p = pagelist; p; p = p->next) 0400 if (p == page) 0401 return; 0402 page->read (m_config); 0403 if (configdialog) { 0404 configdialog->addPrefPage (page); 0405 page->sync (false); 0406 } 0407 page->next = pagelist; 0408 pagelist = page; 0409 } 0410 0411 void Settings::removePage (PreferencesPage * page) { 0412 if (configdialog) 0413 configdialog->removePrefPage (page); 0414 PreferencesPage * prev = 0L; 0415 for (PreferencesPage * p = pagelist; p; prev = p, p = p->next) 0416 if (p == page) { 0417 if (prev) 0418 prev->next = p->next; 0419 else 0420 pagelist = p->next; 0421 break; 0422 } 0423 } 0424 0425 static void selectItem(QButtonGroup* group, int id) { 0426 const QList<QAbstractButton *> buttons = group->buttons(); 0427 for (int i = 0; i < buttons.size(); ++i) 0428 buttons[i]->setChecked(group->id(buttons[i]) == id); 0429 } 0430 0431 void Settings::show (const char * pagename) { 0432 bool created = createDialog (); 0433 configdialog->m_GeneralPageGeneral->keepSizeRatio->setChecked (sizeratio); 0434 configdialog->m_GeneralPageGeneral->autoResize->setChecked (autoresize); 0435 configdialog->m_GeneralPageGeneral->sizesChoice->button(0)->setChecked(!remembersize); 0436 configdialog->m_GeneralPageGeneral->sizesChoice->button(1)->setChecked(remembersize); 0437 configdialog->m_GeneralPageGeneral->dockSysTray->setChecked (docksystray); 0438 configdialog->m_GeneralPageGeneral->loop->setChecked (loop); 0439 configdialog->m_GeneralPageGeneral->framedrop->setChecked (framedrop); 0440 configdialog->m_GeneralPageGeneral->adjustvolume->setChecked (autoadjustvolume); 0441 configdialog->m_GeneralPageGeneral->adjustcolors->setChecked (autoadjustcolors); 0442 //configdialog->m_GeneralPageGeneral->autoHideSlider->setChecked (autohideslider); 0443 configdialog->m_GeneralPageGeneral->showConfigButton->setChecked (showcnfbutton); 0444 configdialog->m_GeneralPageGeneral->showPlaylistButton->setChecked (showplaylistbutton); 0445 configdialog->m_GeneralPageGeneral->showRecordButton->setChecked (showrecordbutton); 0446 configdialog->m_GeneralPageGeneral->showBroadcastButton->setChecked (showbroadcastbutton); 0447 configdialog->m_GeneralPageGeneral->seekTime->setValue(seektime); 0448 for (int i = 0; i < int (ColorSetting::last_target); i++) 0449 colors[i].newcolor = colors[i].color; 0450 for (int i = 0; i < int (FontSetting::last_target); i++) 0451 fonts[i].newfont = fonts[i].font; 0452 0453 QString current = m_player->source()->url().prettyUrl(); 0454 if (!current.isEmpty() && !urllist.contains(current)) 0455 urllist.push_front(current); 0456 configdialog->m_SourcePageURL->urllist->clear (); 0457 configdialog->m_SourcePageURL->urllist->insertItems (0, urllist); 0458 if (!current.isEmpty()) 0459 configdialog->m_SourcePageURL->urllist->setCurrentText(current); 0460 else 0461 configdialog->m_SourcePageURL->urllist->setCurrentIndex(-1); 0462 current = m_player->source()->subUrl().prettyUrl(); 0463 if (!current.isEmpty() && !sub_urllist.contains(current)) 0464 sub_urllist.push_front(current); 0465 configdialog->m_SourcePageURL->sub_urllist->clear (); 0466 configdialog->m_SourcePageURL->sub_urllist->insertItems (0, sub_urllist); 0467 if (!current.isEmpty()) 0468 configdialog->m_SourcePageURL->sub_urllist->setCurrentText(current); 0469 else 0470 configdialog->m_SourcePageURL->sub_urllist->setCurrentIndex(-1); 0471 configdialog->m_SourcePageURL->changed = false; 0472 0473 configdialog->m_SourcePageURL->prefBitRate->setText (QString::number (prefbitrate)); 0474 configdialog->m_SourcePageURL->maxBitRate->setText (QString::number (maxbitrate)); 0475 0476 configdialog->m_GeneralPageOutput->videoDriver->setCurrentRow(videodriver); 0477 configdialog->m_GeneralPageOutput->audioDriver->setCurrentRow(audiodriver); 0478 configdialog->m_SourcePageURL->backend->setCurrentItem(configdialog->m_SourcePageURL->backend->findItems(backends["urlsource"], Qt::MatchFixedString).first()); 0479 int id = 0; 0480 const MediaManager::ProcessInfoMap::const_iterator e = m_player->mediaManager()->processInfos ().constEnd (); 0481 for (MediaManager::ProcessInfoMap::const_iterator i = m_player->mediaManager()->processInfos ().constBegin(); i != e; ++i) { 0482 ProcessInfo *p = i.value (); 0483 if (p->supports ("urlsource")) { 0484 if (backends["urlsource"] == QString (p->name)) 0485 configdialog->m_SourcePageURL->backend->setCurrentRow(id); 0486 id++; 0487 } 0488 } 0489 configdialog->m_SourcePageURL->clicktoplay->setChecked (clicktoplay); 0490 configdialog->m_SourcePageURL->grabhref->setChecked (grabhref); 0491 0492 // postproc 0493 configdialog->m_OPPagePostproc->postProcessing->setChecked (postprocessing); 0494 configdialog->m_OPPagePostproc->disablePPauto->setChecked (disableppauto); 0495 configdialog->m_OPPagePostproc->PostprocessingOptions->setEnabled (postprocessing); 0496 0497 configdialog->m_OPPagePostproc->defaultPreset->setChecked (pp_default); 0498 configdialog->m_OPPagePostproc->fastPreset->setChecked (pp_fast); 0499 configdialog->m_OPPagePostproc->customPreset->setChecked (pp_custom); 0500 0501 configdialog->m_OPPagePostproc->HzDeblockFilter->setChecked (pp_custom_hz); 0502 configdialog->m_OPPagePostproc->HzDeblockAQuality->setChecked (pp_custom_hz_aq); 0503 configdialog->m_OPPagePostproc->HzDeblockCFiltering->setChecked (pp_custom_hz_ch); 0504 0505 configdialog->m_OPPagePostproc->VtDeblockFilter->setChecked (pp_custom_vt); 0506 configdialog->m_OPPagePostproc->VtDeblockAQuality->setChecked (pp_custom_vt_aq); 0507 configdialog->m_OPPagePostproc->VtDeblockCFiltering->setChecked (pp_custom_vt_ch); 0508 0509 configdialog->m_OPPagePostproc->DeringFilter->setChecked (pp_custom_dr); 0510 configdialog->m_OPPagePostproc->DeringAQuality->setChecked (pp_custom_dr_aq); 0511 configdialog->m_OPPagePostproc->DeringCFiltering->setChecked (pp_custom_dr_ch); 0512 0513 configdialog->m_OPPagePostproc->AutolevelsFilter->setChecked (pp_custom_al); 0514 configdialog->m_OPPagePostproc->AutolevelsFullrange->setChecked (pp_custom_al_f); 0515 configdialog->m_OPPagePostproc->TmpNoiseFilter->setChecked (pp_custom_tn); 0516 //configdialog->m_OPPagePostproc->TmpNoiseSlider->setValue (pp_custom_tn_s); 0517 0518 configdialog->m_OPPagePostproc->LinBlendDeinterlacer->setChecked (pp_lin_blend_int); 0519 configdialog->m_OPPagePostproc->LinIntDeinterlacer->setChecked (pp_lin_int); 0520 configdialog->m_OPPagePostproc->CubicIntDeinterlacer->setChecked (pp_cub_int); 0521 configdialog->m_OPPagePostproc->MedianDeinterlacer->setChecked (pp_med_int); 0522 configdialog->m_OPPagePostproc->FfmpegDeinterlacer->setChecked (pp_ffmpeg_int); 0523 // recording 0524 configdialog->m_RecordPage->url->lineEdit()->setText (recordfile); 0525 selectItem(configdialog->m_RecordPage->replay, int (replayoption)); 0526 selectItem(configdialog->m_RecordPage->recorder, int (recorder)); 0527 configdialog->m_RecordPage->replayClicked (int (replayoption)); 0528 configdialog->m_RecordPage->recorderClicked (int (recorder)); 0529 configdialog->m_RecordPage->replaytime->setValue (replaytime); 0530 configdialog->m_MEncoderPage->arguments->setText (mencoderarguments); 0531 selectItem(configdialog->m_MEncoderPage->format, recordcopy ? 0 : 1); 0532 configdialog->m_MEncoderPage->formatClicked (recordcopy ? 0 : 1); 0533 configdialog->m_FFMpegPage->arguments->setText (ffmpegarguments); 0534 0535 //dynamic stuff 0536 for (PreferencesPage * p = pagelist; p; p = p->next) 0537 p->sync (false); 0538 //\dynamic stuff 0539 if (pagename) 0540 configDialog ()->setPage (pagename); 0541 if (created) 0542 configdialog->resize (configdialog->minimumSize ()); 0543 configdialog->show (); 0544 } 0545 0546 void Settings::writeConfig () { 0547 KConfigGroup gen_cfg (m_config, strGeneralGroup); 0548 gen_cfg.writeEntry (strURLList, urllist); 0549 gen_cfg.writeEntry (strSubURLList, sub_urllist); 0550 gen_cfg.writeEntry (strPrefBitRate, prefbitrate); 0551 gen_cfg.writeEntry (strMaxBitRate, maxbitrate); 0552 gen_cfg.writeEntry (strVolume, volume); 0553 gen_cfg.writeEntry (strContrast, contrast); 0554 gen_cfg.writeEntry (strBrightness, brightness); 0555 gen_cfg.writeEntry (strHue, hue); 0556 gen_cfg.writeEntry (strSaturation, saturation); 0557 const QMap<QString,QString>::ConstIterator b_end = backends.constEnd (); 0558 for (QMap<QString,QString>::ConstIterator i = backends.constBegin(); i != b_end; ++i) 0559 gen_cfg.writeEntry (i.key (), i.value ()); 0560 for (int i = 0; i < int (ColorSetting::last_target); i++) 0561 gen_cfg.writeEntry (colors[i].option, colors[i].color); 0562 for (int i = 0; i < int (FontSetting::last_target); i++) 0563 gen_cfg.writeEntry (fonts[i].option, fonts[i].font); 0564 0565 KConfigGroup mplayer_cfg (m_config, strMPlayerGroup); 0566 mplayer_cfg.writeEntry (strKeepSizeRatio, sizeratio); 0567 mplayer_cfg.writeEntry (strAutoResize, autoresize); 0568 mplayer_cfg.writeEntry (strRememberSize, remembersize); 0569 mplayer_cfg.writeEntry (strDockSysTray, docksystray); 0570 mplayer_cfg.writeEntry (strLoop, loop); 0571 mplayer_cfg.writeEntry (strFrameDrop, framedrop); 0572 mplayer_cfg.writeEntry (strAdjustVolume, autoadjustvolume); 0573 mplayer_cfg.writeEntry (strAdjustColors, autoadjustcolors); 0574 mplayer_cfg.writeEntry (strSeekTime, seektime); 0575 mplayer_cfg.writeEntry (strVoDriver, videodriver); 0576 mplayer_cfg.writeEntry (strAoDriver, audiodriver); 0577 mplayer_cfg.writeEntry (strClickToPlay, clicktoplay); 0578 mplayer_cfg.writeEntry (strAllowHref, grabhref); 0579 mplayer_cfg.writeEntry (strAddConfigButton, showcnfbutton); 0580 mplayer_cfg.writeEntry (strAddPlaylistButton, showplaylistbutton); 0581 mplayer_cfg.writeEntry (strAddRecordButton, showrecordbutton); 0582 mplayer_cfg.writeEntry (strAddBroadcastButton, showbroadcastbutton); 0583 mplayer_cfg.writeEntry (strDVDDevice, dvddevice); 0584 mplayer_cfg.writeEntry (strVCDDevice, vcddevice); 0585 0586 //postprocessing stuff 0587 KConfigGroup pp_cfg (m_config, strPPGroup); 0588 pp_cfg.writeEntry (strPostProcessing, postprocessing); 0589 pp_cfg.writeEntry (strDisablePPauto, disableppauto); 0590 pp_cfg.writeEntry (strPP_Default, pp_default); 0591 pp_cfg.writeEntry (strPP_Fast, pp_fast); 0592 pp_cfg.writeEntry (strPP_Custom, pp_custom); 0593 0594 pp_cfg.writeEntry (strCustom_Hz, pp_custom_hz); 0595 pp_cfg.writeEntry (strCustom_Hz_Aq, pp_custom_hz_aq); 0596 pp_cfg.writeEntry (strCustom_Hz_Ch, pp_custom_hz_ch); 0597 0598 pp_cfg.writeEntry (strCustom_Vt, pp_custom_vt); 0599 pp_cfg.writeEntry (strCustom_Vt_Aq, pp_custom_vt_aq); 0600 pp_cfg.writeEntry (strCustom_Vt_Ch, pp_custom_vt_ch); 0601 0602 pp_cfg.writeEntry (strCustom_Dr, pp_custom_dr); 0603 pp_cfg.writeEntry (strCustom_Dr_Aq, pp_custom_vt_aq); 0604 pp_cfg.writeEntry (strCustom_Dr_Ch, pp_custom_vt_ch); 0605 0606 pp_cfg.writeEntry (strCustom_Al, pp_custom_al); 0607 pp_cfg.writeEntry (strCustom_Al_F, pp_custom_al_f); 0608 0609 pp_cfg.writeEntry (strCustom_Tn, pp_custom_tn); 0610 pp_cfg.writeEntry (strCustom_Tn_S, pp_custom_tn_s); 0611 0612 pp_cfg.writeEntry (strPP_Lin_Blend_Int, pp_lin_blend_int); 0613 pp_cfg.writeEntry (strPP_Lin_Int, pp_lin_int); 0614 pp_cfg.writeEntry (strPP_Cub_Int, pp_cub_int); 0615 pp_cfg.writeEntry (strPP_Med_Int, pp_med_int); 0616 pp_cfg.writeEntry (strPP_FFmpeg_Int, pp_ffmpeg_int); 0617 0618 // recording 0619 KConfigGroup rec_cfg (m_config, strRecordingGroup); 0620 rec_cfg.writePathEntry (strRecordingFile, recordfile); 0621 rec_cfg.writeEntry (strAutoPlayAfterRecording, int (replayoption)); 0622 rec_cfg.writeEntry (strAutoPlayAfterTime, replaytime); 0623 rec_cfg.writeEntry (strRecorder, int (recorder)); 0624 rec_cfg.writeEntry (strRecordingCopy, recordcopy); 0625 rec_cfg.writeEntry (strMencoderArgs, mencoderarguments); 0626 rec_cfg.writeEntry (strFFMpegArgs, ffmpegarguments); 0627 0628 //dynamic stuff 0629 for (PreferencesPage * p = pagelist; p; p = p->next) 0630 p->write (m_config); 0631 //\dynamic stuff 0632 m_config->sync (); 0633 } 0634 0635 void Settings::okPressed () { 0636 bool urlchanged = configdialog->m_SourcePageURL->changed; 0637 bool playerchanged = false; 0638 KUrl url = configdialog->m_SourcePageURL->url->url (); 0639 KUrl sub_url = configdialog->m_SourcePageURL->sub_url->url (); 0640 if (urlchanged) { 0641 if (url.isEmpty ()) { 0642 urlchanged = false; 0643 } else { 0644 if (KUrl (url.url ()).isLocalFile () || KUrl::isRelativeUrl (url.url ())) { 0645 QFileInfo fi (url.path ()); 0646 int hpos = url.url ().lastIndexOf ('#'); 0647 QString xine_directives (""); 0648 while (!fi.exists () && hpos > -1) { 0649 xine_directives = url.url ().mid (hpos); 0650 fi.setFile (url.url ().left (hpos)); 0651 hpos = url.url ().lastIndexOf ('#', hpos-1); 0652 } 0653 if (!fi.exists ()) { 0654 urlchanged = false; 0655 KMessageBox::error (m_player->view (), i18n ("File %1 does not exist.",url.url ()), i18n ("Error")); 0656 } else { 0657 configdialog->m_SourcePageURL->url->setUrl (QString(fi.absoluteFilePath () + xine_directives)); 0658 } 0659 } 0660 if (urlchanged && 0661 !sub_url.url ().isEmpty () && 0662 (KUrl (sub_url.url ()).isLocalFile () || 0663 KUrl::isRelativeUrl (sub_url.url ()))) { 0664 QFileInfo sfi (sub_url.path ()); 0665 if (!sfi.exists ()) { 0666 KMessageBox::error (m_player->view (), i18n ("Sub title file %1 does not exist.",sub_url.url ()), i18n ("Error")); 0667 configdialog->m_SourcePageURL->sub_url->setUrl (QString ()); 0668 } else 0669 configdialog->m_SourcePageURL->sub_url->setUrl (sfi.absoluteFilePath ()); 0670 } 0671 } 0672 } 0673 if (urlchanged) { 0674 KUrl uri (url.url ()); 0675 m_player->setUrl (uri.url ()); 0676 if (urllist.indexOf (uri.prettyUrl ()) < 0) 0677 configdialog->m_SourcePageURL->urllist->insertItem (0, uri.prettyUrl ()); 0678 KUrl sub_uri (sub_url.url ()); 0679 if (sub_urllist.indexOf (sub_uri.prettyUrl ()) < 0) 0680 configdialog->m_SourcePageURL->sub_urllist->insertItem (0, sub_uri.prettyUrl ()); 0681 } 0682 urllist.clear (); 0683 for (int i = 0; i < configdialog->m_SourcePageURL->urllist->count () && i < 20; ++i) 0684 // damnit why don't maxCount and setDuplicatesEnabled(false) work :( 0685 // and why can I put a qstringlist in it, but cannot get it out of it again.. 0686 if (!configdialog->m_SourcePageURL->urllist->itemText (i).isEmpty ()) 0687 urllist.push_back (configdialog->m_SourcePageURL->urllist->itemText (i)); 0688 sub_urllist.clear (); 0689 for (int i = 0; i < configdialog->m_SourcePageURL->sub_urllist->count () && i < 20; ++i) 0690 if (!configdialog->m_SourcePageURL->sub_urllist->itemText (i).isEmpty ()) 0691 sub_urllist.push_back (configdialog->m_SourcePageURL->sub_urllist->itemText (i)); 0692 prefbitrate = configdialog->m_SourcePageURL->prefBitRate->text ().toInt (); 0693 maxbitrate = configdialog->m_SourcePageURL->maxBitRate->text ().toInt (); 0694 sizeratio = configdialog->m_GeneralPageGeneral->keepSizeRatio->isChecked (); 0695 autoresize = configdialog->m_GeneralPageGeneral->autoResize->isChecked (); 0696 remembersize= configdialog->m_GeneralPageGeneral->sizesChoice->checkedId(); 0697 docksystray = configdialog->m_GeneralPageGeneral->dockSysTray->isChecked (); 0698 loop = configdialog->m_GeneralPageGeneral->loop->isChecked (); 0699 framedrop = configdialog->m_GeneralPageGeneral->framedrop->isChecked (); 0700 autoadjustvolume = configdialog->m_GeneralPageGeneral->adjustvolume->isChecked (); 0701 autoadjustcolors = configdialog->m_GeneralPageGeneral->adjustcolors->isChecked (); 0702 showcnfbutton = configdialog->m_GeneralPageGeneral->showConfigButton->isChecked (); 0703 showplaylistbutton = configdialog->m_GeneralPageGeneral->showPlaylistButton->isChecked (); 0704 showrecordbutton = configdialog->m_GeneralPageGeneral->showRecordButton->isChecked (); 0705 showbroadcastbutton = configdialog->m_GeneralPageGeneral->showBroadcastButton->isChecked (); 0706 seektime = configdialog->m_GeneralPageGeneral->seekTime->value(); 0707 0708 videodriver = configdialog->m_GeneralPageOutput->videoDriver->currentRow(); 0709 audiodriver = configdialog->m_GeneralPageOutput->audioDriver->currentRow(); 0710 QString backend_name = configdialog->m_SourcePageURL->backend->currentItem()->text(); 0711 if (!backend_name.isEmpty ()) { 0712 const MediaManager::ProcessInfoMap::const_iterator e = m_player->mediaManager()->processInfos ().constEnd (); 0713 for (MediaManager::ProcessInfoMap::const_iterator i = m_player->mediaManager()->processInfos ().constBegin(); i != e; ++i) { 0714 ProcessInfo *p = i.value (); 0715 if (p->supports ("urlsource") && 0716 p->label.remove (QChar ('&')) == backend_name) { 0717 backends["urlsource"] = p->name; 0718 break; 0719 } 0720 } 0721 } 0722 clicktoplay = configdialog->m_SourcePageURL->clicktoplay->isChecked (); 0723 grabhref = configdialog->m_SourcePageURL->grabhref->isChecked (); 0724 //postproc 0725 postprocessing = configdialog->m_OPPagePostproc->postProcessing->isChecked(); 0726 disableppauto = configdialog->m_OPPagePostproc->disablePPauto->isChecked(); 0727 pp_default = configdialog->m_OPPagePostproc->defaultPreset->isChecked(); 0728 pp_fast = configdialog->m_OPPagePostproc->fastPreset->isChecked(); 0729 pp_custom = configdialog->m_OPPagePostproc->customPreset->isChecked(); 0730 0731 pp_custom_hz = configdialog->m_OPPagePostproc->HzDeblockFilter->isChecked(); 0732 pp_custom_hz_aq = configdialog->m_OPPagePostproc->HzDeblockAQuality->isChecked(); 0733 pp_custom_hz_ch = configdialog->m_OPPagePostproc->HzDeblockCFiltering->isChecked(); 0734 0735 pp_custom_vt = configdialog->m_OPPagePostproc->VtDeblockFilter->isChecked(); 0736 pp_custom_vt_aq = configdialog->m_OPPagePostproc->VtDeblockAQuality->isChecked(); 0737 pp_custom_vt_ch = configdialog->m_OPPagePostproc->VtDeblockCFiltering->isChecked(); 0738 0739 pp_custom_dr = configdialog->m_OPPagePostproc->DeringFilter->isChecked(); 0740 pp_custom_dr_aq = configdialog->m_OPPagePostproc->DeringAQuality->isChecked(); 0741 pp_custom_dr_ch = configdialog->m_OPPagePostproc->DeringCFiltering->isChecked(); 0742 0743 pp_custom_al = configdialog->m_OPPagePostproc->AutolevelsFilter->isChecked(); 0744 pp_custom_al_f = configdialog->m_OPPagePostproc->AutolevelsFullrange->isChecked(); 0745 0746 pp_custom_tn = configdialog->m_OPPagePostproc->TmpNoiseFilter->isChecked(); 0747 pp_custom_tn_s = 0; // gotta fix this later 0748 //pp_custom_tn_s = configdialog->m_OPPagePostproc->TmpNoiseSlider->value(); 0749 0750 pp_lin_blend_int = configdialog->m_OPPagePostproc->LinBlendDeinterlacer->isChecked(); 0751 pp_lin_int = configdialog->m_OPPagePostproc->LinIntDeinterlacer->isChecked(); 0752 pp_cub_int = configdialog->m_OPPagePostproc->CubicIntDeinterlacer->isChecked(); 0753 pp_med_int = configdialog->m_OPPagePostproc->MedianDeinterlacer->isChecked(); 0754 pp_ffmpeg_int = configdialog->m_OPPagePostproc->FfmpegDeinterlacer->isChecked(); 0755 // recording 0756 recorder = Recorder (configdialog->m_RecordPage->recorder->checkedId()); 0757 replaytime = configdialog->m_RecordPage->replaytime->value (); 0758 recordfile = configdialog->m_RecordPage->url->lineEdit()->text (); 0759 mencoderarguments = configdialog->m_MEncoderPage->arguments->text (); 0760 ffmpegarguments = configdialog->m_FFMpegPage->arguments->text (); 0761 recordcopy = !configdialog->m_MEncoderPage->format->checkedId(); 0762 0763 //dynamic stuff 0764 for (PreferencesPage * p = pagelist; p; p = p->next) 0765 p->sync (true); 0766 //\dynamic stuff 0767 0768 writeConfig (); 0769 emit configChanged (); 0770 0771 if (urlchanged || playerchanged) { 0772 m_player->sources () ["urlsource"]->setSubURL 0773 (KUrl(configdialog->m_SourcePageURL->sub_url->url())); 0774 m_player->openUrl (KUrl (configdialog->m_SourcePageURL->url->url ())); 0775 m_player->source ()->setSubURL (KUrl (configdialog->m_SourcePageURL->sub_url->url ())); 0776 } 0777 } 0778 0779 KDE_NO_EXPORT void Settings::getHelp () { 0780 // KApplication::kApplication()->invokeBrowser ("man:/mplayer"); 0781 } 0782 0783 #include "kmplayerconfig.moc" 0784