Move the "Next/Previous" card buttons to their own widget.

This commit is contained in:
Lukas Brübach 2024-12-01 13:36:02 +01:00 committed by ZeldaZach
parent 059c23f8f4
commit 9d0d62a72d
No known key found for this signature in database
4 changed files with 52 additions and 16 deletions

View file

@ -3,6 +3,7 @@
#include "../../../../settings/cache_settings.h"
#include "../../../../utility/card_set_comparator.h"
#include "printing_selector_card_display_widget.h"
#include "printing_selector_card_selection_widget.h"
#include <QComboBox>
#include <QDebug>
@ -77,18 +78,7 @@ PrintingSelector::PrintingSelector(QWidget *parent,
layout->addWidget(cardSizeWidget);
cardSelectionBar = new QWidget(this);
cardSelectionBarLayout = new QHBoxLayout(cardSelectionBar);
previousCardButton = new QPushButton(cardSelectionBar);
previousCardButton->setText(tr("Previous Card"));
connect(previousCardButton, &QPushButton::clicked, this, &PrintingSelector::selectPreviousCard);
nextCardButton = new QPushButton(cardSelectionBar);
nextCardButton->setText(tr("Next Card"));
connect(nextCardButton, &QPushButton::clicked, this, &PrintingSelector::selectNextCard);
cardSelectionBarLayout->addWidget(previousCardButton);
cardSelectionBarLayout->addWidget(nextCardButton);
cardSelectionBar = new PrintingSelectorCardSelectionWidget(this);
layout->addWidget(cardSelectionBar);
connect(deckModel, &DeckListModel::dataChanged, this, [this]() {

View file

@ -15,6 +15,7 @@
#define BATCH_SIZE 10
class PrintingSelectorCardSelectionWidget;
class TabDeckEditor;
class PrintingSelector : public QWidget
{
@ -54,10 +55,7 @@ private:
QHBoxLayout *cardSizeLayout;
QLabel *cardSizeLabel;
QSlider *cardSizeSlider;
QWidget *cardSelectionBar;
QHBoxLayout *cardSelectionBarLayout;
QPushButton *previousCardButton;
QPushButton *nextCardButton;
PrintingSelectorCardSelectionWidget *cardSelectionBar;
TabDeckEditor *deckEditor;
DeckListModel *deckModel;
QTreeView *deckView;

View file

@ -0,0 +1,22 @@
#include "printing_selector_card_selection_widget.h"
PrintingSelectorCardSelectionWidget::PrintingSelectorCardSelectionWidget(PrintingSelector *parent) : parent(parent)
{
cardSelectionBarLayout = new QHBoxLayout(this);
previousCardButton = new QPushButton(this);
previousCardButton->setText(tr("Previous Card"));
nextCardButton = new QPushButton(this);
nextCardButton->setText(tr("Next Card"));
connectSignals();
cardSelectionBarLayout->addWidget(previousCardButton);
cardSelectionBarLayout->addWidget(nextCardButton);
}
void PrintingSelectorCardSelectionWidget::connectSignals()
{
connect(previousCardButton, &QPushButton::clicked, parent, &PrintingSelector::selectPreviousCard);
connect(nextCardButton, &QPushButton::clicked, parent, &PrintingSelector::selectNextCard);
}

View file

@ -0,0 +1,26 @@
#ifndef PRINTING_SELECTOR_CARD_SELECTION_WIDGET_H
#define PRINTING_SELECTOR_CARD_SELECTION_WIDGET_H
#include "printing_selector.h"
#include <QHBoxLayout>
#include <QPushButton>
#include <QWidget>
class PrintingSelectorCardSelectionWidget : public QWidget
{
Q_OBJECT
public:
explicit PrintingSelectorCardSelectionWidget(PrintingSelector *parent);
void connectSignals();
private:
PrintingSelector *parent;
QHBoxLayout *cardSelectionBarLayout;
QPushButton *previousCardButton;
QPushButton *nextCardButton;
};
#endif // PRINTING_SELECTOR_CARD_SELECTION_WIDGET_H