2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Notifications settings done: screen corner selection + max count.

This commit is contained in:
John Preston
2016-10-06 19:41:09 +03:00
parent e7b6d7b498
commit 16ce28f4d2
13 changed files with 594 additions and 133 deletions

View File

@@ -30,11 +30,17 @@ DiscreteSlider::DiscreteSlider(QWidget *parent) : TWidget(parent)
setCursor(style::cur_pointer);
}
void DiscreteSlider::setSectionActivatedCallback(SectionActivatedCallback &&callback) {
_callback = std_::move(callback);
}
void DiscreteSlider::setActiveSection(int index) {
setSelectedSection(index);
if (_activeIndex != index) {
_activeIndex = index;
emit sectionActivated();
if (_callback) {
_callback();
}
}
}

View File

@@ -23,17 +23,19 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
namespace Ui {
class DiscreteSlider : public TWidget {
Q_OBJECT
public:
DiscreteSlider(QWidget *parent);
void addSection(const QString &label);
int activeSection() const {
return _activeIndex;
}
void setActiveSection(int index);
void setActiveSectionFast(int index);
void addSection(const QString &label);
using SectionActivatedCallback = base::lambda_unique<void()>;
void setSectionActivatedCallback(SectionActivatedCallback &&callback);
protected:
void paintEvent(QPaintEvent *e) override;
@@ -43,9 +45,6 @@ protected:
int resizeGetHeight(int newWidth) override;
signals:
void sectionActivated();
private:
void resizeSections(int newWidth);
int getIndexFromPosition(QPoint pos);
@@ -62,6 +61,8 @@ private:
QList<Section> _sections;
int _activeIndex = 0;
SectionActivatedCallback _callback;
bool _pressed = false;
int _selected = 0;
anim::ivalue a_left = { 0 };