Provide an error dialog if for any reason we can't access the settings file.

This commit is contained in:
Adam Treat 2023-07-12 08:50:21 -04:00
parent e9d42fba35
commit 13b2d47be5
3 changed files with 33 additions and 6 deletions

View File

@ -8,6 +8,7 @@
#include <QFile>
#include <QProcess>
#include <QResource>
#include <QSettings>
#include <fstream>
class MyLLM: public LLM { };
@ -48,7 +49,13 @@ LLM::LLM()
#endif
m_compatHardware = minimal;
emit compatHardwareChanged();
}
bool LLM::hasSettingsAccess() const
{
QSettings settings;
settings.sync();
return settings.status() == QSettings::NoError;
}
bool LLM::checkForUpdates() const

View File

@ -6,12 +6,11 @@
class LLM : public QObject
{
Q_OBJECT
Q_PROPERTY(bool compatHardware READ compatHardware NOTIFY compatHardwareChanged)
public:
static LLM *globalInstance();
bool compatHardware() const { return m_compatHardware; }
Q_INVOKABLE bool hasSettingsAccess() const;
Q_INVOKABLE bool compatHardware() const { return m_compatHardware; }
Q_INVOKABLE bool checkForUpdates() const;
Q_INVOKABLE bool directoryExists(const QString &path) const;
@ -22,7 +21,6 @@ public:
Q_SIGNALS:
void chatListModelChanged();
void modelListChanged();
void compatHardwareChanged();
private:
bool m_compatHardware;

View File

@ -89,14 +89,22 @@ Window {
property bool hasShownModelDownload: false
property bool hasShownFirstStart: false
property bool hasShownSettingsAccess: false
function startupDialogs() {
if (!LLM.compatHardware) {
if (!LLM.compatHardware()) {
Network.sendNonCompatHardware();
errorCompatHardware.open();
return;
}
// check if we have access to settings and if not show an error
if (!hasShownSettingsAccess && !LLM.hasSettingsAccess()) {
errorSettingsAccess.open();
hasShownSettingsAccess = true;
return;
}
// check for first time start of this version
if (!hasShownFirstStart && Download.isFirstStart()) {
firstStartDialog.open();
@ -135,6 +143,20 @@ Window {
+ qsTr("https://en.wikipedia.org/wiki/Advanced_Vector_Extensions</a>")
}
PopupDialog {
id: errorSettingsAccess
anchors.centerIn: parent
shouldTimeOut: false
shouldShowBusy: false
modal: true
text: qsTr("<h3>Encountered an error starting up:</h3><br>")
+ qsTr("<i>\"Inability to access settings file.\"</i>")
+ qsTr("<br><br>Unfortunately, something is preventing the program from accessing ")
+ qsTr("the settings file. This could be caused by incorrect permissions in the local ")
+ qsTr("app config directory where the settings file is located. ")
+ qsTr("Check out our <a href=\"https://discord.gg/4M2QFmTt2k\">discord channel</a> for help.")
}
StartupDialog {
id: firstStartDialog
anchors.centerIn: parent