Merge branch 'master' into config-cpu-version
This commit is contained in:
@@ -29,7 +29,9 @@
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
#include <QDir>
|
||||
#include <QPushButton>
|
||||
#include <QSettings>
|
||||
#include <QSizePolicy>
|
||||
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
@@ -38,6 +40,7 @@ extern "C" {
|
||||
#include <86box/device.h>
|
||||
#include <86box/midi_rtmidi.h>
|
||||
#include <86box/mem.h>
|
||||
#include <86box/random.h>
|
||||
#include <86box/rom.h>
|
||||
}
|
||||
|
||||
@@ -116,6 +119,7 @@ DeviceConfig::ConfigureDevice(const _device_ *device, int instance, Settings *se
|
||||
device_set_context(&device_context, device, instance);
|
||||
|
||||
auto device_label = new QLabel(device->name);
|
||||
device_label->setAlignment(Qt::AlignCenter);
|
||||
dc.ui->formLayout->addRow(device_label);
|
||||
auto line = new QFrame;
|
||||
line->setFrameShape(QFrame::HLine);
|
||||
@@ -291,6 +295,33 @@ DeviceConfig::ConfigureDevice(const _device_ *device, int instance, Settings *se
|
||||
cbox->setCurrentIndex(currentIndex);
|
||||
break;
|
||||
}
|
||||
case CONFIG_MAC:
|
||||
{
|
||||
// QHBoxLayout for the line edit widget and the generate button
|
||||
auto hboxLayout = new QHBoxLayout();
|
||||
auto generateButton = new QPushButton(tr("Generate"));
|
||||
auto lineEdit = new QLineEdit;
|
||||
// Allow the line edit to expand and fill available space
|
||||
lineEdit->setSizePolicy(QSizePolicy::MinimumExpanding,QSizePolicy::Preferred);
|
||||
lineEdit->setInputMask("HH:HH:HH;0");
|
||||
lineEdit->setObjectName(config->name);
|
||||
// Display the current or generated MAC in uppercase
|
||||
// When stored it will be converted to lowercase
|
||||
if (config_get_mac(device_context.name, config->name, config->default_int) & 0xFF000000) {
|
||||
lineEdit->setText(QString::asprintf("%02X:%02X:%02X", random_generate(), random_generate(), random_generate()));
|
||||
} else {
|
||||
auto current_mac = QString(config_get_string(device_context.name, config->name, const_cast<char *>(config->default_string)));
|
||||
lineEdit->setText(current_mac.toUpper());
|
||||
}
|
||||
// Action for the generate button
|
||||
connect(generateButton, &QPushButton::clicked, [lineEdit] {
|
||||
lineEdit->setText(QString::asprintf("%02X:%02X:%02X", random_generate(), random_generate(), random_generate()));
|
||||
});
|
||||
hboxLayout->addWidget(lineEdit);
|
||||
hboxLayout->addWidget(generateButton);
|
||||
dc.ui->formLayout->addRow(config->description, hboxLayout);
|
||||
break;
|
||||
}
|
||||
}
|
||||
++config;
|
||||
}
|
||||
@@ -362,6 +393,14 @@ DeviceConfig::ConfigureDevice(const _device_ *device, int instance, Settings *se
|
||||
config_set_int(device_context.name, const_cast<char *>(config->name), spinBox->value());
|
||||
break;
|
||||
}
|
||||
case CONFIG_MAC:
|
||||
{
|
||||
const auto *lineEdit = dc.findChild<QLineEdit *>(config->name);
|
||||
// Store the mac address as lowercase
|
||||
auto macText = lineEdit->displayText().toLower();
|
||||
config_set_string(device_context.name, config->name, macText.toUtf8().constData());
|
||||
break;
|
||||
}
|
||||
}
|
||||
config++;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <QFont>
|
||||
#include <QDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QPushButton>
|
||||
|
||||
#ifdef QT_STATIC
|
||||
/* Static builds need plugin imports */
|
||||
@@ -71,6 +72,7 @@ extern "C" {
|
||||
#include "cocoa_mouse.hpp"
|
||||
#include "qt_styleoverride.hpp"
|
||||
#include "qt_unixmanagerfilter.hpp"
|
||||
#include "qt_util.hpp"
|
||||
|
||||
// Void Cast
|
||||
#define VC(x) const_cast<wchar_t *>(x)
|
||||
@@ -220,6 +222,25 @@ main(int argc, char *argv[])
|
||||
return 6;
|
||||
}
|
||||
|
||||
// UUID / copy / move detection
|
||||
if(!util::compareUuid()) {
|
||||
QMessageBox movewarnbox;
|
||||
movewarnbox.setIcon(QMessageBox::Icon::Warning);
|
||||
movewarnbox.setText("This machine might have been moved or copied.");
|
||||
movewarnbox.setInformativeText("In order to ensure proper networking functionality, 86Box needs to know if this machine was moved or copied.\n\nSelect \"I Copied It\" if you are not sure.");
|
||||
const QPushButton *movedButton = movewarnbox.addButton(QObject::tr("I Moved It"), QMessageBox::AcceptRole);
|
||||
const QPushButton *copiedButton = movewarnbox.addButton(QObject::tr("I Copied It"), QMessageBox::DestructiveRole);
|
||||
QPushButton *cancelButton = movewarnbox.addButton(QObject::tr("Cancel"), QMessageBox::RejectRole);
|
||||
movewarnbox.setDefaultButton(cancelButton);
|
||||
movewarnbox.exec();
|
||||
if (movewarnbox.clickedButton() == copiedButton) {
|
||||
util::storeCurrentUuid();
|
||||
util::generateNewMacAdresses();
|
||||
} else if (movewarnbox.clickedButton() == movedButton) {
|
||||
util::storeCurrentUuid();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef Q_OS_WINDOWS
|
||||
# if !defined(EMU_BUILD_NUM) || (EMU_BUILD_NUM != 5624)
|
||||
HWND winbox = FindWindow("TWinBoxMain", NULL);
|
||||
|
||||
@@ -139,6 +139,7 @@ SettingsDisplay::on_comboBoxVideo_currentIndexChanged(int index)
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
static QRegularExpression voodooRegex("3dfx|voodoo|banshee", QRegularExpression::CaseInsensitiveOption);
|
||||
auto curVideoCard_2 = videoCard[1];
|
||||
videoCard[0] = ui->comboBoxVideo->currentData().toInt();
|
||||
if (videoCard[0] == VID_INTERNAL)
|
||||
@@ -207,6 +208,25 @@ SettingsDisplay::on_comboBoxVideo_currentIndexChanged(int index)
|
||||
ui->comboBoxVideoSecondary->setCurrentIndex(0);
|
||||
ui->pushButtonConfigureSecondary->setEnabled(false);
|
||||
}
|
||||
|
||||
// Is the currently selected video card a voodoo?
|
||||
if (ui->comboBoxVideo->currentText().contains(voodooRegex)) {
|
||||
// Get the name of the video card currently in use
|
||||
const device_t *video_dev = video_card_getdevice(gfxcard[0]);
|
||||
const QString currentVideoName = DeviceConfig::DeviceName(video_dev, video_get_internal_name(gfxcard[0]), 1);
|
||||
// Is it a voodoo?
|
||||
const bool currentCardIsVoodoo = currentVideoName.contains(voodooRegex);
|
||||
// Don't uncheck if
|
||||
// * Current card is voodoo
|
||||
// * Add-on voodoo was manually overridden in config
|
||||
if (ui->checkBoxVoodoo->isChecked() && !currentCardIsVoodoo) {
|
||||
// Otherwise, uncheck the add-on voodoo when a main voodoo is selected
|
||||
ui->checkBoxVoodoo->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
ui->checkBoxVoodoo->setDisabled(true);
|
||||
} else {
|
||||
ui->checkBoxVoodoo->setDisabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -61,15 +61,15 @@
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QComboBox" name="comboBoxVideo">
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
@@ -102,7 +102,7 @@
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="checkBoxVoodoo">
|
||||
<property name="text">
|
||||
<string>Voodoo Graphics</string>
|
||||
<string>Voodoo 1 or 2 Graphics</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -122,15 +122,15 @@
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QComboBox" name="comboBoxVideoSecondary">
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="3">
|
||||
|
||||
@@ -61,6 +61,11 @@ SettingsMachine::SettingsMachine(QWidget *parent)
|
||||
break;
|
||||
}
|
||||
|
||||
auto warning_icon = ui->softFloatWarningIcon->style()->standardIcon(QStyle::SP_MessageBoxWarning);
|
||||
ui->softFloatWarningIcon->setPixmap(warning_icon.pixmap(warning_icon.actualSize(QSize(16, 16))));
|
||||
ui->softFloatWarningIcon->setVisible(false);
|
||||
ui->softFloatWarningText->setVisible(false);
|
||||
|
||||
auto *waitStatesModel = ui->comboBoxWaitStates->model();
|
||||
waitStatesModel->insertRows(0, 9);
|
||||
auto idx = waitStatesModel->index(0, 0);
|
||||
@@ -337,3 +342,13 @@ SettingsMachine::on_pushButtonConfigure_clicked()
|
||||
const auto *device = machine_get_device(machineId);
|
||||
DeviceConfig::ConfigureDevice(device, 0, qobject_cast<Settings *>(Settings::settings));
|
||||
}
|
||||
|
||||
void SettingsMachine::on_checkBoxFPUSoftfloat_stateChanged(int state) {
|
||||
if(state == Qt::Checked) {
|
||||
ui->softFloatWarningIcon->setVisible(true);
|
||||
ui->softFloatWarningText->setVisible(true);
|
||||
} else {
|
||||
ui->softFloatWarningIcon->setVisible(false);
|
||||
ui->softFloatWarningText->setVisible(false);
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ private slots:
|
||||
|
||||
private slots:
|
||||
void on_comboBoxMachineType_currentIndexChanged(int index);
|
||||
void on_checkBoxFPUSoftfloat_stateChanged(int state);
|
||||
|
||||
private:
|
||||
Ui::SettingsMachine *ui;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>458</width>
|
||||
<height>434</height>
|
||||
<height>459</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -41,13 +41,6 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Wait states:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="comboBoxMachineType">
|
||||
<property name="maxVisibleItems">
|
||||
@@ -55,6 +48,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>FPU:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
@@ -69,55 +69,21 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QWidget" name="widget_4" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxWaitStates">
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>PIT mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxPitMode">
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="spinBoxRAM">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Machine type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
@@ -144,15 +110,15 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxCPU">
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@@ -167,27 +133,31 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxSpeed">
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="spinBoxRAM">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Wait states:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Machine:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -229,55 +199,120 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Machine type:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Machine:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>FPU:</string>
|
||||
</property>
|
||||
<item row="4" column="1">
|
||||
<widget class="QWidget" name="widget_4" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxWaitStates">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>PIT mode:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboBoxPitMode">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maxVisibleItems">
|
||||
<number>30</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxDynamicRecompiler">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>2</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dynamic Recompiler</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="dynamicRecompilerLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxDynamicRecompiler">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>2</horstretch>
|
||||
<verstretch>2</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dynamic Recompiler</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxFPUSoftfloat">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>3</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Softfloat FPU</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QHBoxLayout" name="softFloatLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkBoxFPUSoftfloat">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>3</horstretch>
|
||||
<verstretch>3</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Softfloat FPU</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="softFloatWarningIcon">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="softFloatWarningText">
|
||||
<property name="text">
|
||||
<string>High performance impact</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="softFloatHorizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
|
||||
@@ -21,8 +21,20 @@
|
||||
#if QT_VERSION <= QT_VERSION_CHECK(5, 14, 0)
|
||||
# include <QDesktopWidget>
|
||||
#endif
|
||||
#include <QUuid>
|
||||
#include "qt_util.hpp"
|
||||
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
#include <86box/config.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/ini.h>
|
||||
#include <86box/random.h>
|
||||
#include <86box/thread.h>
|
||||
#include <86box/timer.h>
|
||||
#include <86box/network.h>
|
||||
}
|
||||
|
||||
namespace util {
|
||||
QScreen *
|
||||
screenOfWidget(QWidget *widget)
|
||||
@@ -56,4 +68,45 @@ DlgFilter(std::initializer_list<QString> extensions, bool last)
|
||||
return " (" % temp.join(' ') % ")" % (!last ? ";;" : "");
|
||||
}
|
||||
|
||||
QString currentUuid()
|
||||
{
|
||||
return QUuid::createUuidV5(QUuid{}, QString(usr_path)).toString(QUuid::WithoutBraces);
|
||||
}
|
||||
|
||||
bool compareUuid()
|
||||
{
|
||||
// A uuid not set in the config file will have a zero length.
|
||||
// Any uuid that is lower than the minimum length will be considered invalid
|
||||
// and a new one will be generated
|
||||
if (const auto currentUuidLength = QString(uuid).length(); currentUuidLength < UUID_MIN_LENGTH) {
|
||||
storeCurrentUuid();
|
||||
return true;
|
||||
}
|
||||
// The uuid appears to be a valid, at least by length.
|
||||
// Compare with a simple string match
|
||||
return uuid == currentUuid();
|
||||
}
|
||||
|
||||
void
|
||||
storeCurrentUuid()
|
||||
{
|
||||
strncpy(uuid, currentUuid().toUtf8().constData(), sizeof(uuid) - 1);
|
||||
}
|
||||
|
||||
void
|
||||
generateNewMacAdresses()
|
||||
{
|
||||
for (int i = 0; i < NET_CARD_MAX; ++i) {
|
||||
auto net_card = net_cards_conf[i];
|
||||
if (net_card.device_num != 0) {
|
||||
const auto network_device = network_card_getdevice(net_card.device_num);
|
||||
device_context_t device_context;
|
||||
|
||||
device_set_context(&device_context, network_device, i+1);
|
||||
auto generatedMac = QString::asprintf("%02X:%02X:%02X", random_generate(), random_generate(), random_generate()).toLower();
|
||||
config_set_string(device_context.name, "mac", generatedMac.toUtf8().constData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,10 +8,15 @@
|
||||
|
||||
class QScreen;
|
||||
namespace util {
|
||||
static constexpr auto UUID_MIN_LENGTH = 36;
|
||||
/* Creates extension list for qt filedialog */
|
||||
QString DlgFilter(std::initializer_list<QString> extensions, bool last = false);
|
||||
/* Returns screen the widget is on */
|
||||
QScreen *screenOfWidget(QWidget *widget);
|
||||
QString currentUuid();
|
||||
void storeCurrentUuid();
|
||||
bool compareUuid();
|
||||
void generateNewMacAdresses();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user