Merge branch 'master' into plasma/declarative

This commit is contained in:
Sebastian Kügler 2011-03-28 17:55:01 +02:00
commit 4081aea62b
13 changed files with 84 additions and 46 deletions

View File

@ -39,10 +39,15 @@ public:
void setDeclarativeItem(QDeclarativeItem *item)
{
if (m_declarativeItem) {
m_declarativeItem.data()->removeSceneEventFilter(this);
}
m_declarativeItem = item;
static_cast<QGraphicsItem *>(item)->setParentItem(this);
setMinimumWidth(item->implicitWidth());
setMinimumHeight(item->implicitHeight());
resize(item->width(), item->height());
item->installSceneEventFilter(this);
}
QDeclarativeItem *declarativeItem() const
@ -59,6 +64,15 @@ protected:
}
}
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event)
{
if (event->type() == QEvent::GraphicsSceneResize) {
resize(watched->boundingRect().size());
}
return QGraphicsWidget::sceneEventFilter(watched, event);
}
private:
QWeakPointer<QDeclarativeItem> m_declarativeItem;
};
@ -67,6 +81,7 @@ DialogProxy::DialogProxy(QObject *parent)
: QObject(parent)
{
m_dialog = new Plasma::Dialog();
m_flags = m_dialog->windowFlags();
}
DialogProxy::~DialogProxy()
@ -146,22 +161,22 @@ void DialogProxy::setVisible(const bool visible)
{
if (m_dialog->isVisible() != visible) {
m_dialog->setVisible(visible);
if (visible) {
m_dialog->setWindowFlags(m_flags);
m_dialog->raise();
}
emit visibleChanged();
}
}
void DialogProxy::showPopup(QGraphicsObject *item)
QPoint DialogProxy::popupPosition(QGraphicsObject *item) const
{
if (m_dialog->isVisible()) {
m_dialog->hide();
} else {
Plasma::Corona *corona = qobject_cast<Plasma::Corona *>(item->scene());
if (corona) {
m_dialog->move(corona->popupPosition(item, m_dialog->size()));
return corona->popupPosition(item, m_dialog->size());
} else {
return QPoint();
}
m_dialog->show();
}
emit visibleChanged();
}
@ -185,6 +200,17 @@ void DialogProxy::setY(int y)
m_dialog->move(m_dialog->pos().x(), y);
}
int DialogProxy::windowFlags() const
{
return (int)m_dialog->windowFlags();
}
void DialogProxy::setWindowFlags(const int flags)
{
m_flags = (Qt::WindowFlags)flags;
m_dialog->setWindowFlags((Qt::WindowFlags)flags);
}
bool DialogProxy::eventFilter(QObject *watched, QEvent *event)
{
if (watched == m_dialog && event->type() == QEvent::Move) {

View File

@ -21,6 +21,7 @@
#include <QObject>
#include <QWeakPointer>
#include <QPoint>
class QGraphicsObject;
@ -39,6 +40,7 @@ class DialogProxy : public QObject
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
Q_PROPERTY(int x READ x WRITE setX NOTIFY positionChanged)
Q_PROPERTY(int y READ y WRITE setY NOTIFY positionChanged)
Q_PROPERTY(int windowFlags READ windowFlags WRITE setWindowFlags)
public:
enum WidgetAttribute {
@ -60,7 +62,11 @@ public:
int y() const;
void setY(int y);
Q_INVOKABLE void showPopup(QGraphicsObject *item);
//FIXME: passing an int is ugly
int windowFlags() const;
void setWindowFlags(const int);
Q_INVOKABLE QPoint popupPosition(QGraphicsObject *item) const;
//FIXME:: Qt::WidgetAttribute should be already
Q_INVOKABLE void setAttribute(int attribute, bool on);
@ -77,6 +83,7 @@ protected:
private:
Plasma::Dialog *m_dialog;
Qt::WindowFlags m_flags;
DeclarativeItemContainer *m_declarativeItemContainer;
QWeakPointer<QGraphicsObject> m_mainItem;
};

View File

@ -71,6 +71,7 @@ FrameSvgItem::~FrameSvgItem()
void FrameSvgItem::setImagePath(const QString &path)
{
m_frameSvg->setImagePath(path);
m_frameSvg->setElementPrefix(m_prefix);
update();
}
@ -83,12 +84,13 @@ QString FrameSvgItem::imagePath() const
void FrameSvgItem::setPrefix(const QString &prefix)
{
m_frameSvg->setElementPrefix(prefix);
m_prefix = prefix;
update();
}
QString FrameSvgItem::prefix() const
{
return m_frameSvg->prefix();
return m_prefix;
}
FrameSvgItemMargins *FrameSvgItem::margins() const

View File

@ -88,6 +88,7 @@ private Q_SLOTS:
private:
Plasma::FrameSvg *m_frameSvg;
FrameSvgItemMargins *m_margins;
QString m_prefix;
};
}

View File

@ -69,7 +69,7 @@ void SvgItem::setSvg(Plasma::Svg *svg)
disconnect(m_svg.data(), 0, this, 0);
}
m_svg = svg;
connect(svg, SIGNAL(repaintNeeded()), this, SLOT(update()));
connect(svg, SIGNAL(repaintNeeded()), this, SLOT(updateNeeded()));
connect(svg, SIGNAL(repaintNeeded()), this, SIGNAL(naturalSizeChanged()));
connect(svg, SIGNAL(sizeChanged()), this, SIGNAL(naturalSizeChanged()));
emit naturalSizeChanged();
@ -115,6 +115,11 @@ void SvgItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
painter->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothTransform);
}
void SvgItem::updateNeeded()
{
update();
}
} // Plasma namespace
#include "svgitem_p.moc"

View File

@ -54,6 +54,9 @@ public:
Q_SIGNALS:
void naturalSizeChanged();
protected Q_SLOTS:
void updateNeeded();
private:
QWeakPointer<Plasma::Svg> m_svg;
QString m_elementID;

View File

@ -2,7 +2,7 @@
* Copyright 2009 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*

View File

@ -2,7 +2,7 @@
* Copyright 2009 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*

View File

@ -373,6 +373,15 @@ Plasma::Extender *AppletInterface::extender() const
return m_appletScriptEngine->extender();
}
void AppletInterface::setAssociatedApplication(const QString &string)
{
applet()->setAssociatedApplication(string);
}
QString AppletInterface::associatedApplication() const
{
return applet()->associatedApplication();
}
void AppletInterface::gc()
{

View File

@ -77,6 +77,7 @@ class AppletInterface : public QObject
Q_PROPERTY(int apiVersion READ apiVersion CONSTANT)
Q_PROPERTY(QRectF rect READ rect)
Q_PROPERTY(QSizeF size READ size)
Q_PROPERTY(QString associatedApplication WRITE setAssociatedApplication READ associatedApplication)
public:
AppletInterface(AbstractJsAppletScript *parent);
@ -285,6 +286,9 @@ enum IntervalAlignment {
static AppletInterface *extract(QScriptEngine *engine);
inline Plasma::Applet *applet() const { return m_appletScriptEngine->applet(); }
void setAssociatedApplication(const QString &string);
QString associatedApplication() const;
Q_SIGNALS:
void releaseVisualFocus();
void configNeedsSaving();

View File

@ -1,39 +1,20 @@
/****************************************************************************
**
** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
** This file is part of the Qt Script Generator.
**
** This file is part of the plugins of the Qt Toolkit.
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** This file may be used under the terms of the GNU General Public
** License version 2.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of
** this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/
** Contact: Nokia Corporation info@qt.nokia.com
**
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** In addition, as a special exception, Trolltech gives you certain
** additional rights. These rights are described in the Trolltech GPL
** Exception version 1.0, which can be found at
** http://www.trolltech.com/products/qt/gplexception/ and in the file
** GPL_EXCEPTION.txt in this package.
**
** In addition, as a special exception, Trolltech, as the sole copyright
** holder for Qt Designer, grants users of the Qt/Eclipse Integration
** plug-in the right for the Qt/Eclipse Integration to link to
** functionality provided by Qt Designer and its related libraries.
**
** Trolltech reserves all rights not expressly granted herein.
**
** Trolltech ASA (c) 2007
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging of
** this file. Please review the following information to ensure the GNU
** Lesser General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** Copyright (C) 2011 Nokia. All rights reserved
****************************************************************************/
#ifndef QTSCRIPTEXTENSIONS_GLOBAL_H
#define QTSCRIPTEXTENSIONS_GLOBAL_H

View File

@ -2,7 +2,7 @@
* Copyright 2009 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*

View File

@ -2,7 +2,7 @@
* Copyright 2009 Aaron Seigo <aseigo@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*