2011-10-30 15:07:14 +00:00
|
|
|
/********************************************************************
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
|
|
|
|
|
|
|
Copyright (C) 2011 Martin Gräßlin <mgraesslin@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 published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
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/>.
|
|
|
|
*********************************************************************/
|
|
|
|
// own
|
|
|
|
#include "declarative.h"
|
|
|
|
#include "tabboxhandler.h"
|
|
|
|
#include "clientmodel.h"
|
|
|
|
// Qt
|
2013-08-06 08:27:49 +00:00
|
|
|
#include <QApplication>
|
2013-09-02 11:14:39 +00:00
|
|
|
#include <QDebug>
|
2013-08-08 11:09:11 +00:00
|
|
|
#include <QtQml/QQmlContext>
|
|
|
|
#include <QtQml/QQmlEngine>
|
2013-02-26 08:00:51 +00:00
|
|
|
#include <QDesktopWidget>
|
2013-08-08 11:09:11 +00:00
|
|
|
#include <QPainter>
|
2011-10-30 15:07:14 +00:00
|
|
|
#include <QtGui/QResizeEvent>
|
2013-08-08 11:09:11 +00:00
|
|
|
#include <QQuickItem>
|
2011-12-15 16:47:23 +00:00
|
|
|
#include <QX11Info>
|
2013-08-03 20:33:50 +00:00
|
|
|
#include <QtCore/QStandardPaths>
|
2011-12-15 16:47:23 +00:00
|
|
|
|
2011-10-30 15:07:14 +00:00
|
|
|
// include KDE
|
2012-02-12 14:15:54 +00:00
|
|
|
#include <KDE/KServiceTypeTrader>
|
2011-10-30 15:07:14 +00:00
|
|
|
#include <KDE/Plasma/FrameSvg>
|
|
|
|
#include <KDE/Plasma/Theme>
|
2013-07-22 14:09:18 +00:00
|
|
|
#include <kwindoweffects.h>
|
2013-08-06 01:03:57 +00:00
|
|
|
#include <kdeclarative/kdeclarative.h>
|
2011-11-10 13:28:06 +00:00
|
|
|
// KWin
|
|
|
|
#include "thumbnailitem.h"
|
2011-12-01 07:48:18 +00:00
|
|
|
#include <kwindowsystem.h>
|
2013-01-16 13:50:43 +00:00
|
|
|
#include "../effects.h"
|
2012-02-21 22:06:15 +00:00
|
|
|
#include "../client.h"
|
|
|
|
#include "../workspace.h"
|
2011-10-30 15:07:14 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
namespace TabBox
|
|
|
|
{
|
|
|
|
|
2013-08-08 11:09:11 +00:00
|
|
|
DeclarativeView::DeclarativeView(QAbstractItemModel *model, TabBoxConfig::TabBoxMode mode, QQuickWindow *parent)
|
|
|
|
: QQuickView(parent)
|
2011-10-30 15:07:14 +00:00
|
|
|
, m_model(model)
|
2012-01-14 10:24:42 +00:00
|
|
|
, m_mode(mode)
|
2011-10-30 15:07:14 +00:00
|
|
|
, m_currentScreenGeometry()
|
|
|
|
, m_frame(new Plasma::FrameSvg(this))
|
|
|
|
, m_currentLayout()
|
2011-12-01 07:48:18 +00:00
|
|
|
, m_cachedWidth(0)
|
|
|
|
, m_cachedHeight(0)
|
2011-10-30 15:07:14 +00:00
|
|
|
{
|
2013-08-08 11:09:11 +00:00
|
|
|
setColor(Qt::transparent);
|
|
|
|
setFlags(Qt::X11BypassWindowManagerHint);
|
2011-12-01 07:48:18 +00:00
|
|
|
if (tabBox->embedded()) {
|
2013-08-08 11:09:11 +00:00
|
|
|
setResizeMode(QQuickView::SizeRootObjectToView);
|
2011-12-01 07:48:18 +00:00
|
|
|
} else {
|
2013-08-08 11:09:11 +00:00
|
|
|
setResizeMode(QQuickView::SizeViewToRootObject);
|
2011-12-01 07:48:18 +00:00
|
|
|
}
|
2011-10-30 15:07:14 +00:00
|
|
|
KDeclarative kdeclarative;
|
|
|
|
kdeclarative.setDeclarativeEngine(engine());
|
|
|
|
kdeclarative.initialize();
|
|
|
|
kdeclarative.setupBindings();
|
2012-03-29 18:17:57 +00:00
|
|
|
#ifndef TABBOX_KCM
|
|
|
|
qmlRegisterType<DesktopThumbnailItem>("org.kde.kwin", 0, 1, "DesktopThumbnailItem");
|
|
|
|
#endif
|
2012-03-29 13:46:53 +00:00
|
|
|
qmlRegisterType<WindowThumbnailItem>("org.kde.kwin", 0, 1, "ThumbnailItem");
|
2013-07-23 05:02:52 +00:00
|
|
|
rootContext()->setContextProperty(QStringLiteral("viewId"), static_cast<qulonglong>(winId()));
|
2012-01-14 10:24:42 +00:00
|
|
|
if (m_mode == TabBoxConfig::ClientTabBox) {
|
2013-07-23 05:02:52 +00:00
|
|
|
rootContext()->setContextProperty(QStringLiteral("clientModel"), model);
|
2012-01-14 10:24:42 +00:00
|
|
|
} else if (m_mode == TabBoxConfig::DesktopTabBox) {
|
2013-07-23 05:02:52 +00:00
|
|
|
rootContext()->setContextProperty(QStringLiteral("clientModel"), model);
|
2012-01-14 10:24:42 +00:00
|
|
|
}
|
2013-08-03 20:33:50 +00:00
|
|
|
setSource(QUrl(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String(KWIN_NAME) + QLatin1String("/tabbox/tabbox.qml"))));
|
2011-10-30 15:07:14 +00:00
|
|
|
|
|
|
|
// FrameSvg
|
2013-07-23 05:02:52 +00:00
|
|
|
m_frame->setImagePath(QStringLiteral("dialogs/background"));
|
2011-10-30 15:07:14 +00:00
|
|
|
m_frame->setCacheAllRenderedFrames(true);
|
|
|
|
m_frame->setEnabledBorders(Plasma::FrameSvg::AllBorders);
|
|
|
|
|
|
|
|
connect(tabBox, SIGNAL(configChanged()), SLOT(updateQmlSource()));
|
2012-01-14 10:24:42 +00:00
|
|
|
if (m_mode == TabBoxConfig::ClientTabBox) {
|
|
|
|
connect(tabBox, SIGNAL(embeddedChanged(bool)), SLOT(slotEmbeddedChanged(bool)));
|
|
|
|
}
|
2011-10-30 15:07:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DeclarativeView::showEvent(QShowEvent *event)
|
|
|
|
{
|
2012-02-21 22:06:15 +00:00
|
|
|
#ifndef TABBOX_KCM
|
2011-12-01 07:48:18 +00:00
|
|
|
if (tabBox->embedded()) {
|
2012-02-21 22:06:15 +00:00
|
|
|
Client *c = Workspace::self()->findClient(WindowMatchPredicate(tabBox->embedded()));
|
|
|
|
if (c) {
|
|
|
|
connect(c, SIGNAL(geometryChanged()), this, SLOT(slotUpdateGeometry()));
|
|
|
|
}
|
2011-12-01 07:48:18 +00:00
|
|
|
}
|
2012-02-21 22:06:15 +00:00
|
|
|
#endif
|
2011-11-04 19:08:23 +00:00
|
|
|
updateQmlSource();
|
2012-03-27 17:14:53 +00:00
|
|
|
m_currentScreenGeometry = QApplication::desktop()->screenGeometry(tabBox->activeScreen());
|
2011-10-30 15:07:14 +00:00
|
|
|
rootObject()->setProperty("screenWidth", m_currentScreenGeometry.width());
|
|
|
|
rootObject()->setProperty("screenHeight", m_currentScreenGeometry.height());
|
|
|
|
rootObject()->setProperty("allDesktops", tabBox->config().tabBoxMode() == TabBoxConfig::ClientTabBox &&
|
2012-03-04 18:24:13 +00:00
|
|
|
tabBox->config().clientDesktopMode() == TabBoxConfig::AllDesktopsClients);
|
2012-01-14 10:24:42 +00:00
|
|
|
if (ClientModel *clientModel = qobject_cast<ClientModel*>(m_model)) {
|
|
|
|
rootObject()->setProperty("longestCaption", clientModel->longestCaption());
|
|
|
|
}
|
2011-10-30 15:07:14 +00:00
|
|
|
|
2013-07-23 05:02:52 +00:00
|
|
|
if (QObject *item = rootObject()->findChild<QObject*>(QStringLiteral("listView"))) {
|
2011-10-30 15:07:14 +00:00
|
|
|
item->setProperty("currentIndex", tabBox->first().row());
|
2011-10-31 13:34:37 +00:00
|
|
|
connect(item, SIGNAL(currentIndexChanged(int)), SLOT(currentIndexChanged(int)));
|
2011-10-30 15:07:14 +00:00
|
|
|
}
|
|
|
|
slotUpdateGeometry();
|
2013-02-13 21:14:29 +00:00
|
|
|
QResizeEvent re(size(), size()); // to set mask and blurring.
|
|
|
|
resizeEvent(&re);
|
2013-08-08 11:09:11 +00:00
|
|
|
QQuickView::showEvent(event);
|
2011-10-30 15:07:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DeclarativeView::resizeEvent(QResizeEvent *event)
|
|
|
|
{
|
2013-01-10 07:55:08 +00:00
|
|
|
if (tabBox->embedded()) {
|
2013-07-22 14:09:18 +00:00
|
|
|
KWindowEffects::enableBlurBehind(winId(), false);
|
2011-10-30 15:07:14 +00:00
|
|
|
} else {
|
2013-01-10 07:55:08 +00:00
|
|
|
const QString maskImagePath = rootObject()->property("maskImagePath").toString();
|
|
|
|
if (maskImagePath.isEmpty()) {
|
2013-07-22 14:09:18 +00:00
|
|
|
KWindowEffects::enableBlurBehind(winId(), false);
|
2013-01-10 07:55:08 +00:00
|
|
|
} else {
|
|
|
|
const double maskWidth = rootObject()->property("maskWidth").toDouble();
|
|
|
|
const double maskHeight = rootObject()->property("maskHeight").toDouble();
|
|
|
|
const int maskTopMargin = rootObject()->property("maskTopMargin").toInt();
|
|
|
|
const int maskLeftMargin = rootObject()->property("maskLeftMargin").toInt();
|
|
|
|
m_frame->setImagePath(maskImagePath);
|
|
|
|
m_frame->resizeFrame(QSizeF(maskWidth, maskHeight));
|
|
|
|
QRegion mask = m_frame->mask().translated(maskLeftMargin, maskTopMargin);
|
2013-02-13 21:14:29 +00:00
|
|
|
#ifndef TABBOX_KCM
|
|
|
|
// notice: this covers an issue with plasma detecting the compositing state. see plasmaThemeVariant()
|
|
|
|
if (Workspace::self()->compositing() && effects) {
|
|
|
|
// blur background?!
|
2013-07-22 14:09:18 +00:00
|
|
|
KWindowEffects::enableBlurBehind(winId(), static_cast<EffectsHandlerImpl*>(effects)->provides(Effect::Blur), mask);
|
2013-02-13 21:14:29 +00:00
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
2013-01-10 07:55:08 +00:00
|
|
|
// do not trim to mask with compositing enabled, otherwise shadows are cropped
|
|
|
|
setMask(mask);
|
|
|
|
}
|
|
|
|
}
|
2011-10-30 15:07:14 +00:00
|
|
|
}
|
2013-08-08 11:09:11 +00:00
|
|
|
QQuickView::resizeEvent(event);
|
2011-10-30 15:07:14 +00:00
|
|
|
}
|
|
|
|
|
2011-12-01 07:48:18 +00:00
|
|
|
void DeclarativeView::hideEvent(QHideEvent *event)
|
|
|
|
{
|
2013-08-08 11:09:11 +00:00
|
|
|
QQuickView::hideEvent(event);
|
2012-02-21 22:06:15 +00:00
|
|
|
#ifndef TABBOX_KCM
|
2011-12-01 07:48:18 +00:00
|
|
|
if (tabBox->embedded()) {
|
2012-02-21 22:06:15 +00:00
|
|
|
Client *c = Workspace::self()->findClient(WindowMatchPredicate(tabBox->embedded()));
|
|
|
|
if (c) {
|
|
|
|
disconnect(c, SIGNAL(geometryChanged()), this, SLOT(slotUpdateGeometry()));
|
|
|
|
}
|
2011-12-01 07:48:18 +00:00
|
|
|
}
|
2012-02-21 22:06:15 +00:00
|
|
|
#endif
|
2011-12-01 07:48:18 +00:00
|
|
|
}
|
|
|
|
|
2013-07-23 05:08:08 +00:00
|
|
|
#if KWIN_QT5_PORTING
|
2011-12-15 16:47:23 +00:00
|
|
|
bool DeclarativeView::x11Event(XEvent *e)
|
|
|
|
{
|
|
|
|
if (tabBox->embedded() &&
|
|
|
|
(e->type == ButtonPress || e->type == ButtonRelease || e->type == MotionNotify)) {
|
|
|
|
XEvent ev;
|
|
|
|
|
|
|
|
memcpy(&ev, e, sizeof(ev));
|
|
|
|
if (e->type == ButtonPress || e->type == ButtonRelease) {
|
|
|
|
ev.xbutton.x += m_relativePos.x();
|
|
|
|
ev.xbutton.y += m_relativePos.y();
|
|
|
|
ev.xbutton.window = tabBox->embedded();
|
|
|
|
} else if (e->type == MotionNotify) {
|
|
|
|
ev.xmotion.x += m_relativePos.x();
|
|
|
|
ev.xmotion.y += m_relativePos.y();
|
|
|
|
ev.xmotion.window = tabBox->embedded();
|
|
|
|
}
|
|
|
|
|
|
|
|
XSendEvent( QX11Info::display(), tabBox->embedded(), False, NoEventMask, &ev );
|
|
|
|
}
|
|
|
|
return QDeclarativeView::x11Event(e);
|
|
|
|
}
|
2013-07-23 05:08:08 +00:00
|
|
|
#endif
|
2011-12-15 16:47:23 +00:00
|
|
|
|
2011-10-30 15:07:14 +00:00
|
|
|
void DeclarativeView::slotUpdateGeometry()
|
|
|
|
{
|
2011-12-01 07:48:18 +00:00
|
|
|
const WId embeddedId = tabBox->embedded();
|
|
|
|
if (embeddedId != 0) {
|
|
|
|
const KWindowInfo info = KWindowSystem::windowInfo(embeddedId, NET::WMGeometry);
|
|
|
|
const Qt::Alignment alignment = tabBox->embeddedAlignment();
|
|
|
|
const QPoint offset = tabBox->embeddedOffset();
|
|
|
|
int x = info.geometry().left();
|
|
|
|
int y = info.geometry().top();
|
|
|
|
int width = tabBox->embeddedSize().width();
|
|
|
|
int height = tabBox->embeddedSize().height();
|
|
|
|
if (alignment.testFlag(Qt::AlignLeft) || alignment.testFlag(Qt::AlignHCenter)) {
|
|
|
|
x += offset.x();
|
|
|
|
}
|
|
|
|
if (alignment.testFlag(Qt::AlignRight)) {
|
|
|
|
x = x + info.geometry().width() - offset.x() - width;
|
|
|
|
}
|
|
|
|
if (alignment.testFlag(Qt::AlignHCenter)) {
|
|
|
|
width = info.geometry().width() - 2 * offset.x();
|
|
|
|
}
|
|
|
|
if (alignment.testFlag(Qt::AlignTop) || alignment.testFlag(Qt::AlignVCenter)) {
|
|
|
|
y += offset.y();
|
|
|
|
}
|
|
|
|
if (alignment.testFlag(Qt::AlignBottom)) {
|
|
|
|
y = y + info.geometry().height() - offset.y() - height;
|
|
|
|
}
|
|
|
|
if (alignment.testFlag(Qt::AlignVCenter)) {
|
|
|
|
height = info.geometry().height() - 2 * offset.y();
|
|
|
|
}
|
|
|
|
setGeometry(QRect(x, y, width, height));
|
2011-12-15 16:47:23 +00:00
|
|
|
|
|
|
|
m_relativePos = QPoint(info.geometry().x(), info.geometry().x());
|
2011-12-01 07:48:18 +00:00
|
|
|
} else {
|
|
|
|
const int width = rootObject()->property("width").toInt();
|
|
|
|
const int height = rootObject()->property("height").toInt();
|
2013-11-05 10:26:29 +00:00
|
|
|
|
|
|
|
Qt::Alignment alignment = Qt::AlignCenter;
|
|
|
|
|
|
|
|
if (rootObject()->property("alignment").canConvert<int>()) {
|
|
|
|
alignment = (Qt::Alignment)rootObject()->property("alignment").toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
|
|
|
|
if (alignment & Qt::AlignLeft) {
|
|
|
|
x = m_currentScreenGeometry.x();
|
2013-11-05 11:17:33 +00:00
|
|
|
} else if (alignment & Qt::AlignRight) {
|
2013-11-05 10:26:29 +00:00
|
|
|
x = m_currentScreenGeometry.right() - width;
|
|
|
|
//Center
|
|
|
|
} else {
|
|
|
|
x = m_currentScreenGeometry.x() + static_cast<qreal>(m_currentScreenGeometry.width()) * 0.5 - static_cast<qreal>(width) * 0.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (alignment & Qt::AlignTop) {
|
|
|
|
y = m_currentScreenGeometry.y();
|
|
|
|
} else if (alignment & Qt::AlignBottom) {
|
|
|
|
y = m_currentScreenGeometry.bottom() - height;
|
|
|
|
//Center
|
|
|
|
} else {
|
|
|
|
y = m_currentScreenGeometry.y() + static_cast<qreal>(m_currentScreenGeometry.height()) * 0.5 - static_cast<qreal>(height) * 0.5;
|
|
|
|
}
|
|
|
|
|
|
|
|
setGeometry(x, y, width, height);
|
2013-08-08 11:09:11 +00:00
|
|
|
m_relativePos = position();
|
2011-12-01 07:48:18 +00:00
|
|
|
}
|
2011-10-30 15:07:14 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 22:58:04 +00:00
|
|
|
void DeclarativeView::setCurrentIndex(const QModelIndex &index, bool disableAnimation)
|
2011-10-30 15:07:14 +00:00
|
|
|
{
|
2012-01-14 10:24:42 +00:00
|
|
|
if (tabBox->config().tabBoxMode() != m_mode) {
|
|
|
|
return;
|
|
|
|
}
|
2013-07-23 05:02:52 +00:00
|
|
|
if (QObject *item = rootObject()->findChild<QObject*>(QStringLiteral("listView"))) {
|
2012-03-20 22:58:04 +00:00
|
|
|
QVariant durationRestore;
|
|
|
|
if (disableAnimation) {
|
|
|
|
durationRestore = item->property("highlightMoveDuration");
|
|
|
|
item->setProperty("highlightMoveDuration", QVariant(1));
|
|
|
|
}
|
2011-10-30 15:07:14 +00:00
|
|
|
item->setProperty("currentIndex", index.row());
|
2012-03-20 22:58:04 +00:00
|
|
|
if (disableAnimation) {
|
|
|
|
item->setProperty("highlightMoveDuration", durationRestore);
|
|
|
|
}
|
2011-10-30 15:07:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-31 13:34:37 +00:00
|
|
|
void DeclarativeView::currentIndexChanged(int row)
|
|
|
|
{
|
|
|
|
tabBox->setCurrentIndex(m_model->index(row, 0));
|
2012-02-29 15:42:22 +00:00
|
|
|
KWindowSystem::forceActiveWindow(m_model->data(m_model->index(row, 0), ClientModel::WIdRole).toLongLong());
|
2011-10-31 13:34:37 +00:00
|
|
|
}
|
|
|
|
|
2011-12-01 07:48:18 +00:00
|
|
|
void DeclarativeView::updateQmlSource(bool force)
|
2011-10-30 15:07:14 +00:00
|
|
|
{
|
2013-07-26 17:58:42 +00:00
|
|
|
if (status() != Ready)
|
|
|
|
return;
|
2012-01-14 10:24:42 +00:00
|
|
|
if (tabBox->config().tabBoxMode() != m_mode) {
|
|
|
|
return;
|
|
|
|
}
|
2011-12-01 07:48:18 +00:00
|
|
|
if (!force && tabBox->config().layoutName() == m_currentLayout) {
|
2011-10-30 15:07:14 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-04-15 11:03:13 +00:00
|
|
|
const bool desktopMode = (m_mode == TabBoxConfig::DesktopTabBox);
|
|
|
|
m_currentLayout = tabBox->config().layoutName();
|
|
|
|
KService::Ptr service = desktopMode ? findDesktopSwitcher() : findWindowSwitcher();
|
2013-09-01 23:28:14 +00:00
|
|
|
if (!service) {
|
2013-04-15 11:03:13 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-07-23 05:02:52 +00:00
|
|
|
if (service->property(QStringLiteral("X-Plasma-API")).toString() != QStringLiteral("declarativeappletscript")) {
|
2013-09-02 11:14:39 +00:00
|
|
|
qDebug() << "Window Switcher Layout is no declarativeappletscript";
|
2012-02-12 14:15:54 +00:00
|
|
|
return;
|
2012-01-14 10:24:42 +00:00
|
|
|
}
|
2013-04-15 11:03:13 +00:00
|
|
|
const QString file = desktopMode ? findDesktopSwitcherScriptFile(service) : findWindowSwitcherScriptFile(service);
|
|
|
|
if (file.isNull()) {
|
2013-09-02 11:14:39 +00:00
|
|
|
qDebug() << "Could not find QML file for window switcher";
|
2013-04-15 11:03:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
rootObject()->setProperty("source", QUrl(file));
|
|
|
|
}
|
|
|
|
|
|
|
|
KService::Ptr DeclarativeView::findWindowSwitcher()
|
|
|
|
{
|
2013-07-23 05:02:52 +00:00
|
|
|
QString constraint = QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(tabBox->config().layoutName());
|
|
|
|
KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("KWin/WindowSwitcher"), constraint);
|
2012-02-12 14:15:54 +00:00
|
|
|
if (offers.isEmpty()) {
|
|
|
|
// load default
|
2013-07-23 05:02:52 +00:00
|
|
|
constraint = QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(QStringLiteral("informative"));
|
|
|
|
offers = KServiceTypeTrader::self()->query(QStringLiteral("KWin/WindowSwitcher"), constraint);
|
2012-02-12 14:15:54 +00:00
|
|
|
if (offers.isEmpty()) {
|
2013-09-02 11:14:39 +00:00
|
|
|
qDebug() << "could not find default window switcher layout";
|
2013-04-15 11:03:13 +00:00
|
|
|
return KService::Ptr();
|
2012-01-14 10:24:42 +00:00
|
|
|
}
|
2011-10-30 15:07:14 +00:00
|
|
|
}
|
2013-04-15 11:03:13 +00:00
|
|
|
return offers.first();
|
|
|
|
}
|
|
|
|
|
|
|
|
KService::Ptr DeclarativeView::findDesktopSwitcher()
|
|
|
|
{
|
2013-07-23 05:02:52 +00:00
|
|
|
QString constraint = QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(tabBox->config().layoutName());
|
|
|
|
KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("KWin/DesktopSwitcher"), constraint);
|
2013-04-15 11:03:13 +00:00
|
|
|
if (offers.isEmpty()) {
|
|
|
|
// load default
|
2013-07-23 05:02:52 +00:00
|
|
|
constraint = QStringLiteral("[X-KDE-PluginInfo-Name] == '%1'").arg(QStringLiteral("informative"));
|
|
|
|
offers = KServiceTypeTrader::self()->query(QStringLiteral("KWin/DesktopSwitcher"), constraint);
|
2013-04-15 11:03:13 +00:00
|
|
|
if (offers.isEmpty()) {
|
2013-09-02 11:14:39 +00:00
|
|
|
qDebug() << "could not find default desktop switcher layout";
|
2013-04-15 11:03:13 +00:00
|
|
|
return KService::Ptr();
|
|
|
|
}
|
2012-02-12 14:15:54 +00:00
|
|
|
}
|
2013-04-15 11:03:13 +00:00
|
|
|
return offers.first();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString DeclarativeView::findWindowSwitcherScriptFile(KService::Ptr service)
|
|
|
|
{
|
2013-07-23 05:02:52 +00:00
|
|
|
const QString pluginName = service->property(QStringLiteral("X-KDE-PluginInfo-Name")).toString();
|
|
|
|
const QString scriptName = service->property(QStringLiteral("X-Plasma-MainScript")).toString();
|
2013-08-03 20:33:50 +00:00
|
|
|
return QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(KWIN_NAME) + QStringLiteral("/tabbox/") + pluginName + QStringLiteral("/contents/") + scriptName);
|
2013-04-15 11:03:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString DeclarativeView::findDesktopSwitcherScriptFile(KService::Ptr service)
|
|
|
|
{
|
2013-07-23 05:02:52 +00:00
|
|
|
const QString pluginName = service->property(QStringLiteral("X-KDE-PluginInfo-Name")).toString();
|
|
|
|
const QString scriptName = service->property(QStringLiteral("X-Plasma-MainScript")).toString();
|
2013-08-03 20:33:50 +00:00
|
|
|
return QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral(KWIN_NAME) + QStringLiteral("/desktoptabbox/") + pluginName + QStringLiteral("/contents/") + scriptName);
|
2011-10-30 15:07:14 +00:00
|
|
|
}
|
|
|
|
|
2011-12-01 07:48:18 +00:00
|
|
|
void DeclarativeView::slotEmbeddedChanged(bool enabled)
|
|
|
|
{
|
|
|
|
if (enabled) {
|
|
|
|
// cache the width
|
2013-08-08 11:09:11 +00:00
|
|
|
setResizeMode(QQuickView::SizeRootObjectToView);
|
2011-12-01 07:48:18 +00:00
|
|
|
m_cachedWidth = rootObject()->property("width").toInt();
|
|
|
|
m_cachedHeight = rootObject()->property("height").toInt();
|
|
|
|
} else {
|
2013-08-08 11:09:11 +00:00
|
|
|
setResizeMode(QQuickView::SizeViewToRootObject);
|
2011-12-01 07:48:18 +00:00
|
|
|
if (m_cachedWidth != 0 && m_cachedHeight != 0) {
|
|
|
|
rootObject()->setProperty("width", m_cachedWidth);
|
|
|
|
rootObject()->setProperty("height", m_cachedHeight);
|
|
|
|
}
|
|
|
|
updateQmlSource(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DeclarativeView::slotWindowChanged(WId wId, unsigned int properties)
|
|
|
|
{
|
|
|
|
if (wId != tabBox->embedded()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (properties & NET::WMGeometry) {
|
|
|
|
slotUpdateGeometry();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-20 19:01:46 +00:00
|
|
|
bool DeclarativeView::sendKeyEvent(QKeyEvent *e)
|
|
|
|
{
|
2013-10-25 13:04:22 +00:00
|
|
|
if (QQuickItem *item = rootObject()->findChild<QQuickItem*>(QStringLiteral("listView"))) {
|
|
|
|
return sendEvent(item, e);
|
|
|
|
}
|
|
|
|
return false;
|
2012-03-20 19:01:46 +00:00
|
|
|
}
|
|
|
|
|
2011-10-30 15:07:14 +00:00
|
|
|
} // namespace TabBox
|
|
|
|
} // namespace KWin
|