git repos / SagoImageBrowser

blame: src/preferencesdialog.cpp

normal view · raw

10d6e6f8 Poul Sander 2026-02-24 18:40 1
#include "preferencesdialog.h"
10d6e6f8 Poul Sander 2026-02-24 18:40 2
10d6e6f8 Poul Sander 2026-02-24 18:40 3
#include <QVBoxLayout>
10d6e6f8 Poul Sander 2026-02-24 18:40 4
#include <QHBoxLayout>
10d6e6f8 Poul Sander 2026-02-24 18:40 5
#include <QLabel>
10d6e6f8 Poul Sander 2026-02-24 18:40 6
#include <QComboBox>
10d6e6f8 Poul Sander 2026-02-24 18:40 7
#include <QPushButton>
10d6e6f8 Poul Sander 2026-02-24 18:40 8
#include <QGroupBox>
10d6e6f8 Poul Sander 2026-02-24 18:40 9
10d6e6f8 Poul Sander 2026-02-24 18:40 10
PreferencesDialog::PreferencesDialog(QWidget *parent)
10d6e6f8 Poul Sander 2026-02-24 18:40 11
    : QDialog(parent)
10d6e6f8 Poul Sander 2026-02-24 18:40 12
{
10d6e6f8 Poul Sander 2026-02-24 18:40 13
    setWindowTitle("Preferences");
10d6e6f8 Poul Sander 2026-02-24 18:40 14
    setModal(true);
10d6e6f8 Poul Sander 2026-02-24 18:40 15
    setMinimumWidth(400);
10d6e6f8 Poul Sander 2026-02-24 18:40 16
10d6e6f8 Poul Sander 2026-02-24 18:40 17
    QVBoxLayout *mainLayout = new QVBoxLayout(this);
10d6e6f8 Poul Sander 2026-02-24 18:40 18
10d6e6f8 Poul Sander 2026-02-24 18:40 19
    QGroupBox *imageGroup = new QGroupBox("Image Viewer", this);
10d6e6f8 Poul Sander 2026-02-24 18:40 20
    QVBoxLayout *groupLayout = new QVBoxLayout(imageGroup);
10d6e6f8 Poul Sander 2026-02-24 18:40 21
10d6e6f8 Poul Sander 2026-02-24 18:40 22
    QHBoxLayout *bgColorLayout = new QHBoxLayout;
10d6e6f8 Poul Sander 2026-02-24 18:40 23
    QLabel *bgColorLabel = new QLabel("Background Color:");
10d6e6f8 Poul Sander 2026-02-24 18:40 24
    m_backgroundColorCombo = new QComboBox;
10d6e6f8 Poul Sander 2026-02-24 18:40 25
    m_backgroundColorCombo->addItem("Black", "black");
10d6e6f8 Poul Sander 2026-02-24 18:40 26
    m_backgroundColorCombo->addItem("White", "white");
10d6e6f8 Poul Sander 2026-02-24 18:40 27
    m_backgroundColorCombo->addItem("Dark Gray", "darkgray");
10d6e6f8 Poul Sander 2026-02-24 18:40 28
10d6e6f8 Poul Sander 2026-02-24 18:40 29
    bgColorLayout->addWidget(bgColorLabel);
10d6e6f8 Poul Sander 2026-02-24 18:40 30
    bgColorLayout->addWidget(m_backgroundColorCombo);
10d6e6f8 Poul Sander 2026-02-24 18:40 31
    bgColorLayout->addStretch();
10d6e6f8 Poul Sander 2026-02-24 18:40 32
10d6e6f8 Poul Sander 2026-02-24 18:40 33
    groupLayout->addLayout(bgColorLayout);
10d6e6f8 Poul Sander 2026-02-24 18:40 34
    mainLayout->addWidget(imageGroup);
10d6e6f8 Poul Sander 2026-02-24 18:40 35
10d6e6f8 Poul Sander 2026-02-24 18:40 36
    mainLayout->addStretch();
10d6e6f8 Poul Sander 2026-02-24 18:40 37
10d6e6f8 Poul Sander 2026-02-24 18:40 38
    QHBoxLayout *buttonLayout = new QHBoxLayout;
10d6e6f8 Poul Sander 2026-02-24 18:40 39
    QPushButton *okButton = new QPushButton("OK");
10d6e6f8 Poul Sander 2026-02-24 18:40 40
    QPushButton *cancelButton = new QPushButton("Cancel");
10d6e6f8 Poul Sander 2026-02-24 18:40 41
10d6e6f8 Poul Sander 2026-02-24 18:40 42
    buttonLayout->addStretch();
10d6e6f8 Poul Sander 2026-02-24 18:40 43
    buttonLayout->addWidget(okButton);
10d6e6f8 Poul Sander 2026-02-24 18:40 44
    buttonLayout->addWidget(cancelButton);
10d6e6f8 Poul Sander 2026-02-24 18:40 45
10d6e6f8 Poul Sander 2026-02-24 18:40 46
    mainLayout->addLayout(buttonLayout);
10d6e6f8 Poul Sander 2026-02-24 18:40 47
10d6e6f8 Poul Sander 2026-02-24 18:40 48
    connect(okButton, &QPushButton::clicked, this, &QDialog::accept);
10d6e6f8 Poul Sander 2026-02-24 18:40 49
    connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
10d6e6f8 Poul Sander 2026-02-24 18:40 50
}
10d6e6f8 Poul Sander 2026-02-24 18:40 51
10d6e6f8 Poul Sander 2026-02-24 18:40 52
QString PreferencesDialog::getBackgroundColor() const
10d6e6f8 Poul Sander 2026-02-24 18:40 53
{
10d6e6f8 Poul Sander 2026-02-24 18:40 54
    return m_backgroundColorCombo->currentData().toString();
10d6e6f8 Poul Sander 2026-02-24 18:40 55
}
10d6e6f8 Poul Sander 2026-02-24 18:40 56
10d6e6f8 Poul Sander 2026-02-24 18:40 57
void PreferencesDialog::setBackgroundColor(const QString &color)
10d6e6f8 Poul Sander 2026-02-24 18:40 58
{
10d6e6f8 Poul Sander 2026-02-24 18:40 59
    int index = m_backgroundColorCombo->findData(color);
10d6e6f8 Poul Sander 2026-02-24 18:40 60
    if (index >= 0)
10d6e6f8 Poul Sander 2026-02-24 18:40 61
        m_backgroundColorCombo->setCurrentIndex(index);
10d6e6f8 Poul Sander 2026-02-24 18:40 62
}
1970-01-01 00:00 63