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