Commit 609163c1 authored by con's avatar con

Make it possible to react on close button of info bar, and use it for

Qt Quick Designer.
parent 811da6e3
......@@ -1770,9 +1770,10 @@ void EditorManager::revertToSaved()
void EditorManager::showEditorInfoBar(const QString &id,
const QString &infoText,
const QString &buttonText,
QObject *object, const char *member)
QObject *object, const char *buttonPressMember,
const char *cancelButtonPressMember)
{
currentEditorView()->showEditorInfoBar(id, infoText, buttonText, object, member);
currentEditorView()->showEditorInfoBar(id, infoText, buttonText, object, buttonPressMember, cancelButtonPressMember);
}
......
......@@ -166,7 +166,8 @@ public:
void showEditorInfoBar(const QString &id,
const QString &infoText,
const QString &buttonText = QString(),
QObject *object = 0, const char *member = 0);
QObject *object = 0, const char *buttonPressMember = 0,
const char *cancelButtonPressMember = 0);
void hideEditorInfoBar(const QString &id);
......
......@@ -112,13 +112,12 @@ EditorView::EditorView(QWidget *parent) :
m_infoWidgetButton->setText(tr("Placeholder"));
hbox->addWidget(m_infoWidgetButton);
QToolButton *closeButton = new QToolButton;
closeButton->setAutoRaise(true);
closeButton->setIcon(QIcon(":/core/images/clear.png"));
closeButton->setToolTip(tr("Close"));
connect(closeButton, SIGNAL(clicked()), m_infoWidget, SLOT(hide()));
m_infoWidgetCloseButton = new QToolButton;
m_infoWidgetCloseButton->setAutoRaise(true);
m_infoWidgetCloseButton->setIcon(QIcon(":/core/images/clear.png"));
m_infoWidgetCloseButton->setToolTip(tr("Close"));
hbox->addWidget(closeButton);
hbox->addWidget(m_infoWidgetCloseButton);
m_infoWidget->setVisible(false);
tl->addWidget(m_infoWidget);
......@@ -173,14 +172,22 @@ void EditorView::closeView()
void EditorView::showEditorInfoBar(const QString &id,
const QString &infoText,
const QString &buttonText,
QObject *object, const char *member)
QObject *object, const char *buttonPressMember,
const char *cancelButtonPressMember)
{
m_infoWidgetId = id;
m_infoWidgetLabel->setText(infoText);
m_infoWidgetButton->setText(buttonText);
m_infoWidgetButton->disconnect();
if (object && member)
connect(m_infoWidgetButton, SIGNAL(clicked()), object, member);
if (object && buttonPressMember)
connect(m_infoWidgetButton, SIGNAL(clicked()), object, buttonPressMember);
m_infoWidgetCloseButton->disconnect();
if (object && cancelButtonPressMember)
connect(m_infoWidgetCloseButton, SIGNAL(clicked()), object, cancelButtonPressMember);
connect(m_infoWidgetCloseButton, SIGNAL(clicked()), m_infoWidget, SLOT(hide()));
m_infoWidget->setVisible(true);
m_editorForInfoWidget = currentEditor();
}
......
......@@ -84,7 +84,8 @@ public:
void showEditorInfoBar(const QString &id,
const QString &infoText,
const QString &buttonText,
QObject *object, const char *member);
QObject *object, const char *buttonPressMember,
const char *cancelButtonPressMember = 0);
void hideEditorInfoBar(const QString &id);
void showEditorStatusBar(const QString &id,
......@@ -109,6 +110,7 @@ private:
QFrame *m_infoWidget;
QLabel *m_infoWidgetLabel;
QToolButton *m_infoWidgetButton;
QToolButton *m_infoWidgetCloseButton;
IEditor *m_editorForInfoWidget;
QString m_statusWidgetId;
QFrame *m_statusHLine;
......
......@@ -139,7 +139,9 @@ void QmlJSEditorFactory::updateEditorInfoBar(Core::IEditor *editor)
if (qobject_cast<QmlJSEditorEditable *>(editor)) {
Core::EditorManager::instance()->showEditorInfoBar(QMLDESIGNER_INFO_BAR,
tr("Do you want to enable the experimental Qt Quick Designer?"),
tr("Enable Qt Quick Designer"), this, SLOT(activateQmlDesigner()));
tr("Enable Qt Quick Designer"), this,
SLOT(activateQmlDesigner()),
SLOT(neverAskAgainAboutQmlDesigner()));
} else {
Core::EditorManager::instance()->hideEditorInfoBar(QMLDESIGNER_INFO_BAR);
}
......@@ -161,7 +163,6 @@ void QmlJSEditorFactory::activateQmlDesigner()
"To disable Qt Quick Designer again, visit the menu '%1' and disable 'QmlDesigner'.").arg(menu));
message.setIcon(QMessageBox::Question);
QPushButton *enable = message.addButton(tr("Enable Qt Quick Designer"), QMessageBox::AcceptRole);
QPushButton *dontNag = message.addButton(tr("Never ask me again"), QMessageBox::ActionRole);
message.addButton(tr("Cancel"), QMessageBox::RejectRole);
message.exec();
if (message.clickedButton() == enable) {
......@@ -178,13 +179,15 @@ void QmlJSEditorFactory::activateQmlDesigner()
return;
}
}
} else if (message.clickedButton() == dontNag) {
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(QLatin1String(KEY_QMLGROUP));
settings->setValue(QLatin1String(KEY_NAGABOUTDESIGNER), false);
settings->endGroup();
disconnect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(updateEditorInfoBar(Core::IEditor*)));
Core::EditorManager::instance()->hideEditorInfoBar(QMLDESIGNER_INFO_BAR);
}
}
void QmlJSEditorFactory::neverAskAgainAboutQmlDesigner()
{
QSettings *settings = Core::ICore::instance()->settings();
settings->beginGroup(QLatin1String(KEY_QMLGROUP));
settings->setValue(QLatin1String(KEY_NAGABOUTDESIGNER), false);
settings->endGroup();
disconnect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(updateEditorInfoBar(Core::IEditor*)));
}
......@@ -60,6 +60,7 @@ public:
private slots:
void activateQmlDesigner();
void neverAskAgainAboutQmlDesigner();
void updateEditorInfoBar(Core::IEditor *editor);
private:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment