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:
parent
254d4c7107
commit
a7aebfa60a
@ -41,7 +41,7 @@ namespace Plasma
|
|||||||
class AbstractRunnerPrivate
|
class AbstractRunnerPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AbstractRunnerPrivate(AbstractRunner* r, KService::Ptr service)
|
AbstractRunnerPrivate(AbstractRunner *r, KService::Ptr service)
|
||||||
: priority(AbstractRunner::NormalPriority),
|
: priority(AbstractRunner::NormalPriority),
|
||||||
speed(AbstractRunner::NormalSpeed),
|
speed(AbstractRunner::NormalSpeed),
|
||||||
blackListed(0),
|
blackListed(0),
|
||||||
@ -56,7 +56,8 @@ public:
|
|||||||
if (!api.isEmpty()) {
|
if (!api.isEmpty()) {
|
||||||
const QString path = KStandardDirs::locate("data",
|
const QString path = KStandardDirs::locate("data",
|
||||||
"plasma/runners/" + runnerDescription.pluginName() + '/');
|
"plasma/runners/" + runnerDescription.pluginName() + '/');
|
||||||
PackageStructure::Ptr structure = Plasma::packageStructure(api, Plasma::RunnerComponent);
|
PackageStructure::Ptr structure =
|
||||||
|
Plasma::packageStructure(api, Plasma::RunnerComponent);
|
||||||
structure->setPath(path);
|
structure->setPath(path);
|
||||||
package = new Package(path, structure);
|
package = new Package(path, structure);
|
||||||
|
|
||||||
@ -86,9 +87,9 @@ public:
|
|||||||
AbstractRunner::Priority priority;
|
AbstractRunner::Priority priority;
|
||||||
AbstractRunner::Speed speed;
|
AbstractRunner::Speed speed;
|
||||||
RunnerContext::Types blackListed;
|
RunnerContext::Types blackListed;
|
||||||
RunnerScript* script;
|
RunnerScript *script;
|
||||||
KPluginInfo runnerDescription;
|
KPluginInfo runnerDescription;
|
||||||
AbstractRunner* runner;
|
AbstractRunner *runner;
|
||||||
QTime runtime;
|
QTime runtime;
|
||||||
int fastRuns;
|
int fastRuns;
|
||||||
Package *package;
|
Package *package;
|
||||||
@ -96,13 +97,13 @@ public:
|
|||||||
|
|
||||||
K_GLOBAL_STATIC(QMutex, s_bigLock)
|
K_GLOBAL_STATIC(QMutex, s_bigLock)
|
||||||
|
|
||||||
AbstractRunner::AbstractRunner(QObject* parent, const QString& serviceId)
|
AbstractRunner::AbstractRunner(QObject *parent, const QString &serviceId)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new AbstractRunnerPrivate(this, KService::serviceByStorageId(serviceId)))
|
d(new AbstractRunnerPrivate(this, KService::serviceByStorageId(serviceId)))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractRunner::AbstractRunner(QObject* parent, const QVariantList& args)
|
AbstractRunner::AbstractRunner(QObject *parent, const QVariantList &args)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new AbstractRunnerPrivate(this, KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString())))
|
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);
|
QMutexLocker lock(s_bigLock);
|
||||||
return KServiceTypeTrader::self()->query(serviceType, constraint);
|
return KServiceTypeTrader::self()->query(serviceType, constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMutex* AbstractRunner::bigLock() const
|
QMutex *AbstractRunner::bigLock() const
|
||||||
{
|
{
|
||||||
return s_bigLock;
|
return s_bigLock;
|
||||||
}
|
}
|
||||||
@ -256,7 +257,7 @@ QString AbstractRunner::description() const
|
|||||||
return d->runnerDescription.property("Comment").toString();
|
return d->runnerDescription.property("Comment").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Package* AbstractRunner::package() const
|
const Package *AbstractRunner::package() const
|
||||||
{
|
{
|
||||||
return d->package;
|
return d->package;
|
||||||
}
|
}
|
||||||
|
@ -93,13 +93,13 @@ Animator::CurveShape AnimationDriver::elementAnimationCurve(Plasma::Animator::An
|
|||||||
return Animator::EaseInOutCurve;
|
return Animator::EaseInOutCurve;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap AnimationDriver::elementAppear(qreal progress, const QPixmap& pixmap)
|
QPixmap AnimationDriver::elementAppear(qreal progress, const QPixmap &pixmap)
|
||||||
{
|
{
|
||||||
Q_UNUSED(progress)
|
Q_UNUSED(progress)
|
||||||
return pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap AnimationDriver::elementDisappear(qreal progress, const QPixmap& pixmap)
|
QPixmap AnimationDriver::elementDisappear(qreal progress, const QPixmap &pixmap)
|
||||||
{
|
{
|
||||||
Q_UNUSED(progress)
|
Q_UNUSED(progress)
|
||||||
QPixmap pix(pixmap.size());
|
QPixmap pix(pixmap.size());
|
||||||
@ -108,19 +108,19 @@ QPixmap AnimationDriver::elementDisappear(qreal progress, const QPixmap& pixmap)
|
|||||||
return pix;
|
return pix;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationDriver::itemAppear(qreal frame, QGraphicsItem* item)
|
void AnimationDriver::itemAppear(qreal frame, QGraphicsItem *item)
|
||||||
{
|
{
|
||||||
Q_UNUSED(frame)
|
Q_UNUSED(frame)
|
||||||
Q_UNUSED(item)
|
Q_UNUSED(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationDriver::itemDisappear(qreal frame, QGraphicsItem* item)
|
void AnimationDriver::itemDisappear(qreal frame, QGraphicsItem *item)
|
||||||
{
|
{
|
||||||
Q_UNUSED(frame)
|
Q_UNUSED(frame)
|
||||||
Q_UNUSED(item)
|
Q_UNUSED(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationDriver::itemActivated(qreal frame, QGraphicsItem* item)
|
void AnimationDriver::itemActivated(qreal frame, QGraphicsItem *item)
|
||||||
{
|
{
|
||||||
Q_UNUSED(frame)
|
Q_UNUSED(frame)
|
||||||
Q_UNUSED(item)
|
Q_UNUSED(item)
|
||||||
|
134
animator.cpp
134
animator.cpp
@ -87,8 +87,8 @@ struct CustomAnimationState
|
|||||||
int interval;
|
int interval;
|
||||||
int currentInterval;
|
int currentInterval;
|
||||||
int id;
|
int id;
|
||||||
QObject* receiver;
|
QObject *receiver;
|
||||||
char* slot;
|
char *slot;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AnimatorPrivate
|
class AnimatorPrivate
|
||||||
@ -131,25 +131,25 @@ class AnimatorPrivate
|
|||||||
return progress;
|
return progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
void performAnimation(qreal amount, const AnimationState* state)
|
void performAnimation(qreal amount, const AnimationState *state)
|
||||||
{
|
{
|
||||||
switch (state->animation) {
|
switch (state->animation) {
|
||||||
case Animator::AppearAnimation:
|
case Animator::AppearAnimation:
|
||||||
driver->itemAppear(amount, state->item);
|
driver->itemAppear(amount, state->item);
|
||||||
break;
|
break;
|
||||||
case Animator::DisappearAnimation:
|
case Animator::DisappearAnimation:
|
||||||
driver->itemDisappear(amount, state->item);
|
driver->itemDisappear(amount, state->item);
|
||||||
if (amount >= 1) {
|
if (amount >= 1) {
|
||||||
state->item->hide();
|
state->item->hide();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Animator::ActivateAnimation:
|
case Animator::ActivateAnimation:
|
||||||
driver->itemActivated(amount, state->item);
|
driver->itemActivated(amount, state->item);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void performMovement(qreal amount, const MovementState* state)
|
void performMovement(qreal amount, const MovementState *state)
|
||||||
{
|
{
|
||||||
switch (state->movement) {
|
switch (state->movement) {
|
||||||
case Animator::SlideInMovement:
|
case Animator::SlideInMovement:
|
||||||
@ -171,7 +171,7 @@ class AnimatorPrivate
|
|||||||
void animatedElementDestroyed(QObject*);
|
void animatedElementDestroyed(QObject*);
|
||||||
void customAnimReceiverDestroyed(QObject*);
|
void customAnimReceiverDestroyed(QObject*);
|
||||||
|
|
||||||
AnimationDriver* driver;
|
AnimationDriver *driver;
|
||||||
int animId;
|
int animId;
|
||||||
int timerId;
|
int timerId;
|
||||||
QTime time;
|
QTime time;
|
||||||
@ -194,13 +194,12 @@ class AnimatorSingleton
|
|||||||
|
|
||||||
K_GLOBAL_STATIC(AnimatorSingleton, privateSelf)
|
K_GLOBAL_STATIC(AnimatorSingleton, privateSelf)
|
||||||
|
|
||||||
Animator* Animator::self()
|
Animator *Animator::self()
|
||||||
{
|
{
|
||||||
return &privateSelf->self;
|
return &privateSelf->self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Animator::Animator(QObject *parent)
|
||||||
Animator::Animator(QObject * parent)
|
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new AnimatorPrivate)
|
d(new AnimatorPrivate)
|
||||||
{
|
{
|
||||||
@ -212,7 +211,7 @@ Animator::~Animator()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimatorPrivate::animatedItemDestroyed(QObject* o)
|
void AnimatorPrivate::animatedItemDestroyed(QObject *o)
|
||||||
{
|
{
|
||||||
//kDebug() << "testing for" << (void*)o;
|
//kDebug() << "testing for" << (void*)o;
|
||||||
QMutableMapIterator<QGraphicsItem*, AnimationState*> it(animatedItems);
|
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);
|
QMutableMapIterator<QGraphicsItem*, MovementState*> it(movingItems);
|
||||||
while (it.hasNext()) {
|
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);
|
QMutableMapIterator<int, ElementAnimationState*> it(animatedElements);
|
||||||
while (it.hasNext()) {
|
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);
|
QMutableMapIterator<int, CustomAnimationState*> it(customAnims);
|
||||||
while (it.hasNext()) {
|
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();
|
//kDebug();
|
||||||
// get rid of any existing animations on this item.
|
// 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);
|
int duration = d->driver->animationDuration(animation);
|
||||||
|
|
||||||
AnimationState* state = new AnimationState;
|
AnimationState *state = new AnimationState;
|
||||||
state->id = ++d->animId;
|
state->id = ++d->animId;
|
||||||
state->item = item;
|
state->item = item;
|
||||||
state->animation = animation;
|
state->animation = animation;
|
||||||
@ -296,11 +295,13 @@ int Animator::animateItem(QGraphicsItem* item, Animation animation)
|
|||||||
state->currentInterval = state->interval;
|
state->currentInterval = state->interval;
|
||||||
state->qobj = dynamic_cast<QObject*>(item);
|
state->qobj = dynamic_cast<QObject*>(item);
|
||||||
|
|
||||||
if (state->qobj) {
|
if (state->qobj) {
|
||||||
//kDebug() << "!!!!!!!!!!!!!!!!!!!!!!!!! got us an object!";
|
//kDebug() << "!!!!!!!!!!!!!!!!!!!!!!!!! got us an object!";
|
||||||
disconnect(state->qobj, SIGNAL(destroyed(QObject*)), this, SLOT(animatedItemDestroyed(QObject*)));
|
disconnect(state->qobj, SIGNAL(destroyed(QObject*)),
|
||||||
connect(state->qobj, SIGNAL(destroyed(QObject*)), this, SLOT(animatedItemDestroyed(QObject*)));
|
this, SLOT(animatedItemDestroyed(QObject*)));
|
||||||
}
|
connect(state->qobj, SIGNAL(destroyed(QObject*)),
|
||||||
|
this, SLOT(animatedItemDestroyed(QObject*)));
|
||||||
|
}
|
||||||
|
|
||||||
d->animatedItems[item] = state;
|
d->animatedItems[item] = state;
|
||||||
d->performAnimation(0, state);
|
d->performAnimation(0, state);
|
||||||
@ -313,7 +314,7 @@ int Animator::animateItem(QGraphicsItem* item, Animation animation)
|
|||||||
return state->id;
|
return state->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Animator::moveItem(QGraphicsItem* item, Movement movement, const QPoint &destination)
|
int Animator::moveItem(QGraphicsItem *item, Movement movement, const QPoint &destination)
|
||||||
{
|
{
|
||||||
//kDebug();
|
//kDebug();
|
||||||
QMap<QGraphicsItem*, MovementState*>::iterator it = d->movingItems.find(item);
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
MovementState* state = new MovementState;
|
MovementState *state = new MovementState;
|
||||||
state->id = ++d->animId;
|
state->id = ++d->animId;
|
||||||
state->destination = destination;
|
state->destination = destination;
|
||||||
state->start = item->pos().toPoint();
|
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,
|
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) {
|
if (frames < 1 || duration < 1 || !receiver || !slot) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -457,12 +458,15 @@ int Animator::animateElement(QGraphicsItem *item, Animation animation)
|
|||||||
state->id = ++d->animId;
|
state->id = ++d->animId;
|
||||||
state->qobj = dynamic_cast<QObject*>(item);
|
state->qobj = dynamic_cast<QObject*>(item);
|
||||||
|
|
||||||
if (state->qobj) {
|
if (state->qobj) {
|
||||||
disconnect(state->qobj, SIGNAL(destroyed(QObject*)), this, SLOT(animatedElementDestroyed(QObject*)));
|
disconnect(state->qobj, SIGNAL(destroyed(QObject*)),
|
||||||
connect(state->qobj, SIGNAL(destroyed(QObject*)), this, SLOT(animatedElementDestroyed(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;
|
bool needTimer = true;
|
||||||
if (state->frames < 1) {
|
if (state->frames < 1) {
|
||||||
state->frames = 1;
|
state->frames = 1;
|
||||||
@ -471,7 +475,7 @@ int Animator::animateElement(QGraphicsItem *item, Animation animation)
|
|||||||
}
|
}
|
||||||
|
|
||||||
d->animatedElements[state->id] = state;
|
d->animatedElements[state->id] = state;
|
||||||
|
|
||||||
//kDebug() << "startElementAnimation(AnimId " << animation << ") returning " << state->id;
|
//kDebug() << "startElementAnimation(AnimId " << animation << ") returning " << state->id;
|
||||||
if (needTimer && !d->timerId) {
|
if (needTimer && !d->timerId) {
|
||||||
// start a 20fps timer;
|
// start a 20fps timer;
|
||||||
@ -513,7 +517,7 @@ QPixmap Animator::currentPixmap(int id)
|
|||||||
return QPixmap();
|
return QPixmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementAnimationState* state = it.value();
|
ElementAnimationState *state = it.value();
|
||||||
qreal progress = d->calculateProgress(state->currentFrame * state->interval,
|
qreal progress = d->calculateProgress(state->currentFrame * state->interval,
|
||||||
state->frames * state->interval,
|
state->frames * state->interval,
|
||||||
state->curve);
|
state->curve);
|
||||||
@ -552,11 +556,12 @@ void Animator::timerEvent(QTimerEvent *event)
|
|||||||
d->time.restart();
|
d->time.restart();
|
||||||
//kDebug() << "timeEvent, elapsed time: " << elapsed;
|
//kDebug() << "timeEvent, elapsed time: " << elapsed;
|
||||||
|
|
||||||
foreach (AnimationState* state, d->animatedItems) {
|
foreach (AnimationState *state, d->animatedItems) {
|
||||||
if (state->currentInterval <= elapsed) {
|
if (state->currentInterval <= elapsed) {
|
||||||
// we need to step forward!
|
// we need to step forward!
|
||||||
state->currentFrame += (KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
|
state->currentFrame +=
|
||||||
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
|
(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
|
||||||
|
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
|
||||||
|
|
||||||
if (state->currentFrame < state->frames) {
|
if (state->currentFrame < state->frames) {
|
||||||
qreal progress = d->calculateProgress(state->currentFrame * state->interval,
|
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) {
|
if (state->currentInterval <= elapsed) {
|
||||||
// we need to step forward!
|
// we need to step forward!
|
||||||
state->currentFrame += (KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
|
state->currentFrame +=
|
||||||
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
|
(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
|
||||||
|
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
|
||||||
|
|
||||||
if (state->currentFrame < state->frames) {
|
if (state->currentFrame < state->frames) {
|
||||||
//kDebug() << "movement";
|
//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) {
|
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
|
// since we keep element animations around until they are
|
||||||
// removed, we will end up with finished animations in the queue;
|
// removed, we will end up with finished animations in the queue;
|
||||||
// just skip them
|
// just skip them
|
||||||
@ -615,11 +622,13 @@ void Animator::timerEvent(QTimerEvent *event)
|
|||||||
|
|
||||||
if (state->currentInterval <= elapsed) {
|
if (state->currentInterval <= elapsed) {
|
||||||
// we need to step forward!
|
// we need to step forward!
|
||||||
/*kDebug() << "stepping forwards element anim " << state->id << " from " << state->currentFrame
|
/*kDebug() << "stepping forwards element anim " << state->id
|
||||||
<< " by " << qMax(1, elapsed / state->interval) << " to "
|
<< " from " << state->currentFrame
|
||||||
<< state->currentFrame + qMax(1, elapsed / state->interval) << endl;*/
|
<< " by " << qMax(1, elapsed / state->interval) << " to "
|
||||||
state->currentFrame += (KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
|
<< state->currentFrame + qMax(1, elapsed / state->interval) << endl;*/
|
||||||
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
|
state->currentFrame +=
|
||||||
|
(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
|
||||||
|
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
|
||||||
|
|
||||||
state->item->update();
|
state->item->update();
|
||||||
if (state->currentFrame < state->frames) {
|
if (state->currentFrame < state->frames) {
|
||||||
@ -639,10 +648,13 @@ void Animator::timerEvent(QTimerEvent *event)
|
|||||||
foreach (CustomAnimationState *state, d->customAnims) {
|
foreach (CustomAnimationState *state, d->customAnims) {
|
||||||
if (state->currentInterval <= elapsed) {
|
if (state->currentInterval <= elapsed) {
|
||||||
// advance the frame
|
// advance the frame
|
||||||
state->currentFrame += (KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
|
state->currentFrame +=
|
||||||
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
|
(KGlobalSettings::graphicEffectsLevel() & KGlobalSettings::SimpleAnimationEffects) ?
|
||||||
/*kDebug() << "custom anim for" << state->receiver << "to slot" << state->slot
|
qMax(1, elapsed / state->interval) : state->frames - state->currentFrame;
|
||||||
<< "with interval of" << state->interval << "at frame" << 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) {
|
if (state->currentFrame < state->frames) {
|
||||||
//kDebug () << "not the final frame";
|
//kDebug () << "not the final frame";
|
||||||
@ -696,11 +708,13 @@ void AnimatorPrivate::init(Animator *q)
|
|||||||
|
|
||||||
KPluginLoader plugin(*offers.first());
|
KPluginLoader plugin(*offers.first());
|
||||||
|
|
||||||
if (Plasma::isPluginVersionCompatible(plugin.pluginVersion()))
|
if (Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
|
||||||
driver = offers.first()->createInstance<Plasma::AnimationDriver>(0, QVariantList(), &error);
|
driver = offers.first()->createInstance<Plasma::AnimationDriver>(0, QVariantList(), &error);
|
||||||
|
}
|
||||||
|
|
||||||
if (!driver) {
|
if (!driver) {
|
||||||
kDebug() << "Could not load requested animator " << offers.first() << ". Error given: " << error;
|
kDebug() << "Could not load requested animator "
|
||||||
|
<< offers.first() << ". Error given: " << error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
172
applet.cpp
172
applet.cpp
@ -88,7 +88,7 @@ namespace Plasma
|
|||||||
{
|
{
|
||||||
|
|
||||||
Applet::Applet(QGraphicsItem *parent,
|
Applet::Applet(QGraphicsItem *parent,
|
||||||
const QString& serviceID,
|
const QString &serviceID,
|
||||||
uint appletId)
|
uint appletId)
|
||||||
: QGraphicsWidget(parent),
|
: QGraphicsWidget(parent),
|
||||||
d(new AppletPrivate(KService::serviceByStorageId(serviceID), appletId, this))
|
d(new AppletPrivate(KService::serviceByStorageId(serviceID), appletId, this))
|
||||||
@ -98,15 +98,16 @@ Applet::Applet(QGraphicsItem *parent,
|
|||||||
d->init();
|
d->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
Applet::Applet(QObject* parentObject, const QVariantList& args)
|
Applet::Applet(QObject *parentObject, const QVariantList &args)
|
||||||
: QGraphicsWidget(0),
|
: QGraphicsWidget(0),
|
||||||
d(new AppletPrivate(KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString()),
|
d(new AppletPrivate(
|
||||||
args.count() > 1 ? args[1].toInt() : 0, this))
|
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
|
// 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
|
// 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
|
// 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()) {
|
if (!mutableArgs.isEmpty()) {
|
||||||
mutableArgs.removeFirst();
|
mutableArgs.removeFirst();
|
||||||
|
|
||||||
@ -185,7 +186,8 @@ void Applet::save(KConfigGroup &g) const
|
|||||||
group.writeEntry("plugin", pluginName());
|
group.writeEntry("plugin", pluginName());
|
||||||
//FIXME: for containments, we need to have some special values here w/regards to
|
//FIXME: for containments, we need to have some special values here w/regards to
|
||||||
// screen affinity (e.g. "bottom of screen 0")
|
// 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("geometry", geometry());
|
||||||
group.writeEntry("zvalue", zValue());
|
group.writeEntry("zvalue", zValue());
|
||||||
|
|
||||||
@ -210,7 +212,6 @@ void Applet::save(KConfigGroup &g) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Applet::restore(KConfigGroup &group)
|
void Applet::restore(KConfigGroup &group)
|
||||||
{
|
{
|
||||||
QList<qreal> m = group.readEntry("transform", QList<qreal>());
|
QList<qreal> m = group.readEntry("transform", QList<qreal>());
|
||||||
@ -266,7 +267,7 @@ void AppletPrivate::setFocus()
|
|||||||
q->setFocus(Qt::ShortcutFocusReason);
|
q->setFocus(Qt::ShortcutFocusReason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Applet::setFailedToLaunch(bool failed, const QString& reason)
|
void Applet::setFailedToLaunch(bool failed, const QString &reason)
|
||||||
{
|
{
|
||||||
if (d->failed == failed) {
|
if (d->failed == failed) {
|
||||||
return;
|
return;
|
||||||
@ -302,7 +303,7 @@ void Applet::setFailedToLaunch(bool failed, const QString& reason)
|
|||||||
Plasma::ToolTipManager::self()->setToolTipContent(failureIcon, data);
|
Plasma::ToolTipManager::self()->setToolTipContent(failureIcon, data);
|
||||||
|
|
||||||
setLayout(failureLayout);
|
setLayout(failureLayout);
|
||||||
resize(300,250);
|
resize(300, 250);
|
||||||
setMinimumSize(failureLayout->minimumSize());
|
setMinimumSize(failureLayout->minimumSize());
|
||||||
d->background->resizePanel(geometry().size());
|
d->background->resizePanel(geometry().size());
|
||||||
|
|
||||||
@ -400,7 +401,7 @@ void AppletPrivate::selectItemToDestroy()
|
|||||||
q->destroy();
|
q->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletPrivate::updateRect(const QRectF& rect)
|
void AppletPrivate::updateRect(const QRectF &rect)
|
||||||
{
|
{
|
||||||
q->update(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.
|
//it probably won't matter, but right now if there are applethandles, *they* are the parent.
|
||||||
//not the containment.
|
//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()) {
|
if (parent && parent->layout()) {
|
||||||
QGraphicsLayout *l = parent->layout();
|
QGraphicsLayout *l = parent->layout();
|
||||||
for (int i = 0; i < l->count(); ++i) {
|
for (int i = 0; i < l->count(); ++i) {
|
||||||
@ -431,19 +433,19 @@ void AppletPrivate::cleanUpAndDelete()
|
|||||||
q->deleteLater();
|
q->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigXml* Applet::configScheme() const
|
ConfigXml *Applet::configScheme() const
|
||||||
{
|
{
|
||||||
return d->configXml;
|
return d->configXml;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataEngine* Applet::dataEngine(const QString& name) const
|
DataEngine *Applet::dataEngine(const QString &name) const
|
||||||
{
|
{
|
||||||
int index = d->loadedEngines.indexOf(name);
|
int index = d->loadedEngines.indexOf(name);
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
return DataEngineManager::self()->engine(name);
|
return DataEngineManager::self()->engine(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataEngine* engine = DataEngineManager::self()->loadEngine(name);
|
DataEngine *engine = DataEngineManager::self()->loadEngine(name);
|
||||||
if (engine->isValid()) {
|
if (engine->isValid()) {
|
||||||
d->loadedEngines.append(name);
|
d->loadedEngines.append(name);
|
||||||
}
|
}
|
||||||
@ -451,7 +453,7 @@ DataEngine* Applet::dataEngine(const QString& name) const
|
|||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Package* Applet::package() const
|
const Package *Applet::package() const
|
||||||
{
|
{
|
||||||
return d->package;
|
return d->package;
|
||||||
}
|
}
|
||||||
@ -469,7 +471,8 @@ QGraphicsView *Applet::view() const
|
|||||||
QGraphicsView *possibleFind = 0;
|
QGraphicsView *possibleFind = 0;
|
||||||
//kDebug() << "looking through" << scene()->views().count() << "views";
|
//kDebug() << "looking through" << scene()->views().count() << "views";
|
||||||
foreach (QGraphicsView *view, scene()->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()) ||
|
if (view->sceneRect().intersects(sceneBoundingRect()) ||
|
||||||
view->sceneRect().contains(scenePos())) {
|
view->sceneRect().contains(scenePos())) {
|
||||||
//kDebug() << " found something!" << view->isActiveWindow();
|
//kDebug() << " found something!" << view->isActiveWindow();
|
||||||
@ -487,13 +490,13 @@ QGraphicsView *Applet::view() const
|
|||||||
QRectF Applet::mapFromView(const QGraphicsView *view, const QRect &rect) const
|
QRectF Applet::mapFromView(const QGraphicsView *view, const QRect &rect) const
|
||||||
{
|
{
|
||||||
// Why is this adjustment needed? Qt calculation error?
|
// 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
|
QRect Applet::mapToView(const QGraphicsView *view, const QRectF &rect) const
|
||||||
{
|
{
|
||||||
// Why is this adjustment needed? Qt calculation error?
|
// 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
|
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.
|
// without calling the Applet:: version as well, which it shouldn't need to.
|
||||||
// INSTEAD put such code into flushPendingConstraintsEvents
|
// INSTEAD put such code into flushPendingConstraintsEvents
|
||||||
Q_UNUSED(constraints)
|
Q_UNUSED(constraints)
|
||||||
//kDebug() << constraints << "constraints are FormFactor: " << formFactor() << ", Location: " << location();
|
//kDebug() << constraints << "constraints are FormFactor: " << formFactor()
|
||||||
|
// << ", Location: " << location();
|
||||||
if (d->script) {
|
if (d->script) {
|
||||||
d->script->constraintsEvent(constraints);
|
d->script->constraintsEvent(constraints);
|
||||||
}
|
}
|
||||||
@ -589,12 +593,12 @@ QString Applet::category() const
|
|||||||
return d->appletDescription.category();
|
return d->appletDescription.category();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Applet::category(const KPluginInfo& applet)
|
QString Applet::category(const KPluginInfo &applet)
|
||||||
{
|
{
|
||||||
return applet.property("X-KDE-PluginInfo-Category").toString();
|
return applet.property("X-KDE-PluginInfo-Category").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Applet::category(const QString& appletName)
|
QString Applet::category(const QString &appletName)
|
||||||
{
|
{
|
||||||
if (appletName.isEmpty()) {
|
if (appletName.isEmpty()) {
|
||||||
return QString();
|
return QString();
|
||||||
@ -688,7 +692,8 @@ bool Applet::hasFailedToLaunch() const
|
|||||||
return d->failed;
|
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(painter)
|
||||||
Q_UNUSED(option)
|
Q_UNUSED(option)
|
||||||
@ -770,7 +775,7 @@ void Applet::flushPendingConstraintsEvents()
|
|||||||
d->constraintsTimerId = 0;
|
d->constraintsTimerId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//kDebug() << "fushing constraints: " << d->pendingConstraints << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!";
|
//kDebug() << "fushing constraints: " << d->pendingConstraints << "!!!!!!!!!!!!!!!!!!!!!!!!!!!";
|
||||||
Plasma::Constraints c = d->pendingConstraints;
|
Plasma::Constraints c = d->pendingConstraints;
|
||||||
d->pendingConstraints = NoConstraint;
|
d->pendingConstraints = NoConstraint;
|
||||||
|
|
||||||
@ -780,7 +785,7 @@ void Applet::flushPendingConstraintsEvents()
|
|||||||
//FIXME desktop containments can't be removed while in use.
|
//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
|
//it's kinda silly to have a keyboard shortcut for something that can only be used when the
|
||||||
//shortcut isn't active.
|
//shortcut isn't active.
|
||||||
QAction* closeApplet = new QAction(this);
|
QAction *closeApplet = new QAction(this);
|
||||||
closeApplet->setIcon(KIcon("edit-delete"));
|
closeApplet->setIcon(KIcon("edit-delete"));
|
||||||
closeApplet->setEnabled(unlocked);
|
closeApplet->setEnabled(unlocked);
|
||||||
closeApplet->setVisible(unlocked);
|
closeApplet->setVisible(unlocked);
|
||||||
@ -812,7 +817,7 @@ void Applet::flushPendingConstraintsEvents()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (c & Plasma::SizeConstraint && d->needsConfigOverlay) {
|
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;
|
QGraphicsItem *button = 0;
|
||||||
QList<QGraphicsItem*> children = d->needsConfigOverlay->QGraphicsItem::children();
|
QList<QGraphicsItem*> children = d->needsConfigOverlay->QGraphicsItem::children();
|
||||||
@ -840,7 +845,7 @@ void Applet::flushPendingConstraintsEvents()
|
|||||||
|
|
||||||
if (d->failed) {
|
if (d->failed) {
|
||||||
if (f == Vertical || f == Horizontal) {
|
if (f == Vertical || f == Horizontal) {
|
||||||
setMinimumSize(0,0);
|
setMinimumSize(0, 0);
|
||||||
QGraphicsLayoutItem *item = layout()->itemAt(1);
|
QGraphicsLayoutItem *item = layout()->itemAt(1);
|
||||||
layout()->removeAt(1);
|
layout()->removeAt(1);
|
||||||
delete item;
|
delete item;
|
||||||
@ -852,9 +857,9 @@ void Applet::flushPendingConstraintsEvents()
|
|||||||
if ((c & Plasma::SizeConstraint || c & Plasma::FormFactorConstraint) &&
|
if ((c & Plasma::SizeConstraint || c & Plasma::FormFactorConstraint) &&
|
||||||
aspectRatioMode() == Plasma::Square) {
|
aspectRatioMode() == Plasma::Square) {
|
||||||
if (formFactor() == Horizontal) {
|
if (formFactor() == Horizontal) {
|
||||||
setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
|
setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding));
|
||||||
} else if (formFactor() == Vertical) {
|
} else if (formFactor() == Vertical) {
|
||||||
setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
|
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
@ -864,15 +869,14 @@ void Applet::flushPendingConstraintsEvents()
|
|||||||
if ((c & Plasma::SizeConstraint || c & Plasma::FormFactorConstraint) &&
|
if ((c & Plasma::SizeConstraint || c & Plasma::FormFactorConstraint) &&
|
||||||
aspectRatioMode() == Plasma::ConstrainedSquare) {
|
aspectRatioMode() == Plasma::ConstrainedSquare) {
|
||||||
if (formFactor() == Horizontal) {
|
if (formFactor() == Horizontal) {
|
||||||
setSizePolicy(QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding));
|
setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding));
|
||||||
} else if (formFactor() == Vertical) {
|
} else if (formFactor() == Vertical) {
|
||||||
setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
|
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Containment* containment = qobject_cast<Plasma::Containment*>(this);
|
Containment* containment = qobject_cast<Plasma::Containment*>(this);
|
||||||
if (isContainment() && containment) {
|
if (isContainment() && containment) {
|
||||||
containment->d->containmentConstraintsEvent(c);
|
containment->d->containmentConstraintsEvent(c);
|
||||||
@ -901,7 +905,7 @@ QList<QAction*> Applet::contextualActions()
|
|||||||
return d->script ? d->script->contextualActions() : QList<QAction*>();
|
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);
|
return d->actions.action(name);
|
||||||
}
|
}
|
||||||
@ -948,9 +952,9 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW
|
|||||||
if (!d->failed) {
|
if (!d->failed) {
|
||||||
qreal left, top, right, bottom;
|
qreal left, top, right, bottom;
|
||||||
getContentsMargins(&left, &top, &right, &bottom);
|
getContentsMargins(&left, &top, &right, &bottom);
|
||||||
QRect contentsRect = QRectF(QPointF(0,0), boundingRect().size())
|
QRect contentsRect =
|
||||||
.adjusted(left, top, -right, -bottom).toRect();
|
QRectF(QPointF(0, 0),
|
||||||
|
boundingRect().size()).adjusted(left, top, -right, -bottom).toRect();
|
||||||
|
|
||||||
if (widget && isContainment()) {
|
if (widget && isContainment()) {
|
||||||
// note that the widget we get is actually the viewport of the view, not the view itself
|
// 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
|
FormFactor Applet::formFactor() const
|
||||||
{
|
{
|
||||||
Containment* c = containment();
|
Containment *c = containment();
|
||||||
return c ? c->d->formFactor : Plasma::Planar;
|
return c ? c->d->formFactor : Plasma::Planar;
|
||||||
}
|
}
|
||||||
|
|
||||||
Containment* Applet::containment() const
|
Containment *Applet::containment() const
|
||||||
{
|
{
|
||||||
if (isContainment()) {
|
if (isContainment()) {
|
||||||
Containment *c = dynamic_cast<Containment*>(const_cast<Applet*>(this));
|
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();
|
//kDebug() << "before" << shortcut.primary() << d->activationAction->globalShortcut().primary();
|
||||||
d->activationAction->setGlobalShortcut(shortcut,
|
d->activationAction->setGlobalShortcut(
|
||||||
KAction::ShortcutTypes(KAction::ActiveShortcut | KAction::DefaultShortcut),
|
shortcut,
|
||||||
KAction::NoAutoloading);
|
KAction::ShortcutTypes(KAction::ActiveShortcut | KAction::DefaultShortcut),
|
||||||
|
KAction::NoAutoloading);
|
||||||
//kDebug() << "after" << shortcut.primary() << d->activationAction->globalShortcut().primary();
|
//kDebug() << "after" << shortcut.primary() << d->activationAction->globalShortcut().primary();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1077,7 +1082,7 @@ Location Applet::location() const
|
|||||||
return c ? c->d->location : Plasma::Desktop;
|
return c ? c->d->location : Plasma::Desktop;
|
||||||
}
|
}
|
||||||
|
|
||||||
Context* Applet::context() const
|
Context *Applet::context() const
|
||||||
{
|
{
|
||||||
Containment *c = containment();
|
Containment *c = containment();
|
||||||
Q_ASSERT(c);
|
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);
|
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);
|
return QObject::eventFilter(o, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Applet::sceneEventFilter( QGraphicsItem * watched, QEvent * event )
|
bool Applet::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
switch (event->type()) {
|
switch (event->type()) {
|
||||||
case QEvent::GraphicsSceneMouseMove: {
|
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
|
// don't move when the containment is not mutable,
|
||||||
if ((!containment() || containment()->immutability() == Mutable) &&
|
// in the rare case the containment doesn't exists consider it as mutable
|
||||||
d->registeredAsDragHandle.contains(watched)) {
|
if ((!containment() || containment()->immutability() == Mutable) &&
|
||||||
mouseMoveEvent(static_cast<QGraphicsSceneMouseEvent*>(event));
|
d->registeredAsDragHandle.contains(watched)) {
|
||||||
return true;
|
mouseMoveEvent(static_cast<QGraphicsSceneMouseEvent*>(event));
|
||||||
}
|
return true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QGraphicsItem::sceneEventFilter(watched, event);
|
return QGraphicsItem::sceneEventFilter(watched, event);
|
||||||
@ -1198,15 +1204,16 @@ void Applet::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
// our direct parent is a containment. just move ourselves.
|
// our direct parent is a containment. just move ourselves.
|
||||||
QPointF curPos = event->pos();
|
QPointF curPos = event->pos();
|
||||||
QPointF lastPos = event->lastPos();
|
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) {
|
} 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());
|
//parent->moveBy(delta.x(),delta.y());
|
||||||
QPointF curPos = parent->transform().map(event->pos());
|
QPointF curPos = parent->transform().map(event->pos());
|
||||||
QPointF lastPos = parent->transform().map(event->lastPos());
|
QPointF lastPos = parent->transform().map(event->lastPos());
|
||||||
QPointF delta = curPos-lastPos;
|
QPointF delta = curPos - lastPos;
|
||||||
|
|
||||||
parent->setPos(parent->pos() + delta);
|
parent->setPos(parent->pos() + delta);
|
||||||
}
|
}
|
||||||
@ -1219,7 +1226,7 @@ void Applet::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
QGraphicsWidget::mousePressEvent(event);
|
QGraphicsWidget::mousePressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Applet::focusInEvent(QFocusEvent * event)
|
void Applet::focusInEvent(QFocusEvent *event)
|
||||||
{
|
{
|
||||||
if (!isContainment() && containment()) {
|
if (!isContainment() && containment()) {
|
||||||
//focusing an applet may trigger this event again, but we won't be here more than twice
|
//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?
|
//TODO: would be nice to not show dialog if there are no pages added?
|
||||||
connect(dialog, SIGNAL(finished()), nullManager, SLOT(deleteLater()));
|
connect(dialog, SIGNAL(finished()), nullManager, SLOT(deleteLater()));
|
||||||
//TODO: Apply button does not correctly work for now, so do not show it
|
//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(applyClicked()), this, SLOT(configChanged()));
|
||||||
connect(dialog, SIGNAL(okClicked()), this, SLOT(configChanged()));
|
connect(dialog, SIGNAL(okClicked()), this, SLOT(configChanged()));
|
||||||
dialog->show();
|
dialog->show();
|
||||||
@ -1333,7 +1340,7 @@ void Applet::createConfigurationInterface(KConfigDialog *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
KPluginInfo::List Applet::listAppletInfo(const QString &category,
|
KPluginInfo::List Applet::listAppletInfo(const QString &category,
|
||||||
const QString &parentApp)
|
const QString &parentApp)
|
||||||
{
|
{
|
||||||
QString constraint;
|
QString constraint;
|
||||||
|
|
||||||
@ -1355,7 +1362,8 @@ KPluginInfo::List Applet::listAppletInfo(const QString &category,
|
|||||||
}
|
}
|
||||||
|
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
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);
|
return KPluginInfo::fromServices(offers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1400,13 +1408,12 @@ QStringList Applet::listCategories(const QString &parentApp, bool visibleOnly)
|
|||||||
return categories;
|
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()) {
|
if (appletName.isEmpty()) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(appletName);
|
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(appletName);
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
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()) {
|
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) {
|
if (isContainment) {
|
||||||
return new Containment(0, offer->storageId(), appletId);
|
return new Containment(0, offer->storageId(), appletId);
|
||||||
}
|
}
|
||||||
@ -1440,7 +1448,8 @@ Applet* Applet::load(const QString& appletName, uint appletId, const QVariantLis
|
|||||||
|
|
||||||
KPluginLoader plugin(*offer);
|
KPluginLoader plugin(*offer);
|
||||||
|
|
||||||
if (!Plasma::isPluginVersionCompatible(plugin.pluginVersion()) && (appletName != "internal:extender")) {
|
if (!Plasma::isPluginVersionCompatible(plugin.pluginVersion()) &&
|
||||||
|
(appletName != "internal:extender")) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1462,7 +1471,7 @@ Applet* Applet::load(const QString& appletName, uint appletId, const QVariantLis
|
|||||||
return applet;
|
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()) {
|
if (!info.isValid()) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -1477,17 +1486,19 @@ QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value)
|
|||||||
|
|
||||||
//kDebug() << change;
|
//kDebug() << change;
|
||||||
switch (change) {
|
switch (change) {
|
||||||
case ItemSceneHasChanged: {
|
case ItemSceneHasChanged:
|
||||||
|
{
|
||||||
QGraphicsScene *newScene = qvariant_cast<QGraphicsScene*>(value);
|
QGraphicsScene *newScene = qvariant_cast<QGraphicsScene*>(value);
|
||||||
if (newScene) {
|
if (newScene) {
|
||||||
d->checkImmutability();
|
d->checkImmutability();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ItemPositionHasChanged:
|
case ItemPositionHasChanged:
|
||||||
emit geometryChanged();
|
emit geometryChanged();
|
||||||
// fall through!
|
// fall through!
|
||||||
case ItemTransformHasChanged: {
|
case ItemTransformHasChanged:
|
||||||
|
{
|
||||||
if (d->modificationsTimerId != -1) {
|
if (d->modificationsTimerId != -1) {
|
||||||
if (d->modificationsTimerId) {
|
if (d->modificationsTimerId) {
|
||||||
killTimer(d->modificationsTimerId);
|
killTimer(d->modificationsTimerId);
|
||||||
@ -1495,7 +1506,7 @@ QVariant Applet::itemChange(GraphicsItemChange change, const QVariant &value)
|
|||||||
d->modificationsTimerId = startTimer(1000);
|
d->modificationsTimerId = startTimer(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
@ -1512,7 +1523,7 @@ QPainterPath Applet::shape() const
|
|||||||
return QGraphicsWidget::shape();
|
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);
|
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) {
|
} else if (d->aspectRatioMode == Plasma::ConstrainedSquare) {
|
||||||
//enforce a size not wider than tall
|
//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());
|
hint.setWidth(size().height());
|
||||||
//enforce a size not taller than wide
|
//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());
|
hint.setHeight(size().width());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1629,7 +1642,6 @@ bool Applet::isContainment() const
|
|||||||
return d->isContainment;
|
return d->isContainment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// PRIVATE CLASS IMPLEMENTATION
|
// PRIVATE CLASS IMPLEMENTATION
|
||||||
|
|
||||||
AppletPrivate::AppletPrivate(KService::Ptr service, int uniqueID, Applet *applet)
|
AppletPrivate::AppletPrivate(KService::Ptr service, int uniqueID, Applet *applet)
|
||||||
@ -1673,8 +1685,8 @@ AppletPrivate::~AppletPrivate()
|
|||||||
activationAction->forgetGlobalShortcut();
|
activationAction->forgetGlobalShortcut();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const QString& engine, loadedEngines) {
|
foreach (const QString &engine, loadedEngines) {
|
||||||
DataEngineManager::self()->unloadEngine( engine );
|
DataEngineManager::self()->unloadEngine(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extender) {
|
if (extender) {
|
||||||
@ -1804,7 +1816,7 @@ void AppletPrivate::scheduleConstraintsUpdate(Plasma::Constraints c)
|
|||||||
pendingConstraints |= c;
|
pendingConstraints |= c;
|
||||||
}
|
}
|
||||||
|
|
||||||
KConfigGroup* AppletPrivate::mainConfigGroup()
|
KConfigGroup *AppletPrivate::mainConfigGroup()
|
||||||
{
|
{
|
||||||
if (mainConfig) {
|
if (mainConfig) {
|
||||||
return mainConfig;
|
return mainConfig;
|
||||||
@ -1839,7 +1851,7 @@ KConfigGroup* AppletPrivate::mainConfigGroup()
|
|||||||
return mainConfig;
|
return mainConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AppletPrivate::visibleFailureText(const QString& reason)
|
QString AppletPrivate::visibleFailureText(const QString &reason)
|
||||||
{
|
{
|
||||||
QString text;
|
QString text;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public:
|
|||||||
KCategorizedItemsView *appletList;
|
KCategorizedItemsView *appletList;
|
||||||
QHash<QString, int> runningApplets; // applet name => count
|
QHash<QString, int> runningApplets; // applet name => count
|
||||||
//extra hash so we can look up the names of deleted applets
|
//extra hash so we can look up the names of deleted applets
|
||||||
QHash<Plasma::Applet*, QString> appletNames;
|
QHash<Plasma::Applet *,QString> appletNames;
|
||||||
|
|
||||||
KConfig config;
|
KConfig config;
|
||||||
KConfigGroup configGroup;
|
KConfigGroup configGroup;
|
||||||
@ -112,7 +112,8 @@ void AppletBrowserWidgetPrivate::initFilters()
|
|||||||
appletList->addEmblem(i18n("Recommended by %1", caption), KIcon(icon),
|
appletList->addEmblem(i18n("Recommended by %1", caption), KIcon(icon),
|
||||||
KCategorizedItemsViewModels::Filter("recommended." + id, true));
|
KCategorizedItemsViewModels::Filter("recommended." + id, true));
|
||||||
filterModel.addFilter(i18n("Recommended by %1", caption),
|
filterModel.addFilter(i18n("Recommended by %1", caption),
|
||||||
KCategorizedItemsViewModels::Filter("recommended." + id, true), KIcon(icon));
|
KCategorizedItemsViewModels::Filter("recommended." + id, true),
|
||||||
|
KIcon(icon));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filters: Special
|
// Filters: Special
|
||||||
@ -331,7 +332,8 @@ void AppletBrowserWidget::downloadWidgets()
|
|||||||
|
|
||||||
void AppletBrowserWidget::openWidgetFile()
|
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());
|
OpenWidgetAssistant *assistant = new OpenWidgetAssistant(topLevelWidget());
|
||||||
assistant->setAttribute(Qt::WA_DeleteOnClose, true);
|
assistant->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
assistant->show();
|
assistant->show();
|
||||||
|
161
configxml.cpp
161
configxml.cpp
@ -56,144 +56,144 @@ class ConfigXmlPrivate
|
|||||||
qDeleteAll(urllists);
|
qDeleteAll(urllists);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool* newBool()
|
bool *newBool()
|
||||||
{
|
{
|
||||||
bool* v = new bool;
|
bool *v = new bool;
|
||||||
bools.append(v);
|
bools.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString* newString()
|
QString *newString()
|
||||||
{
|
{
|
||||||
QString* v = new QString;
|
QString *v = new QString;
|
||||||
strings.append(v);
|
strings.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList* newStringList()
|
QStringList *newStringList()
|
||||||
{
|
{
|
||||||
QStringList* v = new QStringList;
|
QStringList *v = new QStringList;
|
||||||
stringlists.append(v);
|
stringlists.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor* newColor()
|
QColor *newColor()
|
||||||
{
|
{
|
||||||
QColor* v = new QColor;
|
QColor *v = new QColor;
|
||||||
colors.append(v);
|
colors.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFont* newFont()
|
QFont *newFont()
|
||||||
{
|
{
|
||||||
QFont* v = new QFont;
|
QFont *v = new QFont;
|
||||||
fonts.append(v);
|
fonts.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint32* newInt()
|
qint32 *newInt()
|
||||||
{
|
{
|
||||||
qint32* v = new qint32;
|
qint32 *v = new qint32;
|
||||||
ints.append(v);
|
ints.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint32* newUint()
|
quint32 *newUint()
|
||||||
{
|
{
|
||||||
quint32* v = new quint32;
|
quint32 *v = new quint32;
|
||||||
uints.append(v);
|
uints.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
KUrl* newUrl()
|
KUrl *newUrl()
|
||||||
{
|
{
|
||||||
KUrl* v = new KUrl;
|
KUrl *v = new KUrl;
|
||||||
urls.append(v);
|
urls.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDateTime* newDateTime()
|
QDateTime *newDateTime()
|
||||||
{
|
{
|
||||||
QDateTime* v = new QDateTime;
|
QDateTime *v = new QDateTime;
|
||||||
dateTimes.append(v);
|
dateTimes.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
double* newDouble()
|
double *newDouble()
|
||||||
{
|
{
|
||||||
double* v = new double;
|
double *v = new double;
|
||||||
doubles.append(v);
|
doubles.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<qint32>* newIntList()
|
QList<qint32>* newIntList()
|
||||||
{
|
{
|
||||||
QList<qint32>* v = new QList<qint32>;
|
QList<qint32> *v = new QList<qint32>;
|
||||||
intlists.append(v);
|
intlists.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64* newLongLong()
|
qint64 *newLongLong()
|
||||||
{
|
{
|
||||||
qint64* v = new qint64;
|
qint64 *v = new qint64;
|
||||||
longlongs.append(v);
|
longlongs.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint* newPoint()
|
QPoint *newPoint()
|
||||||
{
|
{
|
||||||
QPoint* v = new QPoint;
|
QPoint *v = new QPoint;
|
||||||
points.append(v);
|
points.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect* newRect()
|
QRect *newRect()
|
||||||
{
|
{
|
||||||
QRect* v = new QRect;
|
QRect *v = new QRect;
|
||||||
rects.append(v);
|
rects.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize* newSize()
|
QSize *newSize()
|
||||||
{
|
{
|
||||||
QSize* v = new QSize;
|
QSize *v = new QSize;
|
||||||
sizes.append(v);
|
sizes.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint64* newULongLong()
|
quint64 *newULongLong()
|
||||||
{
|
{
|
||||||
quint64* v = new quint64;
|
quint64 *v = new quint64;
|
||||||
ulonglongs.append(v);
|
ulonglongs.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
KUrl::List* newUrlList()
|
KUrl::List *newUrlList()
|
||||||
{
|
{
|
||||||
KUrl::List* v = new KUrl::List;
|
KUrl::List *v = new KUrl::List;
|
||||||
urllists.append(v);
|
urllists.append(v);
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void parse(ConfigXml *configXml, QIODevice *xml);
|
void parse(ConfigXml *configXml, QIODevice *xml);
|
||||||
|
|
||||||
QList<bool*> bools;
|
QList<bool *> bools;
|
||||||
QList<QString*> strings;
|
QList<QString *> strings;
|
||||||
QList<QStringList*> stringlists;
|
QList<QStringList *> stringlists;
|
||||||
QList<QColor*> colors;
|
QList<QColor *> colors;
|
||||||
QList<QFont*> fonts;
|
QList<QFont *> fonts;
|
||||||
QList<qint32*> ints;
|
QList<qint32 *> ints;
|
||||||
QList<quint32*> uints;
|
QList<quint32 *> uints;
|
||||||
QList<KUrl*> urls;
|
QList<KUrl *> urls;
|
||||||
QList<QDateTime*> dateTimes;
|
QList<QDateTime *> dateTimes;
|
||||||
QList<double*> doubles;
|
QList<double *> doubles;
|
||||||
QList<QList<qint32>*> intlists;
|
QList<QList<qint32> *> intlists;
|
||||||
QList<qint64*> longlongs;
|
QList<qint64 *> longlongs;
|
||||||
QList<QPoint*> points;
|
QList<QPoint *> points;
|
||||||
QList<QRect*> rects;
|
QList<QRect *> rects;
|
||||||
QList<QSize*> sizes;
|
QList<QSize *> sizes;
|
||||||
QList<quint64*> ulonglongs;
|
QList<quint64 *> ulonglongs;
|
||||||
QList<KUrl::List*> urllists;
|
QList<KUrl::List *> urllists;
|
||||||
QString baseGroup;
|
QString baseGroup;
|
||||||
QStringList groups;
|
QStringList groups;
|
||||||
QHash<QString, QString> keysToNames;
|
QHash<QString, QString> keysToNames;
|
||||||
@ -202,17 +202,19 @@ class ConfigXmlPrivate
|
|||||||
class ConfigXmlHandler : public QXmlDefaultHandler
|
class ConfigXmlHandler : public QXmlDefaultHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConfigXmlHandler(ConfigXml* config, ConfigXmlPrivate* d);
|
ConfigXmlHandler(ConfigXml *config, ConfigXmlPrivate *d);
|
||||||
bool startElement(const QString &namespaceURI, const QString & localName, const QString &qName, const QXmlAttributes &atts);
|
bool startElement(const QString &namespaceURI, const QString &localName,
|
||||||
bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName);
|
const QString &qName, const QXmlAttributes &atts);
|
||||||
|
bool endElement(const QString &namespaceURI, const QString &localName,
|
||||||
|
const QString &qName);
|
||||||
bool characters(const QString &ch);
|
bool characters(const QString &ch);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void addItem();
|
void addItem();
|
||||||
void resetState();
|
void resetState();
|
||||||
|
|
||||||
ConfigXml* m_config;
|
ConfigXml *m_config;
|
||||||
ConfigXmlPrivate* d;
|
ConfigXmlPrivate *d;
|
||||||
int m_min;
|
int m_min;
|
||||||
int m_max;
|
int m_max;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
@ -238,7 +240,7 @@ void ConfigXmlPrivate::parse(ConfigXml *configXml, QIODevice *xml)
|
|||||||
reader.parse(&source, false);
|
reader.parse(&source, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigXmlHandler::ConfigXmlHandler(ConfigXml* config, ConfigXmlPrivate* d)
|
ConfigXmlHandler::ConfigXmlHandler(ConfigXml *config, ConfigXmlPrivate *d)
|
||||||
: QXmlDefaultHandler(),
|
: QXmlDefaultHandler(),
|
||||||
m_config(config),
|
m_config(config),
|
||||||
d(d)
|
d(d)
|
||||||
@ -306,7 +308,8 @@ bool ConfigXmlHandler::characters(const QString &ch)
|
|||||||
return true;
|
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(namespaceURI)
|
||||||
Q_UNUSED(qName)
|
Q_UNUSED(qName)
|
||||||
@ -349,7 +352,7 @@ void ConfigXmlHandler::addItem()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
KConfigSkeletonItem* item = 0;
|
KConfigSkeletonItem *item = 0;
|
||||||
|
|
||||||
if (m_type == "bool") {
|
if (m_type == "bool") {
|
||||||
bool defaultValue = m_default.toLower() == "true";
|
bool defaultValue = m_default.toLower() == "true";
|
||||||
@ -361,17 +364,17 @@ void ConfigXmlHandler::addItem()
|
|||||||
QDateTime::fromString(m_default), m_key);
|
QDateTime::fromString(m_default), m_key);
|
||||||
} else if (m_type == "enum") {
|
} else if (m_type == "enum") {
|
||||||
m_key = (m_key.isEmpty()) ? m_name : m_key;
|
m_key = (m_key.isEmpty()) ? m_name : m_key;
|
||||||
KConfigSkeleton::ItemEnum* enumItem =
|
KConfigSkeleton::ItemEnum *enumItem =
|
||||||
new KConfigSkeleton::ItemEnum(m_config->currentGroup(),
|
new KConfigSkeleton::ItemEnum(m_config->currentGroup(),
|
||||||
m_key, *d->newInt(),
|
m_key, *d->newInt(),
|
||||||
m_enumChoices,
|
m_enumChoices,
|
||||||
m_default.toUInt());
|
m_default.toUInt());
|
||||||
m_config->addItem(enumItem, m_name);
|
m_config->addItem(enumItem, m_name);
|
||||||
item = enumItem;
|
item = enumItem;
|
||||||
} else if (m_type == "font") {
|
} else if (m_type == "font") {
|
||||||
item = m_config->addItemFont(m_name, *d->newFont(), QFont(m_default), m_key);
|
item = m_config->addItemFont(m_name, *d->newFont(), QFont(m_default), m_key);
|
||||||
} else if (m_type == "int") {
|
} 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);
|
m_default.toInt(), m_key);
|
||||||
|
|
||||||
if (m_haveMin) {
|
if (m_haveMin) {
|
||||||
@ -391,12 +394,11 @@ void ConfigXmlHandler::addItem()
|
|||||||
item = m_config->addItemString(m_name, *d->newString(), m_default, m_key);
|
item = m_config->addItemString(m_name, *d->newString(), m_default, m_key);
|
||||||
} else if (m_type == "stringlist") {
|
} else if (m_type == "stringlist") {
|
||||||
//FIXME: the split() is naive and will break on lists with ,'s in them
|
//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") {
|
} else if (m_type == "uint") {
|
||||||
KConfigSkeleton::ItemUInt* uintItem = m_config->addItemUInt(m_name,
|
KConfigSkeleton::ItemUInt *uintItem =
|
||||||
*d->newUint(),
|
m_config->addItemUInt(m_name, *d->newUint(), m_default.toUInt(), m_key);
|
||||||
m_default.toUInt(),
|
|
||||||
m_key);
|
|
||||||
if (m_haveMin) {
|
if (m_haveMin) {
|
||||||
uintItem->setMinValue(m_min);
|
uintItem->setMinValue(m_min);
|
||||||
}
|
}
|
||||||
@ -406,14 +408,14 @@ void ConfigXmlHandler::addItem()
|
|||||||
item = uintItem;
|
item = uintItem;
|
||||||
} else if (m_type == "url") {
|
} else if (m_type == "url") {
|
||||||
m_key = (m_key.isEmpty()) ? m_name : m_key;
|
m_key = (m_key.isEmpty()) ? m_name : m_key;
|
||||||
KConfigSkeleton::ItemUrl* urlItem =
|
KConfigSkeleton::ItemUrl *urlItem =
|
||||||
new KConfigSkeleton::ItemUrl(m_config->currentGroup(),
|
new KConfigSkeleton::ItemUrl(m_config->currentGroup(),
|
||||||
m_key, *d->newUrl(),
|
m_key, *d->newUrl(),
|
||||||
m_default);
|
m_default);
|
||||||
m_config->addItem(urlItem, m_name);
|
m_config->addItem(urlItem, m_name);
|
||||||
item = urlItem;
|
item = urlItem;
|
||||||
} else if (m_type == "double") {
|
} 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);
|
*d->newDouble(), m_default.toDouble(), m_key);
|
||||||
if (m_haveMin) {
|
if (m_haveMin) {
|
||||||
doubleItem->setMinValue(m_min);
|
doubleItem->setMinValue(m_min);
|
||||||
@ -430,7 +432,7 @@ void ConfigXmlHandler::addItem()
|
|||||||
}
|
}
|
||||||
item = m_config->addItemIntList(m_name, *d->newIntList(), defaultList, m_key);
|
item = m_config->addItemIntList(m_name, *d->newIntList(), defaultList, m_key);
|
||||||
} else if (m_type == "longlong") {
|
} 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);
|
*d->newLongLong(), m_default.toLongLong(), m_key);
|
||||||
if (m_haveMin) {
|
if (m_haveMin) {
|
||||||
longlongItem->setMinValue(m_min);
|
longlongItem->setMinValue(m_min);
|
||||||
@ -442,7 +444,8 @@ void ConfigXmlHandler::addItem()
|
|||||||
/* No addItemPathList in KConfigSkeleton ?
|
/* No addItemPathList in KConfigSkeleton ?
|
||||||
} else if (m_type == "PathList") {
|
} else if (m_type == "PathList") {
|
||||||
//FIXME: the split() is naive and will break on lists with ,'s in them
|
//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") {
|
} else if (m_type == "point") {
|
||||||
QPoint defaultPoint;
|
QPoint defaultPoint;
|
||||||
QStringList tmpList = m_default.split(",");
|
QStringList tmpList = m_default.split(",");
|
||||||
@ -468,8 +471,8 @@ void ConfigXmlHandler::addItem()
|
|||||||
}
|
}
|
||||||
item = m_config->addItemSize(m_name, *d->newSize(), defaultSize, m_key);
|
item = m_config->addItemSize(m_name, *d->newSize(), defaultSize, m_key);
|
||||||
} else if (m_type == "ulonglong") {
|
} else if (m_type == "ulonglong") {
|
||||||
KConfigSkeleton::ItemULongLong* ulonglongItem = m_config->addItemULongLong(m_name,
|
KConfigSkeleton::ItemULongLong *ulonglongItem =
|
||||||
*d->newULongLong(), m_default.toULongLong(), m_key);
|
m_config->addItemULongLong(m_name, *d->newULongLong(), m_default.toULongLong(), m_key);
|
||||||
if (m_haveMin) {
|
if (m_haveMin) {
|
||||||
ulonglongItem->setMinValue(m_min);
|
ulonglongItem->setMinValue(m_min);
|
||||||
}
|
}
|
||||||
@ -546,7 +549,7 @@ ConfigXml::~ConfigXml()
|
|||||||
delete d;
|
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]);
|
return KConfigSkeleton::findItem(d->keysToNames[group + key]);
|
||||||
}
|
}
|
||||||
|
107
containment.cpp
107
containment.cpp
@ -163,9 +163,11 @@ void Containment::init()
|
|||||||
if (immutability() != SystemImmutable) {
|
if (immutability() != SystemImmutable) {
|
||||||
//FIXME I'm not certain this belongs in Containment
|
//FIXME I'm not certain this belongs in Containment
|
||||||
//but it sure is nice to have the keyboard shortcut in every containment by default
|
//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"));
|
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->setShortcutContext(Qt::WidgetShortcut);
|
||||||
lockDesktopAction->setShortcut(QKeySequence("ctrl+l"));
|
lockDesktopAction->setShortcut(QKeySequence("ctrl+l"));
|
||||||
d->actions().addAction("lock widgets", lockDesktopAction);
|
d->actions().addAction("lock widgets", lockDesktopAction);
|
||||||
@ -210,7 +212,7 @@ void Containment::init()
|
|||||||
d->toolBox->addTool(this->action("add sibling containment"));
|
d->toolBox->addTool(this->action("add sibling containment"));
|
||||||
if (hasConfigurationInterface()) {
|
if (hasConfigurationInterface()) {
|
||||||
// re-use the contianment's action.
|
// re-use the contianment's action.
|
||||||
QAction* configureContainment = this->action("configure");
|
QAction *configureContainment = this->action("configure");
|
||||||
if (configureContainment) {
|
if (configureContainment) {
|
||||||
d->toolBox->addTool(this->action("configure"));
|
d->toolBox->addTool(this->action("configure"));
|
||||||
}
|
}
|
||||||
@ -310,7 +312,7 @@ void Containment::save(KConfigGroup &g) const
|
|||||||
void Containment::saveContents(KConfigGroup &group) const
|
void Containment::saveContents(KConfigGroup &group) const
|
||||||
{
|
{
|
||||||
KConfigGroup applets(&group, "Applets");
|
KConfigGroup applets(&group, "Applets");
|
||||||
foreach (const Applet* applet, d->applets) {
|
foreach (const Applet *applet, d->applets) {
|
||||||
KConfigGroup appletConfig(&applets, QString::number(applet->id()));
|
KConfigGroup appletConfig(&applets, QString::number(applet->id()));
|
||||||
applet->save(appletConfig);
|
applet->save(appletConfig);
|
||||||
}
|
}
|
||||||
@ -338,7 +340,9 @@ void Containment::restoreContents(KConfigGroup &group)
|
|||||||
continue;
|
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);
|
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) {
|
if (item == q) {
|
||||||
item = 0;
|
item = 0;
|
||||||
}
|
}
|
||||||
@ -481,7 +486,7 @@ bool ContainmentPrivate::showContextMenu(const QPointF &point, const QPoint &scr
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (applet->hasConfigurationInterface()) {
|
if (applet->hasConfigurationInterface()) {
|
||||||
QAction* configureApplet = applet->d->actions.action("configure");
|
QAction *configureApplet = applet->d->actions.action("configure");
|
||||||
if (configureApplet) {
|
if (configureApplet) {
|
||||||
desktopMenu.addAction(configureApplet);
|
desktopMenu.addAction(configureApplet);
|
||||||
hasEntries = true;
|
hasEntries = true;
|
||||||
@ -502,7 +507,7 @@ bool ContainmentPrivate::showContextMenu(const QPointF &point, const QPoint &scr
|
|||||||
desktopMenu.addMenu(containmentActionMenu);
|
desktopMenu.addMenu(containmentActionMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (QAction* action, containmentActions) {
|
foreach (QAction *action, containmentActions) {
|
||||||
if (action) {
|
if (action) {
|
||||||
containmentActionMenu->addAction(action);
|
containmentActionMenu->addAction(action);
|
||||||
}
|
}
|
||||||
@ -514,7 +519,7 @@ bool ContainmentPrivate::showContextMenu(const QPointF &point, const QPoint &scr
|
|||||||
desktopMenu.addSeparator();
|
desktopMenu.addSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction* closeApplet = applet->d->actions.action("remove");
|
QAction *closeApplet = applet->d->actions.action("remove");
|
||||||
if (!closeApplet) { //unlikely but not impossible
|
if (!closeApplet) { //unlikely but not impossible
|
||||||
kDebug() << "no remove action!!!!!!!!";
|
kDebug() << "no remove action!!!!!!!!";
|
||||||
closeApplet = new QAction(i18n("Remove this %1", applet->name()), &desktopMenu);
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (QAction* action, actions) {
|
foreach (QAction *action, actions) {
|
||||||
if (action) {
|
if (action) {
|
||||||
desktopMenu.addAction(action);
|
desktopMenu.addAction(action);
|
||||||
}
|
}
|
||||||
@ -600,7 +605,7 @@ void Containment::setLocation(Location location)
|
|||||||
|
|
||||||
d->location = location;
|
d->location = location;
|
||||||
|
|
||||||
foreach (Applet* applet, d->applets) {
|
foreach (Applet *applet, d->applets) {
|
||||||
applet->updateConstraints(Plasma::LocationConstraint);
|
applet->updateConstraints(Plasma::LocationConstraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -631,7 +636,8 @@ void Containment::clearApplets()
|
|||||||
d->applets.clear();
|
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);
|
return d->addApplet(name, args, appletGeometry);
|
||||||
}
|
}
|
||||||
@ -721,16 +727,20 @@ void Containment::setScreen(int screen)
|
|||||||
#ifndef Q_OS_WIN
|
#ifndef Q_OS_WIN
|
||||||
// we want to listen to changes in work area if our screen changes
|
// we want to listen to changes in work area if our screen changes
|
||||||
if (d->screen < 0 && screen > -1) {
|
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) {
|
} else if (screen < 0) {
|
||||||
disconnect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SLOT(positionToolBox()));
|
disconnect(KWindowSystem::self(), SIGNAL(workAreaChanged()),
|
||||||
|
this, SLOT(positionToolBox()));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (screen > -1 && corona()) {
|
if (screen > -1 && corona()) {
|
||||||
// sanity check to make sure someone else doesn't have this screen already!
|
// 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) {
|
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);
|
currently->setScreen(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -790,7 +800,8 @@ QPoint Containment::effectiveScreenPos() const
|
|||||||
return QPoint(r.left(), r.top() + (p.bottom() + INTER_CONTAINMENT_MARGIN));
|
return QPoint(r.left(), r.top() + (p.bottom() + INTER_CONTAINMENT_MARGIN));
|
||||||
break;
|
break;
|
||||||
case RightEdge:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
//FIXME: implement properly for Floating!
|
//FIXME: implement properly for Floating!
|
||||||
@ -890,7 +901,7 @@ void Containment::dropEvent(QGraphicsSceneDragDropEvent *event)
|
|||||||
//TODO: collect the mimetypes of available script engines and offer
|
//TODO: collect the mimetypes of available script engines and offer
|
||||||
// to create widgets out of the matching URLs, if any
|
// to create widgets out of the matching URLs, if any
|
||||||
KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
|
KUrl::List urls = KUrl::List::fromMimeData(event->mimeData());
|
||||||
foreach (const KUrl& url, urls) {
|
foreach (const KUrl &url, urls) {
|
||||||
KMimeType::Ptr mime = KMimeType::findByUrl(url);
|
KMimeType::Ptr mime = KMimeType::findByUrl(url);
|
||||||
QString mimeName = mime->name();
|
QString mimeName = mime->name();
|
||||||
QRectF geom(event->pos(), QSize());
|
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
|
//TODO: should we show a dialog here to choose which plasmoid load if
|
||||||
//!appletList.isEmpty()
|
//!appletList.isEmpty()
|
||||||
QMenu choices;
|
QMenu choices;
|
||||||
QHash<QAction*, QString> actionsToPlugins;
|
QHash<QAction *, QString> actionsToPlugins;
|
||||||
foreach (const KPluginInfo &info, appletList) {
|
foreach (const KPluginInfo &info, appletList) {
|
||||||
QAction *action;
|
QAction *action;
|
||||||
if (!info.icon().isEmpty()) {
|
if (!info.icon().isEmpty()) {
|
||||||
@ -955,7 +966,7 @@ void Containment::dropEvent(QGraphicsSceneDragDropEvent *event)
|
|||||||
selectedPlugin = seenPlugins.constBegin().key();
|
selectedPlugin = seenPlugins.constBegin().key();
|
||||||
} else {
|
} else {
|
||||||
QMenu choices;
|
QMenu choices;
|
||||||
QHash<QAction*, QString > actionsToPlugins;
|
QHash<QAction *, QString> actionsToPlugins;
|
||||||
foreach (const KPluginInfo &info, seenPlugins) {
|
foreach (const KPluginInfo &info, seenPlugins) {
|
||||||
QAction *action;
|
QAction *action;
|
||||||
if (!info.icon().isEmpty()) {
|
if (!info.icon().isEmpty()) {
|
||||||
@ -985,7 +996,6 @@ void Containment::dropEvent(QGraphicsSceneDragDropEvent *event)
|
|||||||
stream.writeRawData(data, data.size());
|
stream.writeRawData(data, data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QRectF geom(event->pos(), QSize());
|
QRectF geom(event->pos(), QSize());
|
||||||
QVariantList args;
|
QVariantList args;
|
||||||
args << tempFile.fileName();
|
args << tempFile.fileName();
|
||||||
@ -1008,7 +1018,8 @@ void Containment::resizeEvent(QGraphicsSceneResizeEvent *event)
|
|||||||
|
|
||||||
void Containment::keyPressEvent(QKeyEvent *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 (event->key() == Qt::Key_Tab) { // && event->modifiers() == 0) {
|
||||||
if (!d->applets.isEmpty()) {
|
if (!d->applets.isEmpty()) {
|
||||||
kDebug() << "let's give focus to...." << (QObject*)d->applets.first();
|
kDebug() << "let's give focus to...." << (QObject*)d->applets.first();
|
||||||
@ -1020,7 +1031,7 @@ void Containment::keyPressEvent(QKeyEvent *event)
|
|||||||
void Containment::wheelEvent(QGraphicsSceneWheelEvent *event)
|
void Containment::wheelEvent(QGraphicsSceneWheelEvent *event)
|
||||||
{
|
{
|
||||||
if (d->wallpaper) {
|
if (d->wallpaper) {
|
||||||
QGraphicsItem* item = scene()->itemAt(event->scenePos());
|
QGraphicsItem *item = scene()->itemAt(event->scenePos());
|
||||||
if (item == this) {
|
if (item == this) {
|
||||||
event->ignore();
|
event->ignore();
|
||||||
d->wallpaper->wheelEvent(event);
|
d->wallpaper->wheelEvent(event);
|
||||||
@ -1034,7 +1045,7 @@ void Containment::wheelEvent(QGraphicsSceneWheelEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (containmentType() == DesktopContainment) {
|
if (containmentType() == DesktopContainment) {
|
||||||
QGraphicsItem* item = scene()->itemAt(event->scenePos());
|
QGraphicsItem *item = scene()->itemAt(event->scenePos());
|
||||||
if (item == this) {
|
if (item == this) {
|
||||||
int numDesktops = KWindowSystem::numberOfDesktops();
|
int numDesktops = KWindowSystem::numberOfDesktops();
|
||||||
int currentDesktop = KWindowSystem::currentDesktop();
|
int currentDesktop = KWindowSystem::currentDesktop();
|
||||||
@ -1059,7 +1070,7 @@ bool Containment::sceneEventFilter(QGraphicsItem *watched, QEvent *event)
|
|||||||
Applet *applet = qgraphicsitem_cast<Applet*>(watched);
|
Applet *applet = qgraphicsitem_cast<Applet*>(watched);
|
||||||
|
|
||||||
// Otherwise we're watching something we shouldn't be...
|
// Otherwise we're watching something we shouldn't be...
|
||||||
Q_ASSERT(applet!=0);
|
Q_ASSERT(applet != 0);
|
||||||
if (!d->applets.contains(applet)) {
|
if (!d->applets.contains(applet)) {
|
||||||
return false;
|
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
|
//FIXME if the applet is moved to another containment we need to unfocus it
|
||||||
|
|
||||||
if (isContainment() &&
|
if (isContainment() &&
|
||||||
(change == QGraphicsItem::ItemSceneHasChanged || change == QGraphicsItem::ItemPositionHasChanged) &&
|
(change == QGraphicsItem::ItemSceneHasChanged ||
|
||||||
!d->positioning) {
|
change == QGraphicsItem::ItemPositionHasChanged) && !d->positioning) {
|
||||||
switch (containmentType()) {
|
switch (containmentType()) {
|
||||||
case PanelContainment:
|
case PanelContainment:
|
||||||
case CustomPanelContainment:
|
case CustomPanelContainment:
|
||||||
@ -1162,7 +1173,7 @@ void Containment::addAssociatedWidget(QWidget *widget)
|
|||||||
d->focusedApplet->addAssociatedWidget(widget);
|
d->focusedApplet->addAssociatedWidget(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const Applet* applet, d->applets) {
|
foreach (const Applet *applet, d->applets) {
|
||||||
if (applet->d->activationAction) {
|
if (applet->d->activationAction) {
|
||||||
widget->addAction(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;
|
return d->wallpaper;
|
||||||
}
|
}
|
||||||
@ -1283,7 +1294,7 @@ QString Containment::activity() const
|
|||||||
return d->context()->currentActivity();
|
return d->context()->currentActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
Context* ContainmentPrivate::context()
|
Context *ContainmentPrivate::context()
|
||||||
{
|
{
|
||||||
if (!con) {
|
if (!con) {
|
||||||
con = new Context(q);
|
con = new Context(q);
|
||||||
@ -1294,7 +1305,7 @@ Context* ContainmentPrivate::context()
|
|||||||
return con;
|
return con;
|
||||||
}
|
}
|
||||||
|
|
||||||
KActionCollection& ContainmentPrivate::actions()
|
KActionCollection &ContainmentPrivate::actions()
|
||||||
{
|
{
|
||||||
return static_cast<Applet*>(q)->d->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
|
//FIXME maybe that %1 should be the containment type not the name
|
||||||
if (!confirm ||
|
if (!confirm ||
|
||||||
KMessageBox::warningContinueCancel(view(), i18n("Do you really want to remove this %1?", name()),
|
KMessageBox::warningContinueCancel(
|
||||||
i18n("Remove %1", name()), KStandardGuiItem::remove()) == KMessageBox::Continue) {
|
view(),
|
||||||
|
i18n("Do you really want to remove this %1?", name()),
|
||||||
|
i18n("Remove %1", name()), KStandardGuiItem::remove()) == KMessageBox::Continue) {
|
||||||
//clearApplets();
|
//clearApplets();
|
||||||
Applet::destroy();
|
Applet::destroy();
|
||||||
}
|
}
|
||||||
@ -1441,7 +1454,7 @@ void ContainmentPrivate::zoomOut()
|
|||||||
positionToolBox();
|
positionToolBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolBox* ContainmentPrivate::createToolBox()
|
ToolBox *ContainmentPrivate::createToolBox()
|
||||||
{
|
{
|
||||||
if (!toolBox) {
|
if (!toolBox) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -1479,14 +1492,17 @@ void ContainmentPrivate::positionToolBox()
|
|||||||
if (type == Containment::PanelContainment) {
|
if (type == Containment::PanelContainment) {
|
||||||
if (q->formFactor() == Vertical) {
|
if (q->formFactor() == Vertical) {
|
||||||
toolBox->setCorner(ToolBox::Bottom);
|
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
|
//defaulting to Horizontal right now
|
||||||
} else {
|
} else {
|
||||||
if (QApplication::layoutDirection() == Qt::RightToLeft) {
|
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);
|
toolBox->setCorner(ToolBox::Left);
|
||||||
} else {
|
} 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);
|
toolBox->setCorner(ToolBox::Right);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1624,8 +1640,8 @@ void ContainmentPrivate::containmentConstraintsEvent(Plasma::Constraints constra
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Applet* ContainmentPrivate::addApplet(const QString& name, const QVariantList& args,
|
Applet *ContainmentPrivate::addApplet(const QString &name, const QVariantList &args,
|
||||||
const QRectF& appletGeometry, uint id, bool delayInit)
|
const QRectF &appletGeometry, uint id, bool delayInit)
|
||||||
{
|
{
|
||||||
if (!q->isContainment()) {
|
if (!q->isContainment()) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -1641,7 +1657,7 @@ Applet* ContainmentPrivate::addApplet(const QString& name, const QVariantList& a
|
|||||||
v->setCursor(Qt::BusyCursor);
|
v->setCursor(Qt::BusyCursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
Applet* applet = Applet::load(name, id, args);
|
Applet *applet = Applet::load(name, id, args);
|
||||||
if (v) {
|
if (v) {
|
||||||
v->unsetCursor();
|
v->unsetCursor();
|
||||||
}
|
}
|
||||||
@ -1668,7 +1684,7 @@ bool ContainmentPrivate::regionIsEmpty(const QRectF ®ion, Applet *ignoredAppl
|
|||||||
return true;
|
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
|
// 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
|
// 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
|
// NOTE: DO NOT USE THE applet VARIABLE FOR ANYTHING OTHER THAN COMPARING
|
||||||
// THE ADDRESS! ACTUALLY USING THE OBJECT WILL RESULT IN A CRASH!!!
|
// 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);
|
applets.removeAll(applet);
|
||||||
if (focusedApplet == applet) {
|
if (focusedApplet == applet) {
|
||||||
focusedApplet = 0;
|
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
|
// this should be ok for small numbers of panels, but if we ever end
|
||||||
// up managing hundreds of them, this simplistic alogrithm will
|
// up managing hundreds of them, this simplistic alogrithm will
|
||||||
// likely be too slow.
|
// likely be too slow.
|
||||||
foreach (const Containment* other, q->corona()->containments()) {
|
foreach (const Containment *other, q->corona()->containments()) {
|
||||||
if (other == q ||
|
if (other == q ||
|
||||||
(other->containmentType() != Containment::PanelContainment &&
|
(other->containmentType() != Containment::PanelContainment &&
|
||||||
other->containmentType() != Containment::CustomPanelContainment) ||
|
other->containmentType() != Containment::CustomPanelContainment) ||
|
||||||
@ -1892,7 +1908,6 @@ void ContainmentPrivate::positionPanel(bool force)
|
|||||||
positioning = false;
|
positioning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
|
||||||
#include "containment.moc"
|
#include "containment.moc"
|
||||||
|
41
corona.cpp
41
corona.cpp
@ -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
|
// 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
|
// point anymore since we are in the qobject dtor. we don't actually
|
||||||
@ -112,11 +112,12 @@ public:
|
|||||||
emit q->configSynced();
|
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;
|
QString pluginName = name;
|
||||||
Containment* containment = 0;
|
Containment *containment = 0;
|
||||||
Applet* applet = 0;
|
Applet *applet = 0;
|
||||||
|
|
||||||
//kDebug() << "Loading" << name << args << id;
|
//kDebug() << "Loading" << name << args << id;
|
||||||
|
|
||||||
@ -133,7 +134,8 @@ public:
|
|||||||
if (!containment) {
|
if (!containment) {
|
||||||
kDebug() << "loading of containment" << name << "failed.";
|
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;
|
delete applet;
|
||||||
containment = new Containment(0, 0, id);
|
containment = new Containment(0, 0, id);
|
||||||
|
|
||||||
@ -158,9 +160,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
containments.append(containment);
|
containments.append(containment);
|
||||||
QObject::connect(containment, SIGNAL(destroyed(QObject*)), q, SLOT(containmentDestroyed(QObject*)));
|
QObject::connect(containment, SIGNAL(destroyed(QObject*)),
|
||||||
QObject::connect(containment, SIGNAL(configNeedsSaving()), q, SLOT(requestConfigSync()));
|
q, SLOT(containmentDestroyed(QObject*)));
|
||||||
QObject::connect(containment, SIGNAL(releaseVisualFocus()), q, SIGNAL(releaseVisualFocus()));
|
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*)),
|
QObject::connect(containment, SIGNAL(screenChanged(int,int,Plasma::Containment*)),
|
||||||
q, SIGNAL(screenOwnerChanged(int,int,Plasma::Containment*)));
|
q, SIGNAL(screenOwnerChanged(int,int,Plasma::Containment*)));
|
||||||
|
|
||||||
@ -204,7 +209,7 @@ Corona::~Corona()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Corona::setAppletMimeType(const QString& type)
|
void Corona::setAppletMimeType(const QString &type)
|
||||||
{
|
{
|
||||||
d->mimetype = type;
|
d->mimetype = type;
|
||||||
}
|
}
|
||||||
@ -261,7 +266,7 @@ void Corona::initializeLayout(const QString &configName)
|
|||||||
setImmutability((ImmutabilityType)coronaConfig.readEntry("immutability", (int)Mutable));
|
setImmutability((ImmutabilityType)coronaConfig.readEntry("immutability", (int)Mutable));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Corona::loadLayout(const QString& configName)
|
void Corona::loadLayout(const QString &configName)
|
||||||
{
|
{
|
||||||
KSharedConfigPtr c;
|
KSharedConfigPtr c;
|
||||||
|
|
||||||
@ -273,7 +278,7 @@ void Corona::loadLayout(const QString& configName)
|
|||||||
|
|
||||||
KConfigGroup containments(config(), "Containments");
|
KConfigGroup containments(config(), "Containments");
|
||||||
|
|
||||||
foreach (const QString& group, containments.groupList()) {
|
foreach (const QString &group, containments.groupList()) {
|
||||||
KConfigGroup containmentConfig(&containments, group);
|
KConfigGroup containmentConfig(&containments, group);
|
||||||
|
|
||||||
if (containmentConfig.entryMap().isEmpty()) {
|
if (containmentConfig.entryMap().isEmpty()) {
|
||||||
@ -293,11 +298,11 @@ void Corona::loadLayout(const QString& configName)
|
|||||||
c->restore(containmentConfig);
|
c->restore(containmentConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (Containment* containment, d->containments) {
|
foreach (Containment *containment, d->containments) {
|
||||||
QString cid = QString::number(containment->id());
|
QString cid = QString::number(containment->id());
|
||||||
KConfigGroup containmentConfig(&containments, cid);
|
KConfigGroup containmentConfig(&containments, cid);
|
||||||
|
|
||||||
foreach(Applet* applet, containment->applets()) {
|
foreach (Applet *applet, containment->applets()) {
|
||||||
applet->init();
|
applet->init();
|
||||||
// We have to flush the applet constraints manually
|
// We have to flush the applet constraints manually
|
||||||
applet->flushPendingConstraintsEvents();
|
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 &&
|
if (containment->screen() == screen &&
|
||||||
(containment->containmentType() == Containment::DesktopContainment ||
|
(containment->containmentType() == Containment::DesktopContainment ||
|
||||||
containment->containmentType() >= Containment::CustomContainment)) {
|
containment->containmentType() >= Containment::CustomContainment)) {
|
||||||
@ -329,7 +334,7 @@ QList<Containment*> Corona::containments() const
|
|||||||
|
|
||||||
void Corona::clearContainments()
|
void Corona::clearContainments()
|
||||||
{
|
{
|
||||||
foreach (Containment* containment, d->containments) {
|
foreach (Containment *containment, d->containments) {
|
||||||
containment->clearApplets();
|
containment->clearApplets();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -343,12 +348,12 @@ KSharedConfigPtr Corona::config() const
|
|||||||
return d->config;
|
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);
|
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);
|
return d->addContainment(name, args, 0, true);
|
||||||
}
|
}
|
||||||
|
@ -41,15 +41,14 @@
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
|
DataEngine::DataEngine(QObject *parent, KService::Ptr service)
|
||||||
DataEngine::DataEngine(QObject* parent, KService::Ptr service)
|
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new DataEnginePrivate(this, service))
|
d(new DataEnginePrivate(this, service))
|
||||||
{
|
{
|
||||||
connect(d->updateTimer, SIGNAL(timeout()), this, SLOT(scheduleSourcesUpdated()));
|
connect(d->updateTimer, SIGNAL(timeout()), this, SLOT(scheduleSourcesUpdated()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DataEngine::DataEngine(QObject* parent, const QVariantList& args)
|
DataEngine::DataEngine(QObject *parent, const QVariantList &args)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new DataEnginePrivate(this, KService::serviceByStorageId(args.count() > 0 ? args[0].toString() : QString())))
|
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();
|
return d->sources.keys();
|
||||||
}
|
}
|
||||||
|
|
||||||
Service* DataEngine::serviceForSource(const QString &source)
|
Service *DataEngine::serviceForSource(const QString &source)
|
||||||
{
|
{
|
||||||
return new NullService(source, this);
|
return new NullService(source, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataEngine::connectSource(const QString& source, QObject* visualization,
|
void DataEngine::connectSource(const QString &source, QObject *visualization,
|
||||||
uint pollingInterval, Plasma::IntervalAlignment intervalAlignment) const
|
uint pollingInterval,
|
||||||
|
Plasma::IntervalAlignment intervalAlignment) const
|
||||||
{
|
{
|
||||||
//kDebug() << "connectSource" << source;
|
//kDebug() << "connectSource" << source;
|
||||||
bool newSource;
|
bool newSource;
|
||||||
DataContainer* s = d->requestSource(source, &newSource);
|
DataContainer *s = d->requestSource(source, &newSource);
|
||||||
|
|
||||||
if (s) {
|
if (s) {
|
||||||
// we suppress the immediate invocation of dataUpdated here if the source was prexisting and they
|
// we suppress the immediate invocation of dataUpdated here if the
|
||||||
// don't request delayed updates (we want to do an immediate update in that case so they
|
// source was prexisting and they don't request delayed updates
|
||||||
// don't have to wait for the first time out)
|
// (we want to do an immediate update in that case so they don't
|
||||||
d->connectSource(s, visualization, pollingInterval, intervalAlignment, !newSource || pollingInterval > 0);
|
// have to wait for the first time out)
|
||||||
|
d->connectSource(s, visualization, pollingInterval, intervalAlignment,
|
||||||
|
!newSource || pollingInterval > 0);
|
||||||
//kDebug() << " ==> source connected";
|
//kDebug() << " ==> source connected";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataEngine::connectAllSources(QObject* visualization, uint pollingInterval,
|
void DataEngine::connectAllSources(QObject *visualization, uint pollingInterval,
|
||||||
Plasma::IntervalAlignment intervalAlignment) const
|
Plasma::IntervalAlignment intervalAlignment) const
|
||||||
{
|
{
|
||||||
foreach (DataContainer* s, d->sources) {
|
foreach (DataContainer *s, d->sources) {
|
||||||
d->connectSource(s, visualization, pollingInterval, intervalAlignment);
|
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) {
|
if (s) {
|
||||||
s->disconnectVisualization(visualization);
|
s->disconnectVisualization(visualization);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DataContainer* DataEngine::containerForSource(const QString &source)
|
DataContainer *DataEngine::containerForSource(const QString &source)
|
||||||
{
|
{
|
||||||
return d->source(source, false);
|
return d->source(source, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
DataEngine::Data DataEngine::query(const QString& source) const
|
DataEngine::Data DataEngine::query(const QString &source) const
|
||||||
{
|
{
|
||||||
bool newSource;
|
bool newSource;
|
||||||
DataContainer* s = d->requestSource(source, &newSource);
|
DataContainer *s = d->requestSource(source, &newSource);
|
||||||
|
|
||||||
if (!s) {
|
if (!s) {
|
||||||
return DataEngine::Data();
|
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) {
|
if (d->script) {
|
||||||
return d->script->updateSourceEvent(source);
|
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);
|
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;
|
bool isNew = !s;
|
||||||
|
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
@ -204,25 +206,25 @@ void DataEngine::setData(const QString &source, const Data &data)
|
|||||||
d->queueUpdate();
|
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) {
|
if (s) {
|
||||||
s->removeAllData();
|
s->removeAllData();
|
||||||
d->queueUpdate();
|
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) {
|
if (s) {
|
||||||
s->setData(key, QVariant());
|
s->setData(key, QVariant());
|
||||||
d->queueUpdate();
|
d->queueUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataEngine::addSource(DataContainer* source)
|
void DataEngine::addSource(DataContainer *source)
|
||||||
{
|
{
|
||||||
if (d->sources.contains(source->objectName())) {
|
if (d->sources.contains(source->objectName())) {
|
||||||
kDebug() << "source named \"" << source->objectName() << "\" already exists.";
|
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;
|
//kDebug() << "removing source " << source;
|
||||||
SourceDict::iterator it = d->sources.find(source);
|
SourceDict::iterator it = d->sources.find(source);
|
||||||
@ -379,7 +381,7 @@ void DataEngine::timerEvent(QTimerEvent *event)
|
|||||||
scheduleSourcesUpdated();
|
scheduleSourcesUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataEngine::setIcon(const QString& icon)
|
void DataEngine::setIcon(const QString &icon)
|
||||||
{
|
{
|
||||||
d->icon = icon;
|
d->icon = icon;
|
||||||
}
|
}
|
||||||
@ -408,14 +410,14 @@ QString DataEngine::name() const
|
|||||||
return d->engineName;
|
return d->engineName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataEngine::setName(const QString& name)
|
void DataEngine::setName(const QString &name)
|
||||||
{
|
{
|
||||||
d->engineName = name;
|
d->engineName = name;
|
||||||
setObjectName(name);
|
setObjectName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Private class implementations
|
// Private class implementations
|
||||||
DataEnginePrivate::DataEnginePrivate(DataEngine* e, KService::Ptr service)
|
DataEnginePrivate::DataEnginePrivate(DataEngine *e, KService::Ptr service)
|
||||||
: q(e),
|
: q(e),
|
||||||
refCount(-1), // first ref
|
refCount(-1), // first ref
|
||||||
updateTimerId(0),
|
updateTimerId(0),
|
||||||
@ -446,9 +448,11 @@ DataEnginePrivate::DataEnginePrivate(DataEngine* e, KService::Ptr service)
|
|||||||
QString api = dataEngineDescription.property("X-Plasma-API").toString();
|
QString api = dataEngineDescription.property("X-Plasma-API").toString();
|
||||||
|
|
||||||
if (!api.isEmpty()) {
|
if (!api.isEmpty()) {
|
||||||
const QString path = KStandardDirs::locate("data",
|
const QString path =
|
||||||
"plasma/engines/" + dataEngineDescription.pluginName() + '/');
|
KStandardDirs::locate("data",
|
||||||
PackageStructure::Ptr structure = Plasma::packageStructure(api, Plasma::RunnerComponent);
|
"plasma/engines/" + dataEngineDescription.pluginName() + '/');
|
||||||
|
PackageStructure::Ptr structure =
|
||||||
|
Plasma::packageStructure(api, Plasma::RunnerComponent);
|
||||||
structure->setPath(path);
|
structure->setPath(path);
|
||||||
package = new Package(path, structure);
|
package = new Package(path, structure);
|
||||||
|
|
||||||
@ -471,7 +475,7 @@ DataEnginePrivate::~DataEnginePrivate()
|
|||||||
package = 0;
|
package = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataEnginePrivate::internalUpdateSource(DataContainer* source)
|
void DataEnginePrivate::internalUpdateSource(DataContainer *source)
|
||||||
{
|
{
|
||||||
if (minPollingInterval > 0 &&
|
if (minPollingInterval > 0 &&
|
||||||
source->timeSinceLastUpdate() < (uint)minPollingInterval) {
|
source->timeSinceLastUpdate() < (uint)minPollingInterval) {
|
||||||
@ -507,11 +511,11 @@ bool DataEnginePrivate::isUsed() const
|
|||||||
return refCount != 0;
|
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);
|
DataEngine::SourceDict::const_iterator it = sources.find(sourceName);
|
||||||
if (it != sources.constEnd()) {
|
if (it != sources.constEnd()) {
|
||||||
DataContainer* s = it.value();
|
DataContainer *s = it.value();
|
||||||
if (limit > 0) {
|
if (limit > 0) {
|
||||||
QQueue<DataContainer*>::iterator it = sourceQueue.begin();
|
QQueue<DataContainer*>::iterator it = sourceQueue.begin();
|
||||||
while (it != sourceQueue.end()) {
|
while (it != sourceQueue.end()) {
|
||||||
@ -533,7 +537,7 @@ DataContainer* DataEnginePrivate::source(const QString& sourceName, bool createW
|
|||||||
/*kDebug() << "DataEngine " << q->objectName()
|
/*kDebug() << "DataEngine " << q->objectName()
|
||||||
<< ": could not find DataContainer " << sourceName
|
<< ": could not find DataContainer " << sourceName
|
||||||
<< ", creating" << endl;*/
|
<< ", creating" << endl;*/
|
||||||
DataContainer* s = new DataContainer(q);
|
DataContainer *s = new DataContainer(q);
|
||||||
s->setObjectName(sourceName);
|
s->setObjectName(sourceName);
|
||||||
sources.insert(sourceName, s);
|
sources.insert(sourceName, s);
|
||||||
QObject::connect(s, SIGNAL(updateRequested(DataContainer*)),
|
QObject::connect(s, SIGNAL(updateRequested(DataContainer*)),
|
||||||
@ -546,8 +550,10 @@ DataContainer* DataEnginePrivate::source(const QString& sourceName, bool createW
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataEnginePrivate::connectSource(DataContainer* s, QObject* visualization, uint pollingInterval,
|
void DataEnginePrivate::connectSource(DataContainer *s, QObject *visualization,
|
||||||
Plasma::IntervalAlignment align, bool immediateCall)
|
uint pollingInterval,
|
||||||
|
Plasma::IntervalAlignment align,
|
||||||
|
bool immediateCall)
|
||||||
{
|
{
|
||||||
//kDebug() << "connect source called" << s->objectName() << "with interval" << pollingInterval;
|
//kDebug() << "connect source called" << s->objectName() << "with interval" << pollingInterval;
|
||||||
if (pollingInterval > 0) {
|
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) {
|
if (newSource) {
|
||||||
*newSource = false;
|
*newSource = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//kDebug() << "requesting source " << sourceName;
|
//kDebug() << "requesting source " << sourceName;
|
||||||
DataContainer* s = source(sourceName, false);
|
DataContainer *s = source(sourceName, false);
|
||||||
|
|
||||||
if (!s) {
|
if (!s) {
|
||||||
// we didn't find a data source, so give the engine an opportunity to make one
|
// 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();
|
uint queueCount = sourceQueue.count();
|
||||||
while (queueCount >= limit) {
|
while (queueCount >= limit) {
|
||||||
DataContainer* punted = sourceQueue.dequeue();
|
DataContainer *punted = sourceQueue.dequeue();
|
||||||
q->removeSource(punted->objectName());
|
q->removeSource(punted->objectName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ namespace Plasma
|
|||||||
class NullEngine : public DataEngine
|
class NullEngine : public DataEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NullEngine(QObject* parent = 0)
|
NullEngine(QObject *parent = 0)
|
||||||
: DataEngine(parent)
|
: DataEngine(parent)
|
||||||
{
|
{
|
||||||
setObjectName(i18n("Null Engine"));
|
setObjectName(i18n("Null Engine"));
|
||||||
@ -51,14 +51,14 @@ class DataEngineManagerPrivate
|
|||||||
|
|
||||||
~DataEngineManagerPrivate()
|
~DataEngineManagerPrivate()
|
||||||
{
|
{
|
||||||
foreach (Plasma::DataEngine* engine, engines) {
|
foreach (Plasma::DataEngine *engine, engines) {
|
||||||
delete engine;
|
delete engine;
|
||||||
}
|
}
|
||||||
engines.clear();
|
engines.clear();
|
||||||
delete nullEng;
|
delete nullEng;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataEngine* nullEngine()
|
DataEngine *nullEngine()
|
||||||
{
|
{
|
||||||
if (!nullEng) {
|
if (!nullEng) {
|
||||||
nullEng = new NullEngine;
|
nullEng = new NullEngine;
|
||||||
@ -68,7 +68,7 @@ class DataEngineManagerPrivate
|
|||||||
}
|
}
|
||||||
|
|
||||||
DataEngine::Dict engines;
|
DataEngine::Dict engines;
|
||||||
DataEngine* nullEng;
|
DataEngine *nullEng;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DataEngineManagerSingleton
|
class DataEngineManagerSingleton
|
||||||
@ -79,7 +79,7 @@ class DataEngineManagerSingleton
|
|||||||
|
|
||||||
K_GLOBAL_STATIC(DataEngineManagerSingleton, privateDataEngineManagerSelf)
|
K_GLOBAL_STATIC(DataEngineManagerSingleton, privateDataEngineManagerSelf)
|
||||||
|
|
||||||
DataEngineManager* DataEngineManager::self()
|
DataEngineManager *DataEngineManager::self()
|
||||||
{
|
{
|
||||||
return &privateDataEngineManagerSelf->self;
|
return &privateDataEngineManagerSelf->self;
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ DataEngineManager::~DataEngineManager()
|
|||||||
delete d;
|
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);
|
Plasma::DataEngine::Dict::const_iterator it = d->engines.find(name);
|
||||||
if (it != d->engines.end()) {
|
if (it != d->engines.end()) {
|
||||||
@ -106,9 +106,9 @@ Plasma::DataEngine* DataEngineManager::engine(const QString& name) const
|
|||||||
return d->nullEngine();
|
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);
|
Plasma::DataEngine::Dict::const_iterator it = d->engines.find(name);
|
||||||
|
|
||||||
if (it != d->engines.end()) {
|
if (it != d->engines.end()) {
|
||||||
@ -132,8 +132,9 @@ Plasma::DataEngine* DataEngineManager::loadEngine(const QString& name)
|
|||||||
if (api.isEmpty()) {
|
if (api.isEmpty()) {
|
||||||
if (offers.first()) {
|
if (offers.first()) {
|
||||||
KPluginLoader plugin(*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);
|
engine = offers.first()->createInstance<Plasma::DataEngine>(0, allArgs, &error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
engine = new DataEngine(0, offers.first());
|
engine = new DataEngine(0, offers.first());
|
||||||
@ -150,12 +151,12 @@ Plasma::DataEngine* DataEngineManager::loadEngine(const QString& name)
|
|||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataEngineManager::unloadEngine(const QString& name)
|
void DataEngineManager::unloadEngine(const QString &name)
|
||||||
{
|
{
|
||||||
Plasma::DataEngine::Dict::iterator it = d->engines.find(name);
|
Plasma::DataEngine::Dict::iterator it = d->engines.find(name);
|
||||||
|
|
||||||
if (it != d->engines.end()) {
|
if (it != d->engines.end()) {
|
||||||
Plasma::DataEngine* engine = *it;
|
Plasma::DataEngine *engine = *it;
|
||||||
engine->d->deref();
|
engine->d->deref();
|
||||||
|
|
||||||
if (!engine->d->isUsed()) {
|
if (!engine->d->isUsed()) {
|
||||||
|
68
delegate.cpp
68
delegate.cpp
@ -53,9 +53,9 @@ class DelegatePrivate
|
|||||||
|
|
||||||
~DelegatePrivate() { }
|
~DelegatePrivate() { }
|
||||||
|
|
||||||
QFont fontForSubTitle(const QFont& titleFont) const;
|
QFont fontForSubTitle(const QFont &titleFont) const;
|
||||||
QRect titleRect(const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
QRect titleRect(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||||
QRect subTitleRect(const QStyleOptionViewItem& option, const QModelIndex& index) const;
|
QRect subTitleRect(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||||
|
|
||||||
QMap<int, int> roles;
|
QMap<int, int> roles;
|
||||||
|
|
||||||
@ -69,8 +69,7 @@ class DelegatePrivate
|
|||||||
static const int ITEM_BOTTOM_MARGIN = 5;
|
static const int ITEM_BOTTOM_MARGIN = 5;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
QFont DelegatePrivate::fontForSubTitle(const QFont &titleFont) const
|
||||||
QFont DelegatePrivate::fontForSubTitle(const QFont& titleFont) const
|
|
||||||
{
|
{
|
||||||
QFont subTitleFont = titleFont;
|
QFont subTitleFont = titleFont;
|
||||||
subTitleFont.setPointSize(qMax(subTitleFont.pointSize() - 2,
|
subTitleFont.setPointSize(qMax(subTitleFont.pointSize() - 2,
|
||||||
@ -78,19 +77,24 @@ QFont DelegatePrivate::fontForSubTitle(const QFont& titleFont) const
|
|||||||
return subTitleFont;
|
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);
|
QFont font(option.font);
|
||||||
font.setBold(true);
|
font.setBold(true);
|
||||||
QFontMetrics fm(font);
|
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;
|
QRect emptyRect;
|
||||||
if (option.direction == Qt::LeftToRight) {
|
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 {
|
} 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) {
|
if (emptyRect.width() < 0) {
|
||||||
@ -98,17 +102,19 @@ QRect DelegatePrivate::titleRect(const QStyleOptionViewItem& option, const QMode
|
|||||||
return emptyRect;
|
return emptyRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect textRect = QStyle::alignedRect(option.direction,
|
QRect textRect = QStyle::alignedRect(
|
||||||
textAlignment,
|
option.direction,
|
||||||
fm.boundingRect(index.data(Qt::DisplayRole).toString()).size(),
|
textAlignment,
|
||||||
emptyRect);
|
fm.boundingRect(index.data(Qt::DisplayRole).toString()).size(),
|
||||||
|
emptyRect);
|
||||||
|
|
||||||
textRect.setWidth(textRect.width() + TEXT_RIGHT_MARGIN);
|
textRect.setWidth(textRect.width() + TEXT_RIGHT_MARGIN);
|
||||||
textRect.setHeight(emptyRect.height()/2);
|
textRect.setHeight(emptyRect.height() / 2);
|
||||||
return textRect;
|
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();
|
QString subTitle = index.data(roles[Delegate::SubTitleRole]).toString();
|
||||||
|
|
||||||
@ -153,7 +159,7 @@ int Delegate::roleMapping(SpecificRoles role) const
|
|||||||
return d->roles[role];
|
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);
|
QRect textRect = d->titleRect(option, index);
|
||||||
|
|
||||||
@ -172,7 +178,7 @@ QRect Delegate::rectAfterTitle(const QStyleOptionViewItem& option, const QModelI
|
|||||||
return emptyRect;
|
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);
|
QRect textRect = d->subTitleRect(option, index);
|
||||||
|
|
||||||
@ -191,30 +197,31 @@ QRect Delegate::rectAfterSubTitle(const QStyleOptionViewItem& option, const QMod
|
|||||||
return emptyRect;
|
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 afterTitleRect = rectAfterTitle(option, index);
|
||||||
QRect afterSubTitleRect = rectAfterSubTitle(option, index);
|
QRect afterSubTitleRect = rectAfterSubTitle(option, index);
|
||||||
|
|
||||||
afterTitleRect.setHeight(afterTitleRect.height()*2);
|
afterTitleRect.setHeight(afterTitleRect.height() * 2);
|
||||||
afterSubTitleRect.setTop(afterTitleRect.top());
|
afterSubTitleRect.setTop(afterTitleRect.top());
|
||||||
|
|
||||||
return afterTitleRect.intersected(afterSubTitleRect);
|
return afterTitleRect.intersected(afterSubTitleRect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Delegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||||
void Delegate::paint(QPainter *painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
const QModelIndex &index) const
|
||||||
{
|
{
|
||||||
const bool hover = option.state & (QStyle::State_MouseOver | QStyle::State_Selected);
|
const bool hover = option.state & (QStyle::State_MouseOver | QStyle::State_Selected);
|
||||||
|
|
||||||
QRect contentRect = option.rect;
|
QRect contentRect = option.rect;
|
||||||
contentRect.setBottom(contentRect.bottom() - 1);
|
contentRect.setBottom(contentRect.bottom() - 1);
|
||||||
|
|
||||||
QRect decorationRect = QStyle::alignedRect(option.direction,
|
QRect decorationRect =
|
||||||
option.decorationPosition == QStyleOptionViewItem::Left ?
|
QStyle::alignedRect(option.direction,
|
||||||
Qt::AlignLeft : Qt::AlignRight,
|
option.decorationPosition == QStyleOptionViewItem::Left ?
|
||||||
option.decorationSize,
|
Qt::AlignLeft : Qt::AlignRight,
|
||||||
contentRect.adjusted(DelegatePrivate::ITEM_LEFT_MARGIN, DelegatePrivate::ITEM_TOP_MARGIN,-DelegatePrivate::ITEM_RIGHT_MARGIN,-DelegatePrivate::ITEM_BOTTOM_MARGIN));
|
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);
|
decorationRect.moveTop(contentRect.top() + qMax(0, (contentRect.height() - decorationRect.height())) / 2);
|
||||||
|
|
||||||
QString titleText = index.data(Qt::DisplayRole).value<QString>();
|
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 titleRect = d->titleRect(option, index);
|
||||||
QRect subTitleRect = d->subTitleRect(option, index);
|
QRect subTitleRect = d->subTitleRect(option, index);
|
||||||
|
|
||||||
|
|
||||||
bool uniqueTitle = !index.data(d->roles[SubTitleMandatoryRole]).value<bool>();// true;
|
bool uniqueTitle = !index.data(d->roles[SubTitleMandatoryRole]).value<bool>();// true;
|
||||||
if (uniqueTitle) {
|
if (uniqueTitle) {
|
||||||
QModelIndex sib = index.sibling(index.row() + 1, index.column());
|
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 (index.data(d->roles[ColumnTypeRole]).toInt() == SecondaryActionColumn) {
|
||||||
if (hover) {
|
if (hover) {
|
||||||
// Only draw on 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);
|
decorationRect.adjust(delta, delta-1, -delta-1, -delta);
|
||||||
decorationIcon.paint(painter, decorationRect, option.decorationAlignment);
|
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)
|
Q_UNUSED(index)
|
||||||
QSize size = option.rect.size();
|
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);
|
size.setHeight(qMax(option.decorationSize.height(), qMax(size.height(), metrics.height() + subMetrics.ascent()) + 3) + 4);
|
||||||
// kDebug() << "size hint is" << size << (metrics.height() + subMetrics.ascent());
|
// kDebug() << "size hint is" << size << (metrics.height() + subMetrics.ascent());
|
||||||
|
|
||||||
size*=1.1;
|
size *= 1.1;
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ void Dialog::paintEvent(QPaintEvent *e)
|
|||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
p.setRenderHint(QPainter::Antialiasing);
|
p.setRenderHint(QPainter::Antialiasing);
|
||||||
p.setClipRect(e->rect());
|
p.setClipRect(e->rect());
|
||||||
p.setCompositionMode(QPainter::CompositionMode_Source );
|
p.setCompositionMode(QPainter::CompositionMode_Source);
|
||||||
p.fillRect(rect(), Qt::transparent);
|
p.fillRect(rect(), Qt::transparent);
|
||||||
d->background->paintPanel(&p);
|
d->background->paintPanel(&p);
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ void Dialog::mouseMoveEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// here we take care of resize..
|
// here we take care of resize..
|
||||||
if (d->resizeStartCorner != Dialog::NoCorner ) {
|
if (d->resizeStartCorner != Dialog::NoCorner) {
|
||||||
int newWidth;
|
int newWidth;
|
||||||
int newHeight;
|
int newHeight;
|
||||||
QPoint position;
|
QPoint position;
|
||||||
@ -375,7 +375,7 @@ Dialog::ResizeCorners Dialog::resizeCorners() const
|
|||||||
|
|
||||||
bool Dialog::inControlArea(const QPoint &point)
|
bool Dialog::inControlArea(const QPoint &point)
|
||||||
{
|
{
|
||||||
foreach(const QRect &r, d->resizeAreas) {
|
foreach (const QRect &r, d->resizeAreas) {
|
||||||
if (r.contains(point)) {
|
if (r.contains(point)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,8 @@ class ExtenderItemPrivate
|
|||||||
returnToSource->setMaximumSize(iconSize);
|
returnToSource->setMaximumSize(iconSize);
|
||||||
|
|
||||||
toolboxLayout->addItem(returnToSource);
|
toolboxLayout->addItem(returnToSource);
|
||||||
QObject::connect(returnToSource, SIGNAL(clicked()), q, SLOT(moveBackToSource()));
|
QObject::connect(returnToSource, SIGNAL(clicked()),
|
||||||
|
q, SLOT(moveBackToSource()));
|
||||||
}
|
}
|
||||||
|
|
||||||
toolboxLayout->updateGeometry();
|
toolboxLayout->updateGeometry();
|
||||||
@ -169,8 +170,8 @@ class ExtenderItemPrivate
|
|||||||
QSizeF minimum = toolboxLayout->minimumSize();
|
QSizeF minimum = toolboxLayout->minimumSize();
|
||||||
toolbox->resize(minimum);
|
toolbox->resize(minimum);
|
||||||
toolbox->setPos(q->size().width() - minimum.width() - bgRight,
|
toolbox->setPos(q->size().width() - minimum.width() - bgRight,
|
||||||
((dragger->size().height() + dragTop + dragBottom)/2) -
|
((dragger->size().height() + dragTop + dragBottom) / 2) -
|
||||||
(minimum.height()/2) + bgTop);
|
(minimum.height() / 2) + bgTop);
|
||||||
toolbox->update();
|
toolbox->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,8 +179,9 @@ class ExtenderItemPrivate
|
|||||||
//TODO: something like this as static function in corona might be a good idea.
|
//TODO: something like this as static function in corona might be a good idea.
|
||||||
QPointF scenePosFromScreenPos(const QPoint &pos) const
|
QPointF scenePosFromScreenPos(const QPoint &pos) const
|
||||||
{
|
{
|
||||||
//get the stacking order of the toplevel windows and remove the toplevel view that's
|
//get the stacking order of the toplevel windows and remove the
|
||||||
//only here while dragging, since we're not interested in finding that.
|
//toplevel view that's only here while dragging, since we're not
|
||||||
|
//interested in finding that.
|
||||||
QList<WId> order = KWindowSystem::stackingOrder();
|
QList<WId> order = KWindowSystem::stackingOrder();
|
||||||
if (toplevel) {
|
if (toplevel) {
|
||||||
order.removeOne(toplevel->winId());
|
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 = new Icon(KIcon(hostExtender->d->applet->icon()), "", this);
|
||||||
d->collapseIcon->resize(d->collapseIcon->sizeFromIconSize(iconSize.height()));
|
d->collapseIcon->resize(d->collapseIcon->sizeFromIconSize(iconSize.height()));
|
||||||
d->collapseIcon->setPos(d->bgLeft + d->dragLeft,
|
d->collapseIcon->setPos(d->bgLeft + d->dragLeft,
|
||||||
(d->dragger->size().height() + d->dragTop + d->dragBottom)/2 -
|
(d->dragger->size().height() + d->dragTop + d->dragBottom) / 2 - d->collapseIcon->size().height() / 2 + d->bgTop);
|
||||||
d->collapseIcon->size().height()/2 + d->bgTop);
|
|
||||||
connect(d->collapseIcon, SIGNAL(clicked()), this, SLOT(toggleCollapse()));
|
connect(d->collapseIcon, SIGNAL(clicked()), this, SLOT(toggleCollapse()));
|
||||||
|
|
||||||
//set the extender we want to move to.
|
//set the extender we want to move to.
|
||||||
@ -563,7 +564,7 @@ void ExtenderItem::destroy()
|
|||||||
void ExtenderItem::setCollapsed(bool collapsed)
|
void ExtenderItem::setCollapsed(bool collapsed)
|
||||||
{
|
{
|
||||||
qreal marginWidth = d->bgLeft + d->bgRight + d->dragLeft + d->dragRight;
|
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) {
|
if (!d->widget) {
|
||||||
setPreferredSize(QSizeF(200, d->dragHandleRect().height()));
|
setPreferredSize(QSizeF(200, d->dragHandleRect().height()));
|
||||||
@ -607,10 +608,10 @@ void ExtenderItem::setCollapsed(bool collapsed)
|
|||||||
} else {
|
} else {
|
||||||
setPreferredSize(QSizeF(preferredSize.width() + marginWidth,
|
setPreferredSize(QSizeF(preferredSize.width() + marginWidth,
|
||||||
preferredSize.height() + d->dragHandleRect().height() + marginHeight));
|
preferredSize.height() + d->dragHandleRect().height() + marginHeight));
|
||||||
setMinimumSize( QSizeF(minimumSize.width() + marginWidth,
|
setMinimumSize(QSizeF(minimumSize.width() + marginWidth,
|
||||||
minimumSize.height() + d->dragHandleRect().height() + marginHeight));
|
minimumSize.height() + d->dragHandleRect().height() + marginHeight));
|
||||||
setMaximumSize( QSizeF(maximumSize.width() + marginWidth,
|
setMaximumSize(QSizeF(maximumSize.width() + marginWidth,
|
||||||
maximumSize.height() + d->dragHandleRect().height() + marginHeight));
|
maximumSize.height() + d->dragHandleRect().height() + marginHeight));
|
||||||
|
|
||||||
if (d->widget->isWidget()) {
|
if (d->widget->isWidget()) {
|
||||||
QGraphicsWidget *graphicsWidget = static_cast<QGraphicsWidget*>(d->widget);
|
QGraphicsWidget *graphicsWidget = static_cast<QGraphicsWidget*>(d->widget);
|
||||||
@ -703,8 +704,7 @@ void ExtenderItem::resizeEvent(QGraphicsSceneResizeEvent *event)
|
|||||||
//resize the widget
|
//resize the widget
|
||||||
if (d->widget && d->widget->isWidget()) {
|
if (d->widget && d->widget->isWidget()) {
|
||||||
QSizeF newWidgetSize(width - d->bgLeft - d->bgRight - d->dragLeft - d->dragRight,
|
QSizeF newWidgetSize(width - d->bgLeft - d->bgRight - d->dragLeft - d->dragRight,
|
||||||
height - d->dragger->size().height() - d->bgTop - d->bgBottom
|
height - d->dragger->size().height() - d->bgTop - d->bgBottom - 2 * d->dragTop - 2 * d->dragBottom);
|
||||||
- 2*d->dragTop - 2*d->dragBottom);
|
|
||||||
|
|
||||||
QGraphicsWidget *graphicsWidget = static_cast<QGraphicsWidget*>(d->widget);
|
QGraphicsWidget *graphicsWidget = static_cast<QGraphicsWidget*>(d->widget);
|
||||||
graphicsWidget->resize(newWidgetSize);
|
graphicsWidget->resize(newWidgetSize);
|
||||||
@ -769,8 +769,8 @@ void ExtenderItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
|
|
||||||
corona->addOffscreenWidget(this);
|
corona->addOffscreenWidget(this);
|
||||||
|
|
||||||
d->toplevel->setWindowFlags(Qt::ToolTip | Qt::FramelessWindowHint
|
d->toplevel->setWindowFlags(
|
||||||
| Qt::WindowStaysOnTopHint);
|
Qt::ToolTip | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
||||||
d->toplevel->setFrameShape(QFrame::NoFrame);
|
d->toplevel->setFrameShape(QFrame::NoFrame);
|
||||||
d->toplevel->resize(screenRect.size());
|
d->toplevel->resize(screenRect.size());
|
||||||
d->toplevel->setSceneRect(sceneBoundingRect());
|
d->toplevel->setSceneRect(sceneBoundingRect());
|
||||||
|
17
glapplet.cpp
17
glapplet.cpp
@ -122,9 +122,9 @@ static inline QPainterPath headerPath(const QRectF &r, int roundness,
|
|||||||
int xRnd = roundness;
|
int xRnd = roundness;
|
||||||
int yRnd = roundness;
|
int yRnd = roundness;
|
||||||
if (r.width() > r.height()) {
|
if (r.width() > r.height()) {
|
||||||
xRnd = int(roundness * r.height()/r.width());
|
xRnd = int(roundness * r.height() / r.width());
|
||||||
} else {
|
} else {
|
||||||
yRnd = int(roundness * r.width()/r.height());
|
yRnd = int(roundness * r.width() / r.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(xRnd >= 100) { // fix ranges
|
if(xRnd >= 100) { // fix ranges
|
||||||
@ -140,8 +140,9 @@ static inline QPainterPath headerPath(const QRectF &r, int roundness,
|
|||||||
|
|
||||||
QRectF rect = r.normalized();
|
QRectF rect = r.normalized();
|
||||||
|
|
||||||
if (rect.isNull())
|
if (rect.isNull()) {
|
||||||
return path;
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
qreal x = rect.x();
|
qreal x = rect.x();
|
||||||
qreal y = rect.y();
|
qreal y = rect.y();
|
||||||
@ -156,13 +157,13 @@ static inline QPainterPath headerPath(const QRectF &r, int roundness,
|
|||||||
if (ryy < 0) {
|
if (ryy < 0) {
|
||||||
ryy = h / 200 * yRnd;
|
ryy = h / 200 * yRnd;
|
||||||
}
|
}
|
||||||
qreal rxx2 = 2*rxx;
|
qreal rxx2 = 2 * rxx;
|
||||||
qreal ryy2 = 2*ryy;
|
qreal ryy2 = 2 * ryy;
|
||||||
|
|
||||||
path.arcMoveTo(x, y, rxx2, ryy2, 90);
|
path.arcMoveTo(x, y, rxx2, ryy2, 90);
|
||||||
path.arcTo(x, y, rxx2, ryy2, 90, 90);
|
path.arcTo(x, y, rxx2, ryy2, 90, 90);
|
||||||
QPointF pt = path.currentPosition();
|
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() + headerHeight);
|
||||||
path.lineTo(x + w, pt.y());
|
path.lineTo(x + w, pt.y());
|
||||||
path.arcTo(x + w - rxx2, y, rxx2, ryy2, 0, 90);
|
path.arcTo(x + w - rxx2, y, rxx2, ryy2, 0, 90);
|
||||||
@ -206,9 +207,9 @@ void GLApplet::paintInterface(QPainter *painter,
|
|||||||
|
|
||||||
void GLApplet::makeCurrent()
|
void GLApplet::makeCurrent()
|
||||||
{
|
{
|
||||||
if (!d->dummy->isValid() ||
|
if (!d->dummy->isValid() || !d->pbuf->isValid()) {
|
||||||
!d->pbuf->isValid())
|
|
||||||
d->dummy->makeCurrent();
|
d->dummy->makeCurrent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
38
package.cpp
38
package.cpp
@ -47,7 +47,7 @@ namespace Plasma
|
|||||||
class PackagePrivate
|
class PackagePrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PackagePrivate(const PackageStructure::Ptr st, const QString& p)
|
PackagePrivate(const PackageStructure::Ptr st, const QString &p)
|
||||||
: structure(st),
|
: structure(st),
|
||||||
basePath(p),
|
basePath(p),
|
||||||
valid(QFile::exists(basePath)),
|
valid(QFile::exists(basePath)),
|
||||||
@ -69,7 +69,8 @@ public:
|
|||||||
PackageMetadata *metadata;
|
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))
|
: d(new PackagePrivate(structure, packageRoot + '/' + package))
|
||||||
{
|
{
|
||||||
structure->setPath(d->basePath);
|
structure->setPath(d->basePath);
|
||||||
@ -112,7 +113,7 @@ bool Package::isValid() const
|
|||||||
return true;
|
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) {
|
if (!d->valid) {
|
||||||
kDebug() << "package is not valid";
|
kDebug() << "package is not valid";
|
||||||
@ -146,12 +147,12 @@ QString Package::filePath(const char* fileType, const QString& filename) const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Package::filePath(const char* fileType) const
|
QString Package::filePath(const char *fileType) const
|
||||||
{
|
{
|
||||||
return filePath(fileType, QString());
|
return filePath(fileType, QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList Package::entryList(const char* fileType) const
|
QStringList Package::entryList(const char *fileType) const
|
||||||
{
|
{
|
||||||
if (!d->valid) {
|
if (!d->valid) {
|
||||||
return QStringList();
|
return QStringList();
|
||||||
@ -176,7 +177,7 @@ QStringList Package::entryList(const char* fileType) const
|
|||||||
return QStringList();
|
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?
|
//FIXME: this only works for native plasma packges; should fall back to... PackageStructure?
|
||||||
if (!d->metadata) {
|
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?
|
//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?
|
// 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);
|
QDir dir(packageRoot);
|
||||||
|
|
||||||
@ -207,7 +208,7 @@ QStringList Package::listInstalled(const QString& packageRoot) // static
|
|||||||
|
|
||||||
QStringList packages;
|
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";
|
QString metadata = packageRoot + '/' + sdir + "/metadata.desktop";
|
||||||
if (QFile::exists(metadata)) {
|
if (QFile::exists(metadata)) {
|
||||||
PackageMetadata m(metadata);
|
PackageMetadata m(metadata);
|
||||||
@ -218,9 +219,9 @@ QStringList Package::listInstalled(const QString& packageRoot) // static
|
|||||||
return packages;
|
return packages;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Package::installPackage(const QString& package,
|
bool Package::installPackage(const QString &package,
|
||||||
const QString& packageRoot,
|
const QString &packageRoot,
|
||||||
const QString& servicePrefix) // static
|
const QString &servicePrefix) // static
|
||||||
{
|
{
|
||||||
//TODO: report *what* failed if something does fail
|
//TODO: report *what* failed if something does fail
|
||||||
QDir root(packageRoot);
|
QDir root(packageRoot);
|
||||||
@ -259,8 +260,8 @@ bool Package::installPackage(const QString& package,
|
|||||||
}
|
}
|
||||||
|
|
||||||
archivedPackage = true;
|
archivedPackage = true;
|
||||||
const KArchiveDirectory* source = archive.directory();
|
const KArchiveDirectory *source = archive.directory();
|
||||||
const KArchiveEntry* metadata = source->entry("metadata.desktop");
|
const KArchiveEntry *metadata = source->entry("metadata.desktop");
|
||||||
|
|
||||||
if (!metadata) {
|
if (!metadata) {
|
||||||
kWarning() << "No metadata file in package" << package;
|
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
|
// Ensure that package names are safe so package uninstall can't inject
|
||||||
// bad characters into the paths used for removal.
|
// bad characters into the paths used for removal.
|
||||||
QRegExp validatePluginName("^[\\w-\\.]+$"); // Only allow letters, numbers, underscore and period.
|
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";
|
kWarning() << "Package plugin name " << targetName << "contains invalid characters";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
targetName = packageRoot + '/' + targetName;
|
targetName = packageRoot + '/' + targetName;
|
||||||
@ -352,9 +353,9 @@ bool Package::installPackage(const QString& package,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Package::uninstallPackage(const QString& pluginName,
|
bool Package::uninstallPackage(const QString &pluginName,
|
||||||
const QString& packageRoot,
|
const QString &packageRoot,
|
||||||
const QString& servicePrefix) // static
|
const QString &servicePrefix) // static
|
||||||
{
|
{
|
||||||
// We need to remove the package directory and its metadata file.
|
// We need to remove the package directory and its metadata file.
|
||||||
QString targetName = pluginName;
|
QString targetName = pluginName;
|
||||||
@ -449,5 +450,4 @@ bool Package::createPackage(const PackageMetadata &metadata,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // Namespace
|
} // Namespace
|
||||||
|
@ -35,8 +35,9 @@ namespace PaintUtils
|
|||||||
|
|
||||||
void shadowBlur(QImage &image, int radius, const QColor &color)
|
void shadowBlur(QImage &image, int radius, const QColor &color)
|
||||||
{
|
{
|
||||||
if (radius < 1)
|
if (radius < 1) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
expblur<16, 7>(image, radius);
|
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)
|
QPixmap shadowText(QString text, QColor textColor, QColor shadowColor, QPoint offset, int radius)
|
||||||
{
|
{
|
||||||
// Draw text
|
// Draw text
|
||||||
QFontMetrics fm(text);
|
QFontMetrics fm(text);
|
||||||
QRect textRect = fm.boundingRect(text);
|
QRect textRect = fm.boundingRect(text);
|
||||||
QPixmap textPixmap(textRect.size());
|
QPixmap textPixmap(textRect.size());
|
||||||
@ -63,7 +64,7 @@ QPixmap shadowText(QString text, QColor textColor, QColor shadowColor, QPoint of
|
|||||||
QImage::Format_ARGB32_Premultiplied);
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
img.fill(Qt::transparent);
|
img.fill(Qt::transparent);
|
||||||
p.begin(&img);
|
p.begin(&img);
|
||||||
p.drawImage(QPoint(radius,radius), textPixmap.toImage());
|
p.drawImage(QPoint(radius, radius), textPixmap.toImage());
|
||||||
p.end();
|
p.end();
|
||||||
shadowBlur(img, radius, shadowColor);
|
shadowBlur(img, radius, shadowColor);
|
||||||
|
|
||||||
@ -85,12 +86,12 @@ QPixmap shadowText(QString text, QColor textColor, QColor shadowColor, QPoint of
|
|||||||
finalPixmap.fill(Qt::transparent);
|
finalPixmap.fill(Qt::transparent);
|
||||||
p.begin(&finalPixmap);
|
p.begin(&finalPixmap);
|
||||||
QPointF offsetF(offset);
|
QPointF offsetF(offset);
|
||||||
QPointF textTopLeft(finalPixmap.rect().topLeft() +
|
QPointF textTopLeft(finalPixmap.rect().topLeft() +
|
||||||
QPointF ((finalPixmap.width() - textPixmap.width()) / 2.0, (finalPixmap.height() - textPixmap.height()) / 2.0) -
|
QPointF ((finalPixmap.width() - textPixmap.width()) / 2.0, (finalPixmap.height() - textPixmap.height()) / 2.0) -
|
||||||
(offsetF / 2.0));
|
(offsetF / 2.0));
|
||||||
QPointF shadowTopLeft(finalPixmap.rect().topLeft() +
|
QPointF shadowTopLeft(finalPixmap.rect().topLeft() +
|
||||||
QPointF ((finalPixmap.width() - img.width()) / 2.0, (finalPixmap.height() - img.height()) / 2.0) +
|
QPointF ((finalPixmap.width() - img.width()) / 2.0, (finalPixmap.height() - img.height()) / 2.0) +
|
||||||
(offsetF / 2.0));
|
(offsetF / 2.0));
|
||||||
|
|
||||||
p.drawImage(shadowTopLeft, img);
|
p.drawImage(shadowTopLeft, img);
|
||||||
p.drawPixmap(textTopLeft, textPixmap);
|
p.drawPixmap(textTopLeft, textPixmap);
|
||||||
@ -99,7 +100,7 @@ QPixmap shadowText(QString text, QColor textColor, QColor shadowColor, QPoint of
|
|||||||
return finalPixmap;
|
return finalPixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainterPath roundedRectangle(const QRectF& rect, qreal radius)
|
QPainterPath roundedRectangle(const QRectF &rect, qreal radius)
|
||||||
{
|
{
|
||||||
QPainterPath path(QPointF(rect.left(), rect.top() + radius));
|
QPainterPath path(QPointF(rect.left(), rect.top() + radius));
|
||||||
path.quadTo(rect.left(), rect.top(), rect.left() + radius, rect.top()); // Top left corner
|
path.quadTo(rect.left(), rect.top(), rect.left() + radius, rect.top()); // Top left corner
|
||||||
|
38
plasma.cpp
38
plasma.cpp
@ -49,32 +49,31 @@ qreal scalingFactor(ZoomLevel level)
|
|||||||
|
|
||||||
Direction locationToDirection(Location location)
|
Direction locationToDirection(Location location)
|
||||||
{
|
{
|
||||||
switch (location)
|
switch (location) {
|
||||||
{
|
case Floating:
|
||||||
case Floating:
|
case Desktop:
|
||||||
case Desktop:
|
case TopEdge:
|
||||||
case TopEdge:
|
case FullScreen:
|
||||||
case FullScreen:
|
//TODO: should we be smarter for floating and planer?
|
||||||
//TODO: should we be smarter for floating and planer?
|
// perhaps we should take a QRect and/or QPos as well?
|
||||||
// perhaps we should take a QRect and/or QPos as well?
|
return Down;
|
||||||
return Down;
|
case BottomEdge:
|
||||||
case BottomEdge:
|
return Up;
|
||||||
return Up;
|
case LeftEdge:
|
||||||
case LeftEdge:
|
return Right;
|
||||||
return Right;
|
case RightEdge:
|
||||||
case RightEdge:
|
return Left;
|
||||||
return Left;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Down;
|
return Down;
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint popupPosition(const QGraphicsItem * item, const QSize &s)
|
QPoint popupPosition(const QGraphicsItem *item, const QSize &s)
|
||||||
{
|
{
|
||||||
QGraphicsView *v = viewFor(item);
|
QGraphicsView *v = viewFor(item);
|
||||||
|
|
||||||
if (!v) {
|
if (!v) {
|
||||||
return QPoint(0,0);
|
return QPoint(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPoint pos = v->mapFromScene(item->scenePos());
|
QPoint pos = v->mapFromScene(item->scenePos());
|
||||||
@ -109,7 +108,8 @@ QPoint popupPosition(const QGraphicsItem * item, const QSize &s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//are we out of screen?
|
//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;
|
//kDebug() << "==> rect for" << (pv ? pv->containment()->screen() : -1) << "is" << screenRect;
|
||||||
|
|
||||||
if (pos.rx() + s.width() > screenRect.right()) {
|
if (pos.rx() + s.width() > screenRect.right()) {
|
||||||
@ -124,7 +124,7 @@ QPoint popupPosition(const QGraphicsItem * item, const QSize &s)
|
|||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGraphicsView* viewFor(const QGraphicsItem * item)
|
QGraphicsView *viewFor(const QGraphicsItem *item)
|
||||||
{
|
{
|
||||||
if (!item->scene()) {
|
if (!item->scene()) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -115,7 +115,8 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints)
|
|||||||
|
|
||||||
Plasma::FormFactor f = q->formFactor();
|
Plasma::FormFactor f = q->formFactor();
|
||||||
if (constraints & Plasma::FormFactorConstraint ||
|
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());
|
QGraphicsLinearLayout *lay = dynamic_cast<QGraphicsLinearLayout *>(q->layout());
|
||||||
|
|
||||||
if (icon && lay) {
|
if (icon && lay) {
|
||||||
@ -219,8 +220,10 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints)
|
|||||||
KWindowSystem::setState(dialog->winId(), NET::SkipTaskbar | NET::SkipPager);
|
KWindowSystem::setState(dialog->winId(), NET::SkipTaskbar | NET::SkipPager);
|
||||||
dialog->installEventFilter(q);
|
dialog->installEventFilter(q);
|
||||||
|
|
||||||
QObject::connect(dialog, SIGNAL(dialogResized()), q, SLOT(dialogSizeChanged()));
|
QObject::connect(dialog, SIGNAL(dialogResized()),
|
||||||
QObject::connect(dialog, SIGNAL(dialogVisible(bool)), q, SLOT(dialogStatusChanged(bool)));
|
q, SLOT(dialogSizeChanged()));
|
||||||
|
QObject::connect(dialog, SIGNAL(dialogVisible(bool)),
|
||||||
|
q, SLOT(dialogStatusChanged(bool)));
|
||||||
q->setMinimumSize(QSize(0, 0));
|
q->setMinimumSize(QSize(0, 0));
|
||||||
if (gWidget) {
|
if (gWidget) {
|
||||||
Corona *corona = qobject_cast<Corona *>(gWidget->scene());
|
Corona *corona = qobject_cast<Corona *>(gWidget->scene());
|
||||||
@ -263,7 +266,8 @@ void PopupApplet::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
|
|
||||||
void PopupApplet::mouseReleaseEvent(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();
|
d->togglePopup();
|
||||||
} else {
|
} else {
|
||||||
Applet::mouseReleaseEvent(event);
|
Applet::mouseReleaseEvent(event);
|
||||||
@ -411,8 +415,10 @@ void PopupAppletPrivate::updateDialogPosition()
|
|||||||
{
|
{
|
||||||
KConfigGroup sizeGroup = q->config();
|
KConfigGroup sizeGroup = q->config();
|
||||||
sizeGroup = KConfigGroup(&sizeGroup, "PopupApplet");
|
sizeGroup = KConfigGroup(&sizeGroup, "PopupApplet");
|
||||||
const int width = qMin(sizeGroup.readEntry("DialogWidth", 0), QApplication::desktop()->screen()->width() - 50);
|
const int width = qMin(sizeGroup.readEntry("DialogWidth", 0),
|
||||||
const int height = qMin(sizeGroup.readEntry("DialogHeight", 0), QApplication::desktop()->screen()->height() - 50);
|
QApplication::desktop()->screen()->width() - 50);
|
||||||
|
const int height = qMin(sizeGroup.readEntry("DialogHeight", 0),
|
||||||
|
QApplication::desktop()->screen()->height() - 50);
|
||||||
|
|
||||||
QSize saved(width, height);
|
QSize saved(width, height);
|
||||||
|
|
||||||
@ -464,8 +470,11 @@ void PopupAppletPrivate::updateDialogPosition()
|
|||||||
}
|
}
|
||||||
//are we out of screen?
|
//are we out of screen?
|
||||||
|
|
||||||
QRect screenRect = QApplication::desktop()->screenGeometry(q->containment() ? q->containment()->screen() : -1);
|
QRect screenRect =
|
||||||
//kDebug() << "==> rect for" << (containment() ? containment()->screen() : -1) << "is" << 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()) {
|
if (pos.rx() + s.width() > screenRect.right()) {
|
||||||
pos.rx() += (int)q->boundingRect().size().width() - s.width();
|
pos.rx() += (int)q->boundingRect().size().width() - s.width();
|
||||||
|
@ -55,7 +55,6 @@ class QueryMatchPrivate : public QSharedData
|
|||||||
qreal relevance;
|
qreal relevance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
QueryMatch::QueryMatch(AbstractRunner *runner)
|
QueryMatch::QueryMatch(AbstractRunner *runner)
|
||||||
: d(new QueryMatchPrivate(runner))
|
: d(new QueryMatchPrivate(runner))
|
||||||
{
|
{
|
||||||
@ -104,22 +103,22 @@ qreal QueryMatch::relevance() const
|
|||||||
return d->relevance;
|
return d->relevance;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractRunner* QueryMatch::runner() const
|
AbstractRunner *QueryMatch::runner() const
|
||||||
{
|
{
|
||||||
return d->runner;
|
return d->runner;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryMatch::setText(const QString& text)
|
void QueryMatch::setText(const QString &text)
|
||||||
{
|
{
|
||||||
d->text = text;
|
d->text = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryMatch::setSubtext(const QString& subtext)
|
void QueryMatch::setSubtext(const QString &subtext)
|
||||||
{
|
{
|
||||||
d->subtext = subtext;
|
d->subtext = subtext;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryMatch::setData(const QVariant& data)
|
void QueryMatch::setData(const QVariant & data)
|
||||||
{
|
{
|
||||||
d->data = data;
|
d->data = data;
|
||||||
setId(data.toString());
|
setId(data.toString());
|
||||||
@ -131,13 +130,12 @@ void QueryMatch::setId(const QString &id)
|
|||||||
d->id = d->runner->id();
|
d->id = d->runner->id();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!id.isEmpty()) {
|
if (!id.isEmpty()) {
|
||||||
d->id.append('_').append(id);
|
d->id.append('_').append(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryMatch::setIcon(const QIcon& icon)
|
void QueryMatch::setIcon(const QIcon &icon)
|
||||||
{
|
{
|
||||||
d->icon = icon;
|
d->icon = icon;
|
||||||
}
|
}
|
||||||
@ -162,7 +160,7 @@ QIcon QueryMatch::icon() const
|
|||||||
return d->icon;
|
return d->icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueryMatch::setEnabled( bool enabled )
|
void QueryMatch::setEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
d->enabled = enabled;
|
d->enabled = enabled;
|
||||||
}
|
}
|
||||||
@ -172,7 +170,7 @@ bool QueryMatch::isEnabled() const
|
|||||||
return d->enabled && d->runner;
|
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 (d->type == other.d->type) {
|
||||||
if (isEnabled() != other.isEnabled()) {
|
if (isEnabled() != other.isEnabled()) {
|
||||||
@ -191,7 +189,7 @@ bool QueryMatch::operator<(const QueryMatch& other) const
|
|||||||
return d->type < other.d->type;
|
return d->type < other.d->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryMatch& QueryMatch::operator=(const QueryMatch &other)
|
QueryMatch &QueryMatch::operator=(const QueryMatch &other)
|
||||||
{
|
{
|
||||||
if (d != other.d) {
|
if (d != other.d) {
|
||||||
d = other.d;
|
d = other.d;
|
||||||
|
@ -57,7 +57,7 @@ class RunnerContextPrivate : public QSharedData
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
RunnerContextPrivate(const RunnerContextPrivate& p)
|
RunnerContextPrivate(const RunnerContextPrivate &p)
|
||||||
: QSharedData(),
|
: QSharedData(),
|
||||||
type(RunnerContext::None),
|
type(RunnerContext::None),
|
||||||
q(p.q)
|
q(p.q)
|
||||||
@ -120,7 +120,6 @@ class RunnerContextPrivate : public QSharedData
|
|||||||
RunnerContext * q;
|
RunnerContext * q;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
RunnerContext::RunnerContext(QObject *parent)
|
RunnerContext::RunnerContext(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new RunnerContextPrivate(this))
|
d(new RunnerContextPrivate(this))
|
||||||
@ -129,7 +128,7 @@ RunnerContext::RunnerContext(QObject *parent)
|
|||||||
|
|
||||||
//copy ctor
|
//copy ctor
|
||||||
RunnerContext::RunnerContext(RunnerContext &other, QObject *parent)
|
RunnerContext::RunnerContext(RunnerContext &other, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
LOCK_FOR_READ((&other))
|
LOCK_FOR_READ((&other))
|
||||||
d = other.d;
|
d = other.d;
|
||||||
@ -142,9 +141,9 @@ RunnerContext::~RunnerContext()
|
|||||||
|
|
||||||
void RunnerContext::reset()
|
void RunnerContext::reset()
|
||||||
{
|
{
|
||||||
// We will detach if we are a copy of someone. But we will 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
|
// if we are the 'main' context others copied from. Resetting
|
||||||
// one RunnerContext makes all the copies oneobsolete.
|
// one RunnerContext makes all the copies oneobsolete.
|
||||||
d.detach();
|
d.detach();
|
||||||
|
|
||||||
// we still have to remove all the matches, since if the
|
// we still have to remove all the matches, since if the
|
||||||
@ -174,7 +173,6 @@ void RunnerContext::setQuery(const QString &term)
|
|||||||
d->determineType();
|
d->determineType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString RunnerContext::query() const
|
QString RunnerContext::query() const
|
||||||
{
|
{
|
||||||
// the query term should never be set after
|
// the query term should never be set after
|
||||||
@ -193,7 +191,7 @@ QString RunnerContext::mimeType() const
|
|||||||
return d->mimeType;
|
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)
|
Q_UNUSED(term)
|
||||||
|
|
||||||
@ -213,9 +211,9 @@ bool RunnerContext::addMatches(const QString& term, const QList<QueryMatch> &mat
|
|||||||
}
|
}
|
||||||
UNLOCK(this);
|
UNLOCK(this);
|
||||||
//kDebug()<< "add matches";
|
//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
|
// we always want to sent the signal of the object that created
|
||||||
// the d pointer
|
// the d pointer
|
||||||
emit d->q->matchesChanged();
|
emit d->q->matchesChanged();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -44,11 +44,9 @@
|
|||||||
using ThreadWeaver::Weaver;
|
using ThreadWeaver::Weaver;
|
||||||
using ThreadWeaver::Job;
|
using ThreadWeaver::Job;
|
||||||
|
|
||||||
|
|
||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
* RunnerRestrictionPolicy class
|
* RunnerRestrictionPolicy class
|
||||||
* Restricts simultaneous jobs of the same type
|
* Restricts simultaneous jobs of the same type
|
||||||
@ -135,7 +133,8 @@ void RunnerRestrictionPolicy::destructed(Job *job)
|
|||||||
class FindMatchesJob : public Job
|
class FindMatchesJob : public Job
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FindMatchesJob(Plasma::AbstractRunner *runner, Plasma::RunnerContext *context, QObject *parent = 0);
|
FindMatchesJob(Plasma::AbstractRunner *runner,
|
||||||
|
Plasma::RunnerContext *context, QObject *parent = 0);
|
||||||
|
|
||||||
int priority() const;
|
int priority() const;
|
||||||
Plasma::AbstractRunner *runner() const;
|
Plasma::AbstractRunner *runner() const;
|
||||||
@ -160,7 +159,8 @@ FindMatchesJob::FindMatchesJob(Plasma::AbstractRunner *runner,
|
|||||||
|
|
||||||
void FindMatchesJob::run()
|
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);
|
m_runner->performMatch(*m_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,7 +206,8 @@ public:
|
|||||||
config = conf;
|
config = conf;
|
||||||
|
|
||||||
//The number of threads used scales with the number of processors.
|
//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.
|
//This entry allows to define a hard upper limit independent of the number of processors.
|
||||||
const int maxThreads = config.readEntry("maxThreads", 16);
|
const int maxThreads = config.readEntry("maxThreads", 16);
|
||||||
const int numThreads = qMin(maxThreads, 2 + ((numProcs - 1) * 2));
|
const int numThreads = qMin(maxThreads, 2 + ((numProcs - 1) * 2));
|
||||||
@ -264,7 +265,8 @@ public:
|
|||||||
kDebug() << "loading runner:" << service->name();
|
kDebug() << "loading runner:" << service->name();
|
||||||
runners.insert(runnerName, runner);
|
runners.insert(runnerName, runner);
|
||||||
} else {
|
} else {
|
||||||
kDebug() << "failed to load runner:" << service->name() << ". error reported:" << error;
|
kDebug() << "failed to load runner:" << service->name()
|
||||||
|
<< ". error reported:" << error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (loaded) {
|
} else if (loaded) {
|
||||||
@ -301,8 +303,6 @@ public:
|
|||||||
KConfigGroup config;
|
KConfigGroup config;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************
|
/*****************************************************
|
||||||
* RunnerManager::Public class
|
* RunnerManager::Public class
|
||||||
*
|
*
|
||||||
@ -316,7 +316,6 @@ RunnerManager::RunnerManager(QObject *parent)
|
|||||||
//ThreadWeaver::setDebugLevel(true, 4);
|
//ThreadWeaver::setDebugLevel(true, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RunnerManager::RunnerManager(KConfigGroup &c, QObject *parent)
|
RunnerManager::RunnerManager(KConfigGroup &c, QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new RunnerManagerPrivate(this))
|
d(new RunnerManagerPrivate(this))
|
||||||
|
20
service.cpp
20
service.cpp
@ -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
|
// 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
|
// 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
|
// 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()) {
|
if (!mutableArgs.isEmpty()) {
|
||||||
setName(mutableArgs[0].toString());
|
setName(mutableArgs[0].toString());
|
||||||
mutableArgs.removeFirst();
|
mutableArgs.removeFirst();
|
||||||
@ -65,7 +65,7 @@ Service::~Service()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
Service* Service::load(const QString &name, QObject *parent)
|
Service *Service::load(const QString &name, QObject *parent)
|
||||||
{
|
{
|
||||||
//TODO: scripting API support
|
//TODO: scripting API support
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
@ -84,7 +84,7 @@ Service* Service::load(const QString &name, QObject *parent)
|
|||||||
QString error;
|
QString error;
|
||||||
QVariantList args;
|
QVariantList args;
|
||||||
args << name;
|
args << name;
|
||||||
Service* service = 0;
|
Service *service = 0;
|
||||||
|
|
||||||
if (Plasma::isPluginVersionCompatible(KPluginLoader(*offer).pluginVersion())) {
|
if (Plasma::isPluginVersionCompatible(KPluginLoader(*offer).pluginVersion())) {
|
||||||
service = offer->createInstance<Plasma::Service>(parent, args, &error);
|
service = offer->createInstance<Plasma::Service>(parent, args, &error);
|
||||||
@ -127,12 +127,13 @@ KConfigGroup Service::operationDescription(const QString &operationName)
|
|||||||
|
|
||||||
d->config->writeConfig();
|
d->config->writeConfig();
|
||||||
KConfigGroup params(d->config->config(), operationName);
|
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();
|
// << d->config->config()->name();
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
ServiceJob* Service::startOperationCall(const KConfigGroup &description, QObject *parent)
|
ServiceJob *Service::startOperationCall(const KConfigGroup &description, QObject *parent)
|
||||||
{
|
{
|
||||||
// TODO: nested groups?
|
// TODO: nested groups?
|
||||||
ServiceJob *job = 0;
|
ServiceJob *job = 0;
|
||||||
@ -178,7 +179,8 @@ void Service::associateWidget(QWidget *widget, const QString &operation)
|
|||||||
|
|
||||||
void Service::disassociateWidget(QWidget *widget)
|
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);
|
d->associatedWidgets.remove(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,14 +188,16 @@ void Service::associateWidget(QGraphicsWidget *widget, const QString &operation)
|
|||||||
{
|
{
|
||||||
disassociateWidget(widget);
|
disassociateWidget(widget);
|
||||||
d->associatedGraphicsWidgets.insert(widget, operation);
|
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));
|
widget->setEnabled(!d->disabledOperations.contains(operation));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::disassociateWidget(QGraphicsWidget *widget)
|
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);
|
d->associatedGraphicsWidgets.remove(widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
52
svg.cpp
52
svg.cpp
@ -80,8 +80,10 @@ class SvgPrivate
|
|||||||
void setImagePath(const QString &imagePath, Svg *q)
|
void setImagePath(const QString &imagePath, Svg *q)
|
||||||
{
|
{
|
||||||
if (themed) {
|
if (themed) {
|
||||||
QObject::disconnect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), q, SLOT(themeChanged()));
|
QObject::disconnect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()),
|
||||||
QObject::disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(colorsChanged()));
|
q, SLOT(themeChanged()));
|
||||||
|
QObject::disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
||||||
|
q, SLOT(colorsChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
themed = !QDir::isAbsolutePath(imagePath);
|
themed = !QDir::isAbsolutePath(imagePath);
|
||||||
@ -89,13 +91,15 @@ class SvgPrivate
|
|||||||
|
|
||||||
if (themed) {
|
if (themed) {
|
||||||
themePath = imagePath;
|
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
|
// check if svg wants colorscheme applied
|
||||||
createRenderer();
|
createRenderer();
|
||||||
applyColors = renderer->elementExists("hint-apply-color-scheme");
|
applyColors = renderer->elementExists("hint-apply-color-scheme");
|
||||||
if (applyColors && !Theme::defaultTheme()->colorScheme()) {
|
if (applyColors && !Theme::defaultTheme()->colorScheme()) {
|
||||||
QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(colorsChanged()));
|
QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
||||||
|
q, SLOT(colorsChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -134,9 +138,8 @@ class SvgPrivate
|
|||||||
return QPixmap();
|
return QPixmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString id = QString::fromLatin1("%3_%2_%1_").arg(size.width())
|
QString id = QString::fromLatin1("%3_%2_%1_").
|
||||||
.arg(size.height())
|
arg(size.width()).arg(size.height()).arg(path);
|
||||||
.arg(path);
|
|
||||||
|
|
||||||
if (!elementId.isEmpty()) {
|
if (!elementId.isEmpty()) {
|
||||||
id.append(elementId);
|
id.append(elementId);
|
||||||
@ -175,7 +178,8 @@ class SvgPrivate
|
|||||||
// Apply current color scheme if the svg asks for it
|
// Apply current color scheme if the svg asks for it
|
||||||
if (applyColors) {
|
if (applyColors) {
|
||||||
QImage itmp = p.toImage();
|
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);
|
p = p.fromImage(itmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +215,7 @@ class SvgPrivate
|
|||||||
|
|
||||||
void eraseRenderer()
|
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 ;)
|
// this and the cache reference it; and boy is this not thread safe ;)
|
||||||
renderers.erase(renderers.find(path));
|
renderers.erase(renderers.find(path));
|
||||||
}
|
}
|
||||||
@ -219,7 +223,7 @@ class SvgPrivate
|
|||||||
renderer = 0;
|
renderer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize elementSize(const QString& elementId)
|
QSize elementSize(const QString &elementId)
|
||||||
{
|
{
|
||||||
createRenderer();
|
createRenderer();
|
||||||
|
|
||||||
@ -231,12 +235,13 @@ class SvgPrivate
|
|||||||
QSizeF naturalSize = renderer->defaultSize();
|
QSizeF naturalSize = renderer->defaultSize();
|
||||||
qreal dx = size.width() / naturalSize.width();
|
qreal dx = size.width() / naturalSize.width();
|
||||||
qreal dy = size.height() / naturalSize.height();
|
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();
|
return elementSize.toSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF elementRect(const QString& elementId)
|
QRectF elementRect(const QString &elementId)
|
||||||
{
|
{
|
||||||
createRenderer();
|
createRenderer();
|
||||||
QRectF elementRect = renderer->boundsOnElement(elementId);
|
QRectF elementRect = renderer->boundsOnElement(elementId);
|
||||||
@ -248,7 +253,7 @@ class SvgPrivate
|
|||||||
elementRect.width() * dx, elementRect.height() * dy);
|
elementRect.width() * dx, elementRect.height() * dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
QMatrix matrixForElement(const QString& elementId)
|
QMatrix matrixForElement(const QString &elementId)
|
||||||
{
|
{
|
||||||
createRenderer();
|
createRenderer();
|
||||||
return renderer->matrixForElement(elementId);
|
return renderer->matrixForElement(elementId);
|
||||||
@ -275,9 +280,11 @@ class SvgPrivate
|
|||||||
createRenderer();
|
createRenderer();
|
||||||
applyColors = renderer->elementExists("hint-apply-color-scheme");
|
applyColors = renderer->elementExists("hint-apply-color-scheme");
|
||||||
if (applyColors && !Theme::defaultTheme()->colorScheme()) {
|
if (applyColors && !Theme::defaultTheme()->colorScheme()) {
|
||||||
QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(colorsChanged()));
|
QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
||||||
|
q, SLOT(colorsChanged()));
|
||||||
} else {
|
} else {
|
||||||
QObject::disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), q, SLOT(colorsChanged()));
|
QObject::disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
||||||
|
q, SLOT(colorsChanged()));
|
||||||
}
|
}
|
||||||
|
|
||||||
emit q->repaintNeeded();
|
emit q->repaintNeeded();
|
||||||
@ -308,7 +315,7 @@ class SvgPrivate
|
|||||||
|
|
||||||
QHash<QString, SharedSvgRenderer::Ptr> SvgPrivate::renderers;
|
QHash<QString, SharedSvgRenderer::Ptr> SvgPrivate::renderers;
|
||||||
|
|
||||||
Svg::Svg(QObject* parent)
|
Svg::Svg(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new SvgPrivate(this))
|
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()) :
|
QPixmap pix(elementID.isNull() ? d->findInCache(elementID, size()) :
|
||||||
d->findInCache(elementID));
|
d->findInCache(elementID));
|
||||||
@ -337,18 +344,18 @@ void Svg::paint(QPainter* painter, const QPointF& point, const QString& elementI
|
|||||||
return;
|
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);
|
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()));
|
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
|
QSize Svg::size() const
|
||||||
@ -398,7 +405,8 @@ FIXME: implement when Qt can support us!
|
|||||||
QSizeF naturalSize = d->renderer->defaultSize();
|
QSizeF naturalSize = d->renderer->defaultSize();
|
||||||
qreal dx = d->size.width() / naturalSize.width();
|
qreal dx = d->size.width() / naturalSize.width();
|
||||||
qreal dy = d->size.height() / naturalSize.height();
|
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));
|
return QString(); // d->renderer->elementAtPoint(QPoint(point.x() *dx, naturalSize.height() - point.y() * dy));
|
||||||
*/
|
*/
|
||||||
|
40
theme.cpp
40
theme.cpp
@ -65,7 +65,7 @@ public:
|
|||||||
generalFont = QApplication::font();
|
generalFont = QApplication::font();
|
||||||
}
|
}
|
||||||
|
|
||||||
KConfigGroup& config()
|
KConfigGroup &config()
|
||||||
{
|
{
|
||||||
if (!cfg.isValid()) {
|
if (!cfg.isValid()) {
|
||||||
QString groupName = "Theme";
|
QString groupName = "Theme";
|
||||||
@ -161,14 +161,14 @@ public:
|
|||||||
Theme self;
|
Theme self;
|
||||||
};
|
};
|
||||||
|
|
||||||
K_GLOBAL_STATIC( ThemeSingleton, privateThemeSelf )
|
K_GLOBAL_STATIC(ThemeSingleton, privateThemeSelf)
|
||||||
|
|
||||||
Theme* Theme::defaultTheme()
|
Theme *Theme::defaultTheme()
|
||||||
{
|
{
|
||||||
return &privateThemeSelf->self;
|
return &privateThemeSelf->self;
|
||||||
}
|
}
|
||||||
|
|
||||||
Theme::Theme(QObject* parent)
|
Theme::Theme(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new ThemePrivate(this))
|
d(new ThemePrivate(this))
|
||||||
{
|
{
|
||||||
@ -256,17 +256,20 @@ void Theme::setThemeName(const QString &themeName)
|
|||||||
d->defaultWallpaperWidth = cg.readEntry("defaultWidth", DEFAULT_WALLPAPER_WIDTH);
|
d->defaultWallpaperWidth = cg.readEntry("defaultWidth", DEFAULT_WALLPAPER_WIDTH);
|
||||||
d->defaultWallpaperHeight = cg.readEntry("defaultHeight", DEFAULT_WALLPAPER_HEIGHT);
|
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()) {
|
if (colorsFile.isEmpty()) {
|
||||||
d->colors = 0;
|
d->colors = 0;
|
||||||
connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SIGNAL(themeChanged()));
|
connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
||||||
|
this, SIGNAL(themeChanged()));
|
||||||
} else {
|
} else {
|
||||||
d->colors = KSharedConfig::openConfig(colorsFile);
|
d->colors = KSharedConfig::openConfig(colorsFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
d->colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, d->colors);
|
d->colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, d->colors);
|
||||||
d->buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, 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) {
|
if (d->isDefault) {
|
||||||
// we're the default theme, let's save our state
|
// we're the default theme, let's save our state
|
||||||
@ -286,7 +289,7 @@ QString Theme::themeName() const
|
|||||||
return d->themeName;
|
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
|
// look for a compressed svg file in the theme
|
||||||
if (name.contains("../")) {
|
if (name.contains("../")) {
|
||||||
@ -369,7 +372,7 @@ QString Theme::wallpaperPath(const QSize &size) const
|
|||||||
return fullPath;
|
return fullPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Theme::currentThemeHasImage(const QString& name) const
|
bool Theme::currentThemeHasImage(const QString &name) const
|
||||||
{
|
{
|
||||||
if (name.contains("../")) {
|
if (name.contains("../")) {
|
||||||
// we don't support relative paths
|
// we don't support relative paths
|
||||||
@ -422,15 +425,16 @@ QFont Theme::font(FontRole role) const
|
|||||||
{
|
{
|
||||||
Q_UNUSED(role)
|
Q_UNUSED(role)
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case DesktopFont: {
|
case DesktopFont:
|
||||||
KConfigGroup cg(KGlobal::config(), "General");
|
{
|
||||||
return cg.readEntry("desktopFont", QFont("Sans Serif", 10));
|
KConfigGroup cg(KGlobal::config(), "General");
|
||||||
}
|
return cg.readEntry("desktopFont", QFont("Sans Serif", 10));
|
||||||
break;
|
}
|
||||||
case DefaultFont:
|
break;
|
||||||
default:
|
case DefaultFont:
|
||||||
return d->generalFont;
|
default:
|
||||||
break;
|
return d->generalFont;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
#include <fixx11h.h>
|
#include <fixx11h.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//Plasma
|
//Plasma
|
||||||
#include <applet.h>
|
#include <applet.h>
|
||||||
#include <containment.h>
|
#include <containment.h>
|
||||||
@ -79,7 +78,6 @@ public :
|
|||||||
*/
|
*/
|
||||||
void onWidgetDestroyed(QObject * object);
|
void onWidgetDestroyed(QObject * object);
|
||||||
|
|
||||||
|
|
||||||
QGraphicsWidget *currentWidget;
|
QGraphicsWidget *currentWidget;
|
||||||
QTimer *showTimer;
|
QTimer *showTimer;
|
||||||
QTimer *hideTimer;
|
QTimer *hideTimer;
|
||||||
@ -97,7 +95,7 @@ class ToolTipManagerSingleton
|
|||||||
}
|
}
|
||||||
ToolTipManager self;
|
ToolTipManager self;
|
||||||
};
|
};
|
||||||
K_GLOBAL_STATIC( ToolTipManagerSingleton, privateInstance )
|
K_GLOBAL_STATIC(ToolTipManagerSingleton, privateInstance)
|
||||||
|
|
||||||
ToolTipManager *ToolTipManager::self()
|
ToolTipManager *ToolTipManager::self()
|
||||||
{
|
{
|
||||||
@ -114,7 +112,7 @@ bool ToolTipManager::ToolTipContent::isEmpty() const
|
|||||||
return mainText.isEmpty() && subText.isEmpty() && image.isNull() && windowToPreview == 0;
|
return mainText.isEmpty() && subText.isEmpty() && image.isNull() && windowToPreview == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolTipManager::ToolTipManager(QObject* parent)
|
ToolTipManager::ToolTipManager(QObject *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
d(new ToolTipManagerPrivate)
|
d(new ToolTipManagerPrivate)
|
||||||
{
|
{
|
||||||
@ -416,7 +414,7 @@ bool ToolTipManager::eventFilter(QObject *watched, QEvent *event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QObject::eventFilter(watched,event);
|
return QObject::eventFilter(watched, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
66
uiloader.cpp
66
uiloader.cpp
@ -50,18 +50,18 @@ UiLoader::UiLoader(QObject *parent)
|
|||||||
{
|
{
|
||||||
d->widgets
|
d->widgets
|
||||||
<< "CheckBox"
|
<< "CheckBox"
|
||||||
<< "ComboBox"
|
<< "ComboBox"
|
||||||
<< "Flash"
|
<< "Flash"
|
||||||
<< "Frame"
|
<< "Frame"
|
||||||
<< "GroupBox"
|
<< "GroupBox"
|
||||||
<< "Icon"
|
<< "Icon"
|
||||||
<< "Label"
|
<< "Label"
|
||||||
<< "LineEdit"
|
<< "LineEdit"
|
||||||
<< "PushButton"
|
<< "PushButton"
|
||||||
<< "RadioButton"
|
<< "RadioButton"
|
||||||
<< "Slider"
|
<< "Slider"
|
||||||
<< "TabBar"
|
<< "TabBar"
|
||||||
<< "TextEdit";
|
<< "TextEdit";
|
||||||
}
|
}
|
||||||
|
|
||||||
UiLoader::~UiLoader()
|
UiLoader::~UiLoader()
|
||||||
@ -78,41 +78,29 @@ QGraphicsWidget *UiLoader::createWidget(const QString &className, QGraphicsWidge
|
|||||||
{
|
{
|
||||||
if (className == QString("CheckBox")) {
|
if (className == QString("CheckBox")) {
|
||||||
return new CheckBox(parent);
|
return new CheckBox(parent);
|
||||||
}
|
} else if (className == QString("ComboBox")) {
|
||||||
else if (className == QString("ComboBox")) {
|
|
||||||
return new ComboBox(parent);
|
return new ComboBox(parent);
|
||||||
}
|
} else if (className == QString("Flash")) {
|
||||||
else if (className == QString("Flash")) {
|
|
||||||
return new Flash(parent);
|
return new Flash(parent);
|
||||||
}
|
} else if (className == QString("Frame")) {
|
||||||
else if (className == QString("Frame")) {
|
|
||||||
return new Frame(parent);
|
return new Frame(parent);
|
||||||
}
|
} else if (className == QString("GroupBox")) {
|
||||||
else if (className == QString("GroupBox")) {
|
|
||||||
return new GroupBox(parent);
|
return new GroupBox(parent);
|
||||||
}
|
} else if (className == QString("Icon")) {
|
||||||
else if (className == QString("Icon")) {
|
|
||||||
return new Icon(parent);
|
return new Icon(parent);
|
||||||
}
|
} else if (className == QString("Label")) {
|
||||||
else if (className == QString("Label")) {
|
|
||||||
return new Label(parent);
|
return new Label(parent);
|
||||||
}
|
} else if (className == QString("LineEdit")) {
|
||||||
else if (className == QString("LineEdit")) {
|
|
||||||
return new LineEdit(parent);
|
return new LineEdit(parent);
|
||||||
}
|
} else if (className == QString("PushButton")) {
|
||||||
else if (className == QString("PushButton")) {
|
|
||||||
return new PushButton(parent);
|
return new PushButton(parent);
|
||||||
}
|
} else if (className == QString("RadioButton")) {
|
||||||
else if (className == QString("RadioButton")) {
|
|
||||||
return new RadioButton(parent);
|
return new RadioButton(parent);
|
||||||
}
|
} else if (className == QString("Slider")) {
|
||||||
else if (className == QString("Slider")) {
|
|
||||||
return new Slider(parent);
|
return new Slider(parent);
|
||||||
}
|
} else if (className == QString("TabBar")) {
|
||||||
else if (className == QString("TabBar")) {
|
|
||||||
return new TabBar(parent);
|
return new TabBar(parent);
|
||||||
}
|
} else if (className == QString("TextEdit")) {
|
||||||
else if (className == QString("TextEdit")) {
|
|
||||||
return new TextEdit(parent);
|
return new TextEdit(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,17 +112,15 @@ QStringList UiLoader::availableLayouts() const
|
|||||||
return d->layouts;
|
return d->layouts;
|
||||||
}
|
}
|
||||||
|
|
||||||
Layout *UiLoader::createLayout( const QString &className, LayoutItem *parent )
|
Layout *UiLoader::createLayout(const QString &className, LayoutItem *parent)
|
||||||
{
|
{
|
||||||
#ifdef RICHARD_WORK
|
#ifdef RICHARD_WORK
|
||||||
if (className == QString("HBoxLayout")) {
|
if (className == QString("HBoxLayout")) {
|
||||||
return new HBoxLayout( parent );
|
return new HBoxLayout(parent);
|
||||||
}
|
} else if (className == QString("VBoxLayout")) {
|
||||||
else if (className == QString("VBoxLayout")) {
|
return new VBoxLayout(parent);
|
||||||
return new VBoxLayout( parent );
|
} else if (className == QString("FlowLayout")) {
|
||||||
}
|
return new FlowLayout(parent);
|
||||||
else if (className == QString("FlowLayout")) {
|
|
||||||
return new FlowLayout( parent );
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -47,14 +47,14 @@ public:
|
|||||||
KServiceAction mode;
|
KServiceAction mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallpaper::Wallpaper(QObject* parentObject, const QVariantList& args)
|
Wallpaper::Wallpaper(QObject *parentObject, const QVariantList &args)
|
||||||
: d(new WallpaperPrivate(KService::serviceByStorageId(args.count() > 0 ?
|
: d(new WallpaperPrivate(KService::serviceByStorageId(args.count() > 0 ?
|
||||||
args[0].toString() : QString()), this))
|
args[0].toString() : QString()), this))
|
||||||
{
|
{
|
||||||
// now remove first item since those are managed by Wallpaper and subclasses shouldn't
|
// 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
|
// 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
|
// 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()) {
|
if (!mutableArgs.isEmpty()) {
|
||||||
mutableArgs.removeFirst();
|
mutableArgs.removeFirst();
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ KPluginInfo::List Wallpaper::listWallpaperInfo(const QString &formFactor)
|
|||||||
return KPluginInfo::fromServices(offers);
|
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()) {
|
if (wallpaperName.isEmpty()) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -102,7 +102,7 @@ Wallpaper* Wallpaper::load(const QString& wallpaperName, const QVariantList& arg
|
|||||||
QVariantList allArgs;
|
QVariantList allArgs;
|
||||||
allArgs << offer->storageId() << args;
|
allArgs << offer->storageId() << args;
|
||||||
QString error;
|
QString error;
|
||||||
Wallpaper* wallpaper = offer->createInstance<Plasma::Wallpaper>(0, allArgs, &error);
|
Wallpaper *wallpaper = offer->createInstance<Plasma::Wallpaper>(0, allArgs, &error);
|
||||||
|
|
||||||
if (!wallpaper) {
|
if (!wallpaper) {
|
||||||
kDebug() << "Couldn't load wallpaper \"" << wallpaperName << "\"! reason given: " << error;
|
kDebug() << "Couldn't load wallpaper \"" << wallpaperName << "\"! reason given: " << error;
|
||||||
@ -110,7 +110,7 @@ Wallpaper* Wallpaper::load(const QString& wallpaperName, const QVariantList& arg
|
|||||||
return wallpaper;
|
return wallpaper;
|
||||||
}
|
}
|
||||||
|
|
||||||
Wallpaper* Wallpaper::load(const KPluginInfo& info, const QVariantList& args)
|
Wallpaper *Wallpaper::load(const KPluginInfo &info, const QVariantList &args)
|
||||||
{
|
{
|
||||||
if (!info.isValid()) {
|
if (!info.isValid()) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -164,7 +164,7 @@ QRectF Wallpaper::boundingRect() const
|
|||||||
return d->boundingRect;
|
return d->boundingRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Wallpaper::setBoundingRect(const QRectF& boundingRect)
|
void Wallpaper::setBoundingRect(const QRectF &boundingRect)
|
||||||
{
|
{
|
||||||
d->boundingRect = boundingRect;
|
d->boundingRect = boundingRect;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user