diff options
Diffstat (limited to 'kcontrol')
| -rw-r--r-- | kcontrol/background/bgmonitor.cpp | 84 | ||||
| -rw-r--r-- | kcontrol/background/bgmonitor.h | 22 | ||||
| -rw-r--r-- | kcontrol/background/bgrender.cpp | 7 |
3 files changed, 72 insertions, 41 deletions
diff --git a/kcontrol/background/bgmonitor.cpp b/kcontrol/background/bgmonitor.cpp index ac826a1ff..75fd56546 100644 --- a/kcontrol/background/bgmonitor.cpp +++ b/kcontrol/background/bgmonitor.cpp @@ -5,16 +5,16 @@ Copyright (C) 2002 Laurent Montel <montell@club-internet.fr> Copyright (C) 2003 Waldo Bastian <bastian@kde.org> Copyright (C) 2005 David Saxton <david@bluehaze.org> - + This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License + modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. - + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. - + You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, @@ -30,6 +30,8 @@ #include <tqpixmap.h> #include <tqwhatsthis.h> +#include <memory> + #include "bgmonitor.h" // Constants used (should they be placed somewhere?) @@ -40,16 +42,10 @@ BGMonitorArrangement::BGMonitorArrangement(TQWidget *parent, const char *name) : TQWidget(parent, name) { - m_pBGMonitor.resize( TQApplication::desktop()->numScreens(), 0l ); - - for (int screen = 0; screen < TQApplication::desktop()->numScreens(); ++screen) - { - BGMonitorLabel * label = new BGMonitorLabel(this); - m_pBGMonitor[screen] = label; - - connect( label->monitor(), TQ_SIGNAL(imageDropped(const TQString &)), this, TQ_SIGNAL(imageDropped(const TQString &)) ); - } - + connect(TQApplication::desktop(), TQ_SIGNAL(screenCountChanged(int)), + this , TQ_SLOT(updateArrangement())); + connect(TQApplication::desktop(), TQ_SIGNAL(resized(int)), + this , TQ_SLOT(updateArrangement())); parent->setFixedSize(200, 186); setFixedSize(200, 186); updateArrangement(); @@ -92,40 +88,66 @@ void BGMonitorArrangement::updateArrangement() // value. The expanded value is used for setting the size of the monitor // image that contains the preview of the background. The monitor image // will set the background preview back to the normal value. - + + bool isVDesktop = TQApplication::desktop()->isVirtualDesktop(); TQRect overallGeometry; - for (int screen = 0; screen < TQApplication::desktop()->numScreens(); ++screen) - overallGeometry |= TQApplication::desktop()->screenGeometry(screen); - + size_t screen_num = isVDesktop ? TQApplication::desktop()->numScreens() : 1; + + // create/destroy monitors + if (m_pBGMonitor.size() != screen_num) { + size_t old_size = m_pBGMonitor.size(); + if(old_size<screen_num) { + for (size_t screen = old_size; screen < screen_num; ++screen) + { + m_pBGMonitor.emplace_back(std::make_unique<BGMonitorLabel>(this)); + connect( m_pBGMonitor[screen]->monitor(), TQ_SIGNAL(imageDropped(const TQString &)), this, TQ_SIGNAL(imageDropped(const TQString &)) ); + } + } else { + m_pBGMonitor.resize(screen_num); + } + } + overallGeometry = TQApplication::desktop()->screenGeometry(); + if (isVDesktop) { + for (size_t screen = 0; screen < screen_num; ++screen) + overallGeometry |= TQApplication::desktop()->screenGeometry(screen); + } else { + overallGeometry = TQApplication::desktop()->screenGeometry(); + } + TQRect expandedOverallGeometry = expandToPreview(overallGeometry); - + double scale = TQMIN( double(width()) / double(expandedOverallGeometry.width()), double(height()) / double(expandedOverallGeometry.height()) ); - + m_combinedPreviewSize = overallGeometry.size() * scale; - + m_maxPreviewSize = TQSize(0,0); int previousMax = 0; - - for (int screen = 0; screen < TQApplication::desktop()->numScreens(); ++screen) - { + + auto screenSetupWorker = [&](size_t screen){ TQPoint topLeft = (TQApplication::desktop()->screenGeometry(screen).topLeft() - overallGeometry.topLeft()) * scale; - TQPoint expandedTopLeft = expandToPreview(topLeft); - TQSize previewSize = TQApplication::desktop()->screenGeometry(screen).size() * scale; + + TQPoint expandedTopLeft = expandToPreview(topLeft); TQSize expandedPreviewSize = expandToPreview(previewSize); - + if ( (previewSize.width() * previewSize.height()) > previousMax ) { previousMax = previewSize.width() * previewSize.height(); m_maxPreviewSize = previewSize; } - + m_pBGMonitor[screen]->setPreviewPosition( TQRect( topLeft, previewSize ) ); m_pBGMonitor[screen]->setGeometry( TQRect( expandedTopLeft, expandedPreviewSize ) ); m_pBGMonitor[screen]->updateMonitorGeometry(); + }; + if(isVDesktop) { + for (size_t screen = 0; screen < screen_num; ++screen) + screenSetupWorker(screen); + } else { + screenSetupWorker(TQApplication::desktop()->primaryScreen()); } } @@ -142,7 +164,7 @@ void BGMonitorArrangement::setPixmap( const KPixmap & pm ) for (unsigned screen = 0; screen < m_pBGMonitor.size(); ++screen) { TQRect position = m_pBGMonitor[screen]->previewPosition(); - + TQPixmap monitorPixmap( position.size(), pm.depth() ); copyBlt( &monitorPixmap, 0, 0, &pm, position.x(), position.y(), position.width(), position.height() ); m_pBGMonitor[screen]->monitor()->setPixmap(monitorPixmap); @@ -160,7 +182,7 @@ BGMonitorLabel::BGMonitorLabel(TQWidget *parent, const char *name) setScaledContents(true); setPixmap( TQPixmap( locate("data", "kcontrol/pics/monitor.png") ) ); m_pBGMonitor = new BGMonitor(this); - + TQWhatsThis::add( this, i18n("This picture of a monitor contains a preview of what the current settings will look like on your desktop.") ); } @@ -169,7 +191,7 @@ void BGMonitorLabel::updateMonitorGeometry() { double scaleX = double(width()) / double(sizeHint().width()); double scaleY = double(height()) / double(sizeHint().height()); - + kdDebug() << k_funcinfo << " Setting geometry to " << TQRect( int(23*scaleX), int(14*scaleY), int(151*scaleX), int(115*scaleY) ) << endl; m_pBGMonitor->setGeometry( int(23*scaleX), int(14*scaleY), int(151*scaleX), int(115*scaleY) ); } diff --git a/kcontrol/background/bgmonitor.h b/kcontrol/background/bgmonitor.h index 95608261b..848263e2c 100644 --- a/kcontrol/background/bgmonitor.h +++ b/kcontrol/background/bgmonitor.h @@ -25,9 +25,11 @@ #define _BGMONITOR_H_ #include <tqlabel.h> -#include <tqvaluevector.h> #include <tqwidget.h> +#include <vector> +#include <memory> + class BGMonitor; class BGMonitorLabel; class KPixmap; @@ -41,7 +43,7 @@ class BGMonitorArrangement : public TQWidget TQ_OBJECT public: BGMonitorArrangement(TQWidget *parent, const char *name=0L); - + /** * Splits up the pixmap according to monitor geometries and sets each * BGMonitor pixmap accordingly. @@ -50,20 +52,22 @@ public: TQSize combinedPreviewSize() const { return m_combinedPreviewSize; } TQSize maxPreviewSize() const { return m_maxPreviewSize; } unsigned numMonitors() const { return m_pBGMonitor.size(); } - + BGMonitor * monitor( unsigned screen ) const; + +public slots: void updateArrangement(); signals: void imageDropped(const TQString &); - + protected: virtual void resizeEvent( TQResizeEvent * ); TQRect expandToPreview( TQRect r ) const; TQSize expandToPreview( TQSize s ) const; TQPoint expandToPreview( TQPoint p ) const; - - TQValueVector<BGMonitorLabel*> m_pBGMonitor; + + std::vector<std::unique_ptr<BGMonitorLabel>> m_pBGMonitor; TQSize m_combinedPreviewSize; TQSize m_maxPreviewSize; }; @@ -75,13 +79,13 @@ class BGMonitorLabel : public TQLabel { public: BGMonitorLabel(TQWidget *parent, const char *name=0L); - + BGMonitor * monitor() const { return m_pBGMonitor; } void updateMonitorGeometry(); - + void setPreviewPosition( TQRect r ) { m_previewPosition = r; } TQRect previewPosition() const { return m_previewPosition; } - + protected: virtual void resizeEvent( TQResizeEvent * ); BGMonitor * m_pBGMonitor; diff --git a/kcontrol/background/bgrender.cpp b/kcontrol/background/bgrender.cpp index 522065711..650dc63a2 100644 --- a/kcontrol/background/bgrender.cpp +++ b/kcontrol/background/bgrender.cpp @@ -1206,7 +1206,12 @@ void KVirtualBGRenderer::initRenderers() m_bCommonScreen = m_pConfig->readBoolEntry("CommonScreen", _defCommonScreen); - m_numRenderers = m_bDrawBackgroundPerScreen ? TDEApplication::desktop()->numScreens() : 1; + if (m_bDrawBackgroundPerScreen && TDEApplication::desktop()->isVirtualDesktop()) { + m_numRenderers = TDEApplication::desktop()->numScreens(); + } else { + m_numRenderers = 1; + } + if (m_numRenderers < 2) { // Only one screen is currently available; deactivate per-screen rendering but do not overwrite multi-screen settings m_bDrawBackgroundPerScreen = false; |
