KPlayer – multimedia player with mplayer backend
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1295 lines
47KB

  1. /***************************************************************************
  2. kplayersettingsdialog.cpp
  3. -------------------------
  4. begin : Tue Apr 22 2003
  5. copyright : (C) 2003-2007 by kiriuja
  6. email : http://kplayer.sourceforge.net/email.html
  7. ***************************************************************************/
  8. /***************************************************************************
  9. * This program is free software; you can redistribute it and/or modify *
  10. * it under the terms of the GNU General Public License as published by *
  11. * the Free Software Foundation, either version 3 of the License, or *
  12. * (at your option) any later version. *
  13. ***************************************************************************/
  14. #include <tdefontcombo.h>
  15. #include <tdelistview.h>
  16. #include <tdelocale.h>
  17. #include <tdemessagebox.h>
  18. #include <tqcheckbox.h>
  19. #include <tqcombobox.h>
  20. #include <tqfontdatabase.h>
  21. #include <tqlabel.h>
  22. #include <tqlayout.h>
  23. #include <tqlineedit.h>
  24. #include <tqpushbutton.h>
  25. #include <tqregexp.h>
  26. #include <tqslider.h>
  27. #include <math.h>
  28. #include <stdlib.h>
  29. #ifdef DEBUG
  30. #define DEBUG_KPLAYER_SETTINGS_DIALOG
  31. #endif
  32. #include "kplayersettingsdialog.h"
  33. #include "kplayersettingsdialog.moc"
  34. #include "kplayerengine.h"
  35. #include "kplayersettings.h"
  36. static TQString s_default_entry (i18n("%1 (%2)"));
  37. static TQRegExp re_key_value ("^([^:]+): *(.*)$");
  38. KPlayerSettingsDialog::KPlayerSettingsDialog (TQWidget* parent)
  39. : KDialogBase (TreeList, i18n("KPlayer Preferences"), Help | Default | Ok | Apply | Cancel, Ok, parent)
  40. {
  41. //m_initial_move = false;
  42. TQApplication::connect (this, SIGNAL (aboutToShowPage (TQWidget*)), this, SLOT (pageAboutToShow(TQWidget*)));
  43. TQFrame* frame = addPage (i18n("General"), i18n("General Settings"));
  44. TQBoxLayout* layout = new TQVBoxLayout (frame, 0, 0);
  45. layout -> setAutoAdd (true);
  46. m_general = new KPlayerSettingsGeneral (frame, "general");
  47. frame = addPage (i18n("Controls"), i18n("Control Settings"));
  48. layout = new TQVBoxLayout (frame, 0, 0);
  49. layout -> setAutoAdd (true);
  50. m_controls = new KPlayerSettingsControls (frame, "controls");
  51. frame = addPage (i18n("Video"), i18n("Video Settings"));
  52. layout = new TQVBoxLayout (frame, 0, 0);
  53. layout -> setAutoAdd (true);
  54. m_video = new KPlayerSettingsVideo (frame, "video");
  55. frame = addPage (i18n("Audio"), i18n("Audio Settings"));
  56. layout = new TQVBoxLayout (frame, 0, 0);
  57. layout -> setAutoAdd (true);
  58. m_audio = new KPlayerSettingsAudio (frame, "audio");
  59. frame = addPage (i18n("Subtitles"), i18n("Subtitle Settings"));
  60. layout = new TQVBoxLayout (frame, 0, 0);
  61. layout -> setAutoAdd (true);
  62. m_subtitles = new KPlayerSettingsSubtitles (frame, "subtitles");
  63. frame = addPage (i18n("Advanced"), i18n("Advanced Settings"));
  64. layout = new TQVBoxLayout (frame, 0, 0);
  65. layout -> setAutoAdd (true);
  66. m_advanced = new KPlayerSettingsAdvanced (frame, "advanced");
  67. frame = addPage (TQStringList() << i18n("Controls") << i18n("Progress"), i18n("Progress Control Settings"));
  68. layout = new TQVBoxLayout (frame, 0, 0);
  69. layout -> setAutoAdd (true);
  70. m_progress = new KPlayerSettingsProgress (frame, "progress");
  71. frame = addPage (TQStringList() << i18n("Controls") << i18n("Volume"), i18n("Volume Control Settings"));
  72. layout = new TQVBoxLayout (frame, 0, 0);
  73. layout -> setAutoAdd (true);
  74. m_volume = new KPlayerSettingsVolume (frame, "volume");
  75. frame = addPage (TQStringList() << i18n("Controls") << i18n("Contrast"), i18n("Contrast Control Settings"));
  76. layout = new TQVBoxLayout (frame, 0, 0);
  77. layout -> setAutoAdd (true);
  78. m_contrast = new KPlayerSettingsContrast (frame, "contrast");
  79. frame = addPage (TQStringList() << i18n("Controls") << i18n("Brightness"), i18n("Brightness Control Settings"));
  80. layout = new TQVBoxLayout (frame, 0, 0);
  81. layout -> setAutoAdd (true);
  82. m_brightness = new KPlayerSettingsBrightness (frame, "brightness");
  83. frame = addPage (TQStringList() << i18n("Controls") << i18n("Hue"), i18n("Hue Control Settings"));
  84. layout = new TQVBoxLayout (frame, 0, 0);
  85. layout -> setAutoAdd (true);
  86. m_hue = new KPlayerSettingsHue (frame, "hue");
  87. frame = addPage (TQStringList() << i18n("Controls") << i18n("Saturation"), i18n("Saturation Control Settings"));
  88. layout = new TQVBoxLayout (frame, 0, 0);
  89. layout -> setAutoAdd (true);
  90. m_saturation = new KPlayerSettingsSaturation (frame, "saturation");
  91. frame = addPage (TQStringList() << i18n("Controls") << i18n("Sliders"), i18n("Slider Control Settings"));
  92. layout = new TQVBoxLayout (frame, 0, 0);
  93. layout -> setAutoAdd (true);
  94. m_sliders = new KPlayerSettingsSliders (frame, "sliders");
  95. setHelp ("settings");
  96. TDEListView* view = (TDEListView*) child (0, "TDEListView");
  97. if ( view )
  98. {
  99. for ( TQListViewItem* item = view -> firstChild(); item; item = item -> nextSibling() )
  100. item -> setOpen (true);
  101. view -> setMinimumSize (view -> sizeHint());
  102. }
  103. layout = (TQBoxLayout*) child (0, "TQHBoxLayout");
  104. if ( layout )
  105. layout -> insertSpacing (0, 6);
  106. TDEConfig* config = kPlayerConfig();
  107. config -> setGroup ("Dialog Options");
  108. TQString name (config -> readEntry ("Settings Dialog Page"));
  109. if ( ! name.isEmpty() )
  110. {
  111. frame = (TQFrame*) child (name.latin1());
  112. if ( frame )
  113. {
  114. frame = (TQFrame*) frame -> parent();
  115. if ( frame )
  116. showPage (pageIndex (frame));
  117. }
  118. }
  119. /*int x = config -> readNumEntry ("Settings Dialog Left", -1);
  120. int y = config -> readNumEntry ("Settings Dialog Top", -1);*/
  121. int w = config -> readNumEntry ("Settings Dialog Width");
  122. int h = config -> readNumEntry ("Settings Dialog Height");
  123. //TQSize size (config -> readNumEntry ("Settings Dialog Width"),
  124. // config -> readNumEntry ("Settings Dialog Height"));
  125. //TQSize hint = minimumSizeHint();
  126. //if ( size.width() < hint.width() || size.height() < hint.height() )
  127. // size = sizeHint();
  128. //setGeometry (x, y, size.width(), size.height());
  129. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  130. //kdDebugTime() << "KPlayerSettingsDialog position " << x << "x" << y << " size " << w << "x" << h << "\n";
  131. #endif
  132. /*if ( x >= 0 && y >= 0 )
  133. {
  134. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  135. kdDebugTime() << "KPlayerSettingsDialog moving to " << x << "x" << y << "\n";
  136. #endif
  137. move (x, y);
  138. }*/
  139. if ( w > 0 && h > 0 )
  140. {
  141. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  142. kdDebugTime() << "KPlayerSettingsDialog resizing to " << w << "x" << h << "\n";
  143. #endif
  144. resize (w, h);
  145. }
  146. }
  147. KPlayerSettingsDialog::~KPlayerSettingsDialog (void)
  148. {
  149. kPlayerEngine() -> getLists();
  150. TDEConfig* config = kPlayerConfig();
  151. config -> setGroup ("Dialog Options");
  152. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  153. kdDebugTime() << "KPlayerSettingsDialog " << x() << "x" << y() << " " << width() << "x" << height() << " Hint " << sizeHint().width() << "x" << sizeHint().height() << "\n";
  154. #endif
  155. /*if ( size() == sizeHint() )
  156. {
  157. config -> deleteEntry ("Settings Dialog Width");
  158. config -> deleteEntry ("Settings Dialog Height");
  159. }
  160. else
  161. {*/
  162. /*config -> writeEntry ("Settings Dialog Left", frameGeometry().x());
  163. config -> writeEntry ("Settings Dialog Top", frameGeometry().y());*/
  164. config -> writeEntry ("Settings Dialog Width", width());
  165. config -> writeEntry ("Settings Dialog Height", height());
  166. }
  167. /*void KPlayerSettingsDialog::moveEvent (TQMoveEvent* event)
  168. {
  169. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  170. kdDebugTime() << "KPlayerSettingsDialog move " << event -> oldPos().x() << "x" << event -> oldPos().y()
  171. << " => " << event -> pos().x() << "x" << event -> pos().y() << "\n";
  172. #endif
  173. KDialogBase::moveEvent (event);
  174. if ( m_initial_move )
  175. return;
  176. m_initial_move = true;
  177. TDEConfig* config = kPlayerConfig();
  178. config -> setGroup ("Dialog Options");
  179. int x = config -> readNumEntry ("Settings Dialog Left", -1);
  180. int y = config -> readNumEntry ("Settings Dialog Top", -1);
  181. if ( x >= 0 && y >= 0 )
  182. {
  183. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  184. kdDebugTime() << "KPlayerSettingsDialog moving to " << x << "x" << y << "\n";
  185. #endif
  186. move (x + frameGeometry().x() - geometry().x(), y + frameGeometry().y() - geometry().y());
  187. }
  188. m_initial_move = false;
  189. }
  190. void KPlayerSettingsDialog::resizeEvent (TQResizeEvent* event)
  191. {
  192. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  193. kdDebugTime() << "KPlayerSettingsDialog resize " << event -> oldSize(). width() << "x" << event -> oldSize(). height()
  194. << " => " << event -> size(). width() << "x" << event -> size(). height() << "\n";
  195. #endif
  196. KDialogBase::resizeEvent (event);
  197. }
  198. void KPlayerSettingsDialog::showEvent (TQShowEvent* event)
  199. {
  200. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  201. kdDebugTime() << "KPlayerSettingsDialog::showEvent\n";
  202. #endif
  203. KDialogBase::showEvent (event);
  204. }
  205. void KPlayerSettingsDialog::windowActivationChange (bool old)
  206. {
  207. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  208. kdDebugTime() << "KPlayerSettingsDialog::windowActivationChange " << old << "\n";
  209. #endif
  210. m_initial_move = true;
  211. KDialogBase::windowActivationChange (old);
  212. }*/
  213. void KPlayerSettingsDialog::slotDefault (void)
  214. {
  215. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  216. kdDebugTime() << "KPlayerSettingsDialog::defaults\n";
  217. #endif
  218. if ( KMessageBox::warningYesNo (this, i18n("All configuration settings will be reset.\n\nAre you sure?"))
  219. != KMessageBox::Yes )
  220. return;
  221. configuration() -> defaults();
  222. configuration() -> commit();
  223. m_general -> load();
  224. m_controls -> load();
  225. m_video -> load();
  226. m_audio -> load();
  227. m_sliders -> load();
  228. m_subtitles -> load();
  229. m_advanced -> load();
  230. m_progress -> load();
  231. m_volume -> load();
  232. m_contrast -> load();
  233. m_brightness -> load();
  234. m_hue -> load();
  235. m_saturation -> load();
  236. setButtonCancel (KStdGuiItem::close());
  237. KDialogBase::slotDefault();
  238. }
  239. void KPlayerSettingsDialog::pageAboutToShow (TQWidget* page)
  240. {
  241. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  242. kdDebugTime() << "KPlayerSettingsDialog::pageAboutToShow\n";
  243. #endif
  244. m_advanced -> refreshLists();
  245. TQObject* object = page -> child (0, "TQFrame");
  246. TDEConfig* config = kPlayerConfig();
  247. config -> setGroup ("Dialog Options");
  248. TQString name;
  249. if ( object )
  250. {
  251. name = object -> name ("");
  252. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  253. kdDebugTime() << " Page " << name << "\n";
  254. #endif
  255. }
  256. if ( name.isEmpty() )
  257. config -> deleteEntry ("Settings Dialog Page");
  258. else
  259. config -> writeEntry ("Settings Dialog Page", name);
  260. setHelp (name.isEmpty() ? "settings" : "settings-" + name);
  261. }
  262. void KPlayerSettingsDialog::slotOk (void)
  263. {
  264. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  265. kdDebugTime() << "KPlayerSettingsDialog::OK\n";
  266. #endif
  267. slotApply();
  268. KDialogBase::slotOk();
  269. }
  270. //void dumpObject (const TQObject* object, int indent, int depth = 20);
  271. void KPlayerSettingsDialog::slotApply (void)
  272. {
  273. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  274. kdDebugTime() << "KPlayerSettingsDialog::apply\n";
  275. //dumpObject (this, 0);
  276. #endif
  277. m_advanced -> save();
  278. m_audio -> save();
  279. m_controls -> save();
  280. m_general -> save();
  281. m_sliders -> save();
  282. m_subtitles -> save();
  283. m_video -> save();
  284. m_progress -> save();
  285. m_volume -> save();
  286. m_contrast -> save();
  287. m_brightness -> save();
  288. m_hue -> save();
  289. m_saturation -> save();
  290. configuration() -> commit();
  291. setButtonCancel (KStdGuiItem::close());
  292. KDialogBase::slotApply();
  293. }
  294. KPlayerSettingsAdvanced::KPlayerSettingsAdvanced (TQWidget* parent, const char* name)
  295. : KPlayerSettingsAdvancedPage (parent, name)
  296. {
  297. loadLists();
  298. load();
  299. TQApplication::connect (kPlayerEngine(), SIGNAL (updated()), this, SLOT (refresh()));
  300. }
  301. void KPlayerSettingsAdvanced::refresh (void)
  302. {
  303. int index = c_demuxer -> currentItem();
  304. if ( index > 0 )
  305. index = engine() -> demuxerIndex (listEntry (c_demuxer)) + 1;
  306. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  307. kdDebugTime() << "Demuxer: " << c_demuxer -> currentText() << " => " << index << " / " << engine() -> demuxerCount() << "\n";
  308. #endif
  309. loadLists();
  310. c_demuxer -> setCurrentItem (index);
  311. }
  312. void KPlayerSettingsAdvanced::loadLists (void)
  313. {
  314. if ( engine() -> demuxerCount() )
  315. {
  316. c_demuxer -> clear();
  317. c_demuxer -> insertItem (i18n("auto"));
  318. for ( int i = 0; i < engine() -> demuxerCount(); i ++ )
  319. c_demuxer -> insertItem (engine() -> demuxerName (i));
  320. }
  321. }
  322. void KPlayerSettingsAdvanced::load (void)
  323. {
  324. c_executable_path -> setText (configuration() -> executablePath());
  325. c_command_line -> setText (configuration() -> commandLine());
  326. c_demuxer -> setCurrentItem (engine() -> demuxerIndex (configuration() -> demuxer()) + 1);
  327. c_frame_drop -> setCurrentItem (configuration() -> frameDrop());
  328. c_use_cache -> setCurrentItem (configuration() -> cache());
  329. cacheChanged (c_use_cache -> currentItem());
  330. c_build_index -> setCurrentItem (configuration() -> buildNewIndex());
  331. c_osd_level -> setCurrentItem (configuration() -> osdLevel());
  332. c_use_temporary_file -> setChecked (configuration() -> useTemporaryFile());
  333. c_use_tdeioslave_for_http -> setChecked (configuration() -> useKioslaveForHttp());
  334. c_use_tdeioslave_for_ftp -> setChecked (configuration() -> useKioslaveForFtp());
  335. c_use_tdeioslave_for_smb -> setChecked (configuration() -> useKioslaveForSmb());
  336. }
  337. void KPlayerSettingsAdvanced::save (void)
  338. {
  339. configuration() -> setExecutablePath (c_executable_path -> text());
  340. configuration() -> setCommandLine (c_command_line -> text());
  341. configuration() -> setDemuxer (listEntry (c_demuxer));
  342. configuration() -> setFrameDrop (c_frame_drop -> currentItem());
  343. configuration() -> setCache (c_use_cache -> currentItem(), labs (c_cache_size -> text().toInt()));
  344. configuration() -> setBuildNewIndex (c_build_index -> currentItem());
  345. configuration() -> setOsdLevel (c_osd_level -> currentItem());
  346. configuration() -> setUseTemporaryFile (c_use_temporary_file -> isChecked());
  347. configuration() -> setUseKioslaveForHttp (c_use_tdeioslave_for_http -> isChecked());
  348. configuration() -> setUseKioslaveForFtp (c_use_tdeioslave_for_ftp -> isChecked());
  349. configuration() -> setUseKioslaveForSmb (c_use_tdeioslave_for_smb -> isChecked());
  350. }
  351. void KPlayerSettingsAdvanced::refreshLists (void)
  352. {
  353. engine() -> getLists (c_executable_path -> text());
  354. }
  355. void KPlayerSettingsAdvanced::cacheChanged (int cache)
  356. {
  357. if ( cache == 2 )
  358. c_cache_size -> setText (TQString::number (configuration() -> cacheSize()));
  359. else
  360. c_cache_size -> setText ("");
  361. c_cache_size -> setEnabled (cache == 2);
  362. l_cache_size_kb -> setEnabled (cache == 2);
  363. if ( cache == 2 && sender() )
  364. {
  365. c_cache_size -> setFocus();
  366. c_cache_size -> selectAll();
  367. }
  368. }
  369. KPlayerSettingsAudio::KPlayerSettingsAudio (TQWidget* parent, const char* name)
  370. : KPlayerSettingsAudioPage (parent, name)
  371. {
  372. m_amixer_running = false;
  373. loadLists();
  374. load();
  375. TQApplication::connect (kPlayerEngine(), SIGNAL (updated()), this, SLOT (refresh()));
  376. }
  377. void KPlayerSettingsAudio::refresh (void)
  378. {
  379. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  380. kdDebugTime() << "KPlayerSettingsAudio::refresh\n";
  381. #endif
  382. int dindex = c_driver -> currentItem();
  383. if ( dindex > 0 )
  384. dindex = engine() -> audioDriverIndex (listEntry (c_driver)) + 1;
  385. int cindex = c_codec -> currentItem();
  386. if ( cindex > 0 )
  387. cindex = engine() -> audioCodecIndex (listEntry (c_codec)) + 1;
  388. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  389. kdDebugTime() << "Audio Driver: " << c_driver -> currentText() << " => " << dindex << " / " << engine() -> audioDriverCount() << "\n";
  390. kdDebugTime() << "Audio Codec: " << c_codec -> currentText() << " => " << cindex << " / " << engine() -> audioCodecCount() << "\n";
  391. #endif
  392. loadLists();
  393. c_driver -> setCurrentItem (dindex);
  394. driverChanged (dindex);
  395. c_codec -> setCurrentItem (cindex);
  396. }
  397. void KPlayerSettingsAudio::loadLists (void)
  398. {
  399. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  400. kdDebugTime() << "KPlayerSettingsAudio::loadLists\n";
  401. #endif
  402. if ( engine() -> audioCodecCount() )
  403. {
  404. c_codec -> clear();
  405. c_codec -> insertItem (i18n("auto"));
  406. for ( int i = 0; i < engine() -> audioCodecCount(); i ++ )
  407. c_codec -> insertItem (engine() -> audioCodecName (i));
  408. }
  409. if ( engine() -> audioDriverCount() )
  410. {
  411. c_driver -> clear();
  412. c_driver -> insertItem (i18n("auto"));
  413. for ( int i = 0; i < engine() -> audioDriverCount(); i ++ )
  414. c_driver -> insertItem (engine() -> audioDriverName (i));
  415. }
  416. }
  417. void KPlayerSettingsAudio::load (void)
  418. {
  419. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  420. kdDebugTime() << "KPlayerSettingsAudio::load\n";
  421. #endif
  422. c_driver -> setCurrentItem (engine() -> audioDriverIndex (configuration() -> audioDriver()) + 1);
  423. m_softvol = configuration() -> softwareVolume();
  424. c_softvol -> setChecked (m_softvol);
  425. softvolChanged (m_softvol);
  426. c_codec -> setCurrentItem (engine() -> audioCodecIndex (configuration() -> audioCodec()) + 1);
  427. c_delay_step -> setText (TQString::number (configuration() -> audioDelayStep()));
  428. }
  429. void KPlayerSettingsAudio::save (void)
  430. {
  431. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  432. kdDebugTime() << "KPlayerSettingsAudio::save\n";
  433. #endif
  434. configuration() -> setAudioDriver (listEntry (c_driver));
  435. if ( c_driver -> currentItem() > 0 )
  436. {
  437. configuration() -> setAudioDevice (c_device -> text());
  438. configuration() -> setMixerDevice (c_mixer -> text());
  439. configuration() -> setMixerChannel (c_channel -> currentText());
  440. }
  441. configuration() -> setSoftwareVolume (c_softvol -> isChecked());
  442. if ( configuration() -> softwareVolume() )
  443. {
  444. int maximum = labs (c_maximum -> text().toInt());
  445. if ( maximum < 10 )
  446. configuration() -> resetMaximumSoftwareVolume();
  447. else
  448. configuration() -> setMaximumSoftwareVolume (maximum);
  449. }
  450. configuration() -> setAudioCodec (listEntry (c_codec));
  451. float value = fabs (c_delay_step -> text().toFloat());
  452. if ( value )
  453. configuration() -> setAudioDelayStep (value);
  454. else
  455. configuration() -> resetAudioDelayStep();
  456. }
  457. void KPlayerSettingsAudio::defaultAlsaChannels (void)
  458. {
  459. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  460. kdDebugTime() << "KPlayerSettingsAudio::defaultAlsaChannels\n";
  461. #endif
  462. TQString text = c_channel -> currentText();
  463. c_channel -> insertItem ("Master");
  464. c_channel -> insertItem ("PCM");
  465. c_channel -> insertItem ("Line");
  466. c_channel -> setEditText (text);
  467. }
  468. void KPlayerSettingsAudio::runAmixer (void)
  469. {
  470. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  471. kdDebugTime() << "KPlayerSettingsAudio::runAmixer\n";
  472. #endif
  473. m_rerun_amixer = m_amixer_running;
  474. if ( m_amixer_running )
  475. return;
  476. c_channel -> clear();
  477. KPlayerLineOutputProcess* amixer = new KPlayerLineOutputProcess;
  478. *amixer << "amixer";
  479. TQString mixer = c_mixer -> text();
  480. if ( ! mixer.isEmpty() )
  481. {
  482. *amixer << "-D" << mixer;
  483. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  484. kdDebugTime() << " Device " << mixer << "\n";
  485. #endif
  486. }
  487. *amixer << "scontents";
  488. connect (amixer, SIGNAL (receivedStdoutLine (KPlayerLineOutputProcess*, char*, int)),
  489. SLOT (amixerOutput (KPlayerLineOutputProcess*, char*, int)));
  490. connect (amixer, SIGNAL (processExited (TDEProcess*)), SLOT (amixerExited (TDEProcess*)));
  491. m_amixer_running = amixer -> start (TDEProcess::NotifyOnExit, TDEProcess::All);
  492. if ( ! m_amixer_running )
  493. defaultAlsaChannels();
  494. }
  495. void KPlayerSettingsAudio::amixerOutput (KPlayerLineOutputProcess*, char* str, int)
  496. {
  497. static TQString control;
  498. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  499. kdDebugTime() << " amixer: " << str << "\n";
  500. #endif
  501. static TQRegExp re_control ("^Simple mixer control '(.*)'");
  502. static TQRegExp re_pvolume ("^ +Capabilities:.* pvolume");
  503. if ( re_control.search (str) >= 0 )
  504. {
  505. control = re_control.cap(1);
  506. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  507. kdDebugTime() << " Control " << control << "\n";
  508. #endif
  509. }
  510. else if ( re_pvolume.search (str) >= 0 )
  511. {
  512. TQString text = c_channel -> currentText();
  513. c_channel -> insertItem (control);
  514. c_channel -> setEditText (text);
  515. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  516. kdDebugTime() << " Volume " << control << "\n";
  517. #endif
  518. }
  519. }
  520. void KPlayerSettingsAudio::amixerExited (TDEProcess* proc)
  521. {
  522. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  523. kdDebugTime() << "KPlayerSettingsAudio::amixerExited\n";
  524. #endif
  525. delete proc;
  526. m_amixer_running = false;
  527. if ( m_rerun_amixer )
  528. runAmixer();
  529. else if ( c_channel -> count() <= 0 )
  530. defaultAlsaChannels();
  531. }
  532. void KPlayerSettingsAudio::driverChanged (int index)
  533. {
  534. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  535. kdDebugTime() << "KPlayerSettingsAudio::driverChanged\n";
  536. kdDebugTime() << " Index " << index << "\n";
  537. #endif
  538. TQString driver (listEntry (c_driver));
  539. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  540. kdDebugTime() << " Driver " << driver << "\n";
  541. #endif
  542. bool device = index > 0;
  543. bool softvol = c_softvol -> isChecked();
  544. bool mixer = device && ! softvol && (driver == "alsa" || driver == "oss" || driver == "sun");
  545. bool channel = mixer && driver != "sun";
  546. if ( driver != m_driver )
  547. {
  548. bool original = driver == configuration() -> audioDriver();
  549. c_device -> setText (original && device ? configuration() -> audioDevice() : "");
  550. m_device = c_device -> text();
  551. c_mixer -> setText (original && mixer ? configuration() -> mixerDevice() : "");
  552. if ( channel )
  553. if ( driver == "oss" )
  554. {
  555. c_channel -> clear();
  556. c_channel -> insertItem ("vol");
  557. c_channel -> insertItem ("pcm");
  558. c_channel -> insertItem ("line");
  559. }
  560. else if ( ! m_amixer_running )
  561. runAmixer();
  562. c_channel -> setEditText (original && channel ? configuration() -> mixerChannel() : "");
  563. }
  564. c_device -> setEnabled (device);
  565. c_mixer -> setEnabled (mixer);
  566. c_channel -> setEnabled (channel);
  567. m_driver = driver;
  568. }
  569. void KPlayerSettingsAudio::deviceChanged (const TQString& device)
  570. {
  571. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  572. kdDebugTime() << "KPlayerSettingsAudio::deviceChanged\n";
  573. kdDebugTime() << " Device " << device << "\n";
  574. #endif
  575. if ( c_mixer -> isEnabled() && c_mixer -> text() == m_device && listEntry (c_driver) == "alsa" )
  576. c_mixer -> setText (device);
  577. m_device = device;
  578. }
  579. void KPlayerSettingsAudio::mixerChanged (const TQString&)
  580. {
  581. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  582. kdDebugTime() << "KPlayerSettingsAudio::mixerChanged\n";
  583. #endif
  584. if ( ! c_softvol -> isChecked() && listEntry (c_driver) == "alsa" )
  585. runAmixer();
  586. }
  587. void KPlayerSettingsAudio::softvolChanged (bool checked)
  588. {
  589. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  590. kdDebugTime() << "KPlayerSettingsAudio::softvolChanged\n";
  591. kdDebugTime() << " Checked " << checked << "\n";
  592. #endif
  593. c_maximum -> setText (checked ? TQString::number (configuration() -> maximumSoftwareVolume()) : "");
  594. c_maximum -> setEnabled (checked);
  595. TQString driver (listEntry (c_driver));
  596. bool empty = checked || driver != configuration() -> audioDriver()
  597. || driver != "alsa" && driver != "oss" && driver != "sun";
  598. c_mixer -> setText (empty ? "" : configuration() -> hasMixerDevice()
  599. || m_softvol == checked ? configuration() -> mixerDevice() : configuration() -> audioDevice());
  600. c_channel -> setEditText (empty || driver == "sun" ? "" : configuration() -> mixerChannel());
  601. driverChanged (c_driver -> currentItem());
  602. m_softvol = checked;
  603. }
  604. KPlayerSettingsControls::KPlayerSettingsControls (TQWidget* parent, const char* name)
  605. : KPlayerSettingsControlsPage (parent, name)
  606. {
  607. load();
  608. }
  609. void KPlayerSettingsControls::load (void)
  610. {
  611. c_shift -> setChecked (configuration() -> rememberWithShift());
  612. c_size -> setChecked (configuration() -> rememberSize());
  613. rememberSizeChanged (configuration() -> rememberSize());
  614. c_full_screen -> setChecked (configuration() -> rememberFullScreen());
  615. c_maximized -> setChecked (configuration() -> rememberMaximized());
  616. c_maintain_aspect -> setChecked (configuration() -> rememberMaintainAspect());
  617. c_volume -> setChecked (configuration() -> rememberVolume());
  618. c_audio_delay -> setChecked (configuration() -> rememberAudioDelay());
  619. c_frame_drop -> setChecked (configuration() -> rememberFrameDrop());
  620. c_contrast -> setChecked (configuration() -> rememberContrast());
  621. c_brightness -> setChecked (configuration() -> rememberBrightness());
  622. c_hue -> setChecked (configuration() -> rememberHue());
  623. c_saturation -> setChecked (configuration() -> rememberSaturation());
  624. c_subtitle_position -> setChecked (configuration() -> rememberSubtitlePosition());
  625. c_subtitle_delay -> setChecked (configuration() -> rememberSubtitleDelay());
  626. }
  627. void KPlayerSettingsControls::save (void)
  628. {
  629. configuration() -> setRememberWithShift (c_shift -> isChecked());
  630. configuration() -> setRememberSize (c_size -> isChecked());
  631. if ( ! configuration() -> rememberSize() )
  632. configuration() -> setRememberAspect (c_aspect -> isChecked());
  633. configuration() -> setRememberFullScreen (c_full_screen -> isChecked());
  634. configuration() -> setRememberMaximized (c_maximized -> isChecked());
  635. configuration() -> setRememberMaintainAspect (c_maintain_aspect -> isChecked());
  636. configuration() -> setRememberVolume (c_volume -> isChecked());
  637. configuration() -> setRememberAudioDelay (c_audio_delay -> isChecked());
  638. configuration() -> setRememberFrameDrop (c_frame_drop -> isChecked());
  639. configuration() -> setRememberContrast (c_contrast -> isChecked());
  640. configuration() -> setRememberBrightness (c_brightness -> isChecked());
  641. configuration() -> setRememberHue (c_hue -> isChecked());
  642. configuration() -> setRememberSaturation (c_saturation -> isChecked());
  643. configuration() -> setRememberSubtitlePosition (c_subtitle_position -> isChecked());
  644. configuration() -> setRememberSubtitleDelay (c_subtitle_delay -> isChecked());
  645. }
  646. void KPlayerSettingsControls::rememberSizeChanged (bool checked)
  647. {
  648. c_aspect -> setChecked (checked || configuration() -> rememberAspect());
  649. c_aspect -> setEnabled (! checked);
  650. }
  651. KPlayerSettingsGeneral::KPlayerSettingsGeneral (TQWidget* parent, const char* name)
  652. : KPlayerSettingsGeneralPage (parent, name)
  653. {
  654. load();
  655. }
  656. void KPlayerSettingsGeneral::load (void)
  657. {
  658. c_resize_automatically -> setChecked (configuration() -> resizeAutomatically());
  659. resizeAutomaticallyChanged (configuration() -> resizeAutomatically());
  660. c_playlist_menu_size -> setText (TQString::number (configuration() -> playlistMenuSize()));
  661. c_recent_menu_size -> setText (TQString::number (configuration() -> recentMenuSize()));
  662. c_recent_list_size -> setText (TQString::number (configuration() -> recentListSize()));
  663. c_cache_size_limit -> setText (TQString::number (configuration() -> cacheSizeLimit()));
  664. c_allow_duplicate_entries -> setChecked (configuration() -> allowDuplicateEntries());
  665. c_show_messages_on_error -> setChecked (configuration() -> showMessagesOnError());
  666. }
  667. void KPlayerSettingsGeneral::save (void)
  668. {
  669. configuration() -> setResizeAutomatically (c_resize_automatically -> isChecked());
  670. if ( configuration() -> resizeAutomatically() )
  671. configuration() -> setMinimumInitialWidth (labs (c_minimum_initial_width -> text().toInt()));
  672. configuration() -> setPlaylistMenuSize (labs (c_playlist_menu_size -> text().toInt()));
  673. configuration() -> setRecentMenuSize (labs (c_recent_menu_size -> text().toInt()));
  674. configuration() -> setRecentListSize (labs (c_recent_list_size -> text().toInt()));
  675. configuration() -> setCacheSizeLimit (labs (c_cache_size_limit -> text().toInt()));
  676. configuration() -> setAllowDuplicateEntries (c_allow_duplicate_entries -> isChecked());
  677. configuration() -> setShowMessagesOnError (c_show_messages_on_error -> isChecked());
  678. }
  679. void KPlayerSettingsGeneral::resizeAutomaticallyChanged (bool resizeAutomaticallyChecked)
  680. {
  681. if ( resizeAutomaticallyChecked )
  682. c_minimum_initial_width -> setText (TQString::number (configuration() -> minimumInitialWidth()));
  683. else
  684. c_minimum_initial_width -> setText ("");
  685. c_minimum_initial_width -> setEnabled (resizeAutomaticallyChecked);
  686. l_minimum_initial_width -> setEnabled (resizeAutomaticallyChecked);
  687. }
  688. KPlayerSettingsSliders::KPlayerSettingsSliders (TQWidget* parent, const char* name)
  689. : KPlayerSettingsSlidersPage (parent, name)
  690. {
  691. load();
  692. }
  693. void KPlayerSettingsSliders::load (void)
  694. {
  695. c_preferred_slider_length -> setText (TQString::number (configuration() -> preferredSliderLength()));
  696. c_minimum_slider_length -> setText (TQString::number (configuration() -> minimumSliderLength()));
  697. c_show_slider_marks -> setChecked (configuration() -> showSliderMarks());
  698. showMarksChanged (c_show_slider_marks -> isChecked());
  699. }
  700. void KPlayerSettingsSliders::save (void)
  701. {
  702. int value = labs (c_preferred_slider_length -> text().toInt());
  703. if ( value )
  704. configuration() -> setPreferredSliderLength (value);
  705. else
  706. configuration() -> resetPreferredSliderLength();
  707. value = labs (c_minimum_slider_length -> text().toInt());
  708. if ( value )
  709. configuration() -> setMinimumSliderLength (value);
  710. else
  711. configuration() -> resetMinimumSliderLength();
  712. configuration() -> setShowSliderMarks (c_show_slider_marks -> isChecked());
  713. value = labs (c_slider_marks -> text().toInt());
  714. if ( value )
  715. configuration() -> setSliderMarks (value);
  716. else
  717. configuration() -> resetSliderMarks();
  718. }
  719. void KPlayerSettingsSliders::showMarksChanged (bool showMarksChecked)
  720. {
  721. if ( showMarksChecked )
  722. c_slider_marks -> setText (TQString::number (configuration() -> sliderMarks()));
  723. else
  724. c_slider_marks -> setText ("");
  725. l_slider_marks -> setEnabled (showMarksChecked);
  726. c_slider_marks -> setEnabled (showMarksChecked);
  727. l_slider_marks_percent -> setEnabled (showMarksChecked);
  728. }
  729. KPlayerSettingsSubtitles::KPlayerSettingsSubtitles (TQWidget* parent, const char* name)
  730. : KPlayerSettingsSubtitlesPage (parent, name)
  731. {
  732. m_initialized = m_recursion = false;
  733. loadLists();
  734. load();
  735. m_initialized = true;
  736. }
  737. void fillEncodingCombobox (TQComboBox* combobox);
  738. void KPlayerSettingsSubtitles::loadLists (void)
  739. {
  740. TQValueList<int> sizes (TQFontDatabase::standardSizes());
  741. TQValueList<int>::ConstIterator it (sizes.begin());
  742. for ( int i = 1; i < *it; ++ i )
  743. c_text_size -> insertItem (TQString::number (i));
  744. while ( it != sizes.end() )
  745. {
  746. c_text_size -> insertItem (TQString::number (*it));
  747. ++ it;
  748. }
  749. fillEncodingCombobox (c_encoding);
  750. }
  751. void KPlayerSettingsSubtitles::load (void)
  752. {
  753. c_font_name -> setEditText (configuration() -> subtitleFontName());
  754. c_bold -> setChecked (configuration() -> subtitleFontBold());
  755. c_italic -> setChecked (configuration() -> subtitleFontItalic());
  756. if ( configuration() -> subtitleTextSize() )
  757. c_text_size -> setEditText (TQString::number (configuration() -> subtitleTextSize()));
  758. else
  759. c_text_size -> setCurrentItem (0);
  760. c_autoscale -> setChecked (configuration() -> subtitleAutoscale());
  761. c_outline -> setText (TQString::number (configuration() -> subtitleFontOutline()));
  762. outlineEditChanged (c_outline -> text());
  763. c_width -> setText (TQString::number (configuration() -> subtitleTextWidth()));
  764. widthEditChanged (c_width -> text());
  765. c_position_step -> setText (TQString::number (configuration() -> subtitlePositionStep()));
  766. c_delay_step -> setText (TQString::number (configuration() -> subtitleDelayStep()));
  767. if ( configuration() -> hasSubtitleEncoding() )
  768. {
  769. TQString encoding = configuration() -> subtitleEncoding();
  770. c_encoding -> setEditText (encoding);
  771. encoding += ": ";
  772. for ( int i = 1; i < c_encoding -> count(); ++ i )
  773. if ( c_encoding -> text (i).startsWith (encoding) )
  774. {
  775. c_encoding -> setCurrentItem (i);
  776. break;
  777. }
  778. }
  779. else
  780. c_encoding -> setCurrentItem (0);
  781. c_embedded_fonts -> setChecked (configuration() -> subtitleEmbeddedFonts());
  782. c_closed_caption -> setChecked (configuration() -> subtitleClosedCaption());
  783. c_subtitles_autoexpand -> setChecked (configuration() -> hasSubtitleAutoexpand());
  784. autoexpandChanged (c_subtitles_autoexpand -> isChecked());
  785. c_subtitles_autoload -> setChecked (configuration() -> subtitleAutoload());
  786. autoloadSubtitlesChanged (c_subtitles_autoload -> isChecked());
  787. }
  788. void KPlayerSettingsSubtitles::save (void)
  789. {
  790. configuration() -> setSubtitleFontName (c_font_name -> currentText());
  791. configuration() -> setSubtitleFontBold (c_bold -> isChecked());
  792. configuration() -> setSubtitleFontItalic (c_italic -> isChecked());
  793. float value = fabs (c_text_size -> currentText().toFloat());
  794. if ( value )
  795. configuration() -> setSubtitleTextSize (value);
  796. else
  797. configuration() -> resetSubtitleTextSize();
  798. configuration() -> setSubtitleAutoscale (c_autoscale -> isChecked());
  799. configuration() -> setSubtitleFontOutline (c_outline -> text().toFloat());
  800. configuration() -> setSubtitleTextWidth (c_width -> text().toInt());
  801. configuration() -> setSubtitlePositionStep (labs (c_position_step -> text().toInt()));
  802. value = fabs (c_delay_step -> text().toFloat());
  803. if ( value )
  804. configuration() -> setSubtitleDelayStep (value);
  805. else
  806. configuration() -> resetSubtitleDelayStep();
  807. if ( c_encoding -> currentItem() )
  808. configuration() -> setSubtitleEncoding (c_encoding -> currentText().section (':', 0, 0));
  809. else
  810. configuration() -> resetSubtitleEncoding();
  811. configuration() -> setSubtitleEmbeddedFonts (c_embedded_fonts -> isChecked());
  812. configuration() -> setSubtitleClosedCaption (c_closed_caption -> isChecked());
  813. if ( c_subtitles_autoexpand -> isChecked() )
  814. configuration() -> setSubtitleAutoexpand (c_aspect -> currentItem() + 1);
  815. else
  816. configuration() -> resetSubtitleAutoexpand();
  817. configuration() -> setSubtitleAutoload (c_subtitles_autoload -> isChecked());
  818. if ( c_subtitles_autoload -> isChecked() )
  819. configuration() -> setAutoloadExtensionList (c_subtitles_list -> text());
  820. }
  821. void KPlayerSettingsSubtitles::widthSliderChanged (int value)
  822. {
  823. if ( ! m_recursion )
  824. c_width -> setText (TQString::number (value));
  825. }
  826. void KPlayerSettingsSubtitles::widthEditChanged (const TQString& value)
  827. {
  828. int number = value.toInt();
  829. if ( number < 10 )
  830. number = 10;
  831. else if ( number > 100 )
  832. number = 100;
  833. m_recursion = true;
  834. c_width_slider -> setValue (number);
  835. m_recursion = false;
  836. }
  837. void KPlayerSettingsSubtitles::outlineSliderChanged (int value)
  838. {
  839. if ( ! m_recursion )
  840. c_outline -> setText (TQString::number (float (value) / 20));
  841. }
  842. void KPlayerSettingsSubtitles::outlineEditChanged (const TQString& value)
  843. {
  844. int number = int (value.toFloat() * 20 + 0.5);
  845. if ( number < 0 )
  846. number = 0;
  847. else if ( number > 200 )
  848. number = 200;
  849. m_recursion = true;
  850. c_outline_slider -> setValue (number);
  851. m_recursion = false;
  852. }
  853. void KPlayerSettingsSubtitles::autoexpandChanged (bool autoexpandChecked)
  854. {
  855. if ( autoexpandChecked )
  856. {
  857. if ( c_aspect -> text (0).isEmpty() )
  858. c_aspect -> removeItem (0);
  859. int value = configuration() -> subtitleAutoexpand();
  860. c_aspect -> setCurrentItem (value ? value - 1 : 1);
  861. }
  862. else
  863. {
  864. c_aspect -> insertItem ("", 0);
  865. c_aspect -> setCurrentItem (0);
  866. }
  867. c_aspect -> setEnabled (autoexpandChecked);
  868. }
  869. void KPlayerSettingsSubtitles::autoloadSubtitlesChanged (bool autoloadSubtitlesChecked)
  870. {
  871. if ( autoloadSubtitlesChecked )
  872. {
  873. c_subtitles_list -> setText (configuration() -> autoloadExtensionList());
  874. c_subtitles_list -> setCursorPosition (0);
  875. }
  876. else
  877. c_subtitles_list -> setText ("");
  878. l_extensions -> setEnabled (autoloadSubtitlesChecked);
  879. c_subtitles_list -> setEnabled (autoloadSubtitlesChecked);
  880. if ( autoloadSubtitlesChecked && m_initialized )
  881. {
  882. c_subtitles_list -> setFocus();
  883. c_subtitles_list -> selectAll();
  884. }
  885. }
  886. KPlayerSettingsVideo::KPlayerSettingsVideo (TQWidget* parent, const char* name)
  887. : KPlayerSettingsVideoPage (parent, name)
  888. {
  889. loadLists();
  890. load();
  891. TQApplication::connect (engine(), SIGNAL (updated()), this, SLOT (refresh()));
  892. }
  893. void KPlayerSettingsVideo::refresh (void)
  894. {
  895. int dindex = c_driver -> currentItem();
  896. if ( dindex > 0 )
  897. dindex = engine() -> videoDriverIndex (listEntry (c_driver)) + 1;
  898. int cindex = c_codec -> currentItem();
  899. if ( cindex > 0 )
  900. cindex = engine() -> videoCodecIndex (listEntry (c_codec)) + 1;
  901. #ifdef DEBUG_KPLAYER_SETTINGS_DIALOG
  902. kdDebugTime() << "Video Driver: " << c_driver -> currentText()
  903. << " => " << dindex << " / " << engine() -> videoDriverCount() << "\n";
  904. kdDebugTime() << "Video Codec: " << c_codec -> currentText()
  905. << " => " << cindex << " / " << engine() -> videoCodecCount() << "\n";
  906. #endif
  907. loadLists();
  908. c_driver -> setCurrentItem (dindex);
  909. driverChanged (dindex);
  910. c_codec -> setCurrentItem (cindex);
  911. }
  912. void KPlayerSettingsVideo::loadLists (void)
  913. {
  914. if ( engine() -> videoCodecCount() )
  915. {
  916. c_codec -> clear();
  917. c_codec -> insertItem (i18n("auto"));
  918. for ( int i = 0; i < engine() -> videoCodecCount(); i ++ )
  919. c_codec -> insertItem (engine() -> videoCodecName (i));
  920. }
  921. if ( engine() -> videoDriverCount() )
  922. {
  923. c_driver -> clear();
  924. c_driver -> insertItem (i18n("auto"));
  925. for ( int i = 0; i < engine() -> videoDriverCount(); i ++ )
  926. c_driver -> insertItem (engine() -> videoDriverName (i));
  927. }
  928. }
  929. void KPlayerSettingsVideo::load (void)
  930. {
  931. c_driver -> setCurrentItem (engine() -> videoDriverIndex (configuration() -> videoDriver()) + 1);
  932. driverChanged (c_driver -> currentItem());
  933. c_codec -> setCurrentItem (engine() -> videoCodecIndex (configuration() -> videoCodec()) + 1);
  934. c_scaler -> setCurrentItem (configuration() -> videoScaler());
  935. c_doublebuffering -> setChecked (configuration() -> videoDoubleBuffering());
  936. c_direct_rendering -> setChecked (configuration() -> videoDirectRendering());
  937. }
  938. void KPlayerSettingsVideo::save (void)
  939. {
  940. configuration() -> setVideoDriver (listEntry (c_driver));
  941. if ( c_driver -> currentItem() > 0 )
  942. configuration() -> setVideoDevice (c_device -> text());
  943. configuration() -> setVideoCodec (listEntry (c_codec));
  944. configuration() -> setVideoScaler (c_scaler -> currentItem());
  945. configuration() -> setVideoDoubleBuffering (c_doublebuffering -> isChecked());
  946. configuration() -> setVideoDirectRendering (c_direct_rendering -> isChecked());
  947. }
  948. void KPlayerSettingsVideo::driverChanged (int index)
  949. {
  950. c_device -> setText (index > 0 ? configuration() -> videoDevice() : "");
  951. c_device -> setEnabled (index > 0);
  952. }
  953. KPlayerSettingsProgress::KPlayerSettingsProgress (TQWidget* parent, const char* name)
  954. : KPlayerSettingsProgressPage (parent, name)
  955. {
  956. load();
  957. }
  958. void KPlayerSettingsProgress::load (void)
  959. {
  960. c_progress_seek -> setText (TQString::number (configuration() -> progressNormalSeek()));
  961. c_progress_seek_units -> setCurrentItem (configuration() -> progressNormalSeekUnits());
  962. c_progress_fast -> setText (TQString::number (configuration() -> progressFastSeek()));
  963. c_progress_fast_units -> setCurrentItem (configuration() -> progressFastSeekUnits());
  964. }
  965. void KPlayerSettingsProgress::save (void)
  966. {
  967. configuration() -> setProgressNormalSeekUnits (c_progress_seek_units -> currentItem());
  968. configuration() -> setProgressFastSeekUnits (c_progress_fast_units -> currentItem());
  969. configuration() -> setProgressNormalSeek (labs (c_progress_seek -> text().toInt()));
  970. configuration() -> setProgressFastSeek (labs (c_progress_fast -> text().toInt()));
  971. }
  972. KPlayerSettingsVolume::KPlayerSettingsVolume (TQWidget* parent, const char* name)
  973. : KPlayerSettingsVolumePage (parent, name)
  974. {
  975. load();
  976. }
  977. void KPlayerSettingsVolume::load (void)
  978. {
  979. c_volume_minimum -> setText (TQString::number (configuration() -> volumeMinimum()));
  980. c_volume_maximum -> setText (TQString::number (configuration() -> volumeMaximum()));
  981. c_volume_step -> setText (TQString::number (configuration() -> volumeStep()));
  982. c_volume_reset -> setChecked (configuration() -> volumeReset());
  983. resetChanged (configuration() -> volumeReset());
  984. }
  985. void KPlayerSettingsVolume::save (void)
  986. {
  987. configuration() -> setVolumeMinimumMaximum (labs (c_volume_minimum -> text().toInt()), labs (c_volume_maximum -> text().toInt()));
  988. configuration() -> setVolumeStep (labs (c_volume_step -> text().toInt()));
  989. configuration() -> setVolumeReset (c_volume_reset -> isChecked());
  990. if ( configuration() -> volumeReset() )
  991. {
  992. configuration() -> setInitialVolume (labs (c_volume_default -> text().toInt()));
  993. configuration() -> setVolumeEvery (c_volume_every -> currentItem());
  994. }
  995. }
  996. void KPlayerSettingsVolume::resetChanged (bool resetChecked)
  997. {
  998. if ( resetChecked )
  999. {
  1000. c_volume_default -> setText (TQString::number (configuration() -> initialVolume()));
  1001. c_volume_every -> setCurrentItem (0);
  1002. c_volume_every -> setCurrentText (i18n("file"));
  1003. c_volume_every -> setCurrentItem (configuration() -> volumeEvery());
  1004. }
  1005. else
  1006. {
  1007. c_volume_default -> setText ("");
  1008. c_volume_every -> setCurrentItem (0);
  1009. c_volume_every -> setCurrentText ("");
  1010. }
  1011. c_volume_default -> setEnabled (resetChecked);
  1012. c_volume_every -> setEnabled (resetChecked);
  1013. if ( resetChecked && sender() )
  1014. {
  1015. c_volume_default -> setFocus();
  1016. c_volume_default -> selectAll();
  1017. }
  1018. }
  1019. KPlayerSettingsContrast::KPlayerSettingsContrast (TQWidget* parent, const char* name)
  1020. : KPlayerSettingsContrastPage (parent, name)
  1021. {
  1022. load();
  1023. }
  1024. void KPlayerSettingsContrast::load (void)
  1025. {
  1026. c_contrast_minimum -> setText (TQString::number (configuration() -> contrastMinimum()));
  1027. c_contrast_maximum -> setText (TQString::number (configuration() -> contrastMaximum()));
  1028. c_contrast_step -> setText (TQString::number (configuration() -> contrastStep()));
  1029. c_contrast_reset -> setChecked (configuration() -> contrastReset());
  1030. resetChanged (configuration() -> contrastReset());
  1031. }
  1032. void KPlayerSettingsContrast::save (void)
  1033. {
  1034. configuration() -> setContrastMinimumMaximum (c_contrast_minimum -> text().toInt(), c_contrast_maximum -> text().toInt());
  1035. configuration() -> setContrastStep (labs (c_contrast_step -> text().toInt()));
  1036. configuration() -> setContrastReset (c_contrast_reset -> isChecked());
  1037. if ( configuration() -> contrastReset() )
  1038. {
  1039. configuration() -> setInitialContrast (c_contrast_default -> text().toInt());
  1040. configuration() -> setContrastEvery (c_contrast_every -> currentItem());
  1041. }
  1042. }
  1043. void KPlayerSettingsContrast::resetChanged (bool resetChecked)
  1044. {
  1045. if ( resetChecked )
  1046. {
  1047. c_contrast_default -> setText (TQString::number (configuration() -> initialContrast()));
  1048. c_contrast_every -> setCurrentItem (0);
  1049. c_contrast_every -> setCurrentText (i18n("file"));
  1050. c_contrast_every -> setCurrentItem (configuration() -> contrastEvery());
  1051. }
  1052. else
  1053. {
  1054. c_contrast_default -> setText ("");
  1055. c_contrast_every -> setCurrentItem (0);
  1056. c_contrast_every -> setCurrentText ("");
  1057. }
  1058. c_contrast_default -> setEnabled (resetChecked);
  1059. c_contrast_every -> setEnabled (resetChecked);
  1060. if ( resetChecked && sender() )
  1061. {
  1062. c_contrast_default -> setFocus();
  1063. c_contrast_default -> selectAll();
  1064. }
  1065. }
  1066. KPlayerSettingsBrightness::KPlayerSettingsBrightness (TQWidget* parent, const char* name)
  1067. : KPlayerSettingsBrightnessPage (parent, name)
  1068. {
  1069. load();
  1070. }
  1071. void KPlayerSettingsBrightness::load (void)
  1072. {
  1073. c_brightness_minimum -> setText (TQString::number (configuration() -> brightnessMinimum()));
  1074. c_brightness_maximum -> setText (TQString::number (configuration() -> brightnessMaximum()));
  1075. c_brightness_step -> setText (TQString::number (configuration() -> brightnessStep()));
  1076. c_brightness_reset -> setChecked (configuration() -> brightnessReset());
  1077. resetChanged (configuration() -> brightnessReset());
  1078. }
  1079. void KPlayerSettingsBrightness::save (void)
  1080. {
  1081. configuration() -> setBrightnessMinimumMaximum (c_brightness_minimum -> text().toInt(), c_brightness_maximum -> text().toInt());
  1082. configuration() -> setBrightnessStep (labs (c_brightness_step -> text().toInt()));
  1083. configuration() -> setBrightnessReset (c_brightness_reset -> isChecked());
  1084. if ( configuration() -> brightnessReset() )
  1085. {
  1086. configuration() -> setInitialBrightness (c_brightness_default -> text().toInt());
  1087. configuration() -> setBrightnessEvery (c_brightness_every -> currentItem());
  1088. }
  1089. }
  1090. void KPlayerSettingsBrightness::resetChanged (bool resetChecked)
  1091. {
  1092. if ( resetChecked )
  1093. {
  1094. c_brightness_default -> setText (TQString::number (configuration() -> initialBrightness()));
  1095. c_brightness_every -> setCurrentItem (0);
  1096. c_brightness_every -> setCurrentText (i18n("file"));
  1097. c_brightness_every -> setCurrentItem (configuration() -> brightnessEvery());
  1098. }
  1099. else
  1100. {
  1101. c_brightness_default -> setText ("");
  1102. c_brightness_every -> setCurrentItem (0);
  1103. c_brightness_every -> setCurrentText ("");
  1104. }
  1105. c_brightness_default -> setEnabled (resetChecked);
  1106. c_brightness_every -> setEnabled (resetChecked);
  1107. if ( resetChecked && sender() )
  1108. {
  1109. c_brightness_default -> setFocus();
  1110. c_brightness_default -> selectAll();
  1111. }
  1112. }
  1113. KPlayerSettingsHue::KPlayerSettingsHue (TQWidget* parent, const char* name)
  1114. : KPlayerSettingsHuePage (parent, name)
  1115. {
  1116. load();
  1117. }
  1118. void KPlayerSettingsHue::load (void)
  1119. {
  1120. c_hue_minimum -> setText (TQString::number (configuration() -> hueMinimum()));
  1121. c_hue_maximum -> setText (TQString::number (configuration() -> hueMaximum()));
  1122. c_hue_step -> setText (TQString::number (configuration() -> hueStep()));
  1123. c_hue_reset -> setChecked (configuration() -> hueReset());
  1124. resetChanged (configuration() -> hueReset());
  1125. }
  1126. void KPlayerSettingsHue::save (void)
  1127. {
  1128. configuration() -> setHueMinimumMaximum (c_hue_minimum -> text().toInt(), c_hue_maximum -> text().toInt());
  1129. configuration() -> setHueStep (labs (c_hue_step -> text().toInt()));
  1130. configuration() -> setHueReset (c_hue_reset -> isChecked());
  1131. if ( configuration() -> hueReset() )
  1132. {
  1133. configuration() -> setInitialHue (c_hue_default -> text().toInt());
  1134. configuration() -> setHueEvery (c_hue_every -> currentItem());
  1135. }
  1136. }
  1137. void KPlayerSettingsHue::resetChanged (bool resetChecked)
  1138. {
  1139. if ( resetChecked )
  1140. {
  1141. c_hue_default -> setText (TQString::number (configuration() -> initialHue()));
  1142. c_hue_every -> setCurrentItem (0);
  1143. c_hue_every -> setCurrentText (i18n("file"));
  1144. c_hue_every -> setCurrentItem (configuration() -> hueEvery());
  1145. }
  1146. else
  1147. {
  1148. c_hue_default -> setText ("");
  1149. c_hue_every -> setCurrentItem (0);
  1150. c_hue_every -> setCurrentText ("");
  1151. }
  1152. c_hue_default -> setEnabled (resetChecked);
  1153. c_hue_every -> setEnabled (resetChecked);
  1154. if ( resetChecked && sender() )
  1155. {
  1156. c_hue_default -> setFocus();
  1157. c_hue_default -> selectAll();
  1158. }
  1159. }
  1160. KPlayerSettingsSaturation::KPlayerSettingsSaturation (TQWidget* parent, const char* name)
  1161. : KPlayerSettingsSaturationPage (parent, name)
  1162. {
  1163. load();
  1164. }
  1165. void KPlayerSettingsSaturation::load (void)
  1166. {
  1167. c_saturation_minimum -> setText (TQString::number (configuration() -> saturationMinimum()));
  1168. c_saturation_maximum -> setText (TQString::number (configuration() -> saturationMaximum()));
  1169. c_saturation_step -> setText (TQString::number (configuration() -> saturationStep()));
  1170. c_saturation_reset -> setChecked (configuration() -> saturationReset());
  1171. resetChanged (configuration() -> saturationReset());
  1172. }
  1173. void KPlayerSettingsSaturation::save (void)
  1174. {
  1175. configuration() -> setSaturationMinimumMaximum (c_saturation_minimum -> text().toInt(), c_saturation_maximum -> text().toInt());
  1176. configuration() -> setSaturationStep (labs (c_saturation_step -> text().toInt()));
  1177. configuration() -> setSaturationReset (c_saturation_reset -> isChecked());
  1178. if ( configuration() -> saturationReset() )
  1179. {
  1180. configuration() -> setInitialSaturation (c_saturation_default -> text().toInt());
  1181. configuration() -> setSaturationEvery (c_saturation_every -> currentItem());
  1182. }
  1183. }
  1184. void KPlayerSettingsSaturation::resetChanged (bool resetChecked)
  1185. {
  1186. if ( resetChecked )
  1187. {
  1188. c_saturation_default -> setText (TQString::number (configuration() -> initialSaturation()));
  1189. c_saturation_every -> setCurrentItem (0);
  1190. c_saturation_every -> setCurrentText (i18n("file"));
  1191. c_saturation_every -> setCurrentItem (configuration() -> saturationEvery());
  1192. }
  1193. else
  1194. {
  1195. c_saturation_default -> setText ("");
  1196. c_saturation_every -> setCurrentItem (0);
  1197. c_saturation_every -> setCurrentText ("");
  1198. }
  1199. c_saturation_default -> setEnabled (resetChecked);
  1200. c_saturation_every -> setEnabled (resetChecked);
  1201. if ( resetChecked && sender() )
  1202. {
  1203. c_saturation_default -> setFocus();
  1204. c_saturation_default -> selectAll();
  1205. }
  1206. }