Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions qtfred/src/ui/Theme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,11 @@ void applyEditorTheme(ThemeMode mode)
applyPalette(resolveDark(mode));
}

bool currentThemeIsDark()
{
return resolveDark(Current_mode);
}

ThemeMode readThemeModeSetting()
{
QSettings settings;
Expand Down
3 changes: 3 additions & 0 deletions qtfred/src/ui/Theme.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ void applyEditorTheme(ThemeMode mode);
ThemeMode readThemeModeSetting();
void writeThemeModeSetting(ThemeMode mode);

// Whether the currently-applied editor theme is dark (System resolved against the OS scheme).
bool currentThemeIsDark();

// Draw a palette-aware icon for a standard Qt pixmap using QPainter.
// Falls back to the style's own icon for unhandled StandardPixmap values.
QIcon makeThemedIcon(QStyle::StandardPixmap sp, const QColor& color, int size = 16);
Expand Down
47 changes: 5 additions & 42 deletions qtfred/src/ui/dialogs/BriefingEditorDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@ void BriefingEditorDialog::setupMapWidget()
{
// Replace the mapView placeholder with the BriefingMapWidget
_mapWidget = new fso::fred::BriefingMapWidget(this, _model.get(), _viewport);
_mapWidget->setMinimumSize(ui->mapView->minimumSize());
_mapWidget->setSizePolicy(ui->mapView->sizePolicy());
// The map paints an aspect-correct, letterboxed image and can scale to any size, so it needs no
// minimum. A minimum here would set the floor the whole left pane can't shrink below, which is
// what stops the dialog narrowing. Keep it at (0,0) and let it expand to fill available space.
_mapWidget->setMinimumSize(0, 0);
_mapWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);

// Insert the map widget in place of the placeholder in the left pane layout
int idx = ui->leftPaneLayout->indexOf(ui->mapView);
Expand Down Expand Up @@ -184,46 +187,6 @@ void BriefingEditorDialog::setupMapWidget()
_mapWidget->setStage(_model->getCurrentStage());
captureResetCameraForCurrentStage();
}

applyMapWidgetAspectRatio();
}

void BriefingEditorDialog::applyMapWidgetAspectRatio()
{
if (_mapWidget == nullptr) {
return;
}

if (Briefing_window_resolution[0] <= 0 || Briefing_window_resolution[1] <= 0) {
return;
}

auto mapWidth = _mapWidget->width();
if (mapWidth <= 0) {
mapWidth = _mapWidget->minimumWidth();
}
if (mapWidth <= 0) {
return;
}

const auto targetHeight = std::max(1,
static_cast<int>(std::lround(static_cast<double>(mapWidth) *
static_cast<double>(Briefing_window_resolution[1]) /
static_cast<double>(Briefing_window_resolution[0]))));

_mapWidget->setMinimumHeight(targetHeight);
_mapWidget->setMaximumHeight(targetHeight);
_mapWidget->resize(mapWidth, targetHeight);

const auto oldDialogHeight = height();
if (auto* dialogLayout = layout(); dialogLayout != nullptr) {
dialogLayout->activate();
}

const auto requiredSize = sizeHint();
if (requiredSize.height() > oldDialogHeight) {
resize(width(), requiredSize.height());
}
}

void BriefingEditorDialog::initializeUi()
Expand Down
1 change: 0 additions & 1 deletion qtfred/src/ui/dialogs/BriefingEditorDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class BriefingEditorDialog : public QDialog, public SexpTreeEditorInterface {

void initializeUi();
void setupMapWidget();
void applyMapWidgetAspectRatio();
void updateUi();
void enableDisableControls();
void captureResetCameraForCurrentStage();
Expand Down
2 changes: 1 addition & 1 deletion qtfred/src/ui/dialogs/HelpTopicsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ QVariant HelpBrowser::loadResource(int type, const QUrl& name) {
}

bool HelpBrowser::isDarkMode() const {
return palette().color(QPalette::Window).lightness() < 128;
return currentThemeIsDark();
}

QByteArray HelpBrowser::darkModeStyleBlock() {
Expand Down
3 changes: 1 addition & 2 deletions qtfred/src/ui/dialogs/VariableDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ VariableDialog::VariableDialog(QWidget* parent, EditorViewport* viewport, Tab in
VariableDialog::~VariableDialog() = default;

// Returns a subtle, theme-aware tint: blue for blue_type=true, orange for blue_type=false.
// Detects dark/light mode via the application window-background lightness.
QColor VariableDialog::rowTypeColor(bool blue_type)
{
const bool dark_mode = QApplication::palette().color(QPalette::Window).lightness() < 128;
const bool dark_mode = currentThemeIsDark();
if (blue_type) {
return dark_mode ? QColor(50, 60, 80) : QColor(225, 235, 252);
} else {
Expand Down
Loading
Loading