fixes and cleanup
This commit is contained in:
parent
58756c4635
commit
a8f169428d
|
@ -37,10 +37,9 @@ NotifyWidget::NotifyWidget(int pos,QWidget *parent) :
|
|||
TomahawkUtils::DpiScaler::setFontSize(this->ui->titel->fontInfo().pointSize());
|
||||
m_scaler = new TomahawkUtils::DpiScaler(this);
|
||||
ui->closeButton->setMaximumWidth(ui->closeButton->height());
|
||||
QSize size = m_scaler->scaled(300, 80);
|
||||
setMaximumSize(size);
|
||||
setMinimumSize(size);
|
||||
resize(size);
|
||||
|
||||
setFixedSize( m_scaler->scaled(300, 80));
|
||||
|
||||
m_dest = QPoint(m_desktop.topRight().x() - width(), m_desktop.topRight().y() + (m_scaler->scaledY(10) + height()) * pos);
|
||||
}
|
||||
|
||||
|
@ -59,7 +58,7 @@ void NotifyWidget::display(const Notification ¬ification)
|
|||
m_moveTimer->setInterval(2);
|
||||
connect( m_moveTimer, SIGNAL(timeout()), this, SLOT(slotMove()));
|
||||
m_moveTimer->start();
|
||||
snoreDebug( SNORE_DEBUG ) << size();
|
||||
|
||||
}
|
||||
|
||||
void NotifyWidget::update(const Notification ¬ification)
|
||||
|
@ -70,42 +69,11 @@ void NotifyWidget::update(const Notification ¬ification)
|
|||
|
||||
QSize iconSize = m_scaler->scaled(65,65);
|
||||
ui->icon->setPixmap(QPixmap::fromImage(notification.icon().image().scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
|
||||
ui->icon->setMaximumSize(iconSize);
|
||||
|
||||
iconSize = m_scaler->scaled(20,20);
|
||||
QImage img = notification.application().icon().image().scaled(iconSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
ui->appIcon->setPixmap(QPixmap::fromImage(img));
|
||||
ui->appIcon->setMaximumSize(iconSize);
|
||||
|
||||
qulonglong r = 0;
|
||||
qulonglong g = 0;
|
||||
qulonglong b = 0;
|
||||
for(int x=0;x<img.width();++x)
|
||||
{
|
||||
for(int y=0;y<img.height();++y)
|
||||
{
|
||||
QRgb c = img.pixel(x,y);
|
||||
r += qRed(c);
|
||||
g += qGreen(c);
|
||||
b += qBlue(c);
|
||||
}
|
||||
}
|
||||
int s = img.width()*img.height();
|
||||
|
||||
QPalette p = palette();
|
||||
QColor bg = QColor(r/s,g/s, b/s,255);
|
||||
p.setColor(QPalette::All, QPalette::Window, bg);
|
||||
p.setColor(QPalette::All, QPalette::Background, bg);
|
||||
p.setColor(QPalette::All, QPalette::Base, bg);
|
||||
p.setColor(QPalette::All, QPalette::Text, Qt::white);
|
||||
p.setColor(QPalette::All, QPalette::BrightText, Qt::white);
|
||||
p.setColor(QPalette::All, QPalette::ButtonText, Qt::white);
|
||||
p.setColor(QPalette::All, QPalette::WindowText, Qt::white);
|
||||
setPalette(p);
|
||||
ui->closeButton->setPalette(p);
|
||||
ui->body->setPalette(p);
|
||||
ui->titel->setPalette(p);
|
||||
|
||||
setPalette(img);
|
||||
}
|
||||
|
||||
Notification &NotifyWidget::notification()
|
||||
|
@ -139,3 +107,35 @@ void NotifyWidget::mousePressEvent(QMouseEvent *e)
|
|||
hide();
|
||||
QWidget::mousePressEvent(e);
|
||||
}
|
||||
|
||||
void NotifyWidget::setPalette(const QImage &img)
|
||||
{
|
||||
qulonglong r = 0;
|
||||
qulonglong g = 0;
|
||||
qulonglong b = 0;
|
||||
for(int x=0;x<img.width();++x)
|
||||
{
|
||||
for(int y=0;y<img.height();++y)
|
||||
{
|
||||
QRgb c = img.pixel(x,y);
|
||||
r += qRed(c);
|
||||
g += qGreen(c);
|
||||
b += qBlue(c);
|
||||
}
|
||||
}
|
||||
int s = img.width()*img.height();
|
||||
|
||||
QPalette p = palette();
|
||||
QColor bg = QColor(r/s, g/s, b/s);
|
||||
p.setColor(QPalette::All, QPalette::Window, bg);
|
||||
p.setColor(QPalette::All, QPalette::Background, bg);
|
||||
p.setColor(QPalette::All, QPalette::Base, bg);
|
||||
p.setColor(QPalette::All, QPalette::Text, Qt::white);
|
||||
p.setColor(QPalette::All, QPalette::BrightText, Qt::white);
|
||||
p.setColor(QPalette::All, QPalette::ButtonText, Qt::white);
|
||||
p.setColor(QPalette::All, QPalette::WindowText, Qt::white);
|
||||
QWidget::setPalette(p);
|
||||
ui->closeButton->setPalette(p);
|
||||
ui->body->setPalette(p);
|
||||
ui->titel->setPalette(p);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,10 @@ protected:
|
|||
void mousePressEvent(QMouseEvent *e);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void setPalette(const QImage &img);
|
||||
Ui::NotifyWidget *ui;
|
||||
QTimer *m_moveTimer;
|
||||
QPoint m_dest;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>359</width>
|
||||
<height>180</height>
|
||||
<height>122</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="mouseTracking">
|
||||
|
@ -79,10 +79,7 @@
|
|||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -94,6 +91,12 @@
|
|||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
|
@ -115,76 +118,6 @@
|
|||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="palette">
|
||||
<palette>
|
||||
<active>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Text">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</active>
|
||||
<inactive>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Text">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</inactive>
|
||||
<disabled>
|
||||
<colorrole role="WindowText">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
<colorrole role="Text">
|
||||
<brush brushstyle="SolidPattern">
|
||||
<color alpha="255">
|
||||
<red>0</red>
|
||||
<green>0</green>
|
||||
<blue>0</blue>
|
||||
</color>
|
||||
</brush>
|
||||
</colorrole>
|
||||
</disabled>
|
||||
</palette>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
|
@ -206,7 +139,7 @@
|
|||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<string notr="true"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
|
|
Loading…
Reference in New Issue