You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Code/Tools/ProjectManager/Source/PathValidator.h

42 lines
1.2 KiB
C++

/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#if !defined(Q_MOC_RUN)
#include <QValidator>
#endif
QT_FORWARD_DECLARE_CLASS(QWidget)
namespace O3DE::ProjectManager
{
class PathValidator
: public QValidator
{
public:
enum class PathMode {
ExistingFile, //!< A single, existings file. Useful for "Open file"
ExistingFolder, //!< A single, existing directory. Useful for "Open Folder"
AnyFile //!< A single, valid file, doesn't have to exist but the directory must. Useful for "Save File"
};
explicit PathValidator(PathMode pathMode, QWidget* parent = nullptr);
~PathValidator() = default;
void setAllowEmpty(bool allowEmpty);
void setPathMode(PathMode pathMode);
QValidator::State validate(QString &text, int &) const override;
private:
PathMode m_pathMode = PathMode::AnyFile;
bool m_allowEmpty = false;
};
} // namespace O3DE::ProjectManager