diff --git a/applet.cpp b/applet.cpp index 47396cdc3..75b842838 100644 --- a/applet.cpp +++ b/applet.cpp @@ -33,18 +33,17 @@ namespace Plasma class Applet::Private { public: - Private(KService::Ptr appletDescription, int uniqueID) - : id(uniqueID), - globalConfig(0), - appletConfig(0), + Private( KService::Ptr appletDescription, int uniqueID ) + : id( uniqueID ), + globalConfig( 0 ), + appletConfig( 0 ), appletDescription(appletDescription) { } ~Private() { - foreach (const QString& engine, loadedEngines) - { - Interface::self()->unloadDataEngine(engine); + foreach ( const QString& engine, loadedEngines ) { + Interface::self()->unloadDataEngine( engine ); } } @@ -56,29 +55,28 @@ class Applet::Private QStringList loadedEngines; }; -Applet::Applet(QGraphicsItem *parent, - KService::Ptr appletDescription, - int id) - : QWidget(0), - QGraphicsItemGroup(parent), - d(new Private(appletDescription, id)) +Applet::Applet( QGraphicsItem *parent, + KService::Ptr appletDescription, + int id ) + : QWidget( 0 ), + QGraphicsItemGroup( parent ), + d( new Private( appletDescription, id ) ) { } Applet::~Applet() { - needsFocus(false); + needsFocus( false ); delete d; } KSharedConfig::Ptr Applet::appletConfig() const { - if (!d->appletConfig) - { - QString file = KStandardDirs::locateLocal("appdata", + if ( !d->appletConfig ) { + QString file = KStandardDirs::locateLocal( "appdata", "applets/" + instanceName() + "rc", - true); - d->appletConfig = KSharedConfig::openConfig(file); + true ); + d->appletConfig = KSharedConfig::openConfig( file ); } return d->appletConfig; @@ -86,25 +84,22 @@ KSharedConfig::Ptr Applet::appletConfig() const KSharedConfig::Ptr Applet::globalAppletConfig() const { - if (!d->globalConfig) - { - QString file = KStandardDirs::locateLocal("config", "plasma_" + globalName() + "rc"); - d->globalConfig = KSharedConfig::openConfig(file); + if ( !d->globalConfig ) { + QString file = KStandardDirs::locateLocal( "config", "plasma_" + globalName() + "rc" ); + d->globalConfig = KSharedConfig::openConfig( file ); } return d->globalConfig; } -bool Applet::loadDataEngine(const QString& name) +bool Applet::loadDataEngine( const QString& name ) { - if (d->loadedEngines.indexOf(name) != -1) - { + if ( d->loadedEngines.indexOf( name ) != -1 ) { return true; } - if (Plasma::Interface::self()->loadDataEngine(name)) - { - d->loadedEngines.append(name); + if ( Plasma::Interface::self()->loadDataEngine( name ) ) { + d->loadedEngines.append( name ); return true; } @@ -122,54 +117,50 @@ QString Applet::globalName() const QString Applet::instanceName() const { - return d->appletDescription->library() + QString::number(d->id); + return d->appletDescription->library() + QString::number( d->id ); } void Applet::watchForFocus(QObject *widget, bool watch) { - if (!widget) + if ( !widget ) { return; + } int index = d->watchedForFocus.indexOf(widget); - if (watch) - { - if (index == -1) - { - d->watchedForFocus.append(widget); - widget->installEventFilter(this); + if ( watch ) { + if ( index == -1 ) { + d->watchedForFocus.append( widget ); + widget->installEventFilter( this ); } - } - else if (index != -1) - { - d->watchedForFocus.removeAt(index); - widget->removeEventFilter(this); + } else if ( index != -1 ) { + d->watchedForFocus.removeAt( index ); + widget->removeEventFilter( this ); } } -void Applet::needsFocus(bool focus) +void Applet::needsFocus( bool focus ) { - if (focus == QWidget::hasFocus() || focus == QGraphicsItem::hasFocus()) + if ( focus == QWidget::hasFocus() || + focus == QGraphicsItem::hasFocus() ) { return; + } emit requestFocus(focus); } -bool Applet::eventFilter(QObject *o, QEvent * e) +bool Applet::eventFilter( QObject *o, QEvent * e ) { - if (!d->watchedForFocus.contains(o)) + if ( !d->watchedForFocus.contains( o ) ) { - if (e->type() == QEvent::MouseButtonRelease || - e->type() == QEvent::FocusIn) - { - needsFocus(true); - } - else if (e->type() == QEvent::FocusOut) - { - needsFocus(false); + if ( e->type() == QEvent::MouseButtonRelease || + e->type() == QEvent::FocusIn ) { + needsFocus( true ); + } else if ( e->type() == QEvent::FocusOut ) { + needsFocus( false ); } } - return QWidget::eventFilter(o, e); + return QWidget::eventFilter( o, e ); } } // Plasma namespace diff --git a/applet.h b/applet.h index d6e67ce91..5afe3e05c 100644 --- a/applet.h +++ b/applet.h @@ -37,9 +37,9 @@ class KDE_EXPORT Applet : public QWidget, public QGraphicsItemGroup public: typedef QList List; - Applet(QGraphicsItem* parent, - KService::Ptr appletDescription, - int id); + Applet( QGraphicsItem* parent, + KService::Ptr appletDescription, + int id ); ~Applet(); /** @@ -66,7 +66,7 @@ class KDE_EXPORT Applet : public QWidget, public QGraphicsItemGroup * * @return returns true on success, false on failure */ - bool loadDataEngine(const QString& name); + bool loadDataEngine( const QString& name ); /** * called when any of the geometry constraints have been updated @@ -77,7 +77,7 @@ class KDE_EXPORT Applet : public QWidget, public QGraphicsItemGroup virtual void constraintsUpdated(); Q_SIGNALS: - void requestFocus(bool focus); + void requestFocus( bool focus ); protected: @@ -90,7 +90,7 @@ class KDE_EXPORT Applet : public QWidget, public QGraphicsItemGroup * @param widget the widget to watch for keyboard focus * @param watch whether to start watching the widget, or to stop doing so */ - void watchForFocus(QObject *widget, bool watch = true); + void watchForFocus( QObject *widget, bool watch = true ); /** * Call this whenever focus is needed or not needed. You do not have to @@ -99,10 +99,10 @@ class KDE_EXPORT Applet : public QWidget, public QGraphicsItemGroup * @see watchForFocus * @param focus whether to or not to request focus */ - void needsFocus(bool focus); + void needsFocus( bool focus ); - bool eventFilter(QObject *o, QEvent *e); + bool eventFilter( QObject *o, QEvent *e ); private: class Private; diff --git a/interface.h b/interface.h index 5740345ad..7795e259d 100644 --- a/interface.h +++ b/interface.h @@ -31,8 +31,8 @@ class KDE_EXPORT Interface public: static Interface* self(); - virtual bool loadDataEngine(const QString &name) = 0; - virtual void unloadDataEngine(const QString &name) = 0; + virtual bool loadDataEngine( const QString &name ) = 0; + virtual void unloadDataEngine( const QString &name ) = 0; protected: Interface(); diff --git a/theme.cpp b/theme.cpp index 21fa216d9..fad4efbcd 100644 --- a/theme.cpp +++ b/theme.cpp @@ -29,7 +29,7 @@ class Theme::Private { public: Private() - : themeName("default") + : themeName( "default" ) { } @@ -40,9 +40,9 @@ Theme::Theme(QObject* parent) : QObject(parent), d(new Private) { - KConfig config("plasma"); - KConfigGroup group(&config, "Theme"); - d->themeName = group.readEntry("name", d->themeName); + KConfig config( "plasmarc" ); + KConfigGroup group( &config, "Theme" ); + d->themeName = group.readEntry( "name", d->themeName ); } Theme::~Theme() @@ -54,10 +54,11 @@ QString Theme::themeName() const return d->themeName; } -QString Theme::imagePath(const QString& name) const +QString Theme::imagePath( const QString& name ) const { - return KStandardDirs::locate("data", "desktoptheme/" + d->themeName - + "/" + name + ".svg"); + return KStandardDirs::locate( "data", "desktoptheme/" + + d->themeName + + "/" + name + ".svg" ); } } diff --git a/theme.h b/theme.h index fbc276738..7a4294acb 100644 --- a/theme.h +++ b/theme.h @@ -31,11 +31,11 @@ class KDE_EXPORT Theme : public QObject Q_OBJECT public: - explicit Theme(QObject* parent = 0); + explicit Theme( QObject* parent = 0 ); ~Theme(); QString themeName() const; - QString imagePath(const QString& name) const; + QString imagePath( const QString& name ) const; signals: void changed();