mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-23 10: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
|
|
@ -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