mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-03-21 17:55:21 -05:00
[AnalyticsPanel] Move close button to on panel
This commit is contained in:
parent
f3d3fb203e
commit
8ad90bd655
|
|
@ -13,6 +13,16 @@ AbstractAnalyticsPanelWidget::AbstractAnalyticsPanelWidget(QWidget *parent, Deck
|
|||
|
||||
bannerAndSettingsLayout = new QHBoxLayout(bannerAndSettingsContainer);
|
||||
bannerAndSettingsContainer->setLayout(bannerAndSettingsLayout);
|
||||
|
||||
// close button
|
||||
closeButton = new QPushButton(this);
|
||||
closeButton->hide();
|
||||
closeButton->setIcon(QPixmap("theme:icons/close"));
|
||||
closeButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
|
||||
connect(closeButton, &QPushButton::clicked, this, &AbstractAnalyticsPanelWidget::closed);
|
||||
bannerAndSettingsLayout->addWidget(closeButton, 0);
|
||||
|
||||
// banner
|
||||
bannerWidget = new BannerWidget(this, "Analytics Widget", Qt::Vertical, 100);
|
||||
bannerWidget->setMaximumHeight(100);
|
||||
|
||||
|
|
@ -30,6 +40,11 @@ AbstractAnalyticsPanelWidget::AbstractAnalyticsPanelWidget(QWidget *parent, Deck
|
|||
connect(analyzer, &DeckListStatisticsAnalyzer::statsUpdated, this, &AbstractAnalyticsPanelWidget::updateDisplay);
|
||||
}
|
||||
|
||||
void AbstractAnalyticsPanelWidget::setClosable(bool closable)
|
||||
{
|
||||
closeButton->setHidden(!closable);
|
||||
}
|
||||
|
||||
bool AbstractAnalyticsPanelWidget::applyConfigFromDialog()
|
||||
{
|
||||
QDialog *dlg = createConfigDialog(this);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void setClosable(bool closable);
|
||||
|
||||
QString displayTitleText() const
|
||||
{
|
||||
return displayTitle;
|
||||
|
|
@ -54,8 +56,12 @@ protected:
|
|||
QWidget *bannerAndSettingsContainer;
|
||||
QHBoxLayout *bannerAndSettingsLayout;
|
||||
QString displayTitle;
|
||||
QPushButton *closeButton;
|
||||
BannerWidget *bannerWidget;
|
||||
QPushButton *configureButton;
|
||||
|
||||
signals:
|
||||
void closed();
|
||||
};
|
||||
|
||||
#endif // COCKATRICE_DECK_ANALYTICS_WIDGET_BASE_H
|
||||
|
|
|
|||
|
|
@ -25,19 +25,18 @@ DeckAnalyticsWidget::DeckAnalyticsWidget(QWidget *parent, DeckListStatisticsAnal
|
|||
// Controls
|
||||
controlContainer = new QWidget(this);
|
||||
controlLayout = new QHBoxLayout(controlContainer);
|
||||
controlLayout->setContentsMargins(0, 0, 0, 0);
|
||||
addButton = new QPushButton(this);
|
||||
removeButton = new QPushButton(this);
|
||||
saveButton = new QPushButton(this);
|
||||
loadButton = new QPushButton(this);
|
||||
controlLayout->addWidget(addButton);
|
||||
controlLayout->addWidget(removeButton);
|
||||
controlLayout->addWidget(saveButton);
|
||||
controlLayout->addWidget(loadButton);
|
||||
controlLayout->addStretch();
|
||||
|
||||
layout->addWidget(controlContainer);
|
||||
|
||||
connect(addButton, &QPushButton::clicked, this, &DeckAnalyticsWidget::onAddPanel);
|
||||
connect(removeButton, &QPushButton::clicked, this, &DeckAnalyticsWidget::onRemoveSelected);
|
||||
connect(saveButton, &QPushButton::clicked, this, &DeckAnalyticsWidget::saveLayout);
|
||||
connect(loadButton, &QPushButton::clicked, this, &DeckAnalyticsWidget::loadLayout);
|
||||
|
||||
|
|
@ -63,7 +62,6 @@ DeckAnalyticsWidget::DeckAnalyticsWidget(QWidget *parent, DeckListStatisticsAnal
|
|||
void DeckAnalyticsWidget::retranslateUi()
|
||||
{
|
||||
addButton->setText(tr("Add Panel"));
|
||||
removeButton->setText(tr("Remove Panel"));
|
||||
saveButton->setText(tr("Save Layout"));
|
||||
loadButton->setText(tr("Load Layout"));
|
||||
}
|
||||
|
|
@ -111,6 +109,9 @@ void DeckAnalyticsWidget::addPanelInstance(const QString &typeId,
|
|||
|
||||
panelLayout->insertWidget(panelLayout->count() - 1, resPanel);
|
||||
|
||||
panel->setClosable(true);
|
||||
connect(panel, &AbstractAnalyticsPanelWidget::closed, this, [this, resPanel] { onPanelClosed(resPanel); });
|
||||
|
||||
// Event filter for selection
|
||||
resPanel->installEventFilter(this);
|
||||
panel->installEventFilter(this);
|
||||
|
|
@ -119,14 +120,14 @@ void DeckAnalyticsWidget::addPanelInstance(const QString &typeId,
|
|||
connect(resPanel, &ResizablePanel::dropRequested, this, &DeckAnalyticsWidget::onPanelDropped);
|
||||
}
|
||||
|
||||
void DeckAnalyticsWidget::onRemoveSelected()
|
||||
void DeckAnalyticsWidget::onPanelClosed(ResizablePanel *panel)
|
||||
{
|
||||
int idx = indexOfSelectedWrapper();
|
||||
int idx = panelWrappers.indexOf(panel);
|
||||
if (idx < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
ResizablePanel *panel = panelWrappers.takeAt(idx);
|
||||
panelWrappers.removeAt(idx);
|
||||
selectWrapper(nullptr);
|
||||
|
||||
panel->deleteLater();
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
private slots:
|
||||
void onAddPanel();
|
||||
void onRemoveSelected();
|
||||
void onPanelClosed(ResizablePanel *panel);
|
||||
void onPanelDropped(ResizablePanel *dragged, ResizablePanel *target, bool insertBefore);
|
||||
void saveLayout();
|
||||
void loadLayout();
|
||||
|
|
@ -53,7 +53,6 @@ private:
|
|||
QHBoxLayout *controlLayout;
|
||||
|
||||
QPushButton *addButton;
|
||||
QPushButton *removeButton;
|
||||
QPushButton *saveButton;
|
||||
QPushButton *loadButton;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user