Skip to content

Commit 906d10c

Browse files
committed
feat: Automatically configure the Qt render backend in the dev-watch script and refactor QML context property assignment in main.cpp.
1 parent e405784 commit 906d10c

2 files changed

Lines changed: 45 additions & 12 deletions

File tree

scripts/dev-watch.sh

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,36 @@ RED='\033[0;31m'
1414
GREEN='\033[0;32m'
1515
YELLOW='\033[1;33m'
1616
CYAN='\033[0;36m'
17-
BOLD='\033[1m'
1817
RESET='\033[0m'
1918

2019
log() { echo -e "${CYAN}[dev-watch]${RESET} $*"; }
2120
ok() { echo -e "${GREEN}[dev-watch]${RESET} $*"; }
2221
warn() { echo -e "${YELLOW}[dev-watch]${RESET} $*"; }
2322
err() { echo -e "${RED}[dev-watch]${RESET} $*"; }
2423

24+
# --- Qt render backend otomatik sec ---
25+
# GPU olmadan calisan sistemlerde (NVIDIA surucusu kurulu degil, VM, vb.)
26+
# Qt'un EGL hatasi vermemesi icin fallback backend ayarla
27+
setup_qt_env() {
28+
# Eger kullanici zaten bir backend secmisse dokunma
29+
if [[ -n "${QSG_RHI_BACKEND:-}" || -n "${QT_XCB_GL_INTEGRATION:-}" ]]; then
30+
return
31+
fi
32+
33+
# EGL/DRI2 kullanilabilir mi kontrol et
34+
if command -v glxinfo &>/dev/null && glxinfo 2>/dev/null | grep -q "direct rendering: Yes"; then
35+
# Donanim hizlandirma var, varsayilan backend kullan
36+
log "OpenGL donanim hizlandirma mevcut, varsayilan renderer kullaniliyor."
37+
else
38+
# Yazilim renderer'a gec - GPU olmayan / surucusuz ortam
39+
warn "GPU/EGL hizlandirma bulunamadi, yazilim renderer'a geciliyor."
40+
warn "NVIDIA surucu kurulduktan sonra bu uyari kaybolacak."
41+
export QT_XCB_GL_INTEGRATION=none
42+
export LIBGL_ALWAYS_SOFTWARE=0
43+
export QSG_RENDERER_DEBUG=""
44+
fi
45+
}
46+
2547
# --- Bagimlilik kontrolu ---
2648
if ! command -v inotifywait &>/dev/null; then
2749
err "inotify-tools bulunamadi. Kurmak icin:"
@@ -35,6 +57,12 @@ if [[ ! -d "$BUILD_DIR" || ! -f "$BUILD_DIR/CMakeCache.txt" ]]; then
3557
exit 1
3658
fi
3759

60+
if [[ ! -f "$BINARY" ]]; then
61+
warn "Binary bulunamadi: $BINARY"
62+
warn "Once sunu calistir: ./scripts/fedora-bootstrap.sh"
63+
exit 1
64+
fi
65+
3866
# --- Uygulamayi durdur ---
3967
stop_app() {
4068
if [[ -n "$APP_PID" ]] && kill -0 "$APP_PID" 2>/dev/null; then
@@ -52,8 +80,8 @@ build_and_run() {
5280
if cmake --build "$BUILD_DIR" -j"$(nproc)" 2>&1; then
5381
ok "Build basarili"
5482
stop_app
55-
log "Uygulama baslatiliyor: $BINARY"
56-
"$BINARY" &
83+
log "Uygulama baslatiliyor..."
84+
"$BINARY" 2>/dev/null &
5785
APP_PID=$!
5886
ok "ro-control calisiyor (PID: $APP_PID)"
5987
else
@@ -71,11 +99,15 @@ cleanup() {
7199
}
72100
trap cleanup SIGINT SIGTERM
73101

102+
# --- Qt ortam degiskenlerini ayarla ---
103+
setup_qt_env
104+
74105
# --- Baslangic ---
75106
echo ""
76107
log "ro-Control dev-watch modu"
77-
log "Izlenen dizin : $ROOT_DIR/src"
108+
log "Proje dizini : $ROOT_DIR"
78109
log "Build dizini : $BUILD_DIR"
110+
log "Izlenen dizin : $ROOT_DIR/src"
79111
log "Cikmak icin : Ctrl+C"
80112
echo ""
81113

src/main.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <QLocale>
77
#include <QObject>
88
#include <QQmlApplicationEngine>
9+
#include <QQmlContext>
910
#include <QTextStream>
1011
#include <QTranslator>
1112
#include <QVariant>
@@ -235,14 +236,14 @@ int main(int argc, char *argv[]) {
235236
RamMonitor ramMonitor;
236237

237238
QQmlApplicationEngine engine;
238-
engine.setInitialProperties({
239-
{"nvidiaDetector", QVariant::fromValue(&detector)},
240-
{"nvidiaInstaller", QVariant::fromValue(&installer)},
241-
{"nvidiaUpdater", QVariant::fromValue(&updater)},
242-
{"cpuMonitor", QVariant::fromValue(&cpuMonitor)},
243-
{"gpuMonitor", QVariant::fromValue(&gpuMonitor)},
244-
{"ramMonitor", QVariant::fromValue(&ramMonitor)},
245-
});
239+
240+
// Backend nesnelerini tüm QML dosyalarına global olarak aç
241+
engine.rootContext()->setContextProperty("nvidiaDetector", &detector);
242+
engine.rootContext()->setContextProperty("nvidiaInstaller", &installer);
243+
engine.rootContext()->setContextProperty("nvidiaUpdater", &updater);
244+
engine.rootContext()->setContextProperty("cpuMonitor", &cpuMonitor);
245+
engine.rootContext()->setContextProperty("gpuMonitor", &gpuMonitor);
246+
engine.rootContext()->setContextProperty("ramMonitor", &ramMonitor);
246247

247248
QObject::connect(
248249
&engine, &QQmlApplicationEngine::objectCreationFailed, &app,

0 commit comments

Comments
 (0)