Skip to content

Commit 9ad36df

Browse files
committed
add border and cancel buttion
1 parent cee27a7 commit 9ad36df

File tree

3 files changed

+41
-15
lines changed

3 files changed

+41
-15
lines changed

src/Dialog.cpp

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,54 @@ Dialog::Dialog(QWidget *parent)
2323
m_buttonGroup(new QButtonGroup(this)),
2424
m_okButton(new QPushButton("OK", this))
2525
{
26-
// Remove or reduce spacing between widgets
27-
m_layout->setSpacing(4); // smaller space between widgets
28-
m_layout->setContentsMargins(10, 10, 10, 10);
29-
30-
// Add stretch to push content to vertical center
31-
m_layout->addStretch(1);
32-
33-
// Label (centered)
26+
// ========== Frame to hold content ==========
27+
QFrame *frame = new QFrame(this);
28+
frame->setFrameShape(QFrame::StyledPanel);
29+
frame->setFrameShadow(QFrame::Plain);
30+
frame->setStyleSheet("QFrame { border: 1px solid #999; border-radius: 6px; padding: 10px; }");
31+
32+
// Layout inside the frame
33+
QVBoxLayout *frameLayout = new QVBoxLayout(frame);
34+
frameLayout->setSpacing(6);
35+
frameLayout->setContentsMargins(10, 10, 10, 10);
36+
37+
// Label
3438
m_label->setAlignment(Qt::AlignCenter);
35-
m_layout->addWidget(m_label, 0, Qt::AlignHCenter);
39+
frameLayout->addWidget(m_label, 0, Qt::AlignHCenter);
3640

37-
// Option container (centered and compact)
38-
m_optionLayout->setContentsMargins(0, 0, 0, 0);
41+
// Options
3942
m_optionLayout->setSpacing(4);
43+
m_optionLayout->setContentsMargins(0, 0, 0, 0);
4044
m_optionContainer->setLayout(m_optionLayout);
41-
m_layout->addWidget(m_optionContainer, 0, Qt::AlignHCenter);
45+
frameLayout->addWidget(m_optionContainer, 0, Qt::AlignHCenter);
4246

43-
// OK Button (centered, fixed width)
47+
// ========== OK + Cancel buttons ==========
48+
QHBoxLayout *buttonLayout = new QHBoxLayout;
4449
m_okButton->setFixedWidth(80);
45-
m_layout->addWidget(m_okButton, 0, Qt::AlignHCenter);
50+
QPushButton *m_cancelButton = new QPushButton("Cancel", this);
51+
m_cancelButton->setFixedWidth(80);
4652

53+
buttonLayout->addStretch();
54+
buttonLayout->addWidget(m_okButton);
55+
buttonLayout->addWidget(m_cancelButton);
56+
buttonLayout->addStretch();
57+
58+
frameLayout->addLayout(buttonLayout);
59+
60+
// ========== Main layout ==========
61+
m_layout->setSpacing(4);
62+
m_layout->setContentsMargins(10, 10, 10, 10);
63+
m_layout->addStretch(1);
64+
m_layout->addWidget(frame, 0, Qt::AlignHCenter);
4765
m_layout->addStretch(1);
4866

49-
// Connect OK button
67+
// ========== Connections ==========
5068
connect(m_okButton, &QPushButton::clicked, this, [this]() {
5169
emit okClicked();
5270
});
71+
connect(m_cancelButton, &QPushButton::clicked, this, [this]() {
72+
emit cancelClicked(); // Add this signal in your class
73+
});
5374
}
5475

5576
void Dialog::setMessage(const QString &text) {

src/Dialog.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class Dialog : public QWidget {
3232

3333
signals:
3434
void okClicked();
35+
void cancelClicked();
3536

3637
private:
3738
QVBoxLayout* m_layout;

src/TombRaiderLinuxLauncher.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ TombRaiderLinuxLauncher::TombRaiderLinuxLauncher(QWidget *parent)
169169
ui->stackedWidget->setCurrentWidget(
170170
ui->stackedWidget->findChild<QWidget*>("select"));
171171
});
172+
connect(m_dialogWidget, &Dialog::cancelClicked, this, [this]() {
173+
ui->stackedWidget->setCurrentWidget(
174+
ui->stackedWidget->findChild<QWidget*>("select"));
175+
});
172176

173177

174178
ui->Tabs->setTabEnabled(

0 commit comments

Comments
 (0)