Port add/remove buttons in DesktopGrid to QtQuick 2

With this change we no longer need to link QtDeclarative in the Effects.
This commit is contained in:
Martin Gräßlin 2013-08-05 14:55:37 +02:00
parent 47cf35720f
commit 7bd86505f5
4 changed files with 19 additions and 31 deletions

View file

@ -12,7 +12,6 @@ set(kwin_effect_KDE_LIBS
)
set(kwin_effect_QT_LIBS
${Qt5Declarative_LIBRARIES}
${Qt5Quick_LIBRARIES}
${Qt5X11Extras_LIBRARIES}
${Qt5DBus_LIBRARIES}

View file

@ -34,15 +34,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KDE/KGlobal>
#include <KDE/KLocalizedString>
#include <KDE/KStandardDirs>
#include <kdeclarative.h>
#include <netwm_def.h>
#include <QEvent>
#include <QMouseEvent>
#include <kglobalsettings.h>
#include <QtGui/QVector2D>
#include <QDeclarativeEngine>
#include <QDeclarativeContext>
#include <QGraphicsObject>
#include <QQmlContext>
#include <QQmlEngine>
#include <QQuickItem>
namespace KWin
{
@ -1117,9 +1116,9 @@ void DesktopGridEffect::setup()
connect(view, SIGNAL(addDesktop()), SLOT(slotAddDesktop()));
connect(view, SIGNAL(removeDesktop()), SLOT(slotRemoveDesktop()));
const QRect screenRect = effects->clientArea(FullScreenArea, i, 1);
view->setGeometry(screenRect.right() + 1 - view->sceneRect().width(),
screenRect.bottom() + 1 - view->sceneRect().height(),
view->sceneRect().width(), view->sceneRect().height());
view->setGeometry(screenRect.right() + 1 - view->width(),
screenRect.bottom() + 1 - view->height(),
view->width(), view->height());
view->show();
m_desktopButtonsViews.insert(view, NULL);
}
@ -1382,24 +1381,11 @@ bool DesktopGridEffect::isRelevantWithPresentWindows(EffectWindow *w) const
/************************************************
* DesktopButtonView
************************************************/
DesktopButtonsView::DesktopButtonsView(QWidget *parent)
: QDeclarativeView(parent)
DesktopButtonsView::DesktopButtonsView(QWindow *parent)
: QQuickView(parent)
{
setWindowFlags(Qt::X11BypassWindowManagerHint);
setAttribute(Qt::WA_TranslucentBackground);
QPalette pal = palette();
pal.setColor(backgroundRole(), Qt::transparent);
setPalette(pal);
for (const QString &importPath : KGlobal::dirs()->findDirs("module", QStringLiteral("imports"))) {
engine()->addImportPath(importPath);
}
#warning Port declarative code to QtQuick2
#if KWIN_QT5_PORTING
KDeclarative kdeclarative;
kdeclarative.setDeclarativeEngine(engine());
kdeclarative.initialize();
kdeclarative.setupBindings();
#endif
setFlags(Qt::X11BypassWindowManagerHint);
setColor(Qt::transparent);
rootContext()->setContextProperty(QStringLiteral("add"), QVariant(true));
rootContext()->setContextProperty(QStringLiteral("remove"), QVariant(true));

View file

@ -25,19 +25,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <kwineffects.h>
#include <kshortcut.h>
#include <QObject>
#include <QDeclarativeView>
#include <QTimeLine>
#include <QQuickView>
namespace KWin
{
class PresentWindowsEffectProxy;
class DesktopButtonsView : public QDeclarativeView
class DesktopButtonsView : public QQuickView
{
Q_OBJECT
public:
explicit DesktopButtonsView(QWidget *parent = 0);
explicit DesktopButtonsView(QWindow *parent = 0);
void windowInputMouseEvent(QMouseEvent* e);
void setAddDesktopEnabled(bool enable);
void setRemoveDesktopEnabled(bool enable);

View file

@ -17,13 +17,16 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
import QtQuick 1.1
import org.kde.plasma.components 0.1 as Plasma
import QtQuick 2.0
import org.kde.plasma.components 2.0 as Plasma
Item {
width: childrenRect.width
height: childrenRect.height
Plasma.ButtonRow {
anchors.fill: parent
exclusive: false
width: childrenRect.width
height: childrenRect.height
Plasma.Button {
id: removeButton
objectName: "removeButton"