2016-05-17 03:04:11 +12:00
|
|
|
#pragma once
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
#ifndef DVDIALOG_INCLUDED
|
|
|
|
#define DVDIALOG_INCLUDED
|
|
|
|
|
|
|
|
// TnzCore includes
|
|
|
|
#include "tcommon.h"
|
|
|
|
#include "tmsgcore.h"
|
|
|
|
|
|
|
|
// Qt includes
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QString>
|
|
|
|
#include <QProgressBar>
|
|
|
|
#include <QFrame>
|
|
|
|
#include <QSettings>
|
|
|
|
|
|
|
|
#undef DVAPI
|
|
|
|
#undef DVVAR
|
|
|
|
#ifdef TOONZQT_EXPORTS
|
|
|
|
#define DVAPI DV_EXPORT_API
|
|
|
|
#define DVVAR DV_EXPORT_VAR
|
|
|
|
#else
|
|
|
|
#define DVAPI DV_IMPORT_API
|
|
|
|
#define DVVAR DV_IMPORT_VAR
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// forward declaration
|
|
|
|
class QAbstractButton;
|
|
|
|
class QHBoxLayout;
|
|
|
|
class QVBoxLayout;
|
|
|
|
class QLayout;
|
|
|
|
class QLabel;
|
|
|
|
class TXsheetHandle;
|
|
|
|
class TPalette;
|
|
|
|
|
2017-05-09 00:13:29 +12:00
|
|
|
#ifdef _MSC_VER
|
2016-03-19 06:57:51 +13:00
|
|
|
#pragma warning(disable : 4251)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//=============================================================================
|
2016-06-15 18:43:10 +12:00
|
|
|
namespace DVGui {
|
2016-03-19 06:57:51 +13:00
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
const int WidgetHeight = 20;
|
|
|
|
|
|
|
|
class Dialog;
|
2017-04-21 16:41:45 +12:00
|
|
|
class MessageAndCheckboxDialog;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void DVAPI MsgBoxInPopup(MsgType type, const QString &text);
|
|
|
|
|
|
|
|
// ATTENZIONE: Valore di ritorno
|
2016-06-15 18:43:10 +12:00
|
|
|
// 0 = l'utente ha chiuso la finestra (dovrebbe corrispondere ad un cancel o ad
|
2016-09-26 21:35:34 +13:00
|
|
|
// un NO) - closed window
|
|
|
|
// 1 = primo bottone da sx premuto - first button selected
|
|
|
|
// 2 = secondo bottone da sx premuto - second button
|
|
|
|
// 3 = terzo bottone da sx premuto - third button
|
|
|
|
// 4 = fourth button
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int DVAPI MsgBox(MsgType type, const QString &text,
|
|
|
|
const std::vector<QString> &buttons,
|
|
|
|
int defaultButtonIndex = 0, QWidget *parent = 0);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
// QUESTION: due bottoni user defined
|
2016-06-15 18:43:10 +12:00
|
|
|
int DVAPI MsgBox(const QString &text, const QString &button1,
|
|
|
|
const QString &button2, int defaultButtonIndex = 0,
|
|
|
|
QWidget *parent = 0);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
// QUESTION: tre bottoni user defined
|
2016-06-15 18:43:10 +12:00
|
|
|
int DVAPI MsgBox(const QString &text, const QString &button1,
|
|
|
|
const QString &button2, const QString &button3,
|
|
|
|
int defaultButtonIndex = 0, QWidget *parent = 0);
|
|
|
|
|
2016-09-26 21:35:34 +13:00
|
|
|
// QUESTION: four botton user defined
|
|
|
|
int DVAPI MsgBox(const QString &text, const QString &button1,
|
|
|
|
const QString &button2, const QString &button3,
|
|
|
|
const QString &button4, int defaultButtonIndex = 0,
|
|
|
|
QWidget *parent = 0);
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
Dialog DVAPI *createMsgBox(MsgType type, const QString &text,
|
|
|
|
const QStringList &buttons, int defaultButtonIndex,
|
|
|
|
QWidget *parent = 0);
|
|
|
|
|
2017-04-21 16:41:45 +12:00
|
|
|
MessageAndCheckboxDialog DVAPI *createMsgandCheckbox(
|
|
|
|
MsgType type, const QString &text, const QString &checkBoxText,
|
2018-03-14 20:58:55 +13:00
|
|
|
const QStringList &buttons, int defaultButtonIndex,
|
|
|
|
Qt::CheckState defaultCheckBoxState, QWidget *parent = 0);
|
2017-04-21 16:41:45 +12:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// void DVAPI error(const QString &msg);
|
|
|
|
// void DVAPI info(const QString &msg);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
QString DVAPI getText(const QString &title, const QString &label,
|
2016-06-15 18:43:10 +12:00
|
|
|
const QString &text = QString(), bool *ok = 0);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//=============================================================================
|
|
|
|
/*! \brief The Separator class provides a separator.
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
Inherits \b QWidget.
|
|
|
|
|
|
|
|
The separator can be text and line or only line. If QString \b
|
|
|
|
name, passed to
|
|
|
|
constructor, is not empty, separator is composed by text \b name
|
|
|
|
and line;
|
|
|
|
else separator is a line, this line width is DV dialog width,
|
|
|
|
clearly taking care
|
|
|
|
DV dialog margin.
|
|
|
|
The separator can be horizontal (by default) or vertical,
|
|
|
|
isVertical(), you can
|
|
|
|
set it using function \b setOrientation().
|
|
|
|
|
|
|
|
To add a separator to DV dialog \b Dialog you must create a new
|
|
|
|
Separator
|
|
|
|
and recall \b Dialog::addWidget(), or recall \b
|
|
|
|
Dialog::addSeparator().
|
|
|
|
|
|
|
|
\b Example: in a DV dialog \b Dialog
|
|
|
|
\code
|
|
|
|
Separator* exampleNameAndLine = new
|
|
|
|
Separator(QString("Example Name"));
|
|
|
|
addWidget(exampleNameAndLine);
|
|
|
|
Separator* exampleLine = new Separator("");
|
|
|
|
addWidget(exampleLine);
|
|
|
|
\endcode
|
|
|
|
or:
|
|
|
|
\code
|
|
|
|
addSeparator(QString("Example Name"));
|
|
|
|
addSeparator();
|
|
|
|
\endcode
|
|
|
|
\b Result
|
|
|
|
\image html DialogSeparator.jpg
|
2016-03-19 06:57:51 +13:00
|
|
|
*/
|
2016-06-29 18:17:12 +12:00
|
|
|
class DVAPI Separator final : public QFrame {
|
2016-06-15 18:43:10 +12:00
|
|
|
Q_OBJECT
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QString m_name;
|
|
|
|
bool m_isHorizontal;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2018-03-22 12:23:25 +13:00
|
|
|
Separator(QString name = "", QWidget *parent = 0, bool isHorizontal = true);
|
2016-06-15 18:43:10 +12:00
|
|
|
~Separator();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
/*! Set dialog saparator \b name to name, if name is empty dialog separator
|
|
|
|
is a line. */
|
|
|
|
void setName(const QString &name) { m_name = name; }
|
|
|
|
QString getName() { return m_name; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
/*! Set dialog saparator orientation to horizontal if \b isHorizontal is
|
|
|
|
true,
|
|
|
|
otherwise to vertical. */
|
|
|
|
void setOrientation(bool isHorizontal) { m_isHorizontal = isHorizontal; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
/*! Return true if saparator orientation is horizontal, false otherwise. */
|
|
|
|
bool isHorizontal() { return m_isHorizontal; }
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
protected:
|
2016-06-19 20:06:29 +12:00
|
|
|
void paintEvent(QPaintEvent *event) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
class DVAPI Dialog : public QDialog {
|
|
|
|
Q_OBJECT
|
|
|
|
// If the dialog has button then is modal too.
|
|
|
|
bool m_hasButton;
|
|
|
|
QString m_name;
|
2017-07-28 19:16:25 +12:00
|
|
|
int m_currentScreen = -1;
|
2016-06-15 18:43:10 +12:00
|
|
|
// gmt. rendo m_buttonLayout protected per ovviare ad un problema
|
|
|
|
// sull'addButtonBarWidget(). cfr filebrowserpopup.cpp.
|
|
|
|
// Dobbiamo discutere di Dialog.
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
protected:
|
2016-06-15 18:43:10 +12:00
|
|
|
QHBoxLayout *m_buttonLayout;
|
|
|
|
QList<QLabel *> m_labelList;
|
2016-06-19 20:06:29 +12:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
QVBoxLayout *m_topLayout;
|
|
|
|
QFrame *m_mainFrame, *m_buttonFrame;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QHBoxLayout *m_mainHLayout;
|
|
|
|
bool m_isMainHLayout;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QVBoxLayout *m_leftVLayout, *m_rightVLayout;
|
|
|
|
bool m_isMainVLayout;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int m_layoutSpacing;
|
|
|
|
int m_layoutMargin;
|
|
|
|
int m_labelWidth;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
std::vector<QWidget *> m_buttonBarWidgets;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
// if 'name' is not empty, the dialog will remember its geometry between Toonz
|
|
|
|
// sessions
|
|
|
|
Dialog(QWidget *parent = 0, bool hasButton = false, bool hasFixedSize = true,
|
|
|
|
const QString &name = QString());
|
|
|
|
~Dialog();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void beginVLayout();
|
|
|
|
void endVLayout();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void beginHLayout();
|
|
|
|
void endHLayout();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void addWidget(QWidget *widget, bool isRight = true);
|
|
|
|
void addWidgets(QWidget *firstW, QWidget *secondW);
|
|
|
|
void addWidget(QString labelName, QWidget *widget);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void addLayout(QLayout *layout, bool isRight = true);
|
|
|
|
void addWidgetLayout(QWidget *widget, QLayout *layout);
|
|
|
|
void addLayout(QString labelName, QLayout *layout);
|
|
|
|
void addLayouts(QLayout *firstL, QLayout *secondL);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void addSpacing(int spacing);
|
|
|
|
void addSeparator(QString name = QString());
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void setAlignment(Qt::Alignment alignment);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void setTopMargin(int margin);
|
|
|
|
void setTopSpacing(int spacing);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void setLabelWidth(int labelWidth);
|
|
|
|
int getLabelWidth() const { return m_labelWidth; };
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void setLayoutInsertedSpacing(int spacing);
|
|
|
|
int getLayoutInsertedSpacing();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void setButtonBarMargin(int margin);
|
|
|
|
void setButtonBarSpacing(int spacing);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void addButtonBarWidget(QWidget *widget);
|
|
|
|
void addButtonBarWidget(QWidget *first, QWidget *second);
|
|
|
|
void addButtonBarWidget(QWidget *first, QWidget *second, QWidget *third);
|
2016-09-26 21:35:34 +13:00
|
|
|
void addButtonBarWidget(QWidget *first, QWidget *second, QWidget *third,
|
|
|
|
QWidget *fourth);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-19 20:06:29 +12:00
|
|
|
void hideEvent(QHideEvent *event) override;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void clearButtonBar();
|
2016-03-19 06:57:51 +13:00
|
|
|
signals:
|
2016-06-15 18:43:10 +12:00
|
|
|
void dialogClosed();
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
2017-04-21 16:41:45 +12:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class DVAPI MessageAndCheckboxDialog final : public DVGui::Dialog {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
int m_checked = 0;
|
|
|
|
|
|
|
|
public:
|
|
|
|
MessageAndCheckboxDialog(QWidget *parent = 0, bool hasButton = false,
|
2018-03-14 20:58:55 +13:00
|
|
|
bool hasFixedSize = true,
|
|
|
|
const QString &name = QString(),
|
|
|
|
Qt::CheckState checkButtonState = Qt::Unchecked);
|
2017-04-21 16:41:45 +12:00
|
|
|
int getChecked() { return m_checked; }
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void onCheckboxChanged(int checked);
|
|
|
|
void onButtonPressed(int id);
|
|
|
|
};
|
|
|
|
|
2016-03-19 06:57:51 +13:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/*! Is a modal dialog with exclusive list of radio button.
|
|
|
|
Exec value depend to checked button.
|
|
|
|
0 -> Cancel or Close Popup,
|
|
|
|
1,2,3,... -> checkbox clicked.
|
|
|
|
*/
|
2016-06-29 18:17:12 +12:00
|
|
|
class DVAPI RadioButtonDialog final : public DVGui::Dialog {
|
2016-06-15 18:43:10 +12:00
|
|
|
Q_OBJECT
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int m_result;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
RadioButtonDialog(const QString &labelText,
|
|
|
|
const QList<QString> &radioButtonList, QWidget *parent = 0,
|
|
|
|
Qt::WindowFlags f = 0);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
2016-06-15 18:43:10 +12:00
|
|
|
void onButtonClicked(int id);
|
|
|
|
void onCancel();
|
|
|
|
void onApply();
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
int DVAPI RadioButtonMsgBox(MsgType type, const QString &labelText,
|
2016-06-15 18:43:10 +12:00
|
|
|
const QList<QString> &buttons, QWidget *parent = 0);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
class DVAPI ProgressDialog : public DVGui::Dialog {
|
|
|
|
Q_OBJECT
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
QLabel *m_label;
|
|
|
|
QProgressBar *m_progressBar;
|
|
|
|
QPushButton *m_cancelButton;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
protected:
|
2016-06-15 18:43:10 +12:00
|
|
|
bool m_isCanceled;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
ProgressDialog(const QString &labelText, const QString &cancelButtonText,
|
|
|
|
int minimum, int maximum, QWidget *parent = 0,
|
|
|
|
Qt::WindowFlags f = 0);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void setLabelText(const QString &text);
|
|
|
|
void setCancelButton(QPushButton *cancelButton);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int maximum();
|
|
|
|
void setMaximum(int maximum);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int minimum();
|
|
|
|
void setMinimum(int minimum);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
void reset();
|
|
|
|
int value();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
bool wasCanceled() const;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public Q_SLOTS:
|
2016-06-15 18:43:10 +12:00
|
|
|
void setValue(int progress);
|
|
|
|
virtual void onCancel();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
Q_SIGNALS:
|
|
|
|
void canceled();
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/*! Return 2 if erase style,
|
2016-06-15 18:43:10 +12:00
|
|
|
1 if don't erase style,
|
|
|
|
0 if press cancel or close popup.
|
|
|
|
If newPalette != 0 verify if styles to erase are in new palette before
|
|
|
|
send question.
|
2016-03-19 06:57:51 +13:00
|
|
|
*/
|
2016-06-15 18:43:10 +12:00
|
|
|
int eraseStylesInDemand(TPalette *palette, const TXsheetHandle *xsheetHandle,
|
|
|
|
TPalette *newPalette = 0);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
int eraseStylesInDemand(TPalette *palette, std::vector<int> styleIds,
|
|
|
|
const TXsheetHandle *xsheetHandle);
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
2016-06-15 18:43:10 +12:00
|
|
|
} // namespace DVGui
|
2016-03-19 06:57:51 +13:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
#endif // DVDIALOG_INCLUDED
|