1 #ifndef QTMVVM_MESSAGE_H 2 #define QTMVVM_MESSAGE_H 6 #include <QtCore/qcoreapplication.h> 7 #include <QtCore/qshareddata.h> 8 #include <QtCore/qscopedpointer.h> 9 #include <QtCore/qurl.h> 10 #include <QtCore/qvariant.h> 12 #include "QtMvvmCore/qtmvvmcore_global.h" 16 class MessageConfigPrivate;
26 Q_PROPERTY(
QByteArray subType READ subType WRITE setSubType RESET resetSubType)
29 Q_PROPERTY(
QString title READ title WRITE setTitle)
31 Q_PROPERTY(
QString text READ text WRITE setText)
33 Q_PROPERTY(StandardButtons buttons READ buttons WRITE setButtons RESET resetButtons)
35 Q_PROPERTY(QVariantMap buttonTexts READ buttonTextsMap WRITE setButtonTextsMap RESET resetButtons)
38 Q_PROPERTY(
QVariant defaultValue READ defaultValue WRITE setDefaultValue)
40 Q_PROPERTY(QVariantMap viewProperties READ viewProperties WRITE setViewProperties)
46 NoButton = 0x00000000,
52 YesToAll = 0x00008000,
64 RestoreDefaults = 0x08000000
66 Q_DECLARE_FLAGS(StandardButtons, StandardButton)
67 Q_FLAG(StandardButtons)
129 StandardButtons buttons()
const;
135 QVariantMap viewProperties()
const;
154 MessageConfig &setViewProperties(
const QVariantMap &viewProperties);
166 QVariantMap buttonTextsMap()
const;
167 void setButtonTextsMap(
const QVariantMap &buttonTexts);
170 class MessageResultPrivate;
177 Q_PROPERTY(
QVariant result READ result WRITE setResult)
179 Q_PROPERTY(
bool autoDelete READ autoDelete WRITE setAutoDelete NOTIFY autoDeleteChanged)
186 bool hasResult() const;
190 bool autoDelete() const;
197 Q_INVOKABLE
void setCloseTarget(
QObject *closeObject, const
QString &closeMethod);
200 Q_INVOKABLE
void setCloseTarget(
QObject *closeObject, const
QMetaMethod &closeMethod);
212 void discardMessage();
217 void setAutoDelete(
bool autoDelete);
224 void autoDeleteChanged(
bool autoDelete, QPrivateSignal);
242 const std::function<
void()> &onResult,
247 const std::function<
void()> &onResult,
259 const std::function<
void(
bool)> &onResult,
265 const std::function<
void(
bool)> &onResult,
277 const std::function<
void()> &onResult,
282 const std::function<
void()> &onResult,
293 const std::function<
void()> &onResult,
298 const std::function<
void()> &onResult,
302 Q_MVVMCORE_EXPORT MessageResult *
about(
const QString &description,
307 bool addQtVersion =
true,
319 const char *inputType,
321 const QVariantMap &viewProperties = {},
323 const QString &cancelText = {});
327 const char *inputType,
329 const std::function<
void(
QVariant)> &onResult,
331 const QVariantMap &viewProperties = {},
333 const QString &cancelText = {});
337 const char *inputType,
338 const std::function<
void(
QVariant)> &onResult,
340 const QVariantMap &viewProperties = {},
342 const QString &cancelText = {});
345 template <
typename TEdit>
348 const TEdit &defaultValue = {},
349 const QVariantMap &viewProperties = {},
351 const QString &cancelText = {}) {
355 template <
typename TEdit>
359 const std::function<
void(TEdit,
bool)> &onResult,
360 const TEdit &defaultValue = {},
361 const QVariantMap &viewProperties = {},
363 const QString &cancelText = {}) {
365 onResult(v.template value<TEdit>(), v.
isValid());
369 template <
typename TEdit>
372 const std::function<
void(TEdit,
bool)> &onResult,
373 const TEdit &defaultValue = {},
374 const QVariantMap &viewProperties = {},
376 const QString &cancelText = {}) {
378 onResult(v.template value<TEdit>(), v.
isValid());
389 const QUrl &dir = {});
392 const std::function<
void(
QUrl)> &onResult,
394 const QUrl &dir = {});
398 const QUrl &dir = {});
403 const QUrl &dir = {});
406 const std::function<
void(
QUrl)> &onResult,
409 const QUrl &dir = {});
411 Q_MVVMCORE_EXPORT
void getOpenFile(
const std::function<
void(
QUrl)> &onResult,
414 const QUrl &dir = {});
419 const QUrl &dir = {});
425 const QUrl &dir = {});
430 const QUrl &dir = {});
435 const QUrl &dir = {});
438 const std::function<
void(
QUrl)> &onResult,
441 const QUrl &dir = {});
443 Q_MVVMCORE_EXPORT
void getSaveFile(
const std::function<
void(
QUrl)> &onResult,
446 const QUrl &dir = {});
455 Q_DECLARE_OPERATORS_FOR_FLAGS(QtMvvm::MessageConfig::StandardButtons)
457 #endif // QTMVVM_MESSAGE_H Q_MVVMCORE_EXPORT MessageResult * question(const QString &title, const QString &text, const QString &yesText={}, const QString &noText={})
A shortcut to show a simple question messagebox.
static const QByteArray TypeFileDialog
A type to show a generic file dialog.
static const QByteArray SubTypeSaveFile
A subType for to show a save file dialog.
static const QByteArray SubTypeOpenFile
A subType for to show an open file dialog.
Q_MVVMCORE_EXPORT MessageResult * getOpenFiles(const QString &title={}, const QStringList &supportedMimeTypes={}, const QUrl &dir={})
A shortcut to show a file dialog to select multiple existing files.
StandardButton
The Possible Buttons a dialog can have.
static const QByteArray TypeInputDialog
A type to show a generic input dialog.
Q_MVVMCORE_EXPORT MessageResult * getSaveFile(const QString &title={}, const QStringList &supportedMimeTypes={}, const QUrl &dir={})
A shortcut to show a file dialog to select a new file for saving.
Q_MVVMCORE_EXPORT MessageResult * getInput(const QString &title, const QString &text, const char *inputType, const QVariant &defaultValue={}, const QVariantMap &viewProperties={}, const QString &okText={}, const QString &cancelText={})
A shortcut to show an input dialog based of a type name.
A configuration for a simple dialog to be shown from the core code.
static const QByteArray SubTypeOpenFiles
A subType for to show an open files dialog.
Q_MVVMCORE_EXPORT MessageResult * getOpenFile(const QString &title={}, const QStringList &supportedMimeTypes={}, const QUrl &dir={})
A shortcut to show a file dialog to select an existing file.
static const QByteArray SubTypeQuestion
A subType to show a question message.
static const QByteArray SubTypeAbout
A subType to show an about dialog.
Q_MVVMCORE_EXPORT MessageResult * about(const QString &description, const QUrl &websiteUrl=QUrl(), const QString &licenseName=QString(), const QUrl &licenseUrl=QUrl(), const QString &companyName=QString(), bool addQtVersion=true, const QStringList &extraTopInfos=QStringList(), const QString &extraBottomInfos=QString())
A shortcut to show a rich but simple about dialog.
static const QByteArray SubTypeCritical
A subType to show a critical error message.
QVariant fromValue(const T &value)
Q_MVVMCORE_EXPORT MessageResult * critical(const QString &title, const QString &text, const QString &okText={})
A shortcut to show a simple critical error messagebox.
A result watcher to get the result once a dialog has finished.
The primary namespace of the QtMvvm library.
static const QByteArray SubTypeWarning
A subType to show a warning message.
Q_MVVMCORE_EXPORT MessageResult * warning(const QString &title, const QString &text, const QString &okText={})
A shortcut to show a simple warning messagebox.
Q_MVVMCORE_EXPORT MessageResult * getExistingDirectory(const QString &title={}, const QUrl &dir={})
A shortcut to show a file dialog to select an existing directory.
Q_MVVMCORE_EXPORT MessageResult * information(const QString &title, const QString &text, const QString &okText={})
A shortcut to show a simple information messagebox.