mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-06-20 21:42:05 +08:00
Qt cleanup (#2622)
* scale * contain weston hack in one file * rest * no show * missed one
This commit is contained in:
@@ -40,7 +40,7 @@ if arch in ["x86_64", "Darwin", "larch64"]:
|
||||
"-DQT_CORE_LIB"
|
||||
]
|
||||
qt_env['CXXFLAGS'] += qt_flags
|
||||
|
||||
qt_env['LIBPATH'] += ['#selfdrive/ui']
|
||||
|
||||
|
||||
src = ['ui.cc', 'paint.cc', 'sidebar.cc', '#phonelibs/nanovg/nanovg.c']
|
||||
@@ -71,7 +71,13 @@ else:
|
||||
else:
|
||||
qt_libs += [f"Qt5{m}" for m in qt_modules]
|
||||
|
||||
qt_src = ["qt/ui.cc", "qt/window.cc", "qt/qt_sound.cc", "qt//offroad/keyboard.cc", "qt/offroad/input_field.cc", "qt/offroad/settings.cc", "qt/offroad/onboarding.cc", "qt/offroad/wifi.cc", "qt/offroad/wifiManager.cc"] + src
|
||||
qt_env.Library("qt_widgets",
|
||||
["qt/qt_window.cc", "qt/qt_sound.cc", "qt/offroad/keyboard.cc", "qt/offroad/input_field.cc",
|
||||
"qt/offroad/wifi.cc", "qt/offroad/wifiManager.cc"],
|
||||
LIBS=qt_libs)
|
||||
qt_libs.append("qt_widgets")
|
||||
|
||||
qt_src = ["qt/ui.cc", "qt/window.cc", "qt/offroad/settings.cc", "qt/offroad/onboarding.cc"] + src
|
||||
qt_env.Program("_ui", qt_src, LIBS=qt_libs + libs)
|
||||
|
||||
# spinner and text window
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
#include <string>
|
||||
|
||||
#ifdef QCOM2
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <QPlatformSurfaceEvent>
|
||||
#include <wayland-client-protocol.h>
|
||||
#endif
|
||||
|
||||
#include "qt_window.hpp"
|
||||
|
||||
void setMainWindow(QWidget *w) {
|
||||
float scale = getenv("SCALE") != NULL ? std::stof(getenv("SCALE")) : 1.0;
|
||||
w->setFixedSize(vwp_w*scale, vwp_h*scale);
|
||||
w->show();
|
||||
|
||||
#ifdef QCOM2
|
||||
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
|
||||
wl_surface *s = reinterpret_cast<wl_surface*>(native->nativeResourceForWindow("surface", w.windowHandle()));
|
||||
wl_surface_set_buffer_transform(s, WL_OUTPUT_TRANSFORM_270);
|
||||
wl_surface_commit(s);
|
||||
w.showFullScreen();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <QWidget>
|
||||
|
||||
#ifdef QCOM2
|
||||
const int vwp_w = 2160, vwp_h = 1080;
|
||||
#else
|
||||
const int vwp_w = 1920, vwp_h = 1080;
|
||||
#endif
|
||||
|
||||
void setMainWindow(QWidget *w);
|
||||
@@ -11,12 +11,7 @@
|
||||
#include <QApplication>
|
||||
|
||||
#include "setup.hpp"
|
||||
|
||||
#ifdef QCOM2
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <QPlatformSurfaceEvent>
|
||||
#include <wayland-client-protocol.h>
|
||||
#endif
|
||||
#include "qt_window.hpp"
|
||||
|
||||
int download(std::string url) {
|
||||
CURL *curl;
|
||||
@@ -166,25 +161,8 @@ Setup::Setup(QWidget *parent) {
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
#ifdef QCOM2
|
||||
int w = 2160, h = 1080;
|
||||
#else
|
||||
int w = 1920, h = 1080;
|
||||
#endif
|
||||
|
||||
QApplication a(argc, argv);
|
||||
|
||||
Setup setup;
|
||||
setup.setFixedSize(w, h);
|
||||
setup.show();
|
||||
|
||||
#ifdef QCOM2
|
||||
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
|
||||
wl_surface *s = reinterpret_cast<wl_surface*>(native->nativeResourceForWindow("surface", setup.windowHandle()));
|
||||
wl_surface_set_buffer_transform(s, WL_OUTPUT_TRANSFORM_270);
|
||||
wl_surface_commit(s);
|
||||
setup.showFullScreen();
|
||||
#endif
|
||||
|
||||
setMainWindow(&setup);
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
@@ -7,14 +7,8 @@
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
#ifdef QCOM2
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <QPlatformSurfaceEvent>
|
||||
#include <wayland-client-protocol.h>
|
||||
#endif
|
||||
|
||||
#include "spinner.hpp"
|
||||
|
||||
#include "qt_window.hpp"
|
||||
|
||||
Spinner::Spinner(QWidget *parent) {
|
||||
QGridLayout *main_layout = new QGridLayout();
|
||||
@@ -100,25 +94,7 @@ void Spinner::update(int n) {
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
|
||||
Spinner *spinner = new Spinner();
|
||||
|
||||
// TODO: get size from QScreen, doesn't work on tici
|
||||
#ifdef QCOM2
|
||||
int w = 2160, h = 1080;
|
||||
#else
|
||||
int w = 1920, h = 1080;
|
||||
#endif
|
||||
spinner->setFixedSize(w, h);
|
||||
spinner->show();
|
||||
|
||||
#ifdef QCOM2
|
||||
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
|
||||
wl_surface *s = reinterpret_cast<wl_surface*>(native->nativeResourceForWindow("surface", spinner->windowHandle()));
|
||||
wl_surface_set_buffer_transform(s, WL_OUTPUT_TRANSFORM_270);
|
||||
wl_surface_commit(s);
|
||||
spinner->showFullScreen();
|
||||
#endif
|
||||
|
||||
Spinner spinner;
|
||||
setMainWindow(&spinner);
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
+2
-26
@@ -6,26 +6,13 @@
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
|
||||
#ifdef QCOM2
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <QPlatformSurfaceEvent>
|
||||
#include <wayland-client-protocol.h>
|
||||
#endif
|
||||
|
||||
#include "qt_window.hpp"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
QApplication a(argc, argv);
|
||||
QWidget *window = new QWidget();
|
||||
|
||||
// TODO: get size from QScreen, doesn't work on tici
|
||||
#ifdef QCOM2
|
||||
int w = 2160, h = 1080;
|
||||
#else
|
||||
int w = 1920, h = 1080;
|
||||
#endif
|
||||
window->setFixedSize(w, h);
|
||||
setMainWindow(window);
|
||||
|
||||
QVBoxLayout *main_layout = new QVBoxLayout();
|
||||
|
||||
@@ -75,16 +62,5 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
)");
|
||||
|
||||
window->show();
|
||||
|
||||
|
||||
#ifdef QCOM2
|
||||
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
|
||||
wl_surface *s = reinterpret_cast<wl_surface*>(native->nativeResourceForWindow("surface", window->windowHandle()));
|
||||
wl_surface_set_buffer_transform(s, WL_OUTPUT_TRANSFORM_270);
|
||||
wl_surface_commit(s);
|
||||
window->showFullScreen();
|
||||
#endif
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
+3
-19
@@ -1,14 +1,10 @@
|
||||
#include <QApplication>
|
||||
|
||||
#ifdef QCOM2
|
||||
#include <qpa/qplatformnativeinterface.h>
|
||||
#include <QPlatformSurfaceEvent>
|
||||
#include <wayland-client-protocol.h>
|
||||
#endif
|
||||
|
||||
#include "window.hpp"
|
||||
#include "qt_window.hpp"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
// TODO: should probably be done in gl window
|
||||
QSurfaceFormat fmt;
|
||||
#ifdef __APPLE__
|
||||
fmt.setVersion(3, 2);
|
||||
@@ -20,20 +16,8 @@ int main(int argc, char *argv[]) {
|
||||
QSurfaceFormat::setDefaultFormat(fmt);
|
||||
|
||||
QApplication a(argc, argv);
|
||||
|
||||
MainWindow w;
|
||||
w.setFixedSize(vwp_w, vwp_h);
|
||||
w.show();
|
||||
|
||||
setMainWindow(&w);
|
||||
a.installEventFilter(&w);
|
||||
|
||||
#ifdef QCOM2
|
||||
QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
|
||||
wl_surface *s = reinterpret_cast<wl_surface*>(native->nativeResourceForWindow("surface", w.windowHandle()));
|
||||
wl_surface_set_buffer_transform(s, WL_OUTPUT_TRANSFORM_270);
|
||||
wl_surface_commit(s);
|
||||
w.showFullScreen();
|
||||
#endif
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include "window.hpp"
|
||||
#include "qt_window.hpp"
|
||||
#include "offroad/input_field.hpp"
|
||||
#include "offroad/settings.hpp"
|
||||
#include "offroad/onboarding.hpp"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
#include <QOpenGLWidget>
|
||||
@@ -11,14 +13,6 @@
|
||||
#include "offroad/settings.hpp"
|
||||
#include "offroad/onboarding.hpp"
|
||||
|
||||
#ifdef QCOM2
|
||||
const int vwp_w = 2160;
|
||||
#else
|
||||
const int vwp_w = 1920;
|
||||
#endif
|
||||
const int vwp_h = 1080;
|
||||
|
||||
|
||||
class GLWindow : public QOpenGLWidget, protected QOpenGLFunctions {
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user