Merge remote branch 'origin/KDE/4.7'
This commit is contained in:
commit
7cb65fb04e
@ -24,7 +24,7 @@ Comment[fi]=Skriptauskielituki Plasmalle
|
||||
Comment[fr]=Langage de script d'extension pour Plasma
|
||||
Comment[fy]=Scripting taal taheaksel foar Plasma
|
||||
Comment[ga]=Eisínteacht teanga scriptithe le haghaidh Plasma
|
||||
Comment[gl]=Engadido de linguaxe de scripts para o Plasma
|
||||
Comment[gl]=Extensión de linguaxe de scripts para o Plasma
|
||||
Comment[gu]=પ્લાઝમા માટે સ્ક્રિપ્ટીંગ ભાષા એક્સટેન્શન
|
||||
Comment[he]=הרחבת שפת תסריטים של Plasma
|
||||
Comment[hne]=प्लाज्मा बर स्क्रिप्टिंग भाखा
|
||||
|
@ -331,10 +331,11 @@ void DataEngine::removeAllSources()
|
||||
while (it.hasNext()) {
|
||||
it.next();
|
||||
Plasma::DataContainer *s = it.value();
|
||||
emit sourceRemoved(it.key());
|
||||
const QString source = it.key();
|
||||
it.remove();
|
||||
s->disconnect(this);
|
||||
delete s;
|
||||
s->deleteLater();
|
||||
emit sourceRemoved(source);
|
||||
}
|
||||
}
|
||||
|
||||
@ -681,6 +682,7 @@ void DataEnginePrivate::sourceDestroyed(QObject *object)
|
||||
while (it != sources.end()) {
|
||||
if (it.value() == object) {
|
||||
sources.erase(it);
|
||||
emit q->sourceRemoved(object->objectName());
|
||||
break;
|
||||
}
|
||||
++it;
|
||||
|
110
popupapplet.cpp
110
popupapplet.cpp
@ -160,8 +160,8 @@ void PopupApplet::setWidget(QWidget *widget)
|
||||
|
||||
QGraphicsWidget *PopupApplet::graphicsWidget()
|
||||
{
|
||||
if (d->graphicsWidget != 0) {
|
||||
return d->graphicsWidget;
|
||||
if (d->graphicsWidget) {
|
||||
return d->graphicsWidget.data();
|
||||
} else {
|
||||
return static_cast<Applet*>(this)->d->extender.data();
|
||||
}
|
||||
@ -172,10 +172,12 @@ void PopupApplet::setGraphicsWidget(QGraphicsWidget *graphicsWidget)
|
||||
if (d->graphicsWidget) {
|
||||
if (d->dialogPtr) {
|
||||
d->dialogPtr.data()->setGraphicsWidget(graphicsWidget);
|
||||
} else {
|
||||
} else if (layout()) {
|
||||
QGraphicsLinearLayout *lay = static_cast<QGraphicsLinearLayout *>(layout());
|
||||
lay->removeAt(0);
|
||||
lay->addItem(graphicsWidget);
|
||||
if (graphicsWidget) {
|
||||
lay->addItem(graphicsWidget);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,8 +343,8 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints)
|
||||
q->resize(prefSize);
|
||||
emit q->appletTransformedItself();
|
||||
}
|
||||
//Applet on popup
|
||||
} else {
|
||||
//Applet on popup
|
||||
if (icon && lay) {
|
||||
lay->addItem(icon);
|
||||
}
|
||||
@ -363,56 +365,57 @@ void PopupAppletPrivate::popupConstraintsEvent(Plasma::Constraints constraints)
|
||||
delete proxy.data();
|
||||
}
|
||||
|
||||
if (!dialogPtr) {
|
||||
//save the aspect ratio mode in case we drag'n drop in the Desktop later
|
||||
savedAspectRatio = q->aspectRatioMode();
|
||||
//save the aspect ratio mode in case we drag'n drop in the Desktop later
|
||||
savedAspectRatio = q->aspectRatioMode();
|
||||
|
||||
if (icon) {
|
||||
icon->show();
|
||||
q->setAspectRatioMode(Plasma::ConstrainedSquare);
|
||||
}
|
||||
|
||||
Dialog *dialog = new Dialog();
|
||||
dialog->d->appletPtr = q;
|
||||
dialogPtr = dialog;
|
||||
|
||||
if (icon) {
|
||||
dialog->setAspectRatioMode(savedAspectRatio);
|
||||
}
|
||||
|
||||
//no longer use Qt::Popup since that seems to cause a lot of problem when you drag
|
||||
//stuff out of your Dialog (extenders). Monitor WindowDeactivate events so we can
|
||||
//emulate the same kind of behavior as Qt::Popup (close when you click somewhere
|
||||
//else.
|
||||
|
||||
if (gWidget) {
|
||||
Corona *corona = qobject_cast<Corona *>(gWidget->scene());
|
||||
|
||||
if (corona) {
|
||||
corona->addOffscreenWidget(gWidget);
|
||||
}
|
||||
|
||||
dialog->setGraphicsWidget(gWidget);
|
||||
//gWidget->resize(gWidget->preferredSize());
|
||||
dialog->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | (gWidget->windowFlags() & Qt::X11BypassWindowManagerHint));
|
||||
} else if (qWidget) {
|
||||
QVBoxLayout *l_layout = new QVBoxLayout(dialog);
|
||||
l_layout->setSpacing(0);
|
||||
l_layout->setMargin(0);
|
||||
l_layout->addWidget(qWidget);
|
||||
dialog->adjustSize();
|
||||
dialog->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | (qWidget->windowFlags() & Qt::X11BypassWindowManagerHint));
|
||||
} else {
|
||||
dialog->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
||||
}
|
||||
|
||||
restoreDialogSize();
|
||||
KWindowSystem::setState(dialog->winId(), NET::SkipTaskbar | NET::SkipPager);
|
||||
dialog->installEventFilter(q);
|
||||
|
||||
QObject::connect(dialog, SIGNAL(dialogResized()), q, SLOT(dialogSizeChanged()));
|
||||
QObject::connect(dialog, SIGNAL(dialogVisible(bool)), q, SLOT(dialogStatusChanged(bool)));
|
||||
if (icon) {
|
||||
icon->show();
|
||||
q->setAspectRatioMode(Plasma::ConstrainedSquare);
|
||||
}
|
||||
|
||||
Dialog *dialog = new Dialog();
|
||||
dialog->d->appletPtr = q;
|
||||
dialogPtr = dialog;
|
||||
|
||||
if (icon) {
|
||||
dialog->setAspectRatioMode(savedAspectRatio);
|
||||
}
|
||||
|
||||
//no longer use Qt::Popup since that seems to cause a lot of problem when you drag
|
||||
//stuff out of your Dialog (extenders). Monitor WindowDeactivate events so we can
|
||||
//emulate the same kind of behavior as Qt::Popup (close when you click somewhere
|
||||
//else.
|
||||
|
||||
if (gWidget) {
|
||||
Corona *corona = qobject_cast<Corona *>(gWidget->scene());
|
||||
if (!corona) {
|
||||
corona = qobject_cast<Corona *>(q->scene());
|
||||
}
|
||||
|
||||
if (corona) {
|
||||
corona->addOffscreenWidget(gWidget);
|
||||
}
|
||||
|
||||
gWidget->show();
|
||||
dialog->setGraphicsWidget(gWidget);
|
||||
dialog->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | (gWidget->windowFlags() & Qt::X11BypassWindowManagerHint));
|
||||
} else if (qWidget) {
|
||||
QVBoxLayout *l_layout = new QVBoxLayout(dialog);
|
||||
l_layout->setSpacing(0);
|
||||
l_layout->setMargin(0);
|
||||
l_layout->addWidget(qWidget);
|
||||
dialog->adjustSize();
|
||||
dialog->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | (qWidget->windowFlags() & Qt::X11BypassWindowManagerHint));
|
||||
} else {
|
||||
dialog->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
||||
}
|
||||
|
||||
restoreDialogSize();
|
||||
KWindowSystem::setState(dialog->winId(), NET::SkipTaskbar | NET::SkipPager);
|
||||
dialog->installEventFilter(q);
|
||||
|
||||
QObject::connect(dialog, SIGNAL(dialogResized()), q, SLOT(dialogSizeChanged()));
|
||||
QObject::connect(dialog, SIGNAL(dialogVisible(bool)), q, SLOT(dialogStatusChanged(bool)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -668,7 +671,6 @@ PopupAppletPrivate::PopupAppletPrivate(PopupApplet *applet)
|
||||
: q(applet),
|
||||
icon(0),
|
||||
widget(0),
|
||||
graphicsWidget(0),
|
||||
popupPlacement(Plasma::FloatingPopup),
|
||||
popupAlignment(Qt::AlignLeft),
|
||||
savedAspectRatio(Plasma::InvalidAspectRatioMode),
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
QWeakPointer<Plasma::Dialog> dialogPtr;
|
||||
QWeakPointer<QGraphicsProxyWidget>proxy;
|
||||
QWidget *widget;
|
||||
QGraphicsWidget *graphicsWidget;
|
||||
QWeakPointer<QGraphicsWidget> graphicsWidget;
|
||||
Plasma::PopupPlacement popupPlacement;
|
||||
Qt::AlignmentFlag popupAlignment;
|
||||
Plasma::AspectRatioMode savedAspectRatio;
|
||||
|
@ -56,6 +56,9 @@ public:
|
||||
m_toolTip(parent),
|
||||
m_document(new QTextDocument(this))
|
||||
{
|
||||
QTextOption option = m_document->defaultTextOption();
|
||||
option.setWrapMode(QTextOption::WordWrap);
|
||||
m_document->setDefaultTextOption(option);
|
||||
}
|
||||
|
||||
void setStyleSheet(const QString &css)
|
||||
@ -66,8 +69,13 @@ public:
|
||||
void setContent(const ToolTipContent &data)
|
||||
{
|
||||
QString html;
|
||||
if (!data.mainText().isEmpty()) {
|
||||
html.append("<div><b>" + data.mainText() + "</b></div>");
|
||||
QString mainText = data.mainText();
|
||||
if (!mainText.isEmpty()) {
|
||||
if (mainText.size() < 50) {
|
||||
// don't let short texts wrap on us!
|
||||
mainText = mainText.replace(" ", " ");
|
||||
}
|
||||
html.append("<div align=\"center\"><b>" + mainText + "</b></div>");
|
||||
}
|
||||
html.append(data.subText());
|
||||
|
||||
@ -76,28 +84,18 @@ public:
|
||||
data.registerResources(m_document);
|
||||
if (!html.isEmpty()) {
|
||||
m_document->setHtml("<p>" + html + "</p>");
|
||||
} else {
|
||||
m_document->clear();
|
||||
}
|
||||
m_document->adjustSize();
|
||||
|
||||
m_haloRects.clear();
|
||||
QTextLayout *layout = m_document->begin().layout();
|
||||
//layout->setPosition(QPointF(textRect.x(), textBoundingRect->y()));
|
||||
QTextLine line;
|
||||
for (int i = 0; i < layout->lineCount(); ++i) {
|
||||
line = layout->lineAt(i);
|
||||
|
||||
// Add halo rect only when a non empty line is found
|
||||
if (line.naturalTextWidth()) {
|
||||
m_haloRects.append(line.naturalTextRect().translated(layout->position().toPoint()).toRect().translated(m_margin, m_margin));
|
||||
}
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
QSize minimumSizeHint() const
|
||||
{
|
||||
return m_document->size().toSize() + QSize(m_margin, m_margin)*2;
|
||||
const int margin = 6;
|
||||
return m_document->size().toSize() + QSize(margin, margin)*2;
|
||||
}
|
||||
|
||||
QSize maximumSizeHint() const
|
||||
@ -108,14 +106,6 @@ public:
|
||||
void paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter p(this);
|
||||
|
||||
if (Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor).value() < 128) {
|
||||
foreach (const QRectF &rect, m_haloRects) {
|
||||
Plasma::PaintUtils::drawHalo(&p, rect);
|
||||
}
|
||||
|
||||
p.translate(m_margin, m_margin);
|
||||
}
|
||||
m_document->drawContents(&p, event->rect());
|
||||
}
|
||||
|
||||
@ -145,8 +135,6 @@ private:
|
||||
ToolTip *m_toolTip;
|
||||
QTextDocument *m_document;
|
||||
QString m_anchor;
|
||||
QList<QRectF> m_haloRects;
|
||||
static const int m_margin = 6;
|
||||
};
|
||||
|
||||
class ToolTipPrivate
|
||||
@ -179,8 +167,8 @@ ToolTip::ToolTip(QWidget *parent)
|
||||
d->preview = new WindowPreview(this);
|
||||
d->text = new TipTextWidget(this);
|
||||
d->imageLabel = new QLabel(this);
|
||||
d->imageLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
||||
|
||||
d->imageLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
|
||||
d->animation = new QPropertyAnimation(this, "pos", this);
|
||||
d->animation->setEasingCurve(QEasingCurve::InOutQuad);
|
||||
d->animation->setDuration(250);
|
||||
@ -198,7 +186,7 @@ ToolTip::ToolTip(QWidget *parent)
|
||||
|
||||
QHBoxLayout *iconTextHBoxLayout = new QHBoxLayout;
|
||||
iconTextHBoxLayout->addWidget(d->imageLabel);
|
||||
iconTextHBoxLayout->setAlignment(d->imageLabel, Qt::AlignCenter);
|
||||
iconTextHBoxLayout->setAlignment(d->imageLabel, Qt::AlignTop | Qt::AlignHCenter);
|
||||
iconTextHBoxLayout->addWidget(d->text);
|
||||
iconTextHBoxLayout->setAlignment(d->text, Qt::AlignLeft | Qt::AlignVCenter);
|
||||
iconTextHBoxLayout->setStretchFactor(d->text, 1);
|
||||
@ -300,7 +288,12 @@ void ToolTip::setContent(QObject *tipper, const ToolTipContent &data)
|
||||
{
|
||||
//reset our size
|
||||
d->text->setContent(data);
|
||||
d->imageLabel->setPixmap(data.image());
|
||||
if (data.image().isNull()) {
|
||||
d->imageLabel->hide();
|
||||
} else {
|
||||
d->imageLabel->show();
|
||||
d->imageLabel->setPixmap(data.image());
|
||||
}
|
||||
|
||||
if (data.highlightWindows() && !data.windowsToPreview().isEmpty()) {
|
||||
WindowEffects::highlightWindows(winId(), QList<WId>() << winId() << data.windowsToPreview());
|
||||
|
@ -99,7 +99,7 @@ void slideWindow(WId id, Plasma::Location location, int offset)
|
||||
#ifdef Q_WS_X11
|
||||
Display *dpy = QX11Info::display();
|
||||
Atom atom = XInternAtom( dpy, "_KDE_SLIDE", False );
|
||||
QVarLengthArray<long, 1024> data(2);
|
||||
QVarLengthArray<long, 2> data(2);
|
||||
|
||||
data[0] = offset;
|
||||
|
||||
@ -133,7 +133,7 @@ void slideWindow(QWidget *widget, Plasma::Location location)
|
||||
#ifdef Q_WS_X11
|
||||
Display *dpy = QX11Info::display();
|
||||
Atom atom = XInternAtom( dpy, "_KDE_SLIDE", False );
|
||||
QVarLengthArray<long, 1024> data(2);
|
||||
QVarLengthArray<long, 2> data(2);
|
||||
|
||||
switch (location) {
|
||||
case LeftEdge:
|
||||
@ -197,7 +197,8 @@ void showWindowThumbnails(WId parent, const QList<WId> &windows, const QList<QRe
|
||||
|
||||
int numWindows = windows.size();
|
||||
|
||||
QVarLengthArray<long, 1024> data(1 + (6 * numWindows));
|
||||
// 64 is enough for 10 windows and is a nice base 2 number
|
||||
QVarLengthArray<long, 64> data(1 + (6 * numWindows));
|
||||
data[0] = numWindows;
|
||||
|
||||
QList<WId>::const_iterator windowsIt;
|
||||
@ -252,7 +253,7 @@ void presentWindows(WId controller, const QList<WId> &ids)
|
||||
void presentWindows(WId controller, int desktop)
|
||||
{
|
||||
#ifdef Q_WS_X11
|
||||
QVarLengthArray<long, 32> data(1);
|
||||
QVarLengthArray<long, 1> data(1);
|
||||
data[0] = desktop;
|
||||
Display *dpy = QX11Info::display();
|
||||
Atom atom = XInternAtom(dpy, "_KDE_PRESENT_WINDOWS_DESKTOP", False);
|
||||
@ -298,12 +299,11 @@ void overrideShadow(WId window, bool override)
|
||||
#ifdef Q_WS_X11
|
||||
Display *dpy = QX11Info::display();
|
||||
Atom atom = XInternAtom( dpy, "_KDE_SHADOW_OVERRIDE", False );
|
||||
QVarLengthArray<long, 1024> data(1);
|
||||
data[0] = 1;
|
||||
|
||||
if (!override) {
|
||||
XDeleteProperty(dpy, window, atom);
|
||||
} else {
|
||||
QVarLengthArray<long, 1> data(1);
|
||||
data[0] = 1;
|
||||
XChangeProperty(dpy, window, atom, atom, 32, PropModeReplace,
|
||||
reinterpret_cast<unsigned char *>(data.data()), data.size());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user