From 44800df89c0136afcf41666de7c42644da38d382 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Thu, 14 May 2015 13:12:24 +0200 Subject: [PATCH] Reworked the layout of "edit sets" window --- cockatrice/cockatrice.qrc | 5 + cockatrice/resources/arrow_bottom_green.svg | 793 ++++++++++++++++++++ cockatrice/resources/arrow_down_green.svg | 793 ++++++++++++++++++++ cockatrice/resources/arrow_top_green.svg | 793 ++++++++++++++++++++ cockatrice/resources/arrow_up_green.svg | 792 +++++++++++++++++++ cockatrice/src/window_sets.cpp | 103 +-- cockatrice/src/window_sets.h | 4 +- 7 files changed, 3234 insertions(+), 49 deletions(-) create mode 100644 cockatrice/resources/arrow_bottom_green.svg create mode 100644 cockatrice/resources/arrow_down_green.svg create mode 100644 cockatrice/resources/arrow_top_green.svg create mode 100644 cockatrice/resources/arrow_up_green.svg diff --git a/cockatrice/cockatrice.qrc b/cockatrice/cockatrice.qrc index 944e239f..0300a74f 100644 --- a/cockatrice/cockatrice.qrc +++ b/cockatrice/cockatrice.qrc @@ -38,6 +38,11 @@ resources/remove_row.svg resources/arrow_left_green.svg resources/arrow_right_green.svg + + resources/arrow_top_green.svg + resources/arrow_up_green.svg + resources/arrow_down_green.svg + resources/arrow_bottom_green.svg resources/icon_ready_start.svg resources/icon_not_ready_start.svg diff --git a/cockatrice/resources/arrow_bottom_green.svg b/cockatrice/resources/arrow_bottom_green.svg new file mode 100644 index 00000000..3a45053a --- /dev/null +++ b/cockatrice/resources/arrow_bottom_green.svg @@ -0,0 +1,793 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/cockatrice/resources/arrow_down_green.svg b/cockatrice/resources/arrow_down_green.svg new file mode 100644 index 00000000..574c1206 --- /dev/null +++ b/cockatrice/resources/arrow_down_green.svg @@ -0,0 +1,793 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/cockatrice/resources/arrow_top_green.svg b/cockatrice/resources/arrow_top_green.svg new file mode 100644 index 00000000..c515c6a1 --- /dev/null +++ b/cockatrice/resources/arrow_top_green.svg @@ -0,0 +1,793 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/cockatrice/resources/arrow_up_green.svg b/cockatrice/resources/arrow_up_green.svg new file mode 100644 index 00000000..1d0f6111 --- /dev/null +++ b/cockatrice/resources/arrow_up_green.svg @@ -0,0 +1,792 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/cockatrice/src/window_sets.cpp b/cockatrice/src/window_sets.cpp index b5178421..db486f06 100644 --- a/cockatrice/src/window_sets.cpp +++ b/cockatrice/src/window_sets.cpp @@ -10,10 +10,48 @@ #include #include #include +#include +#include +#include WndSets::WndSets(QWidget *parent) : QMainWindow(parent) { + // left toolbar + QToolBar *setsEditToolBar = new QToolBar; + setsEditToolBar->setOrientation(Qt::Vertical); + setsEditToolBar->setIconSize(QSize(24, 24)); + setsEditToolBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + + aTop = new QAction(QString(), this); + aTop->setIcon(QIcon(":/resources/arrow_top_green.svg")); + aTop->setToolTip(tr("Move selected set to top")); + aTop->setEnabled(false); + connect(aTop, SIGNAL(triggered()), this, SLOT(actTop())); + setsEditToolBar->addAction(aTop); + + aUp = new QAction(QString(), this); + aUp->setIcon(QIcon(":/resources/arrow_up_green.svg")); + aUp->setToolTip(tr("Move selected set up")); + aUp->setEnabled(false); + connect(aUp, SIGNAL(triggered()), this, SLOT(actUp())); + setsEditToolBar->addAction(aUp); + + aDown = new QAction(QString(), this); + aDown->setIcon(QIcon(":/resources/arrow_down_green.svg")); + aDown->setToolTip(tr("Move selected set down")); + aDown->setEnabled(false); + connect(aDown, SIGNAL(triggered()), this, SLOT(actDown())); + setsEditToolBar->addAction(aDown); + + aBottom = new QAction(QString(), this); + aBottom->setIcon(QIcon(":/resources/arrow_bottom_green.svg")); + aBottom->setToolTip(tr("Move selected set to bottom")); + aBottom->setEnabled(false); + connect(aBottom, SIGNAL(triggered()), this, SLOT(actBottom())); + setsEditToolBar->addAction(aBottom); + + // view model = new SetsModel(db, this); view = new QTreeView; view->setModel(model); @@ -43,59 +81,32 @@ WndSets::WndSets(QWidget *parent) view->setColumnHidden(SetsModel::IsKnownCol, true); view->setRootIsDecorated(false); - enableButton = new QPushButton(tr("Enable set")); - connect(enableButton, SIGNAL(clicked()), this, SLOT(actEnable())); - disableButton = new QPushButton(tr("Disable set")); - connect(disableButton, SIGNAL(clicked()), this, SLOT(actDisable())); + connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), + this, SLOT(actToggleButtons(const QItemSelection &, const QItemSelection &))); + + // bottom buttons enableAllButton = new QPushButton(tr("Enable all sets")); connect(enableAllButton, SIGNAL(clicked()), this, SLOT(actEnableAll())); disableAllButton = new QPushButton(tr("Disable all sets")); connect(disableAllButton, SIGNAL(clicked()), this, SLOT(actDisableAll())); - upButton = new QPushButton(tr("Move selected set up")); - connect(upButton, SIGNAL(clicked()), this, SLOT(actUp())); - downButton = new QPushButton(tr("Move selected set down")); - connect(downButton, SIGNAL(clicked()), this, SLOT(actDown())); - topButton = new QPushButton(tr("Move selected set to top")); - connect(topButton, SIGNAL(clicked()), this, SLOT(actTop())); - bottomButton = new QPushButton(tr("Move selected set to bottom")); - connect(bottomButton, SIGNAL(clicked()), this, SLOT(actBottom())); - enableButton->setDisabled(true); - disableButton->setDisabled(true); - upButton->setDisabled(true); - downButton->setDisabled(true); - topButton->setDisabled(true); - bottomButton->setDisabled(true); - - connect(view->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), - this, SLOT(actToggleButtons(const QItemSelection &, const QItemSelection &))); - - QGroupBox *toggleFrame = new QGroupBox(tr("Enable sets")); - QVBoxLayout *toggleVBox = new QVBoxLayout; - toggleVBox->addWidget(enableButton); - toggleVBox->addWidget(disableButton); - toggleVBox->addWidget(enableAllButton); - toggleVBox->addWidget(disableAllButton); - toggleFrame->setLayout(toggleVBox); - - QGroupBox *sortFrame = new QGroupBox(tr("Sort sets")); - QVBoxLayout *sortVBox = new QVBoxLayout; - sortVBox->addWidget(upButton); - sortVBox->addWidget(downButton); - sortVBox->addWidget(topButton); - sortVBox->addWidget(bottomButton); - sortFrame->setLayout(sortVBox); + QLabel *labNotes = new QLabel; + labNotes->setText("Enable the sets that you want to have available in the deck editor.\nMove sets around to change their order, or click on a column header to sort sets on that field.\nSets order decides the source that will be used when loading images for a specific card.\nDisabled sets will still be used for loading images."); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); connect(buttonBox, SIGNAL(accepted()), this, SLOT(actSave())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(actRestore())); QGridLayout *mainLayout = new QGridLayout; - mainLayout->addWidget(view, 0, 0, 1, 2); - mainLayout->addWidget(toggleFrame, 1, 0, 1, 1); - mainLayout->addWidget(sortFrame, 1, 1, 1, 1); - mainLayout->addWidget(buttonBox, 2, 0, 1, 2); + mainLayout->addWidget(setsEditToolBar, 0, 0, 1, 1); + mainLayout->addWidget(view, 0, 1, 1, 2); + mainLayout->addWidget(enableAllButton, 1, 1, 1, 1); + mainLayout->addWidget(disableAllButton, 1, 2, 1, 1); + mainLayout->addWidget(labNotes, 2, 1, 1, 2); + mainLayout->addWidget(buttonBox, 3, 1, 1, 2); + mainLayout->setColumnStretch(1, 1); + mainLayout->setColumnStretch(2, 1); QWidget *centralWidget = new QWidget; centralWidget->setLayout(mainLayout); @@ -125,12 +136,10 @@ void WndSets::actRestore() void WndSets::actToggleButtons(const QItemSelection & selected, const QItemSelection &) { bool disabled = selected.empty(); - upButton->setDisabled(disabled); - downButton->setDisabled(disabled); - topButton->setDisabled(disabled); - bottomButton->setDisabled(disabled); - enableButton->setDisabled(disabled); - disableButton->setDisabled(disabled); + aTop->setDisabled(disabled); + aUp->setDisabled(disabled); + aDown->setDisabled(disabled); + aBottom->setDisabled(disabled); } void WndSets::selectRow(int row) diff --git a/cockatrice/src/window_sets.h b/cockatrice/src/window_sets.h index cd341cdb..0d57a62d 100644 --- a/cockatrice/src/window_sets.h +++ b/cockatrice/src/window_sets.h @@ -15,8 +15,8 @@ class WndSets : public QMainWindow { private: SetsModel *model; QTreeView *view; - QPushButton *enableButton, *disableButton, *enableAllButton, *disableAllButton, - *upButton, *downButton, *bottomButton, *topButton; + QPushButton *enableAllButton, *disableAllButton; + QAction *aUp, *aDown, *aBottom, *aTop; public: WndSets(QWidget *parent = 0); ~WndSets();