mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-26 14:23:09 +00:00
Folio: Add ability to lock layout
Adds a new setting to lock the layout of the home screen so one will not accidentally modify it. Closes https://invent.kde.org/plasma/plasma-mobile/-/issues/459
This commit is contained in:
parent
1a89b84917
commit
036cc8502b
9 changed files with 64 additions and 2 deletions
|
|
@ -14,6 +14,7 @@ const QString CFG_KEY_HOMESCREEN_ROWS = QStringLiteral("homeScreenRows");
|
|||
const QString CFG_KEY_HOMESCREEN_COLS = QStringLiteral("homeScreenColumns");
|
||||
const QString CFG_KEY_SHOW_PAGES_APPLABELS = QStringLiteral("showPagesAppLabels");
|
||||
const QString CFG_KEY_SHOW_FAVORITES_APPLABELS = QStringLiteral("showFavoritesAppLabels");
|
||||
const QString CFG_KEY_LOCK_LAYOUT = QStringLiteral("lockLayout");
|
||||
const QString CFG_KEY_DELEGATE_ICON_SIZE = QStringLiteral("delegateIconSize");
|
||||
const QString CFG_KEY_SHOW_FAVORITES_BAR_BACKGROUND = QStringLiteral("showFavoritesBarBackground");
|
||||
const QString CFG_KEY_PAGE_TRANSITION_EFFECT = QStringLiteral("pageTransitionEffect");
|
||||
|
|
@ -82,6 +83,20 @@ void FolioSettings::setShowFavouritesAppLabels(bool showFavouritesAppLabels)
|
|||
}
|
||||
}
|
||||
|
||||
bool FolioSettings::lockLayout() const
|
||||
{
|
||||
return m_lockLayout;
|
||||
}
|
||||
|
||||
void FolioSettings::setLockLayout(bool lockLayout)
|
||||
{
|
||||
if (m_lockLayout != lockLayout) {
|
||||
m_lockLayout = lockLayout;
|
||||
Q_EMIT lockLayoutChanged();
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
int FolioSettings::delegateIconSize() const
|
||||
{
|
||||
return m_delegateIconSize;
|
||||
|
|
@ -148,6 +163,7 @@ void FolioSettings::save()
|
|||
m_homeScreen->config().writeEntry(CFG_KEY_HOMESCREEN_COLS, m_homeScreenColumns);
|
||||
m_homeScreen->config().writeEntry(CFG_KEY_SHOW_PAGES_APPLABELS, m_showPagesAppLabels);
|
||||
m_homeScreen->config().writeEntry(CFG_KEY_SHOW_FAVORITES_APPLABELS, m_showFavouritesAppLabels);
|
||||
m_homeScreen->config().writeEntry(CFG_KEY_LOCK_LAYOUT, m_lockLayout);
|
||||
m_homeScreen->config().writeEntry(CFG_KEY_DELEGATE_ICON_SIZE, m_delegateIconSize);
|
||||
m_homeScreen->config().writeEntry(CFG_KEY_SHOW_FAVORITES_BAR_BACKGROUND, m_showFavouritesBarBackground);
|
||||
m_homeScreen->config().writeEntry(CFG_KEY_PAGE_TRANSITION_EFFECT, (int)m_pageTransitionEffect);
|
||||
|
|
@ -166,6 +182,7 @@ void FolioSettings::load()
|
|||
m_homeScreenColumns = m_homeScreen->config().readEntry(CFG_KEY_HOMESCREEN_COLS, 4);
|
||||
m_showPagesAppLabels = m_homeScreen->config().readEntry(CFG_KEY_SHOW_PAGES_APPLABELS, true);
|
||||
m_showFavouritesAppLabels = m_homeScreen->config().readEntry(CFG_KEY_SHOW_FAVORITES_APPLABELS, false);
|
||||
m_lockLayout = m_homeScreen->config().readEntry(CFG_KEY_LOCK_LAYOUT, false);
|
||||
m_delegateIconSize = m_homeScreen->config().readEntry(CFG_KEY_DELEGATE_ICON_SIZE, 48);
|
||||
m_showFavouritesBarBackground = m_homeScreen->config().readEntry(CFG_KEY_SHOW_FAVORITES_BAR_BACKGROUND, true);
|
||||
m_pageTransitionEffect = static_cast<PageTransitionEffect>(m_homeScreen->config().readEntry(CFG_KEY_PAGE_TRANSITION_EFFECT, (int)SlideTransition));
|
||||
|
|
@ -175,6 +192,7 @@ void FolioSettings::load()
|
|||
Q_EMIT homeScreenColumnsChanged();
|
||||
Q_EMIT showPagesAppLabels();
|
||||
Q_EMIT showFavouritesAppLabelsChanged();
|
||||
Q_EMIT lockLayoutChanged();
|
||||
Q_EMIT delegateIconSizeChanged();
|
||||
Q_EMIT showWallpaperBlurChanged();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ class FolioSettings : public QObject
|
|||
Q_PROPERTY(int homeScreenColumns READ homeScreenColumns WRITE setHomeScreenColumns NOTIFY homeScreenColumnsChanged)
|
||||
Q_PROPERTY(bool showPagesAppLabels READ showPagesAppLabels WRITE setShowPagesAppLabels NOTIFY showPagesAppLabelsChanged)
|
||||
Q_PROPERTY(bool showFavouritesAppLabels READ showFavouritesAppLabels WRITE setShowFavouritesAppLabels NOTIFY showFavouritesAppLabelsChanged)
|
||||
Q_PROPERTY(bool lockLayout READ lockLayout WRITE setLockLayout NOTIFY lockLayoutChanged)
|
||||
Q_PROPERTY(int delegateIconSize READ delegateIconSize WRITE setDelegateIconSize NOTIFY delegateIconSizeChanged)
|
||||
Q_PROPERTY(bool showFavouritesBarBackground READ showFavouritesBarBackground WRITE setShowFavouritesBarBackground NOTIFY showFavouritesBarBackgroundChanged)
|
||||
Q_PROPERTY(
|
||||
|
|
@ -52,6 +53,9 @@ public:
|
|||
bool showFavouritesAppLabels() const;
|
||||
void setShowFavouritesAppLabels(bool showFavouritesAppLabels);
|
||||
|
||||
bool lockLayout() const;
|
||||
void setLockLayout(bool lockLayout);
|
||||
|
||||
int delegateIconSize() const;
|
||||
void setDelegateIconSize(int delegateIconSize);
|
||||
|
||||
|
|
@ -74,6 +78,7 @@ Q_SIGNALS:
|
|||
void homeScreenColumnsChanged();
|
||||
void showPagesAppLabelsChanged();
|
||||
void showFavouritesAppLabelsChanged();
|
||||
void lockLayoutChanged();
|
||||
void delegateIconSizeChanged();
|
||||
void showFavouritesBarBackgroundChanged();
|
||||
void pageTransitionEffectChanged();
|
||||
|
|
@ -88,6 +93,7 @@ private:
|
|||
int m_homeScreenColumns{4};
|
||||
bool m_showPagesAppLabels{false};
|
||||
bool m_showFavouritesAppLabels{false};
|
||||
bool m_lockLayout{false};
|
||||
qreal m_delegateIconSize{48};
|
||||
bool m_showFavouritesBarBackground{false};
|
||||
PageTransitionEffect m_pageTransitionEffect{SlideTransition};
|
||||
|
|
|
|||
|
|
@ -91,6 +91,9 @@ MobileShell.GridView {
|
|||
height: root.cellHeight
|
||||
|
||||
onPressAndHold: {
|
||||
// prevent editing if lock layout is enabled
|
||||
if (folio.FolioSettings.lockLayout) return;
|
||||
|
||||
const mappedCoords = root.homeScreen.prepareStartDelegateDrag(model.delegate, appDelegate.delegateItem, true);
|
||||
folio.HomeScreenState.closeAppDrawer();
|
||||
|
||||
|
|
|
|||
|
|
@ -108,6 +108,9 @@ MouseArea {
|
|||
labelOpacity: delegate.opacity
|
||||
|
||||
onPressAndHold: {
|
||||
// prevent editing if lock layout is enabled
|
||||
if (folio.FolioSettings.lockLayout) return;
|
||||
|
||||
let mappedCoords = root.homeScreen.prepareStartDelegateDrag(delegate.delegateModel, appDelegate.delegateItem);
|
||||
folio.HomeScreenState.startDelegateFavouritesDrag(
|
||||
mappedCoords.x,
|
||||
|
|
@ -149,6 +152,7 @@ MouseArea {
|
|||
Kirigami.Action {
|
||||
icon.name: "emblem-favorite"
|
||||
text: i18n("Remove")
|
||||
enabled: !folio.FolioSettings.lockLayout
|
||||
onTriggered: folio.FavouritesModel.removeEntry(delegate.index)
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -246,6 +246,9 @@ Folio.DelegateTouchArea {
|
|||
labelOpacity: delegate.opacity
|
||||
|
||||
onPressAndHold: {
|
||||
// prevent editing if lock layout is enabled
|
||||
if (folio.FolioSettings.lockLayout) return;
|
||||
|
||||
let mappedCoords = root.homeScreen.prepareStartDelegateDrag(delegate.delegateModel, appDelegate.delegateItem);
|
||||
folio.HomeScreenState.startDelegateFolderDrag(
|
||||
mappedCoords.x,
|
||||
|
|
@ -288,6 +291,7 @@ Folio.DelegateTouchArea {
|
|||
Kirigami.Action {
|
||||
icon.name: "emblem-favorite"
|
||||
text: i18n("Remove")
|
||||
enabled: !folio.FolioSettings.lockLayout
|
||||
onTriggered: root.folder.removeDelegate(delegate.index)
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -174,6 +174,9 @@ Item {
|
|||
labelOpacity: delegate.opacity
|
||||
|
||||
onPressAndHold: {
|
||||
// prevent editing if lock layout is enabled
|
||||
if (folio.FolioSettings.lockLayout) return;
|
||||
|
||||
let mappedCoords = root.homeScreen.prepareStartDelegateDrag(delegate.pageDelegate, appDelegate.delegateItem);
|
||||
folio.HomeScreenState.startDelegatePageDrag(
|
||||
mappedCoords.x,
|
||||
|
|
@ -216,6 +219,7 @@ Item {
|
|||
Kirigami.Action {
|
||||
icon.name: "emblem-favorite"
|
||||
text: i18n("Remove")
|
||||
enabled: !folio.FolioSettings.lockLayout
|
||||
onTriggered: delegate.removeSelf()
|
||||
}
|
||||
]
|
||||
|
|
@ -253,6 +257,9 @@ Item {
|
|||
}
|
||||
|
||||
onPressAndHold: {
|
||||
// prevent editing if lock layout is enabled
|
||||
if (folio.FolioSettings.lockLayout) return;
|
||||
|
||||
let mappedCoords = root.homeScreen.prepareStartDelegateDrag(delegate.pageDelegate, appFolderDelegate.delegateItem);
|
||||
folio.HomeScreenState.startDelegatePageDrag(
|
||||
mappedCoords.x,
|
||||
|
|
@ -296,6 +303,7 @@ Item {
|
|||
Kirigami.Action {
|
||||
icon.name: "emblem-favorite"
|
||||
text: i18n("Remove")
|
||||
enabled: !folio.FolioSettings.lockLayout
|
||||
onTriggered: deleteDialog.open()
|
||||
}
|
||||
]
|
||||
|
|
@ -326,6 +334,9 @@ Item {
|
|||
widget: suppressAppletReparent ? null : delegate.pageDelegate.widget
|
||||
|
||||
onStartEditMode: (pressPoint) => {
|
||||
// prevent editing if lock layout is enabled
|
||||
if (folio.FolioSettings.lockLayout) return;
|
||||
|
||||
let mappedCoords = root.homeScreen.prepareStartDelegateDrag(delegate.pageDelegate, widgetDelegate);
|
||||
folio.HomeScreenState.startDelegatePageDrag(
|
||||
mappedCoords.x,
|
||||
|
|
@ -348,7 +359,7 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
layer.enabled: widgetDelegate.editMode
|
||||
layer.enabled: widgetDelegate.editMode && folio.FolioSettings.lockLayout === false
|
||||
layer.effect: DarkenEffect {}
|
||||
|
||||
PC3.ToolTip {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ Item {
|
|||
signal closed()
|
||||
|
||||
function startOpen() {
|
||||
// prevent config overlay if lock layout is enabled
|
||||
if (folio.FolioSettings.lockLayout) return;
|
||||
configOverlay.open();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ Loader {
|
|||
delegate: PC3.MenuItem {
|
||||
icon.name: modelData.iconName
|
||||
text: modelData.text
|
||||
enabled: modelData.enabled
|
||||
onClicked: modelData.triggered()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,7 +194,20 @@ Window {
|
|||
}
|
||||
}
|
||||
|
||||
FormCard.FormDelegateSeparator { above: showLabelsInFavourites; below: pageTransitionCombobox }
|
||||
FormCard.FormDelegateSeparator { above: showLabelsInFavourites; below: lockLayout }
|
||||
|
||||
FormCard.FormSwitchDelegate {
|
||||
id: lockLayout
|
||||
text: i18n("Lock layout")
|
||||
checked: folio.FolioSettings.lockLayout
|
||||
onCheckedChanged: {
|
||||
if (checked != folio.FolioSettings.lockLayout) {
|
||||
folio.FolioSettings.lockLayout = checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FormCard.FormDelegateSeparator { above: lockLayout; below: pageTransitionCombobox }
|
||||
|
||||
FormCard.FormComboBoxDelegate {
|
||||
id: pageTransitionCombobox
|
||||
|
|
|
|||
Loading…
Reference in a new issue