mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
add option to show keyboard shortcuts in right click menu (#5225)
This commit is contained in:
parent
8d9b27bf47
commit
8cb1470643
7 changed files with 51 additions and 0 deletions
|
|
@ -302,6 +302,8 @@ void GeneralSettingsPage::retranslateUi()
|
|||
AppearanceSettingsPage::AppearanceSettingsPage()
|
||||
{
|
||||
SettingsCache &settings = SettingsCache::instance();
|
||||
|
||||
// Theme settings
|
||||
QString themeName = SettingsCache::instance().getThemeName();
|
||||
|
||||
QStringList themeDirs = themeManager->getAvailableThemes().keys();
|
||||
|
|
@ -322,6 +324,17 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
|||
themeGroupBox = new QGroupBox;
|
||||
themeGroupBox->setLayout(themeGrid);
|
||||
|
||||
// Menu settings
|
||||
showShortcutsCheckBox.setChecked(settings.getShowShortcuts());
|
||||
connect(&showShortcutsCheckBox, &QCheckBox::QT_STATE_CHANGED, this, &AppearanceSettingsPage::showShortcutsChanged);
|
||||
|
||||
auto *menuGrid = new QGridLayout;
|
||||
menuGrid->addWidget(&showShortcutsCheckBox, 0, 0);
|
||||
|
||||
menuGroupBox = new QGroupBox;
|
||||
menuGroupBox->setLayout(menuGrid);
|
||||
|
||||
// Card rendering
|
||||
displayCardNamesCheckBox.setChecked(settings.getDisplayCardNames());
|
||||
connect(&displayCardNamesCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings, &SettingsCache::setDisplayCardNames);
|
||||
|
||||
|
|
@ -342,6 +355,7 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
|||
cardsGroupBox = new QGroupBox;
|
||||
cardsGroupBox->setLayout(cardsGrid);
|
||||
|
||||
// Hand layout
|
||||
horizontalHandCheckBox.setChecked(settings.getHorizontalHand());
|
||||
connect(&horizontalHandCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings, &SettingsCache::setHorizontalHand);
|
||||
|
||||
|
|
@ -355,6 +369,7 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
|||
handGroupBox = new QGroupBox;
|
||||
handGroupBox->setLayout(handGrid);
|
||||
|
||||
// table grid layout
|
||||
invertVerticalCoordinateCheckBox.setChecked(settings.getInvertVerticalCoordinate());
|
||||
connect(&invertVerticalCoordinateCheckBox, &QCheckBox::QT_STATE_CHANGED, &settings,
|
||||
&SettingsCache::setInvertVerticalCoordinate);
|
||||
|
|
@ -381,8 +396,10 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
|||
tableGroupBox = new QGroupBox;
|
||||
tableGroupBox->setLayout(tableGrid);
|
||||
|
||||
// putting it all together
|
||||
auto *mainLayout = new QVBoxLayout;
|
||||
mainLayout->addWidget(themeGroupBox);
|
||||
mainLayout->addWidget(menuGroupBox);
|
||||
mainLayout->addWidget(cardsGroupBox);
|
||||
mainLayout->addWidget(handGroupBox);
|
||||
mainLayout->addWidget(tableGroupBox);
|
||||
|
|
@ -411,12 +428,21 @@ void AppearanceSettingsPage::openThemeLocation()
|
|||
}
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::showShortcutsChanged(QT_STATE_CHANGED_T value)
|
||||
{
|
||||
SettingsCache::instance().setShowShortcuts(value);
|
||||
qApp->setAttribute(Qt::AA_DontShowShortcutsInContextMenus, value == 0); // 0 = unchecked
|
||||
}
|
||||
|
||||
void AppearanceSettingsPage::retranslateUi()
|
||||
{
|
||||
themeGroupBox->setTitle(tr("Theme settings"));
|
||||
themeLabel.setText(tr("Current theme:"));
|
||||
openThemeButton.setText(tr("Open themes folder"));
|
||||
|
||||
menuGroupBox->setTitle(tr("Menu settings"));
|
||||
showShortcutsCheckBox.setText(tr("Show keyboard shortcuts in right-click menus"));
|
||||
|
||||
cardsGroupBox->setTitle(tr("Card rendering"));
|
||||
displayCardNamesCheckBox.setText(tr("Display card names on cards having a picture"));
|
||||
cardScalingCheckBox.setText(tr("Scale cards on mouse over"));
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ class AppearanceSettingsPage : public AbstractSettingsPage
|
|||
private slots:
|
||||
void themeBoxChanged(int index);
|
||||
void openThemeLocation();
|
||||
void showShortcutsChanged(QT_STATE_CHANGED_T enabled);
|
||||
|
||||
private:
|
||||
QLabel themeLabel;
|
||||
|
|
@ -90,6 +91,7 @@ private:
|
|||
QPushButton openThemeButton;
|
||||
QLabel minPlayersForMultiColumnLayoutLabel;
|
||||
QLabel maxFontSizeForCardsLabel;
|
||||
QCheckBox showShortcutsCheckBox;
|
||||
QCheckBox displayCardNamesCheckBox;
|
||||
QCheckBox cardScalingCheckBox;
|
||||
QLabel verticalCardOverlapPercentLabel;
|
||||
|
|
@ -98,6 +100,7 @@ private:
|
|||
QCheckBox leftJustifiedHandCheckBox;
|
||||
QCheckBox invertVerticalCoordinateCheckBox;
|
||||
QGroupBox *themeGroupBox;
|
||||
QGroupBox *menuGroupBox;
|
||||
QGroupBox *cardsGroupBox;
|
||||
QGroupBox *handGroupBox;
|
||||
QGroupBox *tableGroupBox;
|
||||
|
|
|
|||
|
|
@ -180,6 +180,9 @@ int main(int argc, char *argv[])
|
|||
ui.show();
|
||||
qDebug("main(): ui.show() finished");
|
||||
|
||||
// force shortcuts to be shown/hidden in right-click menus, regardless of system defaults
|
||||
qApp->setAttribute(Qt::AA_DontShowShortcutsInContextMenus, !SettingsCache::instance().getShowShortcuts());
|
||||
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
|
||||
app.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -239,6 +239,7 @@ SettingsCache::SettingsCache()
|
|||
knownMissingFeatures = settings->value("interface/knownmissingfeatures", "").toString();
|
||||
useTearOffMenus = settings->value("interface/usetearoffmenus", true).toBool();
|
||||
|
||||
showShortcuts = settings->value("menu/showshortcuts", true).toBool();
|
||||
displayCardNames = settings->value("cards/displaycardnames", true).toBool();
|
||||
horizontalHand = settings->value("hand/horizontal", true).toBool();
|
||||
invertVerticalCoordinate = settings->value("table/invert_vertical", false).toBool();
|
||||
|
|
@ -506,6 +507,12 @@ void SettingsCache::setTabGameSplitterSizes(const QByteArray &_tabGameSplitterSi
|
|||
settings->setValue("interface/tabgame_splittersizes", tabGameSplitterSizes);
|
||||
}
|
||||
|
||||
void SettingsCache::setShowShortcuts(QT_STATE_CHANGED_T _showShortcuts)
|
||||
{
|
||||
showShortcuts = static_cast<bool>(_showShortcuts);
|
||||
settings->setValue("menu/showshortcuts", showShortcuts);
|
||||
}
|
||||
|
||||
void SettingsCache::setDisplayCardNames(QT_STATE_CHANGED_T _displayCardNames)
|
||||
{
|
||||
displayCardNames = static_cast<bool>(_displayCardNames);
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ private:
|
|||
int startingHandSize;
|
||||
bool annotateTokens;
|
||||
QByteArray tabGameSplitterSizes;
|
||||
bool showShortcuts;
|
||||
bool displayCardNames;
|
||||
bool horizontalHand;
|
||||
bool invertVerticalCoordinate;
|
||||
|
|
@ -289,6 +290,10 @@ public:
|
|||
{
|
||||
return tabGameSplitterSizes;
|
||||
}
|
||||
bool getShowShortcuts() const
|
||||
{
|
||||
return showShortcuts;
|
||||
}
|
||||
bool getDisplayCardNames() const
|
||||
{
|
||||
return displayCardNames;
|
||||
|
|
@ -565,6 +570,7 @@ public slots:
|
|||
void setStartingHandSize(int _startingHandSize);
|
||||
void setAnnotateTokens(QT_STATE_CHANGED_T _annotateTokens);
|
||||
void setTabGameSplitterSizes(const QByteArray &_tabGameSplitterSizes);
|
||||
void setShowShortcuts(QT_STATE_CHANGED_T _showShortcuts);
|
||||
void setDisplayCardNames(QT_STATE_CHANGED_T _displayCardNames);
|
||||
void setHorizontalHand(QT_STATE_CHANGED_T _horizontalHand);
|
||||
void setInvertVerticalCoordinate(QT_STATE_CHANGED_T _invertVerticalCoordinate);
|
||||
|
|
|
|||
|
|
@ -148,6 +148,9 @@ void SettingsCache::setAnnotateTokens(QT_STATE_CHANGED_T /* _annotateTokens */)
|
|||
void SettingsCache::setTabGameSplitterSizes(const QByteArray & /* _tabGameSplitterSizes */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setShowShortcuts(QT_STATE_CHANGED_T /* _showShortcuts */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setDisplayCardNames(QT_STATE_CHANGED_T /* _displayCardNames */)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,6 +152,9 @@ void SettingsCache::setAnnotateTokens(QT_STATE_CHANGED_T /* _annotateTokens */)
|
|||
void SettingsCache::setTabGameSplitterSizes(const QByteArray & /* _tabGameSplitterSizes */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setShowShortcuts(QT_STATE_CHANGED_T /* _showShortcuts */)
|
||||
{
|
||||
}
|
||||
void SettingsCache::setDisplayCardNames(QT_STATE_CHANGED_T /* _displayCardNames */)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue