mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Make sure only powers of two are entered for the page size (#1405)
* Make sure only powers of two are entered for the page size * Replace QSpinBox with QComboBox Having a QSpinBox didn't make too much sense when we only have 8 valid values. Forcing the user to type a valid value would have required a warning message too, along with translations. Having a QComboBox makes it clear (obviously) what values we are expecting, without any risk of invalid values or confusion. * Add thousands separator for page size values
This commit is contained in:
committed by
Martin Kleusberg
parent
c92a981164
commit
9c2cec628b
@@ -4,6 +4,8 @@
|
||||
#include <QPushButton>
|
||||
#include <QRegExpValidator>
|
||||
|
||||
#include <QtCore/qmath.h>
|
||||
|
||||
CipherDialog::CipherDialog(QWidget* parent, bool encrypt) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::CipherDialog),
|
||||
@@ -12,6 +14,21 @@ CipherDialog::CipherDialog(QWidget* parent, bool encrypt) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
int minimumPageSizeExponent = 9;
|
||||
int maximumPageSizeExponent = 16;
|
||||
int defaultPageSizeExponent = 10;
|
||||
|
||||
for(int exponent = minimumPageSizeExponent; exponent <= maximumPageSizeExponent; exponent++)
|
||||
{
|
||||
int pageSize = static_cast<int>(qPow(2, exponent));
|
||||
ui->comboPageSize->addItem(QLocale().toString(pageSize), pageSize);
|
||||
|
||||
if (exponent == defaultPageSizeExponent)
|
||||
ui->comboPageSize->setCurrentIndex(exponent - minimumPageSizeExponent);
|
||||
}
|
||||
|
||||
ui->comboPageSize->setMinimumWidth(ui->editPassword->width());
|
||||
|
||||
if(encrypt)
|
||||
{
|
||||
ui->labelDialogDescription->setText(tr("Please set a key to encrypt the database.\nNote that if you change any of the other, optional, settings you'll need "
|
||||
@@ -47,7 +64,7 @@ QString CipherDialog::password() const
|
||||
|
||||
int CipherDialog::pageSize() const
|
||||
{
|
||||
return ui->spinPageSize->value();
|
||||
return ui->comboPageSize->itemData(ui->comboPageSize->currentIndex()).toInt();
|
||||
}
|
||||
|
||||
void CipherDialog::checkInputFields()
|
||||
|
||||
@@ -66,17 +66,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="spinPageSize">
|
||||
<property name="minimum">
|
||||
<number>512</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65536</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1024</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="comboPageSize"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
@@ -129,7 +119,7 @@
|
||||
<tabstop>editPassword</tabstop>
|
||||
<tabstop>comboKeyFormat</tabstop>
|
||||
<tabstop>editPassword2</tabstop>
|
||||
<tabstop>spinPageSize</tabstop>
|
||||
<tabstop>comboPageSize</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections>
|
||||
|
||||
Reference in New Issue
Block a user