2017-07-21 18:21:34 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_DIALOG_H
|
|
|
|
#define QSK_DIALOG_H 1
|
|
|
|
|
|
|
|
#include "QskGlobal.h"
|
2018-08-03 08:30:23 +02:00
|
|
|
|
2018-07-19 14:10:48 +02:00
|
|
|
#include <qobject.h>
|
2017-07-21 18:21:34 +02:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class QString;
|
|
|
|
class QStringList;
|
|
|
|
class QWindow;
|
|
|
|
|
|
|
|
#if defined( qskDialog )
|
|
|
|
#undef qskDialog
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define qskDialog QskDialog::instance()
|
|
|
|
|
|
|
|
class QSK_EXPORT QskDialog : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
Q_PROPERTY( Policy policy READ policy
|
|
|
|
WRITE setPolicy NOTIFY policyChanged )
|
|
|
|
|
|
|
|
Q_PROPERTY( QWindow* transientParent READ transientParent
|
|
|
|
WRITE setTransientParent NOTIFY transientParentChanged )
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
public:
|
2017-07-21 18:21:34 +02:00
|
|
|
enum Policy
|
|
|
|
{
|
|
|
|
EmbeddedBox,
|
|
|
|
EmbeddedWindow, // not yet implemented, do we need it ?
|
|
|
|
TopLevelWindow
|
|
|
|
};
|
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
Q_ENUM( Policy )
|
|
|
|
|
|
|
|
// a.k.a QMessageBox::StandardButton or QPlatformDialogHelper::StandardButton
|
|
|
|
enum Action
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
2018-11-05 13:29:52 +01:00
|
|
|
NoAction = 0,
|
|
|
|
Ok = 1 << 10,
|
|
|
|
Save = 1 << 11,
|
|
|
|
SaveAll = 1 << 12,
|
|
|
|
Open = 1 << 13,
|
|
|
|
Yes = 1 << 14,
|
|
|
|
YesToAll = 1 << 15,
|
|
|
|
No = 1 << 16,
|
|
|
|
NoToAll = 1 << 17,
|
|
|
|
Abort = 1 << 18,
|
|
|
|
Retry = 1 << 19,
|
|
|
|
Ignore = 1 << 20,
|
|
|
|
Close = 1 << 21,
|
|
|
|
Cancel = 1 << 22,
|
|
|
|
Discard = 1 << 23,
|
|
|
|
Help = 1 << 24,
|
|
|
|
Apply = 1 << 25,
|
|
|
|
Reset = 1 << 26,
|
|
|
|
RestoreDefaults = 1 << 27
|
2017-07-21 18:21:34 +02:00
|
|
|
};
|
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
Q_ENUM( Action )
|
|
|
|
Q_DECLARE_FLAGS( Actions, Action )
|
|
|
|
|
|
|
|
// a.k.a QMessageBox::ButtonRole
|
|
|
|
enum ActionRole
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
|
|
|
InvalidRole = -1,
|
|
|
|
|
|
|
|
AcceptRole,
|
|
|
|
RejectRole,
|
|
|
|
DestructiveRole,
|
2018-11-05 13:29:52 +01:00
|
|
|
UserRole,
|
2017-07-21 18:21:34 +02:00
|
|
|
HelpRole,
|
|
|
|
YesRole,
|
|
|
|
NoRole,
|
|
|
|
ResetRole,
|
|
|
|
ApplyRole,
|
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
NActionRoles
|
2017-07-21 18:21:34 +02:00
|
|
|
};
|
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
Q_ENUM( ActionRole )
|
|
|
|
|
2018-11-05 16:06:43 +01:00
|
|
|
// for building the mask in QskSkin::dialogButtonLayout
|
|
|
|
enum ButtonLayoutFlag
|
|
|
|
{
|
|
|
|
// from QPlatformDialogHelper::ButtonRole
|
|
|
|
ActionMask = 0x0FFFFFFF,
|
|
|
|
|
|
|
|
AlternateRole = 1 << 28,
|
|
|
|
Stretch = 1 << 29,
|
|
|
|
Reverse = 1 << 30
|
|
|
|
};
|
|
|
|
|
2017-07-21 18:21:34 +02:00
|
|
|
enum DialogCode
|
|
|
|
{
|
|
|
|
Rejected = 0,
|
|
|
|
Accepted
|
|
|
|
};
|
|
|
|
|
|
|
|
Q_ENUM( DialogCode )
|
|
|
|
|
|
|
|
static QskDialog* instance();
|
|
|
|
|
|
|
|
Q_INVOKABLE void setPolicy( Policy );
|
|
|
|
Q_INVOKABLE Policy policy() const;
|
|
|
|
|
|
|
|
Q_INVOKABLE void setTransientParent( QWindow* );
|
|
|
|
Q_INVOKABLE QWindow* transientParent() const;
|
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
Q_INVOKABLE Action message(
|
|
|
|
const QString& title, const QString& text, int symbolType,
|
|
|
|
Actions actions = Ok, Action defaultAction = NoAction ) const;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
Q_INVOKABLE Action information(
|
2017-07-21 18:21:34 +02:00
|
|
|
const QString& title, const QString& text,
|
2018-11-05 13:29:52 +01:00
|
|
|
Actions actions = Ok, Action defaultAction = NoAction ) const;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
Q_INVOKABLE Action warning(
|
2018-08-03 08:15:28 +02:00
|
|
|
const QString& title, const QString& text,
|
2018-11-05 13:29:52 +01:00
|
|
|
Actions actions = Ok, Action defaultAction = NoAction ) const;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
Q_INVOKABLE Action critical(
|
2018-08-03 08:15:28 +02:00
|
|
|
const QString& title, const QString& text,
|
2018-11-05 13:29:52 +01:00
|
|
|
Actions actions = Ok, Action defaultAction = NoAction ) const;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
Q_INVOKABLE Action question(
|
2018-08-03 08:15:28 +02:00
|
|
|
const QString& title, const QString& text,
|
2018-11-05 13:29:52 +01:00
|
|
|
Actions actions = Actions( Yes | No ),
|
|
|
|
Action defaultAction = NoAction ) const;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
Q_INVOKABLE QString select(
|
|
|
|
const QString& title, const QString& text,
|
2018-08-03 08:15:28 +02:00
|
|
|
const QStringList& entries, int selectedRow = 0 ) const;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
Q_SIGNALS:
|
2017-07-21 18:21:34 +02:00
|
|
|
void transientParentChanged();
|
|
|
|
void policyChanged();
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
private:
|
2017-07-21 18:21:34 +02:00
|
|
|
QskDialog();
|
2018-07-31 17:32:25 +02:00
|
|
|
~QskDialog() override;
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
static QskDialog* s_instance;
|
|
|
|
|
|
|
|
class PrivateData;
|
|
|
|
std::unique_ptr< PrivateData > m_data;
|
|
|
|
};
|
|
|
|
|
2018-11-05 13:29:52 +01:00
|
|
|
Q_DECLARE_METATYPE( QskDialog::Action )
|
|
|
|
Q_DECLARE_METATYPE( QskDialog::Actions )
|
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS( QskDialog::Actions )
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
#endif
|