NotificationBox: Clang format

This commit is contained in:
Abdullah Tahiri
2023-03-21 10:24:52 +01:00
committed by abdullahtahiriyo
parent 26e48cb63a
commit 48a921d2b7
2 changed files with 50 additions and 41 deletions

View File

@@ -60,7 +60,8 @@ class NotificationLabel: public QLabel
{
Q_OBJECT
public:
NotificationLabel(const QString& text, const QPoint& pos, int displayTime, int minShowTime = 0, int width = 0);
NotificationLabel(const QString& text, const QPoint& pos, int displayTime, int minShowTime = 0,
int width = 0);
/// Reuse existing notification to show a new notification (with a new text)
void reuseNotification(const QString& text, int displayTime, const QPoint& pos, int width);
/// Hide notification after a hiding timer.
@@ -74,7 +75,7 @@ public:
/// Place the notification at the given position
void placeNotificationLabel(const QPoint& pos);
/// Set the windowrect defining an area to which the label should be constrained
void setTipRect(const QRect &restrictionarea);
void setTipRect(const QRect& restrictionarea);
void setHideIfReferenceWidgetDeactivated(bool on);
@@ -150,9 +151,10 @@ void NotificationLabel::restartExpireTimer(int displayTime)
hideTimer.stop();
}
void NotificationLabel::reuseNotification(const QString& text, int displayTime, const QPoint& pos, int width)
void NotificationLabel::reuseNotification(const QString& text, int displayTime, const QPoint& pos,
int width)
{
if(width > 0)
if (width > 0)
setFixedWidth(width);
setText(text);
@@ -248,10 +250,9 @@ bool NotificationLabel::eventFilter(QObject* o, QEvent* e)
return insideclick;
}
}
break;
} break;
case QEvent::WindowDeactivate:
if(hideIfReferenceWidgetDeactivated)
if (hideIfReferenceWidgetDeactivated)
hideNotificationImmediately();
break;
@@ -278,7 +279,7 @@ void NotificationLabel::placeNotificationLabel(const QPoint& pos)
QRect actinglimit = screen->geometry();
if(!restrictionArea.isNull())
if (!restrictionArea.isNull())
actinglimit = restrictionArea;
const int standard_x_padding = 4;
@@ -301,7 +302,7 @@ void NotificationLabel::placeNotificationLabel(const QPoint& pos)
this->move(p);
}
void NotificationLabel::setTipRect(const QRect &restrictionarea)
void NotificationLabel::setTipRect(const QRect& restrictionarea)
{
restrictionArea = restrictionarea;
}
@@ -318,25 +319,25 @@ bool NotificationLabel::notificationLabelChanged(const QString& text)
/***************************** NotificationBox **********************************/
bool NotificationBox::showText(const QPoint& pos, const QString& text, QWidget * referenceWidget, int displayTime,
unsigned int minShowTime, Options options,
int width)
bool NotificationBox::showText(const QPoint& pos, const QString& text, QWidget* referenceWidget,
int displayTime, unsigned int minShowTime, Options options,
int width)
{
QRect restrictionarea = {};
if(referenceWidget) {
if(options & Options::OnlyIfReferenceActive) {
if (referenceWidget) {
if (options & Options::OnlyIfReferenceActive) {
if (!referenceWidget->isActiveWindow()) {
return false;
}
}
if(options & Options::RestrictAreaToReference) {
if (options & Options::RestrictAreaToReference) {
// Calculate the main window QRect in global screen coordinates.
auto mainwindowrect = referenceWidget->rect();
restrictionarea =
QRect(referenceWidget->mapToGlobal(mainwindowrect.topLeft()), mainwindowrect.size());
restrictionarea = QRect(referenceWidget->mapToGlobal(mainwindowrect.topLeft()),
mainwindowrect.size());
}
}
@@ -350,8 +351,8 @@ bool NotificationBox::showText(const QPoint& pos, const QString& text, QWidget *
// If the label has changed, reuse the one that is showing (removes flickering)
if (NotificationLabel::instance->notificationLabelChanged(text)) {
NotificationLabel::instance->setTipRect(restrictionarea);
NotificationLabel::instance->setHideIfReferenceWidgetDeactivated(options &
Options::HideIfReferenceWidgetDeactivated);
NotificationLabel::instance->setHideIfReferenceWidgetDeactivated(
options & Options::HideIfReferenceWidgetDeactivated);
NotificationLabel::instance->reuseNotification(text, displayTime, pos, width);
NotificationLabel::instance->placeNotificationLabel(pos);
}
@@ -371,8 +372,8 @@ bool NotificationBox::showText(const QPoint& pos, const QString& text, QWidget *
width);// sets NotificationLabel::instance to itself
NotificationLabel::instance->setTipRect(restrictionarea);
NotificationLabel::instance->setHideIfReferenceWidgetDeactivated(options &
Options::HideIfReferenceWidgetDeactivated);
NotificationLabel::instance->setHideIfReferenceWidgetDeactivated(
options & Options::HideIfReferenceWidgetDeactivated);
NotificationLabel::instance->placeNotificationLabel(pos);
NotificationLabel::instance->setObjectName(QLatin1String("NotificationBox_label"));