mirror of
https://github.com/nomic-ai/gpt4all.git
synced 2024-10-01 01:06:10 -04:00
main: fix style and cleanup #includes
Signed-off-by: Jared Van Bortel <jared@nomic.ai>
This commit is contained in:
parent
edccc5b2f1
commit
a9d9d282d7
@ -12,14 +12,11 @@
|
|||||||
#include <singleapplication.h>
|
#include <singleapplication.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QGuiApplication>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QQmlApplicationEngine>
|
#include <QQmlApplicationEngine>
|
||||||
#include <QQmlEngine>
|
|
||||||
#include <QQuickWindow>
|
#include <QQuickWindow>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QTranslator>
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
|
|
||||||
@ -31,16 +28,19 @@
|
|||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void raiseWindow(QWindow* window) {
|
using namespace Qt::Literals::StringLiterals;
|
||||||
|
|
||||||
|
|
||||||
|
static void raiseWindow(QWindow *window)
|
||||||
|
{
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
HWND hwnd = (HWND)window->winId();
|
HWND hwnd = HWND(window->winId());
|
||||||
|
|
||||||
// check if window is minimized to Windows task bar
|
// check if window is minimized to Windows task bar
|
||||||
if (::IsIconic(hwnd)) {
|
if (IsIconic(hwnd))
|
||||||
::ShowWindow(hwnd, SW_RESTORE);
|
ShowWindow(hwnd, SW_RESTORE);
|
||||||
}
|
|
||||||
|
|
||||||
::SetForegroundWindow(hwnd);
|
SetForegroundWindow(hwnd);
|
||||||
#else
|
#else
|
||||||
window->show();
|
window->show();
|
||||||
window->raise();
|
window->raise();
|
||||||
@ -61,7 +61,7 @@ int main(int argc, char *argv[])
|
|||||||
SingleApplication app(argc, argv, true /*allowSecondary*/);
|
SingleApplication app(argc, argv, true /*allowSecondary*/);
|
||||||
if (app.isSecondary()) {
|
if (app.isSecondary()) {
|
||||||
#ifdef Q_OS_WINDOWS
|
#ifdef Q_OS_WINDOWS
|
||||||
AllowSetForegroundWindow( DWORD( app.primaryPid() ) );
|
AllowSetForegroundWindow(DWORD(app.primaryPid()));
|
||||||
#endif
|
#endif
|
||||||
app.sendMessage("RAISE_WINDOW");
|
app.sendMessage("RAISE_WINDOW");
|
||||||
return 0;
|
return 0;
|
||||||
@ -107,7 +107,7 @@ int main(int argc, char *argv[])
|
|||||||
qmlRegisterSingletonInstance("localdocs", 1, 0, "LocalDocs", LocalDocs::globalInstance());
|
qmlRegisterSingletonInstance("localdocs", 1, 0, "LocalDocs", LocalDocs::globalInstance());
|
||||||
qmlRegisterUncreatableMetaObject(MySettingsEnums::staticMetaObject, "mysettingsenums", 1, 0, "MySettingsEnums", "Error: only enums");
|
qmlRegisterUncreatableMetaObject(MySettingsEnums::staticMetaObject, "mysettingsenums", 1, 0, "MySettingsEnums", "Error: only enums");
|
||||||
|
|
||||||
const QUrl url(u"qrc:/gpt4all/main.qml"_qs);
|
const QUrl url(u"qrc:/gpt4all/main.qml"_s);
|
||||||
|
|
||||||
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
|
||||||
&app, [url](QObject *obj, const QUrl &objUrl) {
|
&app, [url](QObject *obj, const QUrl &objUrl) {
|
||||||
@ -117,7 +117,7 @@ int main(int argc, char *argv[])
|
|||||||
engine.load(url);
|
engine.load(url);
|
||||||
|
|
||||||
QObject *rootObject = engine.rootObjects().first();
|
QObject *rootObject = engine.rootObjects().first();
|
||||||
QQuickWindow *windowObject = qobject_cast<QQuickWindow*>(rootObject);
|
QQuickWindow *windowObject = qobject_cast<QQuickWindow *>(rootObject);
|
||||||
QObject::connect(&app, &SingleApplication::receivedMessage,
|
QObject::connect(&app, &SingleApplication::receivedMessage,
|
||||||
windowObject, [windowObject] () { raiseWindow(windowObject); } );
|
windowObject, [windowObject] () { raiseWindow(windowObject); } );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user