Added better support for Qt5 and Qt6
This commit is contained in:
parent
0dee863e9c
commit
bb85b52418
|
@ -932,14 +932,14 @@ Result ISystemSettingsServer::SetPrimaryAlbumStorage(PrimaryAlbumStorage primary
|
||||||
Result ISystemSettingsServer::GetBatteryLot(Out<BatteryLot> out_battery_lot) {
|
Result ISystemSettingsServer::GetBatteryLot(Out<BatteryLot> out_battery_lot) {
|
||||||
LOG_INFO(Service_SET, "called");
|
LOG_INFO(Service_SET, "called");
|
||||||
|
|
||||||
*out_battery_lot = {"SUDA0EMULATOR14022024"};
|
*out_battery_lot = BatteryLot{"SUDA0EMULATOR14022024"};
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result ISystemSettingsServer::GetSerialNumber(Out<SerialNumber> out_console_serial) {
|
Result ISystemSettingsServer::GetSerialNumber(Out<SerialNumber> out_console_serial) {
|
||||||
LOG_INFO(Service_SET, "called");
|
LOG_INFO(Service_SET, "called");
|
||||||
|
|
||||||
*out_console_serial = {"YUZ10000000001"};
|
*out_console_serial = SerialNumber{"YUZ10000000001"};
|
||||||
R_SUCCEED();
|
R_SUCCEED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -736,19 +736,35 @@ void GRenderWindow::wheelEvent(QWheelEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) {
|
void GRenderWindow::TouchBeginEvent(const QTouchEvent* event) {
|
||||||
|
#ifdef ENABLE_QT6
|
||||||
QList<QTouchEvent::TouchPoint> touch_points = event->points();
|
QList<QTouchEvent::TouchPoint> touch_points = event->points();
|
||||||
|
#else
|
||||||
|
QList<QTouchEvent::TouchPoint> touch_points = event->touchPoints();
|
||||||
|
#endif
|
||||||
for (const auto& touch_point : touch_points) {
|
for (const auto& touch_point : touch_points) {
|
||||||
|
#ifdef ENABLE_QT6
|
||||||
const auto [x, y] = ScaleTouch(touch_point.position());
|
const auto [x, y] = ScaleTouch(touch_point.position());
|
||||||
|
#else
|
||||||
|
const auto [x, y] = ScaleTouch(touch_point.pos());
|
||||||
|
#endif
|
||||||
const auto [touch_x, touch_y] = MapToTouchScreen(x, y);
|
const auto [touch_x, touch_y] = MapToTouchScreen(x, y);
|
||||||
input_subsystem->GetTouchScreen()->TouchPressed(touch_x, touch_y, touch_point.id());
|
input_subsystem->GetTouchScreen()->TouchPressed(touch_x, touch_y, touch_point.id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GRenderWindow::TouchUpdateEvent(const QTouchEvent* event) {
|
void GRenderWindow::TouchUpdateEvent(const QTouchEvent* event) {
|
||||||
|
#ifdef ENABLE_QT6
|
||||||
QList<QTouchEvent::TouchPoint> touch_points = event->points();
|
QList<QTouchEvent::TouchPoint> touch_points = event->points();
|
||||||
|
#else
|
||||||
|
QList<QTouchEvent::TouchPoint> touch_points = event->touchPoints();
|
||||||
|
#endif
|
||||||
input_subsystem->GetTouchScreen()->ClearActiveFlag();
|
input_subsystem->GetTouchScreen()->ClearActiveFlag();
|
||||||
for (const auto& touch_point : touch_points) {
|
for (const auto& touch_point : touch_points) {
|
||||||
|
#ifdef ENABLE_QT6
|
||||||
const auto [x, y] = ScaleTouch(touch_point.position());
|
const auto [x, y] = ScaleTouch(touch_point.position());
|
||||||
|
#else
|
||||||
|
const auto [x, y] = ScaleTouch(touch_point.pos());
|
||||||
|
#endif
|
||||||
const auto [touch_x, touch_y] = MapToTouchScreen(x, y);
|
const auto [touch_x, touch_y] = MapToTouchScreen(x, y);
|
||||||
input_subsystem->GetTouchScreen()->TouchMoved(touch_x, touch_y, touch_point.id());
|
input_subsystem->GetTouchScreen()->TouchMoved(touch_x, touch_y, touch_point.id());
|
||||||
}
|
}
|
||||||
|
|
|
@ -505,7 +505,11 @@ void TouchScreenPreview::mouseMoveEvent(QMouseEvent* event) {
|
||||||
if (!coord_label) {
|
if (!coord_label) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_QT6
|
||||||
const auto pos = MapToDeviceCoords(event->position().x(), event->position().y());
|
const auto pos = MapToDeviceCoords(event->position().x(), event->position().y());
|
||||||
|
#else
|
||||||
|
const auto pos = MapToDeviceCoords(event->x(), event->y());
|
||||||
|
#endif
|
||||||
if (pos) {
|
if (pos) {
|
||||||
coord_label->setText(QStringLiteral("X: %1, Y: %2").arg(pos->x()).arg(pos->y()));
|
coord_label->setText(QStringLiteral("X: %1, Y: %2").arg(pos->x()).arg(pos->y()));
|
||||||
} else {
|
} else {
|
||||||
|
@ -523,7 +527,11 @@ void TouchScreenPreview::mousePressEvent(QMouseEvent* event) {
|
||||||
if (event->button() != Qt::MouseButton::LeftButton) {
|
if (event->button() != Qt::MouseButton::LeftButton) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_QT6
|
||||||
const auto pos = MapToDeviceCoords(event->position().x(), event->position().y());
|
const auto pos = MapToDeviceCoords(event->position().x(), event->position().y());
|
||||||
|
#else
|
||||||
|
const auto pos = MapToDeviceCoords(event->x(), event->y());
|
||||||
|
#endif
|
||||||
if (pos) {
|
if (pos) {
|
||||||
emit DotAdded(*pos);
|
emit DotAdded(*pos);
|
||||||
}
|
}
|
||||||
|
@ -539,7 +547,11 @@ bool TouchScreenPreview::eventFilter(QObject* obj, QEvent* event) {
|
||||||
emit DotSelected(obj->property(PropId).toInt());
|
emit DotSelected(obj->property(PropId).toInt());
|
||||||
|
|
||||||
drag_state.dot = qobject_cast<QLabel*>(obj);
|
drag_state.dot = qobject_cast<QLabel*>(obj);
|
||||||
|
#ifdef ENABLE_QT6
|
||||||
drag_state.start_pos = mouse_event->globalPosition().toPoint();
|
drag_state.start_pos = mouse_event->globalPosition().toPoint();
|
||||||
|
#else
|
||||||
|
drag_state.start_pos = mouse_event->globalPos();
|
||||||
|
#endif
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case QEvent::Type::MouseMove: {
|
case QEvent::Type::MouseMove: {
|
||||||
|
@ -548,13 +560,22 @@ bool TouchScreenPreview::eventFilter(QObject* obj, QEvent* event) {
|
||||||
}
|
}
|
||||||
const auto mouse_event = static_cast<QMouseEvent*>(event);
|
const auto mouse_event = static_cast<QMouseEvent*>(event);
|
||||||
if (!drag_state.active) {
|
if (!drag_state.active) {
|
||||||
|
#ifdef ENABLE_QT6
|
||||||
drag_state.active = (mouse_event->globalPosition().toPoint() - drag_state.start_pos)
|
drag_state.active = (mouse_event->globalPosition().toPoint() - drag_state.start_pos)
|
||||||
.manhattanLength() >= QApplication::startDragDistance();
|
.manhattanLength() >= QApplication::startDragDistance();
|
||||||
|
#else
|
||||||
|
drag_state.active = (mouse_event->globalPos() - drag_state.start_pos)
|
||||||
|
.manhattanLength() >= QApplication::startDragDistance();
|
||||||
|
#endif
|
||||||
if (!drag_state.active) {
|
if (!drag_state.active) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef ENABLE_QT6
|
||||||
auto current_pos = mapFromGlobal(mouse_event->globalPosition().toPoint());
|
auto current_pos = mapFromGlobal(mouse_event->globalPosition().toPoint());
|
||||||
|
#else
|
||||||
|
auto current_pos = mapFromGlobal(mouse_event->globalPos());
|
||||||
|
#endif
|
||||||
current_pos.setX(std::clamp(current_pos.x(), contentsMargins().left(),
|
current_pos.setX(std::clamp(current_pos.x(), contentsMargins().left(),
|
||||||
contentsMargins().left() + contentsRect().width() - 1));
|
contentsMargins().left() + contentsRect().width() - 1));
|
||||||
current_pos.setY(std::clamp(current_pos.y(), contentsMargins().top(),
|
current_pos.setY(std::clamp(current_pos.y(), contentsMargins().top(),
|
||||||
|
|
|
@ -256,8 +256,13 @@ void ConfigureUi::InitializeLanguageComboBox() {
|
||||||
locale.truncate(locale.lastIndexOf(QLatin1Char{'.'}));
|
locale.truncate(locale.lastIndexOf(QLatin1Char{'.'}));
|
||||||
locale.remove(0, locale.lastIndexOf(QLatin1Char{'/'}) + 1);
|
locale.remove(0, locale.lastIndexOf(QLatin1Char{'/'}) + 1);
|
||||||
const QString lang = QLocale::languageToString(QLocale(locale).language());
|
const QString lang = QLocale::languageToString(QLocale(locale).language());
|
||||||
|
#ifdef ENABLE_QT6
|
||||||
const QString territory = QLocale::territoryToString(QLocale(locale).territory());
|
const QString territory = QLocale::territoryToString(QLocale(locale).territory());
|
||||||
ui->language_combobox->addItem(QStringLiteral("%1 (%2)").arg(lang, territory), locale);
|
ui->language_combobox->addItem(QStringLiteral("%1 (%2)").arg(lang, territory), locale);
|
||||||
|
#else
|
||||||
|
const QString country = QLocale::countryToString(QLocale(locale).country());
|
||||||
|
ui->language_combobox->addItem(QStringLiteral("%1 (%2)").arg(lang, country), locale);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unlike other configuration changes, interface language changes need to be reflected on the
|
// Unlike other configuration changes, interface language changes need to be reflected on the
|
||||||
|
|
Loading…
Reference in New Issue