git repos / SagoImageBrowser

blame: src/preferencesdialog.cpp

normal view · raw

10d6e6f8 Poul Sander 2026-02-24 18:40 1
#include "preferencesdialog.h"
83f0e0bc Poul Sander 2026-05-30 17:59 2
#include "shortcutmanager.h"
10d6e6f8 Poul Sander 2026-02-24 18:40 3
10d6e6f8 Poul Sander 2026-02-24 18:40 4
#include <QVBoxLayout>
10d6e6f8 Poul Sander 2026-02-24 18:40 5
#include <QHBoxLayout>
10d6e6f8 Poul Sander 2026-02-24 18:40 6
#include <QLabel>
10d6e6f8 Poul Sander 2026-02-24 18:40 7
#include <QComboBox>
459bad0f Poul Sander 2026-05-17 14:11 8
#include <QSpinBox>
4ae57f60 Poul Sander 2026-02-25 21:35 9
#include <QCheckBox>
10d6e6f8 Poul Sander 2026-02-24 18:40 10
#include <QPushButton>
10d6e6f8 Poul Sander 2026-02-24 18:40 11
#include <QGroupBox>
83f0e0bc Poul Sander 2026-05-30 17:59 12
#include <QTabWidget>
83f0e0bc Poul Sander 2026-05-30 17:59 13
#include <QTableWidget>
83f0e0bc Poul Sander 2026-05-30 17:59 14
#include <QKeySequenceEdit>
83f0e0bc Poul Sander 2026-05-30 17:59 15
#include <QHeaderView>
10d6e6f8 Poul Sander 2026-02-24 18:40 16
10d6e6f8 Poul Sander 2026-02-24 18:40 17
PreferencesDialog::PreferencesDialog(QWidget *parent)
10d6e6f8 Poul Sander 2026-02-24 18:40 18
    : QDialog(parent)
10d6e6f8 Poul Sander 2026-02-24 18:40 19
{
10d6e6f8 Poul Sander 2026-02-24 18:40 20
    setWindowTitle("Preferences");
10d6e6f8 Poul Sander 2026-02-24 18:40 21
    setModal(true);
83f0e0bc Poul Sander 2026-05-30 17:59 22
    setMinimumWidth(500);
10d6e6f8 Poul Sander 2026-02-24 18:40 23
10d6e6f8 Poul Sander 2026-02-24 18:40 24
    QVBoxLayout *mainLayout = new QVBoxLayout(this);
10d6e6f8 Poul Sander 2026-02-24 18:40 25
83f0e0bc Poul Sander 2026-05-30 17:59 26
    QTabWidget *tabs = new QTabWidget(this);
83f0e0bc Poul Sander 2026-05-30 17:59 27
    setupGeneralTab(tabs);
83f0e0bc Poul Sander 2026-05-30 17:59 28
    setupShortcutsTab(tabs);
83f0e0bc Poul Sander 2026-05-30 17:59 29
    mainLayout->addWidget(tabs);
83f0e0bc Poul Sander 2026-05-30 17:59 30
83f0e0bc Poul Sander 2026-05-30 17:59 31
    QHBoxLayout *buttonLayout = new QHBoxLayout;
83f0e0bc Poul Sander 2026-05-30 17:59 32
    QPushButton *okButton = new QPushButton("OK");
83f0e0bc Poul Sander 2026-05-30 17:59 33
    QPushButton *cancelButton = new QPushButton("Cancel");
83f0e0bc Poul Sander 2026-05-30 17:59 34
83f0e0bc Poul Sander 2026-05-30 17:59 35
    buttonLayout->addStretch();
83f0e0bc Poul Sander 2026-05-30 17:59 36
    buttonLayout->addWidget(okButton);
83f0e0bc Poul Sander 2026-05-30 17:59 37
    buttonLayout->addWidget(cancelButton);
83f0e0bc Poul Sander 2026-05-30 17:59 38
83f0e0bc Poul Sander 2026-05-30 17:59 39
    mainLayout->addLayout(buttonLayout);
83f0e0bc Poul Sander 2026-05-30 17:59 40
83f0e0bc Poul Sander 2026-05-30 17:59 41
    connect(okButton, &QPushButton::clicked, this, [this]() {
83f0e0bc Poul Sander 2026-05-30 17:59 42
        if (m_resetLayoutCheck->isChecked())
83f0e0bc Poul Sander 2026-05-30 17:59 43
            emit resetLayoutRequested();
83f0e0bc Poul Sander 2026-05-30 17:59 44
        accept();
83f0e0bc Poul Sander 2026-05-30 17:59 45
    });
83f0e0bc Poul Sander 2026-05-30 17:59 46
    connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject);
83f0e0bc Poul Sander 2026-05-30 17:59 47
}
83f0e0bc Poul Sander 2026-05-30 17:59 48
83f0e0bc Poul Sander 2026-05-30 17:59 49
void PreferencesDialog::setupGeneralTab(QTabWidget *tabs)
83f0e0bc Poul Sander 2026-05-30 17:59 50
{
83f0e0bc Poul Sander 2026-05-30 17:59 51
    QWidget *page = new QWidget;
83f0e0bc Poul Sander 2026-05-30 17:59 52
    QVBoxLayout *pageLayout = new QVBoxLayout(page);
83f0e0bc Poul Sander 2026-05-30 17:59 53
83f0e0bc Poul Sander 2026-05-30 17:59 54
    QGroupBox *imageGroup = new QGroupBox("Image Viewer", page);
10d6e6f8 Poul Sander 2026-02-24 18:40 55
    QVBoxLayout *groupLayout = new QVBoxLayout(imageGroup);
10d6e6f8 Poul Sander 2026-02-24 18:40 56
10d6e6f8 Poul Sander 2026-02-24 18:40 57
    QHBoxLayout *bgColorLayout = new QHBoxLayout;
10d6e6f8 Poul Sander 2026-02-24 18:40 58
    QLabel *bgColorLabel = new QLabel("Background Color:");
10d6e6f8 Poul Sander 2026-02-24 18:40 59
    m_backgroundColorCombo = new QComboBox;
10d6e6f8 Poul Sander 2026-02-24 18:40 60
    m_backgroundColorCombo->addItem("Black", "black");
10d6e6f8 Poul Sander 2026-02-24 18:40 61
    m_backgroundColorCombo->addItem("White", "white");
10d6e6f8 Poul Sander 2026-02-24 18:40 62
    m_backgroundColorCombo->addItem("Dark Gray", "darkgray");
10d6e6f8 Poul Sander 2026-02-24 18:40 63
10d6e6f8 Poul Sander 2026-02-24 18:40 64
    bgColorLayout->addWidget(bgColorLabel);
10d6e6f8 Poul Sander 2026-02-24 18:40 65
    bgColorLayout->addWidget(m_backgroundColorCombo);
10d6e6f8 Poul Sander 2026-02-24 18:40 66
    bgColorLayout->addStretch();
10d6e6f8 Poul Sander 2026-02-24 18:40 67
10d6e6f8 Poul Sander 2026-02-24 18:40 68
    groupLayout->addLayout(bgColorLayout);
459bad0f Poul Sander 2026-05-17 14:11 69
459bad0f Poul Sander 2026-05-17 14:11 70
    QHBoxLayout *cacheSizeLayout = new QHBoxLayout;
459bad0f Poul Sander 2026-05-17 14:11 71
    QLabel *cacheSizeLabel = new QLabel("Folder thumbnail cache (folders):");
459bad0f Poul Sander 2026-05-17 14:11 72
    m_cacheSizeSpinBox = new QSpinBox;
459bad0f Poul Sander 2026-05-17 14:11 73
    m_cacheSizeSpinBox->setRange(1, 20);
459bad0f Poul Sander 2026-05-17 14:11 74
    m_cacheSizeSpinBox->setValue(4);
459bad0f Poul Sander 2026-05-17 14:11 75
    cacheSizeLayout->addWidget(cacheSizeLabel);
459bad0f Poul Sander 2026-05-17 14:11 76
    cacheSizeLayout->addWidget(m_cacheSizeSpinBox);
459bad0f Poul Sander 2026-05-17 14:11 77
    cacheSizeLayout->addStretch();
459bad0f Poul Sander 2026-05-17 14:11 78
    groupLayout->addLayout(cacheSizeLayout);
459bad0f Poul Sander 2026-05-17 14:11 79
ac476ca8 Poul Sander 2026-05-18 16:47 80
    QHBoxLayout *thumbSizeLayout = new QHBoxLayout;
ac476ca8 Poul Sander 2026-05-18 16:47 81
    QLabel *thumbSizeLabel = new QLabel("Thumbnail cache size:");
ac476ca8 Poul Sander 2026-05-18 16:47 82
    m_thumbnailSizeCombo = new QComboBox;
ac476ca8 Poul Sander 2026-05-18 16:47 83
    m_thumbnailSizeCombo->addItem("Normal (128 px)", "normal");
ac476ca8 Poul Sander 2026-05-18 16:47 84
    m_thumbnailSizeCombo->addItem("Large (256 px)", "large");
ac476ca8 Poul Sander 2026-05-18 16:47 85
    thumbSizeLayout->addWidget(thumbSizeLabel);
ac476ca8 Poul Sander 2026-05-18 16:47 86
    thumbSizeLayout->addWidget(m_thumbnailSizeCombo);
ac476ca8 Poul Sander 2026-05-18 16:47 87
    thumbSizeLayout->addStretch();
ac476ca8 Poul Sander 2026-05-18 16:47 88
    groupLayout->addLayout(thumbSizeLayout);
ac476ca8 Poul Sander 2026-05-18 16:47 89
83f0e0bc Poul Sander 2026-05-30 17:59 90
    pageLayout->addWidget(imageGroup);
10d6e6f8 Poul Sander 2026-02-24 18:40 91
83f0e0bc Poul Sander 2026-05-30 17:59 92
    QGroupBox *layoutGroup = new QGroupBox("Layout", page);
4ae57f60 Poul Sander 2026-02-25 21:35 93
    QVBoxLayout *layoutGroupLayout = new QVBoxLayout(layoutGroup);
4ae57f60 Poul Sander 2026-02-25 21:35 94
    m_lockDockingCheck = new QCheckBox("Lock docking (prevent accidental moves)");
4ae57f60 Poul Sander 2026-02-25 21:35 95
    layoutGroupLayout->addWidget(m_lockDockingCheck);
83f0e0bc Poul Sander 2026-05-30 17:59 96
d1aa6cbe Poul Sander 2026-03-02 16:57 97
    m_resetLayoutCheck = new QCheckBox("Reset layout to default when closing the menu");
d1aa6cbe Poul Sander 2026-03-02 16:57 98
    layoutGroupLayout->addWidget(m_resetLayoutCheck);
4ae57f60 Poul Sander 2026-02-25 21:35 99
83f0e0bc Poul Sander 2026-05-30 17:59 100
    pageLayout->addWidget(layoutGroup);
83f0e0bc Poul Sander 2026-05-30 17:59 101
    pageLayout->addStretch();
10d6e6f8 Poul Sander 2026-02-24 18:40 102
83f0e0bc Poul Sander 2026-05-30 17:59 103
    tabs->addTab(page, "General");
83f0e0bc Poul Sander 2026-05-30 17:59 104
}
10d6e6f8 Poul Sander 2026-02-24 18:40 105
83f0e0bc Poul Sander 2026-05-30 17:59 106
void PreferencesDialog::setupShortcutsTab(QTabWidget *tabs)
83f0e0bc Poul Sander 2026-05-30 17:59 107
{
83f0e0bc Poul Sander 2026-05-30 17:59 108
    QWidget *page = new QWidget;
83f0e0bc Poul Sander 2026-05-30 17:59 109
    QVBoxLayout *pageLayout = new QVBoxLayout(page);
10d6e6f8 Poul Sander 2026-02-24 18:40 110
83f0e0bc Poul Sander 2026-05-30 17:59 111
    // Count configurable actions to size the table (plus 2 section header rows)
83f0e0bc Poul Sander 2026-05-30 17:59 112
    int configurableCount = 0;
83f0e0bc Poul Sander 2026-05-30 17:59 113
    for (int i = 0; i < ShortcutManager::ActionCount; ++i) {
83f0e0bc Poul Sander 2026-05-30 17:59 114
        if (ShortcutManager::actionCategory(static_cast<ShortcutManager::Action>(i))
83f0e0bc Poul Sander 2026-05-30 17:59 115
            != ShortcutManager::CatNotConfigurable)
83f0e0bc Poul Sander 2026-05-30 17:59 116
            ++configurableCount;
83f0e0bc Poul Sander 2026-05-30 17:59 117
    }
83f0e0bc Poul Sander 2026-05-30 17:59 118
    // +2 for section headers (Image Viewer, Browser)
83f0e0bc Poul Sander 2026-05-30 17:59 119
    const int totalRows = configurableCount + 2;
10d6e6f8 Poul Sander 2026-02-24 18:40 120
83f0e0bc Poul Sander 2026-05-30 17:59 121
    m_shortcutsTable = new QTableWidget(totalRows, 2, page);
83f0e0bc Poul Sander 2026-05-30 17:59 122
    m_shortcutsTable->setHorizontalHeaderLabels({"Action", "Key"});
83f0e0bc Poul Sander 2026-05-30 17:59 123
    m_shortcutsTable->horizontalHeader()->setStretchLastSection(true);
83f0e0bc Poul Sander 2026-05-30 17:59 124
    m_shortcutsTable->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Stretch);
83f0e0bc Poul Sander 2026-05-30 17:59 125
    m_shortcutsTable->verticalHeader()->hide();
83f0e0bc Poul Sander 2026-05-30 17:59 126
    m_shortcutsTable->setSelectionMode(QAbstractItemView::SingleSelection);
83f0e0bc Poul Sander 2026-05-30 17:59 127
83f0e0bc Poul Sander 2026-05-30 17:59 128
    m_rowToAction.clear();
83f0e0bc Poul Sander 2026-05-30 17:59 129
    const ShortcutManager &mgr = ShortcutManager::instance();
83f0e0bc Poul Sander 2026-05-30 17:59 130
    int row = 0;
83f0e0bc Poul Sander 2026-05-30 17:59 131
83f0e0bc Poul Sander 2026-05-30 17:59 132
    auto addSectionHeader = [&](const QString &title) {
83f0e0bc Poul Sander 2026-05-30 17:59 133
        auto *item = new QTableWidgetItem(title);
83f0e0bc Poul Sander 2026-05-30 17:59 134
        item->setFlags(Qt::NoItemFlags);
83f0e0bc Poul Sander 2026-05-30 17:59 135
        QFont f = item->font();
83f0e0bc Poul Sander 2026-05-30 17:59 136
        f.setBold(true);
83f0e0bc Poul Sander 2026-05-30 17:59 137
        item->setFont(f);
83f0e0bc Poul Sander 2026-05-30 17:59 138
        item->setBackground(palette().alternateBase());
83f0e0bc Poul Sander 2026-05-30 17:59 139
        m_shortcutsTable->setItem(row, 0, item);
83f0e0bc Poul Sander 2026-05-30 17:59 140
        auto *emptyItem = new QTableWidgetItem();
83f0e0bc Poul Sander 2026-05-30 17:59 141
        emptyItem->setFlags(Qt::NoItemFlags);
83f0e0bc Poul Sander 2026-05-30 17:59 142
        emptyItem->setBackground(palette().alternateBase());
83f0e0bc Poul Sander 2026-05-30 17:59 143
        m_shortcutsTable->setItem(row, 1, emptyItem);
83f0e0bc Poul Sander 2026-05-30 17:59 144
        m_rowToAction.append(-1); // -1 = section header
83f0e0bc Poul Sander 2026-05-30 17:59 145
        ++row;
83f0e0bc Poul Sander 2026-05-30 17:59 146
    };
83f0e0bc Poul Sander 2026-05-30 17:59 147
83f0e0bc Poul Sander 2026-05-30 17:59 148
    auto addAction = [&](ShortcutManager::Action action) {
83f0e0bc Poul Sander 2026-05-30 17:59 149
        auto *descItem = new QTableWidgetItem(mgr.description(action));
83f0e0bc Poul Sander 2026-05-30 17:59 150
        descItem->setFlags(descItem->flags() & ~Qt::ItemIsEditable);
83f0e0bc Poul Sander 2026-05-30 17:59 151
        m_shortcutsTable->setItem(row, 0, descItem);
83f0e0bc Poul Sander 2026-05-30 17:59 152
83f0e0bc Poul Sander 2026-05-30 17:59 153
        auto *edit = new QKeySequenceEdit(mgr.shortcut(action));
83f0e0bc Poul Sander 2026-05-30 17:59 154
        edit->setMaximumSequenceLength(1);
83f0e0bc Poul Sander 2026-05-30 17:59 155
        connect(edit, &QKeySequenceEdit::keySequenceChanged, this, [this]() {
83f0e0bc Poul Sander 2026-05-30 17:59 156
            highlightConflicts();
83f0e0bc Poul Sander 2026-05-30 17:59 157
        });
83f0e0bc Poul Sander 2026-05-30 17:59 158
        m_shortcutsTable->setCellWidget(row, 1, edit);
83f0e0bc Poul Sander 2026-05-30 17:59 159
        m_rowToAction.append(static_cast<int>(action));
83f0e0bc Poul Sander 2026-05-30 17:59 160
        ++row;
83f0e0bc Poul Sander 2026-05-30 17:59 161
    };
83f0e0bc Poul Sander 2026-05-30 17:59 162
83f0e0bc Poul Sander 2026-05-30 17:59 163
    // Image Viewer section
83f0e0bc Poul Sander 2026-05-30 17:59 164
    addSectionHeader("Image Viewer");
83f0e0bc Poul Sander 2026-05-30 17:59 165
    for (int i = 0; i < ShortcutManager::ActionCount; ++i) {
83f0e0bc Poul Sander 2026-05-30 17:59 166
        auto action = static_cast<ShortcutManager::Action>(i);
83f0e0bc Poul Sander 2026-05-30 17:59 167
        if (ShortcutManager::actionCategory(action) == ShortcutManager::CatImageViewer)
83f0e0bc Poul Sander 2026-05-30 17:59 168
            addAction(action);
83f0e0bc Poul Sander 2026-05-30 17:59 169
    }
83f0e0bc Poul Sander 2026-05-30 17:59 170
83f0e0bc Poul Sander 2026-05-30 17:59 171
    // Browser section
83f0e0bc Poul Sander 2026-05-30 17:59 172
    addSectionHeader("Browser");
83f0e0bc Poul Sander 2026-05-30 17:59 173
    for (int i = 0; i < ShortcutManager::ActionCount; ++i) {
83f0e0bc Poul Sander 2026-05-30 17:59 174
        auto action = static_cast<ShortcutManager::Action>(i);
83f0e0bc Poul Sander 2026-05-30 17:59 175
        if (ShortcutManager::actionCategory(action) == ShortcutManager::CatBrowser)
83f0e0bc Poul Sander 2026-05-30 17:59 176
            addAction(action);
83f0e0bc Poul Sander 2026-05-30 17:59 177
    }
83f0e0bc Poul Sander 2026-05-30 17:59 178
83f0e0bc Poul Sander 2026-05-30 17:59 179
    pageLayout->addWidget(m_shortcutsTable);
83f0e0bc Poul Sander 2026-05-30 17:59 180
83f0e0bc Poul Sander 2026-05-30 17:59 181
    QHBoxLayout *btnLayout = new QHBoxLayout;
83f0e0bc Poul Sander 2026-05-30 17:59 182
    QPushButton *resetBtn = new QPushButton("Reset to Defaults");
83f0e0bc Poul Sander 2026-05-30 17:59 183
    btnLayout->addStretch();
83f0e0bc Poul Sander 2026-05-30 17:59 184
    btnLayout->addWidget(resetBtn);
83f0e0bc Poul Sander 2026-05-30 17:59 185
    pageLayout->addLayout(btnLayout);
83f0e0bc Poul Sander 2026-05-30 17:59 186
83f0e0bc Poul Sander 2026-05-30 17:59 187
    connect(resetBtn, &QPushButton::clicked, this, [this]() {
83f0e0bc Poul Sander 2026-05-30 17:59 188
        for (int r = 0; r < m_rowToAction.size(); ++r) {
83f0e0bc Poul Sander 2026-05-30 17:59 189
            int actionIdx = m_rowToAction[r];
83f0e0bc Poul Sander 2026-05-30 17:59 190
            if (actionIdx < 0)
83f0e0bc Poul Sander 2026-05-30 17:59 191
                continue;
83f0e0bc Poul Sander 2026-05-30 17:59 192
            auto *edit = qobject_cast<QKeySequenceEdit *>(
83f0e0bc Poul Sander 2026-05-30 17:59 193
                m_shortcutsTable->cellWidget(r, 1));
83f0e0bc Poul Sander 2026-05-30 17:59 194
            if (edit)
83f0e0bc Poul Sander 2026-05-30 17:59 195
                edit->setKeySequence(ShortcutManager::defaultShortcut(
83f0e0bc Poul Sander 2026-05-30 17:59 196
                    static_cast<ShortcutManager::Action>(actionIdx)));
83f0e0bc Poul Sander 2026-05-30 17:59 197
        }
83f0e0bc Poul Sander 2026-05-30 17:59 198
        highlightConflicts();
d1aa6cbe Poul Sander 2026-03-02 16:57 199
    });
83f0e0bc Poul Sander 2026-05-30 17:59 200
83f0e0bc Poul Sander 2026-05-30 17:59 201
    tabs->addTab(page, "Shortcuts");
83f0e0bc Poul Sander 2026-05-30 17:59 202
}
83f0e0bc Poul Sander 2026-05-30 17:59 203
83f0e0bc Poul Sander 2026-05-30 17:59 204
void PreferencesDialog::highlightConflicts()
83f0e0bc Poul Sander 2026-05-30 17:59 205
{
83f0e0bc Poul Sander 2026-05-30 17:59 206
    // Group sequences by category, then detect conflicts within each category.
83f0e0bc Poul Sander 2026-05-30 17:59 207
    // key: (category, sequenceString) → list of rows
83f0e0bc Poul Sander 2026-05-30 17:59 208
    QMap<QPair<int,QString>, QList<int>> catSeqToRows;
83f0e0bc Poul Sander 2026-05-30 17:59 209
83f0e0bc Poul Sander 2026-05-30 17:59 210
    for (int r = 0; r < m_rowToAction.size(); ++r) {
83f0e0bc Poul Sander 2026-05-30 17:59 211
        int actionIdx = m_rowToAction[r];
83f0e0bc Poul Sander 2026-05-30 17:59 212
        if (actionIdx < 0)
83f0e0bc Poul Sander 2026-05-30 17:59 213
            continue;
83f0e0bc Poul Sander 2026-05-30 17:59 214
        auto *edit = qobject_cast<QKeySequenceEdit *>(
83f0e0bc Poul Sander 2026-05-30 17:59 215
            m_shortcutsTable->cellWidget(r, 1));
83f0e0bc Poul Sander 2026-05-30 17:59 216
        if (!edit)
83f0e0bc Poul Sander 2026-05-30 17:59 217
            continue;
83f0e0bc Poul Sander 2026-05-30 17:59 218
        QString s = edit->keySequence().toString();
83f0e0bc Poul Sander 2026-05-30 17:59 219
        if (!s.isEmpty()) {
83f0e0bc Poul Sander 2026-05-30 17:59 220
            int cat = ShortcutManager::actionCategory(
83f0e0bc Poul Sander 2026-05-30 17:59 221
                static_cast<ShortcutManager::Action>(actionIdx));
83f0e0bc Poul Sander 2026-05-30 17:59 222
            catSeqToRows[{cat, s}].append(r);
83f0e0bc Poul Sander 2026-05-30 17:59 223
        }
83f0e0bc Poul Sander 2026-05-30 17:59 224
    }
83f0e0bc Poul Sander 2026-05-30 17:59 225
83f0e0bc Poul Sander 2026-05-30 17:59 226
    // Reset all backgrounds
83f0e0bc Poul Sander 2026-05-30 17:59 227
    for (int r = 0; r < m_rowToAction.size(); ++r) {
83f0e0bc Poul Sander 2026-05-30 17:59 228
        if (m_rowToAction[r] < 0)
83f0e0bc Poul Sander 2026-05-30 17:59 229
            continue;
83f0e0bc Poul Sander 2026-05-30 17:59 230
        QTableWidgetItem *item = m_shortcutsTable->item(r, 0);
83f0e0bc Poul Sander 2026-05-30 17:59 231
        if (item)
83f0e0bc Poul Sander 2026-05-30 17:59 232
            item->setBackground(QBrush());
83f0e0bc Poul Sander 2026-05-30 17:59 233
    }
83f0e0bc Poul Sander 2026-05-30 17:59 234
83f0e0bc Poul Sander 2026-05-30 17:59 235
    // Highlight conflicts (only within same category)
83f0e0bc Poul Sander 2026-05-30 17:59 236
    for (auto it = catSeqToRows.cbegin(); it != catSeqToRows.cend(); ++it) {
83f0e0bc Poul Sander 2026-05-30 17:59 237
        if (it.value().size() > 1) {
83f0e0bc Poul Sander 2026-05-30 17:59 238
            for (int r : it.value()) {
83f0e0bc Poul Sander 2026-05-30 17:59 239
                QTableWidgetItem *item = m_shortcutsTable->item(r, 0);
83f0e0bc Poul Sander 2026-05-30 17:59 240
                if (item)
83f0e0bc Poul Sander 2026-05-30 17:59 241
                    item->setBackground(QColor(255, 100, 100, 80));
83f0e0bc Poul Sander 2026-05-30 17:59 242
            }
83f0e0bc Poul Sander 2026-05-30 17:59 243
        }
83f0e0bc Poul Sander 2026-05-30 17:59 244
    }
83f0e0bc Poul Sander 2026-05-30 17:59 245
}
83f0e0bc Poul Sander 2026-05-30 17:59 246
83f0e0bc Poul Sander 2026-05-30 17:59 247
QMap<int, QKeySequence> PreferencesDialog::getShortcuts() const
83f0e0bc Poul Sander 2026-05-30 17:59 248
{
83f0e0bc Poul Sander 2026-05-30 17:59 249
    QMap<int, QKeySequence> map;
83f0e0bc Poul Sander 2026-05-30 17:59 250
    for (int r = 0; r < m_rowToAction.size(); ++r) {
83f0e0bc Poul Sander 2026-05-30 17:59 251
        int actionIdx = m_rowToAction[r];
83f0e0bc Poul Sander 2026-05-30 17:59 252
        if (actionIdx < 0)
83f0e0bc Poul Sander 2026-05-30 17:59 253
            continue;
83f0e0bc Poul Sander 2026-05-30 17:59 254
        auto *edit = qobject_cast<QKeySequenceEdit *>(
83f0e0bc Poul Sander 2026-05-30 17:59 255
            m_shortcutsTable->cellWidget(r, 1));
83f0e0bc Poul Sander 2026-05-30 17:59 256
        if (edit)
83f0e0bc Poul Sander 2026-05-30 17:59 257
            map[actionIdx] = edit->keySequence();
83f0e0bc Poul Sander 2026-05-30 17:59 258
    }
83f0e0bc Poul Sander 2026-05-30 17:59 259
    return map;
83f0e0bc Poul Sander 2026-05-30 17:59 260
}
83f0e0bc Poul Sander 2026-05-30 17:59 261
83f0e0bc Poul Sander 2026-05-30 17:59 262
void PreferencesDialog::setShortcuts(const QMap<int, QKeySequence> &map)
83f0e0bc Poul Sander 2026-05-30 17:59 263
{
83f0e0bc Poul Sander 2026-05-30 17:59 264
    for (int r = 0; r < m_rowToAction.size(); ++r) {
83f0e0bc Poul Sander 2026-05-30 17:59 265
        int actionIdx = m_rowToAction[r];
83f0e0bc Poul Sander 2026-05-30 17:59 266
        if (actionIdx < 0)
83f0e0bc Poul Sander 2026-05-30 17:59 267
            continue;
83f0e0bc Poul Sander 2026-05-30 17:59 268
        if (!map.contains(actionIdx))
83f0e0bc Poul Sander 2026-05-30 17:59 269
            continue;
83f0e0bc Poul Sander 2026-05-30 17:59 270
        auto *edit = qobject_cast<QKeySequenceEdit *>(
83f0e0bc Poul Sander 2026-05-30 17:59 271
            m_shortcutsTable->cellWidget(r, 1));
83f0e0bc Poul Sander 2026-05-30 17:59 272
        if (edit)
83f0e0bc Poul Sander 2026-05-30 17:59 273
            edit->setKeySequence(map[actionIdx]);
83f0e0bc Poul Sander 2026-05-30 17:59 274
    }
83f0e0bc Poul Sander 2026-05-30 17:59 275
    highlightConflicts();
10d6e6f8 Poul Sander 2026-02-24 18:40 276
}
10d6e6f8 Poul Sander 2026-02-24 18:40 277
10d6e6f8 Poul Sander 2026-02-24 18:40 278
QString PreferencesDialog::getBackgroundColor() const
10d6e6f8 Poul Sander 2026-02-24 18:40 279
{
10d6e6f8 Poul Sander 2026-02-24 18:40 280
    return m_backgroundColorCombo->currentData().toString();
10d6e6f8 Poul Sander 2026-02-24 18:40 281
}
10d6e6f8 Poul Sander 2026-02-24 18:40 282
10d6e6f8 Poul Sander 2026-02-24 18:40 283
void PreferencesDialog::setBackgroundColor(const QString &color)
10d6e6f8 Poul Sander 2026-02-24 18:40 284
{
10d6e6f8 Poul Sander 2026-02-24 18:40 285
    int index = m_backgroundColorCombo->findData(color);
10d6e6f8 Poul Sander 2026-02-24 18:40 286
    if (index >= 0)
10d6e6f8 Poul Sander 2026-02-24 18:40 287
        m_backgroundColorCombo->setCurrentIndex(index);
10d6e6f8 Poul Sander 2026-02-24 18:40 288
}
4ae57f60 Poul Sander 2026-02-25 21:35 289
459bad0f Poul Sander 2026-05-17 14:11 290
int PreferencesDialog::getCacheSize() const
459bad0f Poul Sander 2026-05-17 14:11 291
{
459bad0f Poul Sander 2026-05-17 14:11 292
    return m_cacheSizeSpinBox->value();
459bad0f Poul Sander 2026-05-17 14:11 293
}
459bad0f Poul Sander 2026-05-17 14:11 294
459bad0f Poul Sander 2026-05-17 14:11 295
void PreferencesDialog::setCacheSize(int n)
459bad0f Poul Sander 2026-05-17 14:11 296
{
459bad0f Poul Sander 2026-05-17 14:11 297
    m_cacheSizeSpinBox->setValue(n);
459bad0f Poul Sander 2026-05-17 14:11 298
}
459bad0f Poul Sander 2026-05-17 14:11 299
ac476ca8 Poul Sander 2026-05-18 16:47 300
QString PreferencesDialog::getThumbnailCacheSize() const
ac476ca8 Poul Sander 2026-05-18 16:47 301
{
ac476ca8 Poul Sander 2026-05-18 16:47 302
    return m_thumbnailSizeCombo->currentData().toString();
ac476ca8 Poul Sander 2026-05-18 16:47 303
}
ac476ca8 Poul Sander 2026-05-18 16:47 304
ac476ca8 Poul Sander 2026-05-18 16:47 305
void PreferencesDialog::setThumbnailCacheSize(const QString &size)
ac476ca8 Poul Sander 2026-05-18 16:47 306
{
ac476ca8 Poul Sander 2026-05-18 16:47 307
    int index = m_thumbnailSizeCombo->findData(size);
ac476ca8 Poul Sander 2026-05-18 16:47 308
    if (index >= 0)
ac476ca8 Poul Sander 2026-05-18 16:47 309
        m_thumbnailSizeCombo->setCurrentIndex(index);
ac476ca8 Poul Sander 2026-05-18 16:47 310
}
ac476ca8 Poul Sander 2026-05-18 16:47 311
4ae57f60 Poul Sander 2026-02-25 21:35 312
bool PreferencesDialog::getLockDocking() const
4ae57f60 Poul Sander 2026-02-25 21:35 313
{
4ae57f60 Poul Sander 2026-02-25 21:35 314
    return m_lockDockingCheck->isChecked();
4ae57f60 Poul Sander 2026-02-25 21:35 315
}
4ae57f60 Poul Sander 2026-02-25 21:35 316
4ae57f60 Poul Sander 2026-02-25 21:35 317
void PreferencesDialog::setLockDocking(bool lock)
4ae57f60 Poul Sander 2026-02-25 21:35 318
{
4ae57f60 Poul Sander 2026-02-25 21:35 319
    m_lockDockingCheck->setChecked(lock);
4ae57f60 Poul Sander 2026-02-25 21:35 320
}
d1aa6cbe Poul Sander 2026-03-02 16:57 321
d1aa6cbe Poul Sander 2026-03-02 16:57 322
bool PreferencesDialog::getResetLayout() const
d1aa6cbe Poul Sander 2026-03-02 16:57 323
{
d1aa6cbe Poul Sander 2026-03-02 16:57 324
    return m_resetLayoutCheck->isChecked();
d1aa6cbe Poul Sander 2026-03-02 16:57 325
}
d1aa6cbe Poul Sander 2026-03-02 16:57 326
d1aa6cbe Poul Sander 2026-03-02 16:57 327
void PreferencesDialog::setResetLayout(bool reset)
d1aa6cbe Poul Sander 2026-03-02 16:57 328
{
d1aa6cbe Poul Sander 2026-03-02 16:57 329
    m_resetLayoutCheck->setChecked(reset);
d1aa6cbe Poul Sander 2026-03-02 16:57 330
}
1970-01-01 00:00 331