TDE base libraries and programs
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.

1333 lines
39 KiB

  1. /*
  2. kate: space-indent on; indent-width 3; indent-mode cstyle;
  3. This file is part of the KDE libraries
  4. Copyright (c) 2005 David Saxton <david@bluehaze.org>
  5. Copyright (c) 2003 Waldo Bastian <bastian@kde.org>
  6. Copyright (c) 1999 Geert Jansen <g.t.jansen@stud.tue.nl>
  7. Copyright (c) 1996 Martin R. Jones
  8. Copyright (c) 1997 Matthias Hoelzer
  9. Copyright (c) 1997 Mark Donohoe
  10. Copyright (c) 1998 Stephan Kulow
  11. Copyright (c) 1998 Matej Koss
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. version 2 as published by the Free Software Foundation.
  15. This library is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. Library General Public License for more details.
  19. You should have received a copy of the GNU Library General Public License
  20. along with this library; see the file COPYING.LIB. If not, write to
  21. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  22. Boston, MA 02110-1301, USA.
  23. */
  24. #include <config.h>
  25. #include <tqbuttongroup.h>
  26. #include <tqcheckbox.h>
  27. #include <tqlabel.h>
  28. #include <tqpainter.h>
  29. #include <tqradiobutton.h>
  30. #include <tqslider.h>
  31. #include <tqtimer.h>
  32. #include <tqtooltip.h>
  33. #include <tqwhatsthis.h>
  34. #include <tqapplication.h>
  35. #include <tdeconfig.h>
  36. #include <kdebug.h>
  37. #include <tdefiledialog.h>
  38. #include <tdefilemetainfo.h>
  39. #include <tdeglobal.h>
  40. #include <kiconloader.h>
  41. #include <kimageio.h>
  42. #include <tdelocale.h>
  43. #include <kpixmap.h>
  44. #include <kstandarddirs.h>
  45. #include <kstringhandler.h>
  46. #include <kurlrequester.h>
  47. #include <twin.h>
  48. #include <twinmodule.h>
  49. #include <kimagefilepreview.h>
  50. #include <tdenewstuff/downloaddialog.h>
  51. #include <stdlib.h>
  52. #include "bgmonitor.h"
  53. #include "bgwallpaper.h"
  54. #include "bgadvanced.h"
  55. #include "bgdialog.h"
  56. #define NR_PREDEF_PATTERNS 6
  57. BGDialog::BGDialog(TQWidget* parent, TDEConfig* _config, bool _multidesktop)
  58. : BGDialog_UI(parent, "BGDialog")
  59. {
  60. m_pGlobals = new TDEGlobalBackgroundSettings(_config);
  61. m_pDirs = TDEGlobal::dirs();
  62. m_multidesktop = _multidesktop;
  63. m_previewUpdates = true;
  64. KWinModule *m_twin;
  65. m_twin = new KWinModule(TQT_TQOBJECT(this));
  66. m_curDesk = m_twin->currentDesktop();
  67. TQSize s(m_twin->numberOfViewports(m_twin->currentDesktop()));
  68. m_useViewports = s.width() * s.height() > 1;
  69. m_numDesks = m_multidesktop ? KWin::numberOfDesktops() : 1;
  70. m_numViewports = s.width() * s.height();
  71. m_numScreens = TQApplication::desktop()->numScreens();
  72. TQCString multiHead = getenv("TDE_MULTIHEAD");
  73. if (multiHead.lower() == "true")
  74. {
  75. m_numScreens = 1;
  76. }
  77. TQPoint vx(m_twin->currentViewport(m_twin->currentDesktop()));
  78. int t_eViewport = (vx.x() * vx.y());
  79. if (t_eViewport < 1) {
  80. t_eViewport = 1;
  81. }
  82. delete m_twin;
  83. m_desk = m_multidesktop ? KWin::currentDesktop() : 1;
  84. m_desk = m_multidesktop ? (m_useViewports ? (((m_desk - 1) * m_numViewports) + t_eViewport) : m_desk) : m_desk;
  85. m_numDesks = m_multidesktop ? (m_useViewports ? (m_numDesks * m_numViewports) : m_numDesks) : m_numDesks;
  86. m_screen = TQApplication::desktop()->screenNumber(this);
  87. if (m_screen >= (int)m_numScreens)
  88. m_screen = m_numScreens-1;
  89. m_eDesk = m_pGlobals->commonDeskBackground() ? 0 : m_desk;
  90. getEScreen();
  91. m_copyAllDesktops = true;
  92. m_copyAllScreens = true;
  93. if (!m_multidesktop)
  94. {
  95. m_pDesktopLabel->hide();
  96. m_comboDesktop->hide();
  97. }
  98. if (m_numScreens < 2)
  99. {
  100. m_comboScreen->hide();
  101. m_buttonIdentifyScreens->hide();
  102. m_screen = 0;
  103. m_eScreen = 0;
  104. }
  105. connect(m_buttonIdentifyScreens, TQT_SIGNAL(clicked()), TQT_SLOT(slotIdentifyScreens()));
  106. // preview monitor
  107. m_pMonitorArrangement = new BGMonitorArrangement(m_screenArrangement, "monitor arrangement");
  108. connect(m_pMonitorArrangement, TQT_SIGNAL(imageDropped(const TQString &)), TQT_SLOT(slotImageDropped(const TQString &)));
  109. if( m_multidesktop)
  110. {
  111. // desktop
  112. connect(m_comboDesktop, TQT_SIGNAL(activated(int)),
  113. TQT_SLOT(slotSelectDesk(int)));
  114. }
  115. if (m_numScreens > 1)
  116. {
  117. connect(m_comboScreen, TQT_SIGNAL(activated(int)),
  118. TQT_SLOT(slotSelectScreen(int)));
  119. }
  120. // background image settings
  121. TQIconSet iconSet = SmallIconSet(TQString::fromLatin1("document-open"));
  122. TQPixmap pixMap = iconSet.pixmap( TQIconSet::Small, TQIconSet::Normal );
  123. m_urlWallpaperButton->setIconSet( iconSet );
  124. m_urlWallpaperButton->setFixedSize( pixMap.width()+8, pixMap.height()+8 );
  125. TQToolTip::add(m_urlWallpaperButton, i18n("Open file dialog"));
  126. connect(m_buttonGroupBackground, TQT_SIGNAL(clicked(int)),
  127. TQT_SLOT(slotWallpaperTypeChanged(int)));
  128. connect(m_urlWallpaperBox, TQT_SIGNAL(activated(int)),
  129. TQT_SLOT(slotWallpaper(int)));
  130. connect(m_urlWallpaperButton, TQT_SIGNAL(clicked()),
  131. TQT_SLOT(slotWallpaperSelection()));
  132. connect(m_comboWallpaperPos, TQT_SIGNAL(activated(int)),
  133. TQT_SLOT(slotWallpaperPos(int)));
  134. connect(m_buttonSetupWallpapers, TQT_SIGNAL(clicked()),
  135. TQT_SLOT(slotSetupMulti()));
  136. // set up the background colour stuff
  137. connect(m_colorPrimary, TQT_SIGNAL(changed(const TQColor &)),
  138. TQT_SLOT(slotPrimaryColor(const TQColor &)));
  139. connect(m_colorSecondary, TQT_SIGNAL(changed(const TQColor &)),
  140. TQT_SLOT(slotSecondaryColor(const TQColor &)));
  141. connect(m_comboPattern, TQT_SIGNAL(activated(int)),
  142. TQT_SLOT(slotPattern(int)));
  143. // blend
  144. connect(m_comboBlend, TQT_SIGNAL(activated(int)), TQT_SLOT(slotBlendMode(int)));
  145. connect(m_sliderBlend, TQT_SIGNAL(valueChanged(int)),
  146. TQT_SLOT(slotBlendBalance(int)));
  147. connect(m_cbBlendReverse, TQT_SIGNAL(toggled(bool)),
  148. TQT_SLOT(slotBlendReverse(bool)));
  149. // Crossfading background
  150. connect(m_cbCrossFadeBg, TQT_SIGNAL(toggled(bool)),
  151. TQT_SLOT(slotCrossFadeBg(bool)));
  152. // advanced options
  153. connect(m_buttonAdvanced, TQT_SIGNAL(clicked()),
  154. TQT_SLOT(slotAdvanced()));
  155. connect(m_buttonGetNew, TQT_SIGNAL(clicked()),
  156. TQT_SLOT(slotGetNewStuff()));
  157. // renderers
  158. m_renderer.resize(m_numDesks+1);
  159. if (m_numScreens > 1)
  160. {
  161. for (unsigned i = 0; i < m_numDesks+1; ++i)
  162. {
  163. m_renderer[i].resize(m_numScreens+2);
  164. m_renderer[i].setAutoDelete(true);
  165. int eDesk = i>0 ? i-1 : 0;
  166. // Setup the merged-screen renderer
  167. KBackgroundRenderer * r = new KBackgroundRenderer(eDesk, 0, false, _config);
  168. m_renderer[i].insert( 0, r );
  169. connect( r, TQT_SIGNAL(imageDone(int,int)), TQT_SLOT(slotPreviewDone(int,int)) );
  170. // Setup the common-screen renderer
  171. r = new KBackgroundRenderer(eDesk, 0, true, _config);
  172. m_renderer[i].insert( 1, r );
  173. connect( r, TQT_SIGNAL(imageDone(int,int)), TQT_SLOT(slotPreviewDone(int,int)) );
  174. // Setup the remaining renderers for each screen
  175. for (unsigned j=0; j < m_numScreens; ++j )
  176. {
  177. r = new KBackgroundRenderer(eDesk, j, true, _config);
  178. m_renderer[i].insert( j+2, r );
  179. connect( r, TQT_SIGNAL(imageDone(int,int)), TQT_SLOT(slotPreviewDone(int,int)) );
  180. }
  181. }
  182. }
  183. else
  184. {
  185. for (unsigned i = 0; i < m_numDesks+1; ++i )
  186. {
  187. m_renderer[i].resize(1);
  188. m_renderer[i].setAutoDelete(true);
  189. }
  190. // set up the common desktop renderer
  191. KBackgroundRenderer * r = new KBackgroundRenderer(0, 0, false, _config);
  192. m_renderer[0].insert(0, r);
  193. connect(r, TQT_SIGNAL(imageDone(int,int)), TQT_SLOT(slotPreviewDone(int,int)));
  194. // set up all the other desktop renderers
  195. for (unsigned i = 0; i < m_numDesks; ++i)
  196. {
  197. r = new KBackgroundRenderer(i, 0, false, _config);
  198. m_renderer[i+1].insert(0, r);
  199. connect(r, TQT_SIGNAL(imageDone(int,int)), TQT_SLOT(slotPreviewDone(int,int)));
  200. }
  201. }
  202. // Random or InOrder
  203. m_slideShowRandom = eRenderer()->multiWallpaperMode();
  204. if (m_slideShowRandom == KBackgroundSettings::NoMultiRandom)
  205. m_slideShowRandom = KBackgroundSettings::Random;
  206. if (m_slideShowRandom == KBackgroundSettings::NoMulti)
  207. m_slideShowRandom = KBackgroundSettings::InOrder;
  208. // Wallpaper Position
  209. m_wallpaperPos = eRenderer()->wallpaperMode();
  210. if (m_wallpaperPos == KBackgroundSettings::NoWallpaper)
  211. m_wallpaperPos = KBackgroundSettings::Centred; // Default
  212. if (TDEGlobal::dirs()->isRestrictedResource("wallpaper"))
  213. {
  214. m_urlWallpaperButton->hide();
  215. m_buttonSetupWallpapers->hide();
  216. m_radioSlideShow->hide();
  217. }
  218. initUI();
  219. updateUI();
  220. #if (TQT_VERSION-0 >= 0x030200)
  221. connect( tqApp->desktop(), TQT_SIGNAL( resized( int )), TQT_SLOT( desktopResized())); // RANDR support
  222. #endif
  223. }
  224. BGDialog::~BGDialog()
  225. {
  226. delete m_pGlobals;
  227. }
  228. KBackgroundRenderer * BGDialog::eRenderer()
  229. {
  230. return m_renderer[m_eDesk][m_eScreen];
  231. }
  232. void BGDialog::getEScreen()
  233. {
  234. if ( m_pGlobals->drawBackgroundPerScreen( m_eDesk>0 ? m_eDesk-1 : 0 ) )
  235. m_eScreen = m_pGlobals->commonScreenBackground() ? 1 : m_screen+2;
  236. else
  237. m_eScreen = 0;
  238. if ( m_numScreens == 1 )
  239. m_eScreen = 0;
  240. else if ( m_eScreen > int(m_numScreens+1) )
  241. m_eScreen = m_numScreens+1;
  242. }
  243. void BGDialog::makeReadOnly()
  244. {
  245. m_pMonitorArrangement->setEnabled( false );
  246. m_comboScreen->setEnabled( false );
  247. m_comboDesktop->setEnabled( false );
  248. m_colorPrimary->setEnabled( false );
  249. m_colorSecondary->setEnabled( false );
  250. m_comboPattern->setEnabled( false );
  251. m_radioNoPicture->setEnabled( false );
  252. m_radioPicture->setEnabled( false );
  253. m_radioSlideShow->setEnabled( false );
  254. m_urlWallpaperBox->setEnabled( false );
  255. m_urlWallpaperButton->setEnabled( false );
  256. m_comboWallpaperPos->setEnabled( false );
  257. m_buttonSetupWallpapers->setEnabled( false );
  258. m_comboBlend->setEnabled( false );
  259. m_sliderBlend->setEnabled( false );
  260. m_cbBlendReverse->setEnabled( false );
  261. m_buttonAdvanced->setEnabled( false );
  262. m_buttonGetNew->setEnabled( false );
  263. m_cbCrossFadeBg->setEnabled( false );
  264. }
  265. void BGDialog::load( bool useDefaults )
  266. {
  267. m_pGlobals->getConfig()->setReadDefaults( useDefaults );
  268. m_pGlobals->readSettings();
  269. m_eDesk = m_pGlobals->commonDeskBackground() ? 0 : m_desk;
  270. getEScreen();
  271. for (unsigned desk = 0; desk < m_renderer.size(); ++desk)
  272. {
  273. unsigned eDesk = desk>0 ? desk-1 : 0;
  274. for (unsigned screen = 0; screen < m_renderer[desk].size(); ++screen)
  275. {
  276. unsigned eScreen = screen>1 ? screen-2 : 0;
  277. m_renderer[desk][screen]->load( eDesk, eScreen, (screen>0), useDefaults );
  278. }
  279. }
  280. m_copyAllDesktops = true;
  281. m_copyAllScreens = true;
  282. // Random or InOrder
  283. m_slideShowRandom = eRenderer()->multiWallpaperMode();
  284. if (m_slideShowRandom == KBackgroundSettings::NoMultiRandom)
  285. m_slideShowRandom = KBackgroundSettings::Random;
  286. if (m_slideShowRandom == KBackgroundSettings::NoMulti)
  287. m_slideShowRandom = KBackgroundSettings::InOrder;
  288. // Wallpaper Position
  289. m_wallpaperPos = eRenderer()->wallpaperMode();
  290. if (m_wallpaperPos == KBackgroundSettings::NoWallpaper)
  291. m_wallpaperPos = KBackgroundSettings::Centred; // Default
  292. updateUI();
  293. emit changed(useDefaults);
  294. }
  295. void BGDialog::save()
  296. {
  297. m_pGlobals->writeSettings();
  298. // write out the common desktop or the "Desktop 1" settings
  299. // depending on which are the real settings
  300. // they both share Desktop[0] in the config file
  301. // similar for screen...
  302. for (unsigned desk = 0; desk < m_renderer.size(); ++desk)
  303. {
  304. if (desk == 0 && !m_pGlobals->commonDeskBackground())
  305. continue;
  306. if (desk == 1 && m_pGlobals->commonDeskBackground())
  307. continue;
  308. for (unsigned screen = 0; screen < m_renderer[desk].size(); ++screen)
  309. {
  310. if (screen == 1 && !m_pGlobals->commonScreenBackground())
  311. continue;
  312. if (screen == 2 && m_pGlobals->commonScreenBackground())
  313. continue;
  314. m_renderer[desk][screen]->writeSettings();
  315. }
  316. }
  317. emit changed(false);
  318. }
  319. void BGDialog::defaults()
  320. {
  321. load( true );
  322. eRenderer()->setWallpaper( eRenderer()->wallpaper() );
  323. }
  324. TQString BGDialog::quickHelp() const
  325. {
  326. return i18n("<h1>Background</h1> This module allows you to control the"
  327. " appearance of the virtual desktops. TDE offers a variety of options"
  328. " for customization, including the ability to specify different settings"
  329. " for each virtual desktop, or a common background for all of them.<p>"
  330. " The appearance of the desktop results from the combination of its"
  331. " background colors and patterns, and optionally, wallpaper, which is"
  332. " based on the image from a graphic file.<p>"
  333. " The background can be made up of a single color, or a pair of colors"
  334. " which can be blended in a variety of patterns. Wallpaper is also"
  335. " customizable, with options for tiling and stretching images. The"
  336. " wallpaper can be overlaid opaquely, or blended in different ways with"
  337. " the background colors and patterns.<p>"
  338. " TDE allows you to have the wallpaper change automatically at specified"
  339. " intervals of time. You can also replace the background with a program"
  340. " that updates the desktop dynamically. For example, the \"kworldclock\""
  341. " program shows a day/night map of the world which is updated periodically.");
  342. }
  343. void BGDialog::slotIdentifyScreens()
  344. {
  345. // Taken from PositionTab::showIdentify in tdebase/kcontrol/kicker/positiontab_impl.cpp
  346. for(unsigned s = 0; s < m_numScreens; s++)
  347. {
  348. TQLabel *screenLabel = new TQLabel(0,"Screen Identify", (WFlags)(WDestructiveClose | WStyle_Customize | WX11BypassWM));
  349. TQFont identifyFont(TDEGlobalSettings::generalFont());
  350. identifyFont.setPixelSize(100);
  351. screenLabel->setFont(identifyFont);
  352. screenLabel->setFrameStyle(TQFrame::Panel);
  353. screenLabel->setFrameShadow(TQFrame::Plain);
  354. screenLabel->setAlignment(Qt::AlignCenter);
  355. screenLabel->setNum(int(s + 1));
  356. // BUGLET: we should not allow the identification to be entered again
  357. // until the timer fires.
  358. TQTimer::singleShot(1500, screenLabel, TQT_SLOT(close()));
  359. TQPoint screenCenter(TQApplication::desktop()->screenGeometry(s).center());
  360. TQRect targetGeometry(TQPoint(0,0),screenLabel->sizeHint());
  361. targetGeometry.moveCenter(screenCenter);
  362. screenLabel->setGeometry(targetGeometry);
  363. screenLabel->show();
  364. }
  365. }
  366. void BGDialog::initUI()
  367. {
  368. // Desktop names
  369. if (m_useViewports == false) {
  370. for (unsigned i = 0; i < m_numDesks; ++i) {
  371. m_comboDesktop->insertItem(m_pGlobals->deskName(i));
  372. }
  373. }
  374. else {
  375. for (unsigned i = 0; i < (m_numDesks/m_numViewports); ++i) {
  376. for (unsigned j = 0; j < m_numViewports; ++j) {
  377. m_comboDesktop->insertItem(i18n("Desktop %1 Viewport %2").arg(i+1).arg(j+1));
  378. }
  379. }
  380. }
  381. // Screens
  382. for (unsigned i = 0; i < m_numScreens; ++i)
  383. m_comboScreen->insertItem( i18n("Screen %1").arg(TQString::number(i+1)) );
  384. // Patterns
  385. m_comboPattern->insertItem(i18n("Single Color"));
  386. m_comboPattern->insertItem(i18n("Horizontal Gradient"));
  387. m_comboPattern->insertItem(i18n("Vertical Gradient"));
  388. m_comboPattern->insertItem(i18n("Pyramid Gradient"));
  389. m_comboPattern->insertItem(i18n("Pipecross Gradient"));
  390. m_comboPattern->insertItem(i18n("Elliptic Gradient"));
  391. m_patterns = KBackgroundPattern::list();
  392. m_patterns.sort(); // Defined order
  393. TQStringList::Iterator it;
  394. for (it=m_patterns.begin(); it != m_patterns.end(); ++it)
  395. {
  396. KBackgroundPattern pat(*it);
  397. if (pat.isAvailable())
  398. m_comboPattern->insertItem(pat.comment());
  399. }
  400. loadWallpaperFilesList();
  401. // Wallpaper tilings: again they must match the ones from bgrender.cc
  402. m_comboWallpaperPos->insertItem(i18n("Centered"));
  403. m_comboWallpaperPos->insertItem(i18n("Tiled"));
  404. m_comboWallpaperPos->insertItem(i18n("Center Tiled"));
  405. m_comboWallpaperPos->insertItem(i18n("Centered Maxpect"));
  406. m_comboWallpaperPos->insertItem(i18n("Tiled Maxpect"));
  407. m_comboWallpaperPos->insertItem(i18n("Scaled"));
  408. m_comboWallpaperPos->insertItem(i18n("Centered Auto Fit"));
  409. m_comboWallpaperPos->insertItem(i18n("Scale & Crop"));
  410. // Blend modes: make sure these match with kdesktop/bgrender.cc !!
  411. m_comboBlend->insertItem(i18n("No Blending"));
  412. m_comboBlend->insertItem(i18n("Flat"));
  413. m_comboBlend->insertItem(i18n("Horizontal"));
  414. m_comboBlend->insertItem(i18n("Vertical"));
  415. m_comboBlend->insertItem(i18n("Pyramid"));
  416. m_comboBlend->insertItem(i18n("Pipecross"));
  417. m_comboBlend->insertItem(i18n("Elliptic"));
  418. m_comboBlend->insertItem(i18n("Intensity"));
  419. m_comboBlend->insertItem(i18n("Saturation"));
  420. m_comboBlend->insertItem(i18n("Contrast"));
  421. m_comboBlend->insertItem(i18n("Hue Shift"));
  422. }
  423. void BGDialog::loadWallpaperFilesList() {
  424. // Wallpapers
  425. // the following TQMap is lower cased names mapped to cased names and URLs
  426. // this way we get case insensitive sorting
  427. TQMap<TQString, QPair<TQString, TQString> > papers;
  428. //search for .desktop files before searching for images without .desktop files
  429. TQStringList lst = m_pDirs->findAllResources("wallpaper", "*desktop", false, true);
  430. TQStringList files;
  431. TQStringList hiddenfiles;
  432. for (TQStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it)
  433. {
  434. KSimpleConfig fileConfig(*it);
  435. fileConfig.setGroup("Wallpaper");
  436. int slash = (*it).findRev('/') + 1;
  437. TQString directory = (*it).left(slash);
  438. TQString imageCaption = fileConfig.readEntry("Name");
  439. TQString fileName = fileConfig.readEntry("File");
  440. if (fileConfig.readBoolEntry("Hidden",false)) {
  441. hiddenfiles.append(directory + fileName);
  442. continue;
  443. }
  444. if (imageCaption.isEmpty())
  445. {
  446. imageCaption = fileName;
  447. imageCaption.replace('_', ' ');
  448. imageCaption = KStringHandler::capwords(imageCaption);
  449. }
  450. // avoid name collisions
  451. TQString rs = imageCaption;
  452. TQString lrs = rs.lower();
  453. for (int n = 1; papers.find(lrs) != papers.end(); ++n)
  454. {
  455. rs = imageCaption + " (" + TQString::number(n) + ')';
  456. lrs = rs.lower();
  457. }
  458. bool canLoadScaleable = false;
  459. #ifdef HAVE_LIBART
  460. canLoadScaleable = true;
  461. #endif
  462. if ( fileConfig.readEntry("ImageType") == "pixmap" || canLoadScaleable ) {
  463. papers[lrs] = qMakePair(rs, directory + fileName);
  464. files.append(directory + fileName);
  465. }
  466. }
  467. //now find any wallpapers that don't have a .desktop file
  468. lst = m_pDirs->findAllResources("wallpaper", "*", false, true);
  469. for (TQStringList::ConstIterator it = lst.begin(); it != lst.end(); ++it)
  470. {
  471. if ( !(*it).endsWith(".desktop") && files.grep(*it).empty() && hiddenfiles.grep(*it).empty() ) {
  472. // First try to see if we have a comment describing the image. If we do
  473. // just use the first line of said comment.
  474. KFileMetaInfo metaInfo(*it);
  475. TQString imageCaption;
  476. if (metaInfo.isValid() && metaInfo.item("Comment").isValid())
  477. imageCaption = metaInfo.item("Comment").string().section('\n', 0, 0);
  478. if (imageCaption.isEmpty())
  479. {
  480. int slash = (*it).findRev('/') + 1;
  481. int endDot = (*it).findRev('.');
  482. // strip the extension if it exists
  483. if (endDot != -1 && endDot > slash)
  484. imageCaption = (*it).mid(slash, endDot - slash);
  485. else
  486. imageCaption = (*it).mid(slash);
  487. imageCaption.replace('_', ' ');
  488. imageCaption = KStringHandler::capwords(imageCaption);
  489. }
  490. // avoid name collisions
  491. TQString rs = imageCaption;
  492. TQString lrs = rs.lower();
  493. for (int n = 1; papers.find(lrs) != papers.end(); ++n)
  494. {
  495. rs = imageCaption + " (" + TQString::number(n) + ')';
  496. lrs = rs.lower();
  497. }
  498. papers[lrs] = qMakePair(rs, *it);
  499. }
  500. }
  501. KComboBox *comboWallpaper = m_urlWallpaperBox;
  502. comboWallpaper->clear();
  503. m_wallpaper.clear();
  504. int i = 0;
  505. for (TQMap<TQString, QPair<TQString, TQString> >::Iterator it = papers.begin();
  506. it != papers.end();
  507. ++it)
  508. {
  509. comboWallpaper->insertItem(it.data().first);
  510. m_wallpaper[it.data().second] = i;
  511. i++;
  512. }
  513. }
  514. void BGDialog::setWallpaper(const TQString &s)
  515. {
  516. KComboBox *comboWallpaper = m_urlWallpaperBox;
  517. comboWallpaper->blockSignals(true);
  518. if (m_wallpaper.find(s) == m_wallpaper.end())
  519. {
  520. int i = comboWallpaper->count();
  521. TQString imageCaption;
  522. int slash = s.findRev('/') + 1;
  523. int endDot = s.findRev('.');
  524. // strip the extension if it exists
  525. if (endDot != -1 && endDot > slash)
  526. imageCaption = s.mid(slash, endDot - slash);
  527. else
  528. imageCaption = s.mid(slash);
  529. if (comboWallpaper->text(i-1) == imageCaption)
  530. {
  531. i--;
  532. comboWallpaper->removeItem(i);
  533. }
  534. comboWallpaper->insertItem(imageCaption);
  535. m_wallpaper[s] = i;
  536. comboWallpaper->setCurrentItem(i);
  537. }
  538. else
  539. {
  540. comboWallpaper->setCurrentItem(m_wallpaper[s]);
  541. }
  542. comboWallpaper->blockSignals(false);
  543. }
  544. void BGDialog::slotWallpaperSelection()
  545. {
  546. KFileDialog dlg( TQString::null, TQString::null, this,
  547. "file dialog", true );
  548. KImageFilePreview* previewWidget = new KImageFilePreview(&dlg);
  549. dlg.setPreviewWidget(previewWidget);
  550. TQStringList mimeTypes = KImageIO::mimeTypes( KImageIO::Reading );
  551. #ifdef HAVE_LIBART
  552. mimeTypes += "image/svg+xml";
  553. #endif
  554. dlg.setFilter( mimeTypes.join( " " ) );
  555. dlg.setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly );
  556. dlg.setCaption( i18n("Select Wallpaper") );
  557. int j = m_urlWallpaperBox->currentItem();
  558. TQString uri;
  559. for(TQMap<TQString,int>::ConstIterator it = m_wallpaper.begin();
  560. it != m_wallpaper.end();
  561. ++it)
  562. {
  563. if (it.data() == j)
  564. {
  565. uri = it.key();
  566. break;
  567. }
  568. }
  569. if ( !uri.isEmpty() ) {
  570. dlg.setSelection( uri );
  571. }
  572. if ( dlg.exec() == TQDialog::Accepted )
  573. {
  574. setWallpaper(dlg.selectedFile());
  575. int optionID = m_buttonGroupBackground->id(m_radioPicture);
  576. m_buttonGroupBackground->setButton( optionID );
  577. slotWallpaperTypeChanged( optionID );
  578. emit changed(true);
  579. }
  580. }
  581. void BGDialog::updateUI()
  582. {
  583. KBackgroundRenderer *r = eRenderer();
  584. m_comboDesktop->setCurrentItem(m_eDesk);
  585. m_comboScreen->setCurrentItem(m_eScreen);
  586. m_colorPrimary->setColor(r->colorA());
  587. m_colorSecondary->setColor(r->colorB());
  588. int wallpaperMode = r->wallpaperMode();
  589. int multiMode = r->multiWallpaperMode();
  590. if (r->backgroundMode() == KBackgroundSettings::Program &&
  591. wallpaperMode == KBackgroundSettings::NoWallpaper)
  592. groupBox3->setEnabled( false );
  593. else
  594. groupBox3->setEnabled( true );
  595. if ((multiMode == KBackgroundSettings::NoMultiRandom) ||
  596. (multiMode == KBackgroundSettings::NoMulti))
  597. {
  598. // No wallpaper
  599. if (wallpaperMode == KBackgroundSettings::NoWallpaper )
  600. {
  601. m_urlWallpaperBox->setEnabled(false);
  602. m_urlWallpaperButton->setEnabled(false);
  603. m_buttonSetupWallpapers->setEnabled(false);
  604. m_comboWallpaperPos->setEnabled(false);
  605. m_lblWallpaperPos->setEnabled(false);
  606. m_buttonGroupBackground->setButton(
  607. m_buttonGroupBackground->id(m_radioNoPicture) );
  608. }
  609. // 1 Picture
  610. else
  611. {
  612. m_urlWallpaperBox->setEnabled(true);
  613. m_urlWallpaperButton->setEnabled(true);
  614. m_buttonSetupWallpapers->setEnabled(false);
  615. m_comboWallpaperPos->setEnabled(true);
  616. m_lblWallpaperPos->setEnabled(true);
  617. setWallpaper(r->wallpaper());
  618. m_buttonGroupBackground->setButton(
  619. m_buttonGroupBackground->id(m_radioPicture) );
  620. }
  621. }
  622. // Slide show
  623. else
  624. {
  625. m_urlWallpaperBox->setEnabled(false);
  626. m_urlWallpaperButton->setEnabled(false);
  627. m_buttonSetupWallpapers->setEnabled(true);
  628. m_comboWallpaperPos->setEnabled(true);
  629. m_lblWallpaperPos->setEnabled(true);
  630. m_buttonGroupBackground->setButton(
  631. m_buttonGroupBackground->id(m_radioSlideShow) );
  632. }
  633. m_comboWallpaperPos->setCurrentItem(r->wallpaperMode()-1);
  634. bool bSecondaryEnabled = true;
  635. m_comboPattern->blockSignals(true);
  636. switch (r->backgroundMode()) {
  637. case KBackgroundSettings::Flat:
  638. m_comboPattern->setCurrentItem(0);
  639. bSecondaryEnabled = false;
  640. break;
  641. case KBackgroundSettings::Pattern:
  642. {
  643. int i = m_patterns.findIndex(r->KBackgroundPattern::name());
  644. if (i >= 0)
  645. m_comboPattern->setCurrentItem(NR_PREDEF_PATTERNS+i);
  646. else
  647. m_comboPattern->setCurrentItem(0);
  648. }
  649. break;
  650. case KBackgroundSettings::Program:
  651. m_comboPattern->setCurrentItem(0);
  652. bSecondaryEnabled = false;
  653. break;
  654. default: // Gradient
  655. m_comboPattern->setCurrentItem(
  656. 1 + r->backgroundMode() - KBackgroundSettings::HorizontalGradient);
  657. break;
  658. }
  659. m_comboPattern->blockSignals(false);
  660. m_colorSecondary->setEnabled(bSecondaryEnabled);
  661. int mode = r->blendMode();
  662. m_comboBlend->blockSignals(true);
  663. m_sliderBlend->blockSignals(true);
  664. m_comboBlend->setCurrentItem(mode);
  665. m_cbBlendReverse->setChecked(r->reverseBlending());
  666. m_sliderBlend->setValue( r->blendBalance() / 10 );
  667. m_cbCrossFadeBg->setChecked(r->crossFadeBg());
  668. m_comboBlend->blockSignals(false);
  669. m_sliderBlend->blockSignals(false);
  670. // turn it off if there is no background picture set!
  671. setBlendingEnabled(wallpaperMode != KBackgroundSettings::NoWallpaper);
  672. // Start preview renderer(s)
  673. if ( m_eScreen == 0 )
  674. {
  675. r->setPreview( m_pMonitorArrangement->combinedPreviewSize() );
  676. r->start(true);
  677. }
  678. else if ( m_eScreen == 1 )
  679. {
  680. r->setPreview( m_pMonitorArrangement->maxPreviewSize() );
  681. r->start(true);
  682. }
  683. else
  684. {
  685. for (unsigned j = 0; j < m_numScreens; ++j)
  686. {
  687. m_renderer[m_eDesk][j+2]->stop();
  688. m_renderer[m_eDesk][j+2]->setPreview( m_pMonitorArrangement->monitor(j)->size() );
  689. m_renderer[m_eDesk][j+2]->start(true);
  690. }
  691. }
  692. }
  693. void BGDialog::slotPreviewDone(int desk_done, int screen_done)
  694. {
  695. int currentDesk = (m_eDesk > 0) ? m_eDesk-1 : 0;
  696. if ( desk_done != currentDesk )
  697. return;
  698. if (!m_previewUpdates)
  699. return;
  700. KBackgroundRenderer * r = m_renderer[m_eDesk][(m_eScreen>1) ? (screen_done+2) : m_eScreen];
  701. if (r->image().isNull())
  702. return;
  703. r->saveCacheFile();
  704. KPixmap pm;
  705. if (TQPixmap::defaultDepth() < 15)
  706. pm.convertFromImage(r->image(), KPixmap::LowColor);
  707. else
  708. pm.convertFromImage(r->image());
  709. if ( m_eScreen == 0 )
  710. {
  711. m_pMonitorArrangement->setPixmap(pm);
  712. }
  713. else if ( m_eScreen == 1 )
  714. {
  715. for (unsigned i = 0; i < m_pMonitorArrangement->numMonitors(); ++i)
  716. m_pMonitorArrangement->monitor(i)->setPixmap(pm);
  717. }
  718. else
  719. {
  720. m_pMonitorArrangement->monitor(screen_done)->setPixmap(pm);
  721. }
  722. }
  723. void BGDialog::slotImageDropped(const TQString &uri)
  724. {
  725. setWallpaper(uri);
  726. int optionID = m_buttonGroupBackground->id(m_radioPicture);
  727. m_buttonGroupBackground->setButton( optionID );
  728. slotWallpaperTypeChanged( optionID );
  729. }
  730. void BGDialog::slotWallpaperTypeChanged(int i)
  731. {
  732. KBackgroundRenderer *r = eRenderer();
  733. r->stop();
  734. // No picture
  735. if (i == m_buttonGroupBackground->id(m_radioNoPicture)) //None
  736. {
  737. m_urlWallpaperBox->setEnabled(false);
  738. m_urlWallpaperButton->setEnabled(false);
  739. m_buttonSetupWallpapers->setEnabled(false);
  740. m_comboWallpaperPos->setEnabled(false);
  741. m_lblWallpaperPos->setEnabled(false);
  742. r->setWallpaperMode(KBackgroundSettings::NoWallpaper);
  743. if (m_slideShowRandom == KBackgroundSettings::InOrder)
  744. r->setMultiWallpaperMode(KBackgroundSettings::NoMulti);
  745. else
  746. r->setMultiWallpaperMode(KBackgroundSettings::NoMultiRandom);
  747. setBlendingEnabled(false);
  748. }
  749. // Slide show
  750. else if (i == m_buttonGroupBackground->id(m_radioSlideShow))
  751. {
  752. m_urlWallpaperBox->setEnabled(false);
  753. m_urlWallpaperButton->setEnabled(false);
  754. m_buttonSetupWallpapers->setEnabled(true);
  755. m_comboWallpaperPos->setEnabled(true);
  756. m_lblWallpaperPos->setEnabled(true);
  757. setBlendingEnabled(true);
  758. m_comboWallpaperPos->blockSignals(true);
  759. m_comboWallpaperPos->setCurrentItem(m_wallpaperPos-1);
  760. m_comboWallpaperPos->blockSignals(false);
  761. if (r->wallpaperList().count() == 0)
  762. r->setWallpaperMode( KBackgroundSettings::NoWallpaper );
  763. else
  764. r->setWallpaperMode(m_wallpaperPos);
  765. r->setMultiWallpaperMode(m_slideShowRandom);
  766. setWallpaper(r->wallpaper());
  767. setBlendingEnabled(true);
  768. }
  769. // 1 Picture
  770. else if (i == m_buttonGroupBackground->id(m_radioPicture))
  771. {
  772. m_urlWallpaperBox->setEnabled(true);
  773. m_urlWallpaperButton->setEnabled(true);
  774. m_buttonSetupWallpapers->setEnabled(false);
  775. m_lblWallpaperPos->setEnabled(true);
  776. m_comboWallpaperPos->setEnabled(true);
  777. setBlendingEnabled(true);
  778. if (m_slideShowRandom == KBackgroundSettings::InOrder)
  779. r->setMultiWallpaperMode(KBackgroundSettings::NoMulti);
  780. else
  781. r->setMultiWallpaperMode(KBackgroundSettings::NoMultiRandom);
  782. int j = m_urlWallpaperBox->currentItem();
  783. TQString path;
  784. for(TQMap<TQString,int>::ConstIterator it = m_wallpaper.begin();
  785. it != m_wallpaper.end();
  786. ++it)
  787. {
  788. if (it.data() == j)
  789. {
  790. path = it.key();
  791. break;
  792. }
  793. }
  794. KFileMetaInfo metaInfo(path);
  795. if (metaInfo.isValid() && metaInfo.item("Dimensions").isValid())
  796. {
  797. // If the image is greater than 800x600 default to using scaled mode,
  798. // otherwise default to tiled.
  799. TQSize s = metaInfo.item("Dimensions").value().toSize();
  800. if (s.width() >= 800 && s.height() >= 600)
  801. m_wallpaperPos = KBackgroundSettings::Scaled;
  802. else
  803. m_wallpaperPos = KBackgroundSettings::Tiled;
  804. }
  805. else if (KMimeType::findByPath(path)->is("image/svg+xml"))
  806. {
  807. m_wallpaperPos = KBackgroundSettings::Scaled;
  808. }
  809. r->setWallpaperMode(m_wallpaperPos);
  810. m_comboWallpaperPos->blockSignals(true);
  811. m_comboWallpaperPos->setCurrentItem(m_wallpaperPos-1);
  812. m_comboWallpaperPos->blockSignals(false);
  813. r->setWallpaper(path);
  814. }
  815. r->start(true);
  816. m_copyAllDesktops = true;
  817. m_copyAllScreens = true;
  818. emit changed(true);
  819. }
  820. void BGDialog::slotWallpaper(int)
  821. {
  822. slotWallpaperTypeChanged(m_buttonGroupBackground->id(m_radioPicture));
  823. emit changed(true);
  824. }
  825. void BGDialog::setBlendingEnabled(bool enable)
  826. {
  827. int mode = eRenderer()->blendMode();
  828. bool b = !(mode == KBackgroundSettings::NoBlending);
  829. m_lblBlending->setEnabled(enable);
  830. m_comboBlend->setEnabled(enable);
  831. m_lblBlendBalance->setEnabled(enable && b);
  832. m_sliderBlend->setEnabled(enable && b);
  833. b = !(mode < KBackgroundSettings::IntensityBlending);
  834. m_cbBlendReverse->setEnabled(enable && b);
  835. }
  836. void BGDialog::slotWallpaperPos(int mode)
  837. {
  838. KBackgroundRenderer *r = eRenderer();
  839. mode++;
  840. m_wallpaperPos = mode;
  841. if (mode == r->wallpaperMode())
  842. return;
  843. r->stop();
  844. r->setWallpaperMode(mode);
  845. r->start(true);
  846. m_copyAllDesktops = true;
  847. m_copyAllScreens = true;
  848. emit changed(true);
  849. }
  850. void BGDialog::slotSetupMulti()
  851. {
  852. KBackgroundRenderer *r = eRenderer();
  853. BGMultiWallpaperDialog dlg(r, topLevelWidget());
  854. if (dlg.exec() == TQDialog::Accepted) {
  855. r->stop();
  856. m_slideShowRandom = r->multiWallpaperMode();
  857. r->setWallpaperMode(m_wallpaperPos);
  858. r->start(true);
  859. m_copyAllDesktops = true;
  860. m_copyAllScreens = true;
  861. emit changed(true);
  862. }
  863. }
  864. void BGDialog::slotPrimaryColor(const TQColor &color)
  865. {
  866. KBackgroundRenderer *r = eRenderer();
  867. if (color == r->colorA())
  868. return;
  869. r->stop();
  870. r->setColorA(color);
  871. r->start(true);
  872. m_copyAllDesktops = true;
  873. m_copyAllScreens = true;
  874. emit changed(true);
  875. }
  876. void BGDialog::slotSecondaryColor(const TQColor &color)
  877. {
  878. KBackgroundRenderer *r = eRenderer();
  879. if (color == r->colorB())
  880. return;
  881. r->stop();
  882. r->setColorB(color);
  883. r->start(true);
  884. m_copyAllDesktops = true;
  885. m_copyAllScreens = true;
  886. emit changed(true);
  887. }
  888. void BGDialog::slotPattern(int pattern)
  889. {
  890. KBackgroundRenderer *r = eRenderer();
  891. r->stop();
  892. bool bSecondaryEnabled = true;
  893. if (pattern < NR_PREDEF_PATTERNS)
  894. {
  895. if (pattern == 0)
  896. {
  897. r->setBackgroundMode(KBackgroundSettings::Flat);
  898. bSecondaryEnabled = false;
  899. }
  900. else
  901. {
  902. r->setBackgroundMode(pattern - 1 + KBackgroundSettings::HorizontalGradient);
  903. }
  904. }
  905. else
  906. {
  907. r->setBackgroundMode(KBackgroundSettings::Pattern);
  908. r->setPatternName(m_patterns[pattern - NR_PREDEF_PATTERNS]);
  909. }
  910. r->start(true);
  911. m_colorSecondary->setEnabled(bSecondaryEnabled);
  912. m_copyAllDesktops = true;
  913. m_copyAllScreens = true;
  914. emit changed(true);
  915. }
  916. void BGDialog::slotSelectScreen(int screen)
  917. {
  918. // Copy the settings from "All screens" to all the other screens
  919. // at a suitable point
  920. if (m_pGlobals->commonScreenBackground() && (screen >1) && m_copyAllScreens)
  921. {
  922. // Copy stuff
  923. for (unsigned desk = 0; desk < m_numDesks+1; ++desk )
  924. {
  925. KBackgroundRenderer *master = m_renderer[desk][1];
  926. for (unsigned screen = 0; screen < m_numScreens; ++screen)
  927. {
  928. m_renderer[desk][screen+2]->copyConfig(master);
  929. }
  930. }
  931. }
  932. if (screen == m_eScreen )
  933. {
  934. return; // Nothing to do
  935. }
  936. m_copyAllScreens = false;
  937. bool drawBackgroundPerScreen = screen > 0;
  938. bool commonScreenBackground = screen < 2;
  939. // Update drawBackgroundPerScreen
  940. if (m_eDesk == 0)
  941. {
  942. for (unsigned desk = 0; desk < m_numDesks; ++desk )
  943. m_pGlobals->setDrawBackgroundPerScreen(desk, drawBackgroundPerScreen);
  944. }
  945. else
  946. {
  947. m_pGlobals->setDrawBackgroundPerScreen(m_eDesk-1, drawBackgroundPerScreen);
  948. }
  949. m_pGlobals->setCommonScreenBackground(commonScreenBackground);
  950. if (screen < 2)
  951. emit changed(true);
  952. else
  953. {
  954. for (unsigned i = 0; i < m_renderer[m_eDesk].size(); ++i)
  955. {
  956. if ( m_renderer[m_eDesk][i]->isActive() )
  957. m_renderer[m_eDesk][i]->stop();
  958. }
  959. }
  960. m_eScreen = screen;
  961. updateUI();
  962. }
  963. void BGDialog::slotSelectDesk(int desk)
  964. {
  965. // Copy the settings from "All desktops" to all the other desktops
  966. // at a suitable point.
  967. if (m_pGlobals->commonDeskBackground() && (desk > 0) && m_copyAllDesktops)
  968. {
  969. // Copy stuff
  970. for (unsigned screen = 0; screen < m_renderer[0].size(); ++screen )
  971. {
  972. KBackgroundRenderer *master = m_renderer[0][screen];
  973. for (unsigned desk = 0; desk < m_numDesks; ++desk )
  974. {
  975. m_renderer[desk+1][screen]->copyConfig(master);
  976. }
  977. }
  978. }
  979. if (desk == m_eDesk)
  980. {
  981. return; // Nothing to do
  982. }
  983. m_copyAllDesktops = false;
  984. if (desk == 0)
  985. {
  986. if (m_pGlobals->commonDeskBackground())
  987. return; // Nothing to do
  988. m_pGlobals->setCommonDeskBackground(true);
  989. emit changed(true);
  990. }
  991. else
  992. {
  993. for (unsigned i = 0; i < m_renderer[m_eDesk].size(); ++i)
  994. {
  995. if ( m_renderer[m_eDesk][i]->isActive() )
  996. m_renderer[m_eDesk][i]->stop();
  997. }
  998. m_pGlobals->setCommonDeskBackground(false);
  999. }
  1000. m_eDesk = desk;
  1001. getEScreen();
  1002. updateUI();
  1003. }
  1004. void BGDialog::slotAdvanced()
  1005. {
  1006. KBackgroundRenderer *r = eRenderer();
  1007. m_previewUpdates = false;
  1008. BGAdvancedDialog dlg(r, topLevelWidget(), m_multidesktop);
  1009. if (!m_pMonitorArrangement->isEnabled()) {
  1010. dlg.makeReadOnly();
  1011. dlg.exec();
  1012. return;
  1013. }
  1014. dlg.setTextColor(m_pGlobals->textColor());
  1015. dlg.setTextBackgroundColor(m_pGlobals->textBackgroundColor());
  1016. dlg.setShadowEnabled(m_pGlobals->shadowEnabled());
  1017. dlg.setTextLines(m_pGlobals->textLines());
  1018. dlg.setTextWidth(m_pGlobals->textWidth());
  1019. if (m_pGlobals->limitCache())
  1020. dlg.setCacheSize( m_pGlobals->cacheSize() );
  1021. else
  1022. dlg.setCacheSize( 0 );
  1023. if( !dlg.exec())
  1024. {
  1025. m_previewUpdates = true;
  1026. return;
  1027. }
  1028. r->setBackgroundMode(dlg.backgroundMode());
  1029. if (dlg.backgroundMode() == KBackgroundSettings::Program)
  1030. {
  1031. r->setProgram(dlg.backgroundProgram());
  1032. }
  1033. int cacheSize = dlg.cacheSize();
  1034. if (cacheSize)
  1035. {
  1036. m_pGlobals->setCacheSize(cacheSize);
  1037. m_pGlobals->setLimitCache(true);
  1038. }
  1039. else
  1040. {
  1041. m_pGlobals->setLimitCache(false);
  1042. }
  1043. m_pGlobals->setTextColor(dlg.textColor());
  1044. m_pGlobals->setTextBackgroundColor(dlg.textBackgroundColor());
  1045. m_pGlobals->setShadowEnabled(dlg.shadowEnabled());
  1046. m_pGlobals->setTextLines(dlg.textLines());
  1047. m_pGlobals->setTextWidth(dlg.textWidth());
  1048. r->stop();
  1049. m_previewUpdates = true;
  1050. r->start(true);
  1051. updateUI();
  1052. m_copyAllDesktops = true;
  1053. emit changed(true);
  1054. }
  1055. void BGDialog::slotGetNewStuff()
  1056. {
  1057. //FIXME set this to a server when we get one
  1058. //should really be in a .rc file but could be either
  1059. //tdecmshellrc or kcontrolrc
  1060. TDEConfig* config = TDEGlobal::config();
  1061. config->setGroup("TDENewStuff");
  1062. config->writeEntry( "ProvidersUrl", "https://www.trinitydesktop.org/ocs/providers.xml" );
  1063. config->writeEntry( "StandardResource", "wallpaper" );
  1064. config->sync();
  1065. KNS::DownloadDialog::open("wallpaper", i18n("Get New Wallpapers"));
  1066. loadWallpaperFilesList();
  1067. }
  1068. void BGDialog::slotBlendMode(int mode)
  1069. {
  1070. if (mode == eRenderer()->blendMode())
  1071. return;
  1072. bool b = !(mode == KBackgroundSettings::NoBlending);
  1073. m_sliderBlend->setEnabled( b );
  1074. m_lblBlendBalance->setEnabled( b );
  1075. b = !(mode < KBackgroundSettings::IntensityBlending);
  1076. m_cbBlendReverse->setEnabled(b);
  1077. emit changed(true);
  1078. eRenderer()->stop();
  1079. eRenderer()->setBlendMode(mode);
  1080. eRenderer()->start(true);
  1081. }
  1082. void BGDialog::slotBlendBalance(int value)
  1083. {
  1084. value = value*10;
  1085. if (value == eRenderer()->blendBalance())
  1086. return;
  1087. emit changed(true);
  1088. eRenderer()->stop();
  1089. eRenderer()->setBlendBalance(value);
  1090. eRenderer()->start(true);
  1091. }
  1092. void BGDialog::slotBlendReverse(bool b)
  1093. {
  1094. if (b == eRenderer()->reverseBlending())
  1095. return;
  1096. emit changed(true);
  1097. eRenderer()->stop();
  1098. eRenderer()->setReverseBlending(b);
  1099. eRenderer()->start(true);
  1100. }
  1101. void BGDialog::slotCrossFadeBg(bool b)
  1102. {
  1103. if (b == eRenderer()->crossFadeBg())
  1104. return;
  1105. emit changed(true);
  1106. eRenderer()->stop();
  1107. eRenderer()->setCrossFadeBg(b);
  1108. eRenderer()->start(true);
  1109. }
  1110. void BGDialog::desktopResized()
  1111. {
  1112. for (unsigned i = 0; i < m_renderer.size(); ++i)
  1113. {
  1114. for (unsigned j = 0; j < m_renderer[i].size(); ++j )
  1115. {
  1116. KBackgroundRenderer * r = m_renderer[i][j];
  1117. if( r->isActive())
  1118. r->stop();
  1119. r->desktopResized();
  1120. }
  1121. }
  1122. eRenderer()->start(true);
  1123. }
  1124. #include "bgdialog.moc"