[kcmtabbox] Preview goes QtQuick
QQuickView instead of a QDeclarativeView. As background a white element is used.
This commit is contained in:
parent
06033f1263
commit
db89652175
4 changed files with 19 additions and 33 deletions
|
@ -20,18 +20,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
// own
|
||||
#include "layoutpreview.h"
|
||||
#include "thumbnailitem.h"
|
||||
#include <QtDeclarative/qdeclarative.h>
|
||||
#include <QtDeclarative/QDeclarativeContext>
|
||||
#include <QtDeclarative/QDeclarativeEngine>
|
||||
#include <QGraphicsObject>
|
||||
#include <QQmlContext>
|
||||
#include <QtCore/QStandardPaths>
|
||||
#include <kdeclarative.h>
|
||||
#include <KDE/KConfigGroup>
|
||||
#include <KDE/KDesktopFile>
|
||||
#include <KDE/KGlobal>
|
||||
#include <KDE/KIcon>
|
||||
#include <KDE/KIconEffect>
|
||||
#include <KDE/KIconLoader>
|
||||
#include <KDE/KLocalizedString>
|
||||
#include <KDE/KService>
|
||||
|
||||
namespace KWin
|
||||
|
@ -39,32 +35,22 @@ namespace KWin
|
|||
namespace TabBox
|
||||
{
|
||||
|
||||
LayoutPreview::LayoutPreview(QWidget* parent)
|
||||
: QDeclarativeView(parent)
|
||||
LayoutPreview::LayoutPreview(QWindow *parent)
|
||||
: QQuickView(parent)
|
||||
{
|
||||
setAutoFillBackground(false);
|
||||
QPalette pal = palette();
|
||||
pal.setColor(backgroundRole(), Qt::transparent);
|
||||
setPalette(pal);
|
||||
setColor(Qt::white);
|
||||
setMinimumSize(QSize(480, 300));
|
||||
setResizeMode(QDeclarativeView::SizeRootObjectToView);
|
||||
foreach (const QString &importPath, KGlobal::dirs()->findDirs("module", "imports")) {
|
||||
engine()->addImportPath(importPath);
|
||||
}
|
||||
foreach (const QString &importPath, QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "kwin/tabbox", QStandardPaths::LocateDirectoty)) {
|
||||
setResizeMode(QQuickView::SizeRootObjectToView);
|
||||
foreach (const QString &importPath, QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "kwin/tabbox", QStandardPaths::LocateDirectory)) {
|
||||
engine()->addImportPath(importPath);
|
||||
}
|
||||
ExampleClientModel *model = new ExampleClientModel(this);
|
||||
engine()->addImageProvider(QLatin1String("client"), new TabBoxImageProvider(model));
|
||||
KDeclarative kdeclarative;
|
||||
kdeclarative.setDeclarativeEngine(engine());
|
||||
kdeclarative.initialize();
|
||||
kdeclarative.setupBindings();
|
||||
qmlRegisterType<WindowThumbnailItem>("org.kde.kwin", 0, 1, "ThumbnailItem");
|
||||
rootContext()->setContextProperty("clientModel", model);
|
||||
rootContext()->setContextProperty("sourcePath", QString());
|
||||
rootContext()->setContextProperty("name", QString());
|
||||
setSource(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kwin/kcm_kwintabbox/main.qml"));
|
||||
setSource(QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kwin/kcm_kwintabbox/main.qml")));
|
||||
}
|
||||
|
||||
LayoutPreview::~LayoutPreview()
|
||||
|
@ -78,7 +64,7 @@ void LayoutPreview::setLayout(const QString &path, const QString &name)
|
|||
}
|
||||
|
||||
TabBoxImageProvider::TabBoxImageProvider(QAbstractListModel* model)
|
||||
: QDeclarativeImageProvider(QDeclarativeImageProvider::Pixmap)
|
||||
: QQuickImageProvider(QQuickImageProvider::Pixmap)
|
||||
, m_model(model)
|
||||
{
|
||||
}
|
||||
|
@ -89,7 +75,7 @@ QPixmap TabBoxImageProvider::requestPixmap(const QString &id, QSize *size, const
|
|||
QStringList parts = id.split('/');
|
||||
const int index = parts.first().toInt(&ok);
|
||||
if (!ok) {
|
||||
return QDeclarativeImageProvider::requestPixmap(id, size, requestedSize);
|
||||
return QQuickImageProvider::requestPixmap(id, size, requestedSize);
|
||||
}
|
||||
QSize s(32, 32);
|
||||
if (requestedSize.isValid()) {
|
||||
|
|
|
@ -21,8 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define KWIN_TABBOX_LAYOUTPREVIEW_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QtDeclarative/QDeclarativeView>
|
||||
#include <QtDeclarative/QDeclarativeImageProvider>
|
||||
#include <QQuickView>
|
||||
#include <QQuickImageProvider>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -30,17 +30,17 @@ namespace KWin
|
|||
namespace TabBox
|
||||
{
|
||||
|
||||
class LayoutPreview : public QDeclarativeView
|
||||
class LayoutPreview : public QQuickView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LayoutPreview(QWidget *parent = NULL);
|
||||
explicit LayoutPreview(QWindow *parent = nullptr);
|
||||
virtual ~LayoutPreview();
|
||||
|
||||
void setLayout(const QString &path, const QString &name);
|
||||
};
|
||||
|
||||
class TabBoxImageProvider : public QDeclarativeImageProvider
|
||||
class TabBoxImageProvider : public QQuickImageProvider
|
||||
{
|
||||
public:
|
||||
explicit TabBoxImageProvider(QAbstractListModel *model);
|
||||
|
|
|
@ -497,9 +497,9 @@ void KWinTabBoxConfig::configureEffectClicked()
|
|||
const int effect = ui->effectCombo->currentIndex();
|
||||
if (effect >= Layout) {
|
||||
if (!m_layoutPreview) {
|
||||
m_layoutPreview = new LayoutPreview(this);
|
||||
m_layoutPreview->setWindowTitle(i18n("Tabbox layout preview"));
|
||||
m_layoutPreview->setWindowFlags(Qt::Dialog);
|
||||
m_layoutPreview = new LayoutPreview();
|
||||
m_layoutPreview->setTitle(i18n("Tabbox layout preview"));
|
||||
m_layoutPreview->setFlags(Qt::Dialog);
|
||||
}
|
||||
m_layoutPreview->setLayout(ui->effectCombo->itemData(effect, Qt::UserRole+1).toString(), ui->effectCombo->itemText(effect));
|
||||
m_layoutPreview->show();
|
||||
|
|
|
@ -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
|
||||
|
||||
Item {
|
||||
id : preview
|
||||
|
|
Loading…
Reference in a new issue