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>
459bad0f Poul Sander 2026-05-17 14:11 7
#include <QSpinBox>
4ae57f60 Poul Sander 2026-02-25 21:35 8
#include <QCheckBox>
10d6e6f8 Poul Sander 2026-02-24 18:40 9
#include <QPushButton>
10d6e6f8 Poul Sander 2026-02-24 18:40 10
#include <QGroupBox>
10d6e6f8 Poul Sander 2026-02-24 18:40 11
10d6e6f8 Poul Sander 2026-02-24 18:40 12
PreferencesDialog::PreferencesDialog(QWidget *parent)
10d6e6f8 Poul Sander 2026-02-24 18:40 13
    : QDialog(parent)
10d6e6f8 Poul Sander 2026-02-24 18:40 14
{
10d6e6f8 Poul Sander 2026-02-24 18:40 15
    setWindowTitle("Preferences");
10d6e6f8 Poul Sander 2026-02-24 18:40 16
    setModal(true);
10d6e6f8 Poul Sander 2026-02-24 18:40 17
    setMinimumWidth(400);
10d6e6f8 Poul Sander 2026-02-24 18:40 18
10d6e6f8 Poul Sander 2026-02-24 18:40 19
    QVBoxLayout *mainLayout = new QVBoxLayout(this);
10d6e6f8 Poul Sander 2026-02-24 18:40 20
10d6e6f8 Poul Sander 2026-02-24 18:40 21
    QGroupBox *imageGroup = new QGroupBox("Image Viewer", this);
10d6e6f8 Poul Sander 2026-02-24 18:40 22
    QVBoxLayout *groupLayout = new QVBoxLayout(imageGroup);
10d6e6f8 Poul Sander 2026-02-24 18:40 23
10d6e6f8 Poul Sander 2026-02-24 18:40 24
    QHBoxLayout *bgColorLayout = new QHBoxLayout;
10d6e6f8 Poul Sander 2026-02-24 18:40 25
    QLabel *bgColorLabel = new QLabel("Background Color:");
10d6e6f8 Poul Sander 2026-02-24 18:40 26
    m_backgroundColorCombo = new QComboBox;
10d6e6f8 Poul Sander 2026-02-24 18:40 27
    m_backgroundColorCombo->addItem("Black", "black");
10d6e6f8 Poul Sander 2026-02-24 18:40 28
    m_backgroundColorCombo->addItem("White", "white");
10d6e6f8 Poul Sander 2026-02-24 18:40 29
    m_backgroundColorCombo->addItem("Dark Gray", "darkgray");
10d6e6f8 Poul Sander 2026-02-24 18:40 30
10d6e6f8 Poul Sander 2026-02-24 18:40 31
    bgColorLayout->addWidget(bgColorLabel);
10d6e6f8 Poul Sander 2026-02-24 18:40 32
    bgColorLayout->addWidget(m_backgroundColorCombo);
10d6e6f8 Poul Sander 2026-02-24 18:40 33
    bgColorLayout->addStretch();
10d6e6f8 Poul Sander 2026-02-24 18:40 34
10d6e6f8 Poul Sander 2026-02-24 18:40 35
    groupLayout->addLayout(bgColorLayout);
459bad0f Poul Sander 2026-05-17 14:11 36
459bad0f Poul Sander 2026-05-17 14:11 37
    QHBoxLayout *cacheSizeLayout = new QHBoxLayout;
459bad0f Poul Sander 2026-05-17 14:11 38
    QLabel *cacheSizeLabel = new QLabel("Folder thumbnail cache (folders):");
459bad0f Poul Sander 2026-05-17 14:11 39
    m_cacheSizeSpinBox = new QSpinBox;
459bad0f Poul Sander 2026-05-17 14:11 40
    m_cacheSizeSpinBox->setRange(1, 20);
459bad0f Poul Sander 2026-05-17 14:11 41
    m_cacheSizeSpinBox->setValue(4);
459bad0f Poul Sander 2026-05-17 14:11 42
    cacheSizeLayout->addWidget(cacheSizeLabel);
459bad0f Poul Sander 2026-05-17 14:11 43
    cacheSizeLayout->addWidget(m_cacheSizeSpinBox);
459bad0f Poul Sander 2026-05-17 14:11 44
    cacheSizeLayout->addStretch();
459bad0f Poul Sander 2026-05-17 14:11 45
    groupLayout->addLayout(cacheSizeLayout);
459bad0f Poul Sander 2026-05-17 14:11 46
10d6e6f8 Poul Sander 2026-02-24 18:40 47
    mainLayout->addWidget(imageGroup);
10d6e6f8 Poul Sander 2026-02-24 18:40 48
4ae57f60 Poul Sander 2026-02-25 21:35 49
    QGroupBox *layoutGroup = new QGroupBox("Layout", this);
4ae57f60 Poul Sander 2026-02-25 21:35 50
    QVBoxLayout *layoutGroupLayout = new QVBoxLayout(layoutGroup);
4ae57f60 Poul Sander 2026-02-25 21:35 51
    m_lockDockingCheck = new QCheckBox("Lock docking (prevent accidental moves)");
4ae57f60 Poul Sander 2026-02-25 21:35 52
    layoutGroupLayout->addWidget(m_lockDockingCheck);
7370f1c0 Poul Sander 2026-03-01 15:15 53
    
d1aa6cbe Poul Sander 2026-03-02 16:57 54
    m_resetLayoutCheck = new QCheckBox("Reset layout to default when closing the menu");
d1aa6cbe Poul Sander 2026-03-02 16:57 55
    layoutGroupLayout->addWidget(m_resetLayoutCheck);
7370f1c0 Poul Sander 2026-03-01 15:15 56
    
4ae57f60 Poul Sander 2026-02-25 21:35 57
    mainLayout->addWidget(layoutGroup);
4ae57f60 Poul Sander 2026-02-25 21:35 58
10d6e6f8 Poul Sander 2026-02-24 18:40 59
    mainLayout->addStretch();
10d6e6f8 Poul Sander 2026-02-24 18:40 60
10d6e6f8 Poul Sander 2026-02-24 18:40 61
    QHBoxLayout *buttonLayout = new QHBoxLayout;
10d6e6f8 Poul Sander 2026-02-24 18:40 62
    QPushButton *okButton = new QPushButton("OK");
10d6e6f8 Poul Sander 2026-02-24 18:40 63
    QPushButton *cancelButton = new QPushButton("Cancel");
10d6e6f8 Poul Sander 2026-02-24 18:40 64
10d6e6f8 Poul Sander 2026-02-24 18:40 65
    buttonLayout->addStretch();
10d6e6f8 Poul Sander 2026-02-24 18:40 66
    buttonLayout->addWidget(okButton);
10d6e6f8 Poul Sander 2026-02-24 18:40 67
    buttonLayout->addWidget(cancelButton);
10d6e6f8 Poul Sander 2026-02-24 18:40 68
10d6e6f8 Poul Sander 2026-02-24 18:40 69
    mainLayout->addLayout(buttonLayout);
10d6e6f8 Poul Sander 2026-02-24 18:40 70
d1aa6cbe Poul Sander 2026-03-02 16:57 71
    connect(okButton, &QPushButton::clicked, this, [this]() {
d1aa6cbe Poul Sander 2026-03-02 16:57 72
        if (m_resetLayoutCheck->isChecked())
d1aa6cbe Poul Sander 2026-03-02 16:57 73
            emit resetLayoutRequested();
d1aa6cbe Poul Sander 2026-03-02 16:57 74
        accept();
d1aa6cbe Poul Sander 2026-03-02 16:57 75
    });
10d6e6f8 Poul Sander 2026-02-24 18:40 76
    connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
10d6e6f8 Poul Sander 2026-02-24 18:40 77
}
10d6e6f8 Poul Sander 2026-02-24 18:40 78
10d6e6f8 Poul Sander 2026-02-24 18:40 79
QString PreferencesDialog::getBackgroundColor() const
10d6e6f8 Poul Sander 2026-02-24 18:40 80
{
10d6e6f8 Poul Sander 2026-02-24 18:40 81
    return m_backgroundColorCombo->currentData().toString();
10d6e6f8 Poul Sander 2026-02-24 18:40 82
}
10d6e6f8 Poul Sander 2026-02-24 18:40 83
10d6e6f8 Poul Sander 2026-02-24 18:40 84
void PreferencesDialog::setBackgroundColor(const QString &color)
10d6e6f8 Poul Sander 2026-02-24 18:40 85
{
10d6e6f8 Poul Sander 2026-02-24 18:40 86
    int index = m_backgroundColorCombo->findData(color);
10d6e6f8 Poul Sander 2026-02-24 18:40 87
    if (index >= 0)
10d6e6f8 Poul Sander 2026-02-24 18:40 88
        m_backgroundColorCombo->setCurrentIndex(index);
10d6e6f8 Poul Sander 2026-02-24 18:40 89
}
4ae57f60 Poul Sander 2026-02-25 21:35 90
459bad0f Poul Sander 2026-05-17 14:11 91
int PreferencesDialog::getCacheSize() const
459bad0f Poul Sander 2026-05-17 14:11 92
{
459bad0f Poul Sander 2026-05-17 14:11 93
    return m_cacheSizeSpinBox->value();
459bad0f Poul Sander 2026-05-17 14:11 94
}
459bad0f Poul Sander 2026-05-17 14:11 95
459bad0f Poul Sander 2026-05-17 14:11 96
void PreferencesDialog::setCacheSize(int n)
459bad0f Poul Sander 2026-05-17 14:11 97
{
459bad0f Poul Sander 2026-05-17 14:11 98
    m_cacheSizeSpinBox->setValue(n);
459bad0f Poul Sander 2026-05-17 14:11 99
}
459bad0f Poul Sander 2026-05-17 14:11 100
4ae57f60 Poul Sander 2026-02-25 21:35 101
bool PreferencesDialog::getLockDocking() const
4ae57f60 Poul Sander 2026-02-25 21:35 102
{
4ae57f60 Poul Sander 2026-02-25 21:35 103
    return m_lockDockingCheck->isChecked();
4ae57f60 Poul Sander 2026-02-25 21:35 104
}
4ae57f60 Poul Sander 2026-02-25 21:35 105
4ae57f60 Poul Sander 2026-02-25 21:35 106
void PreferencesDialog::setLockDocking(bool lock)
4ae57f60 Poul Sander 2026-02-25 21:35 107
{
4ae57f60 Poul Sander 2026-02-25 21:35 108
    m_lockDockingCheck->setChecked(lock);
4ae57f60 Poul Sander 2026-02-25 21:35 109
}
d1aa6cbe Poul Sander 2026-03-02 16:57 110
d1aa6cbe Poul Sander 2026-03-02 16:57 111
bool PreferencesDialog::getResetLayout() const
d1aa6cbe Poul Sander 2026-03-02 16:57 112
{
d1aa6cbe Poul Sander 2026-03-02 16:57 113
    return m_resetLayoutCheck->isChecked();
d1aa6cbe Poul Sander 2026-03-02 16:57 114
}
d1aa6cbe Poul Sander 2026-03-02 16:57 115
d1aa6cbe Poul Sander 2026-03-02 16:57 116
void PreferencesDialog::setResetLayout(bool reset)
d1aa6cbe Poul Sander 2026-03-02 16:57 117
{
d1aa6cbe Poul Sander 2026-03-02 16:57 118
    m_resetLayoutCheck->setChecked(reset);
d1aa6cbe Poul Sander 2026-03-02 16:57 119
}
1970-01-01 00:00 120