Skip to content

Commit

Permalink
Added select template item 64 GB and code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanAizek committed Mar 15, 2024
1 parent 968c3f2 commit d86d313
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/VM_Wizard_Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<enum sz>::max());
ramSizes << "32 MB"
<< "64 MB"
<< "128 MB"
Expand All @@ -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!"));
Expand Down
17 changes: 17 additions & 0 deletions src/VM_Wizard_Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,23 @@ class VM_Wizard_Window: public QDialog
void Set_VM_List( QList<Virtual_Machine*> *list );

std::unique_ptr<Virtual_Machine> 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);
Expand Down

0 comments on commit d86d313

Please sign in to comment.