| 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 |
|
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
47 |
QHBoxLayout *thumbSizeLayout = new QHBoxLayout; |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
48 |
QLabel *thumbSizeLabel = new QLabel("Thumbnail cache size:"); |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
49 |
m_thumbnailSizeCombo = new QComboBox; |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
50 |
m_thumbnailSizeCombo->addItem("Normal (128 px)", "normal"); |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
51 |
m_thumbnailSizeCombo->addItem("Large (256 px)", "large"); |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
52 |
thumbSizeLayout->addWidget(thumbSizeLabel); |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
53 |
thumbSizeLayout->addWidget(m_thumbnailSizeCombo); |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
54 |
thumbSizeLayout->addStretch(); |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
55 |
groupLayout->addLayout(thumbSizeLayout); |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
56 |
|
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
57 |
mainLayout->addWidget(imageGroup); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
58 |
|
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
59 |
QGroupBox *layoutGroup = new QGroupBox("Layout", this); |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
60 |
QVBoxLayout *layoutGroupLayout = new QVBoxLayout(layoutGroup); |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
61 |
m_lockDockingCheck = new QCheckBox("Lock docking (prevent accidental moves)"); |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
62 |
layoutGroupLayout->addWidget(m_lockDockingCheck); |
| 7370f1c0 |
Poul Sander |
2026-03-01 15:15 |
63 |
|
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
64 |
m_resetLayoutCheck = new QCheckBox("Reset layout to default when closing the menu"); |
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
65 |
layoutGroupLayout->addWidget(m_resetLayoutCheck); |
| 7370f1c0 |
Poul Sander |
2026-03-01 15:15 |
66 |
|
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
67 |
mainLayout->addWidget(layoutGroup); |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
68 |
|
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
69 |
mainLayout->addStretch(); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
70 |
|
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
71 |
QHBoxLayout *buttonLayout = new QHBoxLayout; |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
72 |
QPushButton *okButton = new QPushButton("OK"); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
73 |
QPushButton *cancelButton = new QPushButton("Cancel"); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
74 |
|
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
75 |
buttonLayout->addStretch(); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
76 |
buttonLayout->addWidget(okButton); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
77 |
buttonLayout->addWidget(cancelButton); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
78 |
|
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
79 |
mainLayout->addLayout(buttonLayout); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
80 |
|
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
81 |
connect(okButton, &QPushButton::clicked, this, [this]() { |
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
82 |
if (m_resetLayoutCheck->isChecked()) |
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
83 |
emit resetLayoutRequested(); |
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
84 |
accept(); |
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
85 |
}); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
86 |
connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
87 |
} |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
88 |
|
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
89 |
QString PreferencesDialog::getBackgroundColor() const |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
90 |
{ |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
91 |
return m_backgroundColorCombo->currentData().toString(); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
92 |
} |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
93 |
|
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
94 |
void PreferencesDialog::setBackgroundColor(const QString &color) |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
95 |
{ |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
96 |
int index = m_backgroundColorCombo->findData(color); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
97 |
if (index >= 0) |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
98 |
m_backgroundColorCombo->setCurrentIndex(index); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
99 |
} |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
100 |
|
| 459bad0f |
Poul Sander |
2026-05-17 14:11 |
101 |
int PreferencesDialog::getCacheSize() const |
| 459bad0f |
Poul Sander |
2026-05-17 14:11 |
102 |
{ |
| 459bad0f |
Poul Sander |
2026-05-17 14:11 |
103 |
return m_cacheSizeSpinBox->value(); |
| 459bad0f |
Poul Sander |
2026-05-17 14:11 |
104 |
} |
| 459bad0f |
Poul Sander |
2026-05-17 14:11 |
105 |
|
| 459bad0f |
Poul Sander |
2026-05-17 14:11 |
106 |
void PreferencesDialog::setCacheSize(int n) |
| 459bad0f |
Poul Sander |
2026-05-17 14:11 |
107 |
{ |
| 459bad0f |
Poul Sander |
2026-05-17 14:11 |
108 |
m_cacheSizeSpinBox->setValue(n); |
| 459bad0f |
Poul Sander |
2026-05-17 14:11 |
109 |
} |
| 459bad0f |
Poul Sander |
2026-05-17 14:11 |
110 |
|
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
111 |
QString PreferencesDialog::getThumbnailCacheSize() const |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
112 |
{ |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
113 |
return m_thumbnailSizeCombo->currentData().toString(); |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
114 |
} |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
115 |
|
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
116 |
void PreferencesDialog::setThumbnailCacheSize(const QString &size) |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
117 |
{ |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
118 |
int index = m_thumbnailSizeCombo->findData(size); |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
119 |
if (index >= 0) |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
120 |
m_thumbnailSizeCombo->setCurrentIndex(index); |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
121 |
} |
| ac476ca8 |
Poul Sander |
2026-05-18 16:47 |
122 |
|
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
123 |
bool PreferencesDialog::getLockDocking() const |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
124 |
{ |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
125 |
return m_lockDockingCheck->isChecked(); |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
126 |
} |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
127 |
|
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
128 |
void PreferencesDialog::setLockDocking(bool lock) |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
129 |
{ |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
130 |
m_lockDockingCheck->setChecked(lock); |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
131 |
} |
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
132 |
|
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
133 |
bool PreferencesDialog::getResetLayout() const |
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
134 |
{ |
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
135 |
return m_resetLayoutCheck->isChecked(); |
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
136 |
} |
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
137 |
|
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
138 |
void PreferencesDialog::setResetLayout(bool reset) |
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
139 |
{ |
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
140 |
m_resetLayoutCheck->setChecked(reset); |
| d1aa6cbe |
Poul Sander |
2026-03-02 16:57 |
141 |
} |
|
|
1970-01-01 00:00 |
142 |
|