| 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> |
| 7370f1c0 |
Poul Sander |
2026-03-01 15:15 |
10 |
#include <QMessageBox> |
| 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); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
36 |
mainLayout->addWidget(imageGroup); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
37 |
|
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
38 |
QGroupBox *layoutGroup = new QGroupBox("Layout", this); |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
39 |
QVBoxLayout *layoutGroupLayout = new QVBoxLayout(layoutGroup); |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
40 |
m_lockDockingCheck = new QCheckBox("Lock docking (prevent accidental moves)"); |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
41 |
layoutGroupLayout->addWidget(m_lockDockingCheck); |
| 7370f1c0 |
Poul Sander |
2026-03-01 15:15 |
42 |
|
| 7370f1c0 |
Poul Sander |
2026-03-01 15:15 |
43 |
QPushButton *resetLayoutButton = new QPushButton("Reset Layout to Default"); |
| 7370f1c0 |
Poul Sander |
2026-03-01 15:15 |
44 |
connect(resetLayoutButton, &QPushButton::clicked, this, [this]() { |
| 7370f1c0 |
Poul Sander |
2026-03-01 15:15 |
45 |
QMessageBox::information(this, "Layout Reset", "The window layout will be reset to default."); |
| 7370f1c0 |
Poul Sander |
2026-03-01 15:15 |
46 |
emit resetLayoutRequested(); |
| 7370f1c0 |
Poul Sander |
2026-03-01 15:15 |
47 |
accept(); // Close the dialog |
| 7370f1c0 |
Poul Sander |
2026-03-01 15:15 |
48 |
}); |
| 7370f1c0 |
Poul Sander |
2026-03-01 15:15 |
49 |
layoutGroupLayout->addWidget(resetLayoutButton); |
| 7370f1c0 |
Poul Sander |
2026-03-01 15:15 |
50 |
|
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
51 |
mainLayout->addWidget(layoutGroup); |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
52 |
|
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
53 |
mainLayout->addStretch(); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
54 |
|
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
55 |
QHBoxLayout *buttonLayout = new QHBoxLayout; |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
56 |
QPushButton *okButton = new QPushButton("OK"); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
57 |
QPushButton *cancelButton = new QPushButton("Cancel"); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
58 |
|
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
59 |
buttonLayout->addStretch(); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
60 |
buttonLayout->addWidget(okButton); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
61 |
buttonLayout->addWidget(cancelButton); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
62 |
|
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
63 |
mainLayout->addLayout(buttonLayout); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
64 |
|
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
65 |
connect(okButton, &QPushButton::clicked, this, &QDialog::accept); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
66 |
connect(cancelButton, &QPushButton::clicked, this, &QDialog::reject); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
67 |
} |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
68 |
|
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
69 |
QString PreferencesDialog::getBackgroundColor() const |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
70 |
{ |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
71 |
return m_backgroundColorCombo->currentData().toString(); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
72 |
} |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
73 |
|
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
74 |
void PreferencesDialog::setBackgroundColor(const QString &color) |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
75 |
{ |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
76 |
int index = m_backgroundColorCombo->findData(color); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
77 |
if (index >= 0) |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
78 |
m_backgroundColorCombo->setCurrentIndex(index); |
| 10d6e6f8 |
Poul Sander |
2026-02-24 18:40 |
79 |
} |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
80 |
|
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
81 |
bool PreferencesDialog::getLockDocking() const |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
82 |
{ |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
83 |
return m_lockDockingCheck->isChecked(); |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
84 |
} |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
85 |
|
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
86 |
void PreferencesDialog::setLockDocking(bool lock) |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
87 |
{ |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
88 |
m_lockDockingCheck->setChecked(lock); |
| 4ae57f60 |
Poul Sander |
2026-02-25 21:35 |
89 |
} |
|
|
1970-01-01 00:00 |
90 |
|