mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
Don't show the download button if we are not connected to an online network.
Signed-off-by: Adam Treat <treat.adam@gmail.com>
This commit is contained in:
parent
4258bb1f8a
commit
260a56c748
@ -9,6 +9,7 @@
|
|||||||
#include <QResource>
|
#include <QResource>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QNetworkInformation>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#ifndef GPT4ALL_OFFLINE_INSTALLER
|
#ifndef GPT4ALL_OFFLINE_INSTALLER
|
||||||
@ -39,6 +40,10 @@ LLM::LLM()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_compatHardware = minimal;
|
m_compatHardware = minimal;
|
||||||
|
|
||||||
|
QNetworkInformation::loadDefaultBackend();
|
||||||
|
connect(QNetworkInformation::instance(), &QNetworkInformation::reachabilityChanged,
|
||||||
|
this, &LLM::isNetworkOnlineChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LLM::hasSettingsAccess() const
|
bool LLM::hasSettingsAccess() const
|
||||||
@ -100,3 +105,11 @@ QString LLM::systemTotalRAMInGBString() const
|
|||||||
{
|
{
|
||||||
return QString::fromStdString(getSystemTotalRAMInGBString());
|
return QString::fromStdString(getSystemTotalRAMInGBString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LLM::isNetworkOnline() const
|
||||||
|
{
|
||||||
|
if (!QNetworkInformation::instance())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return QNetworkInformation::instance()->reachability() == QNetworkInformation::Reachability::Online;
|
||||||
|
}
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
class LLM : public QObject
|
class LLM : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(bool isNetworkOnline READ isNetworkOnline NOTIFY isNetworkOnlineChanged)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static LLM *globalInstance();
|
static LLM *globalInstance();
|
||||||
|
|
||||||
@ -17,10 +19,10 @@ public:
|
|||||||
Q_INVOKABLE static bool fileExists(const QString &path);
|
Q_INVOKABLE static bool fileExists(const QString &path);
|
||||||
Q_INVOKABLE qint64 systemTotalRAMInGB() const;
|
Q_INVOKABLE qint64 systemTotalRAMInGB() const;
|
||||||
Q_INVOKABLE QString systemTotalRAMInGBString() const;
|
Q_INVOKABLE QString systemTotalRAMInGBString() const;
|
||||||
|
Q_INVOKABLE bool isNetworkOnline() const;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void chatListModelChanged();
|
void isNetworkOnlineChanged();
|
||||||
void modelListChanged();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_compatHardware;
|
bool m_compatHardware;
|
||||||
|
@ -869,6 +869,7 @@ Window {
|
|||||||
|
|
||||||
MyButton {
|
MyButton {
|
||||||
id: downloadButton
|
id: downloadButton
|
||||||
|
visible: LLM.isNetworkOnline
|
||||||
Layout.alignment: Qt.AlignHCenter
|
Layout.alignment: Qt.AlignHCenter
|
||||||
Layout.topMargin: 40
|
Layout.topMargin: 40
|
||||||
text: qsTr("Download models")
|
text: qsTr("Download models")
|
||||||
|
Loading…
Reference in New Issue
Block a user