2017-01-01 18:43:52 +01:00
|
|
|
#include "settingsdialog.h"
|
2017-01-02 03:02:32 +01:00
|
|
|
#include "settingsdialogtab.h"
|
|
|
|
|
|
|
|
#include "QPalette"
|
|
|
|
#include "QFile"
|
|
|
|
#include "QResource"
|
|
|
|
#include "QLabel"
|
|
|
|
#include "QFormLayout"
|
|
|
|
#include "QComboBox"
|
2017-01-03 21:19:33 +01:00
|
|
|
#include "QGroupBox"
|
2017-01-01 18:43:52 +01:00
|
|
|
|
|
|
|
SettingsDialog::SettingsDialog()
|
|
|
|
{
|
2017-01-02 03:02:32 +01:00
|
|
|
QFile file(":/qss/settings.qss");
|
|
|
|
file.open(QFile::ReadOnly);
|
|
|
|
QString styleSheet = QLatin1String(file.readAll());
|
|
|
|
setStyleSheet(styleSheet);
|
|
|
|
|
|
|
|
QPalette palette;
|
|
|
|
palette.setColor(QPalette::Background, QColor("#444"));
|
|
|
|
setPalette(palette);
|
|
|
|
|
|
|
|
pageStack.setObjectName("pages");
|
|
|
|
|
|
|
|
setLayout(&vbox);
|
|
|
|
|
|
|
|
vbox.addLayout(&hbox);
|
|
|
|
|
|
|
|
vbox.addWidget(&buttonBox);
|
|
|
|
|
|
|
|
auto tabWidget = new QWidget();
|
|
|
|
tabWidget->setObjectName("tabWidget");
|
|
|
|
|
|
|
|
tabWidget->setLayout(&tabs);
|
|
|
|
tabWidget->setFixedWidth(200);
|
|
|
|
|
|
|
|
hbox.addWidget(tabWidget);
|
|
|
|
hbox.addLayout(&pageStack);
|
|
|
|
|
|
|
|
buttonBox.addButton(&okButton, QDialogButtonBox::ButtonRole::AcceptRole);
|
|
|
|
buttonBox.addButton(&cancelButton, QDialogButtonBox::ButtonRole::RejectRole);
|
|
|
|
okButton.setText("OK");
|
|
|
|
cancelButton.setText("Cancel");
|
|
|
|
|
|
|
|
resize(600, 500);
|
|
|
|
|
|
|
|
addTabs();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::addTabs()
|
|
|
|
{
|
|
|
|
QVBoxLayout* vbox;
|
|
|
|
|
|
|
|
// Appearance
|
|
|
|
vbox = new QVBoxLayout();
|
|
|
|
|
|
|
|
{
|
2017-01-03 21:19:33 +01:00
|
|
|
auto group = new QGroupBox("Application");
|
|
|
|
|
2017-01-02 03:02:32 +01:00
|
|
|
auto form = new QFormLayout();
|
|
|
|
auto combo = new QComboBox();
|
|
|
|
auto slider = new QSlider(Qt::Horizontal);
|
|
|
|
auto font = new QPushButton("select");
|
|
|
|
|
|
|
|
form->addRow("Theme:", combo);
|
2017-01-03 21:19:33 +01:00
|
|
|
form->addRow("Theme color:", slider);
|
2017-01-02 03:02:32 +01:00
|
|
|
form->addRow("Font:", font);
|
|
|
|
|
2017-01-03 21:19:33 +01:00
|
|
|
group->setLayout(form);
|
|
|
|
|
|
|
|
vbox->addWidget(group);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
auto group = new QGroupBox("Messages");
|
|
|
|
|
|
|
|
auto v = new QVBoxLayout();
|
|
|
|
v->addWidget(createCheckbox("Show timestamp", ""));
|
|
|
|
v->addWidget(createCheckbox("Show seconds in timestamp", ""));
|
|
|
|
v->addWidget(createCheckbox("Allow sending duplicate messages (add a space at the end)", ""));
|
|
|
|
v->addWidget(createCheckbox("Seperate messages", ""));
|
|
|
|
v->addWidget(createCheckbox("Show message length", ""));
|
|
|
|
|
|
|
|
group->setLayout(v);
|
|
|
|
|
|
|
|
vbox->addWidget(group);
|
2017-01-02 03:02:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
vbox->addStretch(1);
|
|
|
|
|
|
|
|
addTab(vbox, "Appearance", ":/images/AppearanceEditorPart_16x.png");
|
|
|
|
|
2017-01-03 21:19:33 +01:00
|
|
|
// Behaviour
|
|
|
|
vbox = new QVBoxLayout();
|
|
|
|
|
|
|
|
vbox->addWidget(createCheckbox("Hide input box if empty", ""));
|
|
|
|
vbox->addWidget(createCheckbox("Mention users with a @ (except in commands)", ""));
|
|
|
|
vbox->addWidget(createCheckbox("Window always on top", ""));
|
|
|
|
vbox->addWidget(createCheckbox("Show last read message indicator", ""));
|
|
|
|
|
|
|
|
{
|
|
|
|
auto v = new QVBoxLayout();
|
|
|
|
v->addWidget(new QLabel("Mouse scroll speed"));
|
|
|
|
|
|
|
|
auto scroll = new QSlider(Qt::Horizontal);
|
|
|
|
|
|
|
|
v->addWidget(scroll);
|
|
|
|
v->addStretch(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
vbox->addStretch(1);
|
|
|
|
|
|
|
|
addTab(vbox, "Behaviour", ":/images/AppearanceEditorPart_16x.png");
|
|
|
|
|
2017-01-02 03:02:32 +01:00
|
|
|
// Commands
|
|
|
|
vbox = new QVBoxLayout();
|
|
|
|
|
|
|
|
vbox->addWidget(new QLabel());
|
|
|
|
|
|
|
|
vbox->addStretch(1);
|
|
|
|
|
|
|
|
addTab(vbox, "Commands", ":/images/CustomActionEditor_16x.png");
|
|
|
|
|
|
|
|
// Add stretch
|
|
|
|
tabs.addStretch(1);
|
|
|
|
}
|
|
|
|
|
2017-01-03 21:19:33 +01:00
|
|
|
QCheckBox* SettingsDialog::createCheckbox(QString title, QString settingsId)
|
|
|
|
{
|
|
|
|
return new QCheckBox(title);
|
|
|
|
}
|
|
|
|
|
2017-01-02 03:02:32 +01:00
|
|
|
void SettingsDialog::addTab(QLayout* layout, QString title, QString imageRes)
|
|
|
|
{
|
|
|
|
auto widget = new QWidget();
|
|
|
|
|
|
|
|
widget->setLayout(layout);
|
|
|
|
|
|
|
|
auto tab = new SettingsDialogTab(this, title, imageRes);
|
|
|
|
|
|
|
|
tab->widget = widget;
|
|
|
|
|
|
|
|
tabs.addWidget(tab, 0, Qt::AlignTop);
|
|
|
|
|
|
|
|
pageStack.addWidget(widget);
|
|
|
|
|
|
|
|
if (tabs.count() == 1)
|
|
|
|
{
|
|
|
|
select(tab);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SettingsDialog::select(SettingsDialogTab* tab)
|
|
|
|
{
|
|
|
|
pageStack.setCurrentWidget(tab->widget);
|
|
|
|
|
|
|
|
if (selectedTab != NULL)
|
|
|
|
{
|
|
|
|
selectedTab->setSelected(false);
|
|
|
|
selectedTab->setStyleSheet("");
|
|
|
|
}
|
2017-01-01 18:43:52 +01:00
|
|
|
|
2017-01-02 03:02:32 +01:00
|
|
|
tab->setSelected(true);
|
|
|
|
tab->setStyleSheet("background: #F00;"
|
|
|
|
"background: qlineargradient( x1:0 y1:0, x2:1 y2:0, stop:0 #333, stop:1 #555);"
|
|
|
|
"border-right: none;");
|
|
|
|
selectedTab = tab;
|
2017-01-01 18:43:52 +01:00
|
|
|
}
|