a bunch more coding style fixes. still some lines longer than 100 chars.

this is definitely helping me find false positives in the Krazy style checker.

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=870161
This commit is contained in:
Allen Winter 2008-10-11 22:48:38 +00:00
parent 254d4c7107
commit a7aebfa60a
27 changed files with 666 additions and 597 deletions

View File

@ -41,7 +41,7 @@ namespace Plasma
class AbstractRunnerPrivate
{
public:
AbstractRunnerPrivate(AbstractRunner* r, KService::Ptr service)
AbstractRunnerPrivate(AbstractRunner *r, KService::Ptr service)
: priority(AbstractRunner::NormalPriority),
speed(AbstractRunner::NormalSpeed),
blackListed(0),
@ -56,7 +56,8 @@ public:
if (!api.isEmpty()) {
const QString path = KStandardDirs::locate("data",
"plasma/runners/" + runnerDescription.pluginName() + '/');
PackageStructure::Ptr structure = Plasma::packageStructure(api, Plasma::RunnerComponent);
PackageStructure::Ptr structure =
Plasma::packageStructure(api, Plasma::RunnerComponent);
structure->setPath(path);
package = new Package(path, structure);
@ -86,9 +87,9 @@ public:
AbstractRunner::Priority priority;
AbstractRunner::Speed speed;
RunnerContext::Types blackListed;
RunnerScript* script;
RunnerScript *script;
KPluginInfo runnerDescription;
AbstractRunner* runner;
AbstractRunner *runner;
QTime runtime;
int fastRuns;
Package *package;
@ -96,13 +97,13 @@ public:
K_GLOBAL_STATIC(QMutex, s_bigLock)
AbstractRunner::AbstractRunner(QObject* parent, const QString& serviceId)
AbstractRunner::AbstractRunner(QObject *parent, const QString &serviceId)
: QObject(parent),
d(new AbstractRunnerPrivate(this, KService::serviceByStorageId(serviceId)))
{
}
AbstractRunner::AbstractRunner(QObject* parent, const QVariantList& args)
AbstractRunner::AbstractRunner(QObject *parent, const QVariantList &args)
: QObject(parent),
d(new AbstractRunnerPrivate(this, KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString())))
{
@ -212,8 +213,8 @@ KService::List AbstractRunner::serviceQuery(const QString &serviceType, const QS
QMutexLocker lock(s_bigLock);
return KServiceTypeTrader::self()->query(serviceType, constraint);
}
QMutex* AbstractRunner::bigLock() const
QMutex *AbstractRunner::bigLock() const
{
return s_bigLock;
}
@ -256,7 +257,7 @@ QString AbstractRunner::description() const
return d->runnerDescription.property("Comment").toString();
}
const Package* AbstractRunner::package() const
const Package *AbstractRunner::package() const
{
return d->package;
}

View File

@ -93,13 +93,13 @@ Animator::CurveShape AnimationDriver::elementAnimationCurve(Plasma::Animator::An
return Animator::EaseInOutCurve;
}
QPixmap AnimationDriver::elementAppear(qreal progress, const QPixmap& pixmap)
QPixmap AnimationDriver::elementAppear(qreal progress, const QPixmap &pixmap)
{
Q_UNUSED(progress)
return pixmap;
}
QPixmap AnimationDriver::elementDisappear(qreal progress, const QPixmap& pixmap)
QPixmap AnimationDriver::elementDisappear(qreal progress, const QPixmap &pixmap)
{
Q_UNUSED(progress)
QPixmap pix(pixmap.size());
@ -108,19 +108,19 @@ QPixmap AnimationDriver::elementDisappear(qreal progress, const QPixmap& pixmap)
return pix;
}
void AnimationDriver::itemAppear(qreal frame, QGraphicsItem* item)
void AnimationDriver::itemAppear(qreal frame, QGraphicsItem *item)
{
Q_UNUSED(frame)
Q_UNUSED(item)
}
void AnimationDriver::itemDisappear(qreal frame, QGraphicsItem* item)
void AnimationDriver::itemDisappear(qreal frame, QGraphicsItem *item)
{
Q_UNUSED(frame)
Q_UNUSED(item)
}
void AnimationDriver::itemActivated(qreal frame, QGraphicsItem* item)
void AnimationDriver::itemActivated(qreal frame, QGraphicsItem *item)
{
Q_UNUSED(frame)
Q_UNUSED(item)

View File

@ -87,8 +87,8 @@ struct CustomAnimationState
int interval;
int currentInterval;
int id;
QObject* receiver;
char* slot;
QObject *receiver;
char *slot;
};
class AnimatorPrivate
@ -131,25 +131,25 @@ class AnimatorPrivate
return progress;
}
void performAnimation(qreal amount, const AnimationState* state)
void performAnimation(qreal amount, const AnimationState *state)
{
switch (state->animation) {
case Animator::AppearAnimation:
driver->itemAppear(amount, state->item);
break;
case Animator::DisappearAnimation:
driver->itemDisappear(amount, state->item);
if (amount >= 1) {
state->item->hide();
}
break;
case Animator::ActivateAnimation:
driver->itemActivated(amount, state->item);
break;
case Animator::AppearAnimation:
driver->itemAppear(amount, state->item);
break;
case Animator::DisappearAnimation:
driver->itemDisappear(amount, state->item);
if (amount >= 1) {
state->item->hide();
}
break;
case Animator::ActivateAnimation:
driver->itemActivated(amount, state->item);
break;
}
}
void performMovement(qreal amount, const MovementState* state)
void performMovement(qreal amount, const MovementState *state)
{
switch (state->movement) {
case Animator::SlideInMovement:
@ -171,7 +171,7 @@ class AnimatorPrivate
void animatedElementDestroyed(QObject*);
void customAnimReceiverDestroyed(QObject*);
AnimationDriver* driver;
AnimationDriver *driver;
int animId;
int timerId;
QTime time;
@ -194,13 +194,12 @@ class AnimatorSingleton
K_GLOBAL_STATIC(AnimatorSingleton, privateSelf)
Animator* Animator::self()
Animator *Animator::self()
{
return &privateSelf->self;
}
Animator::Animator(QObject * parent)
Animator::Animator(QObject *parent)
: QObject(parent),
d(new AnimatorPrivate)
{
@ -212,7 +211,7 @@ Animator::~Animator()
delete d;
}
void AnimatorPrivate::animatedItemDestroyed(QObject* o)
void AnimatorPrivate::animatedItemDestroyed(QObject *o)
{
//kDebug() << "testing for" << (void*)o;
QMutableMapIterator<QGraphicsItem*, AnimationState*> it(animatedItems);
@ -227,7 +226,7 @@ void AnimatorPrivate::animatedItemDestroyed(QObject* o)
}
}
void AnimatorPrivate::movingItemDestroyed(QObject* o)
void AnimatorPrivate::movingItemDestroyed(QObject *o)
{
QMutableMapIterator<QGraphicsItem*, MovementState*> it(movingItems);
while (it.hasNext()) {
@ -239,7 +238,7 @@ void AnimatorPrivate::movingItemDestroyed(QObject* o)
}
}
void AnimatorPrivate::animatedElementDestroyed(QObject* o)
void AnimatorPrivate::animatedElementDestroyed(QObject *o)
{
QMutableMapIterator<int, ElementAnimationState*> it(animatedElements);
while (it.hasNext()) {
@ -251,7 +250,7 @@ void AnimatorPrivate::animatedElementDestroyed(QObject* o)
}
}
void AnimatorPrivate::customAnimReceiverDestroyed(QObject* o)
void AnimatorPrivate::customAnimReceiverDestroyed(QObject *o)
{
QMutableMapIterator<int, CustomAnimationState*> it(customAnims);
while (it.hasNext()) {
@ -263,7 +262,7 @@ void AnimatorPrivate::customAnimReceiverDestroyed(QObject* o)
}
}
int Animator::animateItem(QGraphicsItem* item, Animation animation)
int Animator::animateItem(QGraphicsItem *item, Animation animation)
{
//kDebug();
// get rid of any existing animations on this item.
@ -284,7 +283,7 @@ int Animator::animateItem(QGraphicsItem* item, Animation animation)
int duration = d->driver->animationDuration(animation);
AnimationState* state = new AnimationState;
AnimationState *state = new AnimationState;
state->id = ++d->animId;
state->item = item;
state->animation = animation;
@ -296,11 +295,13 @@ int Animator::animateItem(QGraphicsItem* item, Animation animation)
state->currentInterval = state->interval;
state->qobj = dynamic_cast<QObject*>(item);
if (state->qobj) {
//kDebug() << "!!!!!!!!!!!!!!!!!!!!!!!!! got us an object!";
disconnect(state->qobj, SIGNAL(destroyed(QObject*)), this, SLOT(animatedItemDestroyed(QObject*)));
connect(state->qobj, SIGNAL(destroyed(QObject*)), this, SLOT(animatedItemDestroyed(QObject*)));
}
if (state->qobj) {
//kDebug() << "!!!!!!!!!!!!!!!!!!!!!!!!! got us an object!";
disconnect(state->qobj, SIGNAL(destroyed(QObject*)),
this, SLOT(animatedItemDestroyed(QObject*)));
connect(state->qobj, SIGNAL(destroyed(QObject*)),
this, SLOT(animatedItemDestroyed(QObject*)));
}
d->animatedItems[item] = state;
d->performAnimation(0, state);
@ -313,7 +314,7 @@ int Animator::animateItem(QGraphicsItem* item, Animation animation)
return state->id;
}
int Animator::moveItem(QGraphicsItem* item, Movement movement, const QPoint &destination)
int Animator::moveItem(QGraphicsItem *item, Movement movement, const QPoint &destination)
{
//kDebug();
QMap<QGraphicsItem*, MovementState*>::iterator it = d->movingItems.find(item);
@ -329,7 +330,7 @@ int Animator::moveItem(QGraphicsItem* item, Movement movement, const QPoint &des
return -1;
}
MovementState* state = new MovementState;
MovementState *state = new MovementState;
state->id = ++d->animId;
state->destination = destination;
state->start = item->pos().toPoint();
@ -364,7 +365,7 @@ int Animator::moveItem(QGraphicsItem* item, Movement movement, const QPoint &des
}
int Animator::customAnimation(int frames, int duration, Animator::CurveShape curve,
QObject* receiver, const char* slot)
QObject *receiver, const char *slot)
{
if (frames < 1 || duration < 1 || !receiver || !slot) {
return -1;
@ -457,12 +458,15 @@ int Animator::animateElement(QGraphicsItem *item, Animation animation)
state->id = ++d->animId;
state->qobj = dynamic_cast<QObject*>(item);
if (state->qobj) {
disconnect(state->qobj, SIGNAL(destroyed(QObject*)), this, SLOT(animatedElementDestroyed(QObject*)));
connect(state->qobj, SIGNAL(destroyed(QObject*)), this, SLOT(animatedElementDestroyed(QObject*)));
}
if (state->qobj) {
disconnect(state->qobj, SIGNAL(destroyed(QObject*)),
this, SLOT(animatedElementDestroyed(QObject*)));
connect(state->qobj, SIGNAL(destroyed(QObject*)),
this, SLOT(animatedElementDestroyed(QObject*)));
}
//kDebug() << "animateElement " << animation << ", interval: " << state->interval << ", frames: " << state->frames;
//kDebug() << "animateElement " << animation << ", interval: "
// << state->interval << ", frames: " << state->frames;
bool needTimer = true;
if (state->frames < 1) {
state->frames = 1;
@ -471,7 +475,7 @@ int Animator::animateElement(QGraphicsItem *item, Animation animation)
}
d->animatedElements[state->id] = state;
//kDebug() << "startElementAnimation(AnimId " << animation << ") returning " << state->id;
if (needTimer && !d->timerId) {
// start a 20fps timer;
@ -513,7 +517,7 @@ QPixmap Animator::currentPixmap(int id)
return QPixmap();
}
ElementAnimationState* state = it.value();
ElementAnimationState *state = it.value();
qreal progress = d->calculateProgress(state->currentFrame * state->interval,
state->frames * state->interval,
state->curve);
@ -552,11 +556,12 @@ void Animator::timerEvent(QTimerEvent *event)
d->time.restart();
//kDebug() << "timeEvent, elapsed time: " << elapsed;
foreach (AnimationState* state, d->animatedItems) {
foreach (AnimationState *state, d->animatedItems) {
if (state->currentInterval <= elapsed) {
// we need to step forward!
state->currentFrame += (KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
state->currentFrame +=
(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
if (state->currentFrame < state->frames) {
qreal progress = d->calculateProgress(state->currentFrame * state->interval,
@ -577,11 +582,12 @@ void Animator::timerEvent(QTimerEvent *event)
}
}
foreach (MovementState* state, d->movingItems) {
foreach (MovementState *state, d->movingItems) {
if (state->currentInterval <= elapsed) {
// we need to step forward!
state->currentFrame += (KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
state->currentFrame +=
(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
if (state->currentFrame < state->frames) {
//kDebug() << "movement";
@ -603,9 +609,10 @@ void Animator::timerEvent(QTimerEvent *event)
}
}
foreach (ElementAnimationState* state, d->animatedElements) {
foreach (ElementAnimationState *state, d->animatedElements) {
if (state->currentFrame == state->frames) {
//kDebug() << "skipping" << state->id << "as its already at frame" << state->currentFrame << "of" << state->frames;
//kDebug() << "skipping" << state->id << "as its already at frame"
// << state->currentFrame << "of" << state->frames;
// since we keep element animations around until they are
// removed, we will end up with finished animations in the queue;
// just skip them
@ -615,11 +622,13 @@ void Animator::timerEvent(QTimerEvent *event)
if (state->currentInterval <= elapsed) {
// we need to step forward!
/*kDebug() << "stepping forwards element anim " << state->id << " from " << state->currentFrame
<< " by " << qMax(1, elapsed / state->interval) << " to "
<< state->currentFrame + qMax(1, elapsed / state->interval) << endl;*/
state->currentFrame += (KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
/*kDebug() << "stepping forwards element anim " << state->id
<< " from " << state->currentFrame
<< " by " << qMax(1, elapsed / state->interval) << " to "
<< state->currentFrame + qMax(1, elapsed / state->interval) << endl;*/
state->currentFrame +=
(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
state->item->update();
if (state->currentFrame < state->frames) {
@ -639,10 +648,13 @@ void Animator::timerEvent(QTimerEvent *event)
foreach (CustomAnimationState *state, d->customAnims) {
if (state->currentInterval <= elapsed) {
// advance the frame
state->currentFrame += (KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
/*kDebug() << "custom anim for" << state->receiver << "to slot" << state->slot
<< "with interval of" << state->interval << "at frame" << state->currentFrame;*/
state->currentFrame +=
(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
/*kDebug() << "custom anim for" << state->receiver
<< "to slot" << state->slot
<< "with interval of" << state->interval
<< "at frame" << state->currentFrame;*/
if (state->currentFrame < state->frames) {
//kDebug () << "not the final frame";
@ -696,11 +708,13 @@ void AnimatorPrivate::init(Animator *q)
KPluginLoader plugin(*offers.first());
if (Plasma::isPluginVersionCompatible(plugin.pluginVersion()))
if (Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
driver = offers.first()->createInstance<Plasma::AnimationDriver>(0, QVariantList(), &error);
}
if (!driver) {
kDebug() << "Could not load requested animator " << offers.first() << ". Error given: " << error;
kDebug() << "Could not load requested animator "
<< offers.first() << ". Error given: " << error;
}
}
}

View File

@ -88,7 +88,7 @@ namespace Plasma
{
Applet::Applet(QGraphicsItem *parent,
const QString& serviceID,
const QString &serviceID,
uint appletId)
: QGraphicsWidget(parent),
d(new AppletPrivate(KService::serviceByStorageId(serviceID), appletId, this))
@ -98,15 +98,16 @@ Applet::Applet(QGraphicsItem *parent,
d->init();
}
Applet::Applet(QObject* parentObject, const QVariantList& args)
Applet::Applet(QObject *parentObject, const QVariantList &args)
: QGraphicsWidget(0),
d(new AppletPrivate(KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString()),
args.count() > 1 ? args[1].toInt() : 0, this))
d(new AppletPrivate(
KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString()),
args.count() > 1 ? args[1].toInt() : 0, this))
{
// now remove those first two items since those are managed by Applet and subclasses shouldn't
// need to worry about them. yes, it violates the constness of this var, but it lets us add
// or remove items later while applets can just pretend that their args always start at 0
QVariantList &mutableArgs = const_cast<QVariantList&>(args);
QVariantList &mutableArgs = const_cast<QVariantList &>(args);
if (!mutableArgs.isEmpty()) {
mutableArgs.removeFirst();
@ -185,7 +186,8 @@ void Applet::save(KConfigGroup &g) const
group.writeEntry("plugin", pluginName());
//FIXME: for containments, we need to have some special values here w/regards to
// screen affinity (e.g. "bottom of screen 0")
//kDebug() << pluginName() << "geometry is" << geometry() << "pos is" << pos() << "bounding rect is" << boundingRect();
//kDebug() << pluginName() << "geometry is" << geometry()
// << "pos is" << pos() << "bounding rect is" << boundingRect();
group.writeEntry("geometry", geometry());
group.writeEntry("zvalue", zValue());
@ -210,7 +212,6 @@ void Applet::save(KConfigGroup &g) const
}
}
void Applet::restore(KConfigGroup &group)
{
QList<qreal> m = group.readEntry("transform", QList<qreal>());
@ -266,7 +267,7 @@ void AppletPrivate::setFocus()
q->setFocus(Qt::ShortcutFocusReason);
}
void Applet::setFailedToLaunch(bool failed, const QString& reason)
void Applet::setFailedToLaunch(bool failed, const QString &reason)
{
if (d->failed == failed) {
return;
@ -302,7 +303,7 @@ void Applet::setFailedToLaunch(bool failed, const QString& reason)
Plasma::ToolTipManager::self()->setToolTipContent(failureIcon, data);
setLayout(failureLayout);
resize(300,250);
resize(300, 250);
setMinimumSize(failureLayout->minimumSize());
d->background->resizePanel(geometry().size());
@ -400,7 +401,7 @@ void AppletPrivate::selectItemToDestroy()
q->destroy();
}
void AppletPrivate::updateRect(const QRectF& rect)
void AppletPrivate::updateRect(const QRectF &rect)
{
q->update(rect);
}
@ -412,7 +413,8 @@ void AppletPrivate::cleanUpAndDelete()
//it probably won't matter, but right now if there are applethandles, *they* are the parent.
//not the containment.
//is the applet in a containment and is the containment have a layout? if yes, we remove the applet in the layout
//is the applet in a containment and is the containment have a layout?
//if yes, we remove the applet in the layout
if (parent && parent->layout()) {
QGraphicsLayout *l = parent->layout();
for (int i = 0; i < l->count(); ++i) {
@ -431,19 +433,19 @@ void AppletPrivate::cleanUpAndDelete()
q->deleteLater();
}
ConfigXml* Applet::configScheme() const
ConfigXml *Applet::configScheme() const
{
return d->configXml;
}
DataEngine* Applet::dataEngine(const QString& name) const
DataEngine *Applet::dataEngine(const QString &name) const
{
int index = d->loadedEngines.indexOf(name);
if (index != -1) {
return DataEngineManager::self()->engine(name);
}
DataEngine* engine = DataEngineManager::self()->loadEngine(name);
DataEngine *engine = DataEngineManager::self()->loadEngine(name);
if (engine->isValid()) {
d->loadedEngines.append(name);
}
@ -451,7 +453,7 @@ DataEngine* Applet::dataEngine(const QString& name) const
return engine;
}
const Package* Applet::package() const
const Package *Applet::package() const
{
return d->package;
}
@ -469,7 +471,8 @@ QGraphicsView *Applet::view() const
QGraphicsView *possibleFind = 0;
//kDebug() << "looking through" << scene()->views().count() << "views";
foreach (QGraphicsView *view, scene()->views()) {
//kDebug() << " checking" << view << view->sceneRect() << "against" << sceneBoundingRect() << scenePos();
//kDebug() << " checking" << view << view->sceneRect()
// << "against" << sceneBoundingRect() << scenePos();
if (view->sceneRect().intersects(sceneBoundingRect()) ||
view->sceneRect().contains(scenePos())) {
//kDebug() << " found something!" << view->isActiveWindow();
@ -487,13 +490,13 @@ QGraphicsView *Applet::view() const
QRectF Applet::mapFromView(const QGraphicsView *view, const QRect &rect) const
{
// Why is this adjustment needed? Qt calculation error?
return mapFromScene(view->mapToScene(rect)).boundingRect().adjusted(0, 0, 1, 1);;
return mapFromScene(view->mapToScene(rect)).boundingRect().adjusted(0, 0, 1, 1);
}
QRect Applet::mapToView(const QGraphicsView *view, const QRectF &rect) const
{
// Why is this adjustment needed? Qt calculation error?
return view->mapFromScene(mapToScene(rect)).boundingRect().adjusted(0, 0, -1, -1);;
return view->mapFromScene(mapToScene(rect)).boundingRect().adjusted(0, 0, -1, -1);
}
QPoint Applet::popupPosition(const QSize &s) const
@ -513,7 +516,8 @@ void Applet::constraintsEvent(Plasma::Constraints constraints)
// without calling the Applet:: version as well, which it shouldn't need to.
// INSTEAD put such code into flushPendingConstraintsEvents
Q_UNUSED(constraints)
//kDebug() << constraints << "constraints are FormFactor: " << formFactor() << ", Location: " << location();
//kDebug() << constraints << "constraints are FormFactor: " << formFactor()
// << ", Location: " << location();
if (d->script) {
d->script->constraintsEvent(constraints);
}
@ -589,12 +593,12 @@ QString Applet::category() const
return d->appletDescription.category();
}
QString Applet::category(const KPluginInfo& applet)
QString Applet::category(const KPluginInfo &applet)
{
return applet.property("X-KDE-PluginInfo-Category").toString();
}
QString Applet::category(const QString& appletName)
QString Applet::category(const QString &appletName)
{
if (appletName.isEmpty()) {
return QString();
@ -688,7 +692,8 @@ bool Applet::hasFailedToLaunch() const
return d->failed;
}
void Applet::paintWindowFrame(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget)
void Applet::paintWindowFrame(QPainter *painter,
const QStyleOptionGraphicsItem *option, QWidget *widget)
{
Q_UNUSED(painter)
Q_UNUSED(option)
@ -770,7 +775,7 @@ void Applet::flushPendingConstraintsEvents()
d->constraintsTimerId = 0;
}
//kDebug() << "fushing constraints: " << d->pendingConstraints << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
//kDebug() << "fushing constraints: " << d->pendingConstraints << "!!!!!!!!!!!!!!!!!!!!!!!!!!!";
Plasma::Constraints c = d->pendingConstraints;
d->pendingConstraints = NoConstraint;
@ -780,7 +785,7 @@ void Applet::flushPendingConstraintsEvents()
//FIXME desktop containments can't be removed while in use.
//it's kinda silly to have a keyboard shortcut for something that can only be used when the
//shortcut isn't active.
QAction* closeApplet = new QAction(this);
QAction *closeApplet = new QAction(this);
closeApplet->setIcon(KIcon("edit-delete"));
closeApplet->setEnabled(unlocked);
closeApplet->setVisible(unlocked);
@ -812,7 +817,7 @@ void Applet::flushPendingConstraintsEvents()
}
if (c & Plasma::SizeConstraint && d->needsConfigOverlay) {
d->needsConfigOverlay->setGeometry(QRectF(QPointF(0,0), geometry().size()));
d->needsConfigOverlay->setGeometry(QRectF(QPointF(0, 0), geometry().size()));
QGraphicsItem *button = 0;
QList<QGraphicsItem*> children = d->needsConfigOverlay->QGraphicsItem::children();
@ -840,7 +845,7 @@ void Applet::flushPendingConstraintsEvents()
if (d->failed) {
if (f == Vertical || f == Horizontal) {
setMinimumSize(0,0);
setMinimumSize(0, 0);
QGraphicsLayoutItem *item = layout()->itemAt(1);
layout()->removeAt(1);
delete item;
@ -852,9 +857,9 @@ void Applet::flushPendingConstraintsEvents()
if ((c & Plasma::SizeConstraint || c & Plasma::FormFactorConstraint) &&
aspectRatioMode() == Plasma::Square) {
if (formFactor() == Horizontal) {
setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding));
} else if (formFactor() == Vertical) {
setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
}
updateGeometry();
@ -864,15 +869,14 @@ void Applet::flushPendingConstraintsEvents()
if ((c & Plasma::SizeConstraint || c & Plasma::FormFactorConstraint) &&
aspectRatioMode() == Plasma::ConstrainedSquare) {
if (formFactor() == Horizontal) {
setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding));
} else if (formFactor() == Vertical) {
setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
}
updateGeometry();
}
Containment* containment = qobject_cast<Plasma::Containment*>(this);
if (isContainment() && containment) {
containment->d->containmentConstraintsEvent(c);
@ -901,7 +905,7 @@ QList<QAction*> Applet::contextualActions()
return d->script ? d->script->contextualActions() : QList<QAction*>();
}
QAction* Applet::action(QString name) const
QAction *Applet::action(QString name) const
{
return d->actions.action(name);
}
@ -948,9 +952,9 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
if (!d->failed) {
qreal left, top, right, bottom;
getContentsMargins(&left, &top, &right, &bottom);
QRect contentsRect = QRectF(QPointF(0,0), boundingRect().size())
.adjusted(left, top, -right, -bottom).toRect();
QRect contentsRect =
QRectF(QPointF(0, 0),
boundingRect().size()).adjusted(left, top, -right, -bottom).toRect();
if (widget && isContainment()) {
// note that the widget we get is actually the viewport of the view, not the view itself
@ -1002,11 +1006,11 @@ void Applet::paintInterface(QPainter *painter, const QStyleOptionGraphicsItem *o
FormFactor Applet::formFactor() const
{
Containment* c = containment();
Containment *c = containment();
return c ? c->d->formFactor : Plasma::Planar;
}
Containment* Applet::containment() const
Containment *Applet::containment() const
{
if (isContainment()) {
Containment *c = dynamic_cast<Containment*>(const_cast<Applet*>(this));
@ -1046,9 +1050,10 @@ void Applet::setGlobalShortcut(const KShortcut &shortcut)
}
//kDebug() << "before" << shortcut.primary() << d->activationAction->globalShortcut().primary();
d->activationAction->setGlobalShortcut(shortcut,
KAction::ShortcutTypes(KAction::ActiveShortcut | KAction::DefaultShortcut),
KAction::NoAutoloading);
d->activationAction->setGlobalShortcut(
shortcut,
KAction::ShortcutTypes(KAction::ActiveShortcut | KAction::DefaultShortcut),
KAction::NoAutoloading);
//kDebug() << "after" << shortcut.primary() << d->activationAction->globalShortcut().primary();
}
@ -1077,7 +1082,7 @@ Location Applet::location() const
return c ? c->d->location : Plasma::Desktop;
}
Context* Applet::context() const
Context *Applet::context() const
{
Containment *c = containment();
Q_ASSERT(c);
@ -1121,7 +1126,7 @@ void Applet::unregisterAsDragHandle(QGraphicsItem *item)
}
}
bool Applet::isRegisteredAsDragHandle( QGraphicsItem * item )
bool Applet::isRegisteredAsDragHandle(QGraphicsItem *item)
{
return (d->registeredAsDragHandle.indexOf(item) != -1);
}
@ -1162,27 +1167,28 @@ void Applet::setHasConfigurationInterface(bool hasInterface)
}
}
bool Applet::eventFilter( QObject *o, QEvent * e )
bool Applet::eventFilter(QObject *o, QEvent *e)
{
return QObject::eventFilter(o, e);
}
bool Applet::sceneEventFilter( QGraphicsItem * watched, QEvent * event )
bool Applet::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
{
switch (event->type()) {
case QEvent::GraphicsSceneMouseMove: {
// don't move when the containment is not mutable,
// in the rare case the containment doesn't exists consider it as mutable
if ((!containment() || containment()->immutability() == Mutable) &&
d->registeredAsDragHandle.contains(watched)) {
mouseMoveEvent(static_cast<QGraphicsSceneMouseEvent*>(event));
return true;
}
break;
case QEvent::GraphicsSceneMouseMove:
{
// don't move when the containment is not mutable,
// in the rare case the containment doesn't exists consider it as mutable
if ((!containment() || containment()->immutability() == Mutable) &&
d->registeredAsDragHandle.contains(watched)) {
mouseMoveEvent(static_cast<QGraphicsSceneMouseEvent*>(event));
return true;
}
break;
}
default:
break;
default:
break;
}
return QGraphicsItem::sceneEventFilter(watched, event);
@ -1198,15 +1204,16 @@ void Applet::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
// our direct parent is a containment. just move ourselves.
QPointF curPos = event->pos();
QPointF lastPos = event->lastPos();
QPointF delta = curPos-lastPos;
QPointF delta = curPos - lastPos;
moveBy(delta.x(),delta.y());
moveBy(delta.x(), delta.y());
} else if (parent) {
//don't move the icon as well because our parent (usually an appletHandle) will do it for us
//don't move the icon as well because our parent
//(usually an appletHandle) will do it for us
//parent->moveBy(delta.x(),delta.y());
QPointF curPos = parent->transform().map(event->pos());
QPointF lastPos = parent->transform().map(event->lastPos());
QPointF delta = curPos-lastPos;
QPointF delta = curPos - lastPos;
parent->setPos(parent->pos() + delta);
}
@ -1219,7 +1226,7 @@ void Applet::mousePressEvent(QGraphicsSceneMouseEvent *event)
QGraphicsWidget::mousePressEvent(event);
}
void Applet::focusInEvent(QFocusEvent * event)
void Applet::focusInEvent(QFocusEvent *event)
{
if (!isContainment() && containment()) {
//focusing an applet may trigger this event again, but we won't be here more than twice
@ -1309,7 +1316,7 @@ void Applet::showConfigurationInterface()
//TODO: would be nice to not show dialog if there are no pages added?
connect(dialog, SIGNAL(finished()), nullManager, SLOT(deleteLater()));
//TODO: Apply button does not correctly work for now, so do not show it
dialog->showButton( KDialog::Apply, false );
dialog->showButton(KDialog::Apply, false);
connect(dialog, SIGNAL(applyClicked()), this, SLOT(configChanged()));
connect(dialog, SIGNAL(okClicked()), this, SLOT(configChanged()));
dialog->show();
@ -1333,7 +1340,7 @@ void Applet::createConfigurationInterface(KConfigDialog *parent)
}
KPluginInfo::List Applet::listAppletInfo(const QString &category,
const QString &parentApp)
const QString &parentApp)
{
QString constraint;
@ -1355,7 +1362,8 @@ KPluginInfo::List Applet::listAppletInfo(const QString &category,
}
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
//kDebug() << "Applet::listAppletInfo constraint was '" << constraint << "' which got us " << offers.count() << " matches";
//kDebug() << "Applet::listAppletInfo constraint was '" << constraint
// << "' which got us " << offers.count() << " matches";
return KPluginInfo::fromServices(offers);
}
@ -1400,13 +1408,12 @@ QStringList Applet::listCategories(const QString &parentApp, bool visibleOnly)
return categories;
}
Applet* Applet::load(const QString& appletName, uint appletId, const QVariantList& args)
Applet *Applet::load(const QString &appletName, uint appletId, const QVariantList &args)
{
if (appletName.isEmpty()) {
return 0;
}
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(appletName);
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
@ -1431,7 +1438,8 @@ Applet* Applet::load(const QString& appletName, uint appletId, const QVariantLis
}
if (!offer->property("X-Plasma-API").toString().isEmpty()) {
kDebug() << "we have a script using the" << offer->property("X-Plasma-API").toString() << "API";
kDebug() << "we have a script using the"
<< offer->property("X-Plasma-API").toString() << "API";
if (isContainment) {
return new Containment(0, offer->storageId(), appletId);
}
@ -1440,7 +1448,8 @@ Applet* Applet::load(const QString& appletName, uint appletId, const QVariantLis
KPluginLoader plugin(*offer);
if (!Plasma::isPluginVersionCompatible(plugin.pluginVersion()) && (appletName != "internal:extender")) {
if (!Plasma::isPluginVersionCompatible(plugin.pluginVersion()) &&
(appletName != "internal:extender")) {
return 0;
}
@ -1462,7 +1471,7 @@ Applet* Applet::load(const QString& appletName, uint appletId, const QVariantLis
return applet;
}
Applet* Applet::load(const KPluginInfo& info, uint appletId, const QVariantList& args)
Applet *Applet::load(const KPluginInfo &info, uint appletId, const QVariantList &args)
{
if (!info.isValid()) {
return 0;
@ -1477,17 +1486,19 @@ QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value)
//kDebug() << change;
switch (change) {
case ItemSceneHasChanged: {
case ItemSceneHasChanged:
{
QGraphicsScene *newScene = qvariant_cast<QGraphicsScene*>(value);
if (newScene) {
d->checkImmutability();
}
}
break;
break;
case ItemPositionHasChanged:
emit geometryChanged();
// fall through!
case ItemTransformHasChanged: {
case ItemTransformHasChanged:
{
if (d->modificationsTimerId != -1) {
if (d->modificationsTimerId) {
killTimer(d->modificationsTimerId);
@ -1495,7 +1506,7 @@ QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value)
d->modificationsTimerId = startTimer(1000);
}
}
break;
break;
default:
break;
};
@ -1512,7 +1523,7 @@ QPainterPath Applet::shape() const
return QGraphicsWidget::shape();
}
QSizeF Applet::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const
QSizeF Applet::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
{
QSizeF hint = QGraphicsWidget::sizeHint(which, constraint);
@ -1532,10 +1543,12 @@ QSizeF Applet::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const
}
} else if (d->aspectRatioMode == Plasma::ConstrainedSquare) {
//enforce a size not wider than tall
if (formFactor() == Horizontal && (which == Qt::MaximumSize || size().height() <= KIconLoader::SizeLarge)) {
if (formFactor() == Horizontal &&
(which == Qt::MaximumSize || size().height() <= KIconLoader::SizeLarge)) {
hint.setWidth(size().height());
//enforce a size not taller than wide
} else if (formFactor() == Vertical && (which == Qt::MaximumSize || size().width() <= KIconLoader::SizeLarge)) {
} else if (formFactor() == Vertical &&
(which == Qt::MaximumSize || size().width() <= KIconLoader::SizeLarge)) {
hint.setHeight(size().width());
}
}
@ -1629,7 +1642,6 @@ bool Applet::isContainment() const
return d->isContainment;
}
// PRIVATE CLASS IMPLEMENTATION
AppletPrivate::AppletPrivate(KService::Ptr service, int uniqueID, Applet *applet)
@ -1673,8 +1685,8 @@ AppletPrivate::~AppletPrivate()
activationAction->forgetGlobalShortcut();
}
foreach (const QString& engine, loadedEngines) {
DataEngineManager::self()->unloadEngine( engine );
foreach (const QString &engine, loadedEngines) {
DataEngineManager::self()->unloadEngine(engine);
}
if (extender) {
@ -1804,7 +1816,7 @@ void AppletPrivate::scheduleConstraintsUpdate(Plasma::Constraints c)
pendingConstraints |= c;
}
KConfigGroup* AppletPrivate::mainConfigGroup()
KConfigGroup *AppletPrivate::mainConfigGroup()
{
if (mainConfig) {
return mainConfig;
@ -1839,7 +1851,7 @@ KConfigGroup* AppletPrivate::mainConfigGroup()
return mainConfig;
}
QString AppletPrivate::visibleFailureText(const QString& reason)
QString AppletPrivate::visibleFailureText(const QString &reason)
{
QString text;

View File

@ -78,7 +78,7 @@ public:
KCategorizedItemsView *appletList;
QHash<QString, int> runningApplets; // applet name => count
//extra hash so we can look up the names of deleted applets
QHash<Plasma::Applet*, QString> appletNames;
QHash<Plasma::Applet *,QString> appletNames;
KConfig config;
KConfigGroup configGroup;
@ -112,7 +112,8 @@ void AppletBrowserWidgetPrivate::initFilters()
appletList->addEmblem(i18n("Recommended by %1", caption), KIcon(icon),
KCategorizedItemsViewModels::Filter("recommended." + id, true));
filterModel.addFilter(i18n("Recommended by %1", caption),
KCategorizedItemsViewModels::Filter("recommended." + id, true), KIcon(icon));
KCategorizedItemsViewModels::Filter("recommended." + id, true),
KIcon(icon));
}
// Filters: Special
@ -331,7 +332,8 @@ void AppletBrowserWidget::downloadWidgets()
void AppletBrowserWidget::openWidgetFile()
{
// TODO: if we already have one of these showing and the user clicks to add it again, show the same window?
// TODO: if we already have one of these showing and the user clicks to
// add it again, show the same window?
OpenWidgetAssistant *assistant = new OpenWidgetAssistant(topLevelWidget());
assistant->setAttribute(Qt::WA_DeleteOnClose, true);
assistant->show();

View File

@ -56,144 +56,144 @@ class ConfigXmlPrivate
qDeleteAll(urllists);
}
bool* newBool()
bool *newBool()
{
bool* v = new bool;
bool *v = new bool;
bools.append(v);
return v;
}
QString* newString()
QString *newString()
{
QString* v = new QString;
QString *v = new QString;
strings.append(v);
return v;
}
QStringList* newStringList()
QStringList *newStringList()
{
QStringList* v = new QStringList;
QStringList *v = new QStringList;
stringlists.append(v);
return v;
}
QColor* newColor()
QColor *newColor()
{
QColor* v = new QColor;
QColor *v = new QColor;
colors.append(v);
return v;
}
QFont* newFont()
QFont *newFont()
{
QFont* v = new QFont;
QFont *v = new QFont;
fonts.append(v);
return v;
}
qint32* newInt()
qint32 *newInt()
{
qint32* v = new qint32;
qint32 *v = new qint32;
ints.append(v);
return v;
}
quint32* newUint()
quint32 *newUint()
{
quint32* v = new quint32;
quint32 *v = new quint32;
uints.append(v);
return v;
}
KUrl* newUrl()
KUrl *newUrl()
{
KUrl* v = new KUrl;
KUrl *v = new KUrl;
urls.append(v);
return v;
}
QDateTime* newDateTime()
QDateTime *newDateTime()
{
QDateTime* v = new QDateTime;
QDateTime *v = new QDateTime;
dateTimes.append(v);
return v;
}
double* newDouble()
double *newDouble()
{
double* v = new double;
double *v = new double;
doubles.append(v);
return v;
}
QList<qint32>* newIntList()
{
QList<qint32>* v = new QList<qint32>;
QList<qint32> *v = new QList<qint32>;
intlists.append(v);
return v;
}
qint64* newLongLong()
qint64 *newLongLong()
{
qint64* v = new qint64;
qint64 *v = new qint64;
longlongs.append(v);
return v;
}
QPoint* newPoint()
QPoint *newPoint()
{
QPoint* v = new QPoint;
QPoint *v = new QPoint;
points.append(v);
return v;
}
QRect* newRect()
QRect *newRect()
{
QRect* v = new QRect;
QRect *v = new QRect;
rects.append(v);
return v;
}
QSize* newSize()
QSize *newSize()
{
QSize* v = new QSize;
QSize *v = new QSize;
sizes.append(v);
return v;
}
quint64* newULongLong()
quint64 *newULongLong()
{
quint64* v = new quint64;
quint64 *v = new quint64;
ulonglongs.append(v);
return v;
}
KUrl::List* newUrlList()
KUrl::List *newUrlList()
{
KUrl::List* v = new KUrl::List;
KUrl::List *v = new KUrl::List;
urllists.append(v);
return v;
}
void parse(ConfigXml *configXml, QIODevice *xml);
QList<bool*> bools;
QList<QString*> strings;
QList<QStringList*> stringlists;
QList<QColor*> colors;
QList<QFont*> fonts;
QList<qint32*> ints;
QList<quint32*> uints;
QList<KUrl*> urls;
QList<QDateTime*> dateTimes;
QList<double*> doubles;
QList<QList<qint32>*> intlists;
QList<qint64*> longlongs;
QList<QPoint*> points;
QList<QRect*> rects;
QList<QSize*> sizes;
QList<quint64*> ulonglongs;
QList<KUrl::List*> urllists;
QList<bool *> bools;
QList<QString *> strings;
QList<QStringList *> stringlists;
QList<QColor *> colors;
QList<QFont *> fonts;
QList<qint32 *> ints;
QList<quint32 *> uints;
QList<KUrl *> urls;
QList<QDateTime *> dateTimes;
QList<double *> doubles;
QList<QList<qint32> *> intlists;
QList<qint64 *> longlongs;
QList<QPoint *> points;
QList<QRect *> rects;
QList<QSize *> sizes;
QList<quint64 *> ulonglongs;
QList<KUrl::List *> urllists;
QString baseGroup;
QStringList groups;
QHash<QString, QString> keysToNames;
@ -202,17 +202,19 @@ class ConfigXmlPrivate
class ConfigXmlHandler : public QXmlDefaultHandler
{
public:
ConfigXmlHandler(ConfigXml* config, ConfigXmlPrivate* d);
bool startElement(const QString &namespaceURI, const QString & localName, const QString &qName, const QXmlAttributes &atts);
bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName);
ConfigXmlHandler(ConfigXml *config, ConfigXmlPrivate *d);
bool startElement(const QString &namespaceURI, const QString &localName,
const QString &qName, const QXmlAttributes &atts);
bool endElement(const QString &namespaceURI, const QString &localName,
const QString &qName);
bool characters(const QString &ch);
private:
void addItem();
void resetState();
ConfigXml* m_config;
ConfigXmlPrivate* d;
ConfigXml *m_config;
ConfigXmlPrivate *d;
int m_min;
int m_max;
QString m_name;
@ -238,7 +240,7 @@ void ConfigXmlPrivate::parse(ConfigXml *configXml, QIODevice *xml)
reader.parse(&source, false);
}
ConfigXmlHandler::ConfigXmlHandler(ConfigXml* config, ConfigXmlPrivate* d)
ConfigXmlHandler::ConfigXmlHandler(ConfigXml *config, ConfigXmlPrivate *d)
: QXmlDefaultHandler(),
m_config(config),
d(d)
@ -306,7 +308,8 @@ bool ConfigXmlHandler::characters(const QString &ch)
return true;
}
bool ConfigXmlHandler::endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
bool ConfigXmlHandler::endElement(const QString &namespaceURI,
const QString &localName, const QString &qName)
{
Q_UNUSED(namespaceURI)
Q_UNUSED(qName)
@ -349,7 +352,7 @@ void ConfigXmlHandler::addItem()
return;
}
KConfigSkeletonItem* item = 0;
KConfigSkeletonItem *item = 0;
if (m_type == "bool") {
bool defaultValue = m_default.toLower() == "true";
@ -361,17 +364,17 @@ void ConfigXmlHandler::addItem()
QDateTime::fromString(m_default), m_key);
} else if (m_type == "enum") {
m_key = (m_key.isEmpty()) ? m_name : m_key;
KConfigSkeleton::ItemEnum* enumItem =
new KConfigSkeleton::ItemEnum(m_config->currentGroup(),
m_key, *d->newInt(),
m_enumChoices,
m_default.toUInt());
KConfigSkeleton::ItemEnum *enumItem =
new KConfigSkeleton::ItemEnum(m_config->currentGroup(),
m_key, *d->newInt(),
m_enumChoices,
m_default.toUInt());
m_config->addItem(enumItem, m_name);
item = enumItem;
} else if (m_type == "font") {
item = m_config->addItemFont(m_name, *d->newFont(), QFont(m_default), m_key);
} else if (m_type == "int") {
KConfigSkeleton::ItemInt* intItem = m_config->addItemInt(m_name, *d->newInt(),
KConfigSkeleton::ItemInt *intItem = m_config->addItemInt(m_name, *d->newInt(),
m_default.toInt(), m_key);
if (m_haveMin) {
@ -391,12 +394,11 @@ void ConfigXmlHandler::addItem()
item = m_config->addItemString(m_name, *d->newString(), m_default, m_key);
} else if (m_type == "stringlist") {
//FIXME: the split() is naive and will break on lists with ,'s in them
item = m_config->addItemStringList(m_name, *d->newStringList(), m_default.split(","), m_key);
item = m_config->addItemStringList(m_name, *d->newStringList(),
m_default.split(","), m_key);
} else if (m_type == "uint") {
KConfigSkeleton::ItemUInt* uintItem = m_config->addItemUInt(m_name,
*d->newUint(),
m_default.toUInt(),
m_key);
KConfigSkeleton::ItemUInt *uintItem =
m_config->addItemUInt(m_name, *d->newUint(), m_default.toUInt(), m_key);
if (m_haveMin) {
uintItem->setMinValue(m_min);
}
@ -406,14 +408,14 @@ void ConfigXmlHandler::addItem()
item = uintItem;
} else if (m_type == "url") {
m_key = (m_key.isEmpty()) ? m_name : m_key;
KConfigSkeleton::ItemUrl* urlItem =
new KConfigSkeleton::ItemUrl(m_config->currentGroup(),
m_key, *d->newUrl(),
m_default);
KConfigSkeleton::ItemUrl *urlItem =
new KConfigSkeleton::ItemUrl(m_config->currentGroup(),
m_key, *d->newUrl(),
m_default);
m_config->addItem(urlItem, m_name);
item = urlItem;
} else if (m_type == "double") {
KConfigSkeleton::ItemDouble* doubleItem = m_config->addItemDouble(m_name,
KConfigSkeleton::ItemDouble *doubleItem = m_config->addItemDouble(m_name,
*d->newDouble(), m_default.toDouble(), m_key);
if (m_haveMin) {
doubleItem->setMinValue(m_min);
@ -430,7 +432,7 @@ void ConfigXmlHandler::addItem()
}
item = m_config->addItemIntList(m_name, *d->newIntList(), defaultList, m_key);
} else if (m_type == "longlong") {
KConfigSkeleton::ItemLongLong* longlongItem = m_config->addItemLongLong(m_name,
KConfigSkeleton::ItemLongLong *longlongItem = m_config->addItemLongLong(m_name,
*d->newLongLong(), m_default.toLongLong(), m_key);
if (m_haveMin) {
longlongItem->setMinValue(m_min);
@ -442,7 +444,8 @@ void ConfigXmlHandler::addItem()
/* No addItemPathList in KConfigSkeleton ?
} else if (m_type == "PathList") {
//FIXME: the split() is naive and will break on lists with ,'s in them
item = m_config->addItemPathList(m_name, *d->newStringList(), m_default.split(","), m_key); */
item = m_config->addItemPathList(m_name, *d->newStringList(), m_default.split(","), m_key);
*/
} else if (m_type == "point") {
QPoint defaultPoint;
QStringList tmpList = m_default.split(",");
@ -468,8 +471,8 @@ void ConfigXmlHandler::addItem()
}
item = m_config->addItemSize(m_name, *d->newSize(), defaultSize, m_key);
} else if (m_type == "ulonglong") {
KConfigSkeleton::ItemULongLong* ulonglongItem = m_config->addItemULongLong(m_name,
*d->newULongLong(), m_default.toULongLong(), m_key);
KConfigSkeleton::ItemULongLong *ulonglongItem =
m_config->addItemULongLong(m_name, *d->newULongLong(), m_default.toULongLong(), m_key);
if (m_haveMin) {
ulonglongItem->setMinValue(m_min);
}
@ -546,7 +549,7 @@ ConfigXml::~ConfigXml()
delete d;
}
KConfigSkeletonItem* ConfigXml::findItem(const QString &group, const QString &key)
KConfigSkeletonItem *ConfigXml::findItem(const QString &group, const QString &key)
{
return KConfigSkeleton::findItem(d->keysToNames[group + key]);
}

View File

@ -163,9 +163,11 @@ void Containment::init()
if (immutability() != SystemImmutable) {
//FIXME I'm not certain this belongs in Containment
//but it sure is nice to have the keyboard shortcut in every containment by default
QAction *lockDesktopAction = new QAction(unlocked ? i18n("Lock Widgets") : i18n("Unlock Widgets"), this);
QAction *lockDesktopAction =
new QAction(unlocked ? i18n("Lock Widgets") : i18n("Unlock Widgets"), this);
lockDesktopAction->setIcon(KIcon(unlocked ? "object-locked" : "object-unlocked"));
connect(lockDesktopAction, SIGNAL(triggered(bool)), this, SLOT(toggleDesktopImmutability()));
connect(lockDesktopAction, SIGNAL(triggered(bool)),
this, SLOT(toggleDesktopImmutability()));
lockDesktopAction->setShortcutContext(Qt::WidgetShortcut);
lockDesktopAction->setShortcut(QKeySequence("ctrl+l"));
d->actions().addAction("lock widgets", lockDesktopAction);
@ -210,7 +212,7 @@ void Containment::init()
d->toolBox->addTool(this->action("add sibling containment"));
if (hasConfigurationInterface()) {
// re-use the contianment's action.
QAction* configureContainment = this->action("configure");
QAction *configureContainment = this->action("configure");
if (configureContainment) {
d->toolBox->addTool(this->action("configure"));
}
@ -310,7 +312,7 @@ void Containment::save(KConfigGroup &g) const
void Containment::saveContents(KConfigGroup &group) const
{
KConfigGroup applets(&group, "Applets");
foreach (const Applet* applet, d->applets) {
foreach (const Applet *applet, d->applets) {
KConfigGroup appletConfig(&applets, QString::number(applet->id()));
applet->save(appletConfig);
}
@ -338,7 +340,9 @@ void Containment::restoreContents(KConfigGroup &group)
continue;
}
Applet *applet = d->addApplet(plugin, QVariantList(), appletConfig.readEntry("geometry", QRectF()), appId, true);
Applet *applet =
d->addApplet(plugin, QVariantList(),
appletConfig.readEntry("geometry", QRectF()), appId, true);
applet->restore(appletConfig);
}
}
@ -442,11 +446,12 @@ void Containment::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
}
}
bool ContainmentPrivate::showContextMenu(const QPointF &point, const QPoint &screenPos, bool includeApplet)
bool ContainmentPrivate::showContextMenu(const QPointF &point,
const QPoint &screenPos, bool includeApplet)
{
Applet* applet = 0;
Applet *applet = 0;
QGraphicsItem* item = q->scene()->itemAt(point);
QGraphicsItem *item = q->scene()->itemAt(point);
if (item == q) {
item = 0;
}
@ -481,7 +486,7 @@ bool ContainmentPrivate::showContextMenu(const QPointF &point, const QPoint &scr
}
if (applet->hasConfigurationInterface()) {
QAction* configureApplet = applet->d->actions.action("configure");
QAction *configureApplet = applet->d->actions.action("configure");
if (configureApplet) {
desktopMenu.addAction(configureApplet);
hasEntries = true;
@ -502,7 +507,7 @@ bool ContainmentPrivate::showContextMenu(const QPointF &point, const QPoint &scr
desktopMenu.addMenu(containmentActionMenu);
}
foreach (QAction* action, containmentActions) {
foreach (QAction *action, containmentActions) {
if (action) {
containmentActionMenu->addAction(action);
}
@ -514,7 +519,7 @@ bool ContainmentPrivate::showContextMenu(const QPointF &point, const QPoint &scr
desktopMenu.addSeparator();
}
QAction* closeApplet = applet->d->actions.action("remove");
QAction *closeApplet = applet->d->actions.action("remove");
if (!closeApplet) { //unlikely but not impossible
kDebug() << "no remove action!!!!!!!!";
closeApplet = new QAction(i18n("Remove this %1", applet->name()), &desktopMenu);
@ -543,7 +548,7 @@ bool ContainmentPrivate::showContextMenu(const QPointF &point, const QPoint &scr
return false;
}
foreach (QAction* action, actions) {
foreach (QAction *action, actions) {
if (action) {
desktopMenu.addAction(action);
}
@ -600,7 +605,7 @@ void Containment::setLocation(Location location)
d->location = location;
foreach (Applet* applet, d->applets) {
foreach (Applet *applet, d->applets) {
applet->updateConstraints(Plasma::LocationConstraint);
}
@ -631,7 +636,8 @@ void Containment::clearApplets()
d->applets.clear();
}
Applet* Containment::addApplet(const QString& name, const QVariantList& args, const QRectF &appletGeometry)
Applet *Containment::addApplet(const QString &name, const QVariantList &args,
const QRectF &appletGeometry)
{
return d->addApplet(name, args, appletGeometry);
}
@ -721,16 +727,20 @@ void Containment::setScreen(int screen)
#ifndef Q_OS_WIN
// we want to listen to changes in work area if our screen changes
if (d->screen < 0 && screen > -1) {
connect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SLOT(positionToolBox()));
connect(KWindowSystem::self(), SIGNAL(workAreaChanged()),
this, SLOT(positionToolBox()));
} else if (screen < 0) {
disconnect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SLOT(positionToolBox()));
disconnect(KWindowSystem::self(), SIGNAL(workAreaChanged()),
this, SLOT(positionToolBox()));
}
#endif
if (screen > -1 && corona()) {
// sanity check to make sure someone else doesn't have this screen already!
Containment* currently = corona()->containmentForScreen(screen);
Containment *currently = corona()->containmentForScreen(screen);
if (currently && currently != this) {
//kDebug() << "currently is on screen" << currently->screen() << "and is" << currently->name() << (QObject*)currently << (QObject*)this;
//kDebug() << "currently is on screen" << currently->screen()
// << "and is" << currently->name()
// << (QObject*)currently << (QObject*)this;
currently->setScreen(-1);
}
}
@ -790,7 +800,8 @@ QPoint Containment::effectiveScreenPos() const
return QPoint(r.left(), r.top() + (p.bottom() + INTER_CONTAINMENT_MARGIN));
break;
case RightEdge:
return QPoint(r.right() - p.width(), r.top() + (p.bottom() + INTER_CONTAINMENT_MARGIN));
return QPoint(r.right() - p.width(),
r.top() + (p.bottom() + INTER_CONTAINMENT_MARGIN));
break;
default:
//FIXME: implement properly for Floating!
@ -890,7 +901,7 @@ void Containment::dropEvent(QGraphicsSceneDragDropEvent *event)
//TODO: collect the mimetypes of available script engines and offer
// to create widgets out of the matching URLs, if any
KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
foreach (const KUrl& url, urls) {
foreach (const KUrl &url, urls) {
KMimeType::Ptr mime = KMimeType::findByUrl(url);
QString mimeName = mime->name();
QRectF geom(event->pos(), QSize());
@ -903,7 +914,7 @@ void Containment::dropEvent(QGraphicsSceneDragDropEvent *event)
//TODO: should we show a dialog here to choose which plasmoid load if
//!appletList.isEmpty()
QMenu choices;
QHash<QAction*, QString> actionsToPlugins;
QHash<QAction *, QString> actionsToPlugins;
foreach (const KPluginInfo &info, appletList) {
QAction *action;
if (!info.icon().isEmpty()) {
@ -955,7 +966,7 @@ void Containment::dropEvent(QGraphicsSceneDragDropEvent *event)
selectedPlugin = seenPlugins.constBegin().key();
} else {
QMenu choices;
QHash<QAction*, QString > actionsToPlugins;
QHash<QAction *, QString> actionsToPlugins;
foreach (const KPluginInfo &info, seenPlugins) {
QAction *action;
if (!info.icon().isEmpty()) {
@ -985,7 +996,6 @@ void Containment::dropEvent(QGraphicsSceneDragDropEvent *event)
stream.writeRawData(data, data.size());
}
QRectF geom(event->pos(), QSize());
QVariantList args;
args << tempFile.fileName();
@ -1008,7 +1018,8 @@ void Containment::resizeEvent(QGraphicsSceneResizeEvent *event)
void Containment::keyPressEvent(QKeyEvent *event)
{
//kDebug() << "keyPressEvent with" << event->key() << "and hoping and wishing for a" << Qt::Key_Tab;
//kDebug() << "keyPressEvent with" << event->key()
// << "and hoping and wishing for a" << Qt::Key_Tab;
if (event->key() == Qt::Key_Tab) { // && event->modifiers() == 0) {
if (!d->applets.isEmpty()) {
kDebug() << "let's give focus to...." << (QObject*)d->applets.first();
@ -1020,7 +1031,7 @@ void Containment::keyPressEvent(QKeyEvent *event)
void Containment::wheelEvent(QGraphicsSceneWheelEvent *event)
{
if (d->wallpaper) {
QGraphicsItem* item = scene()->itemAt(event->scenePos());
QGraphicsItem *item = scene()->itemAt(event->scenePos());
if (item == this) {
event->ignore();
d->wallpaper->wheelEvent(event);
@ -1034,7 +1045,7 @@ void Containment::wheelEvent(QGraphicsSceneWheelEvent *event)
}
if (containmentType() == DesktopContainment) {
QGraphicsItem* item = scene()->itemAt(event->scenePos());
QGraphicsItem *item = scene()->itemAt(event->scenePos());
if (item == this) {
int numDesktops = KWindowSystem::numberOfDesktops();
int currentDesktop = KWindowSystem::currentDesktop();
@ -1059,7 +1070,7 @@ bool Containment::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
Applet *applet = qgraphicsitem_cast<Applet*>(watched);
// Otherwise we're watching something we shouldn't be...
Q_ASSERT(applet!=0);
Q_ASSERT(applet != 0);
if (!d->applets.contains(applet)) {
return false;
}
@ -1093,8 +1104,8 @@ QVariant Containment::itemChange(GraphicsItemChange change, const QVariant &valu
//FIXME if the applet is moved to another containment we need to unfocus it
if (isContainment() &&
(change == QGraphicsItem::ItemSceneHasChanged || change == QGraphicsItem::ItemPositionHasChanged) &&
!d->positioning) {
(change == QGraphicsItem::ItemSceneHasChanged ||
change == QGraphicsItem::ItemPositionHasChanged) && !d->positioning) {
switch (containmentType()) {
case PanelContainment:
case CustomPanelContainment:
@ -1162,7 +1173,7 @@ void Containment::addAssociatedWidget(QWidget *widget)
d->focusedApplet->addAssociatedWidget(widget);
}
foreach (const Applet* applet, d->applets) {
foreach (const Applet *applet, d->applets) {
if (applet->d->activationAction) {
widget->addAction(applet->d->activationAction);
}
@ -1257,7 +1268,7 @@ void Containment::setWallpaper(const QString &pluginName, const QString &mode)
}
}
Plasma::Wallpaper* Containment::wallpaper() const
Plasma::Wallpaper *Containment::wallpaper() const
{
return d->wallpaper;
}
@ -1283,7 +1294,7 @@ QString Containment::activity() const
return d->context()->currentActivity();
}
Context* ContainmentPrivate::context()
Context *ContainmentPrivate::context()
{
if (!con) {
con = new Context(q);
@ -1294,7 +1305,7 @@ Context* ContainmentPrivate::context()
return con;
}
KActionCollection& ContainmentPrivate::actions()
KActionCollection &ContainmentPrivate::actions()
{
return static_cast<Applet*>(q)->d->actions;
}
@ -1379,8 +1390,10 @@ void Containment::destroy(bool confirm)
//FIXME maybe that %1 should be the containment type not the name
if (!confirm ||
KMessageBox::warningContinueCancel(view(), i18n("Do you really want to remove this %1?", name()),
i18n("Remove %1", name()), KStandardGuiItem::remove()) == KMessageBox::Continue) {
KMessageBox::warningContinueCancel(
view(),
i18n("Do you really want to remove this %1?", name()),
i18n("Remove %1", name()), KStandardGuiItem::remove()) == KMessageBox::Continue) {
//clearApplets();
Applet::destroy();
}
@ -1441,7 +1454,7 @@ void ContainmentPrivate::zoomOut()
positionToolBox();
}
ToolBox* ContainmentPrivate::createToolBox()
ToolBox *ContainmentPrivate::createToolBox()
{
if (!toolBox) {
switch (type) {
@ -1479,14 +1492,17 @@ void ContainmentPrivate::positionToolBox()
if (type == Containment::PanelContainment) {
if (q->formFactor() == Vertical) {
toolBox->setCorner(ToolBox::Bottom);
toolBox->setPos(q->geometry().width()/2 - toolBox->boundingRect().width()/2, q->geometry().height());
toolBox->setPos(q->geometry().width() / 2 - toolBox->boundingRect().width() / 2,
q->geometry().height());
//defaulting to Horizontal right now
} else {
if (QApplication::layoutDirection() == Qt::RightToLeft) {
toolBox->setPos(q->geometry().left(), q->geometry().height()/2 - toolBox->boundingRect().height()/2);
toolBox->setPos(q->geometry().left(),
q->geometry().height() / 2 - toolBox->boundingRect().height() / 2);
toolBox->setCorner(ToolBox::Left);
} else {
toolBox->setPos(q->geometry().width(), q->geometry().height()/2 - toolBox->boundingRect().height()/2);
toolBox->setPos(q->geometry().width(),
q->geometry().height() / 2 - toolBox->boundingRect().height() / 2);
toolBox->setCorner(ToolBox::Right);
}
}
@ -1624,8 +1640,8 @@ void ContainmentPrivate::containmentConstraintsEvent(Plasma::Constraints constra
}
}
Applet* ContainmentPrivate::addApplet(const QString& name, const QVariantList& args,
const QRectF& appletGeometry, uint id, bool delayInit)
Applet *ContainmentPrivate::addApplet(const QString &name, const QVariantList &args,
const QRectF &appletGeometry, uint id, bool delayInit)
{
if (!q->isContainment()) {
return 0;
@ -1641,7 +1657,7 @@ Applet* ContainmentPrivate::addApplet(const QString& name, const QVariantList& a
v->setCursor(Qt::BusyCursor);
}
Applet* applet = Applet::load(name, id, args);
Applet *applet = Applet::load(name, id, args);
if (v) {
v->unsetCursor();
}
@ -1668,7 +1684,7 @@ bool ContainmentPrivate::regionIsEmpty(const QRectF &region, Applet *ignoredAppl
return true;
}
void ContainmentPrivate::appletDestroyed(QObject* object)
void ContainmentPrivate::appletDestroyed(QObject *object)
{
// we do a static_cast here since it really isn't an Applet by this
// point anymore since we are in the qobject dtor. we don't actually
@ -1677,7 +1693,7 @@ void ContainmentPrivate::appletDestroyed(QObject* object)
//
// NOTE: DO NOT USE THE applet VARIABLE FOR ANYTHING OTHER THAN COMPARING
// THE ADDRESS! ACTUALLY USING THE OBJECT WILL RESULT IN A CRASH!!!
Applet* applet = static_cast<Plasma::Applet*>(object);
Applet *applet = static_cast<Plasma::Applet*>(object);
applets.removeAll(applet);
if (focusedApplet == applet) {
focusedApplet = 0;
@ -1843,7 +1859,7 @@ void ContainmentPrivate::positionPanel(bool force)
// this should be ok for small numbers of panels, but if we ever end
// up managing hundreds of them, this simplistic alogrithm will
// likely be too slow.
foreach (const Containment* other, q->corona()->containments()) {
foreach (const Containment *other, q->corona()->containments()) {
if (other == q ||
(other->containmentType() != Containment::PanelContainment &&
other->containmentType() != Containment::CustomPanelContainment) ||
@ -1892,7 +1908,6 @@ void ContainmentPrivate::positionPanel(bool force)
positioning = false;
}
} // Plasma namespace
#include "containment.moc"

View File

@ -91,7 +91,7 @@ public:
}
}
void containmentDestroyed(QObject* obj)
void containmentDestroyed(QObject *obj)
{
// we do a static_cast here since it really isn't an Containment by this
// point anymore since we are in the qobject dtor. we don't actually
@ -112,11 +112,12 @@ public:
emit q->configSynced();
}
Containment* addContainment(const QString& name, const QVariantList& args, uint id, bool delayedInit)
Containment *addContainment(const QString &name, const QVariantList &args,
uint id, bool delayedInit)
{
QString pluginName = name;
Containment* containment = 0;
Applet* applet = 0;
Containment *containment = 0;
Applet *applet = 0;
//kDebug() << "Loading" << name << args << id;
@ -133,7 +134,8 @@ public:
if (!containment) {
kDebug() << "loading of containment" << name << "failed.";
// in case we got a non-Containment from Applet::loadApplet or a null containment was requested
// in case we got a non-Containment from Applet::loadApplet or
// a null containment was requested
delete applet;
containment = new Containment(0, 0, id);
@ -158,9 +160,12 @@ public:
}
containments.append(containment);
QObject::connect(containment, SIGNAL(destroyed(QObject*)), q, SLOT(containmentDestroyed(QObject*)));
QObject::connect(containment, SIGNAL(configNeedsSaving()), q, SLOT(requestConfigSync()));
QObject::connect(containment, SIGNAL(releaseVisualFocus()), q, SIGNAL(releaseVisualFocus()));
QObject::connect(containment, SIGNAL(destroyed(QObject*)),
q, SLOT(containmentDestroyed(QObject*)));
QObject::connect(containment, SIGNAL(configNeedsSaving()),
q, SLOT(requestConfigSync()));
QObject::connect(containment, SIGNAL(releaseVisualFocus()),
q, SIGNAL(releaseVisualFocus()));
QObject::connect(containment, SIGNAL(screenChanged(int,int,Plasma::Containment*)),
q, SIGNAL(screenOwnerChanged(int,int,Plasma::Containment*)));
@ -204,7 +209,7 @@ Corona::~Corona()
delete d;
}
void Corona::setAppletMimeType(const QString& type)
void Corona::setAppletMimeType(const QString &type)
{
d->mimetype = type;
}
@ -261,7 +266,7 @@ void Corona::initializeLayout(const QString &configName)
setImmutability((ImmutabilityType)coronaConfig.readEntry("immutability", (int)Mutable));
}
void Corona::loadLayout(const QString& configName)
void Corona::loadLayout(const QString &configName)
{
KSharedConfigPtr c;
@ -273,7 +278,7 @@ void Corona::loadLayout(const QString& configName)
KConfigGroup containments(config(), "Containments");
foreach (const QString& group, containments.groupList()) {
foreach (const QString &group, containments.groupList()) {
KConfigGroup containmentConfig(&containments, group);
if (containmentConfig.entryMap().isEmpty()) {
@ -293,11 +298,11 @@ void Corona::loadLayout(const QString& configName)
c->restore(containmentConfig);
}
foreach (Containment* containment, d->containments) {
foreach (Containment *containment, d->containments) {
QString cid = QString::number(containment->id());
KConfigGroup containmentConfig(&containments, cid);
foreach(Applet* applet, containment->applets()) {
foreach (Applet *applet, containment->applets()) {
applet->init();
// We have to flush the applet constraints manually
applet->flushPendingConstraintsEvents();
@ -309,9 +314,9 @@ void Corona::loadLayout(const QString& configName)
}
}
Containment* Corona::containmentForScreen(int screen) const
Containment *Corona::containmentForScreen(int screen) const
{
foreach (Containment* containment, d->containments) {
foreach (Containment *containment, d->containments) {
if (containment->screen() == screen &&
(containment->containmentType() == Containment::DesktopContainment ||
containment->containmentType() >= Containment::CustomContainment)) {
@ -329,7 +334,7 @@ QList<Containment*> Corona::containments() const
void Corona::clearContainments()
{
foreach (Containment* containment, d->containments) {
foreach (Containment *containment, d->containments) {
containment->clearApplets();
}
}
@ -343,12 +348,12 @@ KSharedConfigPtr Corona::config() const
return d->config;
}
Containment* Corona::addContainment(const QString& name, const QVariantList& args)
Containment *Corona::addContainment(const QString &name, const QVariantList &args)
{
return d->addContainment(name, args, 0, false);
}
Containment* Corona::addContainmentDelayed(const QString& name, const QVariantList& args)
Containment *Corona::addContainmentDelayed(const QString &name, const QVariantList &args)
{
return d->addContainment(name, args, 0, true);
}

View File

@ -41,15 +41,14 @@
namespace Plasma
{
DataEngine::DataEngine(QObject* parent, KService::Ptr service)
DataEngine::DataEngine(QObject *parent, KService::Ptr service)
: QObject(parent),
d(new DataEnginePrivate(this, service))
{
connect(d->updateTimer, SIGNAL(timeout()), this, SLOT(scheduleSourcesUpdated()));
}
DataEngine::DataEngine(QObject* parent, const QVariantList& args)
DataEngine::DataEngine(QObject *parent, const QVariantList &args)
: QObject(parent),
d(new DataEnginePrivate(this, KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString())))
{
@ -67,53 +66,56 @@ QStringList DataEngine::sources() const
return d->sources.keys();
}
Service* DataEngine::serviceForSource(const QString &source)
Service *DataEngine::serviceForSource(const QString &source)
{
return new NullService(source, this);
}
void DataEngine::connectSource(const QString& source, QObject* visualization,
uint pollingInterval, Plasma::IntervalAlignment intervalAlignment) const
void DataEngine::connectSource(const QString &source, QObject *visualization,
uint pollingInterval,
Plasma::IntervalAlignment intervalAlignment) const
{
//kDebug() << "connectSource" << source;
bool newSource;
DataContainer* s = d->requestSource(source, &newSource);
DataContainer *s = d->requestSource(source, &newSource);
if (s) {
// we suppress the immediate invocation of dataUpdated here if the source was prexisting and they
// don't request delayed updates (we want to do an immediate update in that case so they
// don't have to wait for the first time out)
d->connectSource(s, visualization, pollingInterval, intervalAlignment, !newSource || pollingInterval > 0);
// we suppress the immediate invocation of dataUpdated here if the
// source was prexisting and they don't request delayed updates
// (we want to do an immediate update in that case so they don't
// have to wait for the first time out)
d->connectSource(s, visualization, pollingInterval, intervalAlignment,
!newSource || pollingInterval > 0);
//kDebug() << " ==> source connected";
}
}
void DataEngine::connectAllSources(QObject* visualization, uint pollingInterval,
void DataEngine::connectAllSources(QObject *visualization, uint pollingInterval,
Plasma::IntervalAlignment intervalAlignment) const
{
foreach (DataContainer* s, d->sources) {
foreach (DataContainer *s, d->sources) {
d->connectSource(s, visualization, pollingInterval, intervalAlignment);
}
}
void DataEngine::disconnectSource(const QString& source, QObject* visualization) const
void DataEngine::disconnectSource(const QString &source, QObject *visualization) const
{
DataContainer* s = d->source(source, false);
DataContainer *s = d->source(source, false);
if (s) {
s->disconnectVisualization(visualization);
}
}
DataContainer* DataEngine::containerForSource(const QString &source)
DataContainer *DataEngine::containerForSource(const QString &source)
{
return d->source(source, false);
}
DataEngine::Data DataEngine::query(const QString& source) const
DataEngine::Data DataEngine::query(const QString &source) const
{
bool newSource;
DataContainer* s = d->requestSource(source, &newSource);
DataContainer *s = d->requestSource(source, &newSource);
if (!s) {
return DataEngine::Data();
@ -149,7 +151,7 @@ bool DataEngine::sourceRequestEvent(const QString &name)
}
}
bool DataEngine::updateSourceEvent(const QString& source)
bool DataEngine::updateSourceEvent(const QString &source)
{
if (d->script) {
return d->script->updateSourceEvent(source);
@ -159,14 +161,14 @@ bool DataEngine::updateSourceEvent(const QString& source)
}
}
void DataEngine::setData(const QString& source, const QVariant& value)
void DataEngine::setData(const QString &source, const QVariant &value)
{
setData(source, source, value);
}
void DataEngine::setData(const QString& source, const QString& key, const QVariant& value)
void DataEngine::setData(const QString &source, const QString &key, const QVariant &value)
{
DataContainer* s = d->source(source, false);
DataContainer *s = d->source(source, false);
bool isNew = !s;
if (isNew) {
@ -204,25 +206,25 @@ void DataEngine::setData(const QString &source, const Data &data)
d->queueUpdate();
}
void DataEngine::removeAllData(const QString& source)
void DataEngine::removeAllData(const QString &source)
{
DataContainer* s = d->source(source, false);
DataContainer *s = d->source(source, false);
if (s) {
s->removeAllData();
d->queueUpdate();
}
}
void DataEngine::removeData(const QString& source, const QString& key)
void DataEngine::removeData(const QString &source, const QString &key)
{
DataContainer* s = d->source(source, false);
DataContainer *s = d->source(source, false);
if (s) {
s->setData(key, QVariant());
d->queueUpdate();
}
}
void DataEngine::addSource(DataContainer* source)
void DataEngine::addSource(DataContainer *source)
{
if (d->sources.contains(source->objectName())) {
kDebug() << "source named \"" << source->objectName() << "\" already exists.";
@ -291,7 +293,7 @@ void DataEngine::pollingInterval()
}
*/
void DataEngine::removeSource(const QString& source)
void DataEngine::removeSource(const QString &source)
{
//kDebug() << "removing source " << source;
SourceDict::iterator it = d->sources.find(source);
@ -379,7 +381,7 @@ void DataEngine::timerEvent(QTimerEvent *event)
scheduleSourcesUpdated();
}
void DataEngine::setIcon(const QString& icon)
void DataEngine::setIcon(const QString &icon)
{
d->icon = icon;
}
@ -408,14 +410,14 @@ QString DataEngine::name() const
return d->engineName;
}
void DataEngine::setName(const QString& name)
void DataEngine::setName(const QString &name)
{
d->engineName = name;
setObjectName(name);
}
// Private class implementations
DataEnginePrivate::DataEnginePrivate(DataEngine* e, KService::Ptr service)
DataEnginePrivate::DataEnginePrivate(DataEngine *e, KService::Ptr service)
: q(e),
refCount(-1), // first ref
updateTimerId(0),
@ -446,9 +448,11 @@ DataEnginePrivate::DataEnginePrivate(DataEngine* e, KService::Ptr service)
QString api = dataEngineDescription.property("X-Plasma-API").toString();
if (!api.isEmpty()) {
const QString path = KStandardDirs::locate("data",
"plasma/engines/" + dataEngineDescription.pluginName() + '/');
PackageStructure::Ptr structure = Plasma::packageStructure(api, Plasma::RunnerComponent);
const QString path =
KStandardDirs::locate("data",
"plasma/engines/" + dataEngineDescription.pluginName() + '/');
PackageStructure::Ptr structure =
Plasma::packageStructure(api, Plasma::RunnerComponent);
structure->setPath(path);
package = new Package(path, structure);
@ -471,7 +475,7 @@ DataEnginePrivate::~DataEnginePrivate()
package = 0;
}
void DataEnginePrivate::internalUpdateSource(DataContainer* source)
void DataEnginePrivate::internalUpdateSource(DataContainer *source)
{
if (minPollingInterval > 0 &&
source->timeSinceLastUpdate() < (uint)minPollingInterval) {
@ -507,11 +511,11 @@ bool DataEnginePrivate::isUsed() const
return refCount != 0;
}
DataContainer* DataEnginePrivate::source(const QString& sourceName, bool createWhenMissing)
DataContainer *DataEnginePrivate::source(const QString &sourceName, bool createWhenMissing)
{
DataEngine::SourceDict::const_iterator it = sources.find(sourceName);
if (it != sources.constEnd()) {
DataContainer* s = it.value();
DataContainer *s = it.value();
if (limit > 0) {
QQueue<DataContainer*>::iterator it = sourceQueue.begin();
while (it != sourceQueue.end()) {
@ -533,7 +537,7 @@ DataContainer* DataEnginePrivate::source(const QString& sourceName, bool createW
/*kDebug() << "DataEngine " << q->objectName()
<< ": could not find DataContainer " << sourceName
<< ", creating" << endl;*/
DataContainer* s = new DataContainer(q);
DataContainer *s = new DataContainer(q);
s->setObjectName(sourceName);
sources.insert(sourceName, s);
QObject::connect(s, SIGNAL(updateRequested(DataContainer*)),
@ -546,8 +550,10 @@ DataContainer* DataEnginePrivate::source(const QString& sourceName, bool createW
return s;
}
void DataEnginePrivate::connectSource(DataContainer* s, QObject* visualization, uint pollingInterval,
Plasma::IntervalAlignment align, bool immediateCall)
void DataEnginePrivate::connectSource(DataContainer *s, QObject *visualization,
uint pollingInterval,
Plasma::IntervalAlignment align,
bool immediateCall)
{
//kDebug() << "connect source called" << s->objectName() << "with interval" << pollingInterval;
if (pollingInterval > 0) {
@ -575,14 +581,14 @@ void DataEnginePrivate::connectSource(DataContainer* s, QObject* visualization,
}
}
DataContainer* DataEnginePrivate::requestSource(const QString& sourceName, bool* newSource)
DataContainer *DataEnginePrivate::requestSource(const QString &sourceName, bool *newSource)
{
if (newSource) {
*newSource = false;
}
//kDebug() << "requesting source " << sourceName;
DataContainer* s = source(sourceName, false);
DataContainer *s = source(sourceName, false);
if (!s) {
// we didn't find a data source, so give the engine an opportunity to make one
@ -609,7 +615,7 @@ void DataEnginePrivate::trimQueue()
{
uint queueCount = sourceQueue.count();
while (queueCount >= limit) {
DataContainer* punted = sourceQueue.dequeue();
DataContainer *punted = sourceQueue.dequeue();
q->removeSource(punted->objectName());
}
}

View File

@ -31,7 +31,7 @@ namespace Plasma
class NullEngine : public DataEngine
{
public:
NullEngine(QObject* parent = 0)
NullEngine(QObject *parent = 0)
: DataEngine(parent)
{
setObjectName(i18n("Null Engine"));
@ -51,14 +51,14 @@ class DataEngineManagerPrivate
~DataEngineManagerPrivate()
{
foreach (Plasma::DataEngine* engine, engines) {
foreach (Plasma::DataEngine *engine, engines) {
delete engine;
}
engines.clear();
delete nullEng;
}
DataEngine* nullEngine()
DataEngine *nullEngine()
{
if (!nullEng) {
nullEng = new NullEngine;
@ -68,7 +68,7 @@ class DataEngineManagerPrivate
}
DataEngine::Dict engines;
DataEngine* nullEng;
DataEngine *nullEng;
};
class DataEngineManagerSingleton
@ -79,7 +79,7 @@ class DataEngineManagerSingleton
K_GLOBAL_STATIC(DataEngineManagerSingleton, privateDataEngineManagerSelf)
DataEngineManager* DataEngineManager::self()
DataEngineManager *DataEngineManager::self()
{
return &privateDataEngineManagerSelf->self;
}
@ -94,7 +94,7 @@ DataEngineManager::~DataEngineManager()
delete d;
}
Plasma::DataEngine* DataEngineManager::engine(const QString& name) const
Plasma::DataEngine *DataEngineManager::engine(const QString &name) const
{
Plasma::DataEngine::Dict::const_iterator it = d->engines.find(name);
if (it != d->engines.end()) {
@ -106,9 +106,9 @@ Plasma::DataEngine* DataEngineManager::engine(const QString& name) const
return d->nullEngine();
}
Plasma::DataEngine* DataEngineManager::loadEngine(const QString& name)
Plasma::DataEngine *DataEngineManager::loadEngine(const QString &name)
{
Plasma::DataEngine* engine = 0;
Plasma::DataEngine *engine = 0;
Plasma::DataEngine::Dict::const_iterator it = d->engines.find(name);
if (it != d->engines.end()) {
@ -132,8 +132,9 @@ Plasma::DataEngine* DataEngineManager::loadEngine(const QString& name)
if (api.isEmpty()) {
if (offers.first()) {
KPluginLoader plugin(*offers.first());
if (Plasma::isPluginVersionCompatible(plugin.pluginVersion()))
if (Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
engine = offers.first()->createInstance<Plasma::DataEngine>(0, allArgs, &error);
}
}
} else {
engine = new DataEngine(0, offers.first());
@ -150,12 +151,12 @@ Plasma::DataEngine* DataEngineManager::loadEngine(const QString& name)
return engine;
}
void DataEngineManager::unloadEngine(const QString& name)
void DataEngineManager::unloadEngine(const QString &name)
{
Plasma::DataEngine::Dict::iterator it = d->engines.find(name);
if (it != d->engines.end()) {
Plasma::DataEngine* engine = *it;
Plasma::DataEngine *engine = *it;
engine->d->deref();
if (!engine->d->isUsed()) {

View File

@ -53,9 +53,9 @@ class DelegatePrivate
~DelegatePrivate() { }
QFont fontForSubTitle(const QFont& titleFont) const;
QRect titleRect(const QStyleOptionViewItem& option, const QModelIndex& index) const;
QRect subTitleRect(const QStyleOptionViewItem& option, const QModelIndex& index) const;
QFont fontForSubTitle(const QFont &titleFont) const;
QRect titleRect(const QStyleOptionViewItem &option, const QModelIndex &index) const;
QRect subTitleRect(const QStyleOptionViewItem &option, const QModelIndex &index) const;
QMap<int, int> roles;
@ -69,8 +69,7 @@ class DelegatePrivate
static const int ITEM_BOTTOM_MARGIN = 5;
};
QFont DelegatePrivate::fontForSubTitle(const QFont& titleFont) const
QFont DelegatePrivate::fontForSubTitle(const QFont &titleFont) const
{
QFont subTitleFont = titleFont;
subTitleFont.setPointSize(qMax(subTitleFont.pointSize() - 2,
@ -78,19 +77,24 @@ QFont DelegatePrivate::fontForSubTitle(const QFont& titleFont) const
return subTitleFont;
}
QRect DelegatePrivate::titleRect(const QStyleOptionViewItem& option, const QModelIndex& index) const
QRect DelegatePrivate::titleRect(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QFont font(option.font);
font.setBold(true);
QFontMetrics fm(font);
Qt::Alignment textAlignment = option.decorationAlignment & Qt::AlignRight ? Qt::AlignRight : Qt::AlignLeft;
Qt::Alignment textAlignment =
option.decorationAlignment & Qt::AlignRight ? Qt::AlignRight : Qt::AlignLeft;
QRect emptyRect;
if (option.direction == Qt::LeftToRight) {
emptyRect = option.rect.adjusted(option.decorationSize.width()+ICON_TEXT_MARGIN+ITEM_LEFT_MARGIN, ITEM_TOP_MARGIN, -ITEM_RIGHT_MARGIN, -ITEM_BOTTOM_MARGIN);
emptyRect = option.rect.adjusted(
option.decorationSize.width() + ICON_TEXT_MARGIN + ITEM_LEFT_MARGIN,
ITEM_TOP_MARGIN, -ITEM_RIGHT_MARGIN, -ITEM_BOTTOM_MARGIN);
} else {
emptyRect = option.rect.adjusted(ITEM_LEFT_MARGIN, ITEM_TOP_MARGIN, -ITEM_RIGHT_MARGIN-option.decorationSize.width()-ICON_TEXT_MARGIN, -ITEM_BOTTOM_MARGIN);
emptyRect = option.rect.adjusted(
ITEM_LEFT_MARGIN, ITEM_TOP_MARGIN,
-ITEM_RIGHT_MARGIN - option.decorationSize.width() - ICON_TEXT_MARGIN, -ITEM_BOTTOM_MARGIN);
}
if (emptyRect.width() < 0) {
@ -98,17 +102,19 @@ QRect DelegatePrivate::titleRect(const QStyleOptionViewItem& option, const QMode
return emptyRect;
}
QRect textRect = QStyle::alignedRect(option.direction,
textAlignment,
fm.boundingRect(index.data(Qt::DisplayRole).toString()).size(),
emptyRect);
QRect textRect = QStyle::alignedRect(
option.direction,
textAlignment,
fm.boundingRect(index.data(Qt::DisplayRole).toString()).size(),
emptyRect);
textRect.setWidth(textRect.width() + TEXT_RIGHT_MARGIN);
textRect.setHeight(emptyRect.height()/2);
textRect.setHeight(emptyRect.height() / 2);
return textRect;
}
QRect DelegatePrivate::subTitleRect(const QStyleOptionViewItem& option, const QModelIndex& index) const
QRect DelegatePrivate::subTitleRect(const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QString subTitle = index.data(roles[Delegate::SubTitleRole]).toString();
@ -153,7 +159,7 @@ int Delegate::roleMapping(SpecificRoles role) const
return d->roles[role];
}
QRect Delegate::rectAfterTitle(const QStyleOptionViewItem& option, const QModelIndex& index) const
QRect Delegate::rectAfterTitle(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QRect textRect = d->titleRect(option, index);
@ -172,7 +178,7 @@ QRect Delegate::rectAfterTitle(const QStyleOptionViewItem& option, const QModelI
return emptyRect;
}
QRect Delegate::rectAfterSubTitle(const QStyleOptionViewItem& option, const QModelIndex& index) const
QRect Delegate::rectAfterSubTitle(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QRect textRect = d->subTitleRect(option, index);
@ -191,30 +197,31 @@ QRect Delegate::rectAfterSubTitle(const QStyleOptionViewItem& option, const QMod
return emptyRect;
}
QRect Delegate::emptyRect(const QStyleOptionViewItem& option, const QModelIndex& index) const
QRect Delegate::emptyRect(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QRect afterTitleRect = rectAfterTitle(option, index);
QRect afterSubTitleRect = rectAfterSubTitle(option, index);
afterTitleRect.setHeight(afterTitleRect.height()*2);
afterTitleRect.setHeight(afterTitleRect.height() * 2);
afterSubTitleRect.setTop(afterTitleRect.top());
return afterTitleRect.intersected(afterSubTitleRect);
}
void Delegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
const bool hover = option.state & (QStyle::State_MouseOver | QStyle::State_Selected);
QRect contentRect = option.rect;
contentRect.setBottom(contentRect.bottom() - 1);
QRect decorationRect = QStyle::alignedRect(option.direction,
option.decorationPosition == QStyleOptionViewItem::Left ?
Qt::AlignLeft : Qt::AlignRight,
option.decorationSize,
contentRect.adjusted(DelegatePrivate::ITEM_LEFT_MARGIN, DelegatePrivate::ITEM_TOP_MARGIN,-DelegatePrivate::ITEM_RIGHT_MARGIN,-DelegatePrivate::ITEM_BOTTOM_MARGIN));
QRect decorationRect =
QStyle::alignedRect(option.direction,
option.decorationPosition == QStyleOptionViewItem::Left ?
Qt::AlignLeft : Qt::AlignRight,
option.decorationSize,
contentRect.adjusted(DelegatePrivate::ITEM_LEFT_MARGIN, DelegatePrivate::ITEM_TOP_MARGIN, -DelegatePrivate::ITEM_RIGHT_MARGIN, -DelegatePrivate::ITEM_BOTTOM_MARGIN));
decorationRect.moveTop(contentRect.top() + qMax(0, (contentRect.height() - decorationRect.height())) / 2);
QString titleText = index.data(Qt::DisplayRole).value<QString>();
@ -223,7 +230,6 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem& option, cons
QRect titleRect = d->titleRect(option, index);
QRect subTitleRect = d->subTitleRect(option, index);
bool uniqueTitle = !index.data(d->roles[SubTitleMandatoryRole]).value<bool>();// true;
if (uniqueTitle) {
QModelIndex sib = index.sibling(index.row() + 1, index.column());
@ -323,7 +329,7 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem& option, cons
if (index.data(d->roles[ColumnTypeRole]).toInt() == SecondaryActionColumn) {
if (hover) {
// Only draw on hover
const int delta = floor((qreal)(option.decorationSize.width() - DelegatePrivate::ACTION_ICON_SIZE)/2.0);
const int delta = floor((qreal)(option.decorationSize.width() - DelegatePrivate::ACTION_ICON_SIZE) / 2.0);
decorationRect.adjust(delta, delta-1, -delta-1, -delta);
decorationIcon.paint(painter, decorationRect, option.decorationAlignment);
}
@ -360,7 +366,7 @@ void Delegate::paint(QPainter *painter, const QStyleOptionViewItem& option, cons
}
QSize Delegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
QSize Delegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
Q_UNUSED(index)
QSize size = option.rect.size();
@ -371,11 +377,9 @@ QSize Delegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex&
size.setHeight(qMax(option.decorationSize.height(), qMax(size.height(), metrics.height() + subMetrics.ascent()) + 3) + 4);
// kDebug() << "size hint is" << size << (metrics.height() + subMetrics.ascent());
size*=1.1;
size *= 1.1;
return size;
}
}

View File

@ -156,7 +156,7 @@ void Dialog::paintEvent(QPaintEvent *e)
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
p.setClipRect(e->rect());
p.setCompositionMode(QPainter::CompositionMode_Source );
p.setCompositionMode(QPainter::CompositionMode_Source);
p.fillRect(rect(), Qt::transparent);
d->background->paintPanel(&p);
@ -198,7 +198,7 @@ void Dialog::mouseMoveEvent(QMouseEvent *event)
}
// here we take care of resize..
if (d->resizeStartCorner != Dialog::NoCorner ) {
if (d->resizeStartCorner != Dialog::NoCorner) {
int newWidth;
int newHeight;
QPoint position;
@ -375,7 +375,7 @@ Dialog::ResizeCorners Dialog::resizeCorners() const
bool Dialog::inControlArea(const QPoint &point)
{
foreach(const QRect &r, d->resizeAreas) {
foreach (const QRect &r, d->resizeAreas) {
if (r.contains(point)) {
return true;
}

View File

@ -160,7 +160,8 @@ class ExtenderItemPrivate
returnToSource->setMaximumSize(iconSize);
toolboxLayout->addItem(returnToSource);
QObject::connect(returnToSource, SIGNAL(clicked()), q, SLOT(moveBackToSource()));
QObject::connect(returnToSource, SIGNAL(clicked()),
q, SLOT(moveBackToSource()));
}
toolboxLayout->updateGeometry();
@ -169,8 +170,8 @@ class ExtenderItemPrivate
QSizeF minimum = toolboxLayout->minimumSize();
toolbox->resize(minimum);
toolbox->setPos(q->size().width() - minimum.width() - bgRight,
((dragger->size().height() + dragTop + dragBottom)/2) -
(minimum.height()/2) + bgTop);
((dragger->size().height() + dragTop + dragBottom) / 2) -
(minimum.height() / 2) + bgTop);
toolbox->update();
}
}
@ -178,8 +179,9 @@ class ExtenderItemPrivate
//TODO: something like this as static function in corona might be a good idea.
QPointF scenePosFromScreenPos(const QPoint &pos) const
{
//get the stacking order of the toplevel windows and remove the toplevel view that's
//only here while dragging, since we're not interested in finding that.
//get the stacking order of the toplevel windows and remove the
//toplevel view that's only here while dragging, since we're not
//interested in finding that.
QList<WId> order = KWindowSystem::stackingOrder();
if (toplevel) {
order.removeOne(toplevel->winId());
@ -345,8 +347,7 @@ ExtenderItem::ExtenderItem(Extender *hostExtender, uint extenderItemId)
d->collapseIcon = new Icon(KIcon(hostExtender->d->applet->icon()), "", this);
d->collapseIcon->resize(d->collapseIcon->sizeFromIconSize(iconSize.height()));
d->collapseIcon->setPos(d->bgLeft + d->dragLeft,
(d->dragger->size().height() + d->dragTop + d->dragBottom)/2 -
d->collapseIcon->size().height()/2 + d->bgTop);
(d->dragger->size().height() + d->dragTop + d->dragBottom) / 2 - d->collapseIcon->size().height() / 2 + d->bgTop);
connect(d->collapseIcon, SIGNAL(clicked()), this, SLOT(toggleCollapse()));
//set the extender we want to move to.
@ -563,7 +564,7 @@ void ExtenderItem::destroy()
void ExtenderItem::setCollapsed(bool collapsed)
{
qreal marginWidth = d->bgLeft + d->bgRight + d->dragLeft + d->dragRight;
qreal marginHeight = d->bgTop + d->bgBottom + 2*d->dragTop + 2*d->dragBottom;
qreal marginHeight = d->bgTop + d->bgBottom + 2 * d->dragTop + 2 * d->dragBottom;
if (!d->widget) {
setPreferredSize(QSizeF(200, d->dragHandleRect().height()));
@ -607,10 +608,10 @@ void ExtenderItem::setCollapsed(bool collapsed)
} else {
setPreferredSize(QSizeF(preferredSize.width() + marginWidth,
preferredSize.height() + d->dragHandleRect().height() + marginHeight));
setMinimumSize( QSizeF(minimumSize.width() + marginWidth,
minimumSize.height() + d->dragHandleRect().height() + marginHeight));
setMaximumSize( QSizeF(maximumSize.width() + marginWidth,
maximumSize.height() + d->dragHandleRect().height() + marginHeight));
setMinimumSize(QSizeF(minimumSize.width() + marginWidth,
minimumSize.height() + d->dragHandleRect().height() + marginHeight));
setMaximumSize(QSizeF(maximumSize.width() + marginWidth,
maximumSize.height() + d->dragHandleRect().height() + marginHeight));
if (d->widget->isWidget()) {
QGraphicsWidget *graphicsWidget = static_cast<QGraphicsWidget*>(d->widget);
@ -703,8 +704,7 @@ void ExtenderItem::resizeEvent(QGraphicsSceneResizeEvent *event)
//resize the widget
if (d->widget && d->widget->isWidget()) {
QSizeF newWidgetSize(width - d->bgLeft - d->bgRight - d->dragLeft - d->dragRight,
height - d->dragger->size().height() - d->bgTop - d->bgBottom
- 2*d->dragTop - 2*d->dragBottom);
height - d->dragger->size().height() - d->bgTop - d->bgBottom - 2 * d->dragTop - 2 * d->dragBottom);
QGraphicsWidget *graphicsWidget = static_cast<QGraphicsWidget*>(d->widget);
graphicsWidget->resize(newWidgetSize);
@ -769,8 +769,8 @@ void ExtenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
corona->addOffscreenWidget(this);
d->toplevel->setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint
| Qt::WindowStaysOnTopHint);
d->toplevel->setWindowFlags(
Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
d->toplevel->setFrameShape(QFrame::NoFrame);
d->toplevel->resize(screenRect.size());
d->toplevel->setSceneRect(sceneBoundingRect());

View File

@ -122,9 +122,9 @@ static inline QPainterPath headerPath(const QRectF &r, int roundness,
int xRnd = roundness;
int yRnd = roundness;
if (r.width() > r.height()) {
xRnd = int(roundness * r.height()/r.width());
xRnd = int(roundness * r.height() / r.width());
} else {
yRnd = int(roundness * r.width()/r.height());
yRnd = int(roundness * r.width() / r.height());
}
if(xRnd >= 100) { // fix ranges
@ -140,8 +140,9 @@ static inline QPainterPath headerPath(const QRectF &r, int roundness,
QRectF rect = r.normalized();
if (rect.isNull())
if (rect.isNull()) {
return path;
}
qreal x = rect.x();
qreal y = rect.y();
@ -156,13 +157,13 @@ static inline QPainterPath headerPath(const QRectF &r, int roundness,
if (ryy < 0) {
ryy = h / 200 * yRnd;
}
qreal rxx2 = 2*rxx;
qreal ryy2 = 2*ryy;
qreal rxx2 = 2 * rxx;
qreal ryy2 = 2 * ryy;
path.arcMoveTo(x, y, rxx2, ryy2, 90);
path.arcTo(x, y, rxx2, ryy2, 90, 90);
QPointF pt = path.currentPosition();
path.lineTo(x, pt.y()+headerHeight);
path.lineTo(x, pt.y() + headerHeight);
path.lineTo(x + w, pt.y() + headerHeight);
path.lineTo(x + w, pt.y());
path.arcTo(x + w - rxx2, y, rxx2, ryy2, 0, 90);
@ -206,9 +207,9 @@ void GLApplet::paintInterface(QPainter *painter,
void GLApplet::makeCurrent()
{
if (!d->dummy->isValid() ||
!d->pbuf->isValid())
if (!d->dummy->isValid() || !d->pbuf->isValid()) {
d->dummy->makeCurrent();
}
}
} // Plasma namespace

View File

@ -47,7 +47,7 @@ namespace Plasma
class PackagePrivate
{
public:
PackagePrivate(const PackageStructure::Ptr st, const QString& p)
PackagePrivate(const PackageStructure::Ptr st, const QString &p)
: structure(st),
basePath(p),
valid(QFile::exists(basePath)),
@ -69,7 +69,8 @@ public:
PackageMetadata *metadata;
};
Package::Package(const QString& packageRoot, const QString& package, PackageStructure::Ptr structure)
Package::Package(const QString &packageRoot, const QString &package,
PackageStructure::Ptr structure)
: d(new PackagePrivate(structure, packageRoot + '/' + package))
{
structure->setPath(d->basePath);
@ -112,7 +113,7 @@ bool Package::isValid() const
return true;
}
QString Package::filePath(const char* fileType, const QString& filename) const
QString Package::filePath(const char *fileType, const QString &filename) const
{
if (!d->valid) {
kDebug() << "package is not valid";
@ -146,12 +147,12 @@ QString Package::filePath(const char* fileType, const QString& filename) const
return QString();
}
QString Package::filePath(const char* fileType) const
QString Package::filePath(const char *fileType) const
{
return filePath(fileType, QString());
}
QStringList Package::entryList(const char* fileType) const
QStringList Package::entryList(const char *fileType) const
{
if (!d->valid) {
return QStringList();
@ -176,7 +177,7 @@ QStringList Package::entryList(const char* fileType) const
return QStringList();
}
const PackageMetadata* Package::metadata() const
const PackageMetadata *Package::metadata() const
{
//FIXME: this only works for native plasma packges; should fall back to... PackageStructure?
if (!d->metadata) {
@ -197,7 +198,7 @@ const PackageStructure::Ptr Package::structure() const
//TODO: provide a version of this that allows one to ask for certain types of packages, etc?
// should we be using KService here instead/as well?
QStringList Package::listInstalled(const QString& packageRoot) // static
QStringList Package::listInstalled(const QString &packageRoot) // static
{
QDir dir(packageRoot);
@ -207,7 +208,7 @@ QStringList Package::listInstalled(const QString& packageRoot) // static
QStringList packages;
foreach (const QString& sdir, dir.entryList(QDir::AllDirs | QDir::Readable)) {
foreach (const QString &sdir, dir.entryList(QDir::AllDirs | QDir::Readable)) {
QString metadata = packageRoot + '/' + sdir + "/metadata.desktop";
if (QFile::exists(metadata)) {
PackageMetadata m(metadata);
@ -218,9 +219,9 @@ QStringList Package::listInstalled(const QString& packageRoot) // static
return packages;
}
bool Package::installPackage(const QString& package,
const QString& packageRoot,
const QString& servicePrefix) // static
bool Package::installPackage(const QString &package,
const QString &packageRoot,
const QString &servicePrefix) // static
{
//TODO: report *what* failed if something does fail
QDir root(packageRoot);
@ -259,8 +260,8 @@ bool Package::installPackage(const QString& package,
}
archivedPackage = true;
const KArchiveDirectory* source = archive.directory();
const KArchiveEntry* metadata = source->entry("metadata.desktop");
const KArchiveDirectory *source = archive.directory();
const KArchiveEntry *metadata = source->entry("metadata.desktop");
if (!metadata) {
kWarning() << "No metadata file in package" << package;
@ -288,9 +289,9 @@ bool Package::installPackage(const QString& package,
// Ensure that package names are safe so package uninstall can't inject
// bad characters into the paths used for removal.
QRegExp validatePluginName("^[\\w-\\.]+$"); // Only allow letters, numbers, underscore and period.
if ( !validatePluginName.exactMatch(targetName) ) {
if (!validatePluginName.exactMatch(targetName)) {
kWarning() << "Package plugin name " << targetName << "contains invalid characters";
return false;
return false;
}
targetName = packageRoot + '/' + targetName;
@ -352,9 +353,9 @@ bool Package::installPackage(const QString& package,
return true;
}
bool Package::uninstallPackage(const QString& pluginName,
const QString& packageRoot,
const QString& servicePrefix) // static
bool Package::uninstallPackage(const QString &pluginName,
const QString &packageRoot,
const QString &servicePrefix) // static
{
// We need to remove the package directory and its metadata file.
QString targetName = pluginName;
@ -449,5 +450,4 @@ bool Package::createPackage(const PackageMetadata &metadata,
return true;
}
} // Namespace

View File

@ -35,8 +35,9 @@ namespace PaintUtils
void shadowBlur(QImage &image, int radius, const QColor &color)
{
if (radius < 1)
if (radius < 1) {
return;
}
expblur<16, 7>(image, radius);
@ -48,7 +49,7 @@ void shadowBlur(QImage &image, int radius, const QColor &color)
QPixmap shadowText(QString text, QColor textColor, QColor shadowColor, QPoint offset, int radius)
{
// Draw text
// Draw text
QFontMetrics fm(text);
QRect textRect = fm.boundingRect(text);
QPixmap textPixmap(textRect.size());
@ -63,7 +64,7 @@ QPixmap shadowText(QString text, QColor textColor, QColor shadowColor, QPoint of
QImage::Format_ARGB32_Premultiplied);
img.fill(Qt::transparent);
p.begin(&img);
p.drawImage(QPoint(radius,radius), textPixmap.toImage());
p.drawImage(QPoint(radius, radius), textPixmap.toImage());
p.end();
shadowBlur(img, radius, shadowColor);
@ -85,12 +86,12 @@ QPixmap shadowText(QString text, QColor textColor, QColor shadowColor, QPoint of
finalPixmap.fill(Qt::transparent);
p.begin(&finalPixmap);
QPointF offsetF(offset);
QPointF textTopLeft(finalPixmap.rect().topLeft() +
QPointF ((finalPixmap.width() - textPixmap.width()) / 2.0, (finalPixmap.height() - textPixmap.height()) / 2.0) -
(offsetF / 2.0));
QPointF shadowTopLeft(finalPixmap.rect().topLeft() +
QPointF ((finalPixmap.width() - img.width()) / 2.0, (finalPixmap.height() - img.height()) / 2.0) +
(offsetF / 2.0));
QPointF textTopLeft(finalPixmap.rect().topLeft() +
QPointF ((finalPixmap.width() - textPixmap.width()) / 2.0, (finalPixmap.height() - textPixmap.height()) / 2.0) -
(offsetF / 2.0));
QPointF shadowTopLeft(finalPixmap.rect().topLeft() +
QPointF ((finalPixmap.width() - img.width()) / 2.0, (finalPixmap.height() - img.height()) / 2.0) +
(offsetF / 2.0));
p.drawImage(shadowTopLeft, img);
p.drawPixmap(textTopLeft, textPixmap);
@ -99,7 +100,7 @@ QPixmap shadowText(QString text, QColor textColor, QColor shadowColor, QPoint of
return finalPixmap;
}
QPainterPath roundedRectangle(const QRectF& rect, qreal radius)
QPainterPath roundedRectangle(const QRectF &rect, qreal radius)
{
QPainterPath path(QPointF(rect.left(), rect.top() + radius));
path.quadTo(rect.left(), rect.top(), rect.left() + radius, rect.top()); // Top left corner

View File

@ -49,32 +49,31 @@ qreal scalingFactor(ZoomLevel level)
Direction locationToDirection(Location location)
{
switch (location)
{
case Floating:
case Desktop:
case TopEdge:
case FullScreen:
//TODO: should we be smarter for floating and planer?
// perhaps we should take a QRect and/or QPos as well?
return Down;
case BottomEdge:
return Up;
case LeftEdge:
return Right;
case RightEdge:
return Left;
switch (location) {
case Floating:
case Desktop:
case TopEdge:
case FullScreen:
//TODO: should we be smarter for floating and planer?
// perhaps we should take a QRect and/or QPos as well?
return Down;
case BottomEdge:
return Up;
case LeftEdge:
return Right;
case RightEdge:
return Left;
}
return Down;
}
QPoint popupPosition(const QGraphicsItem * item, const QSize &s)
QPoint popupPosition(const QGraphicsItem *item, const QSize &s)
{
QGraphicsView *v = viewFor(item);
if (!v) {
return QPoint(0,0);
return QPoint(0, 0);
}
QPoint pos = v->mapFromScene(item->scenePos());
@ -109,7 +108,8 @@ QPoint popupPosition(const QGraphicsItem * item, const QSize &s)
}
//are we out of screen?
QRect screenRect = QApplication::desktop()->screenGeometry(pv ? pv->containment()->screen() : -1);
QRect screenRect =
QApplication::desktop()->screenGeometry(pv ? pv->containment()->screen() : -1);
//kDebug() << "==> rect for" << (pv ? pv->containment()->screen() : -1) << "is" << screenRect;
if (pos.rx() + s.width() > screenRect.right()) {
@ -124,7 +124,7 @@ QPoint popupPosition(const QGraphicsItem * item, const QSize &s)
return pos;
}
QGraphicsView* viewFor(const QGraphicsItem * item)
QGraphicsView *viewFor(const QGraphicsItem *item)
{
if (!item->scene()) {
return 0;

View File

@ -115,7 +115,8 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints)
Plasma::FormFactor f = q->formFactor();
if (constraints & Plasma::FormFactorConstraint ||
(constraints & Plasma::SizeConstraint && (f == Plasma::Vertical || f == Plasma::Horizontal))) {
(constraints & Plasma::SizeConstraint &&
(f == Plasma::Vertical || f == Plasma::Horizontal))) {
QGraphicsLinearLayout *lay = dynamic_cast<QGraphicsLinearLayout *>(q->layout());
if (icon && lay) {
@ -219,8 +220,10 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints)
KWindowSystem::setState(dialog->winId(), NET::SkipTaskbar | NET::SkipPager);
dialog->installEventFilter(q);
QObject::connect(dialog, SIGNAL(dialogResized()), q, SLOT(dialogSizeChanged()));
QObject::connect(dialog, SIGNAL(dialogVisible(bool)), q, SLOT(dialogStatusChanged(bool)));
QObject::connect(dialog, SIGNAL(dialogResized()),
q, SLOT(dialogSizeChanged()));
QObject::connect(dialog, SIGNAL(dialogVisible(bool)),
q, SLOT(dialogStatusChanged(bool)));
q->setMinimumSize(QSize(0, 0));
if (gWidget) {
Corona *corona = qobject_cast<Corona *>(gWidget->scene());
@ -263,7 +266,8 @@ void PopupApplet::mousePressEvent(QGraphicsSceneMouseEvent *event)
void PopupApplet::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if (!d->icon && (d->clicked - scenePos().toPoint()).manhattanLength() < KGlobalSettings::dndEventDelay()) {
if (!d->icon &&
(d->clicked - scenePos().toPoint()).manhattanLength() < KGlobalSettings::dndEventDelay()) {
d->togglePopup();
} else {
Applet::mouseReleaseEvent(event);
@ -411,8 +415,10 @@ void PopupAppletPrivate::updateDialogPosition()
{
KConfigGroup sizeGroup = q->config();
sizeGroup = KConfigGroup(&sizeGroup, "PopupApplet");
const int width = qMin(sizeGroup.readEntry("DialogWidth", 0), QApplication::desktop()->screen()->width() - 50);
const int height = qMin(sizeGroup.readEntry("DialogHeight", 0), QApplication::desktop()->screen()->height() - 50);
const int width = qMin(sizeGroup.readEntry("DialogWidth", 0),
QApplication::desktop()->screen()->width() - 50);
const int height = qMin(sizeGroup.readEntry("DialogHeight", 0),
QApplication::desktop()->screen()->height() - 50);
QSize saved(width, height);
@ -464,8 +470,11 @@ void PopupAppletPrivate::updateDialogPosition()
}
//are we out of screen?
QRect screenRect = QApplication::desktop()->screenGeometry(q->containment() ? q->containment()->screen() : -1);
//kDebug() << "==> rect for" << (containment() ? containment()->screen() : -1) << "is" << screenRect;
QRect screenRect =
QApplication::desktop()->screenGeometry(q->containment() ? q->containment()->screen() : -1);
//kDebug() << "==> rect for"
// << (containment() ? containment()->screen() : -1)
// << "is" << screenRect;
if (pos.rx() + s.width() > screenRect.right()) {
pos.rx() += (int)q->boundingRect().size().width() - s.width();

View File

@ -55,7 +55,6 @@ class QueryMatchPrivate : public QSharedData
qreal relevance;
};
QueryMatch::QueryMatch(AbstractRunner *runner)
: d(new QueryMatchPrivate(runner))
{
@ -104,22 +103,22 @@ qreal QueryMatch::relevance() const
return d->relevance;
}
AbstractRunner* QueryMatch::runner() const
AbstractRunner *QueryMatch::runner() const
{
return d->runner;
}
void QueryMatch::setText(const QString& text)
void QueryMatch::setText(const QString &text)
{
d->text = text;
}
void QueryMatch::setSubtext(const QString& subtext)
void QueryMatch::setSubtext(const QString &subtext)
{
d->subtext = subtext;
}
void QueryMatch::setData(const QVariant& data)
void QueryMatch::setData(const QVariant & data)
{
d->data = data;
setId(data.toString());
@ -131,13 +130,12 @@ void QueryMatch::setId(const QString &id)
d->id = d->runner->id();
}
if (!id.isEmpty()) {
d->id.append('_').append(id);
}
}
void QueryMatch::setIcon(const QIcon& icon)
void QueryMatch::setIcon(const QIcon &icon)
{
d->icon = icon;
}
@ -162,7 +160,7 @@ QIcon QueryMatch::icon() const
return d->icon;
}
void QueryMatch::setEnabled( bool enabled )
void QueryMatch::setEnabled(bool enabled)
{
d->enabled = enabled;
}
@ -172,7 +170,7 @@ bool QueryMatch::isEnabled() const
return d->enabled && d->runner;
}
bool QueryMatch::operator<(const QueryMatch& other) const
bool QueryMatch::operator<(const QueryMatch &other) const
{
if (d->type == other.d->type) {
if (isEnabled() != other.isEnabled()) {
@ -191,7 +189,7 @@ bool QueryMatch::operator<(const QueryMatch& other) const
return d->type < other.d->type;
}
QueryMatch& QueryMatch::operator=(const QueryMatch &other)
QueryMatch &QueryMatch::operator=(const QueryMatch &other)
{
if (d != other.d) {
d = other.d;

View File

@ -57,7 +57,7 @@ class RunnerContextPrivate : public QSharedData
{
}
RunnerContextPrivate(const RunnerContextPrivate& p)
RunnerContextPrivate(const RunnerContextPrivate &p)
: QSharedData(),
type(RunnerContext::None),
q(p.q)
@ -120,7 +120,6 @@ class RunnerContextPrivate : public QSharedData
RunnerContext * q;
};
RunnerContext::RunnerContext(QObject *parent)
: QObject(parent),
d(new RunnerContextPrivate(this))
@ -129,7 +128,7 @@ RunnerContext::RunnerContext(QObject *parent)
//copy ctor
RunnerContext::RunnerContext(RunnerContext &other, QObject *parent)
: QObject(parent)
: QObject(parent)
{
LOCK_FOR_READ((&other))
d = other.d;
@ -142,9 +141,9 @@ RunnerContext::~RunnerContext()
void RunnerContext::reset()
{
// We will detach if we are a copy of someone. But we will reset
// if we are the 'main' context others copied from. Resetting
// one RunnerContext makes all the copies oneobsolete.
// We will detach if we are a copy of someone. But we will reset
// if we are the 'main' context others copied from. Resetting
// one RunnerContext makes all the copies oneobsolete.
d.detach();
// we still have to remove all the matches, since if the
@ -174,7 +173,6 @@ void RunnerContext::setQuery(const QString &term)
d->determineType();
}
QString RunnerContext::query() const
{
// the query term should never be set after
@ -193,7 +191,7 @@ QString RunnerContext::mimeType() const
return d->mimeType;
}
bool RunnerContext::addMatches(const QString& term, const QList<QueryMatch> &matches)
bool RunnerContext::addMatches(const QString &term, const QList<QueryMatch> &matches)
{
Q_UNUSED(term)
@ -213,9 +211,9 @@ bool RunnerContext::addMatches(const QString& term, const QList<QueryMatch> &mat
}
UNLOCK(this);
//kDebug()<< "add matches";
// A copied searchContext may share the d pointer,
// A copied searchContext may share the d pointer,
// we always want to sent the signal of the object that created
// the d pointer
// the d pointer
emit d->q->matchesChanged();
return true;
}

View File

@ -44,11 +44,9 @@
using ThreadWeaver::Weaver;
using ThreadWeaver::Job;
namespace Plasma
{
/*****************************************************
* RunnerRestrictionPolicy class
* Restricts simultaneous jobs of the same type
@ -135,7 +133,8 @@ void RunnerRestrictionPolicy::destructed(Job *job)
class FindMatchesJob : public Job
{
public:
FindMatchesJob(Plasma::AbstractRunner *runner, Plasma::RunnerContext *context, QObject *parent = 0);
FindMatchesJob(Plasma::AbstractRunner *runner,
Plasma::RunnerContext *context, QObject *parent = 0);
int priority() const;
Plasma::AbstractRunner *runner() const;
@ -160,7 +159,8 @@ FindMatchesJob::FindMatchesJob(Plasma::AbstractRunner *runner,
void FindMatchesJob::run()
{
// kDebug() << "Running match for " << m_runner->objectName() << " in Thread " << thread()->id() << endl;
// kDebug() << "Running match for " << m_runner->objectName()
// << " in Thread " << thread()->id() << endl;
m_runner->performMatch(*m_context);
}
@ -206,7 +206,8 @@ public:
config = conf;
//The number of threads used scales with the number of processors.
const int numProcs = qMax(Solid::Device::listFromType(Solid::DeviceInterface::Processor).count(), 1);
const int numProcs =
qMax(Solid::Device::listFromType(Solid::DeviceInterface::Processor).count(), 1);
//This entry allows to define a hard upper limit independent of the number of processors.
const int maxThreads = config.readEntry("maxThreads", 16);
const int numThreads = qMin(maxThreads, 2 + ((numProcs - 1) * 2));
@ -264,7 +265,8 @@ public:
kDebug() << "loading runner:" << service->name();
runners.insert(runnerName, runner);
} else {
kDebug() << "failed to load runner:" << service->name() << ". error reported:" << error;
kDebug() << "failed to load runner:" << service->name()
<< ". error reported:" << error;
}
}
} else if (loaded) {
@ -301,8 +303,6 @@ public:
KConfigGroup config;
};
/*****************************************************
* RunnerManager::Public class
*
@ -316,7 +316,6 @@ RunnerManager::RunnerManager(QObject *parent)
//ThreadWeaver::setDebugLevel(true, 4);
}
RunnerManager::RunnerManager(KConfigGroup &c, QObject *parent)
: QObject(parent),
d(new RunnerManagerPrivate(this))

View File

@ -51,7 +51,7 @@ Service::Service(QObject *parent, const QVariantList &args)
// remove those first item since those are managed by Service and subclasses shouldn't
// need to worry about it. yes, it violates the constness of this var, but it lets us add
// or remove items later while applets can just pretend that their args always start at 0
QVariantList &mutableArgs = const_cast<QVariantList&>(args);
QVariantList &mutableArgs = const_cast<QVariantList &>(args);
if (!mutableArgs.isEmpty()) {
setName(mutableArgs[0].toString());
mutableArgs.removeFirst();
@ -65,7 +65,7 @@ Service::~Service()
delete d;
}
Service* Service::load(const QString &name, QObject *parent)
Service *Service::load(const QString &name, QObject *parent)
{
//TODO: scripting API support
if (name.isEmpty()) {
@ -84,7 +84,7 @@ Service* Service::load(const QString &name, QObject *parent)
QString error;
QVariantList args;
args << name;
Service* service = 0;
Service *service = 0;
if (Plasma::isPluginVersionCompatible(KPluginLoader(*offer).pluginVersion())) {
service = offer->createInstance<Plasma::Service>(parent, args, &error);
@ -127,12 +127,13 @@ KConfigGroup Service::operationDescription(const QString &operationName)
d->config->writeConfig();
KConfigGroup params(d->config->config(), operationName);
//kDebug() << "operation" << operationName << "requested, has keys" << params.keyList() << "from"
//kDebug() << "operation" << operationName
// << "requested, has keys" << params.keyList() << "from"
// << d->config->config()->name();
return params;
}
ServiceJob* Service::startOperationCall(const KConfigGroup &description, QObject *parent)
ServiceJob *Service::startOperationCall(const KConfigGroup &description, QObject *parent)
{
// TODO: nested groups?
ServiceJob *job = 0;
@ -178,7 +179,8 @@ void Service::associateWidget(QWidget *widget, const QString &operation)
void Service::disassociateWidget(QWidget *widget)
{
disconnect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(associatedWidgetDestroyed(QObject*)));
disconnect(widget, SIGNAL(destroyed(QObject*)),
this, SLOT(associatedWidgetDestroyed(QObject*)));
d->associatedWidgets.remove(widget);
}
@ -186,14 +188,16 @@ void Service::associateWidget(QGraphicsWidget *widget, const QString &operation)
{
disassociateWidget(widget);
d->associatedGraphicsWidgets.insert(widget, operation);
connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(associatedGraphicsWidgetDestroyed(QObject*)));
connect(widget, SIGNAL(destroyed(QObject*)),
this, SLOT(associatedGraphicsWidgetDestroyed(QObject*)));
widget->setEnabled(!d->disabledOperations.contains(operation));
}
void Service::disassociateWidget(QGraphicsWidget *widget)
{
disconnect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(associatedGraphicsWidgetDestroyed(QObject*)));
disconnect(widget, SIGNAL(destroyed(QObject*)),
this, SLOT(associatedGraphicsWidgetDestroyed(QObject*)));
d->associatedGraphicsWidgets.remove(widget);
}

52
svg.cpp
View File

@ -80,8 +80,10 @@ class SvgPrivate
void setImagePath(const QString &imagePath, Svg *q)
{
if (themed) {
QObject::disconnect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), q, SLOT(themeChanged()));
QObject::disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(colorsChanged()));
QObject::disconnect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
q, SLOT(themeChanged()));
QObject::disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
q, SLOT(colorsChanged()));
}
themed = !QDir::isAbsolutePath(imagePath);
@ -89,13 +91,15 @@ class SvgPrivate
if (themed) {
themePath = imagePath;
QObject::connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), q, SLOT(themeChanged()));
QObject::connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
q, SLOT(themeChanged()));
// check if svg wants colorscheme applied
createRenderer();
applyColors = renderer->elementExists("hint-apply-color-scheme");
if (applyColors && !Theme::defaultTheme()->colorScheme()) {
QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(colorsChanged()));
QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
q, SLOT(colorsChanged()));
}
} else {
@ -134,9 +138,8 @@ class SvgPrivate
return QPixmap();
}
QString id = QString::fromLatin1("%3_%2_%1_").arg(size.width())
.arg(size.height())
.arg(path);
QString id = QString::fromLatin1("%3_%2_%1_").
arg(size.width()).arg(size.height()).arg(path);
if (!elementId.isEmpty()) {
id.append(elementId);
@ -175,7 +178,8 @@ class SvgPrivate
// Apply current color scheme if the svg asks for it
if (applyColors) {
QImage itmp = p.toImage();
KIconEffect::colorize(itmp, Theme::defaultTheme()->color(Theme::BackgroundColor), 1.0);
KIconEffect::colorize(
itmp, Theme::defaultTheme()->color(Theme::BackgroundColor), 1.0);
p = p.fromImage(itmp);
}
@ -211,7 +215,7 @@ class SvgPrivate
void eraseRenderer()
{
if ( renderer && renderer.count() == 2) {
if (renderer && renderer.count() == 2) {
// this and the cache reference it; and boy is this not thread safe ;)
renderers.erase(renderers.find(path));
}
@ -219,7 +223,7 @@ class SvgPrivate
renderer = 0;
}
QSize elementSize(const QString& elementId)
QSize elementSize(const QString &elementId)
{
createRenderer();
@ -231,12 +235,13 @@ class SvgPrivate
QSizeF naturalSize = renderer->defaultSize();
qreal dx = size.width() / naturalSize.width();
qreal dy = size.height() / naturalSize.height();
elementSize.scale(elementSize.width() * dx, elementSize.height() * dy, Qt::IgnoreAspectRatio);
elementSize.scale(elementSize.width() * dx, elementSize.height() * dy,
Qt::IgnoreAspectRatio);
return elementSize.toSize();
}
QRectF elementRect(const QString& elementId)
QRectF elementRect(const QString &elementId)
{
createRenderer();
QRectF elementRect = renderer->boundsOnElement(elementId);
@ -248,7 +253,7 @@ class SvgPrivate
elementRect.width() * dx, elementRect.height() * dy);
}
QMatrix matrixForElement(const QString& elementId)
QMatrix matrixForElement(const QString &elementId)
{
createRenderer();
return renderer->matrixForElement(elementId);
@ -275,9 +280,11 @@ class SvgPrivate
createRenderer();
applyColors = renderer->elementExists("hint-apply-color-scheme");
if (applyColors && !Theme::defaultTheme()->colorScheme()) {
QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(colorsChanged()));
QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
q, SLOT(colorsChanged()));
} else {
QObject::disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(colorsChanged()));
QObject::disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
q, SLOT(colorsChanged()));
}
emit q->repaintNeeded();
@ -308,7 +315,7 @@ class SvgPrivate
QHash<QString, SharedSvgRenderer::Ptr> SvgPrivate::renderers;
Svg::Svg(QObject* parent)
Svg::Svg(QObject *parent)
: QObject(parent),
d(new SvgPrivate(this))
{
@ -328,7 +335,7 @@ QPixmap Svg::pixmap(const QString &elementID)
}
}
void Svg::paint(QPainter* painter, const QPointF& point, const QString& elementID)
void Svg::paint(QPainter *painter, const QPointF &point, const QString &elementID)
{
QPixmap pix(elementID.isNull() ? d->findInCache(elementID, size()) :
d->findInCache(elementID));
@ -337,18 +344,18 @@ void Svg::paint(QPainter* painter, const QPointF& point, const QString& elementI
return;
}
painter->drawPixmap(QRectF(point, pix.size()), pix, QRectF(QPointF(0,0), pix.size()));
painter->drawPixmap(QRectF(point, pix.size()), pix, QRectF(QPointF(0, 0), pix.size()));
}
void Svg::paint(QPainter* painter, int x, int y, const QString& elementID)
void Svg::paint(QPainter *painter, int x, int y, const QString &elementID)
{
paint(painter, QPointF(x, y), elementID);
}
void Svg::paint(QPainter* painter, const QRectF& rect, const QString& elementID)
void Svg::paint(QPainter *painter, const QRectF &rect, const QString &elementID)
{
QPixmap pix(d->findInCache(elementID, rect.size()));
painter->drawPixmap(rect, pix, QRectF(QPointF(0,0), pix.size()));
painter->drawPixmap(rect, pix, QRectF(QPointF(0, 0), pix.size()));
}
QSize Svg::size() const
@ -398,7 +405,8 @@ FIXME: implement when Qt can support us!
QSizeF naturalSize = d->renderer->defaultSize();
qreal dx = d->size.width() / naturalSize.width();
qreal dy = d->size.height() / naturalSize.height();
//kDebug() << point << "is really" << QPoint(point.x() *dx, naturalSize.height() - point.y() * dy);
//kDebug() << point << "is really"
// << QPoint(point.x() *dx, naturalSize.height() - point.y() * dy);
return QString(); // d->renderer->elementAtPoint(QPoint(point.x() *dx, naturalSize.height() - point.y() * dy));
*/

View File

@ -65,7 +65,7 @@ public:
generalFont = QApplication::font();
}
KConfigGroup& config()
KConfigGroup &config()
{
if (!cfg.isValid()) {
QString groupName = "Theme";
@ -161,14 +161,14 @@ public:
Theme self;
};
K_GLOBAL_STATIC( ThemeSingleton, privateThemeSelf )
K_GLOBAL_STATIC(ThemeSingleton, privateThemeSelf)
Theme* Theme::defaultTheme()
Theme *Theme::defaultTheme()
{
return &privateThemeSelf->self;
}
Theme::Theme(QObject* parent)
Theme::Theme(QObject *parent)
: QObject(parent),
d(new ThemePrivate(this))
{
@ -256,17 +256,20 @@ void Theme::setThemeName(const QString &themeName)
d->defaultWallpaperWidth = cg.readEntry("defaultWidth", DEFAULT_WALLPAPER_WIDTH);
d->defaultWallpaperHeight = cg.readEntry("defaultHeight", DEFAULT_WALLPAPER_HEIGHT);
disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SIGNAL(themeChanged()));
disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
this, SIGNAL(themeChanged()));
if (colorsFile.isEmpty()) {
d->colors = 0;
connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SIGNAL(themeChanged()));
connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
this, SIGNAL(themeChanged()));
} else {
d->colors = KSharedConfig::openConfig(colorsFile);
}
d->colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, d->colors);
d->buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, d->colors);
d->hasWallpapers = !KStandardDirs::locate("data", "desktoptheme/" + theme + "/wallpapers").isEmpty();
d->hasWallpapers =
!KStandardDirs::locate("data", "desktoptheme/" + theme + "/wallpapers").isEmpty();
if (d->isDefault) {
// we're the default theme, let's save our state
@ -286,7 +289,7 @@ QString Theme::themeName() const
return d->themeName;
}
QString Theme::imagePath(const QString& name) const
QString Theme::imagePath(const QString &name) const
{
// look for a compressed svg file in the theme
if (name.contains("../")) {
@ -369,7 +372,7 @@ QString Theme::wallpaperPath(const QSize &size) const
return fullPath;
}
bool Theme::currentThemeHasImage(const QString& name) const
bool Theme::currentThemeHasImage(const QString &name) const
{
if (name.contains("../")) {
// we don't support relative paths
@ -422,15 +425,16 @@ QFont Theme::font(FontRole role) const
{
Q_UNUSED(role)
switch (role) {
case DesktopFont: {
KConfigGroup cg(KGlobal::config(), "General");
return cg.readEntry("desktopFont", QFont("Sans Serif", 10));
}
break;
case DefaultFont:
default:
return d->generalFont;
break;
case DesktopFont:
{
KConfigGroup cg(KGlobal::config(), "General");
return cg.readEntry("desktopFont", QFont("Sans Serif", 10));
}
break;
case DefaultFont:
default:
return d->generalFont;
break;
}
}

View File

@ -38,7 +38,6 @@
#include <fixx11h.h>
#endif
//Plasma
#include <applet.h>
#include <containment.h>
@ -79,7 +78,6 @@ public :
*/
void onWidgetDestroyed(QObject * object);
QGraphicsWidget *currentWidget;
QTimer *showTimer;
QTimer *hideTimer;
@ -97,7 +95,7 @@ class ToolTipManagerSingleton
}
ToolTipManager self;
};
K_GLOBAL_STATIC( ToolTipManagerSingleton, privateInstance )
K_GLOBAL_STATIC(ToolTipManagerSingleton, privateInstance)
ToolTipManager *ToolTipManager::self()
{
@ -114,7 +112,7 @@ bool ToolTipManager::ToolTipContent::isEmpty() const
return mainText.isEmpty() && subText.isEmpty() && image.isNull() && windowToPreview == 0;
}
ToolTipManager::ToolTipManager(QObject* parent)
ToolTipManager::ToolTipManager(QObject *parent)
: QObject(parent),
d(new ToolTipManagerPrivate)
{
@ -416,7 +414,7 @@ bool ToolTipManager::eventFilter(QObject *watched, QEvent *event)
break;
}
return QObject::eventFilter(watched,event);
return QObject::eventFilter(watched, event);
}
} // Plasma namespace

View File

@ -50,18 +50,18 @@ UiLoader::UiLoader(QObject *parent)
{
d->widgets
<< "CheckBox"
<< "ComboBox"
<< "ComboBox"
<< "Flash"
<< "Frame"
<< "Frame"
<< "GroupBox"
<< "Icon"
<< "Icon"
<< "Label"
<< "LineEdit"
<< "PushButton"
<< "RadioButton"
<< "Slider"
<< "TabBar"
<< "TextEdit";
<< "PushButton"
<< "RadioButton"
<< "Slider"
<< "TabBar"
<< "TextEdit";
}
UiLoader::~UiLoader()
@ -78,41 +78,29 @@ QGraphicsWidget *UiLoader::createWidget(const QString &className, QGraphicsWidge
{
if (className == QString("CheckBox")) {
return new CheckBox(parent);
}
else if (className == QString("ComboBox")) {
} else if (className == QString("ComboBox")) {
return new ComboBox(parent);
}
else if (className == QString("Flash")) {
} else if (className == QString("Flash")) {
return new Flash(parent);
}
else if (className == QString("Frame")) {
} else if (className == QString("Frame")) {
return new Frame(parent);
}
else if (className == QString("GroupBox")) {
} else if (className == QString("GroupBox")) {
return new GroupBox(parent);
}
else if (className == QString("Icon")) {
} else if (className == QString("Icon")) {
return new Icon(parent);
}
else if (className == QString("Label")) {
} else if (className == QString("Label")) {
return new Label(parent);
}
else if (className == QString("LineEdit")) {
} else if (className == QString("LineEdit")) {
return new LineEdit(parent);
}
else if (className == QString("PushButton")) {
} else if (className == QString("PushButton")) {
return new PushButton(parent);
}
else if (className == QString("RadioButton")) {
} else if (className == QString("RadioButton")) {
return new RadioButton(parent);
}
else if (className == QString("Slider")) {
} else if (className == QString("Slider")) {
return new Slider(parent);
}
else if (className == QString("TabBar")) {
} else if (className == QString("TabBar")) {
return new TabBar(parent);
}
else if (className == QString("TextEdit")) {
} else if (className == QString("TextEdit")) {
return new TextEdit(parent);
}
@ -124,17 +112,15 @@ QStringList UiLoader::availableLayouts() const
return d->layouts;
}
Layout *UiLoader::createLayout( const QString &className, LayoutItem *parent )
Layout *UiLoader::createLayout(const QString &className, LayoutItem *parent)
{
#ifdef RICHARD_WORK
if (className == QString("HBoxLayout")) {
return new HBoxLayout( parent );
}
else if (className == QString("VBoxLayout")) {
return new VBoxLayout( parent );
}
else if (className == QString("FlowLayout")) {
return new FlowLayout( parent );
return new HBoxLayout(parent);
} else if (className == QString("VBoxLayout")) {
return new VBoxLayout(parent);
} else if (className == QString("FlowLayout")) {
return new FlowLayout(parent);
}
#endif
return 0;

View File

@ -47,14 +47,14 @@ public:
KServiceAction mode;
};
Wallpaper::Wallpaper(QObject* parentObject, const QVariantList& args)
Wallpaper::Wallpaper(QObject *parentObject, const QVariantList &args)
: d(new WallpaperPrivate(KService::serviceByStorageId(args.count() > 0 ?
args[0].toString() : QString()), this))
{
// now remove first item since those are managed by Wallpaper and subclasses shouldn't
// need to worry about them. yes, it violates the constness of this var, but it lets us add
// or remove items later while applets can just pretend that their args always start at 0
QVariantList &mutableArgs = const_cast<QVariantList&>(args);
QVariantList &mutableArgs = const_cast<QVariantList &>(args);
if (!mutableArgs.isEmpty()) {
mutableArgs.removeFirst();
}
@ -78,7 +78,7 @@ KPluginInfo::List Wallpaper::listWallpaperInfo(const QString &formFactor)
return KPluginInfo::fromServices(offers);
}
Wallpaper* Wallpaper::load(const QString& wallpaperName, const QVariantList& args)
Wallpaper *Wallpaper::load(const QString &wallpaperName, const QVariantList &args)
{
if (wallpaperName.isEmpty()) {
return 0;
@ -102,7 +102,7 @@ Wallpaper* Wallpaper::load(const QString& wallpaperName, const QVariantList& arg
QVariantList allArgs;
allArgs << offer->storageId() << args;
QString error;
Wallpaper* wallpaper = offer->createInstance<Plasma::Wallpaper>(0, allArgs, &error);
Wallpaper *wallpaper = offer->createInstance<Plasma::Wallpaper>(0, allArgs, &error);
if (!wallpaper) {
kDebug() << "Couldn't load wallpaper \"" << wallpaperName << "\"! reason given: " << error;
@ -110,7 +110,7 @@ Wallpaper* Wallpaper::load(const QString& wallpaperName, const QVariantList& arg
return wallpaper;
}
Wallpaper* Wallpaper::load(const KPluginInfo& info, const QVariantList& args)
Wallpaper *Wallpaper::load(const KPluginInfo &info, const QVariantList &args)
{
if (!info.isValid()) {
return 0;
@ -164,7 +164,7 @@ QRectF Wallpaper::boundingRect() const
return d->boundingRect;
}
void Wallpaper::setBoundingRect(const QRectF& boundingRect)
void Wallpaper::setBoundingRect(const QRectF &boundingRect)
{
d->boundingRect = boundingRect;
}