mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 17:43:23 -08:00
[Client] Settings: enlarge the settings dialog
Keep settings modal per review: size to ~90% of the main window (5% margins each side) with screen fallback, size grip and 750x700 minimum bounded to the screen. Drops the tab approach while giving dense pages room without the tab-switch friction.
This commit is contained in:
parent
84ad1185b6
commit
b9d37b9b1e
3 changed files with 26 additions and 7 deletions
|
|
@ -20,6 +20,7 @@
|
|||
#include <QMessageBox>
|
||||
#include <QMessageLogger>
|
||||
#include <QPushButton>
|
||||
#include <QRect>
|
||||
#include <QScreen>
|
||||
#include <QSize>
|
||||
#include <QVBoxLayout>
|
||||
|
|
@ -30,8 +31,27 @@
|
|||
|
||||
DlgSettings::DlgSettings(QWidget *parent) : QDialog(parent)
|
||||
{
|
||||
auto rec = QGuiApplication::primaryScreen()->availableGeometry();
|
||||
setMinimumSize(qMin(750, rec.width()), qMin(700, rec.height()));
|
||||
// Fill the main window with small margins so multi-group pages (e.g. Deck Editor) are not buried in a scroll.
|
||||
// 90% of the host window leaves ~5% margins on each side; falls back to 90% of the screen when parentless.
|
||||
QWidget *hostWindow = parent ? parent->window() : nullptr;
|
||||
QScreen *screen = nullptr;
|
||||
QSize hostSize;
|
||||
if (hostWindow) {
|
||||
hostSize = hostWindow->size();
|
||||
screen = QGuiApplication::screenAt(hostWindow->geometry().center());
|
||||
}
|
||||
if (!screen) {
|
||||
screen = QGuiApplication::primaryScreen();
|
||||
}
|
||||
const QRect available = screen ? screen->availableGeometry() : QRect(0, 0, 1280, 800);
|
||||
const QSize minimum(qMin(750, available.width()), qMin(700, available.height()));
|
||||
setMinimumSize(minimum);
|
||||
|
||||
QSize target = !hostSize.isEmpty() ? QSize(qRound(hostSize.width() * 0.9), qRound(hostSize.height() * 0.9))
|
||||
: QSize(qRound(available.width() * 0.9), qRound(available.height() * 0.9));
|
||||
target = target.expandedTo(minimum).boundedTo(available.size());
|
||||
resize(target);
|
||||
setSizeGripEnabled(true);
|
||||
|
||||
connect(&SettingsCache::instance().personal(), &PersonalSettings::langChanged, this, &DlgSettings::updateLanguage);
|
||||
|
||||
|
|
@ -54,8 +74,6 @@ DlgSettings::DlgSettings(QWidget *parent) : QDialog(parent)
|
|||
|
||||
connect(&SettingsCache::instance().personal(), &PersonalSettings::langChanged, this, &DlgSettings::retranslateUi);
|
||||
retranslateUi();
|
||||
|
||||
adjustSize();
|
||||
}
|
||||
|
||||
void DlgSettings::setTab(int index)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,8 @@ inline Q_LOGGING_CATEGORY(DlgSettingsLog, "dlg_settings");
|
|||
*
|
||||
* Thin QDialog frame around SettingsView: only the window title, the OK button
|
||||
* and the close validation live here. All pages, navigation and search are
|
||||
* owned by SettingsView so other hosts (e.g. a settings tab) can reuse them.
|
||||
* owned by SettingsView. The dialog fills ~90% of the main window so dense
|
||||
* pages stay visible without losing the modal adjust-and-return flow.
|
||||
*/
|
||||
class DlgSettings : public QDialog
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* @file settings_view.h
|
||||
* @brief Settings content widget hosted by the settings dialog (and, later, the settings tab)
|
||||
* @brief Settings content widget hosted by the settings dialog
|
||||
* @ingroup Dialogs
|
||||
*/
|
||||
#ifndef SETTINGS_VIEW_H
|
||||
|
|
@ -28,7 +28,7 @@ class SettingsSearchDelegate;
|
|||
* @brief Settings pages with tabbed navigation and search, without any dialog chrome
|
||||
*
|
||||
* Owns the search bar, the tab bar, the stacked settings pages and the search
|
||||
* results view. Dialog/tab hosts only add their own frame (buttons, titles).
|
||||
* results view. The settings dialog only adds its own frame (buttons, titles).
|
||||
*/
|
||||
class SettingsView : public QWidget
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue