diff options
Diffstat (limited to 'kcontrol/background/bgdialog.cpp')
-rw-r--r-- | kcontrol/background/bgdialog.cpp | 144 |
1 files changed, 91 insertions, 53 deletions
diff --git a/kcontrol/background/bgdialog.cpp b/kcontrol/background/bgdialog.cpp index 754a2ba9d..c5d56af0f 100644 --- a/kcontrol/background/bgdialog.cpp +++ b/kcontrol/background/bgdialog.cpp @@ -1,5 +1,4 @@ /* - This file is part of the KDE libraries Copyright (c) 2005 David Saxton <david@bluehaze.org> @@ -74,7 +73,7 @@ BGDialog::BGDialog(TQWidget* parent, TDEConfig* _config, bool _multidesktop) m_previewUpdates = true; KWinModule *m_twin; - m_twin = new KWinModule(TQT_TQOBJECT(this)); + m_twin = new KWinModule(this); m_curDesk = m_twin->currentDesktop(); TQSize s(m_twin->numberOfViewports(m_twin->currentDesktop())); m_useViewports = s.width() * s.height() > 1; @@ -123,21 +122,21 @@ BGDialog::BGDialog(TQWidget* parent, TDEConfig* _config, bool _multidesktop) m_eScreen = 0; } - connect(m_buttonIdentifyScreens, TQT_SIGNAL(clicked()), TQT_SLOT(slotIdentifyScreens())); + connect(m_buttonIdentifyScreens, TQ_SIGNAL(clicked()), TQ_SLOT(slotIdentifyScreens())); // preview monitor m_pMonitorArrangement = new BGMonitorArrangement(m_screenArrangement, "monitor arrangement"); - connect(m_pMonitorArrangement, TQT_SIGNAL(imageDropped(const TQString &)), TQT_SLOT(slotImageDropped(const TQString &))); + connect(m_pMonitorArrangement, TQ_SIGNAL(imageDropped(const TQString &)), TQ_SLOT(slotImageDropped(const TQString &))); if( m_multidesktop) { // desktop - connect(m_comboDesktop, TQT_SIGNAL(activated(int)), - TQT_SLOT(slotSelectDesk(int))); + connect(m_comboDesktop, TQ_SIGNAL(activated(int)), + TQ_SLOT(slotSelectDesk(int))); } if (m_numScreens > 1) { - connect(m_comboScreen, TQT_SIGNAL(activated(int)), - TQT_SLOT(slotSelectScreen(int))); + connect(m_comboScreen, TQ_SIGNAL(activated(int)), + TQ_SLOT(slotSelectScreen(int))); } // background image settings @@ -147,42 +146,42 @@ BGDialog::BGDialog(TQWidget* parent, TDEConfig* _config, bool _multidesktop) m_urlWallpaperButton->setFixedSize( pixMap.width()+8, pixMap.height()+8 ); TQToolTip::add(m_urlWallpaperButton, i18n("Open file dialog")); - connect(m_buttonGroupBackground, TQT_SIGNAL(clicked(int)), - TQT_SLOT(slotWallpaperTypeChanged(int))); - connect(m_urlWallpaperBox, TQT_SIGNAL(activated(int)), - TQT_SLOT(slotWallpaper(int))); - connect(m_urlWallpaperButton, TQT_SIGNAL(clicked()), - TQT_SLOT(slotWallpaperSelection())); - connect(m_comboWallpaperPos, TQT_SIGNAL(activated(int)), - TQT_SLOT(slotWallpaperPos(int))); - connect(m_buttonSetupWallpapers, TQT_SIGNAL(clicked()), - TQT_SLOT(slotSetupMulti())); + connect(m_buttonGroupBackground, TQ_SIGNAL(clicked(int)), + TQ_SLOT(slotWallpaperTypeChanged(int))); + connect(m_urlWallpaperBox, TQ_SIGNAL(activated(int)), + TQ_SLOT(slotWallpaper(int))); + connect(m_urlWallpaperButton, TQ_SIGNAL(clicked()), + TQ_SLOT(slotWallpaperSelection())); + connect(m_comboWallpaperPos, TQ_SIGNAL(activated(int)), + TQ_SLOT(slotWallpaperPos(int))); + connect(m_buttonSetupWallpapers, TQ_SIGNAL(clicked()), + TQ_SLOT(slotSetupMulti())); // set up the background colour stuff - connect(m_colorPrimary, TQT_SIGNAL(changed(const TQColor &)), - TQT_SLOT(slotPrimaryColor(const TQColor &))); - connect(m_colorSecondary, TQT_SIGNAL(changed(const TQColor &)), - TQT_SLOT(slotSecondaryColor(const TQColor &))); - connect(m_comboPattern, TQT_SIGNAL(activated(int)), - TQT_SLOT(slotPattern(int))); + connect(m_colorPrimary, TQ_SIGNAL(changed(const TQColor &)), + TQ_SLOT(slotPrimaryColor(const TQColor &))); + connect(m_colorSecondary, TQ_SIGNAL(changed(const TQColor &)), + TQ_SLOT(slotSecondaryColor(const TQColor &))); + connect(m_comboPattern, TQ_SIGNAL(activated(int)), + TQ_SLOT(slotPattern(int))); // blend - connect(m_comboBlend, TQT_SIGNAL(activated(int)), TQT_SLOT(slotBlendMode(int))); - connect(m_sliderBlend, TQT_SIGNAL(valueChanged(int)), - TQT_SLOT(slotBlendBalance(int))); - connect(m_cbBlendReverse, TQT_SIGNAL(toggled(bool)), - TQT_SLOT(slotBlendReverse(bool))); + connect(m_comboBlend, TQ_SIGNAL(activated(int)), TQ_SLOT(slotBlendMode(int))); + connect(m_sliderBlend, TQ_SIGNAL(valueChanged(int)), + TQ_SLOT(slotBlendBalance(int))); + connect(m_cbBlendReverse, TQ_SIGNAL(toggled(bool)), + TQ_SLOT(slotBlendReverse(bool))); // Crossfading background - connect(m_cbCrossFadeBg, TQT_SIGNAL(toggled(bool)), - TQT_SLOT(slotCrossFadeBg(bool))); + connect(m_cbCrossFadeBg, TQ_SIGNAL(toggled(bool)), + TQ_SLOT(slotCrossFadeBg(bool))); // advanced options - connect(m_buttonAdvanced, TQT_SIGNAL(clicked()), - TQT_SLOT(slotAdvanced())); + connect(m_buttonAdvanced, TQ_SIGNAL(clicked()), + TQ_SLOT(slotAdvanced())); - connect(m_buttonGetNew, TQT_SIGNAL(clicked()), - TQT_SLOT(slotGetNewStuff())); + connect(m_buttonGetNew, TQ_SIGNAL(clicked()), + TQ_SLOT(slotGetNewStuff())); // renderers m_renderer.resize(m_numDesks+1); @@ -199,19 +198,19 @@ BGDialog::BGDialog(TQWidget* parent, TDEConfig* _config, bool _multidesktop) // Setup the merged-screen renderer KBackgroundRenderer * r = new KBackgroundRenderer(eDesk, 0, false, _config); m_renderer[i].insert( 0, r ); - connect( r, TQT_SIGNAL(imageDone(int,int)), TQT_SLOT(slotPreviewDone(int,int)) ); + connect( r, TQ_SIGNAL(imageDone(int,int)), TQ_SLOT(slotPreviewDone(int,int)) ); // Setup the common-screen renderer r = new KBackgroundRenderer(eDesk, 0, true, _config); m_renderer[i].insert( 1, r ); - connect( r, TQT_SIGNAL(imageDone(int,int)), TQT_SLOT(slotPreviewDone(int,int)) ); + connect( r, TQ_SIGNAL(imageDone(int,int)), TQ_SLOT(slotPreviewDone(int,int)) ); // Setup the remaining renderers for each screen for (unsigned j=0; j < m_numScreens; ++j ) { r = new KBackgroundRenderer(eDesk, j, true, _config); m_renderer[i].insert( j+2, r ); - connect( r, TQT_SIGNAL(imageDone(int,int)), TQT_SLOT(slotPreviewDone(int,int)) ); + connect( r, TQ_SIGNAL(imageDone(int,int)), TQ_SLOT(slotPreviewDone(int,int)) ); } } } @@ -226,14 +225,14 @@ BGDialog::BGDialog(TQWidget* parent, TDEConfig* _config, bool _multidesktop) // set up the common desktop renderer KBackgroundRenderer * r = new KBackgroundRenderer(0, 0, false, _config); m_renderer[0].insert(0, r); - connect(r, TQT_SIGNAL(imageDone(int,int)), TQT_SLOT(slotPreviewDone(int,int))); + connect(r, TQ_SIGNAL(imageDone(int,int)), TQ_SLOT(slotPreviewDone(int,int))); // set up all the other desktop renderers for (unsigned i = 0; i < m_numDesks; ++i) { r = new KBackgroundRenderer(i, 0, false, _config); m_renderer[i+1].insert(0, r); - connect(r, TQT_SIGNAL(imageDone(int,int)), TQT_SLOT(slotPreviewDone(int,int))); + connect(r, TQ_SIGNAL(imageDone(int,int)), TQ_SLOT(slotPreviewDone(int,int))); } } @@ -245,10 +244,36 @@ BGDialog::BGDialog(TQWidget* parent, TDEConfig* _config, bool _multidesktop) m_slideShowRandom = KBackgroundSettings::InOrder; // Wallpaper Position + m_prevWallpaperPos = KBackgroundSettings::ScaleAndCrop; + m_prevTilePos = KBackgroundSettings::Tiled; + m_wallpaperPos = eRenderer()->wallpaperMode(); if (m_wallpaperPos == KBackgroundSettings::NoWallpaper) m_wallpaperPos = KBackgroundSettings::Centred; // Default + const TQString path = eRenderer()->wallpaper(); + KFileMetaInfo metaInfo(path); + if (metaInfo.isValid() && metaInfo.item("Dimensions").isValid()) + { + // If the image is greater than 800x600 default to using the user selected mode + // for a normal wallpaper, otherwise default to user selection for tiles. + TQSize s = metaInfo.item("Dimensions").value().toSize(); + m_isTile = (s.width() < 800 || s.height() < 600); + if (m_isTile) + { + m_prevTilePos = m_wallpaperPos; + } + else + { + m_prevWallpaperPos = m_wallpaperPos; + } + } + else if (KMimeType::findByPath(path)->is("image/svg+xml")) + { + m_prevWallpaperPos = m_wallpaperPos; + } + + // Restrictions if (TDEGlobal::dirs()->isRestrictedResource("wallpaper")) { m_urlWallpaperButton->hide(); @@ -260,7 +285,7 @@ BGDialog::BGDialog(TQWidget* parent, TDEConfig* _config, bool _multidesktop) updateUI(); #if (TQT_VERSION-0 >= 0x030200) - connect( tqApp->desktop(), TQT_SIGNAL( resized( int )), TQT_SLOT( desktopResized())); // RANDR support + connect( tqApp->desktop(), TQ_SIGNAL( resized( int )), TQ_SLOT( desktopResized())); // RANDR support #endif } @@ -418,11 +443,11 @@ void BGDialog::slotIdentifyScreens() screenLabel->setFrameStyle(TQFrame::Panel); screenLabel->setFrameShadow(TQFrame::Plain); - screenLabel->setAlignment(Qt::AlignCenter); + screenLabel->setAlignment(TQt::AlignCenter); screenLabel->setNum(int(s + 1)); // BUGLET: we should not allow the identification to be entered again // until the timer fires. - TQTimer::singleShot(1500, screenLabel, TQT_SLOT(close())); + TQTimer::singleShot(1500, screenLabel, TQ_SLOT(close())); TQPoint screenCenter(TQApplication::desktop()->screenGeometry(s).center()); TQRect targetGeometry(TQPoint(0,0),screenLabel->sizeHint()); @@ -503,7 +528,7 @@ void BGDialog::loadWallpaperFilesList() { // Wallpapers // the following TQMap is lower cased names mapped to cased names and URLs // this way we get case insensitive sorting - TQMap<TQString, QPair<TQString, TQString> > papers; + TQMap<TQString, TQPair<TQString, TQString> > papers; //search for .desktop files before searching for images without .desktop files TQStringList lst = m_pDirs->findAllResources("wallpaper", "*desktop", false, true); @@ -595,7 +620,7 @@ void BGDialog::loadWallpaperFilesList() { comboWallpaper->clear(); m_wallpaper.clear(); int i = 0; - for (TQMap<TQString, QPair<TQString, TQString> >::Iterator it = papers.begin(); + for (TQMap<TQString, TQPair<TQString, TQString> >::Iterator it = papers.begin(); it != papers.end(); ++it) { @@ -940,18 +965,22 @@ void BGDialog::slotWallpaperTypeChanged(int i) KFileMetaInfo metaInfo(path); if (metaInfo.isValid() && metaInfo.item("Dimensions").isValid()) { - // If the image is greater than 800x600 default to using scaled mode, - // otherwise default to tiled. - + // If the image is greater than 800x600 default to using the user selected mode + // for a normal wallpaper, otherwise default to user selection for tiles. TQSize s = metaInfo.item("Dimensions").value().toSize(); - if (s.width() >= 800 && s.height() >= 600) - m_wallpaperPos = KBackgroundSettings::Scaled; + m_isTile = (s.width() < 800 || s.height() < 600); + if (m_isTile) + { + m_wallpaperPos = m_prevTilePos; + } else - m_wallpaperPos = KBackgroundSettings::Tiled; + { + m_wallpaperPos = m_prevWallpaperPos; + } } else if (KMimeType::findByPath(path)->is("image/svg+xml")) { - m_wallpaperPos = KBackgroundSettings::Scaled; + m_wallpaperPos = m_prevWallpaperPos; } r->setWallpaperMode(m_wallpaperPos); @@ -998,6 +1027,15 @@ void BGDialog::slotWallpaperPos(int mode) if (mode == r->wallpaperMode()) return; + if (m_isTile) + { + m_prevTilePos = mode; + } + else + { + m_prevWallpaperPos = mode; + } + r->stop(); r->setWallpaperMode(mode); r->start(true); @@ -1256,7 +1294,7 @@ void BGDialog::slotGetNewStuff() config->writeEntry( "StandardResource", "wallpaper" ); config->sync(); - KNS::DownloadDialog::open("wallpaper", i18n("Get New Wallpapers")); + KNS::DownloadDialog::open("Wallpapers", i18n("Get New Wallpapers")); loadWallpaperFilesList(); } |