mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Add option to open deck in new tab by default (#5143)
* add comments * add new setting for openDeckInNewTab * implement open deck in new tab * rename setting * fix typo * set default to false
This commit is contained in:
parent
c54f47efbf
commit
c2fe3cda35
9 changed files with 64 additions and 6 deletions
|
|
@ -765,6 +765,11 @@ void TabDeckEditor::closeRequest()
|
|||
|
||||
void TabDeckEditor::actNewDeck()
|
||||
{
|
||||
if (SettingsCache::instance().getOpenDeckInNewTab()) {
|
||||
emit openDeckEditor(nullptr);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirmClose())
|
||||
return;
|
||||
|
||||
|
|
@ -778,7 +783,9 @@ void TabDeckEditor::actNewDeck()
|
|||
|
||||
void TabDeckEditor::actLoadDeck()
|
||||
{
|
||||
if (!confirmClose())
|
||||
bool openInNewTab = SettingsCache::instance().getOpenDeckInNewTab();
|
||||
|
||||
if (!openInNewTab && !confirmClose())
|
||||
return;
|
||||
|
||||
QFileDialog dialog(this, tr("Load deck"));
|
||||
|
|
@ -792,8 +799,12 @@ void TabDeckEditor::actLoadDeck()
|
|||
|
||||
auto *l = new DeckLoader;
|
||||
if (l->loadFromFile(fileName, fmt)) {
|
||||
setSaveStatus(false);
|
||||
setDeck(l);
|
||||
if (openInNewTab) {
|
||||
emit openDeckEditor(l);
|
||||
} else {
|
||||
setSaveStatus(false);
|
||||
setDeck(l);
|
||||
}
|
||||
} else
|
||||
delete l;
|
||||
setSaveStatus(true);
|
||||
|
|
@ -865,15 +876,22 @@ bool TabDeckEditor::actSaveDeckAs()
|
|||
|
||||
void TabDeckEditor::actLoadDeckFromClipboard()
|
||||
{
|
||||
if (!confirmClose())
|
||||
bool openInNewTab = SettingsCache::instance().getOpenDeckInNewTab();
|
||||
|
||||
if (!openInNewTab && !confirmClose())
|
||||
return;
|
||||
|
||||
DlgLoadDeckFromClipboard dlg(this);
|
||||
if (!dlg.exec())
|
||||
return;
|
||||
|
||||
setDeck(dlg.getDeckList());
|
||||
setModified(true);
|
||||
if (openInNewTab) {
|
||||
emit openDeckEditor(dlg.getDeckList());
|
||||
} else {
|
||||
setDeck(dlg.getDeckList());
|
||||
setModified(true);
|
||||
}
|
||||
|
||||
setSaveStatus(true);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ public:
|
|||
public slots:
|
||||
void closeRequest() override;
|
||||
signals:
|
||||
void openDeckEditor(const DeckLoader *deckLoader);
|
||||
void deckEditorClosing(TabDeckEditor *tab);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -496,6 +496,7 @@ TabDeckEditor *TabSupervisor::addDeckEditorTab(const DeckLoader *deckToOpen)
|
|||
if (deckToOpen)
|
||||
tab->setDeck(new DeckLoader(*deckToOpen));
|
||||
connect(tab, SIGNAL(deckEditorClosing(TabDeckEditor *)), this, SLOT(deckEditorClosed(TabDeckEditor *)));
|
||||
connect(tab, SIGNAL(openDeckEditor(const DeckLoader *)), this, SLOT(addDeckEditorTab(const DeckLoader *)));
|
||||
int tabIndex = myAddTab(tab);
|
||||
addCloseButtonToTab(tab, tabIndex);
|
||||
deckEditorTabs.append(tab);
|
||||
|
|
|
|||
|
|
@ -440,6 +440,7 @@ void AppearanceSettingsPage::retranslateUi()
|
|||
|
||||
UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||
{
|
||||
// general settings and notification settings
|
||||
notificationsEnabledCheckBox.setChecked(SettingsCache::instance().getNotificationsEnabled());
|
||||
connect(¬ificationsEnabledCheckBox, SIGNAL(QT_STATE_CHANGED(QT_STATE_CHANGED_T)), &SettingsCache::instance(),
|
||||
SLOT(setNotificationsEnabled(QT_STATE_CHANGED_T)));
|
||||
|
|
@ -490,6 +491,7 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
|||
notificationsGroupBox = new QGroupBox;
|
||||
notificationsGroupBox->setLayout(notificationsGrid);
|
||||
|
||||
// animation settings
|
||||
tapAnimationCheckBox.setChecked(SettingsCache::instance().getTapAnimation());
|
||||
connect(&tapAnimationCheckBox, SIGNAL(QT_STATE_CHANGED(QT_STATE_CHANGED_T)), &SettingsCache::instance(),
|
||||
SLOT(setTapAnimation(QT_STATE_CHANGED_T)));
|
||||
|
|
@ -500,10 +502,23 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
|||
animationGroupBox = new QGroupBox;
|
||||
animationGroupBox->setLayout(animationGrid);
|
||||
|
||||
// deck editor settings
|
||||
openDeckInNewTabCheckBox.setChecked(SettingsCache::instance().getOpenDeckInNewTab());
|
||||
connect(&openDeckInNewTabCheckBox, SIGNAL(QT_STATE_CHANGED(QT_STATE_CHANGED_T)), &SettingsCache::instance(),
|
||||
SLOT(setOpenDeckInNewTab(QT_STATE_CHANGED_T)));
|
||||
|
||||
auto *deckEditorGrid = new QGridLayout;
|
||||
deckEditorGrid->addWidget(&openDeckInNewTabCheckBox, 0, 0);
|
||||
|
||||
deckEditorGroupBox = new QGroupBox;
|
||||
deckEditorGroupBox->setLayout(deckEditorGrid);
|
||||
|
||||
// putting it all together
|
||||
auto *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(generalGroupBox);
|
||||
mainLayout->addWidget(notificationsGroupBox);
|
||||
mainLayout->addWidget(animationGroupBox);
|
||||
mainLayout->addWidget(deckEditorGroupBox);
|
||||
mainLayout->addStretch();
|
||||
|
||||
setLayout(mainLayout);
|
||||
|
|
@ -532,6 +547,8 @@ void UserInterfaceSettingsPage::retranslateUi()
|
|||
buddyConnectNotificationsEnabledCheckBox.setText(tr("Notify in the taskbar when users in your buddy list connect"));
|
||||
animationGroupBox->setTitle(tr("Animation settings"));
|
||||
tapAnimationCheckBox.setText(tr("&Tap/untap animation"));
|
||||
deckEditorGroupBox->setTitle(tr("Deck editor settings"));
|
||||
openDeckInNewTabCheckBox.setText(tr("Always open deck in new tab"));
|
||||
}
|
||||
|
||||
DeckEditorSettingsPage::DeckEditorSettingsPage()
|
||||
|
|
|
|||
|
|
@ -124,9 +124,11 @@ private:
|
|||
QCheckBox annotateTokensCheckBox;
|
||||
QCheckBox useTearOffMenusCheckBox;
|
||||
QCheckBox tapAnimationCheckBox;
|
||||
QCheckBox openDeckInNewTabCheckBox;
|
||||
QGroupBox *generalGroupBox;
|
||||
QGroupBox *notificationsGroupBox;
|
||||
QGroupBox *animationGroupBox;
|
||||
QGroupBox *deckEditorGroupBox;
|
||||
|
||||
public:
|
||||
UserInterfaceSettingsPage();
|
||||
|
|
|
|||
|
|
@ -243,6 +243,7 @@ SettingsCache::SettingsCache()
|
|||
invertVerticalCoordinate = settings->value("table/invert_vertical", false).toBool();
|
||||
minPlayersForMultiColumnLayout = settings->value("interface/min_players_multicolumn", 4).toInt();
|
||||
tapAnimation = settings->value("cards/tapanimation", true).toBool();
|
||||
openDeckInNewTab = settings->value("editor/openDeckInNewTab", false).toBool();
|
||||
chatMention = settings->value("chat/mention", true).toBool();
|
||||
chatMentionCompleter = settings->value("chat/mentioncompleter", true).toBool();
|
||||
chatMentionForeground = settings->value("chat/mentionforeground", true).toBool();
|
||||
|
|
@ -537,6 +538,12 @@ void SettingsCache::setTapAnimation(QT_STATE_CHANGED_T _tapAnimation)
|
|||
settings->setValue("cards/tapanimation", tapAnimation);
|
||||
}
|
||||
|
||||
void SettingsCache::setOpenDeckInNewTab(QT_STATE_CHANGED_T _openDeckInNewTab)
|
||||
{
|
||||
openDeckInNewTab = static_cast<bool>(_openDeckInNewTab);
|
||||
settings->setValue("editor/openDeckInNewTab", openDeckInNewTab);
|
||||
}
|
||||
|
||||
void SettingsCache::setChatMention(QT_STATE_CHANGED_T _chatMention)
|
||||
{
|
||||
chatMention = static_cast<bool>(_chatMention);
|
||||
|
|
|
|||
|
|
@ -96,6 +96,7 @@ private:
|
|||
bool invertVerticalCoordinate;
|
||||
int minPlayersForMultiColumnLayout;
|
||||
bool tapAnimation;
|
||||
bool openDeckInNewTab;
|
||||
bool chatMention;
|
||||
bool chatMentionCompleter;
|
||||
QString chatMentionColor;
|
||||
|
|
@ -295,6 +296,10 @@ public:
|
|||
{
|
||||
return tapAnimation;
|
||||
}
|
||||
bool getOpenDeckInNewTab() const
|
||||
{
|
||||
return openDeckInNewTab;
|
||||
}
|
||||
bool getChatMention() const
|
||||
{
|
||||
return chatMention;
|
||||
|
|
@ -538,6 +543,7 @@ public slots:
|
|||
void setInvertVerticalCoordinate(QT_STATE_CHANGED_T _invertVerticalCoordinate);
|
||||
void setMinPlayersForMultiColumnLayout(int _minPlayersForMultiColumnLayout);
|
||||
void setTapAnimation(QT_STATE_CHANGED_T _tapAnimation);
|
||||
void setOpenDeckInNewTab(QT_STATE_CHANGED_T _openDeckInNewTab);
|
||||
void setChatMention(QT_STATE_CHANGED_T _chatMention);
|
||||
void setChatMentionCompleter(QT_STATE_CHANGED_T _chatMentionCompleter);
|
||||
void setChatMentionForeground(QT_STATE_CHANGED_T _chatMentionForeground);
|
||||
|
|
|
|||
|
|
@ -163,6 +163,9 @@ void SettingsCache::setMinPlayersForMultiColumnLayout(int /* _minPlayersForMulti
|
|||
void SettingsCache::setTapAnimation(QT_STATE_CHANGED_T /* _tapAnimation */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setOpenDeckInNewTab(QT_STATE_CHANGED_T /* _openDeckInNewTab */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setChatMention(QT_STATE_CHANGED_T /* _chatMention */)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,6 +167,9 @@ void SettingsCache::setMinPlayersForMultiColumnLayout(int /* _minPlayersForMulti
|
|||
void SettingsCache::setTapAnimation(QT_STATE_CHANGED_T /* _tapAnimation */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setOpenDeckInNewTab(QT_STATE_CHANGED_T /* _openDeckInNewTab */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setChatMention(QT_STATE_CHANGED_T /* _chatMention */)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue