Merge pull request #5978 from lemondrops/manager-4
Add a language selection dropdown in manager preferences
This commit is contained in:
@@ -1107,6 +1107,9 @@ usage:
|
||||
pclog("# VM Manager enabled. Path: %s\n", vmm_path);
|
||||
}
|
||||
|
||||
/* Load the global configuration file. */
|
||||
config_load_global();
|
||||
|
||||
if (!vmm_enabled) {
|
||||
/*
|
||||
* We are about to read the configuration file, which MAY
|
||||
|
||||
@@ -2023,8 +2023,6 @@ config_load(void)
|
||||
int i;
|
||||
ini_section_t c;
|
||||
|
||||
config_load_global();
|
||||
|
||||
config_log("Loading VM config file '%s'...\n", cfg_path);
|
||||
|
||||
memset(hdd, 0, sizeof(hard_disk_t));
|
||||
|
||||
@@ -759,6 +759,20 @@ VMManagerMain::onPreferencesUpdated()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerMain::onLanguageUpdated()
|
||||
{
|
||||
vm_model->refreshConfigs();
|
||||
/* Hack to work around details widgets not being re-translatable
|
||||
without going through layers of abstraction */
|
||||
ui->detailsArea->layout()->removeWidget(vm_details);
|
||||
delete vm_details;
|
||||
vm_details = new VMManagerDetails();
|
||||
ui->detailsArea->layout()->addWidget(vm_details);
|
||||
if (vm_model->rowCount(QModelIndex()) > 0)
|
||||
vm_details->updateData(selected_sysconfig);
|
||||
}
|
||||
|
||||
int
|
||||
VMManagerMain::getActiveMachineCount()
|
||||
{
|
||||
|
||||
@@ -79,6 +79,7 @@ public slots:
|
||||
#endif
|
||||
void modelDataChange();
|
||||
void onPreferencesUpdated();
|
||||
void onLanguageUpdated();
|
||||
void onConfigUpdated(const QString &uuid);
|
||||
int getActiveMachineCount();
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
# include "qt_updatecheckdialog.hpp"
|
||||
#endif
|
||||
#include "qt_about.hpp"
|
||||
#include "qt_progsettings.hpp"
|
||||
#include "qt_util.hpp"
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QStringListModel>
|
||||
@@ -113,6 +115,7 @@ VMManagerMainWindow(QWidget *parent)
|
||||
|
||||
// Inform the main view when preferences are updated
|
||||
connect(this, &VMManagerMainWindow::preferencesUpdated, vmm, &VMManagerMain::onPreferencesUpdated);
|
||||
connect(this, &VMManagerMainWindow::languageUpdated, vmm, &VMManagerMain::onLanguageUpdated);
|
||||
|
||||
}
|
||||
|
||||
@@ -151,6 +154,7 @@ VMManagerMainWindow::preferencesTriggered()
|
||||
const auto prefs = new VMManagerPreferences();
|
||||
if (prefs->exec() == QDialog::Accepted) {
|
||||
emit preferencesUpdated();
|
||||
updateLanguage();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,6 +168,27 @@ VMManagerMainWindow::saveSettings() const
|
||||
config->sync();
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerMainWindow::updateLanguage()
|
||||
{
|
||||
ProgSettings::loadTranslators(QCoreApplication::instance());
|
||||
ProgSettings::reloadStrings();
|
||||
ui->retranslateUi(this);
|
||||
setWindowTitle(tr("%1 VM Manager").arg(EMU_NAME));
|
||||
emit languageUpdated();
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerMainWindow::changeEvent(QEvent *event)
|
||||
{
|
||||
#ifdef Q_OS_WINDOWS
|
||||
if (event->type() == QEvent::LanguageChange) {
|
||||
QApplication::setFont(QFont(ProgSettings::getFontName(lang_id), 9));
|
||||
}
|
||||
#endif
|
||||
QWidget::changeEvent(event);
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerMainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
|
||||
@@ -36,6 +36,7 @@ public:
|
||||
~VMManagerMainWindow() override;
|
||||
signals:
|
||||
void preferencesUpdated();
|
||||
void languageUpdated();
|
||||
|
||||
private:
|
||||
Ui::VMManagerMainWindow *ui;
|
||||
@@ -46,6 +47,7 @@ private:
|
||||
public slots:
|
||||
void setStatusLeft(const QString &text) const;
|
||||
void setStatusRight(const QString &text) const;
|
||||
void updateLanguage();
|
||||
|
||||
private slots:
|
||||
void vmmSelectionChanged(const QModelIndex ¤tSelection, QProcess::ProcessState processState) const;
|
||||
@@ -60,6 +62,7 @@ private slots:
|
||||
void on_actionAbout_Qt_triggered();
|
||||
|
||||
protected:
|
||||
void changeEvent(QEvent *event) override;
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
<string>86Box VM Manager</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget"/>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
|
||||
@@ -18,12 +18,14 @@
|
||||
#include <QFileDialog>
|
||||
#include <QStyle>
|
||||
|
||||
#include "qt_progsettings.hpp"
|
||||
#include "qt_vmmanager_preferences.hpp"
|
||||
#include "qt_vmmanager_config.hpp"
|
||||
#include "ui_qt_vmmanager_preferences.h"
|
||||
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
#include <86box/config.h>
|
||||
#include <86box/version.h>
|
||||
}
|
||||
|
||||
@@ -44,6 +46,15 @@ VMManagerPreferences(QWidget *parent) : ui(new Ui::VMManagerPreferences)
|
||||
ui->systemDirectory->setText(QDir(vmm_path).path());
|
||||
}
|
||||
|
||||
ui->comboBoxLanguage->setItemData(0, 0);
|
||||
for (int i = 1; i < ProgSettings::languages.length(); i++) {
|
||||
ui->comboBoxLanguage->addItem(ProgSettings::languages[i].second, i);
|
||||
if (i == lang_id) {
|
||||
ui->comboBoxLanguage->setCurrentIndex(ui->comboBoxLanguage->findData(i));
|
||||
}
|
||||
}
|
||||
ui->comboBoxLanguage->model()->sort(Qt::AscendingOrder);
|
||||
|
||||
// TODO: Defaults
|
||||
#if EMU_BUILD_NUM != 0
|
||||
const auto configUpdateCheck = config->getStringValue("update_check").toInt();
|
||||
@@ -70,11 +81,21 @@ VMManagerPreferences::chooseDirectoryLocation()
|
||||
ui->systemDirectory->setText(QDir::toNativeSeparators(directory));
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerPreferences::on_pushButtonLanguage_released()
|
||||
{
|
||||
ui->comboBoxLanguage->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void
|
||||
VMManagerPreferences::accept()
|
||||
{
|
||||
const auto config = new VMManagerConfig(VMManagerConfig::ConfigType::General);
|
||||
config->setStringValue("system_directory", ui->systemDirectory->text());
|
||||
|
||||
lang_id = ui->comboBoxLanguage->currentData().toInt();
|
||||
config_save_global();
|
||||
|
||||
#if EMU_BUILD_NUM != 0
|
||||
config->setStringValue("update_check", ui->updateCheckBox->isChecked() ? "1" : "0");
|
||||
#endif
|
||||
|
||||
@@ -37,6 +37,7 @@ private:
|
||||
QString settingsFile;
|
||||
private slots:
|
||||
void chooseDirectoryLocation();
|
||||
void on_pushButtonLanguage_released();
|
||||
protected:
|
||||
void accept() override;
|
||||
void reject() override;
|
||||
|
||||
@@ -53,6 +53,42 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelLanguage">
|
||||
<property name="text">
|
||||
<string>Language:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxLanguage">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>(System Default)</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButtonLanguage">
|
||||
<property name="text">
|
||||
<string>Default</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="updateCheckBox">
|
||||
<property name="text">
|
||||
@@ -92,6 +128,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>dirSelectButton</tabstop>
|
||||
<tabstop>comboBoxLanguage</tabstop>
|
||||
<tabstop>pushButtonLanguage</tabstop>
|
||||
<tabstop>updateCheckBox</tabstop>
|
||||
<tabstop>regexSearchCheckBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
|
||||
Reference in New Issue
Block a user