2024-08-01 00:13:01 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2024-08-01 00:13:01 +00:00
|
|
|
* Copyright (C) 2024 Symless Ltd.
|
|
|
|
|
*
|
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* found in the file LICENSE that should have accompanied this file.
|
|
|
|
|
*
|
|
|
|
|
* This package is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ValidationError.h"
|
|
|
|
|
|
2024-08-03 00:17:29 +00:00
|
|
|
#include "gui/styles.h"
|
2024-08-01 00:13:01 +00:00
|
|
|
|
2024-09-17 19:00:25 +00:00
|
|
|
using namespace deskflow::gui;
|
2024-08-07 14:05:18 +00:00
|
|
|
|
2024-08-01 00:13:01 +00:00
|
|
|
namespace validators {
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
void clear(QLabel *label)
|
|
|
|
|
{
|
2024-08-01 00:13:01 +00:00
|
|
|
if (label) {
|
|
|
|
|
label->setStyleSheet(kStyleErrorInactiveLabel);
|
|
|
|
|
label->setText("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
ValidationError::ValidationError(QObject *parent, QLabel *label) : QObject(parent), m_pLabel(label)
|
|
|
|
|
{
|
2024-08-01 00:13:01 +00:00
|
|
|
|
|
|
|
|
if (m_pLabel) {
|
|
|
|
|
clear(m_pLabel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
const QString &ValidationError::message() const
|
|
|
|
|
{
|
|
|
|
|
return m_message;
|
|
|
|
|
}
|
2024-08-01 00:13:01 +00:00
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
void ValidationError::setMessage(const QString &message)
|
|
|
|
|
{
|
2024-08-01 00:13:01 +00:00
|
|
|
m_message = message;
|
|
|
|
|
|
|
|
|
|
if (m_pLabel) {
|
|
|
|
|
if (message.isEmpty()) {
|
|
|
|
|
clear(m_pLabel);
|
|
|
|
|
} else {
|
|
|
|
|
m_pLabel->setStyleSheet(kStyleErrorActiveLabel);
|
|
|
|
|
m_pLabel->setText(message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace validators
|