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