added settingsdialog cancel
This commit is contained in:
+12
-10
@@ -145,7 +145,8 @@ NotebookPage::dragEnterEvent(QDragEnterEvent *event)
|
||||
for (int i = 0; i < this->hbox.count() + 1; ++i) {
|
||||
this->dropRegions.push_back(DropRegion(
|
||||
QRect(((i * 4 - 1) * width() / this->hbox.count()) / 4, 0,
|
||||
width() / this->hbox.count() / 2, height()),
|
||||
width() / this->hbox.count() / 2 + 1, height() + 1),
|
||||
|
||||
std::pair<int, int>(i, -1)));
|
||||
}
|
||||
|
||||
@@ -156,8 +157,9 @@ NotebookPage::dragEnterEvent(QDragEnterEvent *event)
|
||||
this->dropRegions.push_back(DropRegion(
|
||||
QRect(i * width() / this->hbox.count(),
|
||||
((j * 2 - 1) * height() / vbox->count()) / 2,
|
||||
width() / this->hbox.count(),
|
||||
height() / vbox->count()),
|
||||
width() / this->hbox.count() + 1,
|
||||
height() / vbox->count() + 1),
|
||||
|
||||
std::pair<int, int>(i, j)));
|
||||
}
|
||||
}
|
||||
@@ -181,19 +183,19 @@ NotebookPage::setPreviewRect(QPoint mousePos)
|
||||
for (DropRegion region : this->dropRegions) {
|
||||
if (region.rect.contains(mousePos)) {
|
||||
this->preview.setBounds(region.rect);
|
||||
// this->preview.move(region.rect.x(), region.rect.y());
|
||||
// this->preview.resize(region.rect.width(),
|
||||
// region.rect.height());
|
||||
this->preview.show();
|
||||
this->preview.raise();
|
||||
|
||||
if (!this->preview.isVisible()) {
|
||||
this->preview.show();
|
||||
this->preview.raise();
|
||||
}
|
||||
|
||||
dropPosition = region.position;
|
||||
|
||||
return;
|
||||
} else {
|
||||
this->preview.hide();
|
||||
}
|
||||
}
|
||||
|
||||
this->preview.hide();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace chatterino {
|
||||
namespace widgets {
|
||||
|
||||
SettingsDialog::SettingsDialog()
|
||||
: snapshot(Settings::getInstance().createSnapshot())
|
||||
{
|
||||
QFile file(":/qss/settings.qss");
|
||||
file.open(QFile::ReadOnly);
|
||||
@@ -43,6 +44,12 @@ SettingsDialog::SettingsDialog()
|
||||
buttonBox.addButton(&okButton, QDialogButtonBox::ButtonRole::AcceptRole);
|
||||
buttonBox.addButton(&cancelButton,
|
||||
QDialogButtonBox::ButtonRole::RejectRole);
|
||||
|
||||
QObject::connect(&okButton, &QPushButton::clicked, this,
|
||||
&SettingsDialog::okButtonClicked);
|
||||
QObject::connect(&cancelButton, &QPushButton::clicked, this,
|
||||
&SettingsDialog::cancelButtonClicked);
|
||||
|
||||
okButton.setText("OK");
|
||||
cancelButton.setText("Cancel");
|
||||
|
||||
@@ -226,8 +233,7 @@ SettingsDialog::select(SettingsDialogTab *tab)
|
||||
|
||||
/// Widget creation helpers
|
||||
QCheckBox *
|
||||
SettingsDialog::createCheckbox(const QString &title,
|
||||
Setting<bool> &setting)
|
||||
SettingsDialog::createCheckbox(const QString &title, Setting<bool> &setting)
|
||||
{
|
||||
auto checkbox = new QCheckBox(title);
|
||||
|
||||
@@ -240,5 +246,19 @@ SettingsDialog::createCheckbox(const QString &title,
|
||||
return checkbox;
|
||||
}
|
||||
|
||||
void
|
||||
SettingsDialog::okButtonClicked()
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
|
||||
void
|
||||
SettingsDialog::cancelButtonClicked()
|
||||
{
|
||||
snapshot.apply();
|
||||
|
||||
this->close();
|
||||
}
|
||||
|
||||
} // namespace widgets
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define SETTINGSDIALOG_H
|
||||
|
||||
#include "settings.h"
|
||||
#include "settingssnapshot.h"
|
||||
#include "widgets/settingsdialogtab.h"
|
||||
|
||||
#include <QButtonGroup>
|
||||
@@ -26,6 +27,8 @@ public:
|
||||
void select(SettingsDialogTab *tab);
|
||||
|
||||
private:
|
||||
SettingsSnapshot snapshot;
|
||||
|
||||
QVBoxLayout tabs;
|
||||
QVBoxLayout vbox;
|
||||
QHBoxLayout hbox;
|
||||
@@ -41,8 +44,10 @@ private:
|
||||
SettingsDialogTab *selectedTab = NULL;
|
||||
|
||||
/// Widget creation helpers
|
||||
QCheckBox *createCheckbox(const QString &title,
|
||||
Setting<bool> &setting);
|
||||
QCheckBox *createCheckbox(const QString &title, Setting<bool> &setting);
|
||||
|
||||
void okButtonClicked();
|
||||
void cancelButtonClicked();
|
||||
};
|
||||
|
||||
} // namespace widgets
|
||||
|
||||
Reference in New Issue
Block a user