mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-10 06:29:00 +01:00
QtUtils: Add UTF8CodePointCountValidator
This commit is contained in:
parent
c59648337a
commit
92812d0b0b
@ -235,6 +235,8 @@ add_executable(dolphin-emu
|
||||
QtUtils/ParallelProgressDialog.h
|
||||
QtUtils/ImageConverter.cpp
|
||||
QtUtils/ImageConverter.h
|
||||
QtUtils/UTF8CodePointCountValidator.cpp
|
||||
QtUtils/UTF8CodePointCountValidator.h
|
||||
QtUtils/WindowActivationEventFilter.cpp
|
||||
QtUtils/WindowActivationEventFilter.h
|
||||
QtUtils/WinIconHelper.cpp
|
||||
@ -459,8 +461,8 @@ if(APPLE)
|
||||
include(DolphinPostprocessBundle)
|
||||
dolphin_postprocess_bundle(dolphin-emu)
|
||||
# Fix rpath
|
||||
add_custom_command(TARGET dolphin-emu
|
||||
POST_BUILD COMMAND
|
||||
add_custom_command(TARGET dolphin-emu
|
||||
POST_BUILD COMMAND
|
||||
${CMAKE_INSTALL_NAME_TOOL} -add_rpath "@executable_path/../Frameworks/"
|
||||
$<TARGET_FILE:dolphin-emu>)
|
||||
else()
|
||||
|
@ -186,6 +186,7 @@
|
||||
<QtMoc Include="QtUtils\FlowLayout.h" />
|
||||
<QtMoc Include="QtUtils\ModalMessageBox.h" />
|
||||
<QtMoc Include="QtUtils\ParallelProgressDialog.h" />
|
||||
<QtMoc Include="QtUtils\UTF8CodePointCountValidator.h" />
|
||||
<QtMoc Include="QtUtils\WindowActivationEventFilter.h" />
|
||||
<QtMoc Include="QtUtils\WrapInScrollArea.h" />
|
||||
<QtMoc Include="RenderWidget.h" />
|
||||
@ -291,6 +292,7 @@
|
||||
<ClCompile Include="$(QtMocOutPrefix)NewPatchDialog.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)PadMappingDialog.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)ParallelProgressDialog.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)UTF8CodePointCountValidator.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)PatchesWidget.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)PatchInstructionDialog.cpp" />
|
||||
<ClCompile Include="$(QtMocOutPrefix)PathPane.cpp" />
|
||||
@ -433,6 +435,7 @@
|
||||
<ClCompile Include="QtUtils\FlowLayout.cpp" />
|
||||
<ClCompile Include="QtUtils\ImageConverter.cpp" />
|
||||
<ClCompile Include="QtUtils\ModalMessageBox.cpp" />
|
||||
<ClCompile Include="QtUtils\UTF8CodePointCountValidator.cpp" />
|
||||
<ClCompile Include="QtUtils\WindowActivationEventFilter.cpp" />
|
||||
<ClCompile Include="QtUtils\WrapInScrollArea.cpp" />
|
||||
<ClCompile Include="RenderWidget.cpp" />
|
||||
@ -555,4 +558,4 @@
|
||||
<Message Text="Copy: @(BinaryFiles) -> $(BinaryOutputDir)" Importance="High" />
|
||||
<Copy SourceFiles="@(BinaryFiles)" DestinationFolder="$(BinaryOutputDir)" />
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
||||
|
@ -0,0 +1,20 @@
|
||||
// Copyright 2020 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DolphinQt/QtUtils/UTF8CodePointCountValidator.h"
|
||||
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
UTF8CodePointCountValidator::UTF8CodePointCountValidator(int max_count, QObject* parent)
|
||||
: QValidator(parent), m_max_count(max_count)
|
||||
{
|
||||
}
|
||||
|
||||
QValidator::State UTF8CodePointCountValidator::validate(QString& input, int& pos) const
|
||||
{
|
||||
if (StringUTF8CodePointCount(input.toStdString()) > m_max_count)
|
||||
return QValidator::Invalid;
|
||||
|
||||
return QValidator::Acceptable;
|
||||
}
|
19
Source/Core/DolphinQt/QtUtils/UTF8CodePointCountValidator.h
Normal file
19
Source/Core/DolphinQt/QtUtils/UTF8CodePointCountValidator.h
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2020 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <QValidator>
|
||||
|
||||
class UTF8CodePointCountValidator : public QValidator
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UTF8CodePointCountValidator(int max_count, QObject* parent = nullptr);
|
||||
|
||||
QValidator::State validate(QString& input, int& pos) const override;
|
||||
|
||||
int m_max_count;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user