Formats minimally release source files based on former clang-format
This commit is contained in:
387 files changed
+37323
-38074
No files matched your search
+67
-62
@@ -13,94 +13,95 @@
|
||||
namespace LtsNotification
|
||||
{
|
||||
|
||||
LtsNotificationController::LtsNotificationController(const QString& identifier)
|
||||
: QObject(), m_count(0), m_identifier(QStringLiteral("LtsNotification%1").arg(identifier))
|
||||
{
|
||||
}
|
||||
LtsNotificationController::LtsNotificationController(const QString &identifier)
|
||||
: QObject()
|
||||
, m_count(0)
|
||||
, m_identifier(QStringLiteral("LtsNotification%1").arg(identifier))
|
||||
{
|
||||
}
|
||||
|
||||
LtsNotificationController::~LtsNotificationController()
|
||||
{
|
||||
LtsNotificationController::~LtsNotificationController()
|
||||
{
|
||||
qDeleteAll(m_notiList);
|
||||
}
|
||||
}
|
||||
|
||||
void LtsNotificationController::setIcon(const QIcon& icon)
|
||||
{
|
||||
void LtsNotificationController::setIcon(const QIcon &icon)
|
||||
{
|
||||
m_icon = icon;
|
||||
|
||||
setAllIcons();
|
||||
}
|
||||
}
|
||||
|
||||
void LtsNotificationController::setCount(const int count)
|
||||
{
|
||||
void LtsNotificationController::setCount(const int count)
|
||||
{
|
||||
m_count = count;
|
||||
|
||||
setAllIcons();
|
||||
}
|
||||
}
|
||||
|
||||
void LtsNotificationController::setBackground(const int r, const int g, const int b)
|
||||
{
|
||||
void LtsNotificationController::setBackground(const int r, const int g, const int b)
|
||||
{
|
||||
|
||||
for (QToolButton* tb : std::as_const(m_notiList))
|
||||
for (QToolButton *tb : std::as_const(m_notiList))
|
||||
{
|
||||
|
||||
QString stylesheet;
|
||||
QString stylesheet;
|
||||
|
||||
if (r == -1 && g == -1 && b == -1)
|
||||
stylesheet = QStringLiteral("");
|
||||
else
|
||||
stylesheet = QStringLiteral("QToolButton {background-color: rgb(") + QString::number(r) +
|
||||
QStringLiteral(",") + QString::number(g) + QStringLiteral(",") + QString::number(b) +
|
||||
QStringLiteral(");}");
|
||||
if (r == -1 && g == -1 && b == -1)
|
||||
stylesheet = QStringLiteral("");
|
||||
else
|
||||
stylesheet = QStringLiteral("QToolButton {background-color: rgb(") + QString::number(r) + QStringLiteral(",") + QString::number(g) + QStringLiteral(",") +
|
||||
QString::number(b) + QStringLiteral(");}");
|
||||
|
||||
tb->setStyleSheet(stylesheet);
|
||||
tb->setStyleSheet(stylesheet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LtsNotificationController::setEnabled(bool enable)
|
||||
{
|
||||
void LtsNotificationController::setEnabled(bool enable)
|
||||
{
|
||||
m_enable = enable;
|
||||
|
||||
setAllIcons();
|
||||
}
|
||||
}
|
||||
|
||||
void LtsNotificationController::setAction(const std::function<void(void)>& action)
|
||||
{
|
||||
void LtsNotificationController::setAction(const std::function<void(void)> &action)
|
||||
{
|
||||
m_action = action;
|
||||
}
|
||||
}
|
||||
|
||||
void LtsNotificationController::setToolTip(const QString& toolTip)
|
||||
{
|
||||
void LtsNotificationController::setToolTip(const QString &toolTip)
|
||||
{
|
||||
m_toolTip = toolTip;
|
||||
|
||||
for (QToolButton* tb : std::as_const(m_notiList))
|
||||
for (QToolButton *tb : std::as_const(m_notiList))
|
||||
{
|
||||
tb->setToolTip(toolTip);
|
||||
tb->setIconSize(QSize(30, 30));
|
||||
tb->setToolTip(toolTip);
|
||||
tb->setIconSize(QSize(30, 30));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LtsNotificationController::setAllIcons()
|
||||
{
|
||||
void LtsNotificationController::setAllIcons()
|
||||
{
|
||||
if (m_icon.isNull())
|
||||
return;
|
||||
return;
|
||||
|
||||
QIcon icon = modifyIcon(m_icon);
|
||||
|
||||
for (QToolButton* tb : std::as_const(m_notiList))
|
||||
for (QToolButton *tb : std::as_const(m_notiList))
|
||||
{
|
||||
tb->setIcon(icon);
|
||||
tb->setIconSize(QSize(30, 30));
|
||||
tb->setEnabled(m_enable);
|
||||
tb->setIcon(icon);
|
||||
tb->setIconSize(QSize(30, 30));
|
||||
tb->setEnabled(m_enable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define SIZE 40
|
||||
|
||||
QIcon LtsNotificationController::modifyIcon(const QIcon& icon)
|
||||
{
|
||||
QIcon LtsNotificationController::modifyIcon(const QIcon &icon)
|
||||
{
|
||||
|
||||
if (m_count < 1)
|
||||
return icon;
|
||||
return icon;
|
||||
|
||||
QPixmap iconImage(icon.pixmap(SIZE * 8 / 10, SIZE * 8 / 10));
|
||||
QPainter painter(&iconImage);
|
||||
@@ -121,11 +122,11 @@ QIcon LtsNotificationController::modifyIcon(const QIcon& icon)
|
||||
painter.restore();
|
||||
|
||||
return iconImage;
|
||||
}
|
||||
}
|
||||
|
||||
QToolButton* LtsNotificationController::createWidget()
|
||||
{
|
||||
QToolButton* b = new QToolButton();
|
||||
QToolButton *LtsNotificationController::createWidget()
|
||||
{
|
||||
QToolButton *b = new QToolButton();
|
||||
b->setToolButtonStyle(Qt::ToolButtonIconOnly);
|
||||
b->setObjectName(m_identifier);
|
||||
|
||||
@@ -133,23 +134,27 @@ QToolButton* LtsNotificationController::createWidget()
|
||||
b->setMaximumSize(SIZE, SIZE);
|
||||
|
||||
connect(b, &QToolButton::destroyed, this, &LtsNotificationController::slotNotiWidgetDestroyed);
|
||||
connect(b, &QToolButton::clicked, this, [this]() {
|
||||
if (m_action)
|
||||
m_action();
|
||||
});
|
||||
connect(b,
|
||||
&QToolButton::clicked,
|
||||
this,
|
||||
[this]()
|
||||
{
|
||||
if (m_action)
|
||||
m_action();
|
||||
});
|
||||
|
||||
if (!m_icon.isNull())
|
||||
b->setIcon(modifyIcon(m_icon));
|
||||
b->setIcon(modifyIcon(m_icon));
|
||||
|
||||
b->setToolTip(m_toolTip);
|
||||
|
||||
m_notiList.append(b);
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
void LtsNotificationController::slotNotiWidgetDestroyed(QObject* obj)
|
||||
{
|
||||
m_notiList.removeAll(static_cast<QToolButton*>(obj));
|
||||
}
|
||||
void LtsNotificationController::slotNotiWidgetDestroyed(QObject *obj)
|
||||
{
|
||||
m_notiList.removeAll(static_cast<QToolButton *>(obj));
|
||||
}
|
||||
|
||||
} // namespace LtsNotification
|
||||
Reference in new issue
Block a user