2023-10-22 03:59:27 +00:00
|
|
|
// SPDX-FileCopyrightText: 2023 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
|
|
#include "foliosettings.h"
|
2023-10-22 17:17:09 +00:00
|
|
|
#include "favouritesmodel.h"
|
|
|
|
|
#include "pagelistmodel.h"
|
|
|
|
|
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QJsonArray>
|
|
|
|
|
#include <QJsonDocument>
|
|
|
|
|
#include <QTextStream>
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2024-07-31 01:21:19 +00:00
|
|
|
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");
|
2025-04-21 14:01:54 +00:00
|
|
|
const QString CFG_KEY_LOCK_LAYOUT = QStringLiteral("lockLayout");
|
2024-07-31 01:21:19 +00:00
|
|
|
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");
|
Folio/Halcyon: Expand Background Blur Effect using a MaskLayer
This merge request expands upon the folio and halcyon background blur effects, making the folio background blur include the backgrounds of folder icons, the favorites bar, and wallpaper selector, and for halcyon, it now includes the folder icons, app library, search, and wallpaper selector. To accomplish this, a mask layer plugin was created to easily attach to these elements. This way, we can use a `OpacityMask` to cut out from the existing blur layer, thus hopefully keeping the performance cost low. And with my limited testing, it does at least seems to run about the same on my oneplus 6t, though it is not really a low end device, so I can not fairly judge the impact for something slower (eg. PinePhone). To be on the safe side, a third option was also added to the folio settings, allowing for the ability to toggle back to the old functionality if needed.




2025-06-27 18:27:30 +00:00
|
|
|
const QString CFG_KEY_SHOW_WALLPAPER_BLUR = QStringLiteral("wallpaperBlurEffect");
|
2025-06-27 04:14:26 +00:00
|
|
|
const QString CFG_KEY_DOUBLE_TAP_TO_LOCK = QStringLiteral("doubleTapToLock");
|
2024-07-31 01:21:19 +00:00
|
|
|
|
2024-06-21 04:42:14 +00:00
|
|
|
FolioSettings::FolioSettings(HomeScreen *parent)
|
Folio/Halcyon: Expand Background Blur Effect using a MaskLayer
This merge request expands upon the folio and halcyon background blur effects, making the folio background blur include the backgrounds of folder icons, the favorites bar, and wallpaper selector, and for halcyon, it now includes the folder icons, app library, search, and wallpaper selector. To accomplish this, a mask layer plugin was created to easily attach to these elements. This way, we can use a `OpacityMask` to cut out from the existing blur layer, thus hopefully keeping the performance cost low. And with my limited testing, it does at least seems to run about the same on my oneplus 6t, though it is not really a low end device, so I can not fairly judge the impact for something slower (eg. PinePhone). To be on the safe side, a third option was also added to the folio settings, allowing for the ability to toggle back to the old functionality if needed.




2025-06-27 18:27:30 +00:00
|
|
|
: QObject{parent}
|
|
|
|
|
, m_homeScreen{parent}
|
2023-10-22 03:59:27 +00:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int FolioSettings::homeScreenRows() const
|
|
|
|
|
{
|
|
|
|
|
// ensure that this is fetched fast and cached (it is called extremely often)
|
|
|
|
|
return m_homeScreenRows;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FolioSettings::setHomeScreenRows(int homeScreenRows)
|
|
|
|
|
{
|
|
|
|
|
if (m_homeScreenRows != homeScreenRows) {
|
|
|
|
|
m_homeScreenRows = homeScreenRows;
|
|
|
|
|
Q_EMIT homeScreenRowsChanged();
|
|
|
|
|
save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int FolioSettings::homeScreenColumns() const
|
|
|
|
|
{
|
|
|
|
|
return m_homeScreenColumns;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FolioSettings::setHomeScreenColumns(int homeScreenColumns)
|
|
|
|
|
{
|
|
|
|
|
if (m_homeScreenColumns != homeScreenColumns) {
|
|
|
|
|
m_homeScreenColumns = homeScreenColumns;
|
|
|
|
|
Q_EMIT homeScreenColumnsChanged();
|
|
|
|
|
save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FolioSettings::showPagesAppLabels() const
|
|
|
|
|
{
|
|
|
|
|
return m_showPagesAppLabels;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FolioSettings::setShowPagesAppLabels(bool showPagesAppLabels)
|
|
|
|
|
{
|
|
|
|
|
if (m_showPagesAppLabels != showPagesAppLabels) {
|
|
|
|
|
m_showPagesAppLabels = showPagesAppLabels;
|
|
|
|
|
Q_EMIT showPagesAppLabelsChanged();
|
|
|
|
|
save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FolioSettings::showFavouritesAppLabels() const
|
|
|
|
|
{
|
|
|
|
|
return m_showFavouritesAppLabels;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FolioSettings::setShowFavouritesAppLabels(bool showFavouritesAppLabels)
|
|
|
|
|
{
|
|
|
|
|
if (m_showFavouritesAppLabels != showFavouritesAppLabels) {
|
|
|
|
|
m_showFavouritesAppLabels = showFavouritesAppLabels;
|
|
|
|
|
Q_EMIT showFavouritesAppLabelsChanged();
|
|
|
|
|
save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-21 14:01:54 +00:00
|
|
|
bool FolioSettings::lockLayout() const
|
|
|
|
|
{
|
|
|
|
|
return m_lockLayout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FolioSettings::setLockLayout(bool lockLayout)
|
|
|
|
|
{
|
|
|
|
|
if (m_lockLayout != lockLayout) {
|
|
|
|
|
m_lockLayout = lockLayout;
|
|
|
|
|
Q_EMIT lockLayoutChanged();
|
|
|
|
|
save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
int FolioSettings::delegateIconSize() const
|
|
|
|
|
{
|
|
|
|
|
return m_delegateIconSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FolioSettings::setDelegateIconSize(int delegateIconSize)
|
|
|
|
|
{
|
|
|
|
|
if (m_delegateIconSize != delegateIconSize) {
|
|
|
|
|
m_delegateIconSize = delegateIconSize;
|
|
|
|
|
Q_EMIT delegateIconSizeChanged();
|
|
|
|
|
save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FolioSettings::showFavouritesBarBackground() const
|
|
|
|
|
{
|
|
|
|
|
return m_showFavouritesBarBackground;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FolioSettings::setShowFavouritesBarBackground(bool showFavouritesBarBackground)
|
|
|
|
|
{
|
|
|
|
|
if (m_showFavouritesBarBackground != showFavouritesBarBackground) {
|
|
|
|
|
m_showFavouritesBarBackground = showFavouritesBarBackground;
|
|
|
|
|
Q_EMIT showFavouritesBarBackgroundChanged();
|
|
|
|
|
save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-22 19:34:02 +00:00
|
|
|
FolioSettings::PageTransitionEffect FolioSettings::pageTransitionEffect() const
|
|
|
|
|
{
|
|
|
|
|
return m_pageTransitionEffect;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FolioSettings::setPageTransitionEffect(PageTransitionEffect pageTransitionEffect)
|
|
|
|
|
{
|
|
|
|
|
if (m_pageTransitionEffect != pageTransitionEffect) {
|
|
|
|
|
m_pageTransitionEffect = pageTransitionEffect;
|
|
|
|
|
Q_EMIT pageTransitionEffectChanged();
|
|
|
|
|
save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Folio/Halcyon: Expand Background Blur Effect using a MaskLayer
This merge request expands upon the folio and halcyon background blur effects, making the folio background blur include the backgrounds of folder icons, the favorites bar, and wallpaper selector, and for halcyon, it now includes the folder icons, app library, search, and wallpaper selector. To accomplish this, a mask layer plugin was created to easily attach to these elements. This way, we can use a `OpacityMask` to cut out from the existing blur layer, thus hopefully keeping the performance cost low. And with my limited testing, it does at least seems to run about the same on my oneplus 6t, though it is not really a low end device, so I can not fairly judge the impact for something slower (eg. PinePhone). To be on the safe side, a third option was also added to the folio settings, allowing for the ability to toggle back to the old functionality if needed.




2025-06-27 18:27:30 +00:00
|
|
|
FolioSettings::WallpaperBlurEffect FolioSettings::wallpaperBlurEffect() const
|
2024-02-08 17:10:55 +00:00
|
|
|
{
|
Folio/Halcyon: Expand Background Blur Effect using a MaskLayer
This merge request expands upon the folio and halcyon background blur effects, making the folio background blur include the backgrounds of folder icons, the favorites bar, and wallpaper selector, and for halcyon, it now includes the folder icons, app library, search, and wallpaper selector. To accomplish this, a mask layer plugin was created to easily attach to these elements. This way, we can use a `OpacityMask` to cut out from the existing blur layer, thus hopefully keeping the performance cost low. And with my limited testing, it does at least seems to run about the same on my oneplus 6t, though it is not really a low end device, so I can not fairly judge the impact for something slower (eg. PinePhone). To be on the safe side, a third option was also added to the folio settings, allowing for the ability to toggle back to the old functionality if needed.




2025-06-27 18:27:30 +00:00
|
|
|
return m_wallpaperBlurEffect;
|
2024-02-08 17:10:55 +00:00
|
|
|
}
|
|
|
|
|
|
Folio/Halcyon: Expand Background Blur Effect using a MaskLayer
This merge request expands upon the folio and halcyon background blur effects, making the folio background blur include the backgrounds of folder icons, the favorites bar, and wallpaper selector, and for halcyon, it now includes the folder icons, app library, search, and wallpaper selector. To accomplish this, a mask layer plugin was created to easily attach to these elements. This way, we can use a `OpacityMask` to cut out from the existing blur layer, thus hopefully keeping the performance cost low. And with my limited testing, it does at least seems to run about the same on my oneplus 6t, though it is not really a low end device, so I can not fairly judge the impact for something slower (eg. PinePhone). To be on the safe side, a third option was also added to the folio settings, allowing for the ability to toggle back to the old functionality if needed.




2025-06-27 18:27:30 +00:00
|
|
|
void FolioSettings::setWallpaperBlurEffect(WallpaperBlurEffect wallpaperBlurEffect)
|
2024-02-08 17:10:55 +00:00
|
|
|
{
|
Folio/Halcyon: Expand Background Blur Effect using a MaskLayer
This merge request expands upon the folio and halcyon background blur effects, making the folio background blur include the backgrounds of folder icons, the favorites bar, and wallpaper selector, and for halcyon, it now includes the folder icons, app library, search, and wallpaper selector. To accomplish this, a mask layer plugin was created to easily attach to these elements. This way, we can use a `OpacityMask` to cut out from the existing blur layer, thus hopefully keeping the performance cost low. And with my limited testing, it does at least seems to run about the same on my oneplus 6t, though it is not really a low end device, so I can not fairly judge the impact for something slower (eg. PinePhone). To be on the safe side, a third option was also added to the folio settings, allowing for the ability to toggle back to the old functionality if needed.




2025-06-27 18:27:30 +00:00
|
|
|
if (m_wallpaperBlurEffect != wallpaperBlurEffect) {
|
|
|
|
|
m_wallpaperBlurEffect = wallpaperBlurEffect;
|
|
|
|
|
Q_EMIT wallpaperBlurEffectChanged();
|
2024-02-08 17:10:55 +00:00
|
|
|
save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-27 04:14:26 +00:00
|
|
|
bool FolioSettings::doubleTapToLock() const
|
2025-06-25 20:39:36 +00:00
|
|
|
{
|
2025-06-27 04:14:26 +00:00
|
|
|
return m_doubleTapToLock;
|
2025-06-25 20:39:36 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-27 04:14:26 +00:00
|
|
|
void FolioSettings::setDoubleTapToLock(bool doubleTapToLock)
|
2025-06-25 20:39:36 +00:00
|
|
|
{
|
2025-06-27 04:14:26 +00:00
|
|
|
if (m_doubleTapToLock != doubleTapToLock) {
|
|
|
|
|
m_doubleTapToLock = doubleTapToLock;
|
|
|
|
|
Q_EMIT doubleTapToLockChanged();
|
2025-06-25 20:39:36 +00:00
|
|
|
save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
void FolioSettings::save()
|
|
|
|
|
{
|
2024-06-21 04:42:14 +00:00
|
|
|
if (!m_homeScreen) {
|
2023-10-22 03:59:27 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-31 01:21:19 +00:00
|
|
|
m_homeScreen->config().writeEntry(CFG_KEY_HOMESCREEN_ROWS, m_homeScreenRows);
|
|
|
|
|
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);
|
2025-04-21 14:01:54 +00:00
|
|
|
m_homeScreen->config().writeEntry(CFG_KEY_LOCK_LAYOUT, m_lockLayout);
|
2024-07-31 01:21:19 +00:00
|
|
|
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);
|
Folio/Halcyon: Expand Background Blur Effect using a MaskLayer
This merge request expands upon the folio and halcyon background blur effects, making the folio background blur include the backgrounds of folder icons, the favorites bar, and wallpaper selector, and for halcyon, it now includes the folder icons, app library, search, and wallpaper selector. To accomplish this, a mask layer plugin was created to easily attach to these elements. This way, we can use a `OpacityMask` to cut out from the existing blur layer, thus hopefully keeping the performance cost low. And with my limited testing, it does at least seems to run about the same on my oneplus 6t, though it is not really a low end device, so I can not fairly judge the impact for something slower (eg. PinePhone). To be on the safe side, a third option was also added to the folio settings, allowing for the ability to toggle back to the old functionality if needed.




2025-06-27 18:27:30 +00:00
|
|
|
m_homeScreen->config().writeEntry(CFG_KEY_SHOW_WALLPAPER_BLUR, (int)m_wallpaperBlurEffect);
|
2025-06-27 04:14:26 +00:00
|
|
|
m_homeScreen->config().writeEntry(CFG_KEY_DOUBLE_TAP_TO_LOCK, m_doubleTapToLock);
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2024-06-21 04:42:14 +00:00
|
|
|
Q_EMIT m_homeScreen->configNeedsSaving();
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FolioSettings::load()
|
|
|
|
|
{
|
2024-06-21 04:42:14 +00:00
|
|
|
if (!m_homeScreen) {
|
2023-10-22 03:59:27 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-31 01:21:19 +00:00
|
|
|
m_homeScreenRows = m_homeScreen->config().readEntry(CFG_KEY_HOMESCREEN_ROWS, 5);
|
|
|
|
|
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);
|
2025-04-21 14:01:54 +00:00
|
|
|
m_lockLayout = m_homeScreen->config().readEntry(CFG_KEY_LOCK_LAYOUT, false);
|
2024-07-31 01:21:19 +00:00
|
|
|
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));
|
Folio/Halcyon: Expand Background Blur Effect using a MaskLayer
This merge request expands upon the folio and halcyon background blur effects, making the folio background blur include the backgrounds of folder icons, the favorites bar, and wallpaper selector, and for halcyon, it now includes the folder icons, app library, search, and wallpaper selector. To accomplish this, a mask layer plugin was created to easily attach to these elements. This way, we can use a `OpacityMask` to cut out from the existing blur layer, thus hopefully keeping the performance cost low. And with my limited testing, it does at least seems to run about the same on my oneplus 6t, though it is not really a low end device, so I can not fairly judge the impact for something slower (eg. PinePhone). To be on the safe side, a third option was also added to the folio settings, allowing for the ability to toggle back to the old functionality if needed.




2025-06-27 18:27:30 +00:00
|
|
|
m_wallpaperBlurEffect = static_cast<WallpaperBlurEffect>(m_homeScreen->config().readEntry(CFG_KEY_SHOW_WALLPAPER_BLUR, (int)Full));
|
2025-06-27 04:14:26 +00:00
|
|
|
m_doubleTapToLock = m_homeScreen->config().readEntry(CFG_KEY_DOUBLE_TAP_TO_LOCK, true);
|
2023-10-22 03:59:27 +00:00
|
|
|
|
|
|
|
|
Q_EMIT homeScreenRowsChanged();
|
|
|
|
|
Q_EMIT homeScreenColumnsChanged();
|
|
|
|
|
Q_EMIT showPagesAppLabels();
|
|
|
|
|
Q_EMIT showFavouritesAppLabelsChanged();
|
2025-04-21 14:01:54 +00:00
|
|
|
Q_EMIT lockLayoutChanged();
|
2023-10-22 03:59:27 +00:00
|
|
|
Q_EMIT delegateIconSizeChanged();
|
Folio/Halcyon: Expand Background Blur Effect using a MaskLayer
This merge request expands upon the folio and halcyon background blur effects, making the folio background blur include the backgrounds of folder icons, the favorites bar, and wallpaper selector, and for halcyon, it now includes the folder icons, app library, search, and wallpaper selector. To accomplish this, a mask layer plugin was created to easily attach to these elements. This way, we can use a `OpacityMask` to cut out from the existing blur layer, thus hopefully keeping the performance cost low. And with my limited testing, it does at least seems to run about the same on my oneplus 6t, though it is not really a low end device, so I can not fairly judge the impact for something slower (eg. PinePhone). To be on the safe side, a third option was also added to the folio settings, allowing for the ability to toggle back to the old functionality if needed.




2025-06-27 18:27:30 +00:00
|
|
|
Q_EMIT wallpaperBlurEffectChanged();
|
2025-06-27 04:14:26 +00:00
|
|
|
Q_EMIT doubleTapToLockChanged();
|
2023-10-22 03:59:27 +00:00
|
|
|
}
|
2023-10-22 17:17:09 +00:00
|
|
|
|
|
|
|
|
bool FolioSettings::saveLayoutToFile(QString path)
|
|
|
|
|
{
|
2024-06-21 04:42:14 +00:00
|
|
|
if (!m_homeScreen) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-22 17:17:09 +00:00
|
|
|
if (path.startsWith(QStringLiteral("file://"))) {
|
|
|
|
|
path = path.replace(QStringLiteral("file://"), QString());
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-21 04:42:14 +00:00
|
|
|
QJsonArray favourites = m_homeScreen->favouritesModel()->exportToJson();
|
|
|
|
|
QJsonArray pages = m_homeScreen->pageListModel()->exportToJson();
|
2023-10-22 17:17:09 +00:00
|
|
|
|
|
|
|
|
QJsonObject obj;
|
|
|
|
|
obj[QStringLiteral("Favourites")] = favourites;
|
|
|
|
|
obj[QStringLiteral("Pages")] = pages;
|
|
|
|
|
|
|
|
|
|
QByteArray data = QJsonDocument(obj).toJson(QJsonDocument::Compact);
|
|
|
|
|
|
|
|
|
|
QFile file{path};
|
|
|
|
|
if (file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
|
|
|
|
file.write(data);
|
|
|
|
|
} else {
|
|
|
|
|
qDebug() << "failed to write to file:" << file.errorString();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FolioSettings::loadLayoutFromFile(QString path)
|
|
|
|
|
{
|
2024-06-21 04:42:14 +00:00
|
|
|
if (!m_homeScreen) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-22 17:17:09 +00:00
|
|
|
if (path.startsWith(QStringLiteral("file://"))) {
|
|
|
|
|
path = path.replace(QStringLiteral("file://"), QString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QFile file(path);
|
|
|
|
|
if (!file.open(QIODevice::ReadOnly)) {
|
|
|
|
|
qDebug() << "failed to open file:" << file.errorString();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QTextStream in(&file);
|
|
|
|
|
QString contents = in.readAll();
|
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
|
|
QJsonDocument doc = QJsonDocument::fromJson(contents.toUtf8());
|
|
|
|
|
QJsonObject obj = doc.object();
|
|
|
|
|
|
|
|
|
|
// TODO error checking
|
2024-06-21 04:42:14 +00:00
|
|
|
m_homeScreen->favouritesModel()->loadFromJson(obj[QStringLiteral("Favourites")].toArray());
|
|
|
|
|
m_homeScreen->pageListModel()->loadFromJson(obj[QStringLiteral("Pages")].toArray());
|
2023-10-22 17:17:09 +00:00
|
|
|
|
2024-06-21 04:42:14 +00:00
|
|
|
m_homeScreen->favouritesModel()->save();
|
|
|
|
|
m_homeScreen->pageListModel()->save();
|
2023-10-22 19:34:02 +00:00
|
|
|
|
2023-10-22 17:17:09 +00:00
|
|
|
return true;
|
|
|
|
|
}
|