Add warning popup when old settings.json detected
This commit is contained in:
parent
5dfe700880
commit
86f0a8a6a0
|
@ -29,7 +29,9 @@ from .models.model import Model
|
||||||
from .models.model_store import ModelStore
|
from .models.model_store import ModelStore
|
||||||
from .presence import Presence
|
from .presence import Presence
|
||||||
from .sso_server import SSOServer
|
from .sso_server import SSOServer
|
||||||
from .user_files import Accounts, History, NewTheme, Settings, Theme, UIState
|
from .user_files import (
|
||||||
|
Accounts, History, NewTheme, Pre070Settings, Settings, Theme, UIState,
|
||||||
|
)
|
||||||
|
|
||||||
# Logging configuration
|
# Logging configuration
|
||||||
log.getLogger().setLevel(log.INFO)
|
log.getLogger().setLevel(log.INFO)
|
||||||
|
@ -112,6 +114,7 @@ class Backend:
|
||||||
self.theme = Theme(self, self.settings.General.theme)
|
self.theme = Theme(self, self.settings.General.theme)
|
||||||
# self.new_theme = NewTheme(self, self.settings.General.new_theme)
|
# self.new_theme = NewTheme(self, self.settings.General.new_theme)
|
||||||
self.new_theme = NewTheme(self, ".new.py") # TODO
|
self.new_theme = NewTheme(self, ".new.py") # TODO
|
||||||
|
Pre070Settings(self)
|
||||||
|
|
||||||
self.clients: Dict[str, MatrixClient] = {}
|
self.clients: Dict[str, MatrixClient] = {}
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,12 @@ class LoopException(PyOtherSideEvent):
|
||||||
traceback: Optional[str] = None
|
traceback: Optional[str] = None
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Pre070SettingsDetected(PyOtherSideEvent):
|
||||||
|
"""Warn that a pre-0.7.0 settings.json file exists."""
|
||||||
|
path: Path = field()
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class UserFileChanged(PyOtherSideEvent):
|
class UserFileChanged(PyOtherSideEvent):
|
||||||
"""Indicate that a config or data file changed on disk."""
|
"""Indicate that a config or data file changed on disk."""
|
||||||
|
|
|
@ -145,7 +145,7 @@ class QMLBridge:
|
||||||
rc = lambda c: asyncio.run_coroutine_threadsafe(c, self._loop) # noqa
|
rc = lambda c: asyncio.run_coroutine_threadsafe(c, self._loop) # noqa
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from devtools import debug # noqa
|
from devtools import debug # noqa
|
||||||
d = debug # noqa
|
d = debug # noqa
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
log.warning("Module python-devtools not found, can't use debug()")
|
log.warning("Module python-devtools not found, can't use debug()")
|
||||||
|
|
|
@ -18,7 +18,9 @@ import pyotherside
|
||||||
from watchgod import Change, awatch
|
from watchgod import Change, awatch
|
||||||
|
|
||||||
from .pcn.section import Section
|
from .pcn.section import Section
|
||||||
from .pyotherside_events import LoopException, UserFileChanged
|
from .pyotherside_events import (
|
||||||
|
LoopException, Pre070SettingsDetected, UserFileChanged,
|
||||||
|
)
|
||||||
from .theme_parser import convert_to_qml
|
from .theme_parser import convert_to_qml
|
||||||
from .utils import (
|
from .utils import (
|
||||||
aiopen, atomic_write, deep_serialize_for_qml, dict_update_recursive,
|
aiopen, atomic_write, deep_serialize_for_qml, dict_update_recursive,
|
||||||
|
@ -396,6 +398,17 @@ class Accounts(ConfigFile, JSONFile):
|
||||||
self.save()
|
self.save()
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class Pre070Settings(ConfigFile):
|
||||||
|
"""Detect and warn about the presence of a pre-0.7.0 settings.json file."""
|
||||||
|
|
||||||
|
filename: str = "settings.json"
|
||||||
|
|
||||||
|
def __post_init__(self) -> None:
|
||||||
|
if self.path.exists():
|
||||||
|
Pre070SettingsDetected(self.path)
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class Settings(ConfigFile, PCNFile):
|
class Settings(ConfigFile, PCNFile):
|
||||||
"""General config file for UI and backend settings"""
|
"""General config file for UI and backend settings"""
|
||||||
|
|
56
src/gui/Popups/Pre070SettingsDetectedPopup.qml
Normal file
56
src/gui/Popups/Pre070SettingsDetectedPopup.qml
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
// Copyright Mirage authors & contributors <https://github.com/mirukana/mirage>
|
||||||
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
|
||||||
|
import QtQuick 2.12
|
||||||
|
import "../Base"
|
||||||
|
import "../Base/Buttons"
|
||||||
|
|
||||||
|
HFlickableColumnPopup {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
property string path
|
||||||
|
|
||||||
|
readonly property string docs:
|
||||||
|
"https://github.com/mirukana/mirage/tree/dev/docs"
|
||||||
|
|
||||||
|
page.footer: AutoDirectionLayout {
|
||||||
|
CancelButton {
|
||||||
|
id: cancelButton
|
||||||
|
text: qsTr("Close")
|
||||||
|
onClicked: root.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onOpened: cancelButton.forceActiveFocus()
|
||||||
|
|
||||||
|
SummaryLabel {
|
||||||
|
leftPadding: theme.spacing / 2
|
||||||
|
rightPadding: leftPadding
|
||||||
|
textFormat: SummaryLabel.StyledText
|
||||||
|
text: qsTr("Old configuration file %1 detected").arg(
|
||||||
|
utils.htmlColorize("settings.json", theme.colors.accentText),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
DetailsLabel {
|
||||||
|
leftPadding: theme.spacing / 2
|
||||||
|
rightPadding: leftPadding
|
||||||
|
textFormat: DetailsLabel.StyledText
|
||||||
|
text: qsTr(
|
||||||
|
"The configuration format has changed and <i>settings.json</i> " +
|
||||||
|
"is no longer supported. " +
|
||||||
|
`Visit the <a href='${docs}'>new config documentation</a> for ` +
|
||||||
|
"more info.<br><br>" +
|
||||||
|
"This warning will stop appearing if the file " +
|
||||||
|
`<a href='${path}'>${path.replace(/^file:\/\//, "")}</a> is ` +
|
||||||
|
"renamed, removed or moved away."
|
||||||
|
)
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
acceptedButtons: Qt.NoButton
|
||||||
|
cursorShape:
|
||||||
|
parent.hoveredLink ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -61,6 +61,10 @@ QtObject {
|
||||||
py.showError(type, traceback, "", message)
|
py.showError(type, traceback, "", message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onPre070SettingsDetected(path) {
|
||||||
|
window.makePopup("Popups/Pre070SettingsDetectedPopup.qml", {path})
|
||||||
|
}
|
||||||
|
|
||||||
function onUserFileChanged(type, newData) {
|
function onUserFileChanged(type, newData) {
|
||||||
if (type === "Theme") {
|
if (type === "Theme") {
|
||||||
window.theme = Qt.createQmlObject(newData, window, "theme")
|
window.theme = Qt.createQmlObject(newData, window, "theme")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user