From 4aed2c8219774f5d797760606b8489a92ddc5163 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kcontrol/background/main.cpp | 123 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 kcontrol/background/main.cpp (limited to 'kcontrol/background/main.cpp') diff --git a/kcontrol/background/main.cpp b/kcontrol/background/main.cpp new file mode 100644 index 000000000..433065c85 --- /dev/null +++ b/kcontrol/background/main.cpp @@ -0,0 +1,123 @@ +/* vi: ts=8 sts=4 sw=4 + * This file is part of the KDE project, module kcmbackground. + * Copyright (C) 1999 Geert Jansen + * Copyright (C) 2003 Waldo Bastian + * + * Based on old backgnd.cpp: + * + * Copyright (c) Martin R. Jones 1996 + * Converted to a kcc module by Matthias Hoelzer 1997 + * Gradient backgrounds by Mark Donohoe 1997 + * Pattern backgrounds by Stephan Kulow 1998 + * Randomizing & dnd & new display modes by Matej Koss 1998 + * + * You can Freely distribute this program under the GNU General Public + * License. See the file "COPYING" for the exact licensing terms. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bgdialog.h" + +#include "main.h" + +/* as late as possible, as it includes some X headers without protecting them */ +#include + +/**** DLL Interface ****/ +typedef KGenericFactory KBackGndFactory; +K_EXPORT_COMPONENT_FACTORY( kcm_background, KBackGndFactory("kcmbackground")) + +/**** KBackground ****/ +KBackground::~KBackground( ) +{ + delete m_pConfig; +} + +KBackground::KBackground(QWidget *parent, const char *name, const QStringList &/* */) + : KCModule(KBackGndFactory::instance(), parent, name) +{ + int screen_number = 0; + if (qt_xdisplay()) + screen_number = DefaultScreen(qt_xdisplay()); + QCString configname; + if (screen_number == 0) + configname = "kdesktoprc"; + else + configname.sprintf("kdesktop-screen-%drc", screen_number); + m_pConfig = new KConfig(configname, false, false); + + QVBoxLayout *layout = new QVBoxLayout(this); + m_base = new BGDialog(this, m_pConfig); + setQuickHelp( m_base->quickHelp()); + layout->add(m_base); + layout->addStretch(); + + KImageIO::registerFormats(); + + // reparenting that is done. + setAcceptDrops(true); + + connect(m_base, SIGNAL(changed(bool)), SIGNAL(changed(bool))); + + KAboutData *about = + new KAboutData(I18N_NOOP("kcmbackground"), I18N_NOOP("KDE Background Control Module"), + 0, 0, KAboutData::License_GPL, + I18N_NOOP("(c) 1997-2002 Martin R. Jones")); + + about->addAuthor("Waldo Bastian", 0, "bastian@kde.org"); + about->addAuthor("George Staikos", 0, "staikos@kde.org"); + about->addAuthor("Martin R. Jones", 0, "jones@kde.org"); + about->addAuthor("Matthias Hoelzer-Kluepfel", 0, "mhk@kde.org"); + about->addAuthor("Stephan Kulow", 0, "coolo@kde.org"); + about->addAuthor("Mark Donohoe", 0, 0); + about->addAuthor("Matej Koss", 0 , 0); + + setAboutData( about ); +} + +void KBackground::load() +{ + load( false ); +} + +void KBackground::load( bool useDefaults ) +{ + m_base->load( useDefaults ); +} + + +void KBackground::save() +{ + m_base->save(); + + // reconfigure kdesktop. kdesktop will notify all clients + DCOPClient *client = kapp->dcopClient(); + if (!client->isAttached()) + client->attach(); + + int screen_number = 0; + if (qt_xdisplay()) + screen_number = DefaultScreen(qt_xdisplay()); + QCString appname; + if (screen_number == 0) + appname = "kdesktop"; + else + appname.sprintf("kdesktop-screen-%d", screen_number); + + client->send(appname, "KBackgroundIface", "configure()", ""); +} + +void KBackground::defaults() +{ + m_base->defaults(); +} + +#include "main.moc" -- cgit v1.2.3