forked from qt-creator/qt-creator
Make it possible to react on close button of info bar, and use it for
Qt Quick Designer.
This commit is contained in:
@@ -1770,9 +1770,10 @@ void EditorManager::revertToSaved()
|
|||||||
void EditorManager::showEditorInfoBar(const QString &id,
|
void EditorManager::showEditorInfoBar(const QString &id,
|
||||||
const QString &infoText,
|
const QString &infoText,
|
||||||
const QString &buttonText,
|
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,
|
void showEditorInfoBar(const QString &id,
|
||||||
const QString &infoText,
|
const QString &infoText,
|
||||||
const QString &buttonText = QString(),
|
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);
|
void hideEditorInfoBar(const QString &id);
|
||||||
|
|
||||||
|
|||||||
@@ -112,13 +112,12 @@ EditorView::EditorView(QWidget *parent) :
|
|||||||
m_infoWidgetButton->setText(tr("Placeholder"));
|
m_infoWidgetButton->setText(tr("Placeholder"));
|
||||||
hbox->addWidget(m_infoWidgetButton);
|
hbox->addWidget(m_infoWidgetButton);
|
||||||
|
|
||||||
QToolButton *closeButton = new QToolButton;
|
m_infoWidgetCloseButton = new QToolButton;
|
||||||
closeButton->setAutoRaise(true);
|
m_infoWidgetCloseButton->setAutoRaise(true);
|
||||||
closeButton->setIcon(QIcon(":/core/images/clear.png"));
|
m_infoWidgetCloseButton->setIcon(QIcon(":/core/images/clear.png"));
|
||||||
closeButton->setToolTip(tr("Close"));
|
m_infoWidgetCloseButton->setToolTip(tr("Close"));
|
||||||
connect(closeButton, SIGNAL(clicked()), m_infoWidget, SLOT(hide()));
|
|
||||||
|
|
||||||
hbox->addWidget(closeButton);
|
hbox->addWidget(m_infoWidgetCloseButton);
|
||||||
|
|
||||||
m_infoWidget->setVisible(false);
|
m_infoWidget->setVisible(false);
|
||||||
tl->addWidget(m_infoWidget);
|
tl->addWidget(m_infoWidget);
|
||||||
@@ -173,14 +172,22 @@ void EditorView::closeView()
|
|||||||
void EditorView::showEditorInfoBar(const QString &id,
|
void EditorView::showEditorInfoBar(const QString &id,
|
||||||
const QString &infoText,
|
const QString &infoText,
|
||||||
const QString &buttonText,
|
const QString &buttonText,
|
||||||
QObject *object, const char *member)
|
QObject *object, const char *buttonPressMember,
|
||||||
|
const char *cancelButtonPressMember)
|
||||||
{
|
{
|
||||||
m_infoWidgetId = id;
|
m_infoWidgetId = id;
|
||||||
m_infoWidgetLabel->setText(infoText);
|
m_infoWidgetLabel->setText(infoText);
|
||||||
m_infoWidgetButton->setText(buttonText);
|
m_infoWidgetButton->setText(buttonText);
|
||||||
|
|
||||||
m_infoWidgetButton->disconnect();
|
m_infoWidgetButton->disconnect();
|
||||||
if (object && member)
|
if (object && buttonPressMember)
|
||||||
connect(m_infoWidgetButton, SIGNAL(clicked()), object, member);
|
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_infoWidget->setVisible(true);
|
||||||
m_editorForInfoWidget = currentEditor();
|
m_editorForInfoWidget = currentEditor();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ public:
|
|||||||
void showEditorInfoBar(const QString &id,
|
void showEditorInfoBar(const QString &id,
|
||||||
const QString &infoText,
|
const QString &infoText,
|
||||||
const QString &buttonText,
|
const QString &buttonText,
|
||||||
QObject *object, const char *member);
|
QObject *object, const char *buttonPressMember,
|
||||||
|
const char *cancelButtonPressMember = 0);
|
||||||
void hideEditorInfoBar(const QString &id);
|
void hideEditorInfoBar(const QString &id);
|
||||||
|
|
||||||
void showEditorStatusBar(const QString &id,
|
void showEditorStatusBar(const QString &id,
|
||||||
@@ -109,6 +110,7 @@ private:
|
|||||||
QFrame *m_infoWidget;
|
QFrame *m_infoWidget;
|
||||||
QLabel *m_infoWidgetLabel;
|
QLabel *m_infoWidgetLabel;
|
||||||
QToolButton *m_infoWidgetButton;
|
QToolButton *m_infoWidgetButton;
|
||||||
|
QToolButton *m_infoWidgetCloseButton;
|
||||||
IEditor *m_editorForInfoWidget;
|
IEditor *m_editorForInfoWidget;
|
||||||
QString m_statusWidgetId;
|
QString m_statusWidgetId;
|
||||||
QFrame *m_statusHLine;
|
QFrame *m_statusHLine;
|
||||||
|
|||||||
@@ -139,7 +139,9 @@ void QmlJSEditorFactory::updateEditorInfoBar(Core::IEditor *editor)
|
|||||||
if (qobject_cast<QmlJSEditorEditable *>(editor)) {
|
if (qobject_cast<QmlJSEditorEditable *>(editor)) {
|
||||||
Core::EditorManager::instance()->showEditorInfoBar(QMLDESIGNER_INFO_BAR,
|
Core::EditorManager::instance()->showEditorInfoBar(QMLDESIGNER_INFO_BAR,
|
||||||
tr("Do you want to enable the experimental Qt Quick Designer?"),
|
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 {
|
} else {
|
||||||
Core::EditorManager::instance()->hideEditorInfoBar(QMLDESIGNER_INFO_BAR);
|
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));
|
"To disable Qt Quick Designer again, visit the menu '%1' and disable 'QmlDesigner'.").arg(menu));
|
||||||
message.setIcon(QMessageBox::Question);
|
message.setIcon(QMessageBox::Question);
|
||||||
QPushButton *enable = message.addButton(tr("Enable Qt Quick Designer"), QMessageBox::AcceptRole);
|
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.addButton(tr("Cancel"), QMessageBox::RejectRole);
|
||||||
message.exec();
|
message.exec();
|
||||||
if (message.clickedButton() == enable) {
|
if (message.clickedButton() == enable) {
|
||||||
@@ -178,13 +179,15 @@ void QmlJSEditorFactory::activateQmlDesigner()
|
|||||||
return;
|
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:
|
private slots:
|
||||||
void activateQmlDesigner();
|
void activateQmlDesigner();
|
||||||
|
void neverAskAgainAboutQmlDesigner();
|
||||||
void updateEditorInfoBar(Core::IEditor *editor);
|
void updateEditorInfoBar(Core::IEditor *editor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user