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 <QtGui/qcolor.h> 14 #include "QtMvvmCore/qtmvvmcore_global.h" 18 class MessageConfigPrivate;
28 Q_PROPERTY(
QByteArray subType READ subType WRITE setSubType RESET resetSubType)
31 Q_PROPERTY(
QString title READ title WRITE setTitle)
33 Q_PROPERTY(
QString text READ text WRITE setText)
35 Q_PROPERTY(StandardButtons buttons READ buttons WRITE setButtons RESET resetButtons)
37 Q_PROPERTY(QVariantMap buttonTexts READ buttonTextsMap WRITE setButtonTextsMap RESET resetButtons)
40 Q_PROPERTY(
QVariant defaultValue READ defaultValue WRITE setDefaultValue)
42 Q_PROPERTY(QVariantMap viewProperties READ viewProperties WRITE setViewProperties)
48 NoButton = 0x00000000,
54 YesToAll = 0x00008000,
66 RestoreDefaults = 0x08000000
68 Q_DECLARE_FLAGS(StandardButtons, StandardButton)
69 Q_FLAG(StandardButtons)
159 StandardButtons buttons()
const;
165 QVariantMap viewProperties()
const;
186 MessageConfig &setViewProperties(
const QVariantMap &viewProperties);
198 QVariantMap buttonTextsMap()
const;
199 void setButtonTextsMap(
const QVariantMap &buttonTexts);
202 class MessageResultPrivate;
209 Q_PROPERTY(
QVariant result READ result WRITE setResult)
211 Q_PROPERTY(
bool autoDelete READ autoDelete WRITE setAutoDelete NOTIFY autoDeleteChanged)
218 bool hasResult() const;
222 bool autoDelete() const;
229 Q_INVOKABLE
void setCloseTarget(
QObject *closeObject, const
QString &closeMethod);
232 Q_INVOKABLE
void setCloseTarget(
QObject *closeObject, const
QMetaMethod &closeMethod);
244 void discardMessage();
249 void setAutoDelete(
bool autoDelete);
256 void autoDeleteChanged(
bool autoDelete, QPrivateSignal);
262 class ProgressControlPrivate;
269 Q_PROPERTY(
bool autoDelete READ autoDelete WRITE setAutoDelete NOTIFY autoDeleteChanged)
272 Q_PROPERTY(
bool indeterminate READ isIndeterminate WRITE setIndeterminate NOTIFY indeterminateChanged)
274 Q_PROPERTY(
int minimum READ minimum WRITE setMinimum NOTIFY minimumChanged)
276 Q_PROPERTY(
int maximum READ maximum WRITE setMaximum NOTIFY maximumChanged)
278 Q_PROPERTY(
int progress READ progress WRITE setProgress NOTIFY progressChanged)
286 bool autoDelete() const;
288 bool isIndeterminate() const;
294 int progress() const;
304 Q_INVOKABLE
void notifyClosed();
311 void updateLabel(const
QString &text);
314 void setAutoDelete(
bool autoDelete);
316 void setIndeterminate(
bool indeterminate);
318 void setMinimum(
int minimum);
320 void setMaximum(
int maximum);
322 void setProgress(
int progress);
324 void setProgress(
double progressPercent);
328 void autoDeleteChanged(
bool autoDelete, QPrivateSignal);
330 void indeterminateChanged(
bool indeterminate, QPrivateSignal);
332 void minimumChanged(
int minimum, QPrivateSignal);
334 void maximumChanged(
int maximum, QPrivateSignal);
336 void progressChanged(
int progress, QPrivateSignal);
341 void closed(QPrivateSignal);
348 void changeLabel(const
QString &text, QPrivateSignal);
351 void closeRequested(QPrivateSignal);
370 const std::function<
void()> &onResult,
375 const std::function<
void()> &onResult,
387 const std::function<
void(
bool)> &onResult,
393 const std::function<
void(
bool)> &onResult,
405 const std::function<
void()> &onResult,
410 const std::function<
void()> &onResult,
421 const std::function<
void()> &onResult,
426 const std::function<
void()> &onResult,
430 Q_MVVMCORE_EXPORT MessageResult *
about(
const QString &description,
435 bool addQtVersion =
true,
447 const char *inputType,
449 const QVariantMap &viewProperties = {},
451 const QString &cancelText = {});
455 const char *inputType,
457 const std::function<
void(
QVariant)> &onResult,
459 const QVariantMap &viewProperties = {},
461 const QString &cancelText = {});
465 const char *inputType,
466 const std::function<
void(
QVariant)> &onResult,
468 const QVariantMap &viewProperties = {},
470 const QString &cancelText = {});
473 template <
typename TEdit>
476 const TEdit &defaultValue = {},
477 const QVariantMap &viewProperties = {},
479 const QString &cancelText = {}) {
483 template <
typename TEdit>
487 const std::function<
void(TEdit,
bool)> &onResult,
488 const TEdit &defaultValue = {},
489 const QVariantMap &viewProperties = {},
491 const QString &cancelText = {}) {
493 onResult(v.template value<TEdit>(), v.
isValid());
497 template <
typename TEdit>
500 const std::function<
void(TEdit,
bool)> &onResult,
501 const TEdit &defaultValue = {},
502 const QVariantMap &viewProperties = {},
504 const QString &cancelText = {}) {
506 onResult(v.template value<TEdit>(), v.
isValid());
517 const QUrl &dir = {});
520 const std::function<
void(
QUrl)> &onResult,
522 const QUrl &dir = {});
526 const QUrl &dir = {});
531 const QUrl &dir = {});
534 const std::function<
void(
QUrl)> &onResult,
537 const QUrl &dir = {});
539 Q_MVVMCORE_EXPORT
void getOpenFile(
const std::function<
void(
QUrl)> &onResult,
542 const QUrl &dir = {});
547 const QUrl &dir = {});
553 const QUrl &dir = {});
558 const QUrl &dir = {});
563 const QUrl &dir = {});
566 const std::function<
void(
QUrl)> &onResult,
569 const QUrl &dir = {});
571 Q_MVVMCORE_EXPORT
void getSaveFile(
const std::function<
void(
QUrl)> &onResult,
574 const QUrl &dir = {});
587 const std::function<
void(
QColor)> &onResult,
592 Q_MVVMCORE_EXPORT
void getColor(
const std::function<
void(
QColor)> &onResult,
605 ProgressControl *control,
606 bool allowCancel =
true,
608 const QString &cancelText = {});
616 bool allowCancel =
true,
618 const QString &cancelText = {});
624 bool allowCancel =
true,
626 const QString &cancelText = {});
632 bool allowCancel =
true,
633 const QString &cancelText = {});
637 bool allowCancel =
true,
638 const QString &cancelText = {});
644 bool allowCancel =
true,
645 const QString &cancelText = {});
649 bool allowCancel =
true,
650 const QString &cancelText = {});
659 Q_DECLARE_OPERATORS_FOR_FLAGS(QtMvvm::MessageConfig::StandardButtons)
661 #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.
Q_MVVMCORE_EXPORT MessageResult * getColor(const QString &title={}, const QColor &color={}, bool argb=false)
A shortcut to show a color dialog to select a color.
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.
A Helper class to control a generic progress dialog.
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.
Q_MVVMCORE_EXPORT ProgressControl * showBusy(QObject *scope, const QString &title={}, const QString &label={}, bool allowCancel=true, const QString &cancelText={})
A shortcut to show a busy indicator dialog.
static const QByteArray TypeColorDialog
A type to show a generic color dialog.
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.
Q_MVVMCORE_EXPORT MessageResult * showProgress(const QString &title, const QString &label, ProgressControl *control, bool allowCancel=true, bool isBusy=false, const QString &cancelText={})
A shortcut to show a general progress dialog.
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 SubTypeArgb
A subType to show a color dialog with an alpha channel.
static const QByteArray SubTypeCritical
A subType to show a critical error message.
QVariant fromValue(const T &value)
static const QByteArray TypeProgressDialog
A type to show a generic progress dialog.
Q_MVVMCORE_EXPORT ProgressControl * showIndeterminateProgress(QObject *scope, const QString &title={}, const QString &label={}, bool allowCancel=true, const QString &cancelText={})
A shortcut to show an indetermiante progress dialog.
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.
bool isValid() const const
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.
static const QByteArray SubTypeBusy
A subType to show a dialog with a busy indicator.