-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetupdialog.cpp
More file actions
159 lines (116 loc) · 4.72 KB
/
setupdialog.cpp
File metadata and controls
159 lines (116 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#include "setupdialog.h"
#include <QCoreApplication>
#include <QFileDialog>
#include <QLabel>
#include <QMessageBox>
#include <QPushButton>
#include <QTextEdit>
#include <QVBoxLayout>
SetupDialog::SetupDialog(QWidget* parent) : QDialog(parent) {
this->setWindowTitle("Setup Wizard");
this->setFixedSize(400,400);
setWindowFlags(Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint);
m_quit = false;
createFirstPage();
createSecondPage();
m_stackWidget = new QStackedWidget();
m_stackWidget->addWidget(m_firstPage);
m_stackWidget->addWidget(m_secondPage);
QVBoxLayout *contentLayout = new QVBoxLayout(this);
QWidget *contentWidget = new QWidget(this);
contentLayout->addWidget(m_stackWidget);
contentWidget->setLayout(contentLayout);
this->setLayout(contentLayout);
connect(m_nextButton, SIGNAL(clicked()), this, SLOT(onNextClick()));
connect(m_backButton, SIGNAL(clicked()), this, SLOT(onBackClick()));
connect(m_addFolder, SIGNAL(clicked()), this, SLOT(onAddClick()));
connect(m_finishButton, SIGNAL(clicked()), this, SLOT(onFinishClick()));
connect(m_quitButton, SIGNAL(clicked()), this, SLOT(onQuitClick()));
}
void SetupDialog::createFirstPage()
{
m_firstPage = new QWidget();
QVBoxLayout *mainLayout = new QVBoxLayout();
QLabel *label = new QLabel("Welcome!");
label->setStyleSheet("font-size: 20px");
QLabel *content = new QLabel(this);
content->setStyleSheet("background-color: transparent; border: 0px;");
content->setText(
"Welcome to Tunes music player\n"
"Press Add button to select folders which you'd like to import music from. \n ");
content->setMaximumHeight(100);
QLabel *fileLabel = new QLabel("Monitored folders");
m_addFolder = new QPushButton("Add");
m_addFolder->setMaximumSize(50,50);
QHBoxLayout *buttons = new QHBoxLayout();
m_nextButton = new QPushButton("Next");
m_quitButton = new QPushButton("Quit");
buttons->addWidget(m_nextButton);
buttons->addWidget(m_quitButton);
mainLayout->setAlignment(Qt::AlignTop);
mainLayout->addWidget(label);
mainLayout->addWidget(content);
mainLayout->addSpacing(100);
mainLayout->addWidget(fileLabel);
mainLayout->addWidget(m_addFolder);
mainLayout->addSpacing(200);
mainLayout->addLayout(buttons);
m_firstPage->setLayout(mainLayout);
}
void SetupDialog::createSecondPage() {
m_secondPage = new QWidget();
QVBoxLayout *mainLayout = new QVBoxLayout();
QLabel *label = new QLabel("Setup finished");
label->setStyleSheet("font-size: 20px");
QLabel *content = new QLabel(this);
content->setStyleSheet("background-color: transparent; border: 0px;");
content->setText(
"Setup finished!\n"
"Go on and enjoy your freshly imported music. \n You can also check some other "
" settings from Settings -menu.\n ");
content->setMaximumHeight(100);
QHBoxLayout *buttons = new QHBoxLayout();
m_backButton = new QPushButton("Back");
m_finishButton = new QPushButton("Finish");
buttons->addWidget(m_backButton);
buttons->addWidget(m_finishButton);
mainLayout->setAlignment(Qt::AlignTop);
mainLayout->addWidget(label);
mainLayout->addWidget(content);
mainLayout->addSpacing(100);
mainLayout->addSpacing(200);
mainLayout->addLayout(buttons);
m_secondPage->setLayout(mainLayout);
}
bool SetupDialog::getQuit() const
{
return m_quit;
}
void SetupDialog::onAddClick() {
QString folder = QFileDialog::getExistingDirectory(this,tr("Choose a Folder"),QDir::homePath());
}
void SetupDialog::onNextClick() {
m_stackWidget->setCurrentWidget(m_secondPage);
}
void SetupDialog::onBackClick() {
m_stackWidget->setCurrentWidget(m_firstPage);
}
void SetupDialog::onFinishClick() {
QMessageBox::StandardButton msgBox;
msgBox = QMessageBox::question(this, "Finished?", "Are you sure you are finished? \n"
"Clicking Yes takes you to the main window and clicking No goes back to Setup.",
QMessageBox::Yes |QMessageBox::No);
if (msgBox == QMessageBox::Yes) {
accept();
}
}
void SetupDialog::onQuitClick()
{
QMessageBox::StandardButton msgBox;
msgBox = QMessageBox::question(this, "Quit?", "Are you sure you want to quit? \n"
"You will have to complete this setup process on next startup.",
QMessageBox::Yes |QMessageBox::No);
if (msgBox == QMessageBox::Yes)
QCoreApplication::quit();
m_quit = true;
}