KMPlayer – media player
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

742 рядки
37KB

  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. #include <algorithm>
  19. #include <functional>
  20. #include <config.h>
  21. #include <tqcheckbox.h>
  22. #include <tqtextedit.h>
  23. #include <tqpushbutton.h>
  24. #include <tqradiobutton.h>
  25. #include <tqtabwidget.h>
  26. #include <tqslider.h>
  27. #include <tqspinbox.h>
  28. #include <tqlabel.h>
  29. #include <tqbuttongroup.h>
  30. #include <tqfileinfo.h>
  31. #include <kurlrequester.h>
  32. #include <klineedit.h>
  33. #include <kstatusbar.h>
  34. #include <tdeconfig.h>
  35. #include <tdeapplication.h>
  36. #include <kurl.h>
  37. #include <kdebug.h>
  38. #include <tdelocale.h>
  39. #include <kcombobox.h>
  40. #include <tdemessagebox.h>
  41. #include <tdeglobalsettings.h>
  42. #include "kmplayersource.h"
  43. #include "kmplayerconfig.h"
  44. #include "kmplayerpartbase.h"
  45. #include "kmplayerprocess.h"
  46. #include "playlistview.h"
  47. #include "viewarea.h"
  48. #include "pref.h"
  49. using namespace KMPlayer;
  50. static OutputDriver _ads[] = {
  51. { "alsa,oss,sdl,arts", i18n ("Auto") },
  52. { "oss", i18n ("Open Sound System") },
  53. { "sdl", i18n ("Simple DirectMedia Layer") },
  54. { "alsa", i18n ("Advanced Linux Sound Architecture") },
  55. { "arts", i18n ("Analog Real-Time Synthesizer") },
  56. { "jack", i18n ("JACK Audio Connection Kit") },
  57. { "openal", i18n ("OpenAL") },
  58. { "esd", i18n ("Enlightened Sound Daemon") },
  59. { "alsa5", i18n ("Advanced Linux Sound Architecture v0.5") },
  60. { "alsa9", i18n ("Advanced Linux Sound Architecture v0.9") },
  61. { "", i18n ("Use back-end defaults") },
  62. { 0, TQString () }
  63. };
  64. static OutputDriver _vds [] = {
  65. { "xv,sdl,x11", i18n ("Auto") },
  66. { "x11", i18n ("X11Shm") },
  67. { "xvidix", i18n ("XVidix") },
  68. { "xvmc,xv", i18n ("XvMC") },
  69. { "sdl", i18n ("SDL") },
  70. { "gl", i18n ("OpenGL") },
  71. { "gl2", i18n ("OpenGL MT") },
  72. { "xv", i18n ("XVideo") },
  73. { 0, TQString () }
  74. };
  75. static const int ADRIVER_ARTS_INDEX = 4;
  76. KDE_NO_CDTOR_EXPORT Settings::Settings (PartBase * player, TDEConfig * config)
  77. : pagelist (0L), configdialog (0L), m_config (config), m_player (player) {
  78. audiodrivers = _ads;
  79. videodrivers = _vds;
  80. colors [ColorSetting::playlist_background].title = i18n ("Playlist background");
  81. colors [ColorSetting::playlist_background].option = "PlaylistBackground";
  82. colors [ColorSetting::playlist_background].color = TDEGlobalSettings::baseColor ();
  83. colors [ColorSetting::playlist_foreground].title = i18n ("Playlist foreground");
  84. colors [ColorSetting::playlist_foreground].option = "PlaylistForeground";
  85. colors [ColorSetting::playlist_foreground].color = TDEGlobalSettings::textColor();
  86. colors [ColorSetting::console_background].title =i18n("Console background");
  87. colors [ColorSetting::playlist_active].title = i18n("Playlist active item");
  88. colors [ColorSetting::playlist_active].option = "PlaylistActive";
  89. colors [ColorSetting::playlist_active].color = TDEGlobalSettings::linkColor();
  90. colors [ColorSetting::console_background].option = "ConsoleBackground";
  91. colors [ColorSetting::console_background].color = TQColor (0, 0, 0);
  92. colors [ColorSetting::console_foreground].title = i18n ("Console foreground");
  93. colors [ColorSetting::console_foreground].option = "ConsoleForeground";
  94. colors [ColorSetting::console_foreground].color = TQColor (0xB2, 0xB2, 0xB2);
  95. colors [ColorSetting::video_background].title = i18n ("Video background");
  96. colors [ColorSetting::video_background].option = "VideoBackground";
  97. colors [ColorSetting::video_background].color = TQColor (0, 0, 0);
  98. colors [ColorSetting::area_background].title = i18n ("Viewing area background");
  99. colors [ColorSetting::area_background].option = "ViewingAreaBackground";
  100. colors [ColorSetting::area_background].color = TQColor (0, 0, 0);
  101. colors [ColorSetting::infowindow_background].title = i18n ("Info window background");
  102. colors [ColorSetting::infowindow_background].option ="InfoWindowBackground";
  103. colors [ColorSetting::infowindow_background].color = TDEGlobalSettings::baseColor ();
  104. colors [ColorSetting::infowindow_foreground].title = i18n ("Info window foreground");
  105. colors [ColorSetting::infowindow_foreground].option ="InfoWindowForeground";
  106. colors [ColorSetting::infowindow_foreground].color = TDEGlobalSettings::textColor();
  107. fonts [FontSetting::playlist].title = i18n ("Playlist");
  108. fonts [FontSetting::playlist].option = "PlaylistFont";
  109. fonts [FontSetting::playlist].font = TDEGlobalSettings::generalFont();
  110. fonts [FontSetting::playlist].font.setItalic (true);
  111. fonts [FontSetting::infowindow].title = i18n ("Info window");
  112. fonts [FontSetting::infowindow].option = "InfoWindowFont";
  113. fonts [FontSetting::infowindow].font = TDEGlobalSettings::generalFont();
  114. }
  115. KDE_NO_CDTOR_EXPORT Settings::~Settings () {
  116. // configdialog should be destroyed when the view is destroyed
  117. //delete configdialog;
  118. }
  119. KDE_EXPORT const char * strMPlayerGroup = "MPlayer";
  120. const char * strGeneralGroup = "General Options";
  121. static const char * strKeepSizeRatio = "Keep Size Ratio";
  122. static const char * strRememberSize = "Remember Size";
  123. static const char * strAutoResize = "Auto Resize";
  124. static const char * strDockSysTray = "Dock in System Tray";
  125. static const char * strNoIntro = "No Intro";
  126. static const char * strVolume = "Volume";
  127. static const char * strContrast = "Contrast";
  128. static const char * strBrightness = "Brightness";
  129. static const char * strHue = "Hue";
  130. static const char * strSaturation = "Saturation";
  131. static const char * strURLList = "URL List";
  132. static const char * strSubURLList = "URL Sub Title List";
  133. static const char * strPrefBitRate = "Prefered Bitrate";
  134. static const char * strMaxBitRate = "Maximum Bitrate";
  135. //static const char * strUseArts = "Use aRts";
  136. static const char * strVoDriver = "Video Driver";
  137. static const char * strAoDriver = "Audio Driver";
  138. static const char * strLoop = "Loop";
  139. static const char * strFrameDrop = "Frame Drop";
  140. static const char * strAdjustVolume = "Auto Adjust Volume";
  141. static const char * strAdjustColors = "Auto Adjust Colors";
  142. static const char * strAddConfigButton = "Add Configure Button";
  143. static const char * strAddPlaylistButton = "Add Playlist Button";
  144. static const char * strAddRecordButton = "Add Record Button";
  145. static const char * strAddBroadcastButton = "Add Broadcast Button";
  146. static const char * strPostMPlayer090 = "Post MPlayer 0.90";
  147. //static const char * strAutoHideSlider = "Auto Hide Slider";
  148. static const char * strSeekTime = "Forward/Backward Seek Time";
  149. static const char * strDVDDevice = "DVD Device";
  150. //static const char * strShowDVD = "Show DVD Menu";
  151. //static const char * strShowVCD = "Show VCD Menu";
  152. static const char * strVCDDevice = "VCD Device";
  153. const char * strUrlBackend = "URL Backend";
  154. static const char * strAllowHref = "Allow HREF";
  155. // postproc thingies
  156. static const char * strPPGroup = "Post processing options";
  157. static const char * strPostProcessing = "Post processing";
  158. static const char * strDisablePPauto = "Automaticly disable post processing";
  159. static const char * strPP_Default = "Default preset";
  160. static const char * strPP_Fast = "Fast preset";
  161. static const char * strPP_Custom = "Custom preset";
  162. static const char * strCustom_Hz = "Horizontal deblocking";
  163. static const char * strCustom_Hz_Aq = "Horizontal deblocking auto quality";
  164. static const char * strCustom_Hz_Ch = "Horizontal deblocking chrominance";
  165. static const char * strCustom_Vt = "Vertical deblocking";
  166. static const char * strCustom_Vt_Aq = "Vertical deblocking auto quality";
  167. static const char * strCustom_Vt_Ch = "Vertical deblocking chrominance";
  168. static const char * strCustom_Dr = "Dering filter";
  169. static const char * strCustom_Dr_Aq = "Dering auto quality";
  170. static const char * strCustom_Dr_Ch = "Dering chrominance";
  171. static const char * strCustom_Al = "Autolevel";
  172. static const char * strCustom_Al_F = "Autolevel full range";
  173. static const char * strCustom_Tn = "Temporal Noise Reducer";
  174. static const char * strCustom_Tn_S = "Temporal Noise Reducer strength";
  175. static const char * strPP_Lin_Blend_Int = "Linear Blend Deinterlacer";
  176. static const char * strPP_Lin_Int = "Linear Interpolating Deinterlacer";
  177. static const char * strPP_Cub_Int = "Cubic Interpolating Deinterlacer";
  178. static const char * strPP_Med_Int = "Median Interpolating Deinterlacer";
  179. static const char * strPP_FFmpeg_Int = "FFmpeg Interpolating Deinterlacer";
  180. // end of postproc
  181. // recording
  182. static const char * strRecordingGroup = "Recording";
  183. static const char * strRecorder = "Recorder";
  184. static const char * strMencoderArgs = "Mencoder Arguments";
  185. static const char * strFFMpegArgs = "FFMpeg Arguments";
  186. static const char * strRecordingFile = "Last Recording Ouput File";
  187. static const char * strAutoPlayAfterRecording = "Auto Play After Recording";
  188. static const char * strAutoPlayAfterTime = "Auto Play After Recording Time";
  189. static const char * strRecordingCopy = "Recording Is Copy";
  190. KDE_NO_EXPORT void Settings::applyColorSetting (bool only_changed_ones) {
  191. View *view = static_cast <View *> (m_player->view ());
  192. if (!view) return;
  193. for (int i = 0; i < int (ColorSetting::last_target); i++)
  194. if (!only_changed_ones || colors[i].color != colors[i].newcolor) {
  195. colors[i].color = colors[i].newcolor;
  196. switch (ColorSetting::Target (i)) {
  197. case ColorSetting::playlist_background:
  198. view->playList()->setPaletteBackgroundColor(colors[i].color);
  199. break;
  200. case ColorSetting::playlist_foreground:
  201. view->playList()->setPaletteForegroundColor(colors[i].color);
  202. break;
  203. case ColorSetting::playlist_active:
  204. view->playList()->setActiveForegroundColor (colors[i].color);
  205. break;
  206. case ColorSetting::console_background:
  207. view->console()->setPaper (TQBrush (colors[i].color));
  208. break;
  209. case ColorSetting::console_foreground:
  210. view->console()->setColor(colors[i].color);
  211. break;
  212. case ColorSetting::video_background:
  213. view->viewer ()->setBackgroundColor (colors[i].color);
  214. break;
  215. case ColorSetting::area_background:
  216. view->viewArea()->setPaletteBackgroundColor(colors[i].color);
  217. break;
  218. case ColorSetting::infowindow_background:
  219. view->infoPanel ()->setPaper (TQBrush (colors[i].color));
  220. break;
  221. case ColorSetting::infowindow_foreground:
  222. view->infoPanel()->setPaletteForegroundColor(colors[i].color);
  223. view->infoPanel ()->setColor (colors[i].color);
  224. break;
  225. default:
  226. ;
  227. }
  228. }
  229. for (int i = 0; i < int (FontSetting::last_target); i++)
  230. if (!only_changed_ones || fonts[i].font != fonts[i].newfont) {
  231. fonts[i].font = fonts[i].newfont;
  232. switch (FontSetting::Target (i)) {
  233. case FontSetting::playlist:
  234. view->playList ()->setFont (fonts[i].font);
  235. break;
  236. case FontSetting::infowindow:
  237. view->infoPanel ()->setFont (fonts[i].font);
  238. break;
  239. default:
  240. ;
  241. }
  242. }
  243. }
  244. View * Settings::defaultView () {
  245. return static_cast <View *> (m_player->view ());
  246. }
  247. KDE_NO_EXPORT void Settings::readConfig () {
  248. m_config->setGroup (strGeneralGroup);
  249. no_intro = m_config->readBoolEntry (strNoIntro, false);
  250. urllist = m_config->readListEntry (strURLList, ';');
  251. sub_urllist = m_config->readListEntry (strSubURLList, ';');
  252. prefbitrate = m_config->readNumEntry (strPrefBitRate, 512);
  253. maxbitrate = m_config->readNumEntry (strMaxBitRate, 1024);
  254. volume = m_config->readNumEntry (strVolume, 20);
  255. contrast = m_config->readNumEntry (strContrast, 0);
  256. brightness = m_config->readNumEntry (strBrightness, 0);
  257. hue = m_config->readNumEntry (strHue, 0);
  258. saturation = m_config->readNumEntry (strSaturation, 0);
  259. const TQMap <TQString, Source*>::const_iterator e = m_player->sources ().end ();
  260. TQMap <TQString, Source *>::const_iterator i = m_player->sources().begin ();
  261. for (; i != e; ++i)
  262. backends[i.data()->name ()] = m_config->readEntry (i.data()->name ());
  263. for (int i = 0; i < int (ColorSetting::last_target); i++)
  264. colors[i].newcolor = colors[i].color = m_config->readColorEntry (colors[i].option, &colors[i].color);
  265. for (int i = 0; i < int (FontSetting::last_target); i++)
  266. fonts[i].newfont = fonts[i].font = m_config->readFontEntry (fonts[i].option, &fonts[i].font);
  267. m_config->setGroup (strMPlayerGroup);
  268. sizeratio = m_config->readBoolEntry (strKeepSizeRatio, true);
  269. remembersize = m_config->readBoolEntry (strRememberSize, true);
  270. autoresize = m_config->readBoolEntry (strAutoResize, true);
  271. docksystray = m_config->readBoolEntry (strDockSysTray, true);
  272. loop = m_config->readBoolEntry (strLoop, false);
  273. framedrop = m_config->readBoolEntry (strFrameDrop, true);
  274. autoadjustvolume = m_config->readBoolEntry (strAdjustVolume, true);
  275. autoadjustcolors = m_config->readBoolEntry (strAdjustColors, true);
  276. mplayerpost090 = m_config->readBoolEntry (strPostMPlayer090, true);
  277. showcnfbutton = m_config->readBoolEntry (strAddConfigButton, true);
  278. showrecordbutton = m_config->readBoolEntry (strAddRecordButton, true);
  279. showbroadcastbutton = m_config->readBoolEntry (strAddBroadcastButton, true);
  280. showplaylistbutton = m_config->readBoolEntry (strAddPlaylistButton, true);
  281. seektime = m_config->readNumEntry (strSeekTime, 10);
  282. dvddevice = m_config->readEntry (strDVDDevice, "/dev/dvd");
  283. vcddevice = m_config->readEntry (strVCDDevice, "/dev/cdrom");
  284. videodriver = m_config->readNumEntry (strVoDriver, 0);
  285. audiodriver = m_config->readNumEntry (strAoDriver, 0);
  286. allowhref = m_config->readBoolEntry(strAllowHref, false);
  287. // recording
  288. m_config->setGroup (strRecordingGroup);
  289. mencoderarguments = m_config->readEntry (strMencoderArgs, "-oac mp3lame -ovc lavc");
  290. ffmpegarguments = m_config->readEntry (strFFMpegArgs, "-f avi -acodec mp3 -vcodec mpeg4");
  291. recordfile = m_config->readPathEntry(strRecordingFile, TQDir::homeDirPath () + "/record.avi");
  292. recorder = Recorder (m_config->readNumEntry (strRecorder, int (MEncoder)));
  293. replayoption = ReplayOption (m_config->readNumEntry (strAutoPlayAfterRecording, ReplayFinished));
  294. replaytime = m_config->readNumEntry (strAutoPlayAfterTime, 60);
  295. recordcopy = m_config->readBoolEntry(strRecordingCopy, true);
  296. // postproc
  297. m_config->setGroup (strPPGroup);
  298. postprocessing = m_config->readBoolEntry (strPostProcessing, false);
  299. disableppauto = m_config->readBoolEntry (strDisablePPauto, true);
  300. pp_default = m_config->readBoolEntry (strPP_Default, true);
  301. pp_fast = m_config->readBoolEntry (strPP_Fast, false);
  302. pp_custom = m_config->readBoolEntry (strPP_Custom, false);
  303. // default these to default preset
  304. pp_custom_hz = m_config->readBoolEntry (strCustom_Hz, true);
  305. pp_custom_hz_aq = m_config->readBoolEntry (strCustom_Hz_Aq, true);
  306. pp_custom_hz_ch = m_config->readBoolEntry (strCustom_Hz_Ch, false);
  307. pp_custom_vt = m_config->readBoolEntry (strCustom_Vt, true);
  308. pp_custom_vt_aq = m_config->readBoolEntry (strCustom_Vt_Aq, true);
  309. pp_custom_vt_ch = m_config->readBoolEntry (strCustom_Vt_Ch, false);
  310. pp_custom_dr = m_config->readBoolEntry (strCustom_Dr, true);
  311. pp_custom_dr_aq = m_config->readBoolEntry (strCustom_Dr_Aq, true);
  312. pp_custom_dr_ch = m_config->readBoolEntry (strCustom_Dr_Ch, false);
  313. pp_custom_al = m_config->readBoolEntry (strCustom_Al, true);
  314. pp_custom_al_f = m_config->readBoolEntry (strCustom_Al_F, false);
  315. pp_custom_tn = m_config->readBoolEntry (strCustom_Tn, true);
  316. pp_custom_tn_s = m_config->readNumEntry (strCustom_Tn_S, 0);
  317. pp_lin_blend_int = m_config->readBoolEntry (strPP_Lin_Blend_Int, false);
  318. pp_lin_int = m_config->readBoolEntry (strPP_Lin_Int, false);
  319. pp_cub_int = m_config->readBoolEntry (strPP_Cub_Int, false);
  320. pp_med_int = m_config->readBoolEntry (strPP_Med_Int, false);
  321. pp_ffmpeg_int = m_config->readBoolEntry (strPP_FFmpeg_Int, false);
  322. for (PreferencesPage * p = pagelist; p; p = p->next)
  323. p->read (m_config);
  324. emit configChanged ();
  325. }
  326. KDE_NO_EXPORT bool Settings::createDialog () {
  327. if (configdialog) return false;
  328. configdialog = new Preferences (m_player, this);
  329. int id = 0;
  330. const PartBase::ProcessMap::const_iterator e = m_player->players ().end ();
  331. for (PartBase::ProcessMap::const_iterator i = m_player->players ().begin(); i != e; ++i) {
  332. Process * p = i.data ();
  333. if (p->supports ("urlsource"))
  334. configdialog->m_SourcePageURL->backend->insertItem (p->menuName ().remove (TQChar ('&')), id++);
  335. }
  336. connect (configdialog, TQT_SIGNAL (okClicked ()),
  337. this, TQT_SLOT (okPressed ()));
  338. connect (configdialog, TQT_SIGNAL (applyClicked ()),
  339. this, TQT_SLOT (okPressed ()));
  340. if (TDEApplication::kApplication())
  341. connect (configdialog, TQT_SIGNAL (helpClicked ()),
  342. this, TQT_SLOT (getHelp ()));
  343. return true;
  344. }
  345. void Settings::addPage (PreferencesPage * page) {
  346. for (PreferencesPage * p = pagelist; p; p = p->next)
  347. if (p == page)
  348. return;
  349. page->read (m_config);
  350. if (configdialog) {
  351. configdialog->addPrefPage (page);
  352. page->sync (false);
  353. }
  354. page->next = pagelist;
  355. pagelist = page;
  356. }
  357. void Settings::removePage (PreferencesPage * page) {
  358. if (configdialog)
  359. configdialog->removePrefPage (page);
  360. PreferencesPage * prev = 0L;
  361. for (PreferencesPage * p = pagelist; p; prev = p, p = p->next)
  362. if (p == page) {
  363. if (prev)
  364. prev->next = p->next;
  365. else
  366. pagelist = p->next;
  367. break;
  368. }
  369. }
  370. void Settings::show (const char * pagename) {
  371. bool created = createDialog ();
  372. configdialog->m_GeneralPageGeneral->keepSizeRatio->setChecked (sizeratio);
  373. configdialog->m_GeneralPageGeneral->autoResize->setChecked (autoresize);
  374. configdialog->m_GeneralPageGeneral->sizesChoice->setButton (remembersize ? 0 : 1);
  375. configdialog->m_GeneralPageGeneral->dockSysTray->setChecked (docksystray);
  376. configdialog->m_GeneralPageGeneral->loop->setChecked (loop);
  377. configdialog->m_GeneralPageGeneral->framedrop->setChecked (framedrop);
  378. configdialog->m_GeneralPageGeneral->adjustvolume->setChecked (autoadjustvolume);
  379. configdialog->m_GeneralPageGeneral->adjustcolors->setChecked (autoadjustcolors);
  380. //configdialog->m_GeneralPageGeneral->autoHideSlider->setChecked (autohideslider);
  381. configdialog->m_GeneralPageGeneral->showConfigButton->setChecked (showcnfbutton);
  382. configdialog->m_GeneralPageGeneral->showPlaylistButton->setChecked (showplaylistbutton);
  383. configdialog->m_GeneralPageGeneral->showRecordButton->setChecked (showrecordbutton);
  384. configdialog->m_GeneralPageGeneral->showBroadcastButton->setChecked (showbroadcastbutton);
  385. configdialog->m_GeneralPageGeneral->seekTime->setValue(seektime);
  386. for (int i = 0; i < int (ColorSetting::last_target); i++)
  387. colors[i].newcolor = colors[i].color;
  388. for (int i = 0; i < int (FontSetting::last_target); i++)
  389. fonts[i].newfont = fonts[i].font;
  390. configdialog->m_SourcePageURL->urllist->clear ();
  391. configdialog->m_SourcePageURL->urllist->insertStringList (urllist);
  392. configdialog->m_SourcePageURL->urllist->setCurrentText (m_player->source ()->url ().prettyURL ());
  393. configdialog->m_SourcePageURL->sub_urllist->clear ();
  394. configdialog->m_SourcePageURL->sub_urllist->insertStringList (sub_urllist);
  395. configdialog->m_SourcePageURL->sub_urllist->setCurrentText (m_player->source ()->subUrl ().prettyURL ());
  396. configdialog->m_SourcePageURL->changed = false;
  397. configdialog->m_SourcePageURL->prefBitRate->setText (TQString::number (prefbitrate));
  398. configdialog->m_SourcePageURL->maxBitRate->setText (TQString::number (maxbitrate));
  399. configdialog->m_GeneralPageOutput->videoDriver->setCurrentItem (videodriver);
  400. configdialog->m_GeneralPageOutput->audioDriver->setCurrentItem (audiodriver);
  401. configdialog->m_SourcePageURL->backend->setCurrentItem (configdialog->m_SourcePageURL->backend->findItem (backends["urlsource"]));
  402. int id = 0;
  403. const PartBase::ProcessMap::const_iterator e = m_player->players ().end ();
  404. for (PartBase::ProcessMap::const_iterator i = m_player->players ().begin(); i != e; ++i) {
  405. Process * p = i.data ();
  406. if (p->supports ("urlsource")) {
  407. if (backends["urlsource"] == TQString (p->name()))
  408. configdialog->m_SourcePageURL->backend->setCurrentItem (id);
  409. id++;
  410. }
  411. }
  412. configdialog->m_SourcePageURL->allowhref->setChecked (allowhref);
  413. // postproc
  414. configdialog->m_OPPagePostproc->postProcessing->setChecked (postprocessing);
  415. configdialog->m_OPPagePostproc->disablePPauto->setChecked (disableppauto);
  416. configdialog->m_OPPagePostproc->PostprocessingOptions->setEnabled (postprocessing);
  417. configdialog->m_OPPagePostproc->defaultPreset->setChecked (pp_default);
  418. configdialog->m_OPPagePostproc->fastPreset->setChecked (pp_fast);
  419. configdialog->m_OPPagePostproc->customPreset->setChecked (pp_custom);
  420. configdialog->m_OPPagePostproc->HzDeblockFilter->setChecked (pp_custom_hz);
  421. configdialog->m_OPPagePostproc->HzDeblockAQuality->setChecked (pp_custom_hz_aq);
  422. configdialog->m_OPPagePostproc->HzDeblockCFiltering->setChecked (pp_custom_hz_ch);
  423. configdialog->m_OPPagePostproc->VtDeblockFilter->setChecked (pp_custom_vt);
  424. configdialog->m_OPPagePostproc->VtDeblockAQuality->setChecked (pp_custom_vt_aq);
  425. configdialog->m_OPPagePostproc->VtDeblockCFiltering->setChecked (pp_custom_vt_ch);
  426. configdialog->m_OPPagePostproc->DeringFilter->setChecked (pp_custom_dr);
  427. configdialog->m_OPPagePostproc->DeringAQuality->setChecked (pp_custom_dr_aq);
  428. configdialog->m_OPPagePostproc->DeringCFiltering->setChecked (pp_custom_dr_ch);
  429. configdialog->m_OPPagePostproc->AutolevelsFilter->setChecked (pp_custom_al);
  430. configdialog->m_OPPagePostproc->AutolevelsFullrange->setChecked (pp_custom_al_f);
  431. configdialog->m_OPPagePostproc->TmpNoiseFilter->setChecked (pp_custom_tn);
  432. //configdialog->m_OPPagePostproc->TmpNoiseSlider->setValue (pp_custom_tn_s);
  433. configdialog->m_OPPagePostproc->LinBlendDeinterlacer->setChecked (pp_lin_blend_int);
  434. configdialog->m_OPPagePostproc->LinIntDeinterlacer->setChecked (pp_lin_int);
  435. configdialog->m_OPPagePostproc->CubicIntDeinterlacer->setChecked (pp_cub_int);
  436. configdialog->m_OPPagePostproc->MedianDeinterlacer->setChecked (pp_med_int);
  437. configdialog->m_OPPagePostproc->FfmpegDeinterlacer->setChecked (pp_ffmpeg_int);
  438. // recording
  439. configdialog->m_RecordPage->url->lineEdit()->setText (recordfile);
  440. configdialog->m_RecordPage->replay->setButton (int (replayoption));
  441. configdialog->m_RecordPage->recorder->setButton (int (recorder));
  442. configdialog->m_RecordPage->replayClicked (int (replayoption));
  443. configdialog->m_RecordPage->recorderClicked (int (recorder));
  444. configdialog->m_RecordPage->replaytime->setText (TQString::number (replaytime));
  445. configdialog->m_MEncoderPage->arguments->setText (mencoderarguments);
  446. configdialog->m_MEncoderPage->format->setButton (recordcopy ? 0 : 1);
  447. configdialog->m_MEncoderPage->formatClicked (recordcopy ? 0 : 1);
  448. configdialog->m_FFMpegPage->arguments->setText (ffmpegarguments);
  449. //dynamic stuff
  450. for (PreferencesPage * p = pagelist; p; p = p->next)
  451. p->sync (false);
  452. //\dynamic stuff
  453. if (pagename)
  454. configDialog ()->setPage (pagename);
  455. if (created)
  456. configdialog->resize (configdialog->minimumSize ());
  457. configdialog->show ();
  458. }
  459. void Settings::writeConfig () {
  460. m_config->setGroup (strGeneralGroup);
  461. m_config->writeEntry (strURLList, urllist, ';');
  462. m_config->writeEntry (strSubURLList, sub_urllist, ';');
  463. m_config->writeEntry (strPrefBitRate, prefbitrate);
  464. m_config->writeEntry (strMaxBitRate, maxbitrate);
  465. m_config->writeEntry (strVolume, volume);
  466. m_config->writeEntry (strContrast, contrast);
  467. m_config->writeEntry (strBrightness, brightness);
  468. m_config->writeEntry (strHue, hue);
  469. m_config->writeEntry (strSaturation, saturation);
  470. const TQMap<TQString,TQString>::iterator b_end = backends.end ();
  471. for (TQMap<TQString,TQString>::iterator i = backends.begin(); i != b_end; ++i)
  472. m_config->writeEntry (i.key (), i.data ());
  473. for (int i = 0; i < int (ColorSetting::last_target); i++)
  474. m_config->writeEntry (colors[i].option, colors[i].color);
  475. for (int i = 0; i < int (FontSetting::last_target); i++)
  476. m_config->writeEntry (fonts[i].option, fonts[i].font);
  477. m_config->setGroup (strMPlayerGroup);
  478. m_config->writeEntry (strKeepSizeRatio, sizeratio);
  479. m_config->writeEntry (strAutoResize, autoresize);
  480. m_config->writeEntry (strRememberSize, remembersize);
  481. m_config->writeEntry (strDockSysTray, docksystray);
  482. m_config->writeEntry (strLoop, loop);
  483. m_config->writeEntry (strFrameDrop, framedrop);
  484. m_config->writeEntry (strAdjustVolume, autoadjustvolume);
  485. m_config->writeEntry (strAdjustColors, autoadjustcolors);
  486. m_config->writeEntry (strSeekTime, seektime);
  487. m_config->writeEntry (strVoDriver, videodriver);
  488. m_config->writeEntry (strAoDriver, audiodriver);
  489. m_config->writeEntry (strAllowHref, allowhref);
  490. m_config->writeEntry (strAddConfigButton, showcnfbutton);
  491. m_config->writeEntry (strAddPlaylistButton, showplaylistbutton);
  492. m_config->writeEntry (strAddRecordButton, showrecordbutton);
  493. m_config->writeEntry (strAddBroadcastButton, showbroadcastbutton);
  494. m_config->writeEntry (strDVDDevice, dvddevice);
  495. m_config->writeEntry (strVCDDevice, vcddevice);
  496. //postprocessing stuff
  497. m_config->setGroup (strPPGroup);
  498. m_config->writeEntry (strPostProcessing, postprocessing);
  499. m_config->writeEntry (strDisablePPauto, disableppauto);
  500. m_config->writeEntry (strPP_Default, pp_default);
  501. m_config->writeEntry (strPP_Fast, pp_fast);
  502. m_config->writeEntry (strPP_Custom, pp_custom);
  503. m_config->writeEntry (strCustom_Hz, pp_custom_hz);
  504. m_config->writeEntry (strCustom_Hz_Aq, pp_custom_hz_aq);
  505. m_config->writeEntry (strCustom_Hz_Ch, pp_custom_hz_ch);
  506. m_config->writeEntry (strCustom_Vt, pp_custom_vt);
  507. m_config->writeEntry (strCustom_Vt_Aq, pp_custom_vt_aq);
  508. m_config->writeEntry (strCustom_Vt_Ch, pp_custom_vt_ch);
  509. m_config->writeEntry (strCustom_Dr, pp_custom_dr);
  510. m_config->writeEntry (strCustom_Dr_Aq, pp_custom_vt_aq);
  511. m_config->writeEntry (strCustom_Dr_Ch, pp_custom_vt_ch);
  512. m_config->writeEntry (strCustom_Al, pp_custom_al);
  513. m_config->writeEntry (strCustom_Al_F, pp_custom_al_f);
  514. m_config->writeEntry (strCustom_Tn, pp_custom_tn);
  515. m_config->writeEntry (strCustom_Tn_S, pp_custom_tn_s);
  516. m_config->writeEntry (strPP_Lin_Blend_Int, pp_lin_blend_int);
  517. m_config->writeEntry (strPP_Lin_Int, pp_lin_int);
  518. m_config->writeEntry (strPP_Cub_Int, pp_cub_int);
  519. m_config->writeEntry (strPP_Med_Int, pp_med_int);
  520. m_config->writeEntry (strPP_FFmpeg_Int, pp_ffmpeg_int);
  521. // recording
  522. m_config->setGroup (strRecordingGroup);
  523. m_config->writePathEntry (strRecordingFile, recordfile);
  524. m_config->writeEntry (strAutoPlayAfterRecording, int (replayoption));
  525. m_config->writeEntry (strAutoPlayAfterTime, replaytime);
  526. m_config->writeEntry (strRecorder, int (recorder));
  527. m_config->writeEntry (strRecordingCopy, recordcopy);
  528. m_config->writeEntry (strMencoderArgs, mencoderarguments);
  529. m_config->writeEntry (strFFMpegArgs, ffmpegarguments);
  530. //dynamic stuff
  531. for (PreferencesPage * p = pagelist; p; p = p->next)
  532. p->write (m_config);
  533. //\dynamic stuff
  534. m_config->sync ();
  535. }
  536. void Settings::okPressed () {
  537. bool urlchanged = configdialog->m_SourcePageURL->changed;
  538. bool playerchanged = false;
  539. if (urlchanged) {
  540. if (configdialog->m_SourcePageURL->url->url ().isEmpty ())
  541. urlchanged = false;
  542. else {
  543. if (KURL::fromPathOrURL (configdialog->m_SourcePageURL->url->url ()).isLocalFile () ||
  544. KURL::isRelativeURL (configdialog->m_SourcePageURL->url->url ())) {
  545. TQFileInfo fi (configdialog->m_SourcePageURL->url->url ());
  546. int hpos = configdialog->m_SourcePageURL->url->url ().findRev ('#');
  547. TQString xine_directives ("");
  548. while (!fi.exists () && hpos > -1) {
  549. xine_directives = configdialog->m_SourcePageURL->url->url ().mid (hpos);
  550. fi.setFile (configdialog->m_SourcePageURL->url->url ().left (hpos));
  551. hpos = configdialog->m_SourcePageURL->url->url ().findRev ('#', hpos-1);
  552. }
  553. if (!fi.exists ()) {
  554. urlchanged = false;
  555. KMessageBox::error (m_player->view (), i18n ("File %1 does not exist.").arg (configdialog->m_SourcePageURL->url->url ()), i18n ("Error"));
  556. } else
  557. configdialog->m_SourcePageURL->url->setURL (fi.absFilePath () + xine_directives);
  558. }
  559. if (urlchanged &&
  560. !configdialog->m_SourcePageURL->sub_url->url ().isEmpty () &&
  561. (KURL::fromPathOrURL (configdialog->m_SourcePageURL->sub_url->url ()).isLocalFile () ||
  562. KURL::isRelativeURL (configdialog->m_SourcePageURL->sub_url->url ()))) {
  563. TQFileInfo sfi (configdialog->m_SourcePageURL->sub_url->url ());
  564. if (!sfi.exists ()) {
  565. KMessageBox::error (m_player->view (), i18n ("Sub title file %1 does not exist.").arg (configdialog->m_SourcePageURL->sub_url->url ()), i18n ("Error"));
  566. configdialog->m_SourcePageURL->sub_url->setURL (TQString ());
  567. } else
  568. configdialog->m_SourcePageURL->sub_url->setURL (sfi.absFilePath ());
  569. }
  570. }
  571. }
  572. if (urlchanged) {
  573. KURL url = KURL::fromPathOrURL (configdialog->m_SourcePageURL->url->url ());
  574. m_player->setURL (url);
  575. if (urllist.find (url.prettyURL ()) == urllist.end ())
  576. configdialog->m_SourcePageURL->urllist->insertItem (url.prettyURL (), 0);
  577. KURL sub_url = KURL::fromPathOrURL (configdialog->m_SourcePageURL->sub_url->url ());
  578. if (sub_urllist.find (sub_url.prettyURL ()) == sub_urllist.end ())
  579. configdialog->m_SourcePageURL->sub_urllist->insertItem (sub_url.prettyURL (), 0);
  580. }
  581. urllist.clear ();
  582. for (int i = 0; i < configdialog->m_SourcePageURL->urllist->count () && i < 20; ++i)
  583. // damnit why don't maxCount and setDuplicatesEnabled(false) work :(
  584. // and why can I put a qstringlist in it, but cannot get it out of it again..
  585. if (!configdialog->m_SourcePageURL->urllist->text (i).isEmpty ())
  586. urllist.push_back (configdialog->m_SourcePageURL->urllist->text (i));
  587. sub_urllist.clear ();
  588. for (int i = 0; i < configdialog->m_SourcePageURL->sub_urllist->count () && i < 20; ++i)
  589. if (!configdialog->m_SourcePageURL->sub_urllist->text (i).isEmpty ())
  590. sub_urllist.push_back (configdialog->m_SourcePageURL->sub_urllist->text (i));
  591. prefbitrate = configdialog->m_SourcePageURL->prefBitRate->text ().toInt ();
  592. maxbitrate = configdialog->m_SourcePageURL->maxBitRate->text ().toInt ();
  593. sizeratio = configdialog->m_GeneralPageGeneral->keepSizeRatio->isChecked ();
  594. autoresize = configdialog->m_GeneralPageGeneral->autoResize->isChecked ();
  595. remembersize=!configdialog->m_GeneralPageGeneral->sizesChoice->selectedId();
  596. docksystray = configdialog->m_GeneralPageGeneral->dockSysTray->isChecked ();
  597. loop = configdialog->m_GeneralPageGeneral->loop->isChecked ();
  598. framedrop = configdialog->m_GeneralPageGeneral->framedrop->isChecked ();
  599. autoadjustvolume = configdialog->m_GeneralPageGeneral->adjustvolume->isChecked ();
  600. autoadjustcolors = configdialog->m_GeneralPageGeneral->adjustcolors->isChecked ();
  601. showcnfbutton = configdialog->m_GeneralPageGeneral->showConfigButton->isChecked ();
  602. showplaylistbutton = configdialog->m_GeneralPageGeneral->showPlaylistButton->isChecked ();
  603. showrecordbutton = configdialog->m_GeneralPageGeneral->showRecordButton->isChecked ();
  604. showbroadcastbutton = configdialog->m_GeneralPageGeneral->showBroadcastButton->isChecked ();
  605. seektime = configdialog->m_GeneralPageGeneral->seekTime->value();
  606. videodriver = configdialog->m_GeneralPageOutput->videoDriver->currentItem();
  607. audiodriver = configdialog->m_GeneralPageOutput->audioDriver->currentItem();
  608. if (!strcmp (m_player->source()->name (), "urlsource")) {
  609. int backend = configdialog->m_SourcePageURL->backend->currentItem ();
  610. const PartBase::ProcessMap::const_iterator e = m_player->players ().end();
  611. for (PartBase::ProcessMap::const_iterator i = m_player->players ().begin(); backend >=0 && i != e; ++i) {
  612. Process * proc = i.data ();
  613. if (proc->supports ("urlsource") && backend-- == 0) {
  614. backends["urlsource"] = proc->name ();
  615. if (proc != m_player->process ()) {
  616. m_player->setProcess (proc->name ());
  617. playerchanged = true;
  618. }
  619. }
  620. }
  621. }
  622. allowhref = configdialog->m_SourcePageURL->allowhref->isChecked ();
  623. //postproc
  624. postprocessing = configdialog->m_OPPagePostproc->postProcessing->isChecked();
  625. disableppauto = configdialog->m_OPPagePostproc->disablePPauto->isChecked();
  626. pp_default = configdialog->m_OPPagePostproc->defaultPreset->isChecked();
  627. pp_fast = configdialog->m_OPPagePostproc->fastPreset->isChecked();
  628. pp_custom = configdialog->m_OPPagePostproc->customPreset->isChecked();
  629. pp_custom_hz = configdialog->m_OPPagePostproc->HzDeblockFilter->isChecked();
  630. pp_custom_hz_aq = configdialog->m_OPPagePostproc->HzDeblockAQuality->isChecked();
  631. pp_custom_hz_ch = configdialog->m_OPPagePostproc->HzDeblockCFiltering->isChecked();
  632. pp_custom_vt = configdialog->m_OPPagePostproc->VtDeblockFilter->isChecked();
  633. pp_custom_vt_aq = configdialog->m_OPPagePostproc->VtDeblockAQuality->isChecked();
  634. pp_custom_vt_ch = configdialog->m_OPPagePostproc->VtDeblockCFiltering->isChecked();
  635. pp_custom_dr = configdialog->m_OPPagePostproc->DeringFilter->isChecked();
  636. pp_custom_dr_aq = configdialog->m_OPPagePostproc->DeringAQuality->isChecked();
  637. pp_custom_dr_ch = configdialog->m_OPPagePostproc->DeringCFiltering->isChecked();
  638. pp_custom_al = configdialog->m_OPPagePostproc->AutolevelsFilter->isChecked();
  639. pp_custom_al_f = configdialog->m_OPPagePostproc->AutolevelsFullrange->isChecked();
  640. pp_custom_tn = configdialog->m_OPPagePostproc->TmpNoiseFilter->isChecked();
  641. pp_custom_tn_s = 0; // gotta fix this later
  642. //pp_custom_tn_s = configdialog->m_OPPagePostproc->TmpNoiseSlider->value();
  643. pp_lin_blend_int = configdialog->m_OPPagePostproc->LinBlendDeinterlacer->isChecked();
  644. pp_lin_int = configdialog->m_OPPagePostproc->LinIntDeinterlacer->isChecked();
  645. pp_cub_int = configdialog->m_OPPagePostproc->CubicIntDeinterlacer->isChecked();
  646. pp_med_int = configdialog->m_OPPagePostproc->MedianDeinterlacer->isChecked();
  647. pp_ffmpeg_int = configdialog->m_OPPagePostproc->FfmpegDeinterlacer->isChecked();
  648. // recording
  649. recorder = Recorder (configdialog->m_RecordPage->recorder->selectedId ());
  650. replaytime = configdialog->m_RecordPage->replaytime->text ().toInt ();
  651. configdialog->m_RecordPage->replaytime->setText (TQString::number (replaytime));
  652. recordfile = configdialog->m_RecordPage->url->lineEdit()->text ();
  653. mencoderarguments = configdialog->m_MEncoderPage->arguments->text ();
  654. ffmpegarguments = configdialog->m_FFMpegPage->arguments->text ();
  655. recordcopy = !configdialog->m_MEncoderPage->format->selectedId ();
  656. //dynamic stuff
  657. for (PreferencesPage * p = pagelist; p; p = p->next)
  658. p->sync (true);
  659. //\dynamic stuff
  660. writeConfig ();
  661. emit configChanged ();
  662. if (urlchanged || playerchanged) {
  663. m_player->sources () ["urlsource"]->setSubURL
  664. (KURL(configdialog->m_SourcePageURL->sub_url->url()));
  665. m_player->openURL (KURL::fromPathOrURL (configdialog->m_SourcePageURL->url->url ()));
  666. m_player->source ()->setSubURL (KURL::fromPathOrURL (configdialog->m_SourcePageURL->sub_url->url ()));
  667. }
  668. }
  669. KDE_NO_EXPORT void Settings::getHelp () {
  670. TDEApplication::kApplication()->invokeBrowser ("man:/mplayer");
  671. }
  672. #include "kmplayerconfig.moc"