SVN_SILENT let's just get this over with and reformant the classes that are pretty much expected to remain
svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=638722
This commit is contained in:
parent
1cdd84cc85
commit
736e81e422
101
applet.cpp
101
applet.cpp
@ -33,18 +33,17 @@ namespace Plasma
|
|||||||
class Applet::Private
|
class Applet::Private
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private(KService::Ptr appletDescription, int uniqueID)
|
Private( KService::Ptr appletDescription, int uniqueID )
|
||||||
: id(uniqueID),
|
: id( uniqueID ),
|
||||||
globalConfig(0),
|
globalConfig( 0 ),
|
||||||
appletConfig(0),
|
appletConfig( 0 ),
|
||||||
appletDescription(appletDescription)
|
appletDescription(appletDescription)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
~Private()
|
~Private()
|
||||||
{
|
{
|
||||||
foreach (const QString& engine, loadedEngines)
|
foreach ( const QString& engine, loadedEngines ) {
|
||||||
{
|
Interface::self()->unloadDataEngine( engine );
|
||||||
Interface::self()->unloadDataEngine(engine);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,29 +55,28 @@ class Applet::Private
|
|||||||
QStringList loadedEngines;
|
QStringList loadedEngines;
|
||||||
};
|
};
|
||||||
|
|
||||||
Applet::Applet(QGraphicsItem *parent,
|
Applet::Applet( QGraphicsItem *parent,
|
||||||
KService::Ptr appletDescription,
|
KService::Ptr appletDescription,
|
||||||
int id)
|
int id )
|
||||||
: QWidget(0),
|
: QWidget( 0 ),
|
||||||
QGraphicsItemGroup(parent),
|
QGraphicsItemGroup( parent ),
|
||||||
d(new Private(appletDescription, id))
|
d( new Private( appletDescription, id ) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Applet::~Applet()
|
Applet::~Applet()
|
||||||
{
|
{
|
||||||
needsFocus(false);
|
needsFocus( false );
|
||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
KSharedConfig::Ptr Applet::appletConfig() const
|
KSharedConfig::Ptr Applet::appletConfig() const
|
||||||
{
|
{
|
||||||
if (!d->appletConfig)
|
if ( !d->appletConfig ) {
|
||||||
{
|
QString file = KStandardDirs::locateLocal( "appdata",
|
||||||
QString file = KStandardDirs::locateLocal("appdata",
|
|
||||||
"applets/" + instanceName() + "rc",
|
"applets/" + instanceName() + "rc",
|
||||||
true);
|
true );
|
||||||
d->appletConfig = KSharedConfig::openConfig(file);
|
d->appletConfig = KSharedConfig::openConfig( file );
|
||||||
}
|
}
|
||||||
|
|
||||||
return d->appletConfig;
|
return d->appletConfig;
|
||||||
@ -86,25 +84,22 @@ KSharedConfig::Ptr Applet::appletConfig() const
|
|||||||
|
|
||||||
KSharedConfig::Ptr Applet::globalAppletConfig() const
|
KSharedConfig::Ptr Applet::globalAppletConfig() const
|
||||||
{
|
{
|
||||||
if (!d->globalConfig)
|
if ( !d->globalConfig ) {
|
||||||
{
|
QString file = KStandardDirs::locateLocal( "config", "plasma_" + globalName() + "rc" );
|
||||||
QString file = KStandardDirs::locateLocal("config", "plasma_" + globalName() + "rc");
|
d->globalConfig = KSharedConfig::openConfig( file );
|
||||||
d->globalConfig = KSharedConfig::openConfig(file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return d->globalConfig;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Plasma::Interface::self()->loadDataEngine(name))
|
if ( Plasma::Interface::self()->loadDataEngine( name ) ) {
|
||||||
{
|
d->loadedEngines.append( name );
|
||||||
d->loadedEngines.append(name);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,54 +117,50 @@ QString Applet::globalName() const
|
|||||||
|
|
||||||
QString Applet::instanceName() 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)
|
void Applet::watchForFocus(QObject *widget, bool watch)
|
||||||
{
|
{
|
||||||
if (!widget)
|
if ( !widget ) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int index = d->watchedForFocus.indexOf(widget);
|
int index = d->watchedForFocus.indexOf(widget);
|
||||||
if (watch)
|
if ( watch ) {
|
||||||
{
|
if ( index == -1 ) {
|
||||||
if (index == -1)
|
d->watchedForFocus.append( widget );
|
||||||
{
|
widget->installEventFilter( this );
|
||||||
d->watchedForFocus.append(widget);
|
|
||||||
widget->installEventFilter(this);
|
|
||||||
}
|
}
|
||||||
}
|
} else if ( index != -1 ) {
|
||||||
else if (index != -1)
|
d->watchedForFocus.removeAt( index );
|
||||||
{
|
widget->removeEventFilter( this );
|
||||||
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
emit requestFocus(focus);
|
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 ||
|
if ( e->type() == QEvent::MouseButtonRelease ||
|
||||||
e->type() == QEvent::FocusIn)
|
e->type() == QEvent::FocusIn ) {
|
||||||
{
|
needsFocus( true );
|
||||||
needsFocus(true);
|
} else if ( e->type() == QEvent::FocusOut ) {
|
||||||
}
|
needsFocus( false );
|
||||||
else if (e->type() == QEvent::FocusOut)
|
|
||||||
{
|
|
||||||
needsFocus(false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QWidget::eventFilter(o, e);
|
return QWidget::eventFilter( o, e );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
16
applet.h
16
applet.h
@ -37,9 +37,9 @@ class KDE_EXPORT Applet : public QWidget, public QGraphicsItemGroup
|
|||||||
public:
|
public:
|
||||||
typedef QList<Applet*> List;
|
typedef QList<Applet*> List;
|
||||||
|
|
||||||
Applet(QGraphicsItem* parent,
|
Applet( QGraphicsItem* parent,
|
||||||
KService::Ptr appletDescription,
|
KService::Ptr appletDescription,
|
||||||
int id);
|
int id );
|
||||||
~Applet();
|
~Applet();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,7 +66,7 @@ class KDE_EXPORT Applet : public QWidget, public QGraphicsItemGroup
|
|||||||
*
|
*
|
||||||
* @return returns true on success, false on failure
|
* @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
|
* 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();
|
virtual void constraintsUpdated();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void requestFocus(bool focus);
|
void requestFocus( bool focus );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ class KDE_EXPORT Applet : public QWidget, public QGraphicsItemGroup
|
|||||||
* @param widget the widget to watch for keyboard focus
|
* @param widget the widget to watch for keyboard focus
|
||||||
* @param watch whether to start watching the widget, or to stop doing so
|
* @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
|
* 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
|
* @see watchForFocus
|
||||||
* @param focus whether to or not to request focus
|
* @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:
|
private:
|
||||||
class Private;
|
class Private;
|
||||||
|
@ -31,8 +31,8 @@ class KDE_EXPORT Interface
|
|||||||
public:
|
public:
|
||||||
static Interface* self();
|
static Interface* self();
|
||||||
|
|
||||||
virtual bool loadDataEngine(const QString &name) = 0;
|
virtual bool loadDataEngine( const QString &name ) = 0;
|
||||||
virtual void unloadDataEngine(const QString &name) = 0;
|
virtual void unloadDataEngine( const QString &name ) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Interface();
|
Interface();
|
||||||
|
15
theme.cpp
15
theme.cpp
@ -29,7 +29,7 @@ class Theme::Private
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Private()
|
Private()
|
||||||
: themeName("default")
|
: themeName( "default" )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,9 +40,9 @@ Theme::Theme(QObject* parent)
|
|||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new Private)
|
d(new Private)
|
||||||
{
|
{
|
||||||
KConfig config("plasma");
|
KConfig config( "plasmarc" );
|
||||||
KConfigGroup group(&config, "Theme");
|
KConfigGroup group( &config, "Theme" );
|
||||||
d->themeName = group.readEntry("name", d->themeName);
|
d->themeName = group.readEntry( "name", d->themeName );
|
||||||
}
|
}
|
||||||
|
|
||||||
Theme::~Theme()
|
Theme::~Theme()
|
||||||
@ -54,10 +54,11 @@ QString Theme::themeName() const
|
|||||||
return d->themeName;
|
return d->themeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Theme::imagePath(const QString& name) const
|
QString Theme::imagePath( const QString& name ) const
|
||||||
{
|
{
|
||||||
return KStandardDirs::locate("data", "desktoptheme/" + d->themeName
|
return KStandardDirs::locate( "data", "desktoptheme/" +
|
||||||
+ "/" + name + ".svg");
|
d->themeName +
|
||||||
|
"/" + name + ".svg" );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
4
theme.h
4
theme.h
@ -31,11 +31,11 @@ class KDE_EXPORT Theme : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Theme(QObject* parent = 0);
|
explicit Theme( QObject* parent = 0 );
|
||||||
~Theme();
|
~Theme();
|
||||||
|
|
||||||
QString themeName() const;
|
QString themeName() const;
|
||||||
QString imagePath(const QString& name) const;
|
QString imagePath( const QString& name ) const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
|
Loading…
Reference in New Issue
Block a user