1,276 changes: 1,276 additions & 0 deletions src/columnview.cpp

Large diffs are not rendered by default.

408 changes: 408 additions & 0 deletions src/columnview.h

Large diffs are not rendered by default.

89 changes: 89 additions & 0 deletions src/columnview_p.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
/*
* Copyright 2019 Marco Martin <mart@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* 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.
*
* 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 Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

#pragma once

#include "columnview.h"

#include <QQuickItem>
#include <QPointer>

class QPropertyAnimation;
class QQmlComponent;

class QmlComponentsPool: public QObject {
Q_OBJECT

public:
QmlComponentsPool(QObject *parent = nullptr);
~QmlComponentsPool();

void initialize(QQmlEngine *engine);

QQmlComponent *m_separatorComponent = nullptr;
QObject *m_units = nullptr;

Q_SIGNALS:
void gridUnitChanged();
void longDurationChanged();

private:
QObject *m_instance = nullptr;
};

class ContentItem : public QQuickItem {
Q_OBJECT

public:
ContentItem(ColumnView *parent = nullptr);
~ContentItem();

void layoutItems();
qreal childWidth(QQuickItem *child);
void updateVisibleItems();
void forgetItem(QQuickItem *item);
QQuickItem *ensureSeparator(QQuickItem *item);

void setBoundedX(qreal x);
void animateX(qreal x);
void snapToItem();

protected:
void itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) override;
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;

private Q_SLOTS:
void syncItemsOrder();
void updateRepeaterModel();

private:
ColumnView *m_view;
QPropertyAnimation *m_slideAnim;
QList<QQuickItem *> m_items;
QList<QObject *> m_visibleItems;
QPointer<QQuickItem> m_viewAnchorItem;
QHash<QQuickItem *, QQuickItem *> m_separators;
QHash<QObject *, QObject*> m_models;

qreal m_columnWidth = 0;
ColumnView::ColumnResizeMode m_columnResizeMode = ColumnView::FixedColumns;
bool m_shouldAnimate = false;
friend class ColumnView;
};

16 changes: 4 additions & 12 deletions src/controls/Page.qml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import QtQuick 2.5
import QtQuick.Layouts 1.2
import org.kde.kirigami 2.4 as Kirigami
import org.kde.kirigami 2.7 as Kirigami
import "private"
import QtQuick.Templates 2.0 as T2

Expand Down Expand Up @@ -318,8 +318,8 @@ T2.Page {
globalToolBar.stack = null;
globalToolBar.row = null;

if (root.parent.hasOwnProperty("__pageRow")) {
globalToolBar.row = root.parent.__pageRow;
if (root.Kirigami.ColumnView.view) {
globalToolBar.row = root.Kirigami.ColumnView.view.__pageRow;
}
if (root.T2.StackView.view) {
globalToolBar.stack = root.T2.StackView.view;
Expand Down Expand Up @@ -365,17 +365,9 @@ T2.Page {
//TODO: find container reliably, remove assumption
{"pageRow": Qt.binding(function() {return row}),
"page": root,
"current": Qt.binding(function() {return stack || !root.parent ? true : row.currentIndex === root.parent.level})});
"current": Qt.binding(function() {return stack || row.currentIndex === root.Kirigami.ColumnView.level})});
}
}

Separator {
z: 999
anchors.verticalCenter: globalToolBar.verticalCenter
height: globalToolBar.height * 0.6
visible: !root.T2.StackView.view && globalToolBar.row && root.parent && globalToolBar.row.contentItem.contentX < root.parent.x - globalToolBar.row.globalToolBar.leftReservedSpace
Kirigami.Theme.textColor: globalToolBar.item ? globalToolBar.item.Kirigami.Theme.textColor : undefined
}
},

//bottom action buttons
Expand Down
596 changes: 176 additions & 420 deletions src/controls/PageRow.qml

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/controls/private/ActionButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import QtQuick 2.1
import QtQuick.Layouts 1.2
import QtQuick.Controls 2.0 as Controls
import QtGraphicalEffects 1.0
import org.kde.kirigami 2.4
import org.kde.kirigami 2.7

import "../templates/private"

Expand Down Expand Up @@ -128,10 +128,10 @@ Item {

onPressed: {
//search if we have a page to set to current
if (root.hasApplicationWindow && applicationWindow().pageStack.currentIndex !== undefined && root.page.parent.level !== undefined) {
if (root.hasApplicationWindow && applicationWindow().pageStack.currentIndex !== undefined && root.page.ColumnView.level !== undefined) {
//search the button parent's parent, that is the page parent
//this will make the context drawer open for the proper page
applicationWindow().pageStack.currentIndex = root.page.parent.level;
applicationWindow().pageStack.currentIndex = root.page.ColumnView.level;
}
downTimestamp = (new Date()).getTime();
startX = button.x + button.width/2;
Expand Down Expand Up @@ -402,7 +402,7 @@ Item {
}
visible: root.page.actions && root.page.actions.contextualActions.length > 0 && (applicationWindow === undefined || applicationWindow().wideScreen)
//using internal pagerow api
&& (root.page && root.page.parent ? root.page.parent.level < applicationWindow().pageStack.depth-1 : false)
&& (root.page && root.page.parent ? root.page.ColumnView.level < applicationWindow().pageStack.depth-1 : false)

width: Units.iconSizes.smallMedium + Units.smallSpacing*2
height: width
Expand Down
2 changes: 2 additions & 0 deletions src/kirigamiplugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

#include "kirigamiplugin.h"
#include "columnview.h"
#include "enums.h"
#include "desktopicon.h"
#include "settings.h"
Expand Down Expand Up @@ -178,6 +179,7 @@ void KirigamiPlugin::registerTypes(const char *uri)
qmlRegisterType(componentUrl(QStringLiteral("UrlButton.qml")), uri, 2, 6, "UrlButton");

//2.7
qmlRegisterType<ColumnView>(uri, 2, 7, "ColumnView");
qmlRegisterType(componentUrl(QStringLiteral("ActionTextField.qml")), uri, 2, 7, "ActionTextField");

qmlProtectModule(uri, 2);
Expand Down