Port tabbox to QtQuick 2
Straight forward port. Note: this is currently crashing deep down in QtQuick. To circumvent the crashes it helps to disable the property highlightFollowsCurrentItem in the listviews. This solves the problem that QtQuick crashes on first loading. Unfortunately it still crashes if one tries to invoke TabBox for the second time.
This commit is contained in:
parent
69b109b5b9
commit
8cf8f57966
17 changed files with 71 additions and 76 deletions
|
@ -23,12 +23,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "clientmodel.h"
|
||||
// Qt
|
||||
#include <QApplication>
|
||||
#include <QtDeclarative/qdeclarative.h>
|
||||
#include <QtDeclarative/QDeclarativeContext>
|
||||
#include <QtDeclarative/QDeclarativeEngine>
|
||||
#include <QtQml/QQmlContext>
|
||||
#include <QtQml/QQmlEngine>
|
||||
#include <QDesktopWidget>
|
||||
#include <QGraphicsObject>
|
||||
#include <QPainter>
|
||||
#include <QtGui/QResizeEvent>
|
||||
#include <QQuickItem>
|
||||
#include <QX11Info>
|
||||
|
||||
// include KDE
|
||||
|
@ -55,7 +55,7 @@ namespace TabBox
|
|||
{
|
||||
|
||||
ImageProvider::ImageProvider(QAbstractItemModel *model)
|
||||
: QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap)
|
||||
: QQuickImageProvider(QQuickImageProvider::Pixmap)
|
||||
, m_model(model)
|
||||
{
|
||||
}
|
||||
|
@ -114,8 +114,8 @@ QPixmap ImageProvider::requestPixmap(const QString &id, QSize *size, const QSize
|
|||
}
|
||||
|
||||
|
||||
DeclarativeView::DeclarativeView(QAbstractItemModel *model, TabBoxConfig::TabBoxMode mode, QWidget *parent)
|
||||
: QDeclarativeView(parent)
|
||||
DeclarativeView::DeclarativeView(QAbstractItemModel *model, TabBoxConfig::TabBoxMode mode, QQuickWindow *parent)
|
||||
: QQuickView(parent)
|
||||
, m_model(model)
|
||||
, m_mode(mode)
|
||||
, m_currentScreenGeometry()
|
||||
|
@ -124,16 +124,13 @@ DeclarativeView::DeclarativeView(QAbstractItemModel *model, TabBoxConfig::TabBox
|
|||
, m_cachedWidth(0)
|
||||
, m_cachedHeight(0)
|
||||
{
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setWindowFlags(Qt::X11BypassWindowManagerHint);
|
||||
setColor(Qt::transparent);
|
||||
setFlags(Qt::X11BypassWindowManagerHint);
|
||||
if (tabBox->embedded()) {
|
||||
setResizeMode(QDeclarativeView::SizeRootObjectToView);
|
||||
setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
} else {
|
||||
setResizeMode(QDeclarativeView::SizeViewToRootObject);
|
||||
setResizeMode(QQuickView::SizeViewToRootObject);
|
||||
}
|
||||
QPalette pal = palette();
|
||||
pal.setColor(backgroundRole(), Qt::transparent);
|
||||
setPalette(pal);
|
||||
engine()->addImageProvider(QLatin1String("client"), new ImageProvider(model));
|
||||
#warning TabBox needs porting of KDeclarative
|
||||
#if KWIN_QT5_PORTING
|
||||
|
@ -192,7 +189,7 @@ void DeclarativeView::showEvent(QShowEvent *event)
|
|||
slotUpdateGeometry();
|
||||
QResizeEvent re(size(), size()); // to set mask and blurring.
|
||||
resizeEvent(&re);
|
||||
QGraphicsView::showEvent(event);
|
||||
QQuickView::showEvent(event);
|
||||
}
|
||||
|
||||
void DeclarativeView::resizeEvent(QResizeEvent *event)
|
||||
|
@ -202,7 +199,6 @@ void DeclarativeView::resizeEvent(QResizeEvent *event)
|
|||
} else {
|
||||
const QString maskImagePath = rootObject()->property("maskImagePath").toString();
|
||||
if (maskImagePath.isEmpty()) {
|
||||
clearMask();
|
||||
KWindowEffects::enableBlurBehind(winId(), false);
|
||||
} else {
|
||||
const double maskWidth = rootObject()->property("maskWidth").toDouble();
|
||||
|
@ -217,7 +213,6 @@ void DeclarativeView::resizeEvent(QResizeEvent *event)
|
|||
if (Workspace::self()->compositing() && effects) {
|
||||
// blur background?!
|
||||
KWindowEffects::enableBlurBehind(winId(), static_cast<EffectsHandlerImpl*>(effects)->provides(Effect::Blur), mask);
|
||||
clearMask();
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
|
@ -226,12 +221,12 @@ void DeclarativeView::resizeEvent(QResizeEvent *event)
|
|||
}
|
||||
}
|
||||
}
|
||||
QDeclarativeView::resizeEvent(event);
|
||||
QQuickView::resizeEvent(event);
|
||||
}
|
||||
|
||||
void DeclarativeView::hideEvent(QHideEvent *event)
|
||||
{
|
||||
QWidget::hideEvent(event);
|
||||
QQuickView::hideEvent(event);
|
||||
#ifndef TABBOX_KCM
|
||||
if (tabBox->embedded()) {
|
||||
Client *c = Workspace::self()->findClient(WindowMatchPredicate(tabBox->embedded()));
|
||||
|
@ -304,7 +299,7 @@ void DeclarativeView::slotUpdateGeometry()
|
|||
setGeometry(m_currentScreenGeometry.x() + static_cast<qreal>(m_currentScreenGeometry.width()) * 0.5 - static_cast<qreal>(width) * 0.5,
|
||||
m_currentScreenGeometry.y() + static_cast<qreal>(m_currentScreenGeometry.height()) * 0.5 - static_cast<qreal>(height) * 0.5,
|
||||
width, height);
|
||||
m_relativePos = pos();
|
||||
m_relativePos = position();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,11 +405,11 @@ void DeclarativeView::slotEmbeddedChanged(bool enabled)
|
|||
{
|
||||
if (enabled) {
|
||||
// cache the width
|
||||
setResizeMode(QDeclarativeView::SizeRootObjectToView);
|
||||
setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
m_cachedWidth = rootObject()->property("width").toInt();
|
||||
m_cachedHeight = rootObject()->property("height").toInt();
|
||||
} else {
|
||||
setResizeMode(QDeclarativeView::SizeViewToRootObject);
|
||||
setResizeMode(QQuickView::SizeViewToRootObject);
|
||||
if (m_cachedWidth != 0 && m_cachedHeight != 0) {
|
||||
rootObject()->setProperty("width", m_cachedWidth);
|
||||
rootObject()->setProperty("height", m_cachedHeight);
|
||||
|
|
|
@ -20,8 +20,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#ifndef KWIN_TABBOX_DECLARATIVE_H
|
||||
#define KWIN_TABBOX_DECLARATIVE_H
|
||||
// includes
|
||||
#include <QtDeclarative/QDeclarativeImageProvider>
|
||||
#include <QtDeclarative/QDeclarativeView>
|
||||
#include <QQuickImageProvider>
|
||||
#include <QQuickView>
|
||||
#include <KDE/KService>
|
||||
#include "tabboxconfig.h"
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace KWin
|
|||
namespace TabBox
|
||||
{
|
||||
|
||||
class ImageProvider : public QDeclarativeImageProvider
|
||||
class ImageProvider : public QQuickImageProvider
|
||||
{
|
||||
public:
|
||||
explicit ImageProvider(QAbstractItemModel *model);
|
||||
|
@ -50,11 +50,11 @@ private:
|
|||
QAbstractItemModel *m_model;
|
||||
};
|
||||
|
||||
class DeclarativeView : public QDeclarativeView
|
||||
class DeclarativeView : public QQuickView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
DeclarativeView(QAbstractItemModel *model, TabBoxConfig::TabBoxMode mode, QWidget *parent = NULL);
|
||||
DeclarativeView(QAbstractItemModel *model, TabBoxConfig::TabBoxMode mode, QQuickWindow *parent = NULL);
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
virtual void resizeEvent(QResizeEvent *event);
|
||||
void setCurrentIndex(const QModelIndex &index, bool disableAnimation = false);
|
||||
|
|
|
@ -17,9 +17,9 @@ 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.0
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.qtextracomponents 0.1
|
||||
import QtQuick 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.qtextracomponents 2.0
|
||||
|
||||
Item {
|
||||
id: iconsTabBox
|
||||
|
|
|
@ -18,8 +18,8 @@ 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.0
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import QtQuick 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
|
||||
Item {
|
||||
property double leftMargin: shadow.margins.left + background.margins.left
|
||||
|
|
|
@ -17,9 +17,9 @@ 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.0
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.qtextracomponents 0.1
|
||||
import QtQuick 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.qtextracomponents 2.0
|
||||
|
||||
Item {
|
||||
id: bigIconsTabBox
|
||||
|
|
|
@ -17,9 +17,9 @@ 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.0
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.qtextracomponents 0.1
|
||||
import QtQuick 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.qtextracomponents 2.0
|
||||
|
||||
Item {
|
||||
id: compactTabBox
|
||||
|
@ -142,7 +142,7 @@ Item {
|
|||
function calculateMaxRowWidth() {
|
||||
var width = 0;
|
||||
var textElement = Qt.createQmlObject(
|
||||
'import QtQuick 1.0;'
|
||||
'import QtQuick 2.0;'
|
||||
+ 'Text {\n'
|
||||
+ ' text: "' + itemCaption(compactTabBox.longestCaption, true) + '"\n'
|
||||
+ ' font.bold: true\n'
|
||||
|
@ -159,7 +159,7 @@ Item {
|
|||
**/
|
||||
function calcRowHeight() {
|
||||
var textElement = Qt.createQmlObject(
|
||||
'import QtQuick 1.0;'
|
||||
'import QtQuick 2.0;'
|
||||
+ 'Text {\n'
|
||||
+ ' text: "Some Text"\n'
|
||||
+ ' font.bold: true\n'
|
||||
|
|
|
@ -17,9 +17,9 @@ 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.0
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.qtextracomponents 0.1
|
||||
import QtQuick 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.qtextracomponents 2.0
|
||||
|
||||
Item {
|
||||
id: informativeTabBox
|
||||
|
@ -158,7 +158,7 @@ Item {
|
|||
function calculateMaxRowWidth() {
|
||||
var width = 0;
|
||||
var textElement = Qt.createQmlObject(
|
||||
'import QtQuick 1.0;'
|
||||
'import QtQuick 2.0;'
|
||||
+ 'Text {\n'
|
||||
+ ' text: "' + itemCaption(informativeTabBox.longestCaption, true) + '"\n'
|
||||
+ ' font.bold: true\n'
|
||||
|
@ -175,7 +175,7 @@ Item {
|
|||
**/
|
||||
function calcRowHeight() {
|
||||
var textElement = Qt.createQmlObject(
|
||||
'import QtQuick 1.0;'
|
||||
'import QtQuick 2.0;'
|
||||
+ 'Text {\n'
|
||||
+ ' text: "Some Text"\n'
|
||||
+ ' font.bold: true\n'
|
||||
|
|
|
@ -17,9 +17,9 @@ 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.core 0.1 as PlasmaCore
|
||||
import org.kde.qtextracomponents 0.1
|
||||
import QtQuick 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.qtextracomponents 2.0
|
||||
import org.kde.kwin 0.1 as KWin
|
||||
|
||||
Item {
|
||||
|
|
|
@ -17,9 +17,9 @@ 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.0
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.qtextracomponents 0.1
|
||||
import QtQuick 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.qtextracomponents 2.0
|
||||
|
||||
Item {
|
||||
id: smallIconsTabBox
|
||||
|
|
|
@ -17,9 +17,9 @@ 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.0
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.qtextracomponents 0.1
|
||||
import QtQuick 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.qtextracomponents 2.0
|
||||
|
||||
Item {
|
||||
id: textTabBox
|
||||
|
@ -109,7 +109,7 @@ Item {
|
|||
function calculateMaxRowWidth() {
|
||||
var width = 0;
|
||||
var textElement = Qt.createQmlObject(
|
||||
'import QtQuick 1.0;'
|
||||
'import QtQuick 2.0;'
|
||||
+ 'Text {\n'
|
||||
+ ' text: "' + textTabBox.longestCaption + '"\n'
|
||||
+ ' visible: false\n'
|
||||
|
@ -125,7 +125,7 @@ Item {
|
|||
**/
|
||||
function calcRowHeight() {
|
||||
var textElement = Qt.createQmlObject(
|
||||
'import QtQuick 1.0;'
|
||||
'import QtQuick 2.0;'
|
||||
+ 'Text {\n'
|
||||
+ ' text: "Some Text"\n'
|
||||
+ ' visible: false\n'
|
||||
|
|
|
@ -17,9 +17,9 @@ 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.0
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.qtextracomponents 0.1
|
||||
import QtQuick 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.qtextracomponents 2.0
|
||||
import org.kde.kwin 0.1 as KWin
|
||||
|
||||
Item {
|
||||
|
|
|
@ -18,11 +18,11 @@ 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.0
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.plasma.components 0.1 as PlasmaComponents
|
||||
import QtQuick 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.plasma.components 2.0 as PlasmaComponents
|
||||
import org.kde.plasma.mobilecomponents 0.1 as MobileComponents
|
||||
import org.kde.qtextracomponents 0.1
|
||||
import org.kde.qtextracomponents 2.0
|
||||
import org.kde.kwin 0.1 as KWin
|
||||
|
||||
Item {
|
||||
|
|
|
@ -17,9 +17,9 @@ 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.0
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.qtextracomponents 0.1
|
||||
import QtQuick 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.qtextracomponents 2.0
|
||||
|
||||
Item {
|
||||
id: desktopTabBox
|
||||
|
@ -122,7 +122,7 @@ Item {
|
|||
function calculateMaxRowWidth() {
|
||||
var width = 0;
|
||||
var textElement = Qt.createQmlObject(
|
||||
'import QtQuick 1.0;'
|
||||
'import QtQuick 2.0;'
|
||||
+ 'Text {\n'
|
||||
+ ' text: "' + desktopTabBox.longestCaption + '"\n'
|
||||
+ ' font.bold: true\n'
|
||||
|
@ -139,7 +139,7 @@ Item {
|
|||
**/
|
||||
function calcRowHeight() {
|
||||
var textElement = Qt.createQmlObject(
|
||||
'import QtQuick 1.0;'
|
||||
'import QtQuick 2.0;'
|
||||
+ 'Text {\n'
|
||||
+ ' text: "Some Text"\n'
|
||||
+ ' font.bold: true\n'
|
||||
|
|
|
@ -17,9 +17,9 @@ 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.0
|
||||
import org.kde.plasma.core 0.1 as PlasmaCore
|
||||
import org.kde.qtextracomponents 0.1
|
||||
import QtQuick 2.0
|
||||
import org.kde.plasma.core 2.0 as PlasmaCore
|
||||
import org.kde.qtextracomponents 2.0
|
||||
import org.kde.kwin 0.1 as KWin
|
||||
|
||||
Item {
|
||||
|
|
|
@ -17,7 +17,7 @@ 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.0
|
||||
import QtQuick 2.0
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
|
|
|
@ -118,7 +118,7 @@ void TabBoxHandlerPrivate::updateHighlightWindows()
|
|||
|
||||
Display *dpy = QX11Info::display();
|
||||
TabBoxClient *currentClient = q->client(index);
|
||||
QWidget *w = NULL;
|
||||
QWindow *w = NULL;
|
||||
if (m_declarativeView && m_declarativeView->isVisible()) {
|
||||
w = m_declarativeView;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ void TabBoxHandler::show()
|
|||
}
|
||||
dv = d->m_declarativeDesktopView;
|
||||
}
|
||||
if (dv->status() == QDeclarativeView::Ready && dv->rootObject()) {
|
||||
if (dv->status() == QQuickView::Ready && dv->rootObject()) {
|
||||
dv->show();
|
||||
dv->setCurrentIndex(d->index, d->config.tabBoxMode() == TabBoxConfig::ClientTabBox);
|
||||
} else {
|
||||
|
@ -386,7 +386,7 @@ void TabBoxHandler::grabbedKeyEvent(QKeyEvent* event) const
|
|||
|
||||
bool TabBoxHandler::containsPos(const QPoint& pos) const
|
||||
{
|
||||
QWidget *w = NULL;
|
||||
QWindow *w = NULL;
|
||||
if (d->m_declarativeView && d->m_declarativeView->isVisible()) {
|
||||
w = d->m_declarativeView;
|
||||
} else if (d->m_declarativeDesktopView && d->m_declarativeDesktopView->isVisible()) {
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace KWin
|
|||
namespace TabBox
|
||||
{
|
||||
DeclarativeView::DeclarativeView(QAbstractItemModel *model, TabBoxConfig::TabBoxMode mode, QWidget *parent)
|
||||
: QDeclarativeView(parent)
|
||||
: QQuickView(parent)
|
||||
{
|
||||
Q_UNUSED(model)
|
||||
Q_UNUSED(mode)
|
||||
|
|
Loading…
Reference in a new issue