fixed settings color
This commit is contained in:
+1
-5
@@ -6,14 +6,10 @@
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsDialogTab {
|
|
||||||
color: #FFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
SettingsDialogTab:hover {
|
SettingsDialogTab:hover {
|
||||||
border: 1px solid grey;
|
border: 1px solid grey;
|
||||||
}
|
}
|
||||||
|
|
||||||
QLabel, QCheckBox, QGroupBox {
|
QLabel, QCheckBox, QGroupBox, SettingsDialogTab {
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ ChatWidgetView::ChatWidgetView(ChatWidget *parent)
|
|||||||
QObject::connect(&Settings::getInstance(), &Settings::wordTypeMaskChanged,
|
QObject::connect(&Settings::getInstance(), &Settings::wordTypeMaskChanged,
|
||||||
this, &ChatWidgetView::wordTypeMaskChanged);
|
this, &ChatWidgetView::wordTypeMaskChanged);
|
||||||
|
|
||||||
this->scrollbar.getValueChanged().connect([this] { update(); });
|
this->scrollbar.getCurrentValueChanged().connect([this] { update(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatWidgetView::~ChatWidgetView()
|
ChatWidgetView::~ChatWidgetView()
|
||||||
@@ -62,13 +62,12 @@ ChatWidgetView::layoutMessages()
|
|||||||
|
|
||||||
message->layout(this->width(), true);
|
message->layout(this->width(), true);
|
||||||
|
|
||||||
qDebug() << message->getHeight();
|
|
||||||
h -= message->getHeight();
|
h -= message->getHeight();
|
||||||
|
|
||||||
if (h < 0) {
|
if (h < 0) {
|
||||||
this->scrollbar.setLargeChange((messages.size() - i) +
|
this->scrollbar.setLargeChange((messages.size() - i) +
|
||||||
(qreal)h / message->getHeight());
|
(qreal)h / message->getHeight());
|
||||||
this->scrollbar.setValue(this->scrollbar.getValue());
|
this->scrollbar.setDesiredValue(this->scrollbar.getDesiredValue());
|
||||||
|
|
||||||
showScrollbar = true;
|
showScrollbar = true;
|
||||||
break;
|
break;
|
||||||
@@ -141,14 +140,14 @@ ChatWidgetView::paintEvent(QPaintEvent *)
|
|||||||
|
|
||||||
auto messages = c->getMessagesClone();
|
auto messages = c->getMessagesClone();
|
||||||
|
|
||||||
int start = this->scrollbar.getValue();
|
int start = this->scrollbar.getCurrentValue();
|
||||||
|
|
||||||
if (start >= messages.length()) {
|
if (start >= messages.length()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int y = -(messages[start].get()->getHeight() *
|
int y = -(messages[start].get()->getHeight() *
|
||||||
(fmod(this->scrollbar.getValue(), 1)));
|
(fmod(this->scrollbar.getCurrentValue(), 1)));
|
||||||
|
|
||||||
for (int i = start; i < messages.size(); ++i) {
|
for (int i = start; i < messages.size(); ++i) {
|
||||||
messages::Message *message = messages[i].get();
|
messages::Message *message = messages[i].get();
|
||||||
@@ -198,8 +197,8 @@ ChatWidgetView::paintEvent(QPaintEvent *)
|
|||||||
void
|
void
|
||||||
ChatWidgetView::wheelEvent(QWheelEvent *event)
|
ChatWidgetView::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
this->scrollbar.setValue(
|
this->scrollbar.setDesiredValue(
|
||||||
this->scrollbar.getValue() -
|
this->scrollbar.getDesiredValue() -
|
||||||
event->delta() / 10.0 *
|
event->delta() / 10.0 *
|
||||||
Settings::getInstance().mouseScrollMultiplier.get(),
|
Settings::getInstance().mouseScrollMultiplier.get(),
|
||||||
true);
|
true);
|
||||||
|
|||||||
+14
-13
@@ -12,7 +12,7 @@ namespace widgets {
|
|||||||
ScrollBar::ScrollBar(QWidget *widget)
|
ScrollBar::ScrollBar(QWidget *widget)
|
||||||
: QWidget(widget)
|
: QWidget(widget)
|
||||||
, mutex()
|
, mutex()
|
||||||
, valueAnimation(this, "value")
|
, currentValueAnimation(this, "currentValue")
|
||||||
, highlights(NULL)
|
, highlights(NULL)
|
||||||
, mouseOverIndex(-1)
|
, mouseOverIndex(-1)
|
||||||
, mouseDownIndex(-1)
|
, mouseDownIndex(-1)
|
||||||
@@ -24,13 +24,14 @@ ScrollBar::ScrollBar(QWidget *widget)
|
|||||||
, minimum()
|
, minimum()
|
||||||
, largeChange()
|
, largeChange()
|
||||||
, smallChange()
|
, smallChange()
|
||||||
, value()
|
, desiredValue()
|
||||||
, valueChanged()
|
, currentValueChanged()
|
||||||
|
, currentValue()
|
||||||
{
|
{
|
||||||
resize(16, 100);
|
resize(16, 100);
|
||||||
|
|
||||||
valueAnimation.setDuration(300);
|
currentValueAnimation.setDuration(300);
|
||||||
valueAnimation.setEasingCurve(QEasingCurve(QEasingCurve::OutCubic));
|
currentValueAnimation.setEasingCurve(QEasingCurve(QEasingCurve::OutCubic));
|
||||||
|
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
}
|
}
|
||||||
@@ -140,8 +141,8 @@ ScrollBar::mouseMoveEvent(QMouseEvent *event)
|
|||||||
} else if (this->mouseDownIndex == 2) {
|
} else if (this->mouseDownIndex == 2) {
|
||||||
int delta = event->pos().y() - lastMousePosition.y();
|
int delta = event->pos().y() - lastMousePosition.y();
|
||||||
|
|
||||||
this->setValue(this->value +
|
this->setDesiredValue(this->desiredValue +
|
||||||
(qreal)delta / this->trackHeight * maximum);
|
(qreal)delta / this->trackHeight * maximum);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->lastMousePosition = event->pos();
|
this->lastMousePosition = event->pos();
|
||||||
@@ -172,21 +173,21 @@ ScrollBar::mouseReleaseEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
if (y < this->buttonHeight) {
|
if (y < this->buttonHeight) {
|
||||||
if (this->mouseDownIndex == 0) {
|
if (this->mouseDownIndex == 0) {
|
||||||
this->setValue(this->value - this->smallChange, true);
|
this->setDesiredValue(this->desiredValue - this->smallChange, true);
|
||||||
}
|
}
|
||||||
} else if (y < this->thumbRect.y()) {
|
} else if (y < this->thumbRect.y()) {
|
||||||
if (this->mouseDownIndex == 1) {
|
if (this->mouseDownIndex == 1) {
|
||||||
this->setValue(this->value - this->smallChange, true);
|
this->setDesiredValue(this->desiredValue - this->smallChange, true);
|
||||||
}
|
}
|
||||||
} else if (this->thumbRect.contains(2, y)) {
|
} else if (this->thumbRect.contains(2, y)) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else if (y < height() - this->buttonHeight) {
|
} else if (y < height() - this->buttonHeight) {
|
||||||
if (this->mouseDownIndex == 3) {
|
if (this->mouseDownIndex == 3) {
|
||||||
this->setValue(this->value + this->smallChange, true);
|
this->setDesiredValue(this->desiredValue + this->smallChange, true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this->mouseDownIndex == 4) {
|
if (this->mouseDownIndex == 4) {
|
||||||
this->setValue(this->value + this->smallChange, true);
|
this->setDesiredValue(this->desiredValue + this->smallChange, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,8 +211,8 @@ ScrollBar::updateScroll()
|
|||||||
|
|
||||||
this->thumbRect =
|
this->thumbRect =
|
||||||
QRect(0,
|
QRect(0,
|
||||||
(int)(this->value / this->maximum * this->trackHeight) + 1 +
|
(int)(this->desiredValue / this->maximum * this->trackHeight) +
|
||||||
this->buttonHeight,
|
1 + this->buttonHeight,
|
||||||
width(),
|
width(),
|
||||||
(int)(this->largeChange / this->maximum * this->trackHeight) +
|
(int)(this->largeChange / this->maximum * this->trackHeight) +
|
||||||
MIN_THUMB_HEIGHT);
|
MIN_THUMB_HEIGHT);
|
||||||
|
|||||||
+44
-20
@@ -23,7 +23,7 @@ public:
|
|||||||
void removeHighlightsWhere(std::function<bool(ScrollBarHighlight &)> func);
|
void removeHighlightsWhere(std::function<bool(ScrollBarHighlight &)> func);
|
||||||
void addHighlight(ScrollBarHighlight *highlight);
|
void addHighlight(ScrollBarHighlight *highlight);
|
||||||
|
|
||||||
Q_PROPERTY(qreal value READ getValue WRITE setValue)
|
Q_PROPERTY(qreal desiredValue READ getDesiredValue WRITE setDesiredValue)
|
||||||
|
|
||||||
void
|
void
|
||||||
setMaximum(qreal value)
|
setMaximum(qreal value)
|
||||||
@@ -58,26 +58,25 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
setValue(qreal value, bool animated = false)
|
setDesiredValue(qreal value, bool animated = false)
|
||||||
{
|
{
|
||||||
value = std::max(this->minimum,
|
value = std::max(this->minimum,
|
||||||
std::min(this->maximum - this->largeChange, value));
|
std::min(this->maximum - this->largeChange, value));
|
||||||
|
|
||||||
if (this->value != value) {
|
this->desiredValue = value;
|
||||||
|
|
||||||
|
if (this->desiredValue != value) {
|
||||||
if (animated) {
|
if (animated) {
|
||||||
this->valueAnimation.stop();
|
this->currentValueAnimation.stop();
|
||||||
this->valueAnimation.setStartValue(this->value);
|
this->currentValueAnimation.setStartValue(this->currentValue);
|
||||||
|
|
||||||
this->valueAnimation.setEndValue(value);
|
this->currentValueAnimation.setEndValue(value);
|
||||||
this->valueAnimation.start();
|
this->currentValueAnimation.start();
|
||||||
} else {
|
} else {
|
||||||
this->value = value;
|
this->currentValueAnimation.stop();
|
||||||
|
|
||||||
|
this->setCurrentValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->updateScroll();
|
|
||||||
this->valueChanged();
|
|
||||||
|
|
||||||
this->update();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,22 +105,46 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
qreal
|
qreal
|
||||||
getValue() const
|
getDesiredValue() const
|
||||||
{
|
{
|
||||||
return this->value;
|
return this->desiredValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal
|
||||||
|
getCurrentValue() const
|
||||||
|
{
|
||||||
|
return this->currentValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::signals2::signal<void()> &
|
boost::signals2::signal<void()> &
|
||||||
getValueChanged()
|
getCurrentValueChanged()
|
||||||
{
|
{
|
||||||
return valueChanged;
|
return currentValueChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
setCurrentValue(qreal value)
|
||||||
|
{
|
||||||
|
value = std::max(this->minimum,
|
||||||
|
std::min(this->maximum - this->largeChange, value));
|
||||||
|
|
||||||
|
if (this->currentValue != value) {
|
||||||
|
this->currentValue = value;
|
||||||
|
|
||||||
|
this->updateScroll();
|
||||||
|
this->currentValueChanged();
|
||||||
|
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Q_PROPERTY(qreal currentValue READ getCurrentValue WRITE setCurrentValue)
|
||||||
|
|
||||||
QMutex mutex;
|
QMutex mutex;
|
||||||
ScrollBarHighlight *highlights;
|
ScrollBarHighlight *highlights;
|
||||||
|
|
||||||
QPropertyAnimation valueAnimation;
|
QPropertyAnimation currentValueAnimation;
|
||||||
|
|
||||||
void paintEvent(QPaintEvent *);
|
void paintEvent(QPaintEvent *);
|
||||||
void mouseMoveEvent(QMouseEvent *event);
|
void mouseMoveEvent(QMouseEvent *event);
|
||||||
@@ -142,9 +165,10 @@ private:
|
|||||||
qreal minimum;
|
qreal minimum;
|
||||||
qreal largeChange;
|
qreal largeChange;
|
||||||
qreal smallChange;
|
qreal smallChange;
|
||||||
qreal value;
|
qreal desiredValue;
|
||||||
|
qreal currentValue;
|
||||||
|
|
||||||
boost::signals2::signal<void()> valueChanged;
|
boost::signals2::signal<void()> currentValueChanged;
|
||||||
|
|
||||||
void updateScroll();
|
void updateScroll();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -225,14 +225,11 @@ SettingsDialog::select(SettingsDialogTab *tab)
|
|||||||
|
|
||||||
if (selectedTab != NULL) {
|
if (selectedTab != NULL) {
|
||||||
selectedTab->setSelected(false);
|
selectedTab->setSelected(false);
|
||||||
selectedTab->setStyleSheet("");
|
selectedTab->setStyleSheet("color: #FFF");
|
||||||
}
|
}
|
||||||
|
|
||||||
tab->setSelected(true);
|
tab->setSelected(true);
|
||||||
tab->setStyleSheet("background: #F00;"
|
tab->setStyleSheet("background: #555; color: #FFF");
|
||||||
"background: qlineargradient( x1:0 y1:0, x2:1 y2:0, "
|
|
||||||
"stop:0 #333, stop:1 #555);"
|
|
||||||
"border-right: none;");
|
|
||||||
selectedTab = tab;
|
selectedTab = tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ SettingsDialogTab::SettingsDialogTab(SettingsDialog *dialog, QString label,
|
|||||||
setFixedHeight(32);
|
setFixedHeight(32);
|
||||||
|
|
||||||
setCursor(QCursor(Qt::PointingHandCursor));
|
setCursor(QCursor(Qt::PointingHandCursor));
|
||||||
|
|
||||||
|
setStyleSheet("color: #FFF");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Reference in New Issue
Block a user