2021-03-24 12:38:50 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2025-01-24 00:11:17 +00:00
|
|
|
* SPDX-FileCopyrightText: (C) 2021 Symless Ltd.
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
2021-03-24 12:38:50 +00:00
|
|
|
*/
|
2024-08-08 17:41:59 +00:00
|
|
|
|
2021-03-24 12:38:50 +00:00
|
|
|
#include "ScreenDuplicationsValidator.h"
|
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
namespace validators {
|
2021-03-24 12:38:50 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
ScreenDuplicationsValidator::ScreenDuplicationsValidator(
|
2024-10-17 18:04:35 +00:00
|
|
|
const QString &message, const QString &defaultName, const ScreenList *pScreens
|
|
|
|
|
)
|
2024-07-16 13:36:44 +00:00
|
|
|
: IStringValidator(message),
|
|
|
|
|
m_defaultName(defaultName),
|
2024-10-17 18:04:35 +00:00
|
|
|
m_pScreenList(pScreens)
|
|
|
|
|
{
|
2025-05-20 14:39:18 +00:00
|
|
|
// do nothing
|
2024-10-17 18:04:35 +00:00
|
|
|
}
|
2021-03-24 12:38:50 +00:00
|
|
|
|
2024-10-17 18:04:35 +00:00
|
|
|
bool ScreenDuplicationsValidator::validate(const QString &input) const
|
|
|
|
|
{
|
2024-07-02 19:07:06 +00:00
|
|
|
bool result = true;
|
2021-03-24 12:38:50 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
if (m_pScreenList) {
|
|
|
|
|
for (const auto &screen : (*m_pScreenList)) {
|
2024-10-17 18:04:35 +00:00
|
|
|
if (!screen.isNull() && !screen.isServer() && input != m_defaultName && input == screen.name()) {
|
2024-07-02 19:07:06 +00:00
|
|
|
result = false;
|
|
|
|
|
break;
|
2021-03-24 12:38:50 +00:00
|
|
|
}
|
2024-07-02 19:07:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
2021-03-24 12:38:50 +00:00
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
return result;
|
2021-03-24 12:38:50 +00:00
|
|
|
}
|
|
|
|
|
|
2024-07-02 19:07:06 +00:00
|
|
|
} // namespace validators
|