citra-emu
/
citra-canary
Archived
1
0
Fork 0

Port yuzu commit: "yuzu/CMakeLists: Disable implicit QString co… (#5074)

* yuzu/CMakeLists: Disable implicit QString conversions

Now that all of our code is compilable with implicit QString
conversions, we can enforce it at compile-time by disabling them.

Co-Authored-By: Mat M. <lioncash@users.noreply.github.com>

* citra_qt: Remove lots of implicit QString conversions

Co-authored-by: Mat M. <mathew1800@gmail.com>
This commit is contained in:
Tobias 2020-02-11 13:12:09 +01:00 committed by GitHub
parent b53b4bfb17
commit f106e76132
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 55 additions and 41 deletions

View File

@ -244,6 +244,10 @@ target_compile_definitions(citra-qt PRIVATE
# Disable implicit QString->QUrl conversions to enforce use of proper resolving functions. # Disable implicit QString->QUrl conversions to enforce use of proper resolving functions.
-DQT_NO_URL_CAST_FROM_STRING -DQT_NO_URL_CAST_FROM_STRING
# Disable implicit conversions from/to C strings
-DQT_NO_CAST_FROM_ASCII
-DQT_NO_CAST_TO_ASCII
) )
if (CITRA_ENABLE_COMPATIBILITY_REPORTING) if (CITRA_ENABLE_COMPATIBILITY_REPORTING)

View File

@ -190,7 +190,9 @@ GRenderWindow::GRenderWindow(QWidget* parent_, EmuThread* emu_thread)
: QWidget(parent_), emu_thread(emu_thread) { : QWidget(parent_), emu_thread(emu_thread) {
setWindowTitle(QStringLiteral("Citra %1 | %2-%3") setWindowTitle(QStringLiteral("Citra %1 | %2-%3")
.arg(Common::g_build_name, Common::g_scm_branch, Common::g_scm_desc)); .arg(QString::fromUtf8(Common::g_build_name),
QString::fromUtf8(Common::g_scm_branch),
QString::fromUtf8(Common::g_scm_desc)));
setAttribute(Qt::WA_AcceptTouchEvents); setAttribute(Qt::WA_AcceptTouchEvents);
auto layout = new QHBoxLayout(this); auto layout = new QHBoxLayout(this);
layout->setMargin(0); layout->setMargin(0);

View File

@ -36,14 +36,16 @@ const std::string StillImageCameraFactory::GetFilePath() const {
return last_path; return last_path;
} }
QList<QByteArray> types = QImageReader::supportedImageFormats(); QList<QByteArray> types = QImageReader::supportedImageFormats();
QList<QString> temp_filters; QStringList temp_filters;
for (QByteArray type : types) { for (QByteArray type : types) {
temp_filters << QString("*." + QString(type)); temp_filters << QStringLiteral("*.%1").arg(QString::fromUtf8(type));
} }
QString filter = QObject::tr("Supported image files (%1)").arg(temp_filters.join(" ")); QString filter =
QObject::tr("Supported image files (%1)").arg(temp_filters.join(QLatin1Char{' '}));
last_path = last_path =
QFileDialog::getOpenFileName(nullptr, QObject::tr("Open File"), ".", filter).toStdString(); QFileDialog::getOpenFileName(nullptr, QObject::tr("Open File"), QStringLiteral("."), filter)
.toStdString();
return last_path; return last_path;
} }

View File

@ -54,7 +54,7 @@ void CheatDialog::LoadCheats() {
for (size_t i = 0; i < cheats.size(); i++) { for (size_t i = 0; i < cheats.size(); i++) {
QCheckBox* enabled = new QCheckBox(); QCheckBox* enabled = new QCheckBox();
enabled->setChecked(cheats[i]->IsEnabled()); enabled->setChecked(cheats[i]->IsEnabled());
enabled->setStyleSheet("margin-left:7px;"); enabled->setStyleSheet(QStringLiteral("margin-left:7px;"));
ui->tableCheats->setItem(i, 0, new QTableWidgetItem()); ui->tableCheats->setItem(i, 0, new QTableWidgetItem());
ui->tableCheats->setCellWidget(i, 0, enabled); ui->tableCheats->setCellWidget(i, 0, enabled);
ui->tableCheats->setItem( ui->tableCheats->setItem(
@ -90,7 +90,7 @@ bool CheatDialog::SaveCheat(int row) {
} }
// Check if the cheat lines are valid // Check if the cheat lines are valid
auto code_lines = ui->textCode->toPlainText().split("\n", QString::SkipEmptyParts); auto code_lines = ui->textCode->toPlainText().split(QLatin1Char{'\n'}, QString::SkipEmptyParts);
for (int i = 0; i < code_lines.size(); ++i) { for (int i = 0; i < code_lines.size(); ++i) {
Cheats::GatewayCheat::CheatLine cheat_line(code_lines[i].toStdString()); Cheats::GatewayCheat::CheatLine cheat_line(code_lines[i].toStdString());
if (cheat_line.valid) if (cheat_line.valid)
@ -195,9 +195,9 @@ void CheatDialog::OnDeleteCheat() {
LoadCheats(); LoadCheats();
if (cheats.empty()) { if (cheats.empty()) {
ui->lineName->setText(""); ui->lineName->clear();
ui->textCode->setPlainText(""); ui->textCode->clear();
ui->textNotes->setPlainText(""); ui->textNotes->clear();
ui->lineName->setEnabled(false); ui->lineName->setEnabled(false);
ui->textCode->setEnabled(false); ui->textCode->setEnabled(false);
ui->textNotes->setEnabled(false); ui->textNotes->setEnabled(false);
@ -231,11 +231,11 @@ void CheatDialog::OnAddCheat() {
// create a dummy item // create a dummy item
ui->tableCheats->setItem(row, 1, new QTableWidgetItem(tr("[new cheat]"))); ui->tableCheats->setItem(row, 1, new QTableWidgetItem(tr("[new cheat]")));
ui->tableCheats->setItem(row, 2, new QTableWidgetItem("")); ui->tableCheats->setItem(row, 2, new QTableWidgetItem(QString{}));
ui->lineName->setText(""); ui->lineName->clear();
ui->lineName->setPlaceholderText(tr("[new cheat]")); ui->lineName->setPlaceholderText(tr("[new cheat]"));
ui->textCode->setPlainText(""); ui->textCode->clear();
ui->textNotes->setPlainText(""); ui->textNotes->clear();
ui->lineName->setEnabled(true); ui->lineName->setEnabled(true);
ui->textCode->setEnabled(true); ui->textCode->setEnabled(true);
ui->textNotes->setEnabled(true); ui->textNotes->setEnabled(true);

View File

@ -116,7 +116,8 @@ void Config::ReadAudioValues() {
Settings::values.mic_input_type = static_cast<Settings::MicInputType>( Settings::values.mic_input_type = static_cast<Settings::MicInputType>(
ReadSetting(QStringLiteral("mic_input_type"), 0).toInt()); ReadSetting(QStringLiteral("mic_input_type"), 0).toInt());
Settings::values.mic_input_device = Settings::values.mic_input_device =
ReadSetting(QStringLiteral("mic_input_device"), Frontend::Mic::default_device_name) ReadSetting(QStringLiteral("mic_input_device"),
QString::fromUtf8(Frontend::Mic::default_device_name))
.toString() .toString()
.toStdString(); .toStdString();
@ -635,7 +636,7 @@ void Config::SaveAudioValues() {
WriteSetting(QStringLiteral("volume"), Settings::values.volume, 1.0f); WriteSetting(QStringLiteral("volume"), Settings::values.volume, 1.0f);
WriteSetting(QStringLiteral("mic_input_device"), WriteSetting(QStringLiteral("mic_input_device"),
QString::fromStdString(Settings::values.mic_input_device), QString::fromStdString(Settings::values.mic_input_device),
Frontend::Mic::default_device_name); QString::fromUtf8(Frontend::Mic::default_device_name));
WriteSetting(QStringLiteral("mic_input_type"), WriteSetting(QStringLiteral("mic_input_type"),
static_cast<int>(Settings::values.mic_input_type), 0); static_cast<int>(Settings::values.mic_input_type), 0);
@ -1006,7 +1007,7 @@ QVariant Config::ReadSetting(const QString& name) const {
QVariant Config::ReadSetting(const QString& name, const QVariant& default_value) const { QVariant Config::ReadSetting(const QString& name, const QVariant& default_value) const {
QVariant result; QVariant result;
if (qt_config->value(name + "/default", false).toBool()) { if (qt_config->value(name + QStringLiteral("/default"), false).toBool()) {
result = default_value; result = default_value;
} else { } else {
result = qt_config->value(name, default_value); result = qt_config->value(name, default_value);
@ -1020,7 +1021,7 @@ void Config::WriteSetting(const QString& name, const QVariant& value) {
void Config::WriteSetting(const QString& name, const QVariant& value, void Config::WriteSetting(const QString& name, const QVariant& value,
const QVariant& default_value) { const QVariant& default_value) {
qt_config->setValue(name + "/default", value == default_value); qt_config->setValue(name + QStringLiteral("/default"), value == default_value);
qt_config->setValue(name, value); qt_config->setValue(name, value);
} }

View File

@ -183,8 +183,9 @@ void ConfigureCamera::StartPreviewing() {
ui->preview_button->setHidden(true); ui->preview_button->setHidden(true);
preview_width = ui->preview_box->size().width(); preview_width = ui->preview_box->size().width();
preview_height = preview_width * 0.75; preview_height = preview_width * 0.75;
ui->preview_box->setToolTip(tr("Resolution: ") + QString::number(preview_width) + "*" + ui->preview_box->setToolTip(
QString::number(preview_height)); tr("Resolution: %1*%2")
.arg(QString::number(preview_width), QString::number(preview_height)));
// Load previewing camera // Load previewing camera
previewing_camera = Camera::CreateCameraPreview( previewing_camera = Camera::CreateCameraPreview(
camera_name[camera_selection], camera_config[camera_selection], preview_width, camera_name[camera_selection], camera_config[camera_selection], preview_width,
@ -270,7 +271,7 @@ void ConfigureCamera::OnToolButtonClicked() {
QList<QByteArray> types = QImageReader::supportedImageFormats(); QList<QByteArray> types = QImageReader::supportedImageFormats();
QList<QString> temp_filters; QList<QString> temp_filters;
for (const QByteArray& type : types) { for (const QByteArray& type : types) {
temp_filters << QString("*." + QString::fromUtf8(type)); temp_filters << QStringLiteral("*.%1").arg(QString::fromUtf8(type));
} }
QString filter = tr("Supported image files (%1)").arg(temp_filters.join(QStringLiteral(" "))); QString filter = tr("Supported image files (%1)").arg(temp_filters.join(QStringLiteral(" ")));
QString path = QFileDialog::getOpenFileName(this, tr("Open File"), QStringLiteral("."), filter); QString path = QFileDialog::getOpenFileName(this, tr("Open File"), QStringLiteral("."), filter);

View File

@ -72,11 +72,11 @@ void ConfigureEnhancements::updateShaders(Settings::StereoRenderOption stereo_op
ui->shader_combobox->clear(); ui->shader_combobox->clear();
if (stereo_option == Settings::StereoRenderOption::Anaglyph) if (stereo_option == Settings::StereoRenderOption::Anaglyph)
ui->shader_combobox->addItem("dubois (builtin)"); ui->shader_combobox->addItem(QStringLiteral("dubois (builtin)"));
else if (stereo_option == Settings::StereoRenderOption::Interlaced) else if (stereo_option == Settings::StereoRenderOption::Interlaced)
ui->shader_combobox->addItem("horizontal (builtin)"); ui->shader_combobox->addItem(QStringLiteral("horizontal (builtin)"));
else else
ui->shader_combobox->addItem("none (builtin)"); ui->shader_combobox->addItem(QStringLiteral("none (builtin)"));
ui->shader_combobox->setCurrentIndex(0); ui->shader_combobox->setCurrentIndex(0);

View File

@ -178,7 +178,7 @@ QString WaitTreeThread::GetText() const {
QString pc_info = tr(" PC = 0x%1 LR = 0x%2") QString pc_info = tr(" PC = 0x%1 LR = 0x%2")
.arg(thread.context->GetProgramCounter(), 8, 16, QLatin1Char('0')) .arg(thread.context->GetProgramCounter(), 8, 16, QLatin1Char('0'))
.arg(thread.context->GetLinkRegister(), 8, 16, QLatin1Char('0')); .arg(thread.context->GetLinkRegister(), 8, 16, QLatin1Char('0'));
return WaitTreeWaitObject::GetText() + pc_info + " (" + status + ") "; return QStringLiteral("%1%2 (%3) ").arg(WaitTreeWaitObject::GetText(), pc_info, status);
} }
QColor WaitTreeThread::GetColor() const { QColor WaitTreeThread::GetColor() const {

View File

@ -120,14 +120,15 @@ void GameListWorker::run() {
if (game_dir.path == QStringLiteral("INSTALLED")) { if (game_dir.path == QStringLiteral("INSTALLED")) {
QString games_path = QString games_path =
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)) + QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)) +
"Nintendo " QStringLiteral("Nintendo "
"3DS/00000000000000000000000000000000/" "3DS/00000000000000000000000000000000/"
"00000000000000000000000000000000/title/00040000"; "00000000000000000000000000000000/title/00040000");
QString demos_path = QString demos_path =
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)) + QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir)) +
"Nintendo " QStringLiteral(
"3DS/00000000000000000000000000000000/00000000000000000000000000000000/title/" "Nintendo "
"00040002"; "3DS/00000000000000000000000000000000/00000000000000000000000000000000/title/"
"00040002");
watch_list.append(games_path); watch_list.append(games_path);
watch_list.append(demos_path); watch_list.append(demos_path);
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::InstalledDir); auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::InstalledDir);
@ -137,7 +138,7 @@ void GameListWorker::run() {
} else if (game_dir.path == QStringLiteral("SYSTEM")) { } else if (game_dir.path == QStringLiteral("SYSTEM")) {
QString path = QString path =
QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)) + QString::fromStdString(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir)) +
"00000000000000000000000000000000/title/00040010"; QStringLiteral("00000000000000000000000000000000/title/00040010");
watch_list.append(path); watch_list.append(path);
auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SystemDir); auto* const game_list_dir = new GameListDir(game_dir, GameListItemType::SystemDir);
emit DirEntryReady(game_list_dir); emit DirEntryReady(game_list_dir);

View File

@ -134,7 +134,7 @@ void LoadingScreen::Prepare(Loader::AppLoader& loader) {
} }
std::string title; std::string title;
if (loader.ReadTitle(title) == Loader::ResultStatus::Success) { if (loader.ReadTitle(title) == Loader::ResultStatus::Success) {
ui->title->setText(QString("Now Loading\n") + QString::fromStdString(title)); ui->title->setText(tr("Now Loading\n%1").arg(QString::fromStdString(title)));
} }
eta_shown = false; eta_shown = false;
OnLoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0); OnLoadProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0);
@ -150,7 +150,7 @@ void LoadingScreen::OnLoadProgress(VideoCore::LoadCallbackStage stage, std::size
const auto now = high_resolution_clock::now(); const auto now = high_resolution_clock::now();
// reset the timer if the stage changes // reset the timer if the stage changes
if (stage != previous_stage) { if (stage != previous_stage) {
ui->progress_bar->setStyleSheet(progressbar_style.at(stage)); ui->progress_bar->setStyleSheet(QString::fromUtf8(progressbar_style.at(stage)));
// Hide the progress bar during the prepare stage // Hide the progress bar during the prepare stage
if (stage == VideoCore::LoadCallbackStage::Prepare) { if (stage == VideoCore::LoadCallbackStage::Prepare) {
ui->progress_bar->hide(); ui->progress_bar->hide();

View File

@ -637,7 +637,10 @@ void GMainWindow::ConnectMenuEvents() {
->key()); ->key());
ui.action_Screen_Layout_Swap_Screens->setShortcutContext(Qt::WidgetWithChildrenShortcut); ui.action_Screen_Layout_Swap_Screens->setShortcutContext(Qt::WidgetWithChildrenShortcut);
ui.action_Screen_Layout_Upright_Screens->setShortcut( ui.action_Screen_Layout_Upright_Screens->setShortcut(
hotkey_registry.GetHotkey("Main Window", "Rotate Screens Upright", this)->key()); hotkey_registry
.GetHotkey(QStringLiteral("Main Window"), QStringLiteral("Rotate Screens Upright"),
this)
->key());
ui.action_Screen_Layout_Upright_Screens->setShortcutContext(Qt::WidgetWithChildrenShortcut); ui.action_Screen_Layout_Upright_Screens->setShortcutContext(Qt::WidgetWithChildrenShortcut);
connect(ui.action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen); connect(ui.action_Fullscreen, &QAction::triggered, this, &GMainWindow::ToggleFullscreen);
connect(ui.action_Screen_Layout_Default, &QAction::triggered, this, connect(ui.action_Screen_Layout_Default, &QAction::triggered, this,
@ -1169,7 +1172,7 @@ void GMainWindow::OnGameListNavigateToGamedbEntry(u64 program_id,
if (it != compatibility_list.end()) if (it != compatibility_list.end())
directory = it->second.second; directory = it->second.second;
QDesktopServices::openUrl(QUrl("https://citra-emu.org/game/" + directory)); QDesktopServices::openUrl(QUrl(QStringLiteral("https://citra-emu.org/game/") + directory));
} }
void GMainWindow::OnGameListOpenDirectory(const QString& directory) { void GMainWindow::OnGameListOpenDirectory(const QString& directory) {
@ -1232,7 +1235,7 @@ void GMainWindow::OnMenuLoadFile() {
void GMainWindow::OnMenuInstallCIA() { void GMainWindow::OnMenuInstallCIA() {
QStringList filepaths = QFileDialog::getOpenFileNames( QStringList filepaths = QFileDialog::getOpenFileNames(
this, tr("Load Files"), UISettings::values.roms_path, this, tr("Load Files"), UISettings::values.roms_path,
tr("3DS Installation File (*.CIA*)") + ";;" + tr("All Files (*.*)")); tr("3DS Installation File (*.CIA*)") + QStringLiteral(";;") + tr("All Files (*.*)"));
if (filepaths.isEmpty()) if (filepaths.isEmpty())
return; return;

View File

@ -8,7 +8,7 @@
#include "citra_qt/util/util.h" #include "citra_qt/util/util.h"
QFont GetMonospaceFont() { QFont GetMonospaceFont() {
QFont font("monospace"); QFont font(QStringLiteral("monospace"));
// Automatic fallback to a monospace font on on platforms without a font called "monospace" // Automatic fallback to a monospace font on on platforms without a font called "monospace"
font.setStyleHint(QFont::Monospace); font.setStyleHint(QFont::Monospace);
font.setFixedPitch(true); font.setFixedPitch(true);
@ -18,12 +18,12 @@ QFont GetMonospaceFont() {
QString ReadableByteSize(qulonglong size) { QString ReadableByteSize(qulonglong size) {
static const std::array<const char*, 6> units = {"B", "KiB", "MiB", "GiB", "TiB", "PiB"}; static const std::array<const char*, 6> units = {"B", "KiB", "MiB", "GiB", "TiB", "PiB"};
if (size == 0) if (size == 0)
return "0"; return QStringLiteral("0");
int digit_groups = std::min<int>(static_cast<int>(std::log10(size) / std::log10(1024)), int digit_groups = std::min<int>(static_cast<int>(std::log10(size) / std::log10(1024)),
static_cast<int>(units.size())); static_cast<int>(units.size()));
return QString("%L1 %2") return QStringLiteral("%L1 %2")
.arg(size / std::pow(1024, digit_groups), 0, 'f', 1) .arg(size / std::pow(1024, digit_groups), 0, 'f', 1)
.arg(units[digit_groups]); .arg(QString::fromUtf8(units[digit_groups]));
} }
QPixmap CreateCirclePixmapFromColor(const QColor& color) { QPixmap CreateCirclePixmapFromColor(const QColor& color) {