mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-29 09:22:18 -07:00
Add editor spinboxes again
Took 4 minutes
This commit is contained in:
parent
b664050ac3
commit
b17f72802a
2 changed files with 89 additions and 3 deletions
|
|
@ -7,9 +7,11 @@
|
||||||
#include "card_database_model.h"
|
#include "card_database_model.h"
|
||||||
#include "playmat_preview_widget.h"
|
#include "playmat_preview_widget.h"
|
||||||
|
|
||||||
|
#include <QCheckBox>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QCompleter>
|
#include <QCompleter>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
|
#include <QDoubleSpinBox>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
|
@ -61,6 +63,16 @@ PlaymatParams PlaymatSettingsDialog::params() const
|
||||||
return currentParams;
|
return currentParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDoubleSpinBox *PlaymatSettingsDialog::makeSpinBox(double min, double max, double value, double step)
|
||||||
|
{
|
||||||
|
auto *spin = new QDoubleSpinBox;
|
||||||
|
spin->setRange(min, max);
|
||||||
|
spin->setSingleStep(step);
|
||||||
|
spin->setDecimals(3);
|
||||||
|
spin->setValue(value);
|
||||||
|
return spin;
|
||||||
|
}
|
||||||
|
|
||||||
void PlaymatSettingsDialog::initializeSearchBar()
|
void PlaymatSettingsDialog::initializeSearchBar()
|
||||||
{
|
{
|
||||||
searchBar = new QLineEdit;
|
searchBar = new QLineEdit;
|
||||||
|
|
@ -105,6 +117,32 @@ void PlaymatSettingsDialog::setupUi()
|
||||||
form->addRow(cardNameLabel, searchBar);
|
form->addRow(cardNameLabel, searchBar);
|
||||||
form->addRow(printingLabel, providerComboBox);
|
form->addRow(printingLabel, providerComboBox);
|
||||||
|
|
||||||
|
// Numerical editors expose the raw PlaymatParams for precise input. They
|
||||||
|
// stay hidden until requested since the crop surface is the primary control.
|
||||||
|
marginLSpin = makeSpinBox(0.0, 0.95, currentParams.marginPctL, 0.01);
|
||||||
|
marginRSpin = makeSpinBox(0.0, 0.95, currentParams.marginPctR, 0.01);
|
||||||
|
verticalOffsetSpin = makeSpinBox(0.0, 1.0, currentParams.verticalOffset, 0.01);
|
||||||
|
zoomSpin = makeSpinBox(0.1, 4.0, currentParams.zoom, 0.05);
|
||||||
|
|
||||||
|
leftMarginLabel = new QLabel;
|
||||||
|
rightMarginLabel = new QLabel;
|
||||||
|
verticalOffsetLabel = new QLabel;
|
||||||
|
zoomLabel = new QLabel;
|
||||||
|
|
||||||
|
auto *numericForm = new QFormLayout;
|
||||||
|
numericForm->addRow(leftMarginLabel, marginLSpin);
|
||||||
|
numericForm->addRow(rightMarginLabel, marginRSpin);
|
||||||
|
numericForm->addRow(verticalOffsetLabel, verticalOffsetSpin);
|
||||||
|
numericForm->addRow(zoomLabel, zoomSpin);
|
||||||
|
numericEditors = new QWidget;
|
||||||
|
numericEditors->setLayout(numericForm);
|
||||||
|
numericEditors->setVisible(false);
|
||||||
|
|
||||||
|
showNumericEditorsCheck = new QCheckBox;
|
||||||
|
|
||||||
|
form->addRow(showNumericEditorsCheck);
|
||||||
|
form->addRow(numericEditors);
|
||||||
|
|
||||||
controlsGroup = new QGroupBox;
|
controlsGroup = new QGroupBox;
|
||||||
controlsGroup->setLayout(form);
|
controlsGroup->setLayout(form);
|
||||||
|
|
||||||
|
|
@ -133,8 +171,25 @@ void PlaymatSettingsDialog::setupUi()
|
||||||
|
|
||||||
// The crop surface is the primary control: dragging pans, wheel/keys zoom
|
// The crop surface is the primary control: dragging pans, wheel/keys zoom
|
||||||
//, editing exactly the same stored parameters the old numeric fields did.
|
//, editing exactly the same stored parameters the old numeric fields did.
|
||||||
connect(preview, &PlaymatPreviewWidget::paramsEdited, this,
|
connect(preview, &PlaymatPreviewWidget::paramsEdited, this, [this](const PlaymatParams &edited) {
|
||||||
[this](const PlaymatParams &edited) { currentParams = edited; });
|
currentParams = edited;
|
||||||
|
|
||||||
|
QSignalBlocker blockMarginL(marginLSpin);
|
||||||
|
QSignalBlocker blockMarginR(marginRSpin);
|
||||||
|
QSignalBlocker blockOffset(verticalOffsetSpin);
|
||||||
|
QSignalBlocker blockZoom(zoomSpin);
|
||||||
|
marginLSpin->setValue(edited.marginPctL);
|
||||||
|
marginRSpin->setValue(edited.marginPctR);
|
||||||
|
verticalOffsetSpin->setValue(edited.verticalOffset);
|
||||||
|
zoomSpin->setValue(edited.zoom);
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(showNumericEditorsCheck, &QCheckBox::toggled, numericEditors, &QWidget::setVisible);
|
||||||
|
|
||||||
|
connect(marginLSpin, &QDoubleSpinBox::valueChanged, this, &PlaymatSettingsDialog::onParamChanged);
|
||||||
|
connect(marginRSpin, &QDoubleSpinBox::valueChanged, this, &PlaymatSettingsDialog::onParamChanged);
|
||||||
|
connect(verticalOffsetSpin, &QDoubleSpinBox::valueChanged, this, &PlaymatSettingsDialog::onParamChanged);
|
||||||
|
connect(zoomSpin, &QDoubleSpinBox::valueChanged, this, &PlaymatSettingsDialog::onParamChanged);
|
||||||
|
|
||||||
// The crop surface leads visually, card selection supports it below.
|
// The crop surface leads visually, card selection supports it below.
|
||||||
auto *root = new QVBoxLayout;
|
auto *root = new QVBoxLayout;
|
||||||
|
|
@ -229,12 +284,26 @@ void PlaymatSettingsDialog::reloadPreview()
|
||||||
preview->setAttribution(buildArtAttribution(card));
|
preview->setAttribution(buildArtAttribution(card));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlaymatSettingsDialog::onParamChanged()
|
||||||
|
{
|
||||||
|
currentParams.marginPctL = marginLSpin->value();
|
||||||
|
currentParams.marginPctR = marginRSpin->value();
|
||||||
|
currentParams.verticalOffset = verticalOffsetSpin->value();
|
||||||
|
currentParams.zoom = zoomSpin->value();
|
||||||
|
preview->setParams(currentParams);
|
||||||
|
}
|
||||||
|
|
||||||
void PlaymatSettingsDialog::retranslateUi()
|
void PlaymatSettingsDialog::retranslateUi()
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("Playmat Settings"));
|
setWindowTitle(tr("Playmat Settings"));
|
||||||
searchBar->setPlaceholderText(tr("Type a card name..."));
|
searchBar->setPlaceholderText(tr("Type a card name..."));
|
||||||
cardNameLabel->setText(tr("Card name:"));
|
cardNameLabel->setText(tr("Card name:"));
|
||||||
printingLabel->setText(tr("Printing:"));
|
printingLabel->setText(tr("Printing:"));
|
||||||
|
showNumericEditorsCheck->setText(tr("Show numerical editors"));
|
||||||
|
leftMarginLabel->setText(tr("Left margin (%):"));
|
||||||
|
rightMarginLabel->setText(tr("Right margin (%):"));
|
||||||
|
verticalOffsetLabel->setText(tr("Vertical offset:"));
|
||||||
|
zoomLabel->setText(tr("Zoom:"));
|
||||||
controlsGroup->setTitle(tr("Card"));
|
controlsGroup->setTitle(tr("Card"));
|
||||||
previewGroup->setTitle(tr("Crop"));
|
previewGroup->setTitle(tr("Crop"));
|
||||||
previewCaptionLabel->setText(
|
previewCaptionLabel->setText(
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,15 @@
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <libcockatrice/deck_list/deck_list.h>
|
#include <libcockatrice/deck_list/deck_list.h>
|
||||||
|
|
||||||
|
class QCheckBox;
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
class QCompleter;
|
class QCompleter;
|
||||||
|
class QDoubleSpinBox;
|
||||||
class QGroupBox;
|
class QGroupBox;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QLineEdit;
|
class QLineEdit;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
class QWidget;
|
||||||
class CardDatabaseModel;
|
class CardDatabaseModel;
|
||||||
class CardDatabaseDisplayModel;
|
class CardDatabaseDisplayModel;
|
||||||
class CardSearchModel;
|
class CardSearchModel;
|
||||||
|
|
@ -22,7 +25,8 @@ class PlaymatPreviewWidget;
|
||||||
*
|
*
|
||||||
* The crop surface is the primary control: drag to pan the visible art,
|
* The crop surface is the primary control: drag to pan the visible art,
|
||||||
* scroll (or +/- keys) to zoom, arrow keys to nudge. Card name and printing
|
* scroll (or +/- keys) to zoom, arrow keys to nudge. Card name and printing
|
||||||
* are selected below. These gestures edit the same stored PlaymatParams that
|
* are selected below. A checkbox reveals optional numerical editors for the
|
||||||
|
* raw PlaymatParams. These controls edit the same stored PlaymatParams that
|
||||||
* ship in deck files and player properties.
|
* ship in deck files and player properties.
|
||||||
*/
|
*/
|
||||||
class PlaymatSettingsDialog : public QDialog
|
class PlaymatSettingsDialog : public QDialog
|
||||||
|
|
@ -39,6 +43,7 @@ public:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onCardNameChanged(const QString &name);
|
void onCardNameChanged(const QString &name);
|
||||||
|
void onParamChanged();
|
||||||
void reloadPreview();
|
void reloadPreview();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -46,6 +51,7 @@ private:
|
||||||
void populateProviderCombo(const QString &cardName);
|
void populateProviderCombo(const QString &cardName);
|
||||||
void initializeSearchBar();
|
void initializeSearchBar();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
QDoubleSpinBox *makeSpinBox(double min, double max, double value, double step);
|
||||||
|
|
||||||
QLineEdit *searchBar;
|
QLineEdit *searchBar;
|
||||||
QCompleter *completer;
|
QCompleter *completer;
|
||||||
|
|
@ -61,10 +67,21 @@ private:
|
||||||
QLabel *cardNameLabel;
|
QLabel *cardNameLabel;
|
||||||
QLabel *printingLabel;
|
QLabel *printingLabel;
|
||||||
QLabel *previewCaptionLabel;
|
QLabel *previewCaptionLabel;
|
||||||
|
QCheckBox *showNumericEditorsCheck;
|
||||||
|
QWidget *numericEditors;
|
||||||
|
QLabel *leftMarginLabel;
|
||||||
|
QLabel *rightMarginLabel;
|
||||||
|
QLabel *verticalOffsetLabel;
|
||||||
|
QLabel *zoomLabel;
|
||||||
QGroupBox *controlsGroup;
|
QGroupBox *controlsGroup;
|
||||||
QGroupBox *previewGroup;
|
QGroupBox *previewGroup;
|
||||||
QPushButton *removeButton;
|
QPushButton *removeButton;
|
||||||
|
|
||||||
|
QDoubleSpinBox *marginLSpin;
|
||||||
|
QDoubleSpinBox *marginRSpin;
|
||||||
|
QDoubleSpinBox *verticalOffsetSpin;
|
||||||
|
QDoubleSpinBox *zoomSpin;
|
||||||
|
|
||||||
PlaymatPreviewWidget *preview;
|
PlaymatPreviewWidget *preview;
|
||||||
|
|
||||||
QPixmap currentPixmap;
|
QPixmap currentPixmap;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue