refactor: validatorError, make clear a private method
This commit is contained in:
parent
1a9316150d
commit
6851046c5a
2 changed files with 13 additions and 13 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
* Deskflow -- mouse and keyboard sharing utility
|
||||||
|
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||||
* SPDX-FileCopyrightText: (C) 2024 Symless Ltd.
|
* SPDX-FileCopyrightText: (C) 2024 Symless Ltd.
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||||
*/
|
*/
|
||||||
|
|
@ -12,20 +13,9 @@ using namespace deskflow::gui;
|
||||||
|
|
||||||
namespace validators {
|
namespace validators {
|
||||||
|
|
||||||
void clear(QLabel *label)
|
|
||||||
{
|
|
||||||
if (label) {
|
|
||||||
label->setStyleSheet(kStyleErrorInactiveLabel);
|
|
||||||
label->setText("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ValidationError::ValidationError(QObject *parent, QLabel *label) : QObject(parent), m_label(label)
|
ValidationError::ValidationError(QObject *parent, QLabel *label) : QObject(parent), m_label(label)
|
||||||
{
|
{
|
||||||
|
clear();
|
||||||
if (m_label) {
|
|
||||||
clear(m_label);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &ValidationError::message() const
|
const QString &ValidationError::message() const
|
||||||
|
|
@ -39,7 +29,7 @@ void ValidationError::setMessage(const QString &message)
|
||||||
|
|
||||||
if (m_label) {
|
if (m_label) {
|
||||||
if (message.isEmpty()) {
|
if (message.isEmpty()) {
|
||||||
clear(m_label);
|
clear();
|
||||||
} else {
|
} else {
|
||||||
m_label->setStyleSheet(kStyleErrorActiveLabel);
|
m_label->setStyleSheet(kStyleErrorActiveLabel);
|
||||||
m_label->setText(message);
|
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
|
} // namespace validators
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Deskflow -- mouse and keyboard sharing utility
|
* Deskflow -- mouse and keyboard sharing utility
|
||||||
|
* SPDX-FileCopyrightText: (C) 2025 Deskflow Developers
|
||||||
* SPDX-FileCopyrightText: (C) 2024 Symless Ltd.
|
* SPDX-FileCopyrightText: (C) 2024 Symless Ltd.
|
||||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||||
*/
|
*/
|
||||||
|
|
@ -20,6 +21,7 @@ public:
|
||||||
void setMessage(const QString &message);
|
void setMessage(const QString &message);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void clear();
|
||||||
QString m_message;
|
QString m_message;
|
||||||
QLabel *m_label = nullptr;
|
QLabel *m_label = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue