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>
4ae57f60 Poul Sander 2026-02-25 21:35 7
#include <QCheckBox>
10d6e6f8 Poul Sander 2026-02-24 18:40 8
#include <QPushButton>
10d6e6f8 Poul Sander 2026-02-24 18:40 9
#include <QGroupBox>
10d6e6f8 Poul Sander 2026-02-24 18:40 10
10d6e6f8 Poul Sander 2026-02-24 18:40 11
PreferencesDialog::PreferencesDialog(QWidget *parent)
10d6e6f8 Poul Sander 2026-02-24 18:40 12
    : QDialog(parent)
10d6e6f8 Poul Sander 2026-02-24 18:40 13
{
10d6e6f8 Poul Sander 2026-02-24 18:40 14
    setWindowTitle("Preferences");
10d6e6f8 Poul Sander 2026-02-24 18:40 15
    setModal(true);
10d6e6f8 Poul Sander 2026-02-24 18:40 16
    setMinimumWidth(400);
10d6e6f8 Poul Sander 2026-02-24 18:40 17
10d6e6f8 Poul Sander 2026-02-24 18:40 18
    QVBoxLayout *mainLayout = new QVBoxLayout(this);
10d6e6f8 Poul Sander 2026-02-24 18:40 19
10d6e6f8 Poul Sander 2026-02-24 18:40 20
    QGroupBox *imageGroup = new QGroupBox("Image Viewer", this);
10d6e6f8 Poul Sander 2026-02-24 18:40 21
    QVBoxLayout *groupLayout = new QVBoxLayout(imageGroup);
10d6e6f8 Poul Sander 2026-02-24 18:40 22
10d6e6f8 Poul Sander 2026-02-24 18:40 23
    QHBoxLayout *bgColorLayout = new QHBoxLayout;
10d6e6f8 Poul Sander 2026-02-24 18:40 24
    QLabel *bgColorLabel = new QLabel("Background Color:");
10d6e6f8 Poul Sander 2026-02-24 18:40 25
    m_backgroundColorCombo = new QComboBox;
10d6e6f8 Poul Sander 2026-02-24 18:40 26
    m_backgroundColorCombo->addItem("Black", "black");
10d6e6f8 Poul Sander 2026-02-24 18:40 27
    m_backgroundColorCombo->addItem("White", "white");
10d6e6f8 Poul Sander 2026-02-24 18:40 28
    m_backgroundColorCombo->addItem("Dark Gray", "darkgray");
10d6e6f8 Poul Sander 2026-02-24 18:40 29
10d6e6f8 Poul Sander 2026-02-24 18:40 30
    bgColorLayout->addWidget(bgColorLabel);
10d6e6f8 Poul Sander 2026-02-24 18:40 31
    bgColorLayout->addWidget(m_backgroundColorCombo);
10d6e6f8 Poul Sander 2026-02-24 18:40 32
    bgColorLayout->addStretch();
10d6e6f8 Poul Sander 2026-02-24 18:40 33
10d6e6f8 Poul Sander 2026-02-24 18:40 34
    groupLayout->addLayout(bgColorLayout);
10d6e6f8 Poul Sander 2026-02-24 18:40 35
    mainLayout->addWidget(imageGroup);
10d6e6f8 Poul Sander 2026-02-24 18:40 36
4ae57f60 Poul Sander 2026-02-25 21:35 37
    QGroupBox *layoutGroup = new QGroupBox("Layout", this);
4ae57f60 Poul Sander 2026-02-25 21:35 38
    QVBoxLayout *layoutGroupLayout = new QVBoxLayout(layoutGroup);
4ae57f60 Poul Sander 2026-02-25 21:35 39
    m_lockDockingCheck = new QCheckBox("Lock docking (prevent accidental moves)");
4ae57f60 Poul Sander 2026-02-25 21:35 40
    layoutGroupLayout->addWidget(m_lockDockingCheck);
4ae57f60 Poul Sander 2026-02-25 21:35 41
    mainLayout->addWidget(layoutGroup);
4ae57f60 Poul Sander 2026-02-25 21:35 42
10d6e6f8 Poul Sander 2026-02-24 18:40 43
    mainLayout->addStretch();
10d6e6f8 Poul Sander 2026-02-24 18:40 44
10d6e6f8 Poul Sander 2026-02-24 18:40 45
    QHBoxLayout *buttonLayout = new QHBoxLayout;
10d6e6f8 Poul Sander 2026-02-24 18:40 46
    QPushButton *okButton = new QPushButton("OK");
10d6e6f8 Poul Sander 2026-02-24 18:40 47
    QPushButton *cancelButton = new QPushButton("Cancel");
10d6e6f8 Poul Sander 2026-02-24 18:40 48
10d6e6f8 Poul Sander 2026-02-24 18:40 49
    buttonLayout->addStretch();
10d6e6f8 Poul Sander 2026-02-24 18:40 50
    buttonLayout->addWidget(okButton);
10d6e6f8 Poul Sander 2026-02-24 18:40 51
    buttonLayout->addWidget(cancelButton);
10d6e6f8 Poul Sander 2026-02-24 18:40 52
10d6e6f8 Poul Sander 2026-02-24 18:40 53
    mainLayout->addLayout(buttonLayout);
10d6e6f8 Poul Sander 2026-02-24 18:40 54
10d6e6f8 Poul Sander 2026-02-24 18:40 55
    connect(okButton, &QPushButton::clicked, this, &QDialog::accept);
10d6e6f8 Poul Sander 2026-02-24 18:40 56
    connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
10d6e6f8 Poul Sander 2026-02-24 18:40 57
}
10d6e6f8 Poul Sander 2026-02-24 18:40 58
10d6e6f8 Poul Sander 2026-02-24 18:40 59
QString PreferencesDialog::getBackgroundColor() const
10d6e6f8 Poul Sander 2026-02-24 18:40 60
{
10d6e6f8 Poul Sander 2026-02-24 18:40 61
    return m_backgroundColorCombo->currentData().toString();
10d6e6f8 Poul Sander 2026-02-24 18:40 62
}
10d6e6f8 Poul Sander 2026-02-24 18:40 63
10d6e6f8 Poul Sander 2026-02-24 18:40 64
void PreferencesDialog::setBackgroundColor(const QString &color)
10d6e6f8 Poul Sander 2026-02-24 18:40 65
{
10d6e6f8 Poul Sander 2026-02-24 18:40 66
    int index = m_backgroundColorCombo->findData(color);
10d6e6f8 Poul Sander 2026-02-24 18:40 67
    if (index >= 0)
10d6e6f8 Poul Sander 2026-02-24 18:40 68
        m_backgroundColorCombo->setCurrentIndex(index);
10d6e6f8 Poul Sander 2026-02-24 18:40 69
}
4ae57f60 Poul Sander 2026-02-25 21:35 70
4ae57f60 Poul Sander 2026-02-25 21:35 71
bool PreferencesDialog::getLockDocking() const
4ae57f60 Poul Sander 2026-02-25 21:35 72
{
4ae57f60 Poul Sander 2026-02-25 21:35 73
    return m_lockDockingCheck->isChecked();
4ae57f60 Poul Sander 2026-02-25 21:35 74
}
4ae57f60 Poul Sander 2026-02-25 21:35 75
4ae57f60 Poul Sander 2026-02-25 21:35 76
void PreferencesDialog::setLockDocking(bool lock)
4ae57f60 Poul Sander 2026-02-25 21:35 77
{
4ae57f60 Poul Sander 2026-02-25 21:35 78
    m_lockDockingCheck->setChecked(lock);
4ae57f60 Poul Sander 2026-02-25 21:35 79
}
1970-01-01 00:00 80