mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 09:05:10 -07:00
[VDE] Add a new setting to determine initial tab (Context/Deck/Database) (#7122)
* [VDE] Add a new setting to determine initial tab (Context/Deck/Database) Took 16 minutes Took 4 seconds * Adjust tooltip Took 4 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
6ee1fd58e6
commit
fbe5c4ade0
9 changed files with 108 additions and 5 deletions
|
|
@ -183,6 +183,13 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
|||
connect(&defaultDeckEditorTypeSelector, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
&SettingsCache::instance().deckEditor(), &DeckEditorSettings::setDefaultDeckEditorType);
|
||||
|
||||
vdeStartupTabSelector.addItem(""); // these will be set in retranslateUI
|
||||
vdeStartupTabSelector.addItem("");
|
||||
vdeStartupTabSelector.addItem("");
|
||||
vdeStartupTabSelector.setCurrentIndex(SettingsCache::instance().deckEditor().getVdeStartupTab());
|
||||
connect(&vdeStartupTabSelector, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
&SettingsCache::instance().deckEditor(), &DeckEditorSettings::setVdeStartupTab);
|
||||
|
||||
commanderSpellbookIntegrationUseOfficialBracketNamesExplainer.setText("?");
|
||||
commanderSpellbookIntegrationUseOfficialBracketNamesExplainer.setAutoRaise(true);
|
||||
commanderSpellbookIntegrationUseOfficialBracketNamesExplainer.setEnabled(false);
|
||||
|
|
@ -242,10 +249,12 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
|||
deckEditorGrid->addWidget(&visualDeckStoragePromptForConversionSelector, 3, 1);
|
||||
deckEditorGrid->addWidget(&defaultDeckEditorTypeLabel, 4, 0);
|
||||
deckEditorGrid->addWidget(&defaultDeckEditorTypeSelector, 4, 1);
|
||||
deckEditorGrid->addWidget(&commanderSpellbookIntegrationEnabledLabel, 5, 0);
|
||||
deckEditorGrid->addWidget(&commanderSpellbookIntegrationEnabledSelector, 5, 1);
|
||||
deckEditorGrid->addWidget(labelWidget, 6, 0);
|
||||
deckEditorGrid->addWidget(&commanderSpellbookIntegrationBracketNamingSelector, 6, 1);
|
||||
deckEditorGrid->addWidget(&vdeStartupTabLabel, 5, 0);
|
||||
deckEditorGrid->addWidget(&vdeStartupTabSelector, 5, 1);
|
||||
deckEditorGrid->addWidget(&commanderSpellbookIntegrationEnabledLabel, 6, 0);
|
||||
deckEditorGrid->addWidget(&commanderSpellbookIntegrationEnabledSelector, 6, 1);
|
||||
deckEditorGrid->addWidget(labelWidget, 7, 0);
|
||||
deckEditorGrid->addWidget(&commanderSpellbookIntegrationBracketNamingSelector, 7, 1);
|
||||
|
||||
deckEditorGroupBox = new QGroupBox;
|
||||
deckEditorGroupBox->setLayout(deckEditorGrid);
|
||||
|
|
@ -368,6 +377,12 @@ void UserInterfaceSettingsPage::retranslateUi()
|
|||
defaultDeckEditorTypeLabel.setText(tr("Default deck editor type"));
|
||||
defaultDeckEditorTypeSelector.setItemText(TabSupervisor::ClassicDeckEditor, tr("Classic Deck Editor"));
|
||||
defaultDeckEditorTypeSelector.setItemText(TabSupervisor::VisualDeckEditor, tr("Visual Deck Editor"));
|
||||
vdeStartupTabLabel.setText(tr("Visual deck editor startup tab"));
|
||||
vdeStartupTabSelector.setItemText(VdeStartupTabContext, tr("Context"));
|
||||
vdeStartupTabSelector.setItemText(VdeStartupTabDeckDisplay, tr("Deck display"));
|
||||
vdeStartupTabSelector.setItemText(VdeStartupTabDatabaseDisplay, tr("Database display"));
|
||||
vdeStartupTabSelector.setToolTip(
|
||||
tr("Context mode: New decks open on the database display, existing decks open on the deck view."));
|
||||
|
||||
commanderSpellbookIntegrationEnabledLabel.setText(
|
||||
tr("CommanderSpellbook integration to estimate commander bracket"));
|
||||
|
|
|
|||
|
|
@ -50,6 +50,8 @@ private:
|
|||
QCheckBox visualDeckStorageSelectionAnimationCheckBox;
|
||||
QLabel defaultDeckEditorTypeLabel;
|
||||
QComboBox defaultDeckEditorTypeSelector;
|
||||
QLabel vdeStartupTabLabel;
|
||||
QComboBox vdeStartupTabSelector;
|
||||
QLabel commanderSpellbookIntegrationEnabledLabel;
|
||||
QComboBox commanderSpellbookIntegrationEnabledSelector;
|
||||
QLabel commanderSpellbookIntegrationUseOfficialBracketNamesLabel;
|
||||
|
|
|
|||
|
|
@ -263,12 +263,12 @@ protected slots:
|
|||
/** @brief Handles dock close events. */
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
/** @brief Sets the deck for this tab.
|
||||
* @param _deck The deck object.
|
||||
*/
|
||||
virtual void setDeck(const LoadedDeck &_deck);
|
||||
|
||||
private:
|
||||
/** @brief Helper for editing decks from the clipboard. */
|
||||
void editDeckInClipboard(bool annotated);
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include <libcockatrice/models/deck_list/deck_list_model.h>
|
||||
#include <libcockatrice/protocol/pb/command_deck_upload.pb.h>
|
||||
#include <libcockatrice/protocol/pending_command.h>
|
||||
#include <libcockatrice/settings/deck_editor_settings.h>
|
||||
#include <libcockatrice/settings/layouts_settings.h>
|
||||
|
||||
/**
|
||||
|
|
@ -98,6 +99,33 @@ void TabDeckEditorVisual::onDeckChanged()
|
|||
tabContainer->sampleHandWidget->setDeckModel(deckStateManager->getModel());
|
||||
}
|
||||
|
||||
/** @brief Sets the deck and selects the startup sub-tab matching the context. */
|
||||
void TabDeckEditorVisual::setDeck(const LoadedDeck &_deck)
|
||||
{
|
||||
AbstractTabDeckEditor::setDeck(_deck);
|
||||
|
||||
int startupTab = SettingsCache::instance().deckEditor().getVdeStartupTab();
|
||||
if (startupTab == VdeStartupTabContext) {
|
||||
// New (empty) decks open on the database display so cards can be added
|
||||
// right away. Existing decks open on the deck view.
|
||||
startupTab = _deck.isEmpty() ? VdeStartupTabDatabaseDisplay : VdeStartupTabDeckDisplay;
|
||||
}
|
||||
|
||||
switch (startupTab) {
|
||||
case VdeStartupTabDatabaseDisplay:
|
||||
tabContainer->setCurrentIndex(TabDeckEditorVisualTabWidget::TabIndex::VisualDatabaseDisplay);
|
||||
break;
|
||||
case VdeStartupTabDeckDisplay:
|
||||
tabContainer->setCurrentIndex(TabDeckEditorVisualTabWidget::TabIndex::VisualDeckView);
|
||||
break;
|
||||
default:
|
||||
qCWarning(TabSupervisorLog) << "Unknown VdeStartupTab [" << startupTab
|
||||
<< "]; falling back to the deck view";
|
||||
tabContainer->setCurrentIndex(TabDeckEditorVisualTabWidget::TabIndex::VisualDeckView);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** @brief Creates menus for deck editing and view options, including dock actions. */
|
||||
void TabDeckEditorVisual::createMenus()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -164,6 +164,15 @@ public slots:
|
|||
* @return true if successful, false otherwise.
|
||||
*/
|
||||
bool actSaveDeckAs() override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Sets the deck for this tab and selects the sub-tab to open on
|
||||
* startup, per the "Visual deck editor startup tab" setting (Context /
|
||||
* Deck display / Database display).
|
||||
* @param _deck The deck object.
|
||||
*/
|
||||
void setDeck(const LoadedDeck &_deck) override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -49,6 +49,17 @@ class TabDeckEditorVisualTabWidget : public QTabWidget
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Sub-tab order in the container; addNewTab() is called in this order.
|
||||
*/
|
||||
enum TabIndex
|
||||
{
|
||||
VisualDeckView,
|
||||
VisualDatabaseDisplay,
|
||||
DeckAnalytics,
|
||||
SampleHand,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Construct the tab widget with required models.
|
||||
* @param parent Parent widget.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue