|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/dvdialog.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzQt includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/checkbox.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/lineedit.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/fxsettings.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// TnzLib includes
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheethandle.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshsimplelevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/palettecmd.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/preferences.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/toonzfolders.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Qt includes
|
|
Toshihiro Shimizu |
890ddd |
#include <qframe></qframe>
|
|
Toshihiro Shimizu |
890ddd |
#include <qlayout></qlayout>
|
|
Toshihiro Shimizu |
890ddd |
#include <qlabel></qlabel>
|
|
Toshihiro Shimizu |
890ddd |
#include <qpushbutton></qpushbutton>
|
|
Toshihiro Shimizu |
890ddd |
#include <qapplication></qapplication>
|
|
Toshihiro Shimizu |
890ddd |
#include <qstyle></qstyle>
|
|
Toshihiro Shimizu |
890ddd |
#include <qbuttongroup></qbuttongroup>
|
|
Toshihiro Shimizu |
890ddd |
#include <qpainter></qpainter>
|
|
Toshihiro Shimizu |
890ddd |
#include <qradiobutton></qradiobutton>
|
|
Toshihiro Shimizu |
890ddd |
#include <qthread></qthread>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// boost includes
|
|
Toshihiro Shimizu |
890ddd |
#include <boost algorithm="" any_of.hpp="" cxx11=""></boost>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
using namespace DVGui;
|
|
Toshihiro Shimizu |
890ddd |
|
|
brly |
591f92 |
QString DialogTitle = QObject::tr("OpenToonz 1.0");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QPixmap getMsgBoxPixmap(MsgType type)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
int iconSize = QApplication::style()->pixelMetric(QStyle::PM_MessageBoxIconSize);
|
|
Toshihiro Shimizu |
890ddd |
QIcon msgBoxIcon;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
switch (type) {
|
|
Shinya Kitaoka |
eabf18 |
case DVGui::INFORMATION:
|
|
Toshihiro Shimizu |
890ddd |
msgBoxIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation);
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Shinya Kitaoka |
eabf18 |
case DVGui::WARNING:
|
|
Toshihiro Shimizu |
890ddd |
msgBoxIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning);
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Shinya Kitaoka |
eabf18 |
case DVGui::CRITICAL:
|
|
Toshihiro Shimizu |
890ddd |
msgBoxIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical);
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Shinya Kitaoka |
eabf18 |
case DVGui::QUESTION:
|
|
Toshihiro Shimizu |
890ddd |
msgBoxIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxQuestion);
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
default:
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!msgBoxIcon.isNull())
|
|
Toshihiro Shimizu |
890ddd |
return msgBoxIcon.pixmap(iconSize, iconSize);
|
|
Toshihiro Shimizu |
890ddd |
return QPixmap();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString getMsgBoxTitle(MsgType type)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QString title = DialogTitle + " - ";
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
switch (type) {
|
|
Shinya Kitaoka |
eabf18 |
case DVGui::INFORMATION:
|
|
Toshihiro Shimizu |
890ddd |
title.append(QObject::tr("Information"));
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Shinya Kitaoka |
eabf18 |
case DVGui::WARNING:
|
|
Toshihiro Shimizu |
890ddd |
title.append(QObject::tr("Warning"));
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Shinya Kitaoka |
eabf18 |
case DVGui::CRITICAL:
|
|
Toshihiro Shimizu |
890ddd |
title.append(QObject::tr("Critical"));
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Shinya Kitaoka |
eabf18 |
case DVGui::QUESTION:
|
|
Toshihiro Shimizu |
890ddd |
title.append(QObject::tr("Question"));
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
default:
|
|
Toshihiro Shimizu |
890ddd |
break;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return title;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
} // namespace
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// Separator
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Separator::Separator(QString name, QWidget *parent)
|
|
Toshihiro Shimizu |
890ddd |
: QFrame(parent), m_name(name), m_isHorizontal(true)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// if(m_name.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
// setMinimumSize(1,1);
|
|
Toshihiro Shimizu |
890ddd |
// else
|
|
Toshihiro Shimizu |
890ddd |
setMinimumSize(1, 15);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Separator::~Separator()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void Separator::paintEvent(QPaintEvent *)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QPainter p(this);
|
|
Toshihiro Shimizu |
890ddd |
ParamsPage *page = dynamic_cast<paramspage *="">(parentWidget());</paramspage>
|
|
Toshihiro Shimizu |
890ddd |
if (!page)
|
|
Toshihiro Shimizu |
890ddd |
p.setPen(Qt::black);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
p.setPen(page->getTextColor());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QRect contents(contentsRect());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int textWidth = p.fontMetrics().width(m_name);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
p.drawText(contents.left(), 10, m_name);
|
|
Toshihiro Shimizu |
890ddd |
p.setPen(palette().alternateBase().color());
|
|
Toshihiro Shimizu |
890ddd |
int h = contents.height();
|
|
Toshihiro Shimizu |
890ddd |
if (m_isHorizontal) {
|
|
Toshihiro Shimizu |
890ddd |
int y = contents.center().y();
|
|
Toshihiro Shimizu |
890ddd |
int space = (textWidth == 0) ? 0 : 8;
|
|
Toshihiro Shimizu |
890ddd |
p.drawLine(textWidth + space, y, contents.width(), y);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
double w = width();
|
|
Toshihiro Shimizu |
890ddd |
int space = (textWidth == 0) ? 0 : 2;
|
|
Toshihiro Shimizu |
890ddd |
int x0 = (w > textWidth) ? w * 0.5 : (double)textWidth * 0.5;
|
|
Toshihiro Shimizu |
890ddd |
int textHeghit = (space == 0) ? 0 : p.fontMetrics().height();
|
|
Toshihiro Shimizu |
890ddd |
p.drawLine(x0, textHeghit + space, x0, contents.bottom());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*! \class DVGui::Dialog
|
|
Toshihiro Shimizu |
890ddd |
\brief The Dialog class is the base class of dialog windows.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Inherits \b QDialog.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
A dialog window is a top-level window, defined in \b QDialog, this class provides
|
|
Toshihiro Shimizu |
890ddd |
a collection of functions to manage \b QDialog widget visualization.
|
|
Toshihiro Shimizu |
890ddd |
Dialog window can be modal or modeless, from this it depends dialog visualization.
|
|
Toshihiro Shimizu |
890ddd |
You set your dialog to modal or modeless directly in constructor, with \b bool
|
|
Toshihiro Shimizu |
890ddd |
hasButton, in fact if the dialog has button then is modal too.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
If dialog is \b modal it's composed of two part, two \b QFrame; the first, \b main
|
|
Toshihiro Shimizu |
890ddd |
\b part at top of dialog, contains a vertical box layout \b QVBoxLayout, the second,
|
|
Toshihiro Shimizu |
890ddd |
\b button \b part at bottom, contains an horizontal box layout \b QHBoxLayout.
|
|
Toshihiro Shimizu |
890ddd |
Else if dialog is modeless it is composed only of first part, to be more precise,
|
|
Toshihiro Shimizu |
890ddd |
it is composed of a \b QFrame containing a vertical box layout \b QVBoxLayout.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
The first part of dialog can be implemented using different objects. You can manage
|
|
Toshihiro Shimizu |
890ddd |
directly vertical box layout, insert widget addWidget(), or layout addLayout(), set
|
|
Toshihiro Shimizu |
890ddd |
border and spacing, using setTopMargin() and setTopSpacing(), or insert a spece,
|
|
Toshihiro Shimizu |
890ddd |
addSpacing().
|
|
Toshihiro Shimizu |
890ddd |
\n If you need an horizontal layout you can use an implemented horizontal box layout;
|
|
Toshihiro Shimizu |
890ddd |
the function beginHLayout() initialize the horizontal box layout, a collection of
|
|
Toshihiro Shimizu |
890ddd |
function permit to insert object in this layout; at the end you must recall
|
|
Toshihiro Shimizu |
890ddd |
endVLayout(), this add horizontal layout to first part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
This struct permit you to allign the object you insert.
|
|
Toshihiro Shimizu |
890ddd |
\n If you need vertical layout you can use an implemented vertical box layout composed
|
|
Toshihiro Shimizu |
890ddd |
of two column, the function beginVLayout() initialize the vertical box layout,
|
|
Toshihiro Shimizu |
890ddd |
a collection of function permit to insert object in this layout.
|
|
Toshihiro Shimizu |
890ddd |
All this functions insert a pair of object in two vertical layout and permit
|
|
Toshihiro Shimizu |
890ddd |
to allign the objects, all pairs you insert are tabulated.
|
|
Toshihiro Shimizu |
890ddd |
At the end you must recall endVLayout(), this add vertical layout to first part of
|
|
Toshihiro Shimizu |
890ddd |
dialog.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
The second part of dialog may be implemented if dialog is modal.
|
|
Toshihiro Shimizu |
890ddd |
It's possible insert one, two or three widget in its horizontal box layout using
|
|
Toshihiro Shimizu |
890ddd |
addButtonBarWidget(), or clear all widget using clearButtonBar(). You can also
|
|
Toshihiro Shimizu |
890ddd |
set margin and spacing with setButtonBarMargin() and setButtonBarSpacing() functions.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
QSettings *Dialog::m_settings = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Dialog::Dialog(QWidget *parent, bool hasButton, bool hasFixedSize, const QString &name)
|
|
Toshihiro Shimizu |
890ddd |
: QDialog(parent, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), m_hasButton(hasButton), m_mainHLayout(0), m_leftVLayout(0), m_rightVLayout(0), m_isMainVLayout(false), m_isMainHLayout(false), m_layoutSpacing(5), m_layoutMargin(0), m_labelWidth(100), m_name()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QVBoxLayout *mainLayout = new QVBoxLayout;
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->setMargin(0);
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->setSpacing(0);
|
|
Toshihiro Shimizu |
890ddd |
m_mainFrame = new QFrame(this);
|
|
Toshihiro Shimizu |
890ddd |
m_mainFrame->setObjectName("dialogMainFrame");
|
|
Toshihiro Shimizu |
890ddd |
m_mainFrame->setMinimumHeight(41);
|
|
Toshihiro Shimizu |
890ddd |
m_mainFrame->setFrameStyle(QFrame::StyledPanel);
|
|
Toshihiro Shimizu |
890ddd |
m_topLayout = new QVBoxLayout;
|
|
Toshihiro Shimizu |
890ddd |
m_topLayout->setMargin(12);
|
|
Toshihiro Shimizu |
890ddd |
m_topLayout->setSpacing(m_layoutSpacing);
|
|
Toshihiro Shimizu |
890ddd |
m_topLayout->setAlignment(Qt::AlignCenter);
|
|
Toshihiro Shimizu |
890ddd |
m_mainFrame->setLayout(m_topLayout);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->addWidget(m_mainFrame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_hasButton) {
|
|
Toshihiro Shimizu |
890ddd |
// The dialog is modal
|
|
Toshihiro Shimizu |
890ddd |
setModal(true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_buttonFrame = new QFrame(this);
|
|
Toshihiro Shimizu |
890ddd |
m_buttonFrame->setObjectName("dialogButtonFrame");
|
|
Toshihiro Shimizu |
890ddd |
m_buttonFrame->setFrameStyle(QFrame::StyledPanel);
|
|
Toshihiro Shimizu |
890ddd |
m_buttonFrame->setFixedHeight(45);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_buttonLayout = new QHBoxLayout;
|
|
Toshihiro Shimizu |
890ddd |
m_buttonLayout->setMargin(0);
|
|
Toshihiro Shimizu |
890ddd |
m_buttonLayout->setSpacing(20);
|
|
Toshihiro Shimizu |
890ddd |
m_buttonLayout->setAlignment(Qt::AlignHCenter);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QVBoxLayout *buttonFrameLayout = new QVBoxLayout;
|
|
Toshihiro Shimizu |
890ddd |
buttonFrameLayout->setAlignment(Qt::AlignVCenter);
|
|
Toshihiro Shimizu |
890ddd |
buttonFrameLayout->addLayout(m_buttonLayout);
|
|
Toshihiro Shimizu |
890ddd |
m_buttonFrame->setLayout(buttonFrameLayout);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->addWidget(m_buttonFrame);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (hasFixedSize)
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->setSizeConstraint(QLayout::SetMinimumSize);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
setLayout(mainLayout);
|
|
Toshihiro Shimizu |
890ddd |
//this->setGeometry(30, 30, 300, 300);
|
|
Toshihiro Shimizu |
890ddd |
#ifdef MACOSX
|
|
Toshihiro Shimizu |
890ddd |
setWindowFlags(Qt::Tool);
|
|
Toshihiro Shimizu |
890ddd |
#endif
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!m_settings) {
|
|
Toshihiro Shimizu |
890ddd |
TFilePath layoutDir = ToonzFolder::getMyModuleDir();
|
|
Toshihiro Shimizu |
890ddd |
TFilePath savePath = layoutDir + TFilePath("popups.ini");
|
|
Toshihiro Shimizu |
890ddd |
m_settings = new QSettings(QString::fromStdWString(savePath.getWideString()), QSettings::IniFormat);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (name == QString())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
m_name = name + "DialogGeometry";
|
|
Toshihiro Shimizu |
890ddd |
QString geo = m_settings->value(m_name).toString();
|
|
Toshihiro Shimizu |
890ddd |
if (geo != QString()) {
|
|
Toshihiro Shimizu |
890ddd |
QStringList values = geo.split(" ");
|
|
Toshihiro Shimizu |
890ddd |
assert(values.size() == 4);
|
|
Shinya Kitaoka |
12c444 |
setGeometry(values.at(0).toInt(), std::max(30, values.at(1).toInt()), values.at(2).toInt(), values.at(3).toInt());
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Dialog::~Dialog()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::moveEvent(QMoveEvent *e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_name == QString())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QRect r = geometry();
|
|
Toshihiro Shimizu |
890ddd |
m_settings->setValue(m_name, QString::number(r.left()) + " " + QString::number(r.top()) + " " + QString::number(r.width()) + " " + QString::number(r.height()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::resizeEvent(QResizeEvent *e)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Shinya Kitaoka |
822411 |
if (Preferences::instance()->getCurrentLanguage() != "English") {
|
|
Toshihiro Shimizu |
890ddd |
QSize t = this->size();
|
|
Toshihiro Shimizu |
890ddd |
QLabel *s;
|
|
Toshihiro Shimizu |
890ddd |
foreach (s, m_labelList)
|
|
Toshihiro Shimizu |
890ddd |
s->setFixedWidth(t.width() * .35);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_name == QString())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QRect r = geometry();
|
|
Toshihiro Shimizu |
890ddd |
m_settings->setValue(m_name, QString::number(r.left()) + " " + QString::number(r.top()) + " " + QString::number(r.width()) + " " + QString::number(r.height()));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//! By default, QDialogs always reset position/size upon hide events. However,
|
|
Toshihiro Shimizu |
890ddd |
//! we want to prevent such behaviour on Toonz Dialogs - this method is reimplemented
|
|
Toshihiro Shimizu |
890ddd |
//! for this purpose.
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::hideEvent(QHideEvent *event)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
move(pos());
|
|
Toshihiro Shimizu |
890ddd |
resize(size());
|
|
Toshihiro Shimizu |
890ddd |
emit dialogClosed();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Create the new layouts (2 Vertical) for main part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::beginVLayout()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_isMainVLayout = true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_leftVLayout = new QVBoxLayout;
|
|
Toshihiro Shimizu |
890ddd |
m_leftVLayout->setMargin(m_layoutMargin);
|
|
Toshihiro Shimizu |
890ddd |
m_leftVLayout->setSpacing(m_layoutSpacing);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_rightVLayout = new QVBoxLayout;
|
|
Toshihiro Shimizu |
890ddd |
m_rightVLayout->setMargin(m_layoutMargin);
|
|
Toshihiro Shimizu |
890ddd |
m_rightVLayout->setSpacing(m_layoutSpacing);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Add to main part of dialog the Vertical Layouts ,insert them in a orizontal
|
|
Toshihiro Shimizu |
890ddd |
layout to form two column, set Vertical Layouts to 0 .
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::endVLayout()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_leftVLayout || !m_rightVLayout)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
m_isMainVLayout = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QHBoxLayout *layout = new QHBoxLayout;
|
|
Toshihiro Shimizu |
890ddd |
layout->setMargin(m_layoutMargin);
|
|
Toshihiro Shimizu |
890ddd |
layout->setSpacing(m_layoutSpacing);
|
|
Toshihiro Shimizu |
890ddd |
layout->setSizeConstraint(QLayout::SetFixedSize);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
layout->addLayout(m_leftVLayout);
|
|
Toshihiro Shimizu |
890ddd |
layout->setAlignment(m_leftVLayout, Qt::AlignLeft);
|
|
Toshihiro Shimizu |
890ddd |
layout->addLayout(m_rightVLayout);
|
|
Toshihiro Shimizu |
890ddd |
layout->setAlignment(m_rightVLayout, Qt::AlignLeft);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
addLayout(layout);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_leftVLayout = 0;
|
|
Toshihiro Shimizu |
890ddd |
m_rightVLayout = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Create a new Horizontal Layout for main part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::beginHLayout()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_isMainHLayout = true;
|
|
Toshihiro Shimizu |
890ddd |
m_mainHLayout = new QHBoxLayout;
|
|
Toshihiro Shimizu |
890ddd |
m_mainHLayout->setMargin(m_layoutMargin);
|
|
Toshihiro Shimizu |
890ddd |
m_mainHLayout->setSpacing(m_layoutSpacing);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Add to main part of dialog the Horizontal Layout and set it to 0.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::endHLayout()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_isMainHLayout = false;
|
|
Toshihiro Shimizu |
890ddd |
if (!m_mainHLayout)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
addLayout(m_mainHLayout);
|
|
Toshihiro Shimizu |
890ddd |
m_mainHLayout = 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Add a widget \b widget to main part of dialog. If vertical layout is
|
|
Toshihiro Shimizu |
890ddd |
initialized add widget in right column if \b isRight is true, otherwise in
|
|
Toshihiro Shimizu |
890ddd |
left column. \b isRight by default is true.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::addWidget(QWidget *widget, bool isRight)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_isMainVLayout) {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_leftVLayout && m_rightVLayout);
|
|
Toshihiro Shimizu |
890ddd |
QWidget *w = new QWidget();
|
|
Toshihiro Shimizu |
890ddd |
int h = widget->height() + m_layoutSpacing;
|
|
Toshihiro Shimizu |
890ddd |
if (isRight) {
|
|
Toshihiro Shimizu |
890ddd |
m_leftVLayout->addSpacing(h);
|
|
Toshihiro Shimizu |
890ddd |
m_rightVLayout->addWidget(widget);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_leftVLayout->addWidget(widget, 1, Qt::AlignRight);
|
|
Toshihiro Shimizu |
890ddd |
m_rightVLayout->addSpacing(h);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_isMainHLayout) {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_mainHLayout);
|
|
Toshihiro Shimizu |
890ddd |
m_mainHLayout->addWidget(widget);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_topLayout->addWidget(widget);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Add a pair [widget,widget] to main part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
\n If vertical and horizontal layout are not initialized create an horizontal
|
|
Toshihiro Shimizu |
890ddd |
box layout containing the two widgets and recall \b addLayout().
|
|
Toshihiro Shimizu |
890ddd |
If vertical layout is current add the pair to vertical layout of main part,
|
|
Toshihiro Shimizu |
890ddd |
\b firstW on first column and \b secondW on second column.
|
|
Toshihiro Shimizu |
890ddd |
Else if horizontal layout is current create an horizontal box layout containing
|
|
Toshihiro Shimizu |
890ddd |
\b firstW and \b secondW and add it to horizontal layout.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::addWidgets(QWidget *firstW, QWidget *secondW)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_isMainVLayout) {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_leftVLayout && m_rightVLayout);
|
|
Toshihiro Shimizu |
890ddd |
m_leftVLayout->addWidget(firstW);
|
|
Toshihiro Shimizu |
890ddd |
m_rightVLayout->addWidget(secondW);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
QHBoxLayout *pairLayout = new QHBoxLayout;
|
|
Toshihiro Shimizu |
890ddd |
pairLayout->setMargin(m_layoutMargin);
|
|
Toshihiro Shimizu |
890ddd |
pairLayout->setSpacing(m_layoutSpacing);
|
|
Toshihiro Shimizu |
890ddd |
pairLayout->addWidget(firstW);
|
|
Toshihiro Shimizu |
890ddd |
pairLayout->addWidget(secondW);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_isMainHLayout) {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_mainHLayout);
|
|
Toshihiro Shimizu |
890ddd |
m_mainHLayout->addLayout(pairLayout);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
addLayout(pairLayout);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Add a pair [label,widget] to main part of dialog, label is created from
|
|
Toshihiro Shimizu |
890ddd |
\b QString \b nameLabel.
|
|
Toshihiro Shimizu |
890ddd |
\n Recall \b addWidgets(QWdiget* firstW, QWdiget* secondW).
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::addWidget(QString labelName, QWidget *widget)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QLabel *label = new QLabel(labelName);
|
|
Toshihiro Shimizu |
890ddd |
m_labelList.push_back(label);
|
|
Toshihiro Shimizu |
890ddd |
label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
Toshihiro Shimizu |
890ddd |
label->setFixedSize(m_labelWidth, widget->height());
|
|
Toshihiro Shimizu |
890ddd |
addWidgets(label, widget);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Add a layout \b layout to main part of dialog. If vertical layout is
|
|
Toshihiro Shimizu |
890ddd |
initialized add widget in right column if \b isRight is true, otherwise in
|
|
Toshihiro Shimizu |
890ddd |
left column. \b isRight by default is true.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::addLayout(QLayout *layout, bool isRight)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_isMainVLayout) {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_leftVLayout && m_rightVLayout);
|
|
Toshihiro Shimizu |
890ddd |
int h = layout->itemAt(0)->widget()->height() + m_layoutSpacing;
|
|
Toshihiro Shimizu |
890ddd |
if (isRight) {
|
|
Toshihiro Shimizu |
890ddd |
m_leftVLayout->addSpacing(h);
|
|
Toshihiro Shimizu |
890ddd |
m_rightVLayout->addLayout(layout);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
m_leftVLayout->addLayout(layout);
|
|
Toshihiro Shimizu |
890ddd |
m_rightVLayout->addSpacing(h);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_isMainHLayout) {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_mainHLayout);
|
|
Toshihiro Shimizu |
890ddd |
m_mainHLayout->addLayout(layout);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_topLayout->addLayout(layout);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Add a pair [widget,layout] to main part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
\n If vertical and horizontal layout are not initialized create an horizontal
|
|
Toshihiro Shimizu |
890ddd |
box layout containing \b widget and \b layout and recall \b addLayout().
|
|
Toshihiro Shimizu |
890ddd |
If vertical layout is current add the pair [label,layout] to vertical layout
|
|
Toshihiro Shimizu |
890ddd |
of main part, label on first column and layout on second column.
|
|
Toshihiro Shimizu |
890ddd |
Else if horizontal layout is current create an horizontal box layout containing
|
|
Toshihiro Shimizu |
890ddd |
\b widget and \b layout and add it to horizontal layout.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::addWidgetLayout(QWidget *widget, QLayout *layout)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
layout->setMargin(m_layoutMargin);
|
|
Toshihiro Shimizu |
890ddd |
layout->setSpacing(m_layoutSpacing);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_isMainVLayout) {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_leftVLayout && m_rightVLayout);
|
|
Toshihiro Shimizu |
890ddd |
m_leftVLayout->addWidget(widget);
|
|
Toshihiro Shimizu |
890ddd |
m_rightVLayout->addLayout(layout);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QHBoxLayout *pairLayout = new QHBoxLayout;
|
|
Toshihiro Shimizu |
890ddd |
pairLayout->setMargin(m_layoutMargin);
|
|
Toshihiro Shimizu |
890ddd |
pairLayout->setSpacing(m_layoutSpacing);
|
|
Toshihiro Shimizu |
890ddd |
pairLayout->addWidget(widget);
|
|
Toshihiro Shimizu |
890ddd |
pairLayout->addLayout(layout);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_isMainHLayout) {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_mainHLayout);
|
|
Toshihiro Shimizu |
890ddd |
m_mainHLayout->addLayout(pairLayout);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
addLayout(pairLayout);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Add a pair [label,layout] to main part of dialog, label is created from
|
|
Toshihiro Shimizu |
890ddd |
\b QString \b nameLabel.
|
|
Toshihiro Shimizu |
890ddd |
\n Recall \b addWidgetLayout(QWdiget* widget, QWdiget* layout).
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::addLayout(QString labelName, QLayout *layout)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
QLabel *label = new QLabel(labelName);
|
|
Toshihiro Shimizu |
890ddd |
m_labelList.push_back(label);
|
|
Toshihiro Shimizu |
890ddd |
label->setFixedWidth(m_labelWidth);
|
|
Toshihiro Shimizu |
890ddd |
label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
|
Toshihiro Shimizu |
890ddd |
addWidgetLayout(label, layout);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Add a pair [layout,layout] to main part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
\n If vertical and horizontal layout are not initialized create an horizontal
|
|
Toshihiro Shimizu |
890ddd |
box layout containing the two layouts and recall \b addLayout().
|
|
Toshihiro Shimizu |
890ddd |
If vertical layout is current add the pair [layout,layout] to vertical layout
|
|
Toshihiro Shimizu |
890ddd |
of main part, \b firstL on first column and \b secondL on second column.
|
|
Toshihiro Shimizu |
890ddd |
Else if horizontal layout is current create an horizontal box layout containing
|
|
Toshihiro Shimizu |
890ddd |
\b firstL and \b secondL and add it to horizontal layout.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::addLayouts(QLayout *firstL, QLayout *secondL)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
firstL->setMargin(m_layoutMargin);
|
|
Toshihiro Shimizu |
890ddd |
firstL->setSpacing(m_layoutSpacing);
|
|
Toshihiro Shimizu |
890ddd |
secondL->setMargin(m_layoutMargin);
|
|
Toshihiro Shimizu |
890ddd |
secondL->setSpacing(m_layoutSpacing);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_isMainVLayout) {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_leftVLayout && m_rightVLayout);
|
|
Toshihiro Shimizu |
890ddd |
m_leftVLayout->addLayout(firstL);
|
|
Toshihiro Shimizu |
890ddd |
m_rightVLayout->addLayout(secondL);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QHBoxLayout *pairLayout = new QHBoxLayout;
|
|
Toshihiro Shimizu |
890ddd |
pairLayout->setMargin(m_layoutMargin);
|
|
Toshihiro Shimizu |
890ddd |
pairLayout->setSpacing(m_layoutSpacing);
|
|
Toshihiro Shimizu |
890ddd |
pairLayout->addLayout(firstL);
|
|
Toshihiro Shimizu |
890ddd |
pairLayout->addLayout(secondL);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (m_isMainHLayout) {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_mainHLayout);
|
|
Toshihiro Shimizu |
890ddd |
m_mainHLayout->addLayout(pairLayout);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
addLayout(pairLayout);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Add spacing \b spacing to main part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::addSpacing(int spacing)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_isMainVLayout) {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_leftVLayout && m_rightVLayout);
|
|
Toshihiro Shimizu |
890ddd |
m_leftVLayout->addSpacing(spacing);
|
|
Toshihiro Shimizu |
890ddd |
m_rightVLayout->addSpacing(spacing);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_isMainHLayout) {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_mainHLayout);
|
|
Toshihiro Shimizu |
890ddd |
m_mainHLayout->addSpacing(spacing);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_topLayout->addSpacing(spacing);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Add a separator \b Separator to main part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
If vertical layout is initialized add an horizontal separator.
|
|
Toshihiro Shimizu |
890ddd |
If horizontal layout is initialized add a vertical separator.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::addSeparator(QString name)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Separator *separator = new Separator(name);
|
|
Toshihiro Shimizu |
890ddd |
if (m_isMainVLayout) {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_leftVLayout && m_rightVLayout);
|
|
Toshihiro Shimizu |
890ddd |
endVLayout();
|
|
Toshihiro Shimizu |
890ddd |
addWidget(separator);
|
|
Toshihiro Shimizu |
890ddd |
beginVLayout();
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
} else if (m_isMainHLayout) {
|
|
Toshihiro Shimizu |
890ddd |
assert(m_mainHLayout);
|
|
Toshihiro Shimizu |
890ddd |
separator->setOrientation(false);
|
|
Toshihiro Shimizu |
890ddd |
m_mainHLayout->addWidget(separator);
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
addWidget(separator);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Set the alignement of the main layout
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::setAlignment(Qt::Alignment alignment)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_mainFrame->layout()->setAlignment(alignment);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Set to \b spacing spacing of main part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::setTopSpacing(int spacing)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_layoutSpacing = spacing;
|
|
Toshihiro Shimizu |
890ddd |
m_topLayout->setSpacing(spacing);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::setLabelWidth(int labelWidth)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_labelWidth = labelWidth;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Set to \b spacing spacing of all layout inserted in main part of dialog,
|
|
Toshihiro Shimizu |
890ddd |
horizontal layout and vertical layout.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::setLayoutInsertedSpacing(int spacing)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_layoutSpacing = spacing;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Return the spacing of all layout inserted in main part of dialog,
|
|
Toshihiro Shimizu |
890ddd |
horizontal layout and vertical layout.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
int Dialog::getLayoutInsertedSpacing()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_layoutSpacing;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Set to \b margin margin of main part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::setTopMargin(int margin)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_topLayout->setMargin(margin);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Set to \b margin margin of button part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::setButtonBarMargin(int margin)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_buttonLayout->setMargin(margin);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Set to \b spacing spacing of button part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::setButtonBarSpacing(int spacing)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_buttonLayout->setSpacing(spacing);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Add a widget to the button part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::addButtonBarWidget(QWidget *widget)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
widget->setMinimumSize(65, 25);
|
|
Toshihiro Shimizu |
890ddd |
assert(m_hasButton);
|
|
Toshihiro Shimizu |
890ddd |
if (m_hasButton) {
|
|
Toshihiro Shimizu |
890ddd |
m_buttonLayout->addWidget(widget);
|
|
Toshihiro Shimizu |
890ddd |
m_buttonBarWidgets.push_back(widget);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Remove all widget from the button part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::clearButtonBar()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)m_buttonBarWidgets.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
m_buttonLayout->removeWidget(m_buttonBarWidgets[i]);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
m_buttonBarWidgets.clear();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Add two widget to the button part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::addButtonBarWidget(QWidget *first, QWidget *second)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
first->setMinimumSize(65, 25);
|
|
Toshihiro Shimizu |
890ddd |
second->setMinimumSize(65, 25);
|
|
Toshihiro Shimizu |
890ddd |
assert(m_hasButton);
|
|
Toshihiro Shimizu |
890ddd |
if (m_hasButton) {
|
|
Toshihiro Shimizu |
890ddd |
m_buttonLayout->addWidget(first);
|
|
Toshihiro Shimizu |
890ddd |
m_buttonLayout->addWidget(second);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
/*! Add three widget to the button part of dialog.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
void Dialog::addButtonBarWidget(QWidget *first, QWidget *second, QWidget *third)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
first->setMinimumSize(65, 25);
|
|
Toshihiro Shimizu |
890ddd |
second->setMinimumSize(65, 25);
|
|
Toshihiro Shimizu |
890ddd |
third->setMinimumSize(65, 25);
|
|
Toshihiro Shimizu |
890ddd |
assert(m_hasButton);
|
|
Toshihiro Shimizu |
890ddd |
if (m_hasButton) {
|
|
Toshihiro Shimizu |
890ddd |
m_buttonLayout->addWidget(first);
|
|
Toshihiro Shimizu |
890ddd |
m_buttonLayout->addWidget(second);
|
|
Toshihiro Shimizu |
890ddd |
m_buttonLayout->addWidget(third);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
RadioButtonDialog::RadioButtonDialog(const QString &labelText, const QList<qstring> &radioButtonList,</qstring>
|
|
Toshihiro Shimizu |
890ddd |
QWidget *parent, Qt::WindowFlags f)
|
|
Toshihiro Shimizu |
890ddd |
: Dialog(parent, true, true), m_result(1)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setWindowTitle(tr("Toonz"));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
setMinimumSize(20, 20);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
beginVLayout();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QLabel *label = new QLabel(labelText);
|
|
Toshihiro Shimizu |
890ddd |
label->setAlignment(Qt::AlignLeft);
|
|
Toshihiro Shimizu |
890ddd |
label->setFixedHeight(2 * WidgetHeight);
|
|
Toshihiro Shimizu |
890ddd |
addWidget(label);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QButtonGroup *buttonGroup = new QButtonGroup(this);
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < radioButtonList.count(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
QRadioButton *radioButton = new QRadioButton(radioButtonList.at(i));
|
|
Toshihiro Shimizu |
890ddd |
if (i == m_result - 1)
|
|
Toshihiro Shimizu |
890ddd |
radioButton->setChecked(true);
|
|
Toshihiro Shimizu |
890ddd |
radioButton->setFixedHeight(WidgetHeight);
|
|
Toshihiro Shimizu |
890ddd |
buttonGroup->addButton(radioButton);
|
|
Toshihiro Shimizu |
890ddd |
buttonGroup->setId(radioButton, i);
|
|
Toshihiro Shimizu |
890ddd |
addWidget(radioButton);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool ret = connect(buttonGroup, SIGNAL(buttonClicked(int)), SLOT(onButtonClicked(int)));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
endVLayout();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QPushButton *applyButton = new QPushButton(QObject::tr("Apply"));
|
|
Toshihiro Shimizu |
890ddd |
ret = ret && connect(applyButton, SIGNAL(pressed()), this, SLOT(onApply()));
|
|
Toshihiro Shimizu |
890ddd |
QPushButton *cancelButton = new QPushButton(QObject::tr("Cancel"));
|
|
Toshihiro Shimizu |
890ddd |
ret = ret && connect(cancelButton, SIGNAL(pressed()), this, SLOT(onCancel()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
addButtonBarWidget(applyButton, cancelButton);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
assert(ret);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RadioButtonDialog::onButtonClicked(int id)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//Add "1" because "0" is cancel button.
|
|
Toshihiro Shimizu |
890ddd |
m_result = id + 1;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RadioButtonDialog::onCancel()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
done(0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void RadioButtonDialog::onApply()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
done(m_result);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int DVGui::RadioButtonMsgBox(MsgType type, const QString &labelText,
|
|
Toshihiro Shimizu |
890ddd |
const QList<qstring> &radioButtonList, QWidget *parent)</qstring>
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
RadioButtonDialog *dialog = new RadioButtonDialog(labelText, radioButtonList, parent);
|
|
Shinya Kitaoka |
eabf18 |
QString msgBoxTitle = getMsgBoxTitle(DVGui::WARNING);
|
|
Toshihiro Shimizu |
890ddd |
dialog->setWindowTitle(msgBoxTitle);
|
|
Toshihiro Shimizu |
890ddd |
return dialog->exec();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
ProgressDialog::ProgressDialog(const QString &labelText, const QString &cancelButtonText,
|
|
Toshihiro Shimizu |
890ddd |
int minimum, int maximum, QWidget *parent, Qt::WindowFlags f)
|
|
Toshihiro Shimizu |
890ddd |
: Dialog(parent, true, true), m_isCanceled(false)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
setWindowTitle(tr("Toonz"));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
setMinimumSize(20, 20);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
beginVLayout();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_label = new QLabel(this);
|
|
Toshihiro Shimizu |
890ddd |
m_label->setText(labelText);
|
|
Toshihiro Shimizu |
890ddd |
addWidget(m_label);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_progressBar = new QProgressBar(this);
|
|
Toshihiro Shimizu |
890ddd |
m_progressBar->setRange(minimum, maximum);
|
|
Toshihiro Shimizu |
890ddd |
m_progressBar->setMinimumWidth(250);
|
|
Toshihiro Shimizu |
890ddd |
addWidget(m_progressBar);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
endVLayout();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!cancelButtonText.isEmpty())
|
|
Toshihiro Shimizu |
890ddd |
setCancelButton(new QPushButton(cancelButtonText));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ProgressDialog::setLabelText(const QString &text)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_label->setText(text);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ProgressDialog::setCancelButton(QPushButton *cancelButton)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_cancelButton = cancelButton;
|
|
Toshihiro Shimizu |
890ddd |
bool ret = connect(cancelButton, SIGNAL(pressed()), this, SLOT(onCancel()));
|
|
Toshihiro Shimizu |
890ddd |
ret = ret && connect(cancelButton, SIGNAL(pressed()), this, SIGNAL(canceled()));
|
|
Toshihiro Shimizu |
890ddd |
assert(ret);
|
|
Toshihiro Shimizu |
890ddd |
addButtonBarWidget(m_cancelButton);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int ProgressDialog::maximum()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_progressBar->maximum();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ProgressDialog::setMaximum(int maximum)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_progressBar->setMaximum(maximum);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int ProgressDialog::minimum()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_progressBar->minimum();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ProgressDialog::setMinimum(int minimum)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_progressBar->setMinimum(minimum);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int ProgressDialog::value()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_progressBar->value();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ProgressDialog::setValue(int progress)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_progressBar->setValue(progress);
|
|
Toshihiro Shimizu |
890ddd |
if (isModal())
|
|
Toshihiro Shimizu |
890ddd |
qApp->processEvents();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ProgressDialog::reset()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_progressBar->reset();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool ProgressDialog::wasCanceled() const
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return m_isCanceled;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void ProgressDialog::onCancel()
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_isCanceled = true;
|
|
Toshihiro Shimizu |
890ddd |
reset();
|
|
Toshihiro Shimizu |
890ddd |
hide();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int DVGui::MsgBox(MsgType type,
|
|
Toshihiro Shimizu |
890ddd |
const QString &text,
|
|
Toshihiro Shimizu |
890ddd |
const std::vector<qstring> &buttons,</qstring>
|
|
Toshihiro Shimizu |
890ddd |
int defaultButtonIndex,
|
|
Toshihiro Shimizu |
890ddd |
QWidget *parent)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Dialog dialog(parent, true);
|
|
Toshihiro Shimizu |
890ddd |
dialog.setWindowFlags(dialog.windowFlags() | Qt::WindowStaysOnTopHint);
|
|
Toshihiro Shimizu |
890ddd |
dialog.setAlignment(Qt::AlignLeft);
|
|
Toshihiro Shimizu |
890ddd |
QString msgBoxTitle = getMsgBoxTitle(type);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
dialog.setWindowTitle(msgBoxTitle);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QLabel *mainTextLabel = new QLabel(text, &dialog);
|
|
Toshihiro Shimizu |
890ddd |
QPixmap iconPixmap = getMsgBoxPixmap(type);
|
|
Toshihiro Shimizu |
890ddd |
if (!iconPixmap.isNull()) {
|
|
Toshihiro Shimizu |
890ddd |
QLabel *iconLabel = new QLabel(&dialog);
|
|
Toshihiro Shimizu |
890ddd |
iconLabel->setPixmap(iconPixmap);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QHBoxLayout *mainLayout = new QHBoxLayout;
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->addWidget(iconLabel);
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->addSpacing(16);
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->addWidget(mainTextLabel);
|
|
Toshihiro Shimizu |
890ddd |
dialog.addLayout(mainLayout);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
dialog.addWidget(mainTextLabel);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// ButtonGroup: is used only to retrieve the clicked button
|
|
Toshihiro Shimizu |
890ddd |
QButtonGroup *buttonGroup = new QButtonGroup(&dialog);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)buttons.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
QPushButton *button = new QPushButton(buttons[i], &dialog);
|
|
Toshihiro Shimizu |
890ddd |
if (defaultButtonIndex == i)
|
|
Toshihiro Shimizu |
890ddd |
button->setDefault(true);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
button->setDefault(false);
|
|
Toshihiro Shimizu |
890ddd |
dialog.addButtonBarWidget(button);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
buttonGroup->addButton(button, i + 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QObject::connect(buttonGroup, SIGNAL(buttonPressed(int)), &dialog, SLOT(done(int)));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
dialog.raise();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return dialog.exec();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DVGui::MsgBoxInPopup(MsgType type, const QString &text)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
// this function must be called by the main thread only
|
|
Toshihiro Shimizu |
890ddd |
// (only the main thread should access directly the GUI)
|
|
Toshihiro Shimizu |
890ddd |
// (note: working thread can and should call MsgBox(type,text) instead; see tmsgcore.h)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Q_ASSERT(QApplication::instance()->thread() == QThread::currentThread());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// a working thread can trigger a call to this function (by the main thread) also when a popup is already open
|
|
Toshihiro Shimizu |
890ddd |
// therefore we need a messageQueue
|
|
Toshihiro Shimizu |
890ddd |
// note: no mutex are needed because only the main thread call this function
|
|
Toshihiro Shimizu |
890ddd |
static QList<qpair<msgtype, qstring="">> messageQueue;</qpair<msgtype,>
|
|
Toshihiro Shimizu |
890ddd |
static bool popupIsOpen = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
messageQueue.append(qMakePair(type, text));
|
|
Toshihiro Shimizu |
890ddd |
if (popupIsOpen)
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
popupIsOpen = true;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Dialog dialog(0, true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
dialog.setWindowFlags(dialog.windowFlags() | Qt::WindowStaysOnTopHint);
|
|
Toshihiro Shimizu |
890ddd |
dialog.setAlignment(Qt::AlignLeft);
|
|
Toshihiro Shimizu |
890ddd |
QLabel *mainTextLabel = new QLabel("", &dialog);
|
|
Toshihiro Shimizu |
890ddd |
mainTextLabel->setMinimumWidth(400);
|
|
Toshihiro Shimizu |
890ddd |
QLabel *iconLabel = new QLabel(&dialog);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QHBoxLayout *mainLayout = new QHBoxLayout;
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->addWidget(iconLabel);
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->addStretch();
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->addWidget(mainTextLabel);
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->addStretch();
|
|
Toshihiro Shimizu |
890ddd |
dialog.addLayout(mainLayout);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// ButtonGroup: is used only to retrieve the clicked button
|
|
Toshihiro Shimizu |
890ddd |
QButtonGroup *buttonGroup = new QButtonGroup(&dialog);
|
|
Toshihiro Shimizu |
890ddd |
QPushButton *button = new QPushButton(QPushButton::tr("OK"), &dialog);
|
|
Toshihiro Shimizu |
890ddd |
button->setDefault(true);
|
|
Toshihiro Shimizu |
890ddd |
dialog.addButtonBarWidget(button);
|
|
Toshihiro Shimizu |
890ddd |
buttonGroup->addButton(button, 1);
|
|
Toshihiro Shimizu |
890ddd |
QObject::connect(buttonGroup, SIGNAL(buttonPressed(int)), &dialog, SLOT(done(int)));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
while (!messageQueue.empty()) {
|
|
Toshihiro Shimizu |
890ddd |
MsgType type1 = messageQueue.first().first;
|
|
Toshihiro Shimizu |
890ddd |
QString text1 = messageQueue.first().second;
|
|
Toshihiro Shimizu |
890ddd |
messageQueue.pop_front();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
mainTextLabel->setText(text1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString msgBoxTitle = getMsgBoxTitle(type1);
|
|
Toshihiro Shimizu |
890ddd |
dialog.setWindowTitle(msgBoxTitle);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QPixmap iconPixmap = getMsgBoxPixmap(type1);
|
|
Toshihiro Shimizu |
890ddd |
if (!iconPixmap.isNull()) {
|
|
Toshihiro Shimizu |
890ddd |
iconLabel->setPixmap(iconPixmap);
|
|
Toshihiro Shimizu |
890ddd |
iconLabel->setVisible(true);
|
|
Toshihiro Shimizu |
890ddd |
} else {
|
|
Toshihiro Shimizu |
890ddd |
iconLabel->setVisible(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
dialog.raise();
|
|
Toshihiro Shimizu |
890ddd |
dialog.exec();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
} // loop: open the next dialog in the queue
|
|
Toshihiro Shimizu |
890ddd |
popupIsOpen = false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int DVGui::MsgBox(const QString &text,
|
|
Toshihiro Shimizu |
890ddd |
const QString &button1Text,
|
|
Toshihiro Shimizu |
890ddd |
const QString &button2Text,
|
|
Toshihiro Shimizu |
890ddd |
const QString &button3Text,
|
|
Toshihiro Shimizu |
890ddd |
int defaultButtonIndex,
|
|
Toshihiro Shimizu |
890ddd |
QWidget *parent)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Dialog dialog(parent, true);
|
|
Toshihiro Shimizu |
890ddd |
dialog.setWindowFlags(dialog.windowFlags() | Qt::WindowStaysOnTopHint);
|
|
Toshihiro Shimizu |
890ddd |
dialog.setAlignment(Qt::AlignLeft);
|
|
Toshihiro Shimizu |
890ddd |
QString msgBoxTitle = getMsgBoxTitle(QUESTION);
|
|
Toshihiro Shimizu |
890ddd |
dialog.setWindowTitle(msgBoxTitle);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QLabel *mainTextLabel = new QLabel(text, &dialog);
|
|
Toshihiro Shimizu |
890ddd |
QPixmap iconPixmap = getMsgBoxPixmap(QUESTION);
|
|
Toshihiro Shimizu |
890ddd |
if (!iconPixmap.isNull()) {
|
|
Toshihiro Shimizu |
890ddd |
QLabel *iconLabel = new QLabel(&dialog);
|
|
Toshihiro Shimizu |
890ddd |
iconLabel->setPixmap(iconPixmap);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QHBoxLayout *mainLayout = new QHBoxLayout;
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->addWidget(iconLabel);
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->addSpacing(16);
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->addWidget(mainTextLabel);
|
|
Toshihiro Shimizu |
890ddd |
dialog.addLayout(mainLayout);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
dialog.addWidget(mainTextLabel);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// ButtonGroup: is used only to retrieve the clicked button
|
|
Toshihiro Shimizu |
890ddd |
QButtonGroup *buttonGroup = new QButtonGroup(&dialog);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QPushButton *button1 = new QPushButton(button1Text, &dialog);
|
|
Toshihiro Shimizu |
890ddd |
button1->setDefault(false);
|
|
Campbell Barton |
14c02e |
if (defaultButtonIndex == 0)
|
|
Toshihiro Shimizu |
890ddd |
button1->setDefault(true);
|
|
Toshihiro Shimizu |
890ddd |
dialog.addButtonBarWidget(button1);
|
|
Toshihiro Shimizu |
890ddd |
buttonGroup->addButton(button1, 1);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QPushButton *button2 = new QPushButton(button2Text, &dialog);
|
|
Toshihiro Shimizu |
890ddd |
button2->setDefault(false);
|
|
Campbell Barton |
14c02e |
if (defaultButtonIndex == 1)
|
|
Toshihiro Shimizu |
890ddd |
button2->setDefault(true);
|
|
Toshihiro Shimizu |
890ddd |
dialog.addButtonBarWidget(button2);
|
|
Toshihiro Shimizu |
890ddd |
buttonGroup->addButton(button2, 2);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QPushButton *button3 = new QPushButton(button3Text, &dialog);
|
|
Toshihiro Shimizu |
890ddd |
button3->setDefault(false);
|
|
Campbell Barton |
14c02e |
if (defaultButtonIndex == 2)
|
|
Toshihiro Shimizu |
890ddd |
button3->setDefault(true);
|
|
Toshihiro Shimizu |
890ddd |
dialog.addButtonBarWidget(button3);
|
|
Toshihiro Shimizu |
890ddd |
buttonGroup->addButton(button3, 3);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QObject::connect(buttonGroup, SIGNAL(buttonPressed(int)), &dialog, SLOT(done(int)));
|
|
Toshihiro Shimizu |
890ddd |
dialog.raise();
|
|
Toshihiro Shimizu |
890ddd |
return dialog.exec();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int DVGui::MsgBox(const QString &text,
|
|
Toshihiro Shimizu |
890ddd |
const QString &button1,
|
|
Toshihiro Shimizu |
890ddd |
const QString &button2,
|
|
Toshihiro Shimizu |
890ddd |
int defaultButtonIndex,
|
|
Toshihiro Shimizu |
890ddd |
QWidget *parent)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Dialog dialog(parent, true);
|
|
Toshihiro Shimizu |
890ddd |
dialog.setWindowFlags(dialog.windowFlags() | Qt::WindowStaysOnTopHint);
|
|
Toshihiro Shimizu |
890ddd |
std::vector<qstring> buttons;</qstring>
|
|
Toshihiro Shimizu |
890ddd |
buttons.push_back(button1);
|
|
Toshihiro Shimizu |
890ddd |
buttons.push_back(button2);
|
|
Shinya Kitaoka |
eabf18 |
return DVGui::MsgBox(DVGui::QUESTION, text, buttons, defaultButtonIndex, parent);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Dialog *DVGui::createMsgBox(MsgType type,
|
|
Toshihiro Shimizu |
890ddd |
const QString &text,
|
|
Toshihiro Shimizu |
890ddd |
const QStringList &buttons,
|
|
Toshihiro Shimizu |
890ddd |
int defaultButtonIndex,
|
|
Toshihiro Shimizu |
890ddd |
QWidget *parent)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Dialog *dialog = new Dialog(parent, true);
|
|
Toshihiro Shimizu |
890ddd |
dialog->setWindowFlags(dialog->windowFlags() | Qt::WindowStaysOnTopHint);
|
|
Toshihiro Shimizu |
890ddd |
dialog->setAlignment(Qt::AlignLeft);
|
|
Toshihiro Shimizu |
890ddd |
QString msgBoxTitle = getMsgBoxTitle(type);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
dialog->setWindowTitle(msgBoxTitle);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QLabel *mainTextLabel = new QLabel(text, dialog);
|
|
Toshihiro Shimizu |
890ddd |
mainTextLabel->setObjectName("Label");
|
|
Toshihiro Shimizu |
890ddd |
QPixmap iconPixmap = getMsgBoxPixmap(type);
|
|
Toshihiro Shimizu |
890ddd |
if (!iconPixmap.isNull()) {
|
|
Toshihiro Shimizu |
890ddd |
QLabel *iconLabel = new QLabel(dialog);
|
|
Toshihiro Shimizu |
890ddd |
iconLabel->setPixmap(iconPixmap);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QHBoxLayout *mainLayout = new QHBoxLayout;
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->addWidget(iconLabel);
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->addSpacing(16);
|
|
Toshihiro Shimizu |
890ddd |
mainLayout->addWidget(mainTextLabel);
|
|
Toshihiro Shimizu |
890ddd |
dialog->addLayout(mainLayout);
|
|
Toshihiro Shimizu |
890ddd |
} else
|
|
Toshihiro Shimizu |
890ddd |
dialog->addWidget(mainTextLabel);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// ButtonGroup: is used only to retrieve the clicked button
|
|
Toshihiro Shimizu |
890ddd |
QButtonGroup *buttonGroup = new QButtonGroup(dialog);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
for (int i = 0; i < (int)buttons.size(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
QPushButton *button = new QPushButton(buttons[i], dialog);
|
|
Toshihiro Shimizu |
890ddd |
if (defaultButtonIndex == i)
|
|
Toshihiro Shimizu |
890ddd |
button->setDefault(true);
|
|
Toshihiro Shimizu |
890ddd |
else
|
|
Toshihiro Shimizu |
890ddd |
button->setDefault(false);
|
|
Toshihiro Shimizu |
890ddd |
dialog->addButtonBarWidget(button);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
buttonGroup->addButton(button, i + 1);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QObject::connect(buttonGroup, SIGNAL(buttonPressed(int)), dialog, SLOT(done(int)));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return dialog;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString DVGui::getText(const QString &title, const QString &labelText,
|
|
Toshihiro Shimizu |
890ddd |
const QString &text, bool *ok)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Dialog dialog(0, true);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
dialog.setWindowTitle(title);
|
|
Toshihiro Shimizu |
890ddd |
dialog.setWindowFlags(Qt::WindowStaysOnTopHint |
|
|
Toshihiro Shimizu |
890ddd |
Qt::WindowTitleHint |
|
|
Toshihiro Shimizu |
890ddd |
Qt::CustomizeWindowHint);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QVBoxLayout *layout = new QVBoxLayout(&dialog);
|
|
Toshihiro Shimizu |
890ddd |
dialog.addLayout(layout);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QLabel *label = new QLabel(labelText, &dialog);
|
|
Toshihiro Shimizu |
890ddd |
layout->addWidget(label);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
LineEdit *nameFld = new LineEdit(text, &dialog);
|
|
Toshihiro Shimizu |
890ddd |
layout->addWidget(nameFld);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QPushButton *okBtn = new QPushButton(dialog.tr("OK"), &dialog);
|
|
Toshihiro Shimizu |
890ddd |
okBtn->setDefault(true);
|
|
Toshihiro Shimizu |
890ddd |
QPushButton *cancelBtn = new QPushButton(dialog.tr("Cancel"), &dialog);
|
|
Toshihiro Shimizu |
890ddd |
QObject::connect(okBtn, SIGNAL(clicked()), &dialog, SLOT(accept()));
|
|
Toshihiro Shimizu |
890ddd |
QObject::connect(cancelBtn, SIGNAL(clicked()), &dialog, SLOT(reject()));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
dialog.addButtonBarWidget(okBtn, cancelBtn);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int ret = dialog.exec();
|
|
Toshihiro Shimizu |
890ddd |
if (ok)
|
|
Toshihiro Shimizu |
890ddd |
*ok = (ret == QDialog::Accepted);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return nameFld->text();
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
bool isStyleIdInPalette(int styleId, const TPalette *palette)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (palette->getStyleCount() == 0)
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
int i;
|
|
Toshihiro Shimizu |
890ddd |
for (i = 0; i < palette->getPageCount(); i++) {
|
|
Toshihiro Shimizu |
890ddd |
const TPalette::Page *page = palette->getPage(i);
|
|
Toshihiro Shimizu |
890ddd |
if (!page)
|
|
Toshihiro Shimizu |
890ddd |
return false; //La pagina dovrebbe esserci sempre
|
|
Toshihiro Shimizu |
890ddd |
int j;
|
|
Toshihiro Shimizu |
890ddd |
for (j = 0; j < page->getStyleCount(); j++)
|
|
Toshihiro Shimizu |
890ddd |
if (page->getStyleId(j) == styleId)
|
|
Toshihiro Shimizu |
890ddd |
return true;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int DVGui::eraseStylesInDemand(TPalette *palette, const TXsheetHandle *xsheetHandle, TPalette *newPalette)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
//Verifico se gli stili della paletta sono usati : eraseStylesInDemand()
|
|
Shinya Kitaoka |
3bfa54 |
std::vector<int> styleIds;</int>
|
|
Toshihiro Shimizu |
890ddd |
int h;
|
|
Toshihiro Shimizu |
890ddd |
for (h = 0; h < palette->getPageCount(); h++) {
|
|
Toshihiro Shimizu |
890ddd |
TPalette::Page *page = palette->getPage(h);
|
|
Toshihiro Shimizu |
890ddd |
if (!page)
|
|
Toshihiro Shimizu |
890ddd |
continue; //La pagina dovrebbe esserci sempre
|
|
Toshihiro Shimizu |
890ddd |
int k;
|
|
Toshihiro Shimizu |
890ddd |
for (k = 0; k < page->getStyleCount(); k++) {
|
|
Toshihiro Shimizu |
890ddd |
int styleId = page->getStyleId(k);
|
|
Toshihiro Shimizu |
890ddd |
bool isStyleIdInNewPalette = (!newPalette) ? false : isStyleIdInPalette(styleId, newPalette);
|
|
Toshihiro Shimizu |
890ddd |
if (styleId > 0 && !isStyleIdInNewPalette)
|
|
Toshihiro Shimizu |
890ddd |
styleIds.push_back(styleId);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return eraseStylesInDemand(palette, styleIds, xsheetHandle);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int DVGui::eraseStylesInDemand(TPalette *palette, std::vector<int> styleIds,</int>
|
|
Toshihiro Shimizu |
890ddd |
const TXsheetHandle *xsheetHandle)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
struct locals {
|
|
Toshihiro Shimizu |
890ddd |
static bool isRasterLevel(const TXshSimpleLevel *level)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
return level->getType() == TZP_XSHLEVEL || level->getType() == OVL_XSHLEVEL;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}; // locals
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Search xsheet levels attached to the palette
|
|
Toshihiro Shimizu |
890ddd |
std::set<txshsimplelevel *=""> levels;</txshsimplelevel>
|
|
Toshihiro Shimizu |
890ddd |
int row, column;
|
|
Toshihiro Shimizu |
890ddd |
findPaletteLevels(levels, row, column, palette, xsheetHandle->getXsheet());
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool someStyleIsUsed = !levels.empty() || styleIds.empty(); // I guess this is wrong... but I'm not touching it
|
|
Toshihiro Shimizu |
890ddd |
if (someStyleIsUsed)
|
|
Toshihiro Shimizu |
890ddd |
someStyleIsUsed = areStylesUsed(levels, styleIds);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
if (!someStyleIsUsed)
|
|
Toshihiro Shimizu |
890ddd |
return 1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// At least a style is selected and present in some level - ask user if and how styles
|
|
Toshihiro Shimizu |
890ddd |
// should be deleted
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QString question = QObject::tr("Styles you are going to delete are used to paint lines and areas in the animation level.\n") + QObject::tr("How do you want to proceed?");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int ret = DVGui::MsgBox(question, QObject::tr("Delete Styles Only"),
|
|
Toshihiro Shimizu |
890ddd |
QObject::tr("Delete Styles, Lines and Areas"),
|
|
Toshihiro Shimizu |
890ddd |
QObject::tr("Cancel"), 0);
|
|
Toshihiro Shimizu |
890ddd |
if (ret != 2)
|
|
Toshihiro Shimizu |
890ddd |
return (ret == 0 || ret == 3) ? 0 : 1;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
// Inform the user that case 2 will not produce an undo if a raster-based level is detected
|
|
Toshihiro Shimizu |
890ddd |
if (boost::algorithm::any_of(levels, locals::isRasterLevel)) {
|
|
Toshihiro Shimizu |
890ddd |
std::vector<qstring> buttons(2);</qstring>
|
|
Toshihiro Shimizu |
890ddd |
buttons[0] = QObject::tr("Ok"), buttons[1] = QObject::tr("Cancel");
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
eabf18 |
if (DVGui::MsgBox(DVGui::WARNING,
|
|
Shinya Kitaoka |
eabf18 |
QObject::tr("Deletion of Lines and Areas from raster-based levels is not undoable.\n""Are you sure?"),
|
|
Toshihiro Shimizu |
890ddd |
buttons) != 1)
|
|
Toshihiro Shimizu |
890ddd |
return 0;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QApplication::setOverrideCursor(Qt::WaitCursor);
|
|
Toshihiro Shimizu |
890ddd |
PaletteCmd::eraseStyles(levels, styleIds);
|
|
Toshihiro Shimizu |
890ddd |
QApplication::restoreOverrideCursor();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
return (assert(ret == 2), ret); // return 2 ? :D
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void DVGui::setDialogTitle(const QString &dialogTitle)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
DialogTitle = dialogTitle;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|