Commit 80f7c061 authored by Marco Martin's avatar Marco Martin
Browse files

make the modules look indented

if a subcategory has a category owner module, make
them look indented to suggest they are logical
children of the category owner module

BUG:433081
BUG:433202
parent 2f0d084e
......@@ -269,14 +269,21 @@ void SettingsBase::initMenuList(MenuItem *parent)
? parent->service()->property(QStringLiteral("X-KDE-System-Settings-Category-Module")).toString()
: QString();
bool isCategoryOwner = false;
if (!parentCategoryKcm.isEmpty() && parentCategoryKcm == entry->library()) {
parent->setItem(KCModuleInfo(entry));
removeList.append(modules.at(i));
} else if (!parent->category().isEmpty() && (category == parent->category() || category2 == parent->category())) {
isCategoryOwner = true;
}
if (!parent->category().isEmpty() && (category == parent->category() || category2 == parent->category())) {
if (!entry->noDisplay()) {
// Add the module info to the menu
MenuItem *infoItem = new MenuItem(false, parent);
infoItem->setService(entry);
infoItem->setCategoryOwner(isCategoryOwner);
if (m_mode == BaseMode::InfoCenter && entry->pluginKeyword() == QStringLiteral("kcm-about-distro")) {
homeModule = infoItem;
} else if (m_mode == BaseMode::SystemSettings && entry->pluginKeyword() == QStringLiteral("kcm_landingpage")) {
......
......@@ -34,7 +34,8 @@ public:
int weight;
KService::Ptr service;
KCModuleInfo item;
bool showDefaultIndicator;
bool showDefaultIndicator = false;
bool isCategoryOwner = false;
};
MenuItem::MenuItem(bool isMenu, MenuItem *itsParent)
......@@ -42,7 +43,6 @@ MenuItem::MenuItem(bool isMenu, MenuItem *itsParent)
{
d->parent = itsParent;
d->menu = isMenu;
d->showDefaultIndicator = false;
if (d->parent) {
d->parent->children().append(this);
......@@ -138,6 +138,16 @@ bool MenuItem::showDefaultIndicator() const
return d->showDefaultIndicator;
}
bool MenuItem::isCategoryOwner() const
{
return d->isCategoryOwner;
}
void MenuItem::setCategoryOwner(bool owner)
{
d->isCategoryOwner = owner;
}
void MenuItem::setItem(const KCModuleInfo &item)
{
// d->name = item.moduleName();
......
......@@ -150,6 +150,12 @@ public:
void updateDefaultIndicator();
/**
* If true this is the main module of this category and should appear in a more prominent way compared to the others
*/
bool isCategoryOwner() const;
void setCategoryOwner(bool owner);
private:
class Private;
Private *const d;
......
......@@ -112,7 +112,12 @@ QVariant MenuModel::data(const QModelIndex &index, int role) const
theData.setValue(mi->keywords().join(QString()));
break;
case MenuModel::UserSortRole:
theData.setValue(QStringLiteral("%1").arg(QString::number(mi->weight()), 5, QLatin1Char('0')));
//Category owners are always before everything else, regardless of weight
if (mi->isCategoryOwner()) {
theData.setValue(QStringLiteral("%1").arg(QString::number(mi->weight()), 5, QLatin1Char('0')));
} else {
theData.setValue(QStringLiteral("1%1").arg(QString::number(mi->weight()), 5, QLatin1Char('0')));
}
break;
case MenuModel::DepthRole: {
MenuItem *candidate = mi;
......@@ -122,6 +127,13 @@ QVariant MenuModel::data(const QModelIndex &index, int role) const
candidate = candidate->parent();
++depth;
}
MenuItem *parent = mi->parent();
// Items that are in a category with an owner are one level deeper,
// except the owner
if (parent && parent->menu() && !parent->item().service()->library().isEmpty() && !mi->isCategoryOwner()) {
++depth;
}
theData.setValue(depth);
break;
}
......
......@@ -85,7 +85,7 @@ QString SubcategoryModel::title() const
return QString();
}
return mi->item().moduleName();
return mi->name();
}
QIcon SubcategoryModel::icon() const
......@@ -432,7 +432,9 @@ void SidebarMode::requestMostUsedToolTip(int index, const QRectF &rect)
void SidebarMode::hideToolTip()
{
d->toolTipManager->hideToolTip();
if (d->toolTipManager) {
d->toolTipManager->hideToolTip();
}
}
void SidebarMode::hideMostUsedToolTip()
......
......@@ -35,74 +35,53 @@ Kirigami.ScrollablePage {
visible: false
}
background: MouseArea {
acceptedButtons: applicationWindow().wideScreen ? Qt.NoButton : Qt.LeftButton
onClicked: root.pageStack.currentIndex = 0;
hoverEnabled: !Kirigami.Settings.isMobile
visible: !applicationWindow().wideScreen
Accessible.role: Accessible.Button
Accessible.name: i18n("Go back")
Rectangle {
anchors.fill: parent
color: Kirigami.Theme.highlightColor
opacity: parent.containsMouse ? (parent.pressed ? 0.4 : 0.2) : 0
}
QQC2.ToolTip {
text: parent.Accessible.name
}
}
contentItem: RowLayout {
id: toolBarLayout
anchors.fill: parent
spacing: 0
// NOTE: this toolbutton is needed even if is not visible in order to have good
// size hints for the toolbar height which should perfectly align with the toolbar on the other side
QQC2.ToolButton {
id: backButton
visible: !applicationWindow().wideScreen
id: buttonSizePlaceholder
visible: false
icon.name: LayoutMirroring.enabled ? "go-previous-symbolic-rtl" : "go-previous-symbolic"
onClicked: root.pageStack.currentIndex = 0;
Accessible.role: Accessible.Button
Accessible.name: i18n("Go back")
QQC2.ToolTip {
text: parent.Accessible.name
}
}
Kirigami.Icon {
source: LayoutMirroring.enabled ? "go-previous-symbolic-rtl" : "go-previous-symbolic"
Layout.preferredWidth: buttonSizePlaceholder.implicitWidth
Layout.preferredHeight: Kirigami.Units.iconSizes.smallMedium
Layout.alignment: Qt.AlignCenter
}
MouseArea {
id: backToCategoryButton
implicitWidth: titleLayout.implicitWidth
implicitHeight: titleLayout.implicitHeight
Kirigami.Heading {
Layout.fillWidth: true
Layout.leftMargin: Kirigami.Units.smallSpacing
enabled: systemsettings.subCategoryModel.categoryOwnedByKCM
hoverEnabled: true
activeFocusOnTab: true
Accessible.role: Accessible.Button
Accessible.name: subCategoryColumn.title
onClicked: {
focus = true;
systemsettings.subCategoryModel.loadParentCategoryModule();
}
Rectangle {
anchors {
fill: parent
leftMargin: -Kirigami.Units.smallSpacing
}
radius: Kirigami.Units.smallSpacing
color: Kirigami.Theme.highlightColor
opacity: parent.containsMouse ? (parent.pressed ? 0.4 : 0.2) : (parent.activeFocus ? 0.1 : 0)
Behavior on opacity {
OpacityAnimator {
duration: Kirigami.Units.shortDuration
easing.type: Easing.InOutQuad
}
}
}
RowLayout {
id: titleLayout
spacing: Kirigami.Units.smallSpacing
Kirigami.Icon {
visible: systemsettings.subCategoryModel.categoryOwnedByKCM
source: systemsettings.subCategoryModel.icon
implicitWidth: Kirigami.Units.iconSizes.smallMedium
implicitHeight: Kirigami.Units.iconSizes.smallMedium
}
Kirigami.Heading {
Layout.fillWidth: true
Layout.fillHeight: true
// Don't be too short when the back button isn't visible
Layout.minimumHeight: backButton.implicitHeight
level: 3
text: subCategoryColumn.title
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
}
Layout.fillHeight: true
// Don't be too short when the back button isn't visible
Layout.minimumHeight: buttonSizePlaceholder.implicitHeight
level: 3
text: subCategoryColumn.title
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
}
}
background: Rectangle {
......@@ -123,6 +102,7 @@ Kirigami.ScrollablePage {
Keys.onBacktabPressed: {
mainColumn.focus = true;
}
onCountChanged: {
if (count > 1 && !root.searchMode) {
if (root.pageStack.depth < 2) {
......@@ -149,8 +129,6 @@ Kirigami.ScrollablePage {
if (systemsettings.activeSubCategoryRow >= 0) {
root.pageStack.currentIndex = 1;
subCategoryView.forceActiveFocus();
} else {
backToCategoryButton.forceActiveFocus();
}
}
onIntroPageVisibleChanged: {
......@@ -180,6 +158,7 @@ Kirigami.ScrollablePage {
highlighted: systemsettings.activeSubCategoryRow == index
Keys.onEnterPressed: clicked();
Keys.onReturnPressed: clicked();
leftPadding: Kirigami.Units.smallSpacing + (Kirigami.Units.smallSpacing + Kirigami.Units.iconSizes.smallMedium) * (model.DepthRole - 2)
contentItem: CategoryItem {}
}
}
......
Supports Markdown
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