diff --git a/src/biomecolordialog.cpp b/src/biomecolordialog.cpp index be02096..fb90977 100644 --- a/src/biomecolordialog.cpp +++ b/src/biomecolordialog.cpp @@ -27,7 +27,10 @@ BiomeColorDialog::BiomeColorDialog(MainWindow *parent, QString initrc, int mc, i , modified() { ui->setupUi(this); - ui->buttonOk->setIcon(style()->standardIcon(QStyle::SP_DialogOkButton)); + connect(ui->buttonRemove, &QPushButton::clicked, this, &BiomeColorDialog::onRemove); + connect(ui->buttonSaveAs, &QPushButton::clicked, this, &BiomeColorDialog::onSaveAs); + connect(ui->buttonExport, &QPushButton::clicked, this, &BiomeColorDialog::onExport); + connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &BiomeColorDialog::onAccept); memcpy(colors, g_biomeColors, sizeof(colors)); memset(buttons, 0, sizeof(buttons)); @@ -35,12 +38,13 @@ BiomeColorDialog::BiomeColorDialog(MainWindow *parent, QString initrc, int mc, i unsigned char coldefault[256][3]; initBiomeColors(coldefault); - QPushButton *button; ui->gridLayout->setSpacing(2); separator = new QLabel(tr("Currently inactive biomes:"), this); separator->setVisible(false); + QPushButton *button; + button = new QPushButton(getColorIcon(QColor(0,0,0,0), QPen(Qt::transparent)), tr("Import..."), this); connect(button, &QPushButton::clicked, this, &BiomeColorDialog::onImport); ui->gridLayout->addWidget(button, 0, 0); @@ -277,7 +281,7 @@ void BiomeColorDialog::on_comboColormaps_currentIndexChanged(int index) if (modified) { if (activerc.isEmpty()) - on_buttonSaveAs_clicked(); + onSaveAs(); else saveColormap(activerc, ""); } @@ -286,7 +290,7 @@ void BiomeColorDialog::on_comboColormaps_currentIndexChanged(int index) loadColormap(activerc, true); } -void BiomeColorDialog::on_buttonSaveAs_clicked() +void BiomeColorDialog::onSaveAs() { QString rc; int n; @@ -310,7 +314,7 @@ void BiomeColorDialog::on_buttonSaveAs_clicked() activerc = rc; } -void BiomeColorDialog::on_buttonExport_clicked() +void BiomeColorDialog::onExport() { QFileInfo finfo(mainwindow->prevdir); QString fnam = QFileDialog::getSaveFileName( @@ -333,7 +337,7 @@ void BiomeColorDialog::on_buttonExport_clicked() } } -void BiomeColorDialog::on_buttonRemove_clicked() +void BiomeColorDialog::onRemove() { QString rc = qvariant_cast(ui->comboColormaps->currentData()); if (!rc.isEmpty()) @@ -345,7 +349,7 @@ void BiomeColorDialog::on_buttonRemove_clicked() } } -void BiomeColorDialog::on_buttonOk_clicked() +void BiomeColorDialog::onAccept() { on_comboColormaps_currentIndexChanged(ui->comboColormaps->currentIndex()); emit yieldBiomeColorRc(activerc); diff --git a/src/biomecolordialog.h b/src/biomecolordialog.h index 3e185f4..a476dfa 100644 --- a/src/biomecolordialog.h +++ b/src/biomecolordialog.h @@ -33,16 +33,15 @@ public slots: private slots: void on_comboColormaps_currentIndexChanged(int index); - void on_buttonSaveAs_clicked(); - void on_buttonRemove_clicked(); - void on_buttonOk_clicked(); - + void onSaveAs(); + void onExport(); + void onRemove(); + void onAccept(); void onImport(); void onColorHelp(); void onAllToDefault(); void onAllToDimmed(); - void on_buttonExport_clicked(); private: Ui::BiomeColorDialog *ui; diff --git a/src/biomecolordialog.ui b/src/biomecolordialog.ui index 19f4ab7..27adee3 100644 --- a/src/biomecolordialog.ui +++ b/src/biomecolordialog.ui @@ -33,16 +33,16 @@ - + - Save as... + Export... - + - Export... + Save as... @@ -54,9 +54,9 @@ - - - Ok + + + QDialogButtonBox::Ok diff --git a/src/conditiondialog.cpp b/src/conditiondialog.cpp index 0cb9f97..8577e1f 100644 --- a/src/conditiondialog.cpp +++ b/src/conditiondialog.cpp @@ -48,6 +48,9 @@ ConditionDialog::ConditionDialog(FormConditions *parent, Config *config, int mcv memset(&cond, 0, sizeof(cond)); ui->setupUi(this); + connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &ConditionDialog::onAccept); + connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &ConditionDialog::onReject); + textDescription = new QTextEdit(this); textDescription->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); ui->collapseDescription->init(tr("Description/Notes"), textDescription, true); @@ -637,7 +640,7 @@ void ConditionDialog::updateMode() ui->lineEditZ1->setToolTip(lowtip); ui->lineEditX2->setToolTip(uptip); ui->lineEditZ2->setToolTip(uptip); - ui->buttonOk->setEnabled(filterindex != F_SELECT); + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(filterindex != F_SELECT); textDescription->setText(QApplication::translate("Filter", ft.description)); } @@ -862,97 +865,6 @@ int ConditionDialog::warnIfBad(Condition cond) return QMessageBox::Ok; } -void ConditionDialog::on_comboBoxType_activated(int) -{ - updateMode(); -} - -void ConditionDialog::on_comboBoxRelative_activated(int) -{ - QPalette pal; - if (ui->comboBoxRelative->currentText().contains(WARNING_CHAR)) - pal.setColor(QPalette::Normal, QPalette::Button, QColor(255,0,0,127)); - ui->comboBoxRelative->setPalette(pal); -} - -void ConditionDialog::on_buttonUncheck_clicked() -{ - for (const auto& it : biomecboxes) - it.second->setCheckState(Qt::Unchecked); -} - -void ConditionDialog::on_buttonInclude_clicked() -{ - for (const auto& it : biomecboxes) - it.second->setCheckState(it.second->isEnabled() ? Qt::PartiallyChecked : Qt::Unchecked); -} - -void ConditionDialog::on_buttonExclude_clicked() -{ - for (const auto& it : biomecboxes) - it.second->setCheckState(it.second->isEnabled() ? Qt::Checked : Qt::Unchecked); -} - -void ConditionDialog::on_buttonAreaInfo_clicked() -{ - QMessageBox mb(this); - mb.setIcon(QMessageBox::Information); - mb.setWindowTitle(tr("Help: area entry")); - mb.setText(tr( - "

" - "The area can be entered via custom rectangle, that is defined " - "by its two opposing corners, relative to a center point. These bounds " - "are inclusive." - "

" - "Alternatively, the area can be defined as a centered square " - "with a certain side length. In this case the area has the bounds: " - "[-X/2, -X/2] on both axes, rounding down and bounds included. For " - "example a centered square with side 3 will go from -2 to 1 for both " - "the X and Z axes." - "

" - "Important to note is that some filters have a scaling associated with " - "them. This means that the area is not defined in blocks, but on a grid " - "with the given spacing (such as chunks instead of blocks). A scaling " - "of 1:16, for example, means that the aforementioned centered square of " - "side 3 will range from -32 to 31 in block coordinates. (Chunk 1 has " - "blocks 16 to 31.)" - "

" - )); - mb.exec(); -} - -void ConditionDialog::on_checkRadius_toggled(bool) -{ - updateMode(); -} - -void ConditionDialog::on_radioSquare_toggled(bool) -{ - updateMode(); -} - -void ConditionDialog::on_radioCustom_toggled(bool) -{ - updateMode(); -} - -void ConditionDialog::on_lineSquare_editingFinished() -{ - int v = ui->lineSquare->text().toInt(); - int area = (v+1) * (v+1); - for (int i = 0; i < 9; i++) - { - if (tempsboxes[i]) - tempsboxes[i]->setMaximum(area); - } -} - -void ConditionDialog::on_buttonCancel_clicked() -{ - on_comboLua_currentIndexChanged(-1); - close(); -} - static uint16_t tristateFlags(QCheckBox *cb, uint16_t flg) { uint16_t ret = 0; @@ -965,7 +877,14 @@ static uint16_t tristateFlags(QCheckBox *cb, uint16_t flg) return ret; } -void ConditionDialog::on_buttonOk_clicked() + +void ConditionDialog::onReject() +{ + on_comboLua_currentIndexChanged(-1); + close(); +} + +void ConditionDialog::onAccept() { on_pushLuaSave_clicked(); @@ -1110,6 +1029,91 @@ void ConditionDialog::on_buttonOk_clicked() close(); } +void ConditionDialog::on_comboBoxType_activated(int) +{ + updateMode(); +} + +void ConditionDialog::on_comboBoxRelative_activated(int) +{ + QPalette pal; + if (ui->comboBoxRelative->currentText().contains(WARNING_CHAR)) + pal.setColor(QPalette::Normal, QPalette::Button, QColor(255,0,0,127)); + ui->comboBoxRelative->setPalette(pal); +} + +void ConditionDialog::on_buttonUncheck_clicked() +{ + for (const auto& it : biomecboxes) + it.second->setCheckState(Qt::Unchecked); +} + +void ConditionDialog::on_buttonInclude_clicked() +{ + for (const auto& it : biomecboxes) + it.second->setCheckState(it.second->isEnabled() ? Qt::PartiallyChecked : Qt::Unchecked); +} + +void ConditionDialog::on_buttonExclude_clicked() +{ + for (const auto& it : biomecboxes) + it.second->setCheckState(it.second->isEnabled() ? Qt::Checked : Qt::Unchecked); +} + +void ConditionDialog::on_buttonAreaInfo_clicked() +{ + QMessageBox mb(this); + mb.setIcon(QMessageBox::Information); + mb.setWindowTitle(tr("Help: area entry")); + mb.setText(tr( + "

" + "The area can be entered via custom rectangle, that is defined " + "by its two opposing corners, relative to a center point. These bounds " + "are inclusive." + "

" + "Alternatively, the area can be defined as a centered square " + "with a certain side length. In this case the area has the bounds: " + "[-X/2, -X/2] on both axes, rounding down and bounds included. For " + "example a centered square with side 3 will go from -2 to 1 for both " + "the X and Z axes." + "

" + "Important to note is that some filters have a scaling associated with " + "them. This means that the area is not defined in blocks, but on a grid " + "with the given spacing (such as chunks instead of blocks). A scaling " + "of 1:16, for example, means that the aforementioned centered square of " + "side 3 will range from -32 to 31 in block coordinates. (Chunk 1 has " + "blocks 16 to 31.)" + "

" + )); + mb.exec(); +} + +void ConditionDialog::on_checkRadius_toggled(bool) +{ + updateMode(); +} + +void ConditionDialog::on_radioSquare_toggled(bool) +{ + updateMode(); +} + +void ConditionDialog::on_radioCustom_toggled(bool) +{ + updateMode(); +} + +void ConditionDialog::on_lineSquare_editingFinished() +{ + int v = ui->lineSquare->text().toInt(); + int area = (v+1) * (v+1); + for (int i = 0; i < 9; i++) + { + if (tempsboxes[i]) + tempsboxes[i]->setMaximum(area); + } +} + void ConditionDialog::on_ConditionDialog_finished(int result) { if (item) diff --git a/src/conditiondialog.h b/src/conditiondialog.h index 8ed3c98..71e80a2 100644 --- a/src/conditiondialog.h +++ b/src/conditiondialog.h @@ -188,6 +188,9 @@ public: void updateBiomeSelection(); int warnIfBad(Condition cond); + void onReject(); + void onAccept(); + void getClimateLimits(int limok[6][2], int limex[6][2]); void getClimateLimits(LabeledRange *ranges[6], int limits[6][2]); void setClimateLimits(LabeledRange *ranges[6], int limits[6][2], bool complete); @@ -213,10 +216,6 @@ private slots: void on_lineSquare_editingFinished(); //void on_lineRadius_editingFinished(); - void on_buttonCancel_clicked(); - - void on_buttonOk_clicked(); - void on_ConditionDialog_finished(int result); void on_comboBoxCat_currentIndexChanged(int); diff --git a/src/conditiondialog.ui b/src/conditiondialog.ui index 7d67923..62a786e 100644 --- a/src/conditiondialog.ui +++ b/src/conditiondialog.ui @@ -1635,40 +1635,9 @@ QPushButton:hover { - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Cancel - - - - .. - - - - - - - Ok - - - - .. - - - true + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok @@ -1700,8 +1669,6 @@ QPushButton:hover { - buttonOk - buttonCancel comboBoxCat comboBoxType spinBox diff --git a/src/message.cpp b/src/message.cpp index 1340aeb..24e9538 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -7,6 +7,13 @@ static int term_prompt(const QString& title, const QString& text, QMessageBox::StandardButtons buttons) { + // translations for QGnomeTheme as they may override QPlatformThemes + QApplication::translate("QGnomeTheme", "&OK"); + QApplication::translate("QGnomeTheme", "&Save"); + QApplication::translate("QGnomeTheme", "&Cancel"); + QApplication::translate("QGnomeTheme", "&Close"); + QApplication::translate("QGnomeTheme", "Close without Saving"); + QTextStream out (stdout); out << QString("[%1]\n%2\n---\n").arg(title).arg(text); std::vector> opts; diff --git a/src/presetdialog.cpp b/src/presetdialog.cpp index d267edd..91cb8e9 100644 --- a/src/presetdialog.cpp +++ b/src/presetdialog.cpp @@ -60,8 +60,8 @@ PresetDialog::PresetDialog(QWidget *parent, WorldInfo wi, bool showEamples) resize(fontMetrics().horizontalAdvance('x') * 128, fontMetrics().height() * 32); ui->labelMC->setText(tr("MC ") + mc2str(wi.mc)); - connect(ui->buttonOk, &QPushButton::clicked, this, &QDialog::accept); - connect(ui->buttonCancel, &QPushButton::clicked, this, &QDialog::reject); + connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); + connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); if (showEamples) ui->tabWidget->setCurrentWidget(ui->tabExamples); @@ -203,13 +203,13 @@ void PresetDialog::updateSelection() ui->formCond->on_buttonRemoveAll_clicked(); for (Condition& c : presets[rc].condvec) ui->formCond->addItemCondition(new QListWidgetItem(), c); - ui->buttonOk->setEnabled(true); + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); } else { ui->textDesc->clear(); ui->formCond->on_buttonRemoveAll_clicked(); - ui->buttonOk->setEnabled(false); + ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); } } diff --git a/src/presetdialog.ui b/src/presetdialog.ui index 68ad1d0..0c5ba54 100644 --- a/src/presetdialog.ui +++ b/src/presetdialog.ui @@ -116,41 +116,11 @@ - - - - - Qt::Horizontal - - - - 0 - 0 - - - - - - - - false - - - Ok - - - - - - - Cancel - - - true - - - - + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + +