From d86d313af7b5d404f591db85143fc4aabe308089 Mon Sep 17 00:00:00 2001 From: Herman Semenov Date: Fri, 15 Mar 2024 16:13:04 +0300 Subject: [PATCH] Added select template item 64 GB and code refactor --- src/VM_Wizard_Window.cpp | 34 +++++++++++++++++++--------------- src/VM_Wizard_Window.h | 17 +++++++++++++++++ 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/VM_Wizard_Window.cpp b/src/VM_Wizard_Window.cpp index 9714fd5..8f14af5 100644 --- a/src/VM_Wizard_Window.cpp +++ b/src/VM_Wizard_Window.cpp @@ -742,10 +742,11 @@ void VM_Wizard_Window::Update_RAM_Size_ComboBox(int freeRAM) static int oldRamSize = 0; if (freeRAM == oldRamSize) return; - else - oldRamSize = freeRAM; + + oldRamSize = freeRAM; QStringList ramSizes; + ramSizes.reserve(std::numeric_limits::max()); ramSizes << "32 MB" << "64 MB" << "128 MB" @@ -757,31 +758,34 @@ void VM_Wizard_Window::Update_RAM_Size_ComboBox(int freeRAM) << "4 GB" << "8 GB" << "16 GB" - << "32 GB"; + << "32 GB" + << "64 GB"; int maxRamIndex = 0; - if (freeRAM >= 32768) + if (freeRAM >= sz::_64GB) + maxRamIndex = 13; + else if (freeRAM >= sz::_32GB) maxRamIndex = 12; - else if (freeRAM >= 16384) + else if (freeRAM >= sz::_16GB) maxRamIndex = 11; - else if (freeRAM >= 8192) + else if (freeRAM >= sz::_8GB) maxRamIndex = 10; - else if (freeRAM >= 4096) + else if (freeRAM >= sz::_4GB) maxRamIndex = 9; - else if (freeRAM >= 3072) + else if (freeRAM >= sz::_3GB) maxRamIndex = 8; - else if (freeRAM >= 2048) + else if (freeRAM >= sz::_2GB) maxRamIndex = 7; - else if (freeRAM >= 1024) + else if (freeRAM >= sz::_1GB) maxRamIndex = 6; - else if (freeRAM >= 512) + else if (freeRAM >= sz::_512MB) maxRamIndex = 5; - else if (freeRAM >= 256) + else if (freeRAM >= sz::_256MB) maxRamIndex = 4; - else if (freeRAM >= 128) + else if (freeRAM >= sz::_128MB) maxRamIndex = 3; - else if (freeRAM >= 64) + else if (freeRAM >= sz::_64MB) maxRamIndex = 2; - else if (freeRAM >= 32) + else if (freeRAM >= sz::_32MB) maxRamIndex = 1; else { AQGraphic_Warning(tr("Error"), tr("Free memory on this system is lower than 32 MB!")); diff --git a/src/VM_Wizard_Window.h b/src/VM_Wizard_Window.h index 5fe2d08..75d56be 100644 --- a/src/VM_Wizard_Window.h +++ b/src/VM_Wizard_Window.h @@ -40,6 +40,23 @@ class VM_Wizard_Window: public QDialog void Set_VM_List( QList *list ); std::unique_ptr New_VM; + + enum sz + { + _32MB = 1 << 5, + _64MB = 1 << 6, + _128MB = 1 << 7, + _256MB = 1 << 8, + _512MB = 1 << 9, + _1GB = 1 << 10, + _2GB = 1 << 11, + _3GB = (1 << 12) - _1GB, + _4GB = 1 << 12, + _8GB = 1 << 13, + _16GB = 1 << 14, + _32GB = 1 << 15, + _64GB = 1 << 16 + }; private slots: void on_KVM_toggled(bool toggled);