Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 5ff2bf3f authored by Marco Martin's avatar Marco Martin

experimenta switch wo 2 columns mode when very large

parent 76ea7842
......@@ -151,6 +151,7 @@ void SidebarMode::initEvent()
d->subCategoryModel = new QStandardItemModel( this );
d->mainWidget = new QWidget();
d->mainWidget->installEventFilter(this);
d->mainLayout = new QHBoxLayout(d->mainWidget);
d->mainLayout->setContentsMargins(0, 0, 0, 0);
d->moduleView = new ModuleView( d->mainWidget );
......@@ -244,6 +245,11 @@ void SidebarMode::setActiveSubCategory(int cat)
emit activeSubCategoryChanged();
}
int SidebarMode::width() const
{
return d->mainWidget->width();
}
void SidebarMode::initWidget()
{
// Create the widgets
......@@ -313,6 +319,8 @@ bool SidebarMode::eventFilter(QObject* watched, QEvent* event)
//TODO: patch Qt
if (watched == d->quickWidget && event->type() == QEvent::Leave) {
QCoreApplication::sendEvent(d->quickWidget->quickWindow(), event);
} else if (watched == d->mainWidget && event->type() == QEvent::Resize) {
emit widthChanged();
}
return BaseMode::eventFilter(watched, event);
}
......
......@@ -36,6 +36,7 @@ class SidebarMode : public BaseMode
Q_PROPERTY(QAbstractItemModel *subCategoryModel READ subCategoryModel CONSTANT)
Q_PROPERTY(int activeCategory READ activeCategory WRITE setActiveCategory NOTIFY activeCategoryChanged)
Q_PROPERTY(int activeSubCategory READ activeSubCategory WRITE setActiveSubCategory NOTIFY activeSubCategoryChanged)
Q_PROPERTY(int width READ width NOTIFY widthChanged)
public:
SidebarMode(QObject * parent, const QVariantList& );
......@@ -55,6 +56,8 @@ public:
int activeSubCategory() const;
void setActiveSubCategory(int cat);
int width() const;
Q_INVOKABLE void triggerGlobalAction(const QString &name);
Q_INVOKABLE void requestToolTip(int index, const QRectF &rect);
Q_INVOKABLE void hideToolTip();
......@@ -71,6 +74,7 @@ private Q_SLOTS:
Q_SIGNALS:
void activeCategoryChanged();
void activeSubCategoryChanged();
void widthChanged();
private:
class Private;
......
......@@ -25,19 +25,29 @@ import org.kde.kirigami 2.1 as Kirigami
Kirigami.ScrollablePage {
id: subCategoryColumn
header: RowLayout {
header: Item {
width: subCategoryColumn.width
height: implicitHeight + Kirigami.Units.smallSpacing*2
QtControls.ToolButton {
iconName: "go-previous"
onClicked: root.pageStack.currentIndex = 0;
}
Kirigami.Label {
Layout.fillWidth: true
text: subCategoryColumn.title
opacity: 0.3
//FIXME: kirigami bug, why?
Component.onCompleted: font.bold = true
height: topLayout.height + Kirigami.Units.smallSpacing*2
RowLayout {
id: topLayout
height: backButton.implicitHeight
anchors {
fill: parent
margins: Kirigami.Units.smallSpacing
}
QtControls.ToolButton {
id: backButton
visible: !applicationWindow().wideScreen
iconName: "go-previous"
onClicked: root.pageStack.currentIndex = 0;
}
Kirigami.Label {
Layout.fillWidth: true
text: subCategoryColumn.title
opacity: 0.3
//FIXME: kirigami bug, why?
Component.onCompleted: font.bold = true
}
}
Kirigami.Separator {
anchors {
......
......@@ -23,9 +23,11 @@ import org.kde.kirigami 2.1 as Kirigami
Kirigami.ApplicationItem {
id: root
implicitWidth: Kirigami.Units.gridUnit * 15
implicitWidth: wideScreen ? Kirigami.Units.gridUnit * 24 : Kirigami.Units.gridUnit * 12
pageStack.initialPage: mainColumn
pageStack.defaultColumnWidth: wideScreen ? root.width / 2 : root.width
wideScreen: pageStack.depth > 1 && systemsettings.width > Kirigami.Units.gridUnit * 70
CategoriesPage {
id: mainColumn
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment