deskflow/src/lib/gui/validators/ScreenDuplicationsValidator.cpp
sithlord48 1085df54ed refactor: Reuse compliance
build files and documentation: MIT
  images / sources: GPL-2.0-only
  breeze icons: LGPL-2.0-only
  Microsoft MSM file, vc redist license
2025-01-27 17:05:47 -05:00

36 lines
870 B
C++

/*
* Deskflow -- mouse and keyboard sharing utility
* SPDX-FileCopyrightText: (C) 2021 Symless Ltd.
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
*/
#include "ScreenDuplicationsValidator.h"
namespace validators {
ScreenDuplicationsValidator::ScreenDuplicationsValidator(
const QString &message, const QString &defaultName, const ScreenList *pScreens
)
: IStringValidator(message),
m_defaultName(defaultName),
m_pScreenList(pScreens)
{
}
bool ScreenDuplicationsValidator::validate(const QString &input) const
{
bool result = true;
if (m_pScreenList) {
for (const auto &screen : (*m_pScreenList)) {
if (!screen.isNull() && !screen.isServer() && input != m_defaultName && input == screen.name()) {
result = false;
break;
}
}
}
return result;
}
} // namespace validators