mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-01 11:03:54 -07:00
Make settings window scrollable (#5539)
This commit is contained in:
parent
b1b48d50f3
commit
26c0cdc072
2 changed files with 38 additions and 14 deletions
|
|
@ -34,6 +34,8 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QRadioButton>
|
#include <QRadioButton>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
|
#include <QScrollArea>
|
||||||
|
#include <QScrollBar>
|
||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
|
|
@ -181,6 +183,9 @@ GeneralSettingsPage::GeneralSettingsPage()
|
||||||
updateReleaseChannelBox.setCurrentIndex(settings.getUpdateReleaseChannelIndex());
|
updateReleaseChannelBox.setCurrentIndex(settings.getUpdateReleaseChannelIndex());
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
|
connect(&SettingsCache::instance(), &SettingsCache::langChanged, this, &GeneralSettingsPage::retranslateUi);
|
||||||
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList GeneralSettingsPage::findQmFiles()
|
QStringList GeneralSettingsPage::findQmFiles()
|
||||||
|
|
@ -464,6 +469,9 @@ AppearanceSettingsPage::AppearanceSettingsPage()
|
||||||
mainLayout->addStretch();
|
mainLayout->addStretch();
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
|
connect(&SettingsCache::instance(), &SettingsCache::langChanged, this, &AppearanceSettingsPage::retranslateUi);
|
||||||
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppearanceSettingsPage::themeBoxChanged(int index)
|
void AppearanceSettingsPage::themeBoxChanged(int index)
|
||||||
|
|
@ -648,6 +656,9 @@ UserInterfaceSettingsPage::UserInterfaceSettingsPage()
|
||||||
mainLayout->addStretch();
|
mainLayout->addStretch();
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
|
connect(&SettingsCache::instance(), &SettingsCache::langChanged, this, &UserInterfaceSettingsPage::retranslateUi);
|
||||||
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserInterfaceSettingsPage::setNotificationEnabled(QT_STATE_CHANGED_T i)
|
void UserInterfaceSettingsPage::setNotificationEnabled(QT_STATE_CHANGED_T i)
|
||||||
|
|
@ -820,6 +831,9 @@ DeckEditorSettingsPage::DeckEditorSettingsPage()
|
||||||
lpMainLayout->addWidget(mpSpoilerGroupBox);
|
lpMainLayout->addWidget(mpSpoilerGroupBox);
|
||||||
|
|
||||||
setLayout(lpMainLayout);
|
setLayout(lpMainLayout);
|
||||||
|
|
||||||
|
connect(&SettingsCache::instance(), &SettingsCache::langChanged, this, &DeckEditorSettingsPage::retranslateUi);
|
||||||
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeckEditorSettingsPage::resetDownloadedURLsButtonClicked()
|
void DeckEditorSettingsPage::resetDownloadedURLsButtonClicked()
|
||||||
|
|
@ -1122,6 +1136,7 @@ MessagesSettingsPage::MessagesSettingsPage()
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
|
connect(&SettingsCache::instance(), &SettingsCache::langChanged, this, &MessagesSettingsPage::retranslateUi);
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1296,6 +1311,9 @@ SoundSettingsPage::SoundSettingsPage()
|
||||||
mainLayout->addStretch();
|
mainLayout->addStretch();
|
||||||
|
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
|
connect(&SettingsCache::instance(), &SettingsCache::langChanged, this, &SoundSettingsPage::retranslateUi);
|
||||||
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundSettingsPage::themeBoxChanged(int index)
|
void SoundSettingsPage::themeBoxChanged(int index)
|
||||||
|
|
@ -1388,6 +1406,9 @@ ShortcutSettingsPage::ShortcutSettingsPage()
|
||||||
connect(btnClearAll, SIGNAL(clicked()), this, SLOT(clearShortcuts()));
|
connect(btnClearAll, SIGNAL(clicked()), this, SLOT(clearShortcuts()));
|
||||||
|
|
||||||
connect(shortcutsTable, &ShortcutTreeView::currentItemChanged, this, &ShortcutSettingsPage::currentItemChanged);
|
connect(shortcutsTable, &ShortcutTreeView::currentItemChanged, this, &ShortcutSettingsPage::currentItemChanged);
|
||||||
|
|
||||||
|
connect(&SettingsCache::instance(), &SettingsCache::langChanged, this, &ShortcutSettingsPage::retranslateUi);
|
||||||
|
retranslateUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShortcutSettingsPage::currentItemChanged(const QString &key)
|
void ShortcutSettingsPage::currentItemChanged(const QString &key)
|
||||||
|
|
@ -1435,10 +1456,23 @@ void ShortcutSettingsPage::retranslateUi()
|
||||||
searchEdit->setPlaceholderText(tr("Search by shortcut name"));
|
searchEdit->setPlaceholderText(tr("Search by shortcut name"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QScrollArea *makeScrollable(QWidget *widget)
|
||||||
|
{
|
||||||
|
widget->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Maximum);
|
||||||
|
|
||||||
|
auto *scrollArea = new QScrollArea;
|
||||||
|
scrollArea->setWidgetResizable(true);
|
||||||
|
scrollArea->setContentsMargins(0, 0, 0, 0);
|
||||||
|
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
scrollArea->horizontalScrollBar()->setEnabled(false);
|
||||||
|
scrollArea->setWidget(widget);
|
||||||
|
return scrollArea;
|
||||||
|
}
|
||||||
|
|
||||||
DlgSettings::DlgSettings(QWidget *parent) : QDialog(parent)
|
DlgSettings::DlgSettings(QWidget *parent) : QDialog(parent)
|
||||||
{
|
{
|
||||||
auto rec = QGuiApplication::primaryScreen()->availableGeometry();
|
auto rec = QGuiApplication::primaryScreen()->availableGeometry();
|
||||||
this->setBaseSize(qMin(700, rec.width()), qMin(700, rec.height()));
|
this->setMinimumSize(qMin(700, rec.width()), qMin(700, rec.height()));
|
||||||
|
|
||||||
connect(&SettingsCache::instance(), SIGNAL(langChanged()), this, SLOT(updateLanguage()));
|
connect(&SettingsCache::instance(), SIGNAL(langChanged()), this, SLOT(updateLanguage()));
|
||||||
|
|
||||||
|
|
@ -1452,8 +1486,8 @@ DlgSettings::DlgSettings(QWidget *parent) : QDialog(parent)
|
||||||
|
|
||||||
pagesWidget = new QStackedWidget;
|
pagesWidget = new QStackedWidget;
|
||||||
pagesWidget->addWidget(new GeneralSettingsPage);
|
pagesWidget->addWidget(new GeneralSettingsPage);
|
||||||
pagesWidget->addWidget(new AppearanceSettingsPage);
|
pagesWidget->addWidget(makeScrollable(new AppearanceSettingsPage));
|
||||||
pagesWidget->addWidget(new UserInterfaceSettingsPage);
|
pagesWidget->addWidget(makeScrollable(new UserInterfaceSettingsPage));
|
||||||
pagesWidget->addWidget(new DeckEditorSettingsPage);
|
pagesWidget->addWidget(new DeckEditorSettingsPage);
|
||||||
pagesWidget->addWidget(new MessagesSettingsPage);
|
pagesWidget->addWidget(new MessagesSettingsPage);
|
||||||
pagesWidget->addWidget(new SoundSettingsPage);
|
pagesWidget->addWidget(new SoundSettingsPage);
|
||||||
|
|
@ -1475,6 +1509,7 @@ DlgSettings::DlgSettings(QWidget *parent) : QDialog(parent)
|
||||||
mainLayout->addWidget(buttonBox);
|
mainLayout->addWidget(buttonBox);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
|
connect(&SettingsCache::instance(), &SettingsCache::langChanged, this, &DlgSettings::retranslateUi);
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
|
|
||||||
adjustSize();
|
adjustSize();
|
||||||
|
|
@ -1543,13 +1578,6 @@ void DlgSettings::updateLanguage()
|
||||||
installNewTranslator();
|
installNewTranslator();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DlgSettings::changeEvent(QEvent *event)
|
|
||||||
{
|
|
||||||
if (event->type() == QEvent::LanguageChange)
|
|
||||||
retranslateUi();
|
|
||||||
QDialog::changeEvent(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DlgSettings::closeEvent(QCloseEvent *event)
|
void DlgSettings::closeEvent(QCloseEvent *event)
|
||||||
{
|
{
|
||||||
bool showLoadError = true;
|
bool showLoadError = true;
|
||||||
|
|
@ -1638,8 +1666,5 @@ void DlgSettings::retranslateUi()
|
||||||
soundButton->setText(tr("Sound"));
|
soundButton->setText(tr("Sound"));
|
||||||
shortcutsButton->setText(tr("Shortcuts"));
|
shortcutsButton->setText(tr("Shortcuts"));
|
||||||
|
|
||||||
for (int i = 0; i < pagesWidget->count(); i++)
|
|
||||||
dynamic_cast<AbstractSettingsPage *>(pagesWidget->widget(i))->retranslateUi();
|
|
||||||
|
|
||||||
contentsWidget->reset();
|
contentsWidget->reset();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -323,7 +323,6 @@ private:
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void changeEvent(QEvent *event) override;
|
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue