some pieces that compile at the moment
svn path=/trunk/KDE/kdebase/workspace/plasma/lib/; revision=492417
This commit is contained in:
parent
9efce2f8f2
commit
b645137010
@ -2,7 +2,7 @@ INCLUDES = $(all_includes)
|
||||
KDE_CXXFLAGS = -UQT3_SUPPORT
|
||||
lib_LTLIBRARIES = libplasma.la
|
||||
|
||||
libplasma_la_SOURCES = appletinfo.cpp
|
||||
libplasma_la_SOURCES = appletinfo.cpp plasma.cpp applet.cpp appletChain.cpp
|
||||
|
||||
libplasma_la_METASOURCES = AUTO
|
||||
|
||||
@ -13,7 +13,7 @@ libplasma_la_includedir = $(includedir)/plasma
|
||||
|
||||
noinst_HEADERS =
|
||||
|
||||
libplasma_la_include_HEADERS = appletinfo.h
|
||||
libplasma_la_include_HEADERS = appletinfo.h applet.h plasma.h
|
||||
|
||||
#kde_kcfg_DATA = plasmaSettings.kcfg extensionSettings.kcfg
|
||||
|
||||
|
173
applet.cpp
Normal file
173
applet.cpp
Normal file
@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (C) 2005 by Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <QEvent>
|
||||
#include <QList>
|
||||
#include <QSize>
|
||||
#include <QTimer>
|
||||
|
||||
#include <kstandarddirs.h>
|
||||
|
||||
#include "applet.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class Applet::Private
|
||||
{
|
||||
public:
|
||||
Private(KService::Ptr appletDescription, int uniqueID,
|
||||
const AppletChain::Ptr appletChain)
|
||||
: id(uniqueID),
|
||||
globalConfig(0),
|
||||
appletConfig(0),
|
||||
appletDescription(appletDescription),
|
||||
chain(appletChain)
|
||||
{ }
|
||||
|
||||
// ~Private()
|
||||
// {
|
||||
// }
|
||||
|
||||
int id;
|
||||
KSharedConfig::Ptr globalConfig;
|
||||
KSharedConfig::Ptr appletConfig;
|
||||
KService::Ptr appletDescription;
|
||||
QList<QObject*> watchedForFocus;
|
||||
AppletChain::Ptr chain;
|
||||
};
|
||||
|
||||
Applet::Applet(QWidget* parent,
|
||||
KService::Ptr appletDescription,
|
||||
const AppletChain::Ptr chain,
|
||||
int id)
|
||||
: QWidget(parent),
|
||||
d(new Private(appletDescription, id, chain))
|
||||
{
|
||||
}
|
||||
|
||||
Applet::~Applet()
|
||||
{
|
||||
needsFocus(false);
|
||||
delete d;
|
||||
}
|
||||
|
||||
KSharedConfig::Ptr Applet::globalAppletConfig() const
|
||||
{
|
||||
if (!d->globalConfig)
|
||||
{
|
||||
QString file = locateLocal("config",
|
||||
"plasma_" + globalName() + "rc",
|
||||
true);
|
||||
d->globalConfig = KSharedConfig::openConfig(file, false, true);
|
||||
}
|
||||
|
||||
return d->globalConfig;
|
||||
}
|
||||
|
||||
KSharedConfig::Ptr Applet::appletConfig() const
|
||||
{
|
||||
if (!d->appletConfig)
|
||||
{
|
||||
QString file = locateLocal("appdata",
|
||||
"applets/" + instanceName() + "rc",
|
||||
true);
|
||||
d->appletConfig = KSharedConfig::openConfig(file, false, true);
|
||||
}
|
||||
|
||||
return d->appletConfig;
|
||||
}
|
||||
|
||||
const AppletChain::Ptr Applet::chain() const
|
||||
{
|
||||
return d->chain;
|
||||
}
|
||||
|
||||
void Applet::setChain(const AppletChain::Ptr appletChain)
|
||||
{
|
||||
d->chain = appletChain;
|
||||
}
|
||||
|
||||
void Applet::constraintsUpdated()
|
||||
{
|
||||
}
|
||||
|
||||
QString Applet::globalName() const
|
||||
{
|
||||
return d->appletDescription->library();
|
||||
}
|
||||
|
||||
QString Applet::instanceName() const
|
||||
{
|
||||
return d->appletDescription->library() + QString::number(d->id);
|
||||
}
|
||||
|
||||
void Applet::watchForFocus(QWidget* widget, bool watch)
|
||||
{
|
||||
if (!widget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int index = d->watchedForFocus.indexOf(widget);
|
||||
if (watch)
|
||||
{
|
||||
if (index == -1)
|
||||
{
|
||||
d->watchedForFocus.append(widget);
|
||||
widget->installEventFilter(this);
|
||||
}
|
||||
}
|
||||
else if (index != -1)
|
||||
{
|
||||
d->watchedForFocus.removeAt(index);
|
||||
widget->removeEventFilter(this);
|
||||
}
|
||||
}
|
||||
|
||||
void Applet::needsFocus(bool focus)
|
||||
{
|
||||
if (focus == hasFocus())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
emit requestFocus(focus);
|
||||
}
|
||||
|
||||
bool Applet::eventFilter(QObject *o, QEvent * e)
|
||||
{
|
||||
if (!d->watchedForFocus.contains(o))
|
||||
{
|
||||
if (e->type() == QEvent::MouseButtonRelease ||
|
||||
e->type() == QEvent::FocusIn)
|
||||
{
|
||||
needsFocus(true);
|
||||
}
|
||||
else if (e->type() == QEvent::FocusOut)
|
||||
{
|
||||
needsFocus(false);
|
||||
}
|
||||
}
|
||||
|
||||
return QWidget::eventFilter(o, e);
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#include "applet.moc"
|
105
applet.h
Normal file
105
applet.h
Normal file
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (C) 2005 by Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef PLASMA_APPLET_H
|
||||
#define PLASMA_APPLET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <kconfig.h>
|
||||
#include <kservice.h>
|
||||
|
||||
#include "plasma.h"
|
||||
#include "appletChain.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class KDE_EXPORT Applet : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
typedef QList<Applet*> List;
|
||||
|
||||
Applet(QWidget* parent,
|
||||
KService::Ptr appletDescription,
|
||||
const AppletChain::Ptr chain,
|
||||
int id);
|
||||
~Applet();
|
||||
|
||||
/**
|
||||
* Returns the KConfig object to access the applets configuration.
|
||||
*
|
||||
* For unique applets this config object will write to a config file
|
||||
* named \<appletname\>rc in the user's local %KDE directory.
|
||||
*
|
||||
* For normal applets this config object will write to an instance
|
||||
* specific config file nameed \<appletname\>\<instanceid\>rc
|
||||
* in the user's local %KDE directory.
|
||||
**/
|
||||
KSharedConfig::Ptr globalAppletConfig() const;
|
||||
KSharedConfig::Ptr appletConfig() const;
|
||||
|
||||
const AppletChain::Ptr chain() const;
|
||||
void setChain(const AppletChain::Ptr);
|
||||
|
||||
/*
|
||||
* called when any of the geometry constraints have been updated
|
||||
* this is always called prior to painting and should be used as an
|
||||
* opportunity to layout the widget, calculate sizings, etc.
|
||||
* @property constraint
|
||||
*/
|
||||
virtual void constraintsUpdated();
|
||||
|
||||
signals:
|
||||
void requestFocus(bool focus);
|
||||
|
||||
protected:
|
||||
|
||||
QString globalName() const;
|
||||
QString instanceName() const;
|
||||
|
||||
/**
|
||||
* Register widgets that can receive keyboard focus with this this method
|
||||
* This call results in an eventFilter being places on the widget.
|
||||
* @param widget the widget to watch for keyboard focus
|
||||
* @param watch whether to start watching the widget, or to stop doing so
|
||||
*/
|
||||
void watchForFocus(QWidget* widget, bool watch = true);
|
||||
|
||||
/**
|
||||
* Call this whenever focus is needed or not needed. You do not have to
|
||||
* call this method for widgets that have been registered with
|
||||
* watchForFocus
|
||||
* @see watchForFocus
|
||||
* @param focus whether to or not to request focus
|
||||
*/
|
||||
void needsFocus(bool focus);
|
||||
|
||||
|
||||
bool eventFilter(QObject *o, QEvent *e);
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private* d;
|
||||
};
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#endif // multiple inclusion guard
|
94
appletChain.cpp
Normal file
94
appletChain.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (C) 2005 by Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "applet.h"
|
||||
#include "appletChain.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class AppletChain::Private
|
||||
{
|
||||
public:
|
||||
Private()
|
||||
: popupDirection(Up),
|
||||
constraint(Plasma::NoConstraint),
|
||||
screenEdge(BottomEdge)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Direction popupDirection;
|
||||
AppletConstraint constraint;
|
||||
ScreenEdge screenEdge;
|
||||
Applet::List applets;
|
||||
|
||||
// configuration items kept in the display widget:
|
||||
// - start coordinates and length for docked chain
|
||||
// - dimensions for floating chain
|
||||
// - display order of applets
|
||||
};
|
||||
|
||||
AppletChain::AppletChain(QObject* parent)
|
||||
: QObject(parent),
|
||||
d(new Private())
|
||||
{
|
||||
}
|
||||
|
||||
AppletChain::~AppletChain()
|
||||
{
|
||||
}
|
||||
|
||||
Plasma::AppletConstraint AppletChain::constraint()
|
||||
{
|
||||
return d->constraint;
|
||||
}
|
||||
|
||||
void AppletChain::setConstraint(Plasma::AppletConstraint constraint)
|
||||
{
|
||||
if (d->constraint == constraint)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
d->constraint = constraint;
|
||||
|
||||
foreach (Applet* applet, d->applets)
|
||||
{
|
||||
applet->constraintsUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
void AppletChain::setScreenEdge(Plasma::ScreenEdge edge)
|
||||
{
|
||||
d->screenEdge = edge;
|
||||
}
|
||||
|
||||
Plasma::ScreenEdge AppletChain::screenEdge()
|
||||
{
|
||||
return d->screenEdge;
|
||||
}
|
||||
|
||||
Plasma::Direction AppletChain::popupDirection() const
|
||||
{
|
||||
return Plasma::edgeToPopupDirection(d->screenEdge);
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#include "appletChain.moc"
|
55
appletChain.h
Normal file
55
appletChain.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2005 by Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef PLASMA_APPLETCHAIN_H
|
||||
#define PLASMA_APPLETCHAIN_H
|
||||
|
||||
#include <ksharedptr.h>
|
||||
|
||||
#include "plasma.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class KDE_EXPORT AppletChain : public QObject, public KShared
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(AppletConstraint constraint READ constraint WRITE setConstraint)
|
||||
|
||||
public:
|
||||
typedef KSharedPtr<AppletChain> Ptr;
|
||||
|
||||
AppletChain(QObject* parent);
|
||||
~AppletChain();
|
||||
|
||||
Plasma::AppletConstraint constraint();
|
||||
void setConstraint(Plasma::AppletConstraint constraint);
|
||||
Plasma::Direction popupDirection() const;
|
||||
|
||||
void setScreenEdge(Plasma::ScreenEdge edge);
|
||||
Plasma::ScreenEdge screenEdge();
|
||||
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private* d;
|
||||
};
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#endif // multiple inclusion guard
|
@ -19,9 +19,10 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
******************************************************************/
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QFileInfo>
|
||||
#include <QMimeData>
|
||||
#include <QtCore/QBuffer>
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QMimeData>
|
||||
#include <QtCore/QDataStream>
|
||||
|
||||
#include <kdesktopfile.h>
|
||||
#include <kapplication.h>
|
||||
|
53
plasma.cpp
Normal file
53
plasma.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2005 by Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <plasma.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
int plasmaIDs = 0;
|
||||
|
||||
void setMinID(int minID)
|
||||
{
|
||||
plasmaIDs = minID + 1;
|
||||
}
|
||||
|
||||
int uniqueID()
|
||||
{
|
||||
return ++plasmaIDs;
|
||||
}
|
||||
|
||||
Direction edgeToPopupDirection(ScreenEdge edge)
|
||||
{
|
||||
switch (edge)
|
||||
{
|
||||
case Floating:
|
||||
case Desktop:
|
||||
case TopEdge:
|
||||
return Down;
|
||||
case BottomEdge:
|
||||
return Up;
|
||||
case LeftEdge:
|
||||
return Right;
|
||||
case RightEdge:
|
||||
return Left;
|
||||
}
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
46
plasma.h
Normal file
46
plasma.h
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2005 by Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License version 2 as
|
||||
* published by the Free Software Foundation
|
||||
*
|
||||
* This program 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 General Public License for more details
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef PLASMA_DEFS_H
|
||||
#define PLASMA_DEFS_H
|
||||
|
||||
#include <kdemacros.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
enum AppletConstraint { NoConstraint = 0,
|
||||
Width = 1,
|
||||
Height = 2,
|
||||
MaxAppletConstraint = Height };
|
||||
|
||||
enum Direction { Down = 0,
|
||||
Up,
|
||||
Left,
|
||||
Right };
|
||||
|
||||
enum ScreenEdge { Floating = 0, Desktop,
|
||||
TopEdge, BottomEdge, LeftEdge, RightEdge };
|
||||
|
||||
KDE_EXPORT void setMinID(int minID);
|
||||
KDE_EXPORT int uniqueID();
|
||||
KDE_EXPORT Direction edgeToPopupDirection(ScreenEdge edge);
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#endif // multiple inclusion guard
|
Loading…
Reference in New Issue
Block a user