2021-03-24 12:38:50 +00:00
|
|
|
/*
|
2024-09-17 19:00:25 +00:00
|
|
|
* Deskflow -- mouse and keyboard sharing utility
|
2024-08-08 17:41:59 +00:00
|
|
|
* Copyright (C) 2021 Symless Ltd.
|
2021-03-24 12:38:50 +00:00
|
|
|
*
|
|
|
|
|
* 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/>.
|
|
|
|
|
*/
|
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)
|
|
|
|
|
{
|
|
|
|
|
}
|
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
|