if the applet is a popup applet and is in the panel and has a dialog then show messages in a popup as well
svn path=/trunk/KDE/kdelibs/; revision=1022543
This commit is contained in:
parent
6297027cba
commit
229deb1d29
70
applet.cpp
70
applet.cpp
@ -69,6 +69,7 @@
|
|||||||
#include "containment.h"
|
#include "containment.h"
|
||||||
#include "corona.h"
|
#include "corona.h"
|
||||||
#include "dataenginemanager.h"
|
#include "dataenginemanager.h"
|
||||||
|
#include "dialog.h"
|
||||||
#include "extenders/extender.h"
|
#include "extenders/extender.h"
|
||||||
#include "extenders/extenderitem.h"
|
#include "extenders/extenderitem.h"
|
||||||
#include "package.h"
|
#include "package.h"
|
||||||
@ -577,7 +578,12 @@ void AppletPrivate::positionMessageOverlay()
|
|||||||
|
|
||||||
void AppletPrivate::destroyMessageOverlay()
|
void AppletPrivate::destroyMessageOverlay()
|
||||||
{
|
{
|
||||||
//TODO: fade out? =)
|
if (messageDialog) {
|
||||||
|
messageDialog->animatedHide(Plasma::locationToInverseDirection(q->location()));
|
||||||
|
//messageDialog->deleteLater();
|
||||||
|
messageDialog = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!messageOverlay) {
|
if (!messageOverlay) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -998,9 +1004,39 @@ void Applet::showMessage(const QIcon &icon, const QString &message, const Messag
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
d->createMessageOverlay();
|
Corona *corona = qobject_cast<Corona *>(scene());
|
||||||
d->messageOverlay->opacity = 0.8;
|
PopupApplet *popup = qobject_cast<Plasma::PopupApplet*>(this);
|
||||||
QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(d->messageOverlay);
|
QGraphicsWidget *parent = 0;
|
||||||
|
FormFactor f = formFactor();
|
||||||
|
|
||||||
|
if (popup && popup->d->dialog &&
|
||||||
|
(f == Plasma::Horizontal || f == Plasma::Vertical)) {
|
||||||
|
// we are a popup applet, and we are collapsed to an icon, so show it in a dialog
|
||||||
|
// associated with ourselves
|
||||||
|
parent = new QGraphicsWidget;
|
||||||
|
if (corona) {
|
||||||
|
corona->addOffscreenWidget(parent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (d->messageDialog) {
|
||||||
|
delete d->messageDialog->graphicsWidget();
|
||||||
|
} else {
|
||||||
|
d->messageDialog = new Plasma::Dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolTipManager::self()->hide(this);
|
||||||
|
KWindowSystem::setOnAllDesktops(d->messageDialog->winId(), true);
|
||||||
|
KWindowSystem::setState(d->messageDialog->winId(), NET::SkipTaskbar | NET::SkipPager);
|
||||||
|
|
||||||
|
connect(d->messageDialog, SIGNAL(destroyed(QObject*)), parent, SLOT(deleteLater()));
|
||||||
|
} else {
|
||||||
|
delete d->messageDialog;
|
||||||
|
d->createMessageOverlay();
|
||||||
|
d->messageOverlay->opacity = 0.8;
|
||||||
|
parent = d->messageOverlay;
|
||||||
|
}
|
||||||
|
|
||||||
|
QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(parent);
|
||||||
mainLayout->setOrientation(Qt::Vertical);
|
mainLayout->setOrientation(Qt::Vertical);
|
||||||
mainLayout->addStretch();
|
mainLayout->addStretch();
|
||||||
|
|
||||||
@ -1026,7 +1062,6 @@ void Applet::showMessage(const QIcon &icon, const QString &message, const Messag
|
|||||||
messageIcon->setIcon(icon);
|
messageIcon->setIcon(icon);
|
||||||
messageText->setText(message);
|
messageText->setText(message);
|
||||||
|
|
||||||
|
|
||||||
buttonLayout->addStretch();
|
buttonLayout->addStretch();
|
||||||
|
|
||||||
if (buttons & ButtonOk) {
|
if (buttons & ButtonOk) {
|
||||||
@ -1035,18 +1070,21 @@ void Applet::showMessage(const QIcon &icon, const QString &message, const Messag
|
|||||||
buttonLayout->addItem(ok);
|
buttonLayout->addItem(ok);
|
||||||
connect(ok, SIGNAL(clicked()), this, SLOT(destroyMessageOverlay()));
|
connect(ok, SIGNAL(clicked()), this, SLOT(destroyMessageOverlay()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buttons & ButtonYes) {
|
if (buttons & ButtonYes) {
|
||||||
PushButton *yes = new PushButton(this);
|
PushButton *yes = new PushButton(this);
|
||||||
yes->setText(i18n("Yes"));
|
yes->setText(i18n("Yes"));
|
||||||
buttonLayout->addItem(yes);
|
buttonLayout->addItem(yes);
|
||||||
connect(yes, SIGNAL(clicked()), this, SLOT(destroyMessageOverlay()));
|
connect(yes, SIGNAL(clicked()), this, SLOT(destroyMessageOverlay()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buttons & ButtonNo) {
|
if (buttons & ButtonNo) {
|
||||||
PushButton *no = new PushButton(this);
|
PushButton *no = new PushButton(this);
|
||||||
no->setText(i18n("No"));
|
no->setText(i18n("No"));
|
||||||
buttonLayout->addItem(no);
|
buttonLayout->addItem(no);
|
||||||
connect(no, SIGNAL(clicked()), this, SLOT(destroyMessageOverlay()));
|
connect(no, SIGNAL(clicked()), this, SLOT(destroyMessageOverlay()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buttons & ButtonCancel) {
|
if (buttons & ButtonCancel) {
|
||||||
PushButton *cancel = new PushButton(this);
|
PushButton *cancel = new PushButton(this);
|
||||||
cancel->setText(i18n("Cancel"));
|
cancel->setText(i18n("Cancel"));
|
||||||
@ -1055,9 +1093,21 @@ void Applet::showMessage(const QIcon &icon, const QString &message, const Messag
|
|||||||
}
|
}
|
||||||
|
|
||||||
buttonLayout->addStretch();
|
buttonLayout->addStretch();
|
||||||
|
if (d->messageDialog) {
|
||||||
|
parent->adjustSize();
|
||||||
|
d->messageDialog->setGraphicsWidget(parent);
|
||||||
|
|
||||||
d->messageOverlay->show();
|
QPoint pos = geometry().topLeft().toPoint();
|
||||||
|
if (corona) {
|
||||||
|
pos = corona->popupPosition(this, d->messageDialog->size());
|
||||||
|
}
|
||||||
|
|
||||||
|
d->messageDialog->move(pos);
|
||||||
|
kDebug() << location() << locationToDirection(location()) << LeftEdge << Right;
|
||||||
|
d->messageDialog->animatedShow(locationToDirection(location()));
|
||||||
|
} else {
|
||||||
|
d->messageOverlay->show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantList Applet::startupArguments() const
|
QVariantList Applet::startupArguments() const
|
||||||
@ -1655,9 +1705,7 @@ void Applet::showConfigurationInterface()
|
|||||||
}
|
}
|
||||||
|
|
||||||
d->addGlobalShortcutsPage(dialog);
|
d->addGlobalShortcutsPage(dialog);
|
||||||
#ifdef ENABLE_REMOTE_WIDGETS
|
|
||||||
d->addPublishPage(dialog);
|
d->addPublishPage(dialog);
|
||||||
#endif
|
|
||||||
dialog->show();
|
dialog->show();
|
||||||
} else if (d->script) {
|
} else if (d->script) {
|
||||||
d->script->showConfigurationInterface();
|
d->script->showConfigurationInterface();
|
||||||
@ -1716,9 +1764,7 @@ KConfigDialog *AppletPrivate::generateGenericConfigDialog()
|
|||||||
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
q->createConfigurationInterface(dialog);
|
q->createConfigurationInterface(dialog);
|
||||||
addGlobalShortcutsPage(dialog);
|
addGlobalShortcutsPage(dialog);
|
||||||
#ifdef ENABLE_REMOTE_WIDGETS
|
|
||||||
addPublishPage(dialog);
|
addPublishPage(dialog);
|
||||||
#endif
|
|
||||||
//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);
|
||||||
QObject::connect(dialog, SIGNAL(applyClicked()), q, SLOT(configDialogFinished()));
|
QObject::connect(dialog, SIGNAL(applyClicked()), q, SLOT(configDialogFinished()));
|
||||||
@ -1754,6 +1800,7 @@ void AppletPrivate::addGlobalShortcutsPage(KConfigDialog *dialog)
|
|||||||
|
|
||||||
void AppletPrivate::addPublishPage(KConfigDialog *dialog)
|
void AppletPrivate::addPublishPage(KConfigDialog *dialog)
|
||||||
{
|
{
|
||||||
|
#ifdef ENABLE_REMOTE_WIDGETS
|
||||||
QWidget *page = new QWidget;
|
QWidget *page = new QWidget;
|
||||||
publishUI.setupUi(page);
|
publishUI.setupUi(page);
|
||||||
publishUI.publishCheckbox->setChecked(q->isPublished());
|
publishUI.publishCheckbox->setChecked(q->isPublished());
|
||||||
@ -1771,6 +1818,7 @@ void AppletPrivate::addPublishPage(KConfigDialog *dialog)
|
|||||||
q->connect(publishUI.publishCheckbox, SIGNAL(stateChanged(int)),
|
q->connect(publishUI.publishCheckbox, SIGNAL(stateChanged(int)),
|
||||||
q, SLOT(publishCheckboxStateChanged(int)));
|
q, SLOT(publishCheckboxStateChanged(int)));
|
||||||
dialog->addPage(page, i18n("Publish"), "applications-internet");
|
dialog->addPage(page, i18n("Publish"), "applications-internet");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppletPrivate::publishCheckboxStateChanged(int state)
|
void AppletPrivate::publishCheckboxStateChanged(int state)
|
||||||
@ -1799,6 +1847,7 @@ void AppletPrivate::configDialogFinished()
|
|||||||
|
|
||||||
q->config().writeEntry("Publish", publishUI.publishCheckbox->isChecked());
|
q->config().writeEntry("Publish", publishUI.publishCheckbox->isChecked());
|
||||||
|
|
||||||
|
#ifdef ENABLE_REMOTE_WIDGETS
|
||||||
if (publishUI.publishCheckbox->isChecked()) {
|
if (publishUI.publishCheckbox->isChecked()) {
|
||||||
QString resourceName =
|
QString resourceName =
|
||||||
i18nc("%1 is the name of a plasmoid, %2 the name of the machine that plasmoid is published on",
|
i18nc("%1 is the name of a plasmoid, %2 the name of the machine that plasmoid is published on",
|
||||||
@ -1821,6 +1870,7 @@ void AppletPrivate::configDialogFinished()
|
|||||||
} else {
|
} else {
|
||||||
q->unpublish();
|
q->unpublish();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!configLoader) {
|
if (!configLoader) {
|
||||||
// the config loader will trigger this for us, so we don't need to.
|
// the config loader will trigger this for us, so we don't need to.
|
||||||
|
@ -35,6 +35,7 @@ class KKeySequenceWidget;
|
|||||||
namespace Plasma
|
namespace Plasma
|
||||||
{
|
{
|
||||||
|
|
||||||
|
class Dialog;
|
||||||
class FrameSvg;
|
class FrameSvg;
|
||||||
class AppletScript;
|
class AppletScript;
|
||||||
class Wallpaper;
|
class Wallpaper;
|
||||||
@ -134,6 +135,7 @@ public:
|
|||||||
Plasma::Constraints pendingConstraints;
|
Plasma::Constraints pendingConstraints;
|
||||||
|
|
||||||
// overlays and messages
|
// overlays and messages
|
||||||
|
QPointer<Plasma::Dialog> messageDialog;
|
||||||
AppletOverlayWidget *messageOverlay;
|
AppletOverlayWidget *messageOverlay;
|
||||||
QGraphicsProxyWidget *messageOverlayProxy;
|
QGraphicsProxyWidget *messageOverlayProxy;
|
||||||
Plasma::BusyWidget *busyWidget;
|
Plasma::BusyWidget *busyWidget;
|
||||||
|
Loading…
Reference in New Issue
Block a user