forked from qt-creator/qt-creator
InfoBar: Use Core::Id
Change-Id: I0918fbc20027a340facbedc685938a72d117d53b Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -84,7 +84,7 @@ void CMakeEditor::markAsChanged()
|
||||
if (m_infoBarShown)
|
||||
return;
|
||||
m_infoBarShown = true;
|
||||
Core::InfoBarEntry info(QLatin1String("CMakeEditor.RunCMake"),
|
||||
Core::InfoBarEntry info(Core::Id("CMakeEditor.RunCMake"),
|
||||
tr("Changes to cmake files are shown in the project tree after building."));
|
||||
info.setCustomButtonInfo(tr("Build now"), this, SLOT(build()));
|
||||
document()->infoBar()->addInfo(info);
|
||||
|
||||
@@ -208,7 +208,7 @@ bool CMakeProject::parseCMakeLists()
|
||||
CMakeBuildConfiguration *activeBC = static_cast<CMakeBuildConfiguration *>(activeTarget()->activeBuildConfiguration());
|
||||
foreach (Core::IEditor *editor, Core::EditorManager::instance()->openedEditors())
|
||||
if (isProjectFile(editor->document()->fileName()))
|
||||
editor->document()->infoBar()->removeInfo(QLatin1String("CMakeEditor.RunCMake"));
|
||||
editor->document()->infoBar()->removeInfo(Core::Id("CMakeEditor.RunCMake"));
|
||||
|
||||
// Find cbp file
|
||||
QString cbpFile = CMakeManager::findCbpFile(activeBC->buildDirectory());
|
||||
|
||||
@@ -1711,19 +1711,19 @@ void EditorManager::updateMakeWritableWarning()
|
||||
if (ww) {
|
||||
// we are about to change a read-only file, warn user
|
||||
if (promptVCS) {
|
||||
InfoBarEntry info(QLatin1String(kMakeWritableWarning),
|
||||
InfoBarEntry info(Id(kMakeWritableWarning),
|
||||
tr("<b>Warning:</b> This file was not opened in %1 yet.")
|
||||
.arg(versionControl->displayName()));
|
||||
info.setCustomButtonInfo(tr("Open"), this, SLOT(vcsOpenCurrentEditor()));
|
||||
curEditor->document()->infoBar()->addInfo(info);
|
||||
} else {
|
||||
InfoBarEntry info(QLatin1String(kMakeWritableWarning),
|
||||
InfoBarEntry info(Id(kMakeWritableWarning),
|
||||
tr("<b>Warning:</b> You are changing a read-only file."));
|
||||
info.setCustomButtonInfo(tr("Make Writable"), this, SLOT(makeCurrentEditorWritable()));
|
||||
curEditor->document()->infoBar()->addInfo(info);
|
||||
}
|
||||
} else {
|
||||
curEditor->document()->infoBar()->removeInfo(QLatin1String(kMakeWritableWarning));
|
||||
curEditor->document()->infoBar()->removeInfo(Id(kMakeWritableWarning));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ void IDocument::setRestoredFrom(const QString &name)
|
||||
{
|
||||
m_autoSaveName = name;
|
||||
m_restored = true;
|
||||
InfoBarEntry info(QLatin1String(kRestoredAutoSave),
|
||||
InfoBarEntry info(Id(kRestoredAutoSave),
|
||||
tr("File was restored from auto-saved copy. "
|
||||
"Select Save to confirm or Revert to Saved to discard changes."));
|
||||
infoBar()->addInfo(info);
|
||||
@@ -98,7 +98,7 @@ void IDocument::removeAutoSaveFile()
|
||||
m_autoSaveName.clear();
|
||||
if (m_restored) {
|
||||
m_restored = false;
|
||||
infoBar()->removeInfo(QLatin1String(kRestoredAutoSave));
|
||||
infoBar()->removeInfo(Id(kRestoredAutoSave));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
|
||||
namespace Core {
|
||||
|
||||
InfoBarEntry::InfoBarEntry(const QString &_id, const QString &_infoText)
|
||||
InfoBarEntry::InfoBarEntry(Id _id, const QString &_infoText)
|
||||
: id(_id)
|
||||
, infoText(_infoText)
|
||||
, object(0)
|
||||
@@ -77,7 +77,7 @@ void InfoBar::addInfo(const InfoBarEntry &info)
|
||||
emit changed();
|
||||
}
|
||||
|
||||
void InfoBar::removeInfo(const QString &id)
|
||||
void InfoBar::removeInfo(Id id)
|
||||
{
|
||||
QMutableListIterator<InfoBarEntry> it(m_infoBarEntries);
|
||||
while (it.hasNext())
|
||||
@@ -88,7 +88,7 @@ void InfoBar::removeInfo(const QString &id)
|
||||
}
|
||||
}
|
||||
|
||||
bool InfoBar::containsInfo(const QString &id) const
|
||||
bool InfoBar::containsInfo(Id id) const
|
||||
{
|
||||
QListIterator<InfoBarEntry> it(m_infoBarEntries);
|
||||
while (it.hasNext())
|
||||
@@ -183,7 +183,7 @@ void InfoBarDisplay::update()
|
||||
}
|
||||
|
||||
QToolButton *infoWidgetCloseButton = new QToolButton;
|
||||
infoWidgetCloseButton->setProperty("infoId", info.id);
|
||||
infoWidgetCloseButton->setProperty("infoId", info.id.uniqueIdentifier());
|
||||
|
||||
// need to connect to cancelObjectbefore connecting to cancelButtonClicked,
|
||||
// because the latter removes the button and with it any connect
|
||||
@@ -216,7 +216,7 @@ void InfoBarDisplay::widgetDestroyed()
|
||||
|
||||
void InfoBarDisplay::cancelButtonClicked()
|
||||
{
|
||||
m_infoBar->removeInfo(sender()->property("infoId").toString());
|
||||
m_infoBar->removeInfo(Id::fromUniqueIdentifier(sender()->property("infoId").toInt()));
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#define INFOBAR_H
|
||||
|
||||
#include "core_global.h"
|
||||
#include <coreplugin/id.h>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
@@ -46,14 +47,14 @@ class InfoBarDisplay;
|
||||
class CORE_EXPORT InfoBarEntry
|
||||
{
|
||||
public:
|
||||
InfoBarEntry(const QString &_id, const QString &_infoText);
|
||||
InfoBarEntry(Id _id, const QString &_infoText);
|
||||
InfoBarEntry(const InfoBarEntry &other) { *this = other; }
|
||||
void setCustomButtonInfo(const QString &_buttonText, QObject *_object, const char *_member);
|
||||
void setCancelButtonInfo(QObject *_object, const char *_member);
|
||||
void setCancelButtonInfo(const QString &_cancelButtonText, QObject *_object, const char *_member);
|
||||
|
||||
private:
|
||||
QString id;
|
||||
Id id;
|
||||
QString infoText;
|
||||
QString buttonText;
|
||||
QObject *object;
|
||||
@@ -71,8 +72,8 @@ class CORE_EXPORT InfoBar : public QObject
|
||||
|
||||
public:
|
||||
void addInfo(const InfoBarEntry &info);
|
||||
void removeInfo(const QString &id);
|
||||
bool containsInfo(const QString &id) const;
|
||||
void removeInfo(Id id);
|
||||
bool containsInfo(Id id) const;
|
||||
void clear();
|
||||
|
||||
signals:
|
||||
|
||||
@@ -714,7 +714,7 @@ void QmlLiveTextPreview::showSyncWarning(
|
||||
foreach (TextEditor::BaseTextEditorWidget *editor, m_editors) {
|
||||
if (editor) {
|
||||
Core::InfoBar *infoBar = editor->editorDocument()->infoBar();
|
||||
Core::InfoBarEntry info(QLatin1String(INFO_OUT_OF_SYNC), errorMessage);
|
||||
Core::InfoBarEntry info(Core::Id(INFO_OUT_OF_SYNC), errorMessage);
|
||||
BaseToolsClient *toolsClient = m_inspectorAdapter->toolsClient();
|
||||
if (toolsClient && toolsClient->supportReload())
|
||||
info.setCustomButtonInfo(tr("Reload QML"), this,
|
||||
@@ -735,7 +735,7 @@ void QmlLiveTextPreview::removeOutofSyncInfo()
|
||||
foreach (TextEditor::BaseTextEditorWidget *editor, m_editors) {
|
||||
if (editor) {
|
||||
Core::InfoBar *infoBar = editor->editorDocument()->infoBar();
|
||||
infoBar->removeInfo(QLatin1String(INFO_OUT_OF_SYNC));
|
||||
infoBar->removeInfo(Core::Id(INFO_OUT_OF_SYNC));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ Core::IDocument *FormEditorFactory::open(const QString &fileName)
|
||||
if (!iface)
|
||||
return 0;
|
||||
if (qobject_cast<FormWindowEditor *>(iface)) {
|
||||
Core::InfoBarEntry info(QLatin1String(Constants::INFO_READ_ONLY),
|
||||
Core::InfoBarEntry info(Core::Id(Constants::INFO_READ_ONLY),
|
||||
tr("This file can only be edited in <b>Design</b> mode."));
|
||||
info.setCustomButtonInfo(tr("Switch mode"), this, SLOT(designerModeClicked()));
|
||||
iface->document()->infoBar()->addInfo(info);
|
||||
|
||||
@@ -222,7 +222,7 @@ void SearchResultWidget::addResults(const QList<SearchResultItem> &items, Search
|
||||
updateMatchesFoundLabel();
|
||||
if (firstItems) {
|
||||
if (showWarningMessage()) {
|
||||
Core::InfoBarEntry info(QLatin1String(UNDO_WARNING_ID), tr("This change cannot be undone."));
|
||||
Core::InfoBarEntry info(Core::Id(UNDO_WARNING_ID), tr("This change cannot be undone."));
|
||||
info.setCustomButtonInfo(tr("Do not warn again"), this, SLOT(hideNoUndoWarning()));
|
||||
m_infoBar.addInfo(info);
|
||||
}
|
||||
@@ -240,7 +240,7 @@ void SearchResultWidget::addResults(const QList<SearchResultItem> &items, Search
|
||||
} else if (m_count > SEARCHRESULT_WARNING_LIMIT && !m_sizeWarningOverridden && !m_sizeWarningActive) {
|
||||
m_sizeWarningActive = true;
|
||||
emit paused(true);
|
||||
Core::InfoBarEntry info(QLatin1String(SIZE_WARNING_ID),
|
||||
Core::InfoBarEntry info(Core::Id(SIZE_WARNING_ID),
|
||||
tr("The search resulted in more than %n items, do you still want to continue?",
|
||||
0, SEARCHRESULT_WARNING_LIMIT));
|
||||
info.setCancelButtonInfo(tr("Cancel"), this, SLOT(cancelAfterSizeWarning()));
|
||||
@@ -367,7 +367,7 @@ void SearchResultWidget::restart()
|
||||
m_searchResultTreeView->clear();
|
||||
m_count = 0;
|
||||
if (m_sizeWarningActive)
|
||||
m_infoBar.removeInfo(QLatin1String(SIZE_WARNING_ID));
|
||||
m_infoBar.removeInfo(Core::Id(SIZE_WARNING_ID));
|
||||
m_sizeWarningActive = false;
|
||||
m_sizeWarningOverridden = false;
|
||||
m_cancelButton->setVisible(true);
|
||||
@@ -391,7 +391,7 @@ void SearchResultWidget::setSearchAgainEnabled(bool enabled)
|
||||
void SearchResultWidget::finishSearch(bool canceled)
|
||||
{
|
||||
if (m_sizeWarningActive)
|
||||
m_infoBar.removeInfo(QLatin1String(SIZE_WARNING_ID));
|
||||
m_infoBar.removeInfo(Core::Id(SIZE_WARNING_ID));
|
||||
m_sizeWarningActive = false;
|
||||
m_sizeWarningOverridden = false;
|
||||
m_replaceTextEdit->setEnabled(m_count > 0);
|
||||
@@ -409,20 +409,20 @@ void SearchResultWidget::sendRequestPopup()
|
||||
void SearchResultWidget::hideNoUndoWarning()
|
||||
{
|
||||
setShowWarningMessage(false);
|
||||
m_infoBar.removeInfo(QLatin1String(UNDO_WARNING_ID));
|
||||
m_infoBar.removeInfo(Core::Id(UNDO_WARNING_ID));
|
||||
}
|
||||
|
||||
void SearchResultWidget::continueAfterSizeWarning()
|
||||
{
|
||||
m_sizeWarningOverridden = true;
|
||||
m_sizeWarningActive = false;
|
||||
m_infoBar.removeInfo(QLatin1String(SIZE_WARNING_ID));
|
||||
m_infoBar.removeInfo(Core::Id(SIZE_WARNING_ID));
|
||||
emit paused(false);
|
||||
}
|
||||
|
||||
void SearchResultWidget::cancelAfterSizeWarning()
|
||||
{
|
||||
m_infoBar.removeInfo(QLatin1String(SIZE_WARNING_ID));
|
||||
m_infoBar.removeInfo(Core::Id(SIZE_WARNING_ID));
|
||||
m_sizeWarningOverridden = true;
|
||||
m_sizeWarningActive = false;
|
||||
emit cancelled();
|
||||
@@ -460,7 +460,7 @@ void SearchResultWidget::searchAgain()
|
||||
|
||||
bool SearchResultWidget::showWarningMessage() const
|
||||
{
|
||||
if (m_dontAskAgainGroup.isEmpty() || m_infoBar.containsInfo(QLatin1String(UNDO_WARNING_ID)))
|
||||
if (m_dontAskAgainGroup.isEmpty() || m_infoBar.containsInfo(Core::Id(UNDO_WARNING_ID)))
|
||||
return false;
|
||||
// read settings
|
||||
QSettings *settings = Core::ICore::settings();
|
||||
|
||||
@@ -568,14 +568,13 @@ void BaseTextEditorWidget::updateCannotDecodeInfo()
|
||||
{
|
||||
setReadOnly(d->m_document->hasDecodingError());
|
||||
if (d->m_document->hasDecodingError()) {
|
||||
Core::InfoBarEntry info(
|
||||
QLatin1String(Constants::SELECT_ENCODING),
|
||||
Core::InfoBarEntry info(Core::Id(Constants::SELECT_ENCODING),
|
||||
tr("<b>Error:</b> Could not decode \"%1\" with \"%2\"-encoding. Editing not possible.")
|
||||
.arg(displayName()).arg(QString::fromLatin1(d->m_document->codec()->name())));
|
||||
info.setCustomButtonInfo(tr("Select Encoding"), this, SLOT(selectEncoding()));
|
||||
d->m_document->infoBar()->addInfo(info);
|
||||
} else {
|
||||
d->m_document->infoBar()->removeInfo(QLatin1String(Constants::SELECT_ENCODING));
|
||||
d->m_document->infoBar()->removeInfo(Core::Id(Constants::SELECT_ENCODING));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ void PlainTextEditorFactory::updateEditorInfoBar(Core::IEditor *editor)
|
||||
if (!file)
|
||||
return;
|
||||
PlainTextEditorWidget *textEditor = static_cast<PlainTextEditorWidget *>(editorEditable->editorWidget());
|
||||
const QString infoSyntaxDefinition = QLatin1String(Constants::INFO_SYNTAX_DEFINITION);
|
||||
Core::Id infoSyntaxDefinition(Constants::INFO_SYNTAX_DEFINITION);
|
||||
if (textEditor->isMissingSyntaxDefinition() &&
|
||||
!textEditor->ignoreMissingSyntaxDefinition() &&
|
||||
TextEditorSettings::instance()->highlighterSettings().alertWhenNoDefinition()) {
|
||||
|
||||
Reference in New Issue
Block a user