Merge pull request #5479 from lemondrops/ui-2
More UI fixes (part 1 - code)
This commit is contained in:
@@ -160,6 +160,7 @@ int window_remember;
|
||||
int vid_resize; /* (C) allow resizing */
|
||||
int invert_display = 0; /* (C) invert the display */
|
||||
int suppress_overscan = 0; /* (C) suppress overscans */
|
||||
int lang_id = 0; /* (C) language id */
|
||||
int scale = 0; /* (C) screen scale factor */
|
||||
int dpi_scale = 0; /* (C) DPI scaling of the emulated
|
||||
screen */
|
||||
@@ -584,7 +585,7 @@ pc_init(int argc, char *argv[])
|
||||
uint32_t *uid;
|
||||
uint32_t *shwnd;
|
||||
#endif
|
||||
uint32_t lang_init = 0;
|
||||
int lang_init = 0;
|
||||
|
||||
/* Grab the executable's full path. */
|
||||
plat_get_exe_name(exe_path, sizeof(exe_path) - 1);
|
||||
|
||||
@@ -29,6 +29,9 @@
|
||||
#include <86box/cdrom.h>
|
||||
#include <86box/cdrom_image.h>
|
||||
#include <86box/cdrom_interface.h>
|
||||
#ifdef USE_CDROM_MITSUMI
|
||||
#include <86box/cdrom_mitsumi.h>
|
||||
#endif
|
||||
#include <86box/log.h>
|
||||
#include <86box/plat.h>
|
||||
#include <86box/plat_cdrom_ioctl.h>
|
||||
@@ -117,6 +120,9 @@ static const struct {
|
||||
} controllers[] = {
|
||||
// clang-format off
|
||||
{ &cdrom_interface_none_device },
|
||||
#ifdef USE_CDROM_MITSUMI
|
||||
{ &mitsumi_cdrom_device },
|
||||
#endif
|
||||
{ NULL }
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
@@ -186,7 +186,7 @@ load_general(void)
|
||||
if (p != NULL)
|
||||
lang_id = plat_language_code(p);
|
||||
else
|
||||
lang_id = 0xffff;
|
||||
lang_id = plat_language_code(DEFAULT_LANGUAGE);
|
||||
|
||||
mouse_sensitivity = ini_section_get_double(cat, "mouse_sensitivity", 1.0);
|
||||
if (mouse_sensitivity < 0.1)
|
||||
@@ -1842,7 +1842,7 @@ config_load(void)
|
||||
cassette_pcm = 0;
|
||||
cassette_ui_writeprot = 0;
|
||||
|
||||
lang_id = DEFAULT_LANGUAGE;
|
||||
lang_id = plat_language_code(DEFAULT_LANGUAGE);
|
||||
|
||||
config_log("Config file not present or invalid!\n");
|
||||
} else {
|
||||
@@ -2029,7 +2029,7 @@ save_general(void)
|
||||
else
|
||||
ini_section_delete_var(cat, "mouse_sensitivity");
|
||||
|
||||
if (lang_id == DEFAULT_LANGUAGE)
|
||||
if (lang_id == plat_language_code(DEFAULT_LANGUAGE))
|
||||
ini_section_delete_var(cat, "language");
|
||||
else {
|
||||
plat_language_code_r(lang_id, buffer, 511);
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
/* Max UUID Length */
|
||||
#define MAX_UUID_LEN 64
|
||||
|
||||
/* Default language 0xFFFF = from system, 0x409 = en-US */
|
||||
#define DEFAULT_LANGUAGE 0xffff
|
||||
/* Default language code */
|
||||
#define DEFAULT_LANGUAGE "system"
|
||||
|
||||
#define POSTCARDS_NUM 4
|
||||
#define POSTCARD_MASK (POSTCARDS_NUM - 1)
|
||||
@@ -84,8 +84,6 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Global variables. */
|
||||
extern uint32_t lang_sys; /* (-) system language code */
|
||||
|
||||
extern int dump_on_exit; /* (O) dump regs on exit*/
|
||||
extern int start_in_fullscreen; /* (O) start in fullscreen */
|
||||
#ifdef _WIN32
|
||||
@@ -117,7 +115,7 @@ extern int window_remember;
|
||||
extern int vid_resize; /* (C) allow resizing */
|
||||
extern int invert_display; /* (C) invert the display */
|
||||
extern int suppress_overscan; /* (C) suppress overscans */
|
||||
extern uint32_t lang_id; /* (C) language code identifier */
|
||||
extern int lang_id; /* (C) language id */
|
||||
extern int scale; /* (C) screen scale factor */
|
||||
extern int dpi_scale; /* (C) DPI scaling of the emulated screen */
|
||||
extern int vid_api; /* (C) video renderer */
|
||||
|
||||
@@ -160,8 +160,8 @@ extern int plat_vidapi(const char *name);
|
||||
extern char *plat_vidapi_name(int api);
|
||||
extern void plat_resize(int x, int y, int monitor_index);
|
||||
extern void plat_resize_request(int x, int y, int monitor_index);
|
||||
extern uint32_t plat_language_code(char *langcode);
|
||||
extern void plat_language_code_r(uint32_t lcid, char *outbuf, int len);
|
||||
extern int plat_language_code(char *langcode);
|
||||
extern void plat_language_code_r(int id, char *outbuf, int len);
|
||||
extern void plat_get_cpu_string(char *outbuf, uint8_t len);
|
||||
extern void plat_set_thread_name(void *thread, const char *name);
|
||||
extern void plat_break(void);
|
||||
|
||||
@@ -501,7 +501,7 @@ network_attach(void *card_drv, uint8_t *mac, NETRXCB rx, NETSETLINKSTATE set_lin
|
||||
|
||||
if(net_cards_conf[net_card_current].net_type != NET_TYPE_NONE) {
|
||||
// We're here because of a failure
|
||||
swprintf(tempmsg, sizeof_w(tempmsg), L"%ls:<br /><br />%s<br /><br />%ls", plat_get_string(STRING_NET_ERROR), net_drv_error, plat_get_string(STRING_NET_ERROR_DESC));
|
||||
swprintf(tempmsg, sizeof_w(tempmsg), L"%ls:\n\n%s\n\n%ls", plat_get_string(STRING_NET_ERROR), net_drv_error, plat_get_string(STRING_NET_ERROR_DESC));
|
||||
ui_msgbox(MBX_ERROR, tempmsg);
|
||||
net_cards_conf[net_card_current].net_type = NET_TYPE_NONE;
|
||||
}
|
||||
|
||||
@@ -207,6 +207,10 @@ if(WACOM)
|
||||
target_compile_definitions(ui PRIVATE USE_WACOM)
|
||||
endif()
|
||||
|
||||
if(CDROM_MITSUMI)
|
||||
target_compile_definitions(ui PRIVATE USE_CDROM_MITSUMI)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
enable_language(RC)
|
||||
target_sources(86Box PUBLIC 86Box-qt.rc)
|
||||
|
||||
@@ -51,7 +51,7 @@ void
|
||||
Harddrives::populateRemovableBuses(QAbstractItemModel *model)
|
||||
{
|
||||
model->removeRows(0, model->rowCount());
|
||||
#if 0
|
||||
#ifdef USE_CDROM_MITSUMI
|
||||
model->insertRows(0, 4);
|
||||
#else
|
||||
model->insertRows(0, 3);
|
||||
@@ -59,14 +59,14 @@ Harddrives::populateRemovableBuses(QAbstractItemModel *model)
|
||||
model->setData(model->index(0, 0), QObject::tr("Disabled"));
|
||||
model->setData(model->index(1, 0), QObject::tr("ATAPI"));
|
||||
model->setData(model->index(2, 0), QObject::tr("SCSI"));
|
||||
#if 0
|
||||
#ifdef USE_CDROM_MITSUMI
|
||||
model->setData(model->index(3, 0), QObject::tr("Mitsumi"));
|
||||
#endif
|
||||
|
||||
model->setData(model->index(0, 0), HDD_BUS_DISABLED, Qt::UserRole);
|
||||
model->setData(model->index(1, 0), HDD_BUS_ATAPI, Qt::UserRole);
|
||||
model->setData(model->index(2, 0), HDD_BUS_SCSI, Qt::UserRole);
|
||||
#if 0
|
||||
#ifdef USE_CDROM_MITSUMI
|
||||
model->setData(model->index(3, 0), CDROM_BUS_MITSUMI, Qt::UserRole);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1342,17 +1342,17 @@ MainWindow::refreshMediaMenu()
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::showMessage(int flags, const QString &header, const QString &message)
|
||||
MainWindow::showMessage(int flags, const QString &header, const QString &message, bool richText)
|
||||
{
|
||||
if (QThread::currentThread() == this->thread()) {
|
||||
if (!cpu_thread_running) {
|
||||
showMessageForNonQtThread(flags, header, message, nullptr);
|
||||
showMessageForNonQtThread(flags, header, message, richText, nullptr);
|
||||
}
|
||||
else
|
||||
showMessage_(flags, header, message);
|
||||
showMessage_(flags, header, message, richText);
|
||||
} else {
|
||||
std::atomic_bool done = false;
|
||||
emit showMessageForNonQtThread(flags, header, message, &done);
|
||||
emit showMessageForNonQtThread(flags, header, message, richText, &done);
|
||||
while (!done) {
|
||||
QThread::msleep(1);
|
||||
}
|
||||
@@ -1360,7 +1360,7 @@ MainWindow::showMessage(int flags, const QString &header, const QString &message
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::showMessage_(int flags, const QString &header, const QString &message, std::atomic_bool *done)
|
||||
MainWindow::showMessage_(int flags, const QString &header, const QString &message, bool richText, std::atomic_bool *done)
|
||||
{
|
||||
if (done) {
|
||||
*done = false;
|
||||
@@ -1372,7 +1372,8 @@ MainWindow::showMessage_(int flags, const QString &header, const QString &messag
|
||||
} else if (!(flags & (MBX_ERROR | MBX_WARNING))) {
|
||||
box.setIcon(QMessageBox::Warning);
|
||||
}
|
||||
box.setTextFormat(Qt::TextFormat::RichText);
|
||||
if (richText)
|
||||
box.setTextFormat(Qt::TextFormat::RichText);
|
||||
box.exec();
|
||||
if (done) {
|
||||
*done = true;
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
void showMessage(int flags, const QString &header, const QString &message);
|
||||
void showMessage(int flags, const QString &header, const QString &message, bool richText);
|
||||
void getTitle(wchar_t *title);
|
||||
void blitToWidget(int x, int y, int w, int h, int monitor_index);
|
||||
QSize getRenderWidgetSize();
|
||||
@@ -55,7 +55,7 @@ signals:
|
||||
void setFullscreen(bool state);
|
||||
void setMouseCapture(bool state);
|
||||
|
||||
void showMessageForNonQtThread(int flags, const QString &header, const QString &message, std::atomic_bool* done);
|
||||
void showMessageForNonQtThread(int flags, const QString &header, const QString &message, bool richText, std::atomic_bool* done);
|
||||
void getTitleForNonQtThread(wchar_t *title);
|
||||
public slots:
|
||||
void showSettings();
|
||||
@@ -123,7 +123,7 @@ private slots:
|
||||
void on_actionRenderer_options_triggered();
|
||||
|
||||
void refreshMediaMenu();
|
||||
void showMessage_(int flags, const QString &header, const QString &message, std::atomic_bool* done = nullptr);
|
||||
void showMessage_(int flags, const QString &header, const QString &message, bool richText, std::atomic_bool* done = nullptr);
|
||||
void getTitle_(wchar_t *title);
|
||||
|
||||
void on_actionMCA_devices_triggered();
|
||||
|
||||
@@ -200,7 +200,7 @@ OpenGLRenderer::create_program(struct shader_program *program)
|
||||
glw.glGetProgramiv(program->id, GL_INFO_LOG_LENGTH, &maxLength);
|
||||
char *log = (char *) malloc(maxLength);
|
||||
glw.glGetProgramInfoLog(program->id, maxLength, &length, log);
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Program not linked:\n\n%1").arg(log).replace("\n", "<br>"));
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Program not linked:\n\n%1").arg(log), false);
|
||||
// wx_simple_messagebox("GLSL Error", "Program not linked:\n%s", log);
|
||||
free(log);
|
||||
return 0;
|
||||
@@ -247,7 +247,7 @@ OpenGLRenderer::compile_shader(GLenum shader_type, const char *prepend, const ch
|
||||
glw.glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &length);
|
||||
char *log = (char *) malloc(length);
|
||||
glw.glGetShaderInfoLog(shader, length, &length, log);
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Could not compile shader:\n\n%1").arg(log).replace("\n", "<br>"));
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Could not compile shader:\n\n%1").arg(log), false);
|
||||
// wx_simple_messagebox("GLSL Error", "Could not compile shader:\n%s", log);
|
||||
|
||||
ogl3_log("Could not compile shader: %s\n", log);
|
||||
@@ -651,7 +651,7 @@ OpenGLRenderer::load_glslp(glsl_t *glsl, int num_shader, const char *f)
|
||||
|
||||
if (!load_texture(file, &tex->texture)) {
|
||||
//QMessageBox::critical(main_window, tr("GLSL Error"), tr("Could not load texture: %s").arg(file));
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Could not load texture: %1").arg(file));
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Could not load texture: %1").arg(file), false);
|
||||
ogl3_log("Could not load texture %s!\n", file);
|
||||
failed = 1;
|
||||
break;
|
||||
@@ -697,7 +697,7 @@ OpenGLRenderer::load_glslp(glsl_t *glsl, int num_shader, const char *f)
|
||||
ogl3_log("Creating pass %u (%s)\n", (i + 1), pass->alias);
|
||||
ogl3_log("Loading shader %s...\n", shader->shader_fn);
|
||||
if (!shader->shader_program) {
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Could not load shader: %1").arg(shader->shader_fn));
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("GLSL Error"), tr("Could not load shader: %1").arg(shader->shader_fn), false);
|
||||
// wx_simple_messagebox("GLSL Error", "Could not load shader: %s", shader->shader_fn);
|
||||
ogl3_log("Could not load shader %s\n", shader->shader_fn);
|
||||
failed = 1;
|
||||
@@ -1115,7 +1115,7 @@ OpenGLRenderer::initialize()
|
||||
for (auto &flag : buf_usage)
|
||||
flag.test_and_set();
|
||||
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("Error initializing OpenGL"), e.what() + tr("\nFalling back to software rendering."));
|
||||
main_window->showMessage(MBX_ERROR | MBX_FATAL, tr("Error initializing OpenGL"), e.what() + tr("\nFalling back to software rendering."), false);
|
||||
|
||||
context->doneCurrent();
|
||||
isFinalized = true;
|
||||
|
||||
@@ -140,7 +140,6 @@ int update_icons = 1;
|
||||
int kbd_req_capture = 0;
|
||||
int hide_status_bar = 0;
|
||||
int hide_tool_bar = 0;
|
||||
uint32_t lang_id = 0x0409, lang_sys = 0x0409; // Multilangual UI variables, for now all set to LCID of en-US
|
||||
|
||||
int
|
||||
stricmp(const char *s1, const char *s2)
|
||||
@@ -461,58 +460,18 @@ plat_power_off(void)
|
||||
QTimer::singleShot(0, (const QWidget *) main_window, &QMainWindow::close);
|
||||
}
|
||||
|
||||
extern "C++" {
|
||||
QMap<uint32_t, QPair<QString, QString>> ProgSettings::lcid_langcode = {
|
||||
{ 0x0403, { "ca-ES", "Catalan (Spain)" } },
|
||||
{ 0x0804, { "zh-CN", "Chinese (Simplified)" } },
|
||||
{ 0x0404, { "zh-TW", "Chinese (Traditional)" } },
|
||||
{ 0x041A, { "hr-HR", "Croatian (Croatia)" } },
|
||||
{ 0x0405, { "cs-CZ", "Czech (Czech Republic)" } },
|
||||
{ 0x0407, { "de-DE", "German (Germany)" } },
|
||||
{ 0x0809, { "en-GB", "English (United Kingdom)" }},
|
||||
{ 0x0409, { "en-US", "English (United States)" } },
|
||||
{ 0x040B, { "fi-FI", "Finnish (Finland)" } },
|
||||
{ 0x040C, { "fr-FR", "French (France)" } },
|
||||
{ 0x040E, { "hu-HU", "Hungarian (Hungary)" } },
|
||||
{ 0x0410, { "it-IT", "Italian (Italy)" } },
|
||||
{ 0x0411, { "ja-JP", "Japanese (Japan)" } },
|
||||
{ 0x0412, { "ko-KR", "Korean (Korea)" } },
|
||||
{ 0x0413, { "nl-NL", "Dutch (Netherlands)" } },
|
||||
{ 0x0415, { "pl-PL", "Polish (Poland)" } },
|
||||
{ 0x0416, { "pt-BR", "Portuguese (Brazil)" } },
|
||||
{ 0x0816, { "pt-PT", "Portuguese (Portugal)" } },
|
||||
{ 0x0419, { "ru-RU", "Russian (Russia)" } },
|
||||
{ 0x041B, { "sk-SK", "Slovak (Slovakia)" } },
|
||||
{ 0x0424, { "sl-SI", "Slovenian (Slovenia)" } },
|
||||
{ 0x0C0A, { "es-ES", "Spanish (Spain, Modern Sort)" } },
|
||||
{ 0x041F, { "tr-TR", "Turkish (Turkey)" } },
|
||||
{ 0x0422, { "uk-UA", "Ukrainian (Ukraine)" } },
|
||||
{ 0x042A, { "vi-VN", "Vietnamese (Vietnam)" } },
|
||||
{ 0xFFFF, { "system", "(System Default)" } },
|
||||
};
|
||||
}
|
||||
|
||||
/* Sets up the program language before initialization. */
|
||||
uint32_t
|
||||
/* Converts the language code string to a numeric language ID */
|
||||
int
|
||||
plat_language_code(char *langcode)
|
||||
{
|
||||
for (auto &curKey : ProgSettings::lcid_langcode.keys()) {
|
||||
if (ProgSettings::lcid_langcode[curKey].first == langcode) {
|
||||
return curKey;
|
||||
}
|
||||
}
|
||||
return 0xFFFF;
|
||||
return ProgSettings::languageCodeToId(QString(langcode));
|
||||
}
|
||||
|
||||
/* Converts back the language code to LCID */
|
||||
/* Converts the numeric language ID to a language code string */
|
||||
void
|
||||
plat_language_code_r(uint32_t lcid, char *outbuf, int len)
|
||||
plat_language_code_r(int id, char *outbuf, int len)
|
||||
{
|
||||
if (!ProgSettings::lcid_langcode.contains(lcid)) {
|
||||
qstrncpy(outbuf, "system", len);
|
||||
return;
|
||||
}
|
||||
qstrncpy(outbuf, ProgSettings::lcid_langcode[lcid].first.toUtf8().constData(), len);
|
||||
qstrncpy(outbuf, ProgSettings::languageIdToCode(id).toUtf8().constData(), len);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QLibraryInfo>
|
||||
#ifdef Q_OS_WINDOWS
|
||||
# include <QSysInfo>
|
||||
# include <QVersionNumber>
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
@@ -41,18 +45,45 @@ extern MainWindow *main_window;
|
||||
ProgSettings::CustomTranslator *ProgSettings::translator = nullptr;
|
||||
QTranslator *ProgSettings::qtTranslator = nullptr;
|
||||
|
||||
QVector<QPair<QString, QString>> ProgSettings::languages = {
|
||||
{ "system", "(System Default)" },
|
||||
{ "ca-ES", "Catalan (Spain)" },
|
||||
{ "zh-CN", "Chinese (Simplified)" },
|
||||
{ "zh-TW", "Chinese (Traditional)" },
|
||||
{ "hr-HR", "Croatian (Croatia)" },
|
||||
{ "cs-CZ", "Czech (Czech Republic)" },
|
||||
{ "de-DE", "German (Germany)" },
|
||||
{ "en-GB", "English (United Kingdom)" },
|
||||
{ "en-US", "English (United States)" },
|
||||
{ "fi-FI", "Finnish (Finland)" },
|
||||
{ "fr-FR", "French (France)" },
|
||||
{ "hu-HU", "Hungarian (Hungary)" },
|
||||
{ "it-IT", "Italian (Italy)" },
|
||||
{ "ja-JP", "Japanese (Japan)" },
|
||||
{ "ko-KR", "Korean (Korea)" },
|
||||
{ "nl-NL", "Dutch (Netherlands)" },
|
||||
{ "pl-PL", "Polish (Poland)" },
|
||||
{ "pt-BR", "Portuguese (Brazil)" },
|
||||
{ "pt-PT", "Portuguese (Portugal)" },
|
||||
{ "ru-RU", "Russian (Russia)" },
|
||||
{ "sk-SK", "Slovak (Slovakia)" },
|
||||
{ "sl-SI", "Slovenian (Slovenia)" },
|
||||
{ "es-ES", "Spanish (Spain)" },
|
||||
{ "tr-TR", "Turkish (Turkey)" },
|
||||
{ "uk-UA", "Ukrainian (Ukraine)" },
|
||||
{ "vi-VN", "Vietnamese (Vietnam)" },
|
||||
};
|
||||
|
||||
ProgSettings::ProgSettings(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::ProgSettings)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->comboBoxLanguage->setItemData(0, 0xFFFF);
|
||||
for (auto i = lcid_langcode.begin(); i != lcid_langcode.end(); i++) {
|
||||
if (i.key() == 0xFFFF)
|
||||
continue;
|
||||
ui->comboBoxLanguage->addItem(lcid_langcode[i.key()].second, i.key());
|
||||
if (i.key() == lang_id) {
|
||||
ui->comboBoxLanguage->setCurrentIndex(ui->comboBoxLanguage->findData(i.key()));
|
||||
ui->comboBoxLanguage->setItemData(0, 0);
|
||||
for (int i = 1; i < languages.length(); i++) {
|
||||
ui->comboBoxLanguage->addItem(languages[i].second, i);
|
||||
if (i == lang_id) {
|
||||
ui->comboBoxLanguage->setCurrentIndex(ui->comboBoxLanguage->findData(i));
|
||||
}
|
||||
}
|
||||
ui->comboBoxLanguage->model()->sort(Qt::AscendingOrder);
|
||||
@@ -74,7 +105,7 @@ ProgSettings::ProgSettings(QWidget *parent)
|
||||
void
|
||||
ProgSettings::accept()
|
||||
{
|
||||
lang_id = ui->comboBoxLanguage->currentData().toUInt();
|
||||
lang_id = ui->comboBoxLanguage->currentData().toInt();
|
||||
open_dir_usr_path = ui->openDirUsrPath->isChecked() ? 1 : 0;
|
||||
confirm_exit = ui->checkBoxConfirmExit->isChecked() ? 1 : 0;
|
||||
confirm_save = ui->checkBoxConfirmSave->isChecked() ? 1 : 0;
|
||||
@@ -109,23 +140,46 @@ ProgSettings::~ProgSettings()
|
||||
/* Return the standard font name on Windows, which is overridden per-language
|
||||
to prevent CJK fonts with embedded bitmaps being chosen as a fallback. */
|
||||
QString
|
||||
ProgSettings::getFontName(uint32_t lcid)
|
||||
ProgSettings::getFontName(int langId)
|
||||
{
|
||||
switch (lcid) {
|
||||
case 0x0404: /* zh-TW */
|
||||
return "Microsoft JhengHei";
|
||||
case 0x0411: /* ja-JP */
|
||||
QString langCode = languageIdToCode(lang_id);
|
||||
if (langCode == "ja-JP") {
|
||||
/* Check for Windows 10 or later to choose the appropriate system font */
|
||||
if (QVersionNumber::fromString(QSysInfo::kernelVersion()).majorVersion() >= 10)
|
||||
return "Yu Gothic UI";
|
||||
else
|
||||
return "Meiryo UI";
|
||||
case 0x0412: /* ko-KR */
|
||||
return "Malgun Gothic";
|
||||
case 0x0804: /* zh-CN */
|
||||
return "Microsoft YaHei";
|
||||
default:
|
||||
return "Segoe UI";
|
||||
}
|
||||
} else if (langCode == "ko-KR")
|
||||
return "Malgun Gothic";
|
||||
else if (langCode == "zh-CN")
|
||||
return "Microsoft YaHei";
|
||||
else if (langCode == "zh-TW")
|
||||
return "Microsoft JhengHei";
|
||||
else
|
||||
return "Segoe UI";
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
ProgSettings::languageCodeToId(QString langCode)
|
||||
{
|
||||
for (int i = 0; i < languages.length(); i++) {
|
||||
if (languages[i].first == langCode) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString
|
||||
ProgSettings::languageIdToCode(int id)
|
||||
{
|
||||
if ((id == 0) || (id >= languages.length())) {
|
||||
return "system";
|
||||
}
|
||||
return languages[id].first;
|
||||
}
|
||||
|
||||
void
|
||||
ProgSettings::loadTranslators(QObject *parent)
|
||||
{
|
||||
@@ -140,7 +194,7 @@ ProgSettings::loadTranslators(QObject *parent)
|
||||
qtTranslator = new QTranslator(parent);
|
||||
translator = new CustomTranslator(parent);
|
||||
QString localetofilename = "";
|
||||
if (lang_id == 0xFFFF || lcid_langcode.contains(lang_id) == false) {
|
||||
if (lang_id == 0 || lang_id >= languages.length()) {
|
||||
for (int i = 0; i < QLocale::system().uiLanguages().size(); i++) {
|
||||
localetofilename = QLocale::system().uiLanguages()[i];
|
||||
if (translator->load(QLatin1String("86box_") + localetofilename, QLatin1String(":/"))) {
|
||||
@@ -158,12 +212,12 @@ ProgSettings::loadTranslators(QObject *parent)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
translator->load(QLatin1String("86box_") + lcid_langcode[lang_id].first, QLatin1String(":/"));
|
||||
translator->load(QLatin1String("86box_") + languages[lang_id].first, QLatin1String(":/"));
|
||||
QCoreApplication::installTranslator(translator);
|
||||
if (!qtTranslator->load(QLatin1String("qtbase_") + QString(lcid_langcode[lang_id].first).replace('-', '_'), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
||||
if (!qtTranslator->load(QLatin1String("qtbase_") + QString(lcid_langcode[lang_id].first).left(QString(lcid_langcode[lang_id].first).indexOf('-')), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
||||
if(!qtTranslator->load(QLatin1String("qt_") + QString(lcid_langcode[lang_id].first).replace('-', '_'), QApplication::applicationDirPath() + "/./translations/"))
|
||||
qtTranslator->load(QLatin1String("qt_") + QString(lcid_langcode[lang_id].first).replace('-', '_'), QLatin1String(":/"));
|
||||
if (!qtTranslator->load(QLatin1String("qtbase_") + QString(languages[lang_id].first).replace('-', '_'), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
||||
if (!qtTranslator->load(QLatin1String("qtbase_") + QString(languages[lang_id].first).left(QString(languages[lang_id].first).indexOf('-')), QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
|
||||
if(!qtTranslator->load(QLatin1String("qt_") + QString(languages[lang_id].first).replace('-', '_'), QApplication::applicationDirPath() + "/./translations/"))
|
||||
qtTranslator->load(QLatin1String("qt_") + QString(languages[lang_id].first).replace('-', '_'), QLatin1String(":/"));
|
||||
|
||||
QCoreApplication::installTranslator(qtTranslator);
|
||||
}
|
||||
|
||||
@@ -15,10 +15,12 @@ public:
|
||||
explicit ProgSettings(QWidget *parent = nullptr);
|
||||
~ProgSettings();
|
||||
#ifdef Q_OS_WINDOWS
|
||||
static QString getFontName(uint32_t lcid);
|
||||
static QString getFontName(int langId);
|
||||
#endif
|
||||
static void loadTranslators(QObject *parent = nullptr);
|
||||
static void reloadStrings();
|
||||
static int languageCodeToId(QString langCode);
|
||||
static QString languageIdToCode(int id);
|
||||
static void loadTranslators(QObject *parent = nullptr);
|
||||
static void reloadStrings();
|
||||
class CustomTranslator : public QTranslator {
|
||||
public:
|
||||
CustomTranslator(QObject *parent = nullptr)
|
||||
@@ -31,10 +33,10 @@ public:
|
||||
return QTranslator::translate("", sourceText, disambiguation, n);
|
||||
}
|
||||
};
|
||||
static CustomTranslator *translator;
|
||||
static QTranslator *qtTranslator;
|
||||
static QMap<uint32_t, QPair<QString, QString>> lcid_langcode;
|
||||
static QMap<int, std::wstring> translatedstrings;
|
||||
static CustomTranslator *translator;
|
||||
static QTranslator *qtTranslator;
|
||||
static QVector<QPair<QString, QString>> languages;
|
||||
static QMap<int, std::wstring> translatedstrings;
|
||||
|
||||
protected slots:
|
||||
void accept() override;
|
||||
|
||||
@@ -116,7 +116,7 @@ SettingsHarddisks::SettingsHarddisks(QWidget *parent)
|
||||
model->setHeaderData(ColumnHeads, Qt::Horizontal, tr("H"));
|
||||
model->setHeaderData(ColumnSectors, Qt::Horizontal, tr("S"));
|
||||
model->setHeaderData(ColumnSize, Qt::Horizontal, tr("MiB"));
|
||||
model->setHeaderData(ColumnSpeed, Qt::Horizontal, tr("Speed"));
|
||||
model->setHeaderData(ColumnSpeed, Qt::Horizontal, tr("Model"));
|
||||
ui->tableView->setModel(model);
|
||||
|
||||
for (int i = 0; i < HDD_NUM; i++) {
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Adapter</string>
|
||||
<string>Adapter:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -84,7 +84,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
<string>Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -124,14 +124,14 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Interface</string>
|
||||
<string>Interface:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="socketVDELabel1">
|
||||
<property name="text">
|
||||
<string>VDE Socket</string>
|
||||
<string>VDE Socket:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -197,7 +197,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Interface</string>
|
||||
<string>Interface:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -217,7 +217,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
<string>Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -237,7 +237,7 @@
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="socketVDELabel2">
|
||||
<property name="text">
|
||||
<string>VDE Socket</string>
|
||||
<string>VDE Socket:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -257,7 +257,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Adapter</string>
|
||||
<string>Adapter:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -326,7 +326,7 @@
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="socketVDELabel3">
|
||||
<property name="text">
|
||||
<string>VDE Socket</string>
|
||||
<string>VDE Socket:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -362,7 +362,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Interface</string>
|
||||
<string>Interface:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -382,7 +382,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
<string>Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -408,7 +408,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Adapter</string>
|
||||
<string>Adapter:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -461,7 +461,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Mode</string>
|
||||
<string>Mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -481,7 +481,7 @@
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="socketVDELabel4">
|
||||
<property name="text">
|
||||
<string>VDE Socket</string>
|
||||
<string>VDE Socket:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -494,7 +494,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Adapter</string>
|
||||
<string>Adapter:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -514,7 +514,7 @@
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Interface</string>
|
||||
<string>Interface:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -142,6 +142,15 @@ SettingsStorageControllers::onCurrentMachineChanged(int machineId)
|
||||
ui->comboBoxFD->setCurrentIndex(selectedRow);
|
||||
|
||||
/*CD interface controller config*/
|
||||
#ifdef USE_CDROM_MITSUMI
|
||||
ui->label_7->setVisible(true);
|
||||
ui->comboBoxCDInterface->setVisible(true);
|
||||
ui->pushButtonCDInterface->setVisible(true);
|
||||
#else
|
||||
ui->label_7->setVisible(false);
|
||||
ui->comboBoxCDInterface->setVisible(false);
|
||||
ui->pushButtonCDInterface->setVisible(false);
|
||||
#endif
|
||||
c = 0;
|
||||
model = ui->comboBoxCDInterface->model();
|
||||
removeRows = model->rowCount();
|
||||
|
||||
@@ -51,9 +51,6 @@
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>CD-ROM Controller:</string>
|
||||
</property>
|
||||
@@ -61,9 +58,6 @@
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="comboBoxCDInterface">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
@@ -71,9 +65,6 @@
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="pushButtonCDInterface">
|
||||
<property name="visible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Configure</string>
|
||||
</property>
|
||||
|
||||
@@ -142,11 +142,10 @@ ui_msgbox_header(int flags, void *header, void *message)
|
||||
// any error in early init
|
||||
if (main_window == nullptr) {
|
||||
QMessageBox msgBox(QMessageBox::Icon::Critical, hdr, msg);
|
||||
msgBox.setTextFormat(Qt::TextFormat::RichText);
|
||||
msgBox.exec();
|
||||
} else {
|
||||
// else scope it to main_window
|
||||
main_window->showMessage(flags, hdr, msg);
|
||||
main_window->showMessage(flags, hdr, msg, false);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -71,8 +71,6 @@ SDL_mutex *blitmtx;
|
||||
SDL_threadID eventthread;
|
||||
static int exit_event = 0;
|
||||
static int fullscreen_pending = 0;
|
||||
uint32_t lang_id = 0x0409; // Multilangual UI variables, for now all set to LCID of en-US
|
||||
uint32_t lang_sys = 0x0409; // Multilangual UI variables, for now all set to LCID of en-US
|
||||
|
||||
static const uint16_t sdl_to_xt[0x200] = {
|
||||
[SDL_SCANCODE_ESCAPE] = 0x01,
|
||||
@@ -1378,8 +1376,8 @@ plat_vidapi_name(UNUSED(int i))
|
||||
return "default";
|
||||
}
|
||||
|
||||
/* Sets up the program language before initialization. */
|
||||
uint32_t
|
||||
/* Converts the language code string to a numeric language ID */
|
||||
int
|
||||
plat_language_code(UNUSED(char *langcode))
|
||||
{
|
||||
/* or maybe not */
|
||||
@@ -1419,9 +1417,9 @@ plat_set_thread_name(void *thread, const char *name)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Converts back the language code to LCID */
|
||||
/* Converts the numeric language ID to a language code string */
|
||||
void
|
||||
plat_language_code_r(UNUSED(uint32_t lcid), UNUSED(char *outbuf), UNUSED(int len))
|
||||
plat_language_code_r(UNUSED(int id), UNUSED(char *outbuf), UNUSED(int len))
|
||||
{
|
||||
/* or maybe not */
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user