|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef VALIDATEDCHOICEDIALOG_H
|
|
Toshihiro Shimizu |
890ddd |
#define VALIDATEDCHOICEDIALOG_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzCore includes
|
|
Toshihiro Shimizu |
890ddd |
#include "tcommon.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzQt includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/dvdialog.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#undef DVAPI
|
|
Toshihiro Shimizu |
890ddd |
#undef DVVAR
|
|
Toshihiro Shimizu |
890ddd |
#ifdef TOONZQT_EXPORTS
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_EXPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_EXPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#else
|
|
Toshihiro Shimizu |
890ddd |
#define DVAPI DV_IMPORT_API
|
|
Toshihiro Shimizu |
890ddd |
#define DVVAR DV_IMPORT_VAR
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//====================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Forward declarations
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class QButtonGroup;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//====================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
// ValidatedChoiceDialog declaration
|
|
Toshihiro Shimizu |
890ddd |
//************************************************************************
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace DVGui {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*!
|
|
Toshihiro Shimizu |
890ddd |
\brief Base class for validated multi-choice user dialogs.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
\warning For correct usage, observe the guidelines described in the
|
|
Toshihiro Shimizu |
890ddd |
ValidatedChoiceDialog() constructor.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI ValidatedChoiceDialog : public DVGui::Dialog {
|
|
Shinya Kitaoka |
120a6e |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
enum Options //! Construction options
|
|
Shinya Kitaoka |
120a6e |
{ NO_OPTIONS = 0x0, //!< No special options.
|
|
Shinya Kitaoka |
120a6e |
APPLY_TO_ALL =
|
|
Shinya Kitaoka |
120a6e |
0x1 //!< Has the "Apply to All" button. An applied to all
|
|
Shinya Kitaoka |
120a6e |
//! resolution persists as the default without-prompt resolution
|
|
Shinya Kitaoka |
120a6e |
//! until the next call to reset().
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
enum DefaultResolution //! Basic resolutions supported by the dialog.
|
|
Shinya Kitaoka |
120a6e |
{ NO_REQUIRED_RESOLUTION =
|
|
Shinya Kitaoka |
120a6e |
0, //!< An object supplied for validation turns out to be valid,
|
|
Shinya Kitaoka |
120a6e |
//! no need for any resolution.
|
|
Shinya Kitaoka |
120a6e |
CANCEL = 1, //!< Resolution selection was canceled. Stop processing.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
DEFAULT_RESOLUTIONS_COUNT };
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
/*! \warning Due to compatibility with DVGui::Dialog's interface, this class
|
|
Shinya Kitaoka |
120a6e |
reserves
|
|
Shinya Kitaoka |
120a6e |
invocation of \p Dialog::beginVLayout() during class construction -
|
|
Shinya Kitaoka |
120a6e |
however, \p Dialog::endVLayout() invocation is responsibility of
|
|
Shinya Kitaoka |
120a6e |
derived classes after resolution choices have been manually added
|
|
Shinya Kitaoka |
120a6e |
to the layout.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
\warning Users are required to respect the default resolution ids when adding
|
|
Shinya Kitaoka |
120a6e |
buttons into \p m_buttonGroup. See the \p DefaultResolution enum for a
|
|
Shinya Kitaoka |
120a6e |
list of all default resolutions. */
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
ValidatedChoiceDialog(QWidget *parent,
|
|
Shinya Kitaoka |
120a6e |
Options opts = NO_OPTIONS); //!< Constructs the dialog
|
|
Shinya Kitaoka |
38fd86 |
//! with no default
|
|
Shinya Kitaoka |
38fd86 |
//! resolutions.
|
|
Shinya Kitaoka |
38fd86 |
//!\param parent Parent
|
|
Shinya Kitaoka |
38fd86 |
//! top-level widget.
|
|
Shinya Kitaoka |
38fd86 |
//!\param Opts
|
|
Shinya Kitaoka |
38fd86 |
//! Construction options.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*! \param obj The object to resolve.
|
|
Shinya Kitaoka |
120a6e |
\return The accepted resolution. */
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int execute(
|
|
Shinya Kitaoka |
120a6e |
void *obj); //!< Prompts the dialog asking for user input, until a
|
|
Shinya Kitaoka |
120a6e |
//! valid resolution for the specified object is selected or
|
|
Shinya Kitaoka |
120a6e |
//! the action is canceled.
|
|
Shinya Kitaoka |
120a6e |
virtual void
|
|
Shinya Kitaoka |
120a6e |
reset(); //!< Clears accepted resolutions - should be used together
|
|
Shinya Kitaoka |
120a6e |
//! with option \p APPLY_TO_ALL.
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
QButtonGroup *m_buttonGroup; //!< Group of abstract buttons representing all
|
|
Shinya Kitaoka |
120a6e |
//! available resolutions.
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
/*! \details Resolution \p NO_REQUIRED_RESOLUTION is always tested before
|
|
Shinya Kitaoka |
120a6e |
other
|
|
Shinya Kitaoka |
120a6e |
proposed resolutions.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
\return An error message upon failure. */
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
virtual QString acceptResolution(
|
|
Shinya Kitaoka |
120a6e |
void *obj, //!< The type-erased object to be resolved. May be modified.
|
|
Shinya Kitaoka |
120a6e |
int resolution, //!< The button id associated to the selected
|
|
Shinya Kitaoka |
38fd86 |
//! resolution.
|
|
Shinya Kitaoka |
120a6e |
bool applyToAll //!< Whether user selected the resolution for all
|
|
Shinya Kitaoka |
38fd86 |
//! successive prompts.
|
|
Shinya Kitaoka |
120a6e |
) = 0; //!< Attempts enforcement of the selected resolution.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*! \details This function can be used to initialize the widget as soon as
|
|
Shinya Kitaoka |
120a6e |
user interaction is required. Use \p showEvent() in case the
|
|
Shinya Kitaoka |
120a6e |
initialization is needed at \a every interaction time. */
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
virtual void initializeUserInteraction(const void *obj) {
|
|
Shinya Kitaoka |
120a6e |
} //!< Invoked at max \a once per \p execute(), immediately
|
|
Shinya Kitaoka |
120a6e |
//! before the dialog is shown.
|
|
Shinya Kitaoka |
120a6e |
bool appliedToAll() const {
|
|
Shinya Kitaoka |
120a6e |
return m_appliedToAll;
|
|
Shinya Kitaoka |
120a6e |
} //!< Returns whether the "Apply To All" button has been hit.
|
|
Shinya Kitaoka |
120a6e |
int appliedToAllResolution() const {
|
|
Shinya Kitaoka |
120a6e |
return m_appliedToAllRes;
|
|
Shinya Kitaoka |
120a6e |
} //!< Returns the resolution associated to the "Apply To All"
|
|
Shinya Kitaoka |
120a6e |
//! button.
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
QLabel *m_label; //!< Label showing a description of the validation problem.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
int m_appliedToAllRes; //!< Resolution applied in the \p APPLY_TO_ALL case.
|
|
Shinya Kitaoka |
120a6e |
bool m_appliedToAll, //!< Whether the \p APPLY_TO_ALL option has previously
|
|
Shinya Kitaoka |
38fd86 |
//! been selected.
|
|
Shinya Kitaoka |
120a6e |
m_applyToAll; //!< Whether the \p APPLY_TO_ALL option has been selected
|
|
Shinya Kitaoka |
38fd86 |
//! in
|
|
Shinya Kitaoka |
38fd86 |
//! \a current user interaction.
|
|
Toshihiro Shimizu |
890ddd |
private slots:
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void onApplyToAll();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace DVGui
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // VALIDATEDCHOICEDIALOG_H
|