diff --git a/containments/homescreens/folio/foliosettings.cpp b/containments/homescreens/folio/foliosettings.cpp index 7ef571a3..f82271fb 100644 --- a/containments/homescreens/folio/foliosettings.cpp +++ b/containments/homescreens/folio/foliosettings.cpp @@ -106,6 +106,20 @@ void FolioSettings::setShowFavouritesBarBackground(bool showFavouritesBarBackgro } } +FolioSettings::PageTransitionEffect FolioSettings::pageTransitionEffect() const +{ + return m_pageTransitionEffect; +} + +void FolioSettings::setPageTransitionEffect(PageTransitionEffect pageTransitionEffect) +{ + if (m_pageTransitionEffect != pageTransitionEffect) { + m_pageTransitionEffect = pageTransitionEffect; + Q_EMIT pageTransitionEffectChanged(); + save(); + } +} + void FolioSettings::setApplet(Plasma::Applet *applet) { m_applet = applet; @@ -123,6 +137,7 @@ void FolioSettings::save() m_applet->config().writeEntry("showFavouritesAppLabels", m_showFavouritesAppLabels); m_applet->config().writeEntry("delegateIconSize", m_delegateIconSize); m_applet->config().writeEntry("showFavouritesBarBackground", m_showFavouritesBarBackground); + m_applet->config().writeEntry("pageTransitionEffect", (int)m_pageTransitionEffect); Q_EMIT m_applet->configNeedsSaving(); } @@ -139,6 +154,7 @@ void FolioSettings::load() m_showFavouritesAppLabels = m_applet->config().readEntry("showFavoritesAppLabels", false); m_delegateIconSize = m_applet->config().readEntry("delegateIconSize", 48); m_showFavouritesBarBackground = m_applet->config().readEntry("showFavoritesBarBackground", true); + m_pageTransitionEffect = static_cast(m_applet->config().readEntry("pageTransitionEffect", (int)SlideTransition)); Q_EMIT homeScreenRowsChanged(); Q_EMIT homeScreenColumnsChanged(); @@ -197,5 +213,8 @@ bool FolioSettings::loadLayoutFromFile(QString path) FavouritesModel::self()->loadFromJson(obj[QStringLiteral("Favourites")].toArray()); PageListModel::self()->loadFromJson(obj[QStringLiteral("Pages")].toArray()); + FavouritesModel::self()->save(); + PageListModel::self()->save(); + return true; } diff --git a/containments/homescreens/folio/foliosettings.h b/containments/homescreens/folio/foliosettings.h index 3cfe3953..eb47a3d9 100644 --- a/containments/homescreens/folio/foliosettings.h +++ b/containments/homescreens/folio/foliosettings.h @@ -16,12 +16,21 @@ class FolioSettings : public QObject Q_PROPERTY(bool showFavouritesAppLabels READ showFavouritesAppLabels WRITE setShowFavouritesAppLabels NOTIFY showFavouritesAppLabelsChanged) Q_PROPERTY(int delegateIconSize READ delegateIconSize WRITE setDelegateIconSize NOTIFY delegateIconSizeChanged) Q_PROPERTY(bool showFavouritesBarBackground READ showFavouritesBarBackground WRITE setShowFavouritesBarBackground NOTIFY showFavouritesBarBackgroundChanged) + Q_PROPERTY( + FolioSettings::PageTransitionEffect pageTransitionEffect READ pageTransitionEffect WRITE setPageTransitionEffect NOTIFY pageTransitionEffectChanged) public: FolioSettings(QObject *parent = nullptr); static FolioSettings *self(); + // ensure that existing enum values are the same when modifying, since this value is saved + enum PageTransitionEffect { + SlideTransition = 0, + CubeTransition = 1, + }; + Q_ENUM(PageTransitionEffect) + // number of rows and columns in the config for the homescreen // NOTE: use HomeScreenState.pageRows() instead in UI logic since we may have the rows and // columns swapped (in landscape layouts) @@ -43,6 +52,9 @@ public: bool showFavouritesBarBackground() const; void setShowFavouritesBarBackground(bool showFavouritesBarBackground); + PageTransitionEffect pageTransitionEffect() const; + void setPageTransitionEffect(PageTransitionEffect pageTransitionEffect); + Q_INVOKABLE void load(); Q_INVOKABLE bool saveLayoutToFile(QString path); @@ -57,6 +69,7 @@ Q_SIGNALS: void showFavouritesAppLabelsChanged(); void delegateIconSizeChanged(); void showFavouritesBarBackgroundChanged(); + void pageTransitionEffectChanged(); private: void save(); @@ -67,6 +80,7 @@ private: bool m_showFavouritesAppLabels{false}; qreal m_delegateIconSize{48}; bool m_showFavouritesBarBackground{false}; + PageTransitionEffect m_pageTransitionEffect{SlideTransition}; Plasma::Applet *m_applet{nullptr}; }; diff --git a/containments/homescreens/folio/package/contents/ui/HomeScreenPages.qml b/containments/homescreens/folio/package/contents/ui/HomeScreenPages.qml index bf276ba3..0ff543f5 100644 --- a/containments/homescreens/folio/package/contents/ui/HomeScreenPages.qml +++ b/containments/homescreens/folio/package/contents/ui/HomeScreenPages.qml @@ -35,12 +35,29 @@ MouseArea { anchors.bottomMargin: root.verticalMargin // animation so that full opacity is only when the page is in view - opacity: 1 - Math.min(1, Math.max(0, Math.abs(-Folio.HomeScreenState.pageViewX - root.width * pageNum) / root.width)) + readonly property real distanceToCenter: Math.abs(-Folio.HomeScreenState.pageViewX - root.width * pageNum) + readonly property real positionX: root.width * index + Folio.HomeScreenState.pageViewX + + opacity: 1 - Math.min(1, Math.max(0, distanceToCenter / root.width)) // x position of page - transform: Translate { - x: root.width * index + Folio.HomeScreenState.pageViewX - } + transform: [ + Translate { + x: homeScreenPage.positionX + }, + Rotation { + origin.x: Folio.HomeScreenState.pageWidth / 2; + origin.y: Folio.HomeScreenState.pageHeight / 2; + axis { x: 0; y: 1; z: 0 } + angle: { + if (Folio.FolioSettings.pageTransitionEffect !== Folio.FolioSettings.CubeTransition) { + return 0; + } + + return Math.min(1, Math.max(0, distanceToCenter / root.width)) * 90 * ((positionX > 0) ? 1 : -1) + } + } + ] } } } diff --git a/containments/homescreens/folio/package/contents/ui/settings/SettingsWindow.qml b/containments/homescreens/folio/package/contents/ui/settings/SettingsWindow.qml index b2d0a934..8e4693d9 100644 --- a/containments/homescreens/folio/package/contents/ui/settings/SettingsWindow.qml +++ b/containments/homescreens/folio/package/contents/ui/settings/SettingsWindow.qml @@ -128,7 +128,7 @@ Kirigami.ApplicationWindow { } FormCard.FormHeader { - title: i18n("Labels") + title: i18n("Homescreen") } FormCard.FormCard { @@ -155,6 +155,30 @@ Kirigami.ApplicationWindow { } } } + + FormCard.FormDelegateSeparator { above: showLabelsInFavourites; below: pageTransitionCombobox } + + FormCard.FormComboBoxDelegate { + id: pageTransitionCombobox + text: i18n("Page transition effect") + + currentIndex: indexOfValue(Folio.FolioSettings.pageTransitionEffect) + model: ListModel { + // we can't use i18n with ListElement + Component.onCompleted: { + append({"name": i18n("Slide"), "value": Folio.FolioSettings.SlideTransition}); + append({"name": i18n("Cube"), "value": Folio.FolioSettings.CubeTransition}); + + // indexOfValue doesn't bind to model changes unfortunately, set currentIndex manually here + pageTransitionCombobox.currentIndex = pageTransitionCombobox.indexOfValue(Folio.FolioSettings.pageTransitionEffect) + } + } + + textRole: "name" + valueRole: "value" + + onCurrentValueChanged: Folio.FolioSettings.pageTransitionEffect = currentValue + } } FormCard.FormHeader {