refactor: validatorError, make clear a private method

This commit is contained in:
sithlord48
2025-12-24 10:31:57 -05:00
committed by Nick Bolton
parent 1a9316150d
commit 6851046c5a
2 changed files with 13 additions and 13 deletions

View File

@ -1,5 +1,6 @@
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2024 Symless Ltd.
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/
@ -12,20 +13,9 @@ using namespace deskflow::gui;
namespace validators {
void clear(QLabel *label)
{
if (label) {
label->setStyleSheet(kStyleErrorInactiveLabel);
label->setText("");
}
}
ValidationError::ValidationError(QObject *parent, QLabel *label) : QObject(parent), m_label(label)
{
if (m_label) {
clear(m_label);
}
clear();
}
const QString &ValidationError::message() const
@ -39,7 +29,7 @@ void ValidationError::setMessage(const QString &message)
if (m_label) {
if (message.isEmpty()) {
clear(m_label);
clear();
} else {
m_label->setStyleSheet(kStyleErrorActiveLabel);
m_label->setText(message);
@ -47,4 +37,12 @@ void ValidationError::setMessage(const QString &message)
}
}
void ValidationError::clear()
{
if (!m_label)
return;
m_label->setStyleSheet(kStyleErrorInactiveLabel);
m_label->setText({});
}
} // namespace validators

View File

@ -1,5 +1,6 @@
/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
* SPDX-FileCopyrightText: (C) 2024 Symless Ltd.
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/
@ -20,6 +21,7 @@ public:
void setMessage(const QString &message);
private:
void clear();
QString m_message;
QLabel *m_label = nullptr;
};