summaryrefslogtreecommitdiff
path: root/src/plugins/coreplugin
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/coreplugin')
-rw-r--r--src/plugins/coreplugin/actionmanager/actioncontainer.cpp5
-rw-r--r--src/plugins/coreplugin/actionmanager/actionmanager.cpp24
-rw-r--r--src/plugins/coreplugin/actionmanager/actionmanager.h2
-rw-r--r--src/plugins/coreplugin/actionmanager/command.cpp33
-rw-r--r--src/plugins/coreplugin/actionmanager/command_p.h2
-rw-r--r--src/plugins/coreplugin/actionmanager/commandmappings.cpp21
-rw-r--r--src/plugins/coreplugin/actionmanager/commandsfile.cpp2
-rw-r--r--src/plugins/coreplugin/basefilewizard.cpp24
-rw-r--r--src/plugins/coreplugin/coreconstants.h2
-rw-r--r--src/plugins/coreplugin/coreplugin.cpp7
-rw-r--r--src/plugins/coreplugin/coreplugin.pro1
-rw-r--r--src/plugins/coreplugin/coreplugin.qbs70
-rw-r--r--src/plugins/coreplugin/designmode.cpp11
-rw-r--r--src/plugins/coreplugin/dialogs/externaltoolconfig.cpp34
-rw-r--r--src/plugins/coreplugin/dialogs/externaltoolconfig.h1
-rw-r--r--src/plugins/coreplugin/dialogs/externaltoolconfig.ui51
-rw-r--r--src/plugins/coreplugin/dialogs/ioptionspage.h20
-rw-r--r--src/plugins/coreplugin/dialogs/newdialog.cpp13
-rw-r--r--src/plugins/coreplugin/dialogs/promptoverwritedialog.cpp5
-rw-r--r--src/plugins/coreplugin/dialogs/saveitemsdialog.cpp28
-rw-r--r--src/plugins/coreplugin/dialogs/settingsdialog.cpp89
-rw-r--r--src/plugins/coreplugin/dialogs/settingsdialog.h21
-rw-r--r--src/plugins/coreplugin/dialogs/shortcutsettings.cpp29
-rw-r--r--src/plugins/coreplugin/documentmanager.cpp82
-rw-r--r--src/plugins/coreplugin/documentmanager.h3
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.cpp281
-rw-r--r--src/plugins/coreplugin/editormanager/editormanager.h10
-rw-r--r--src/plugins/coreplugin/editormanager/editorview.cpp28
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorsmodel.cpp7
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorsview.cpp87
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorsview.h10
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorsview.ui31
-rw-r--r--src/plugins/coreplugin/editormanager/openeditorswindow.cpp14
-rw-r--r--src/plugins/coreplugin/editortoolbar.cpp15
-rw-r--r--src/plugins/coreplugin/externaltool.cpp39
-rw-r--r--src/plugins/coreplugin/fancyactionbar.cpp15
-rw-r--r--src/plugins/coreplugin/fancytabwidget.cpp20
-rw-r--r--src/plugins/coreplugin/featureprovider.h17
-rw-r--r--src/plugins/coreplugin/fileiconprovider.cpp15
-rw-r--r--src/plugins/coreplugin/fileutils.cpp155
-rw-r--r--src/plugins/coreplugin/generalsettings.cpp24
-rw-r--r--src/plugins/coreplugin/generalsettings.h1
-rw-r--r--src/plugins/coreplugin/generalsettings.ui168
-rw-r--r--src/plugins/coreplugin/icontext.cpp23
-rw-r--r--src/plugins/coreplugin/icontext.h24
-rw-r--r--src/plugins/coreplugin/icore.cpp11
-rw-r--r--src/plugins/coreplugin/icore.h10
-rw-r--r--src/plugins/coreplugin/id.cpp236
-rw-r--r--src/plugins/coreplugin/id.h22
-rw-r--r--src/plugins/coreplugin/idocument.cpp4
-rw-r--r--src/plugins/coreplugin/images/logo/logo.qbs17
-rw-r--r--src/plugins/coreplugin/inavigationwidgetfactory.h2
-rw-r--r--src/plugins/coreplugin/infobar.cpp86
-rw-r--r--src/plugins/coreplugin/infobar.h26
-rw-r--r--src/plugins/coreplugin/iversioncontrol.cpp5
-rw-r--r--src/plugins/coreplugin/iversioncontrol.h5
-rw-r--r--src/plugins/coreplugin/mainwindow.cpp132
-rw-r--r--src/plugins/coreplugin/mainwindow.h9
-rw-r--r--src/plugins/coreplugin/manhattanstyle.cpp18
-rw-r--r--src/plugins/coreplugin/mimedatabase.cpp51
-rw-r--r--src/plugins/coreplugin/mimetypesettings.cpp19
-rw-r--r--src/plugins/coreplugin/modemanager.cpp2
-rw-r--r--src/plugins/coreplugin/navigationsubwidget.cpp2
-rw-r--r--src/plugins/coreplugin/navigationwidget.cpp7
-rw-r--r--src/plugins/coreplugin/outputpane.cpp2
-rw-r--r--src/plugins/coreplugin/outputpanemanager.cpp22
-rw-r--r--src/plugins/coreplugin/outputwindow.cpp3
-rw-r--r--src/plugins/coreplugin/progressmanager/futureprogress.cpp13
-rw-r--r--src/plugins/coreplugin/progressmanager/progressbar.cpp2
-rw-r--r--src/plugins/coreplugin/progressmanager/progressmanager.cpp10
-rw-r--r--src/plugins/coreplugin/progressmanager/progressview.cpp5
-rw-r--r--src/plugins/coreplugin/rightpane.cpp8
-rw-r--r--src/plugins/coreplugin/scriptmanager/scriptmanager.cpp2
-rw-r--r--src/plugins/coreplugin/settingsdatabase.cpp3
-rw-r--r--src/plugins/coreplugin/sidebar.cpp17
-rw-r--r--src/plugins/coreplugin/sidebarwidget.cpp4
-rw-r--r--src/plugins/coreplugin/styleanimator.cpp6
-rw-r--r--src/plugins/coreplugin/textdocument.h1
-rw-r--r--src/plugins/coreplugin/toolsettings.cpp10
-rw-r--r--src/plugins/coreplugin/variablechooser.cpp33
-rw-r--r--src/plugins/coreplugin/variablechooser.h1
-rw-r--r--src/plugins/coreplugin/variablemanager.cpp9
-rw-r--r--src/plugins/coreplugin/variablemanager.h1
-rw-r--r--src/plugins/coreplugin/vcsmanager.cpp11
-rw-r--r--src/plugins/coreplugin/versiondialog.cpp2
85 files changed, 1368 insertions, 1025 deletions
diff --git a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp
index 869b25b00d..8c792830a6 100644
--- a/src/plugins/coreplugin/actionmanager/actioncontainer.cpp
+++ b/src/plugins/coreplugin/actionmanager/actioncontainer.cpp
@@ -307,9 +307,8 @@ Command *ActionContainerPrivate::addSeparator(const Context &context, const Id &
static int separatorIdCount = 0;
QAction *separator = new QAction(this);
separator->setSeparator(true);
- Command *cmd = ActionManager::registerAction(separator, Id(QString::fromLatin1("%1.Separator.%2")
- .arg(id().toString()).arg(++separatorIdCount)),
- context);
+ Id sepId = id().withSuffix(".Separator.").withSuffix(++separatorIdCount);
+ Command *cmd = ActionManager::registerAction(separator, sepId, context);
addAction(cmd, group);
if (outSeparator)
*outSeparator = separator;
diff --git a/src/plugins/coreplugin/actionmanager/actionmanager.cpp b/src/plugins/coreplugin/actionmanager/actionmanager.cpp
index b8a79b4783..574b97cf94 100644
--- a/src/plugins/coreplugin/actionmanager/actionmanager.cpp
+++ b/src/plugins/coreplugin/actionmanager/actionmanager.cpp
@@ -258,6 +258,7 @@ Command *ActionManager::registerAction(QAction *action, const Id &id, const Cont
*/
Command *ActionManager::registerShortcut(QShortcut *shortcut, const Id &id, const Context &context, bool scriptable)
{
+ QTC_CHECK(!context.isEmpty());
Shortcut *sc = 0;
if (CommandPrivate *c = m_instance->d->m_idCmdMap.value(id, 0)) {
sc = qobject_cast<Shortcut *>(c);
@@ -282,11 +283,7 @@ Command *ActionManager::registerShortcut(QShortcut *shortcut, const Id &id, cons
shortcut->setParent(ICore::mainWindow());
sc->setShortcut(shortcut);
sc->setScriptable(scriptable);
-
- if (context.isEmpty())
- sc->setContext(Context(0));
- else
- sc->setContext(context);
+ sc->setContext(context);
emit m_instance->commandListChanged();
emit m_instance->commandAdded(id.toString());
@@ -445,11 +442,6 @@ bool ActionManager::isPresentationModeEnabled()
return m_instance->d->m_presentationLabel;
}
-bool ActionManager::hasContext(int context)
-{
- return m_instance->d->m_context.contains(context);
-}
-
/*!
\class ActionManagerPrivate
\inheaderfile actionmanager_p.h
@@ -471,12 +463,12 @@ ActionManagerPrivate::~ActionManagerPrivate()
qDeleteAll(m_idCmdMap.values());
}
-QDebug operator<<(QDebug in, const Context &context)
+QDebug operator<<(QDebug d, const Context &context)
{
- in << "CONTEXT: ";
- foreach (int c, context)
- in << " " << c << Id::fromUniqueIdentifier(c).toString();
- return in;
+ d << "CONTEXT: ";
+ foreach (Id id, context)
+ d << " " << id.uniqueIdentifier() << " " << id.toString();
+ return d;
}
void ActionManagerPrivate::setContext(const Context &context)
@@ -571,7 +563,7 @@ void ActionManagerPrivate::initialize()
for (int i = 0; i < shortcuts; ++i) {
settings->setArrayIndex(i);
const QKeySequence key(settings->value(QLatin1String(sequenceKey)).toString());
- const Id id = Id(settings->value(QLatin1String(idKey)).toString());
+ const Id id = Id::fromSetting(settings->value(QLatin1String(idKey)));
Command *cmd = ActionManager::command(id);
if (cmd)
diff --git a/src/plugins/coreplugin/actionmanager/actionmanager.h b/src/plugins/coreplugin/actionmanager/actionmanager.h
index c13af9e106..b9b666a14c 100644
--- a/src/plugins/coreplugin/actionmanager/actionmanager.h
+++ b/src/plugins/coreplugin/actionmanager/actionmanager.h
@@ -76,8 +76,6 @@ public:
static void setPresentationModeEnabled(bool enabled);
static bool isPresentationModeEnabled();
- static bool hasContext(int context);
-
signals:
void commandListChanged();
void commandAdded(const QString &id);
diff --git a/src/plugins/coreplugin/actionmanager/command.cpp b/src/plugins/coreplugin/actionmanager/command.cpp
index fffe203840..87136bb196 100644
--- a/src/plugins/coreplugin/actionmanager/command.cpp
+++ b/src/plugins/coreplugin/actionmanager/command.cpp
@@ -33,6 +33,8 @@
#include "icontext.h"
#include "id.h"
+#include <utils/hostosinfo.h>
+
#include <QDebug>
#include <QTextStream>
@@ -331,8 +333,8 @@ QKeySequence Shortcut::keySequence() const
void Shortcut::setCurrentContext(const Core::Context &context)
{
- foreach (int ctxt, m_context) {
- if (context.contains(ctxt)) {
+ foreach (Id id, m_context) {
+ if (context.contains(id)) {
if (!m_shortcut->isEnabled()) {
m_shortcut->setEnabled(true);
emit activeStateChanged();
@@ -421,7 +423,7 @@ void Action::updateActiveState()
setActive(m_action->isEnabled() && m_action->isVisible() && !m_action->isSeparator());
}
-static QString msgActionWarning(QAction *newAction, int k, QAction *oldAction)
+static QString msgActionWarning(QAction *newAction, Id id, QAction *oldAction)
{
QString msg;
QTextStream str(&msg);
@@ -429,27 +431,25 @@ static QString msgActionWarning(QAction *newAction, int k, QAction *oldAction)
<< ": Action ";
if (oldAction)
str << oldAction->objectName() << '/' << oldAction->text();
- str << " is already registered for context " << k << ' '
- << Core::Id::fromUniqueIdentifier(k).toString()
- << '.';
+ str << " is already registered for context " << id.uniqueIdentifier() << ' '
+ << id.toString() << '.';
return msg;
}
void Action::addOverrideAction(QAction *action, const Core::Context &context, bool scriptable)
{
-#ifdef Q_OS_MAC
- action->setIconVisibleInMenu(false);
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ action->setIconVisibleInMenu(false);
if (isEmpty())
m_action->initialize(action);
if (context.isEmpty()) {
m_contextActionMap.insert(0, action);
} else {
for (int i = 0; i < context.size(); ++i) {
- int k = context.at(i);
- if (m_contextActionMap.contains(k))
- qWarning("%s", qPrintable(msgActionWarning(action, k, m_contextActionMap.value(k, 0))));
- m_contextActionMap.insert(k, action);
+ Id id = context.at(i);
+ if (m_contextActionMap.contains(id))
+ qWarning("%s", qPrintable(msgActionWarning(action, id, m_contextActionMap.value(id, 0))));
+ m_contextActionMap.insert(id, action);
}
}
m_scriptableMap[action] = scriptable;
@@ -458,14 +458,13 @@ void Action::addOverrideAction(QAction *action, const Core::Context &context, bo
void Action::removeOverrideAction(QAction *action)
{
- QMutableMapIterator<int, QPointer<QAction> > it(m_contextActionMap);
+ QMutableMapIterator<Id, QPointer<QAction> > it(m_contextActionMap);
while (it.hasNext()) {
it.next();
- if (it.value() == 0) {
+ if (it.value() == 0)
it.remove();
- } else if (it.value() == action) {
+ else if (it.value() == action)
it.remove();
- }
}
setCurrentContext(m_context);
}
diff --git a/src/plugins/coreplugin/actionmanager/command_p.h b/src/plugins/coreplugin/actionmanager/command_p.h
index 6adbca94b2..a2ead8551d 100644
--- a/src/plugins/coreplugin/actionmanager/command_p.h
+++ b/src/plugins/coreplugin/actionmanager/command_p.h
@@ -145,7 +145,7 @@ private:
Utils::ProxyAction *m_action;
QString m_toolTip;
- QMap<int, QPointer<QAction> > m_contextActionMap;
+ QMap<Id, QPointer<QAction> > m_contextActionMap;
QMap<QAction*, bool> m_scriptableMap;
bool m_active;
bool m_contextInitialized;
diff --git a/src/plugins/coreplugin/actionmanager/commandmappings.cpp b/src/plugins/coreplugin/actionmanager/commandmappings.cpp
index 68ca2c63a9..52258a1759 100644
--- a/src/plugins/coreplugin/actionmanager/commandmappings.cpp
+++ b/src/plugins/coreplugin/actionmanager/commandmappings.cpp
@@ -36,6 +36,7 @@
#include "icore.h"
#include "id.h"
+#include <utils/hostosinfo.h>
#include <utils/treewidgetcolumnstretcher.h>
#include <QKeyEvent>
@@ -165,18 +166,18 @@ bool CommandMappings::filter(const QString &filterString, QTreeWidgetItem *item)
int columnCount = item->columnCount();
for (int i = 0; !visible && i < columnCount; ++i) {
QString text = item->text(i);
-#ifdef Q_OS_MAC
- // accept e.g. Cmd+E in the filter. the text shows special fancy characters for Cmd
- if (i == columnCount - 1) {
- QKeySequence key = QKeySequence::fromString(text, QKeySequence::NativeText);
- if (!key.isEmpty()) {
- text = key.toString(QKeySequence::PortableText);
- text.replace(QLatin1String("Ctrl"), QLatin1String("Cmd"));
- text.replace(QLatin1String("Meta"), QLatin1String("Ctrl"));
- text.replace(QLatin1String("Alt"), QLatin1String("Opt"));
+ if (Utils::HostOsInfo::isMacHost()) {
+ // accept e.g. Cmd+E in the filter. the text shows special fancy characters for Cmd
+ if (i == columnCount - 1) {
+ QKeySequence key = QKeySequence::fromString(text, QKeySequence::NativeText);
+ if (!key.isEmpty()) {
+ text = key.toString(QKeySequence::PortableText);
+ text.replace(QLatin1String("Ctrl"), QLatin1String("Cmd"));
+ text.replace(QLatin1String("Meta"), QLatin1String("Ctrl"));
+ text.replace(QLatin1String("Alt"), QLatin1String("Opt"));
+ }
}
}
-#endif
visible |= (bool)text.contains(filterString, Qt::CaseInsensitive);
}
diff --git a/src/plugins/coreplugin/actionmanager/commandsfile.cpp b/src/plugins/coreplugin/actionmanager/commandsfile.cpp
index a9ab7f9a67..46bb4ad5fa 100644
--- a/src/plugins/coreplugin/actionmanager/commandsfile.cpp
+++ b/src/plugins/coreplugin/actionmanager/commandsfile.cpp
@@ -140,7 +140,7 @@ bool CommandsFile::exportCommands(const QList<ShortcutItem *> &items)
w.setAutoFormattingIndent(1); // Historical, used to be QDom.
w.writeStartDocument();
w.writeDTD(QLatin1String("<!DOCTYPE KeyboardMappingScheme>"));
- w.writeComment(QString::fromAscii(" Written by Qt Creator %1, %2. ").
+ w.writeComment(QString::fromLatin1(" Written by Qt Creator %1, %2. ").
arg(QLatin1String(Core::Constants::IDE_VERSION_LONG),
QDateTime::currentDateTime().toString(Qt::ISODate)));
w.writeStartElement(ctx.mappingElement);
diff --git a/src/plugins/coreplugin/basefilewizard.cpp b/src/plugins/coreplugin/basefilewizard.cpp
index 46a70a39b7..bac79c0f78 100644
--- a/src/plugins/coreplugin/basefilewizard.cpp
+++ b/src/plugins/coreplugin/basefilewizard.cpp
@@ -40,6 +40,7 @@
#include <utils/qtcassert.h>
#include <utils/stringutils.h>
#include <utils/fileutils.h>
+#include <utils/hostosinfo.h>
#include <QDir>
#include <QFile>
@@ -546,7 +547,8 @@ void BaseFileWizard::runWizard(const QString &path, QWidget *parent, const QStri
// Post generation handler
if (!postGenerateFiles(wizard.data(), files, &errorMessage))
- QMessageBox::critical(0, tr("File Generation Failure"), errorMessage);
+ if (!errorMessage.isEmpty())
+ QMessageBox::critical(0, tr("File Generation Failure"), errorMessage);
}
@@ -603,15 +605,15 @@ void BaseFileWizard::setupWizard(QWizard *w)
w->setOption(QWizard::NoBackButtonOnStartPage, true);
w->setWindowFlags(w->windowFlags() & ~Qt::WindowContextHelpButtonHint);
-#ifdef Q_OS_MAC
- w->setButtonLayout(QList<QWizard::WizardButton>()
- << QWizard::CancelButton
- << QWizard::Stretch
- << QWizard::BackButton
- << QWizard::NextButton
- << QWizard::CommitButton
- << QWizard::FinishButton);
-#endif
+ if (Utils::HostOsInfo::isMacHost()) {
+ w->setButtonLayout(QList<QWizard::WizardButton>()
+ << QWizard::CancelButton
+ << QWizard::Stretch
+ << QWizard::BackButton
+ << QWizard::NextButton
+ << QWizard::CommitButton
+ << QWizard::FinishButton);
+ }
}
/*!
@@ -651,7 +653,7 @@ bool BaseFileWizard::postGenerateFiles(const QWizard *, const GeneratedFiles &l,
bool BaseFileWizard::postGenerateOpenEditors(const GeneratedFiles &l, QString *errorMessage)
{
- foreach(const Core::GeneratedFile &file, l) {
+ foreach (const Core::GeneratedFile &file, l) {
if (file.attributes() & Core::GeneratedFile::OpenEditorAttribute) {
if (!Core::EditorManager::openEditor(file.path(), file.editorId(), Core::EditorManager::ModeSwitch )) {
if (errorMessage)
diff --git a/src/plugins/coreplugin/coreconstants.h b/src/plugins/coreplugin/coreconstants.h
index 4234774058..79b42fc326 100644
--- a/src/plugins/coreplugin/coreconstants.h
+++ b/src/plugins/coreplugin/coreconstants.h
@@ -227,6 +227,8 @@ const char VARIABLE_SUPPORT_PROPERTY[] = "QtCreator.VariableSupport";
const char TR_CLEAR_MENU[] = QT_TRANSLATE_NOOP("Core", "Clear Menu");
+const char DEFAULT_BUILD_DIRECTORY[] = "../build-%{CurrentProject:Name}-%{CurrentKit:FileSystemName}-%{CurrentBuild:Name}";
+
const int TARGET_ICON_SIZE = 32;
} // namespace Constants
diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp
index 966153437f..f5ea9aeb70 100644
--- a/src/plugins/coreplugin/coreplugin.cpp
+++ b/src/plugins/coreplugin/coreplugin.cpp
@@ -37,8 +37,10 @@
#include "mainwindow.h"
#include "mimedatabase.h"
#include "modemanager.h"
+#include "infobar.h"
#include <extensionsystem/pluginmanager.h>
+#include <utils/savefile.h>
#include <QtPlugin>
#include <QDebug>
@@ -92,7 +94,12 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
addObject(m_editMode);
ModeManager::activateMode(m_editMode->id());
m_designMode = new DesignMode;
+ InfoBar::initializeGloballySuppressed();
}
+
+ // Make sure we respect the process's umask when creating new files
+ Utils::SaveFile::initializeUmask();
+
return success;
}
diff --git a/src/plugins/coreplugin/coreplugin.pro b/src/plugins/coreplugin/coreplugin.pro
index 381f6a6e57..bb02bfc631 100644
--- a/src/plugins/coreplugin/coreplugin.pro
+++ b/src/plugins/coreplugin/coreplugin.pro
@@ -207,7 +207,6 @@ FORMS += dialogs/newdialog.ui \
actionmanager/commandmappings.ui \
dialogs/saveitemsdialog.ui \
dialogs/openwithdialog.ui \
- editormanager/openeditorsview.ui \
generalsettings.ui \
dialogs/externaltoolconfig.ui \
variablechooser.ui \
diff --git a/src/plugins/coreplugin/coreplugin.qbs b/src/plugins/coreplugin/coreplugin.qbs
index cf50a57299..b8250e8cfb 100644
--- a/src/plugins/coreplugin/coreplugin.qbs
+++ b/src/plugins/coreplugin/coreplugin.qbs
@@ -13,20 +13,17 @@ QtcPlugin {
Depends { name: "Utils" }
Depends { name: "ExtensionSystem" }
Depends { name: "Aggregation" }
+ Depends { name: "app_version_header" }
- cpp.includePaths: [
- ".",
- "..",
+ cpp.includePaths: base.concat([
"../..",
- "../../libs",
- "../../../src/shared/scriptwrapper/",
+ "../../shared/scriptwrapper",
"dialogs",
"editormanager",
"progressmanager",
"scriptmanager",
- "actionmanager",
- buildDirectory
- ]
+ "actionmanager"
+ ])
cpp.dynamicLibraries: {
if (qbs.targetOS == "windows") return [
@@ -36,8 +33,6 @@ QtcPlugin {
}
files: [
- "fancyactionbar.qrc",
- "generalsettings.ui",
"basefilewizard.cpp",
"basefilewizard.h",
"core.qrc",
@@ -47,6 +42,8 @@ QtcPlugin {
"coreplugin.h",
"designmode.cpp",
"designmode.h",
+ "documentmanager.cpp",
+ "documentmanager.h",
"editmode.cpp",
"editmode.h",
"editortoolbar.cpp",
@@ -56,10 +53,11 @@ QtcPlugin {
"externaltoolmanager.h",
"fancyactionbar.cpp",
"fancyactionbar.h",
+ "fancyactionbar.qrc",
"fancytabwidget.cpp",
"fancytabwidget.h",
- "featureprovider.h",
"featureprovider.cpp",
+ "featureprovider.h",
"fileiconprovider.cpp",
"fileiconprovider.h",
"fileutils.cpp",
@@ -68,6 +66,7 @@ QtcPlugin {
"findplaceholder.h",
"generalsettings.cpp",
"generalsettings.h",
+ "generalsettings.ui",
"generatedfile.cpp",
"generatedfile.h",
"helpmanager.cpp",
@@ -77,20 +76,21 @@ QtcPlugin {
"icore.cpp",
"icore.h",
"icorelistener.h",
+ "id.cpp",
"id.h",
- "ifilewizardextension.h",
- "imode.cpp",
- "imode.h",
- "documentmanager.cpp",
- "documentmanager.h",
"idocument.cpp",
"idocument.h",
"idocumentfactory.h",
+ "ifilewizardextension.h",
+ "imode.cpp",
+ "imode.h",
"inavigationwidgetfactory.cpp",
"inavigationwidgetfactory.h",
"infobar.cpp",
"infobar.h",
"ioutputpane.h",
+ "iversioncontrol.cpp",
+ "iversioncontrol.h",
"mainwindow.cpp",
"mainwindow.h",
"manhattanstyle.cpp",
@@ -146,18 +146,15 @@ QtcPlugin {
"textdocument.h",
"toolsettings.cpp",
"toolsettings.h",
+ "variablechooser.cpp",
"variablechooser.h",
"variablechooser.ui",
- "vcsmanager.h",
- "versiondialog.cpp",
- "versiondialog.h",
- "id.cpp",
- "iversioncontrol.cpp",
- "iversioncontrol.h",
- "variablechooser.cpp",
"variablemanager.cpp",
"variablemanager.h",
"vcsmanager.cpp",
+ "vcsmanager.h",
+ "versiondialog.cpp",
+ "versiondialog.h",
"actionmanager/actioncontainer.cpp",
"actionmanager/actioncontainer.h",
"actionmanager/actioncontainer_p.h",
@@ -167,23 +164,23 @@ QtcPlugin {
"actionmanager/command.cpp",
"actionmanager/command.h",
"actionmanager/command_p.h",
- "actionmanager/commandbutton.h",
"actionmanager/commandbutton.cpp",
+ "actionmanager/commandbutton.h",
"actionmanager/commandmappings.cpp",
"actionmanager/commandmappings.h",
"actionmanager/commandmappings.ui",
"actionmanager/commandsfile.cpp",
"actionmanager/commandsfile.h",
- "dialogs/externaltoolconfig.ui",
- "dialogs/newdialog.ui",
"dialogs/externaltoolconfig.cpp",
"dialogs/externaltoolconfig.h",
+ "dialogs/externaltoolconfig.ui",
"dialogs/ioptionspage.cpp",
"dialogs/ioptionspage.h",
"dialogs/iwizard.cpp",
"dialogs/iwizard.h",
"dialogs/newdialog.cpp",
"dialogs/newdialog.h",
+ "dialogs/newdialog.ui",
"dialogs/openwithdialog.cpp",
"dialogs/openwithdialog.h",
"dialogs/openwithdialog.ui",
@@ -197,25 +194,24 @@ QtcPlugin {
"dialogs/shortcutsettings.cpp",
"dialogs/shortcutsettings.h",
"editormanager/BinFiles.mimetypes.xml",
+ "editormanager/editormanager.cpp",
+ "editormanager/editormanager.h",
"editormanager/editorview.cpp",
"editormanager/editorview.h",
"editormanager/ieditor.cpp",
"editormanager/ieditor.h",
- "editormanager/ieditorfactory.h",
"editormanager/ieditorfactory.cpp",
+ "editormanager/ieditorfactory.h",
"editormanager/iexternaleditor.cpp",
"editormanager/iexternaleditor.h",
"editormanager/openeditorsmodel.cpp",
"editormanager/openeditorsmodel.h",
"editormanager/openeditorsview.cpp",
"editormanager/openeditorsview.h",
- "editormanager/openeditorsview.ui",
"editormanager/openeditorswindow.cpp",
"editormanager/openeditorswindow.h",
"editormanager/systemeditor.cpp",
"editormanager/systemeditor.h",
- "editormanager/editormanager.cpp",
- "editormanager/editormanager.h",
"progressmanager/futureprogress.cpp",
"progressmanager/futureprogress.h",
"progressmanager/progressbar.cpp",
@@ -228,27 +224,27 @@ QtcPlugin {
"scriptmanager/metatypedeclarations.h",
"scriptmanager/scriptmanager.cpp",
"scriptmanager/scriptmanager.h",
- "scriptmanager/scriptmanager_p.h"
+ "scriptmanager/scriptmanager_p.h",
]
Group {
condition: qbs.targetOS == "windows"
files: [
- "progressmanager/progressmanager_win.cpp"
+ "progressmanager/progressmanager_win.cpp",
]
}
Group {
condition: qbs.targetOS == "macx"
files: [
- "progressmanager/progressmanager_mac.mm"
+ "progressmanager/progressmanager_mac.mm",
]
}
Group {
condition: qbs.targetOS == "linux"
files: [
- "progressmanager/progressmanager_x11.cpp"
+ "progressmanager/progressmanager_x11.cpp",
]
}
@@ -257,11 +253,5 @@ QtcPlugin {
Depends { name: "Aggregation" }
Depends { name: "ExtensionSystem" }
Depends { name: "Utils" }
- cpp.includePaths: [
- "../..",
- "../../libs",
- product.buildDirectory + "/.obj/Core/actionmanager"
- ]
}
}
-
diff --git a/src/plugins/coreplugin/designmode.cpp b/src/plugins/coreplugin/designmode.cpp
index 3b529704aa..4e7a5cdc80 100644
--- a/src/plugins/coreplugin/designmode.cpp
+++ b/src/plugins/coreplugin/designmode.cpp
@@ -44,6 +44,7 @@
#include <QPair>
#include <QFileInfo>
+#include <QPointer>
#include <QStringList>
#include <QDebug>
@@ -100,7 +101,7 @@ public:
public:
Internal::DesignModeCoreListener *m_coreListener;
- QWeakPointer<Core::IEditor> m_currentEditor;
+ QPointer<Core::IEditor> m_currentEditor;
bool m_isActive;
bool m_isRequired;
QList<DesignEditorInfo*> m_editors;
@@ -166,7 +167,7 @@ bool DesignMode::designModeIsRequired() const
QStringList DesignMode::registeredMimeTypes() const
{
QStringList rc;
- foreach(const DesignEditorInfo *i, d->m_editors)
+ foreach (const DesignEditorInfo *i, d->m_editors)
rc += i->mimeTypes;
return rc;
}
@@ -194,7 +195,7 @@ void DesignMode::registerDesignWidget(QWidget *widget,
void DesignMode::unregisterDesignWidget(QWidget *widget)
{
d->m_stackWidget->removeWidget(widget);
- foreach(DesignEditorInfo *info, d->m_editors) {
+ foreach (DesignEditorInfo *info, d->m_editors) {
if (info->widget == widget) {
d->m_editors.removeAll(info);
break;
@@ -236,10 +237,10 @@ void DesignMode::currentEditorChanged(Core::IEditor *editor)
if (ModeManager::currentMode() == this)
ModeManager::activateMode(Core::Constants::MODE_EDIT);
setEnabled(false);
- d->m_currentEditor = QWeakPointer<Core::IEditor>();
+ d->m_currentEditor = 0;
emit actionsUpdated(d->m_currentEditor.data());
} else {
- d->m_currentEditor = QWeakPointer<Core::IEditor>(editor);
+ d->m_currentEditor = editor;
if (d->m_currentEditor)
connect(d->m_currentEditor.data(), SIGNAL(changed()), this, SLOT(updateActions()));
diff --git a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp
index 329a0bf7cb..d7bfdeb12a 100644
--- a/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp
+++ b/src/plugins/coreplugin/dialogs/externaltoolconfig.cpp
@@ -30,10 +30,13 @@
#include "externaltoolconfig.h"
#include "ui_externaltoolconfig.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
+#include <utils/qtcprocess.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/variablechooser.h>
+#include <coreplugin/variablemanager.h>
#include <QTextStream>
#include <QFile>
@@ -180,9 +183,8 @@ QModelIndex ExternalToolModel::index(int row, int column, const QModelIndex &par
QString category = categoryForIndex(parent, &found);
if (found) {
QList<ExternalTool *> items = m_tools.value(category);
- if (row < items.count()) {
+ if (row < items.count())
return createIndex(row, 0, items.at(row));
- }
}
} else if (column == 0 && row < m_tools.keys().count()) {
return createIndex(row, 0);
@@ -209,14 +211,12 @@ int ExternalToolModel::rowCount(const QModelIndex &parent) const
{
if (!parent.isValid())
return m_tools.keys().count();
- if (toolForIndex(parent)) {
+ if (toolForIndex(parent))
return 0;
- }
bool found;
QString category = categoryForIndex(parent, &found);
- if (found) {
+ if (found)
return m_tools.value(category).count();
- }
return 0;
}
@@ -350,13 +350,13 @@ QModelIndex ExternalToolModel::addTool(const QModelIndex &atIndex)
tool->setDescription(tr("This tool prints a line of useful text"));
//: Sample external tool text
const QString text = tr("Useful text");
-#ifdef Q_OS_WIN
- tool->setExecutables(QStringList(QLatin1String("cmd")));
- tool->setArguments(QLatin1String("/c echo ") + text);
-#else
- tool->setExecutables(QStringList(QLatin1String("echo")));
- tool->setArguments(text);
-#endif
+ if (Utils::HostOsInfo::isWindowsHost()) {
+ tool->setExecutables(QStringList(QLatin1String("cmd")));
+ tool->setArguments(QLatin1String("/c echo ") + text);
+ } else {
+ tool->setExecutables(QStringList(QLatin1String("echo")));
+ tool->setArguments(text);
+ }
int pos;
QModelIndex parent;
@@ -419,6 +419,7 @@ ExternalToolConfig::ExternalToolConfig(QWidget *parent) :
connect(ui->executable, SIGNAL(editingFinished()), this, SLOT(updateCurrentItem()));
connect(ui->executable, SIGNAL(browsingFinished()), this, SLOT(updateCurrentItem()));
connect(ui->arguments, SIGNAL(editingFinished()), this, SLOT(updateCurrentItem()));
+ connect(ui->arguments, SIGNAL(editingFinished()), this, SLOT(updateEffectiveArguments()));
connect(ui->workingDirectory, SIGNAL(editingFinished()), this, SLOT(updateCurrentItem()));
connect(ui->workingDirectory, SIGNAL(browsingFinished()), this, SLOT(updateCurrentItem()));
connect(ui->outputBehavior, SIGNAL(activated(int)), this, SLOT(updateCurrentItem()));
@@ -558,6 +559,7 @@ void ExternalToolConfig::showInfoForItem(const QModelIndex &index)
ui->description->setCursorPosition(0);
ui->arguments->setCursorPosition(0);
+ updateEffectiveArguments();
}
QMap<QString, QList<ExternalTool *> > ExternalToolConfig::tools() const
@@ -604,3 +606,9 @@ void ExternalToolConfig::addCategory()
ui->toolTree->selectionModel()->setCurrentIndex(index, QItemSelectionModel::SelectCurrent);
ui->toolTree->edit(index);
}
+
+void ExternalToolConfig::updateEffectiveArguments()
+{
+ ui->effectiveArguments->setText(Utils::QtcProcess::expandMacros(ui->arguments->text(),
+ Core::VariableManager::instance()->macroExpander()));
+}
diff --git a/src/plugins/coreplugin/dialogs/externaltoolconfig.h b/src/plugins/coreplugin/dialogs/externaltoolconfig.h
index 38ca3e991a..ab75a8a3d3 100644
--- a/src/plugins/coreplugin/dialogs/externaltoolconfig.h
+++ b/src/plugins/coreplugin/dialogs/externaltoolconfig.h
@@ -108,6 +108,7 @@ private slots:
void addTool();
void removeTool();
void addCategory();
+ void updateEffectiveArguments();
private:
Ui::ExternalToolConfig *ui;
diff --git a/src/plugins/coreplugin/dialogs/externaltoolconfig.ui b/src/plugins/coreplugin/dialogs/externaltoolconfig.ui
index 4ae615dbaf..f6d2a0e7bf 100644
--- a/src/plugins/coreplugin/dialogs/externaltoolconfig.ui
+++ b/src/plugins/coreplugin/dialogs/externaltoolconfig.ui
@@ -131,20 +131,37 @@
<widget class="QLineEdit" name="arguments"/>
</item>
<item row="3" column="0">
+ <widget class="QLabel" name="effectiveArgumentsLabel">
+ <property name="text">
+ <string>Effective Arguments:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="effectiveArguments">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
<widget class="QLabel" name="workingDirectoryLabel">
<property name="text">
<string>Working directory:</string>
</property>
</widget>
</item>
- <item row="3" column="1">
+ <item row="4" column="1">
<widget class="Utils::PathChooser" name="workingDirectory">
<property name="expectedKind">
<enum>Utils::PathChooser::Directory</enum>
</property>
</widget>
</item>
- <item row="4" column="0">
+ <item row="5" column="0">
<widget class="QLabel" name="outputLabel">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;
@@ -157,7 +174,7 @@
</property>
</widget>
</item>
- <item row="4" column="1">
+ <item row="5" column="1">
<widget class="QComboBox" name="outputBehavior">
<item>
<property name="text">
@@ -176,7 +193,7 @@
</item>
</widget>
</item>
- <item row="5" column="0">
+ <item row="6" column="0">
<widget class="QLabel" name="errorOutputLabel">
<property name="toolTip">
<string>&lt;html&gt;&lt;head&gt;&lt;body&gt;
@@ -191,7 +208,7 @@
</property>
</widget>
</item>
- <item row="5" column="1">
+ <item row="6" column="1">
<widget class="QComboBox" name="errorOutputBehavior">
<item>
<property name="text">
@@ -210,7 +227,17 @@
</item>
</widget>
</item>
- <item row="7" column="0">
+ <item row="7" column="1">
+ <widget class="QCheckBox" name="modifiesDocumentCheckbox">
+ <property name="toolTip">
+ <string>If the tool modifies the current document, set this flag to ensure that the document is saved before running the tool and is reloaded after the tool finished.</string>
+ </property>
+ <property name="text">
+ <string>Modifies current document</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="0">
<widget class="QLabel" name="inputLabel">
<property name="toolTip">
<string>Text to pass to the executable via standard input. Leave empty if the executable should not receive any input.</string>
@@ -220,23 +247,13 @@
</property>
</widget>
</item>
- <item row="7" column="1">
+ <item row="8" column="1">
<widget class="QPlainTextEdit" name="inputText">
<property name="lineWrapMode">
<enum>QPlainTextEdit::NoWrap</enum>
</property>
</widget>
</item>
- <item row="6" column="1">
- <widget class="QCheckBox" name="modifiesDocumentCheckbox">
- <property name="toolTip">
- <string>If the tool modifies the current document, set this flag to ensure that the document is saved before running the tool and is reloaded after the tool finished.</string>
- </property>
- <property name="text">
- <string>Modifies current document</string>
- </property>
- </widget>
- </item>
</layout>
</widget>
</item>
diff --git a/src/plugins/coreplugin/dialogs/ioptionspage.h b/src/plugins/coreplugin/dialogs/ioptionspage.h
index 2ae753267e..178ca4e66c 100644
--- a/src/plugins/coreplugin/dialogs/ioptionspage.h
+++ b/src/plugins/coreplugin/dialogs/ioptionspage.h
@@ -30,7 +30,7 @@
#ifndef IOPTIONSPAGE_H
#define IOPTIONSPAGE_H
-#include <coreplugin/core_global.h>
+#include <coreplugin/id.h>
#include <QIcon>
#include <QObject>
@@ -44,9 +44,9 @@ class CORE_EXPORT IOptionsPage : public QObject
public:
IOptionsPage(QObject *parent = 0) : QObject(parent) {}
- QString id() const { return m_id; }
+ Id id() const { return m_id; }
QString displayName() const { return m_displayName; }
- QString category() const { return m_category; }
+ Id category() const { return m_category; }
QString displayCategory() const { return m_displayCategory; }
QIcon categoryIcon() const { return QIcon(m_categoryIcon); }
@@ -56,15 +56,15 @@ public:
virtual void finish() = 0;
protected:
- void setId(const QString &id) { m_id = id; }
+ void setId(Id id) { m_id = id; }
void setDisplayName(const QString &displayName) { m_displayName = displayName; }
- void setCategory(const QString &category) { m_category = category; }
+ void setCategory(Id category) { m_category = category; }
void setDisplayCategory(const QString &displayCategory) { m_displayCategory = displayCategory; }
void setCategoryIcon(const QString &categoryIcon) { m_categoryIcon = categoryIcon; }
- QString m_id;
+ Id m_id;
QString m_displayName;
- QString m_category;
+ Id m_category;
QString m_displayCategory;
QString m_categoryIcon;
};
@@ -84,18 +84,18 @@ class CORE_EXPORT IOptionsPageProvider : public QObject
public:
IOptionsPageProvider(QObject *parent = 0) : QObject(parent) {}
- QString category() const { return m_category; }
+ Core::Id category() const { return m_category; }
QString displayCategory() const { return m_displayCategory; }
QIcon categoryIcon() const { return QIcon(m_categoryIcon); }
virtual QList<IOptionsPage *> pages() const = 0;
protected:
- void setCategory(const QString &category) { m_category = category; }
+ void setCategory(Core::Id category) { m_category = category; }
void setDisplayCategory(const QString &displayCategory) { m_displayCategory = displayCategory; }
void setCategoryIcon(const QString &categoryIcon) { m_categoryIcon = categoryIcon; }
- QString m_category;
+ Core::Id m_category;
QString m_displayCategory;
QString m_categoryIcon;
};
diff --git a/src/plugins/coreplugin/dialogs/newdialog.cpp b/src/plugins/coreplugin/dialogs/newdialog.cpp
index b14001c517..260aa80525 100644
--- a/src/plugins/coreplugin/dialogs/newdialog.cpp
+++ b/src/plugins/coreplugin/dialogs/newdialog.cpp
@@ -262,9 +262,8 @@ void NewDialog::setWizards(QList<IWizard*> wizards)
parentItem->appendRow(projectKindItem);
parentItem->appendRow(filesClassesKindItem);
- if (m_dummyIcon.isNull()) {
+ if (m_dummyIcon.isNull())
m_dummyIcon = QIcon(QLatin1String(Core::Constants::ICON_NEWFILE));
- }
QStringList availablePlatforms = IWizard::allAvailablePlatforms();
@@ -311,10 +310,9 @@ Core::IWizard *NewDialog::showDialog()
QModelIndex idx;
if (!lastCategory.isEmpty())
- foreach(QStandardItem* item, m_categoryItems) {
- if (item->data(Qt::UserRole) == lastCategory) {
+ foreach (QStandardItem* item, m_categoryItems) {
+ if (item->data(Qt::UserRole) == lastCategory)
idx = m_twoLevelProxyModel->mapToSource(m_model->indexFromItem(item));
- }
}
if (!idx.isValid())
idx = m_twoLevelProxyModel->index(0,0, m_twoLevelProxyModel->index(0,0));
@@ -390,11 +388,10 @@ void NewDialog::addItem(QStandardItem *topLEvelCategoryItem, IWizard *wizard)
QIcon wizardIcon;
// spacing hack. Add proper icons instead
- if (wizard->icon().isNull()) {
+ if (wizard->icon().isNull())
wizardIcon = m_dummyIcon;
- } else {
+ else
wizardIcon = wizard->icon();
- }
wizardItem->setIcon(wizardIcon);
wizardItem->setData(QVariant::fromValue(WizardContainer(wizard, 0)), Qt::UserRole);
wizardItem->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable);
diff --git a/src/plugins/coreplugin/dialogs/promptoverwritedialog.cpp b/src/plugins/coreplugin/dialogs/promptoverwritedialog.cpp
index 643f66f937..9ec8fd9f3d 100644
--- a/src/plugins/coreplugin/dialogs/promptoverwritedialog.cpp
+++ b/src/plugins/coreplugin/dialogs/promptoverwritedialog.cpp
@@ -127,11 +127,10 @@ void PromptOverwriteDialog::setFileEnabled(const QString &f, bool e)
{
if (QStandardItem *item = itemForFile(f)) {
Qt::ItemFlags flags = item->flags();
- if (e) {
+ if (e)
flags |= Qt::ItemIsEnabled;
- } else {
+ else
flags &= ~Qt::ItemIsEnabled;
- }
item->setFlags(flags);
}
}
diff --git a/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp b/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp
index b22e92416e..2fdd2a01c3 100644
--- a/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp
+++ b/src/plugins/coreplugin/dialogs/saveitemsdialog.cpp
@@ -33,6 +33,7 @@
#include <coreplugin/fileiconprovider.h>
#include <coreplugin/idocument.h>
+#include <utils/hostosinfo.h>
#include <QDir>
#include <QFileInfo>
@@ -53,12 +54,10 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent,
{
m_ui.setupUi(this);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
-#ifdef Q_OS_MAC
+
// QDialogButtonBox's behavior for "destructive" is wrong, the "do not save" should be left-aligned
- QDialogButtonBox::ButtonRole discardButtonRole = QDialogButtonBox::ResetRole;
-#else
- QDialogButtonBox::ButtonRole discardButtonRole = QDialogButtonBox::DestructiveRole;
-#endif
+ const QDialogButtonBox::ButtonRole discardButtonRole = Utils::HostOsInfo::isMacHost()
+ ? QDialogButtonBox::ResetRole : QDialogButtonBox::DestructiveRole;
QPushButton *discardButton = m_ui.buttonBox->addButton(tr("Do not Save"), discardButtonRole);
m_ui.buttonBox->button(QDialogButtonBox::Save)->setDefault(true);
m_ui.treeWidget->setFocus();
@@ -85,9 +84,8 @@ SaveItemsDialog::SaveItemsDialog(QWidget *parent,
m_ui.treeWidget->resizeColumnToContents(0);
m_ui.treeWidget->selectAll();
-#ifdef Q_OS_MAC
- m_ui.treeWidget->setAlternatingRowColors(true);
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ m_ui.treeWidget->setAlternatingRowColors(true);
adjustButtonWidths();
updateSaveButton();
@@ -134,13 +132,13 @@ void SaveItemsDialog::adjustButtonWidths()
if (hint > maxTextWidth)
maxTextWidth = hint;
}
-#ifdef Q_OS_MAC
- QPushButton *cancelButton = m_ui.buttonBox->button(QDialogButtonBox::Cancel);
- int cancelButtonWidth = cancelButton->sizeHint().width();
- if (cancelButtonWidth > maxTextWidth)
- maxTextWidth = cancelButtonWidth;
- cancelButton->setMinimumWidth(maxTextWidth);
-#endif
+ if (Utils::HostOsInfo::isMacHost()) {
+ QPushButton *cancelButton = m_ui.buttonBox->button(QDialogButtonBox::Cancel);
+ int cancelButtonWidth = cancelButton->sizeHint().width();
+ if (cancelButtonWidth > maxTextWidth)
+ maxTextWidth = cancelButtonWidth;
+ cancelButton->setMinimumWidth(maxTextWidth);
+ }
saveButton->setMinimumWidth(maxTextWidth);
}
diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.cpp b/src/plugins/coreplugin/dialogs/settingsdialog.cpp
index 0935413c7f..52a1f1aee9 100644
--- a/src/plugins/coreplugin/dialogs/settingsdialog.cpp
+++ b/src/plugins/coreplugin/dialogs/settingsdialog.cpp
@@ -29,32 +29,34 @@
#include "settingsdialog.h"
-#include <extensionsystem/pluginmanager.h>
#include "icore.h"
+#include <extensionsystem/pluginmanager.h>
+#include <utils/hostosinfo.h>
#include <utils/filterlineedit.h>
-#include <QSettings>
-#include <QSortFilterProxyModel>
-#include <QItemSelectionModel>
+#include <QApplication>
+#include <QDialogButtonBox>
+#include <QFrame>
+#include <QGridLayout>
+#include <QGroupBox>
#include <QHBoxLayout>
#include <QIcon>
+#include <QItemSelectionModel>
#include <QLabel>
+#include <QLineEdit>
+#include <QListView>
+#include <QPointer>
#include <QPushButton>
-#include <QToolButton>
-#include <QToolBar>
#include <QScrollBar>
+#include <QSettings>
+#include <QSortFilterProxyModel>
#include <QSpacerItem>
-#include <QStyle>
#include <QStackedLayout>
-#include <QGridLayout>
-#include <QLineEdit>
-#include <QFrame>
-#include <QDialogButtonBox>
-#include <QListView>
-#include <QApplication>
-#include <QGroupBox>
+#include <QStyle>
#include <QStyledItemDelegate>
+#include <QToolBar>
+#include <QToolButton>
static const char categoryKeyC[] = "General/LastPreferenceCategory";
static const char pageKeyC[] = "General/LastPreferencePage";
@@ -63,13 +65,14 @@ const int categoryIconSize = 24;
namespace Core {
namespace Internal {
-QPointer<SettingsDialog> SettingsDialog::m_instance = 0;
+static QPointer<SettingsDialog> m_instance = 0;
// ----------- Category model
-class Category {
+class Category
+{
public:
- QString id;
+ Id id;
QString displayName;
QIcon icon;
QList<IOptionsPage *> pages;
@@ -92,7 +95,7 @@ public:
const QList<Category*> &categories() const { return m_categories; }
private:
- Category *findCategoryById(const QString &id);
+ Category *findCategoryById(Id id);
QList<Category*> m_categories;
QIcon m_emptyIcon;
@@ -135,13 +138,15 @@ QVariant CategoryModel::data(const QModelIndex &index, int role) const
void CategoryModel::setPages(const QList<IOptionsPage*> &pages,
const QList<IOptionsPageProvider *> &providers)
{
+ beginResetModel();
+
// Clear any previous categories
qDeleteAll(m_categories);
m_categories.clear();
// Put the pages in categories
foreach (IOptionsPage *page, pages) {
- const QString &categoryId = page->category();
+ const Id categoryId = page->category();
Category *category = findCategoryById(categoryId);
if (!category) {
category = new Category;
@@ -158,7 +163,7 @@ void CategoryModel::setPages(const QList<IOptionsPage*> &pages,
}
foreach (IOptionsPageProvider *provider, providers) {
- const QString &categoryId = provider->category();
+ const Id categoryId = provider->category();
Category *category = findCategoryById(categoryId);
if (!category) {
category = new Category;
@@ -174,10 +179,10 @@ void CategoryModel::setPages(const QList<IOptionsPage*> &pages,
category->providers.append(provider);
}
- reset();
+ endResetModel();
}
-Category *CategoryModel::findCategoryById(const QString &id)
+Category *CategoryModel::findCategoryById(Id id)
{
for (int i = 0; i < m_categories.size(); ++i) {
Category *category = m_categories.at(i);
@@ -265,9 +270,9 @@ public:
// Helpers to sort by category. id
bool optionsPageLessThan(const IOptionsPage *p1, const IOptionsPage *p2)
{
- if (const int cc = p1->category().compare(p2->category()))
- return cc < 0;
- return p1->id().compare(p2->id()) < 0;
+ if (p1->category() != p2->category())
+ return p1->category().alphabeticallyBefore(p2->category());
+ return p1->id().alphabeticallyBefore(p2->id());
}
static inline QList<Core::IOptionsPage*> sortedOptionsPages()
@@ -294,11 +299,10 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
createGui();
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
-#ifdef Q_OS_MAC
- setWindowTitle(tr("Preferences"));
-#else
- setWindowTitle(tr("Options"));
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ setWindowTitle(tr("Preferences"));
+ else
+ setWindowTitle(tr("Options"));
m_model->setPages(m_pages,
ExtensionSystem::PluginManager::getObjects<IOptionsPageProvider>());
@@ -323,15 +327,15 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
m_categoryList->setFocus();
}
-void SettingsDialog::showPage(const QString &categoryId, const QString &pageId)
+void SettingsDialog::showPage(Id categoryId, Id pageId)
{
// handle the case of "show last page"
- QString initialCategory = categoryId;
- QString initialPage = pageId;
- if (initialCategory.isEmpty() && initialPage.isEmpty()) {
+ Id initialCategory = categoryId;
+ Id initialPage = pageId;
+ if (!initialCategory.isValid() && !initialPage.isValid()) {
QSettings *settings = ICore::settings();
- initialCategory = settings->value(QLatin1String(categoryKeyC), QVariant(QString())).toString();
- initialPage = settings->value(QLatin1String(pageKeyC), QVariant(QString())).toString();
+ initialCategory = Id::fromSetting(settings->value(QLatin1String(categoryKeyC)));
+ initialPage = Id::fromSetting(settings->value(QLatin1String(pageKeyC)));
}
int initialCategoryIndex = -1;
@@ -459,7 +463,7 @@ void SettingsDialog::updateEnabledTabs(Category *category, const QString &search
for (int i = 0; i < category->pages.size(); ++i) {
const IOptionsPage *page = category->pages.at(i);
const bool enabled = searchText.isEmpty()
- || page->category().contains(searchText, Qt::CaseInsensitive)
+ || page->category().toString().contains(searchText, Qt::CaseInsensitive)
|| page->displayName().contains(searchText, Qt::CaseInsensitive)
|| page->matches(searchText);
category->tabWidget->setTabEnabled(i, enabled);
@@ -538,8 +542,8 @@ void SettingsDialog::apply()
void SettingsDialog::done(int val)
{
QSettings *settings = ICore::settings();
- settings->setValue(QLatin1String(categoryKeyC), m_currentCategory);
- settings->setValue(QLatin1String(pageKeyC), m_currentPage);
+ settings->setValue(QLatin1String(categoryKeyC), m_currentCategory.toSetting());
+ settings->setValue(QLatin1String(pageKeyC), m_currentPage.toSetting());
ICore::saveSettings(); // save all settings
@@ -563,12 +567,10 @@ QSize SettingsDialog::sizeHint() const
}
SettingsDialog *SettingsDialog::getSettingsDialog(QWidget *parent,
- const QString &initialCategory,
- const QString &initialPage)
+ Id initialCategory, Id initialPage)
{
- if (!m_instance) {
+ if (!m_instance)
m_instance = new SettingsDialog(parent);
- }
m_instance->showPage(initialCategory, initialPage);
return m_instance;
}
@@ -600,6 +602,5 @@ bool SettingsDialog::execDialog()
return m_applied;
}
-
} // namespace Internal
} // namespace Core
diff --git a/src/plugins/coreplugin/dialogs/settingsdialog.h b/src/plugins/coreplugin/dialogs/settingsdialog.h
index 121453deeb..3fd145c290 100644
--- a/src/plugins/coreplugin/dialogs/settingsdialog.h
+++ b/src/plugins/coreplugin/dialogs/settingsdialog.h
@@ -31,10 +31,10 @@
#define SETTINGSDIALOG_H
#include "coreplugin/dialogs/ioptionspage.h"
+#include "coreplugin/id.h"
#include <QList>
#include <QSet>
-#include <QPointer>
#include <QEventLoop>
#include <QDialog>
@@ -46,9 +46,7 @@ class QLabel;
class QListView;
QT_END_NAMESPACE
-namespace Utils {
- class FilterLineEdit;
-}
+namespace Utils { class FilterLineEdit; }
namespace Core {
namespace Internal {
@@ -61,13 +59,11 @@ class SettingsDialog : public QDialog
Q_OBJECT
public:
-
// Returns a settings dialog. This makes sure that always only
// a single settings dialog instance is running.
// The dialog will be deleted automatically on close.
static SettingsDialog *getSettingsDialog(QWidget *parent,
- const QString &initialCategory = QString(),
- const QString &initialPage = QString());
+ Id initialCategory, Id initialPage);
// Run the dialog and wait for it to finish.
// Returns if the changes have been applied.
bool execDialog();
@@ -92,18 +88,18 @@ private:
void createGui();
void showCategory(int index);
- void showPage(const QString &categoryId, const QString &pageId);
+ void showPage(Id categoryId, Id pageId);
void updateEnabledTabs(Category *category, const QString &searchText);
void ensureCategoryWidget(Category *category);
void disconnectTabWidgets();
- const QList<Core::IOptionsPage*> m_pages;
+ const QList<IOptionsPage *> m_pages;
- QSet<Core::IOptionsPage*> m_visitedPages;
+ QSet<IOptionsPage *> m_visitedPages;
QSortFilterProxyModel *m_proxyModel;
CategoryModel *m_model;
- QString m_currentCategory;
- QString m_currentPage;
+ Id m_currentCategory;
+ Id m_currentPage;
QStackedLayout *m_stackedLayout;
Utils::FilterLineEdit *m_filterLineEdit;
QListView *m_categoryList;
@@ -112,7 +108,6 @@ private:
bool m_applied;
bool m_finished;
QList<QEventLoop *> m_eventLoops;
- static QPointer<SettingsDialog> m_instance;
};
} // namespace Internal
diff --git a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp
index abb5bb3b92..d75dc1d0d4 100644
--- a/src/plugins/coreplugin/dialogs/shortcutsettings.cpp
+++ b/src/plugins/coreplugin/dialogs/shortcutsettings.cpp
@@ -60,9 +60,9 @@ ShortcutSettings::ShortcutSettings(QObject *parent)
{
connect(ActionManager::instance(), SIGNAL(commandListChanged()), this, SLOT(initialize()));
- setId(QLatin1String(Core::Constants::SETTINGS_ID_SHORTCUTS));
+ setId(Core::Constants::SETTINGS_ID_SHORTCUTS);
setDisplayName(tr("Keyboard"));
- setCategory(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE));
+ setCategory(Core::Constants::SETTINGS_CATEGORY_CORE);
setDisplayCategory(QCoreApplication::translate("Core", Core::Constants::SETTINGS_TR_CATEGORY_CORE));
setCategoryIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
}
@@ -141,7 +141,7 @@ void ShortcutSettings::commandChanged(QTreeWidgetItem *current)
CommandMappings::commandChanged(current);
if (!current || !current->data(0, Qt::UserRole).isValid())
return;
- ShortcutItem *scitem = qVariantValue<ShortcutItem *>(current->data(0, Qt::UserRole));
+ ShortcutItem *scitem = qvariant_cast<ShortcutItem *>(current->data(0, Qt::UserRole));
setKeySequence(scitem->m_key);
}
@@ -149,13 +149,13 @@ void ShortcutSettings::targetIdentifierChanged()
{
QTreeWidgetItem *current = commandList()->currentItem();
if (current && current->data(0, Qt::UserRole).isValid()) {
- ShortcutItem *scitem = qVariantValue<ShortcutItem *>(current->data(0, Qt::UserRole));
+ ShortcutItem *scitem = qvariant_cast<ShortcutItem *>(current->data(0, Qt::UserRole));
scitem->m_key = QKeySequence(m_key[0], m_key[1], m_key[2], m_key[3]);
if (scitem->m_cmd->defaultKeySequence() != scitem->m_key)
setModified(current, true);
else
setModified(current, false);
- current->setText(2, scitem->m_key);
+ current->setText(2, scitem->m_key.toString(QKeySequence::NativeText));
resetCollisionMarker(scitem);
markPossibleCollisions(scitem);
}
@@ -168,14 +168,14 @@ void ShortcutSettings::setKeySequence(const QKeySequence &key)
for (int i = 0; i < m_keyNum; ++i) {
m_key[i] = key[i];
}
- targetEdit()->setText(key);
+ targetEdit()->setText(key.toString(QKeySequence::NativeText));
}
void ShortcutSettings::resetTargetIdentifier()
{
QTreeWidgetItem *current = commandList()->currentItem();
if (current && current->data(0, Qt::UserRole).isValid()) {
- ShortcutItem *scitem = qVariantValue<ShortcutItem *>(current->data(0, Qt::UserRole));
+ ShortcutItem *scitem = qvariant_cast<ShortcutItem *>(current->data(0, Qt::UserRole));
setKeySequence(scitem->m_cmd->defaultKeySequence());
}
}
@@ -200,7 +200,7 @@ void ShortcutSettings::importAction()
QString sid = item->m_cmd->id().toString();
if (mapping.contains(sid)) {
item->m_key = mapping.value(sid);
- item->m_item->setText(2, item->m_key);
+ item->m_item->setText(2, item->m_key.toString(QKeySequence::NativeText));
if (item->m_item == commandList()->currentItem())
commandChanged(item->m_item);
@@ -222,7 +222,7 @@ void ShortcutSettings::defaultAction()
{
foreach (ShortcutItem *item, m_scitems) {
item->m_key = item->m_cmd->defaultKeySequence();
- item->m_item->setText(2, item->m_key);
+ item->m_item->setText(2, item->m_key.toString(QKeySequence::NativeText));
setModified(item->m_item, false);
if (item->m_item == commandList()->currentItem())
commandChanged(item->m_item);
@@ -293,7 +293,7 @@ void ShortcutSettings::initialize()
s->m_key = c->keySequence();
item->setText(0, subId);
item->setText(1, c->description());
- item->setText(2, s->m_key);
+ item->setText(2, s->m_key.toString(QKeySequence::NativeText));
if (s->m_cmd->defaultKeySequence() != s->m_key)
setModified(item, true);
@@ -333,7 +333,7 @@ void ShortcutSettings::handleKeyEvent(QKeyEvent *e)
}
m_keyNum++;
QKeySequence ks(m_key[0], m_key[1], m_key[2], m_key[3]);
- targetEdit()->setText(ks);
+ targetEdit()->setText(ks.toString(QKeySequence::NativeText));
e->accept();
}
@@ -362,7 +362,7 @@ void ShortcutSettings::markPossibleCollisions(ShortcutItem *item)
if (item->m_key.isEmpty())
return;
- int globalId = Context(Constants::C_GLOBAL).at(0);
+ Id globalId = Context(Constants::C_GLOBAL).at(0);
foreach (ShortcutItem *currentItem, m_scitems) {
@@ -371,11 +371,10 @@ void ShortcutSettings::markPossibleCollisions(ShortcutItem *item)
continue;
}
- foreach (int context, currentItem->m_cmd->context()) {
-
+ foreach (Id id, currentItem->m_cmd->context()) {
// conflict if context is identical, OR if one
// of the contexts is the global context
- if (item->m_cmd->context().contains(context) ||
+ if (item->m_cmd->context().contains(id) ||
(item->m_cmd->context().contains(globalId) &&
!currentItem->m_cmd->context().isEmpty()) ||
(currentItem->m_cmd->context().contains(globalId) &&
diff --git a/src/plugins/coreplugin/documentmanager.cpp b/src/plugins/coreplugin/documentmanager.cpp
index f90478d938..3beb2ad964 100644
--- a/src/plugins/coreplugin/documentmanager.cpp
+++ b/src/plugins/coreplugin/documentmanager.cpp
@@ -41,6 +41,7 @@
#include "vcsmanager.h"
#include "coreconstants.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <utils/pathchooser.h>
#include <utils/reloadpromptutils.h>
@@ -96,7 +97,7 @@ static const char editorsKeyC[] = "EditorIds";
static const char directoryGroupC[] = "Directories";
static const char projectDirectoryKeyC[] = "Projects";
static const char useProjectDirectoryKeyC[] = "UseProjectsDirectory";
-
+static const char buildDirectoryKeyC[] = "BuildDirectory.Template";
namespace Core {
@@ -155,6 +156,7 @@ struct DocumentManagerPrivate
QString m_lastVisitedDirectory;
QString m_projectsDirectory;
bool m_useProjectsDirectory;
+ QString m_buildDirectory;
// When we are callling into a IDocument
// we don't want to receive a changed()
// signal
@@ -177,17 +179,17 @@ QFileSystemWatcher *DocumentManagerPrivate::fileWatcher()
QFileSystemWatcher *DocumentManagerPrivate::linkWatcher()
{
-#ifdef Q_OS_UNIX
- if (!m_linkWatcher) {
- m_linkWatcher = new QFileSystemWatcher(m_instance);
- m_linkWatcher->setObjectName(QLatin1String("_qt_autotest_force_engine_poller"));
- QObject::connect(m_linkWatcher, SIGNAL(fileChanged(QString)),
- m_instance, SLOT(changedFile(QString)));
+ if (Utils::HostOsInfo::isAnyUnixHost()) {
+ if (!m_linkWatcher) {
+ m_linkWatcher = new QFileSystemWatcher(m_instance);
+ m_linkWatcher->setObjectName(QLatin1String("_qt_autotest_force_engine_poller"));
+ QObject::connect(m_linkWatcher, SIGNAL(fileChanged(QString)),
+ m_instance, SLOT(changedFile(QString)));
+ }
+ return m_linkWatcher;
}
- return m_linkWatcher;
-#else
+
return fileWatcher();
-#endif
}
DocumentManagerPrivate::DocumentManagerPrivate(QMainWindow *mw) :
@@ -196,11 +198,7 @@ DocumentManagerPrivate::DocumentManagerPrivate(QMainWindow *mw) :
m_linkWatcher(0),
m_blockActivated(false),
m_lastVisitedDirectory(QDir::currentPath()),
-#ifdef Q_OS_MAC // Creator is in bizarre places when launched via finder.
- m_useProjectsDirectory(true),
-#else
- m_useProjectsDirectory(false),
-#endif
+ m_useProjectsDirectory(Utils::HostOsInfo::isMacHost()), // Creator is in bizarre places when launched via finder.
m_blockedIDocument(0)
{
}
@@ -246,10 +244,9 @@ static void addFileInfo(const QString &fileName, IDocument *document, bool isLin
state.modified = fi.lastModified();
state.permissions = fi.permissions();
// Add watcher if we don't have that already
- if (!d->m_states.contains(fileName)) {
+ if (!d->m_states.contains(fileName))
d->m_states.insert(fileName, FileState());
- }
QFileSystemWatcher *watcher = 0;
if (isLink)
watcher = d->linkWatcher();
@@ -488,9 +485,8 @@ QString DocumentManager::fixFileName(const QString &fileName, FixMode fixmode)
s = QDir::cleanPath(s);
}
s = QDir::toNativeSeparators(s);
-#ifdef Q_OS_WIN
- s = s.toLower();
-#endif
+ if (Utils::HostOsInfo::isWindowsHost())
+ s = s.toLower();
return s;
}
@@ -863,9 +859,8 @@ void DocumentManager::changedFile(const QString &fileName)
if (d->m_states.contains(fileName))
d->m_changedFiles.insert(fileName);
- if (wasempty && !d->m_changedFiles.isEmpty()) {
+ if (wasempty && !d->m_changedFiles.isEmpty())
QTimer::singleShot(200, this, SLOT(checkForReload()));
- }
}
void DocumentManager::mainWindowActivated()
@@ -966,11 +961,10 @@ void DocumentManager::checkForReload()
// find out the type
IDocument::ChangeType fileChange = changeTypes.value(fileName);
- if (fileChange == IDocument::TypeRemoved) {
+ if (fileChange == IDocument::TypeRemoved)
type = IDocument::TypeRemoved;
- } else if (fileChange == IDocument::TypeContents && type == IDocument::TypePermissions) {
+ else if (fileChange == IDocument::TypeContents && type == IDocument::TypePermissions)
type = IDocument::TypeContents;
- }
}
if (!changed) // probably because the change was blocked with (un)blockFileChange
@@ -1169,6 +1163,7 @@ void DocumentManager::saveSettings()
s->beginGroup(QLatin1String(directoryGroupC));
s->setValue(QLatin1String(projectDirectoryKeyC), d->m_projectsDirectory);
s->setValue(QLatin1String(useProjectDirectoryKeyC), d->m_useProjectsDirectory);
+ s->setValue(QLatin1String(buildDirectoryKeyC), d->m_buildDirectory);
s->endGroup();
}
@@ -1188,19 +1183,26 @@ void readSettings()
editorId = ids.next();
if (QFileInfo(fileName).isFile())
d->m_recentFiles.append(DocumentManager::RecentFile(QDir::fromNativeSeparators(fileName), // from native to guard against old settings
- Id(editorId)));
+ Id::fromString(editorId)));
}
s->beginGroup(QLatin1String(directoryGroupC));
const QString settingsProjectDir = s->value(QLatin1String(projectDirectoryKeyC),
QString()).toString();
- if (!settingsProjectDir.isEmpty() && QFileInfo(settingsProjectDir).isDir()) {
+ if (!settingsProjectDir.isEmpty() && QFileInfo(settingsProjectDir).isDir())
d->m_projectsDirectory = settingsProjectDir;
- } else {
+ else
d->m_projectsDirectory = Utils::PathChooser::homePath();
- }
d->m_useProjectsDirectory = s->value(QLatin1String(useProjectDirectoryKeyC),
d->m_useProjectsDirectory).toBool();
+
+ const QString settingsShadowDir = s->value(QLatin1String(buildDirectoryKeyC),
+ QString()).toString();
+ if (!settingsShadowDir.isEmpty())
+ d->m_buildDirectory = settingsShadowDir;
+ else
+ d->m_buildDirectory = QLatin1String(Constants::DEFAULT_BUILD_DIRECTORY);
+
s->endGroup();
}
@@ -1272,6 +1274,26 @@ void DocumentManager::setProjectsDirectory(const QString &dir)
}
/*!
+ Returns the default build directory.
+
+ \sa setBuildDirectory
+*/
+QString DocumentManager::buildDirectory()
+{
+ return d->m_buildDirectory;
+}
+
+/*!
+ Sets the shadow build directory to \a directory.
+
+ \sa buildDirectory
+*/
+void DocumentManager::setBuildDirectory(const QString &directory)
+{
+ d->m_buildDirectory = directory;
+}
+
+/*!
Returns whether the directory for projects is to be
used or the user wants the current directory.
@@ -1369,7 +1391,7 @@ void DocumentManager::executeOpenWithMenuAction(QAction *action)
{
QTC_ASSERT(action, return);
const QVariant data = action->data();
- OpenWithEntry entry = qVariantValue<OpenWithEntry>(data);
+ OpenWithEntry entry = qvariant_cast<OpenWithEntry>(data);
if (entry.editorFactory) {
// close any open editors that have this file open, but have a different type.
EditorManager *em = EditorManager::instance();
diff --git a/src/plugins/coreplugin/documentmanager.h b/src/plugins/coreplugin/documentmanager.h
index 48669b7d32..2a46c0897a 100644
--- a/src/plugins/coreplugin/documentmanager.h
+++ b/src/plugins/coreplugin/documentmanager.h
@@ -129,6 +129,9 @@ public:
static QString projectsDirectory();
static void setProjectsDirectory(const QString &);
+ static QString buildDirectory();
+ static void setBuildDirectory(const QString &directory);
+
static void populateOpenWithMenu(QMenu *menu, const QString &fileName);
/* Used to notify e.g. the code model to update the given files. Does *not*
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index 66d0e27493..d961e59132 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -60,6 +60,7 @@
#include <extensionsystem/pluginmanager.h>
#include <utils/consoleprocess.h>
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QDateTime>
@@ -89,6 +90,7 @@ static const char kCurrentDocumentFilePath[] = "CurrentDocument:FilePath";
static const char kCurrentDocumentPath[] = "CurrentDocument:Path";
static const char kCurrentDocumentXPos[] = "CurrentDocument:XPos";
static const char kCurrentDocumentYPos[] = "CurrentDocument:YPos";
+static const char kMakeWritableWarning[] = "Core.EditorManager.MakeWritable";
//===================EditorClosingCoreListener======================
@@ -204,6 +206,10 @@ struct EditorManagerPrivate
QAction *m_removeAllSplitsAction;
QAction *m_gotoOtherSplitAction;
+ QAction *m_saveCurrentEditorContextAction;
+ QAction *m_saveAsCurrentEditorContextAction;
+ QAction *m_revertToSavedCurrentEditorContextAction;
+
QAction *m_closeCurrentEditorContextAction;
QAction *m_closeAllEditorsContextAction;
QAction *m_closeOtherEditorsContextAction;
@@ -242,6 +248,9 @@ EditorManagerPrivate::EditorManagerPrivate(QWidget *parent) :
m_gotoPreviousDocHistoryAction(new QAction(EditorManager::tr("Previous Open Document in History"), parent)),
m_goBackAction(new QAction(QIcon(QLatin1String(Constants::ICON_PREV)), EditorManager::tr("Go Back"), parent)),
m_goForwardAction(new QAction(QIcon(QLatin1String(Constants::ICON_NEXT)), EditorManager::tr("Go Forward"), parent)),
+ m_saveCurrentEditorContextAction(new QAction(EditorManager::tr("&Save"), parent)),
+ m_saveAsCurrentEditorContextAction(new QAction(EditorManager::tr("Save &As..."), parent)),
+ m_revertToSavedCurrentEditorContextAction(new QAction(EditorManager::tr("Revert to Saved"), parent)),
m_closeCurrentEditorContextAction(new QAction(EditorManager::tr("Close"), parent)),
m_closeAllEditorsContextAction(new QAction(EditorManager::tr("Close All"), parent)),
m_closeOtherEditorsContextAction(new QAction(EditorManager::tr("Close Others"), parent)),
@@ -333,6 +342,11 @@ EditorManager::EditorManager(QWidget *parent) :
cmd->setAttribute(Core::Command::CA_UpdateText);
connect(d->m_closeOtherEditorsAction, SIGNAL(triggered()), this, SLOT(closeOtherEditors()));
+ //Save XXX Context Actions
+ connect(d->m_saveCurrentEditorContextAction, SIGNAL(triggered()), this, SLOT(saveDocumentFromContextMenu()));
+ connect(d->m_saveAsCurrentEditorContextAction, SIGNAL(triggered()), this, SLOT(saveDocumentAsFromContextMenu()));
+ connect(d->m_revertToSavedCurrentEditorContextAction, SIGNAL(triggered()), this, SLOT(revertToSavedFromContextMenu()));
+
// Close XXX Context Actions
connect(d->m_closeAllEditorsContextAction, SIGNAL(triggered()), this, SLOT(closeAllEditors()));
connect(d->m_closeCurrentEditorContextAction, SIGNAL(triggered()), this, SLOT(closeEditorFromContextMenu()));
@@ -492,11 +506,10 @@ void EditorManager::handleContextChange(Core::IContext *context)
if (debugEditorManager)
qDebug() << Q_FUNC_INFO;
IEditor *editor = context ? qobject_cast<IEditor*>(context) : 0;
- if (editor) {
+ if (editor)
setCurrentEditor(editor);
- } else {
+ else
updateActions();
- }
}
void EditorManager::setCurrentEditor(IEditor *editor, bool ignoreNavigationHistory)
@@ -631,9 +644,8 @@ void EditorManager::closeView(Core::Internal::EditorView *view)
*/
if (!d->m_editorModel->isDuplicate(e)) {
QList<IEditor *> duplicates = d->m_editorModel->duplicatesFor(e);
- if (!duplicates.isEmpty()) {
+ if (!duplicates.isEmpty())
d->m_editorModel->makeOriginal(duplicates.first());
- }
}
}
@@ -651,11 +663,10 @@ void EditorManager::closeView(Core::Internal::EditorView *view)
SplitterOrView *newCurrent = splitter->findFirstView();
if (newCurrent) {
- if (IEditor *e = newCurrent->editor()) {
+ if (IEditor *e = newCurrent->editor())
activateEditor(newCurrent->view(), e);
- } else {
+ else
setCurrentView(newCurrent);
- }
}
}
@@ -666,9 +677,8 @@ QList<IEditor*>
QSet<IEditor *> found;
foreach (IDocument *document, documents) {
foreach (IEditor *editor, editors) {
- if (editor->document() == document && !found.contains(editor)) {
+ if (editor->document() == document && !found.contains(editor))
found << editor;
- }
}
}
return found.toList();
@@ -721,10 +731,37 @@ void EditorManager::closeEditor()
closeEditor(d->m_currentEditor);
}
-void EditorManager::addCloseEditorActions(QMenu *contextMenu, const QModelIndex &editorIndex)
+static void assignAction(QAction *self, QAction *other)
+{
+ self->setText(other->text());
+ self->setIcon(other->icon());
+ self->setShortcut(other->shortcut());
+ self->setEnabled(other->isEnabled());
+}
+
+void EditorManager::addSaveAndCloseEditorActions(QMenu *contextMenu, const QModelIndex &editorIndex)
{
QTC_ASSERT(contextMenu, return);
d->m_contextMenuEditorIndex = editorIndex;
+
+ assignAction(d->m_saveCurrentEditorContextAction, ActionManager::command(Constants::SAVE)->action());
+ assignAction(d->m_saveAsCurrentEditorContextAction, ActionManager::command(Constants::SAVEAS)->action());
+ assignAction(d->m_revertToSavedCurrentEditorContextAction, ActionManager::command(Constants::REVERTTOSAVED)->action());
+
+ IEditor *editor = d->m_contextMenuEditorIndex.data(Qt::UserRole).value<Core::IEditor*>();
+
+ setupSaveActions(editor,
+ d->m_saveCurrentEditorContextAction,
+ d->m_saveAsCurrentEditorContextAction,
+ d->m_revertToSavedCurrentEditorContextAction);
+
+ contextMenu->addAction(d->m_saveCurrentEditorContextAction);
+ contextMenu->addAction(d->m_saveAsCurrentEditorContextAction);
+ contextMenu->addAction(ActionManager::command(Constants::SAVEALL)->action());
+ contextMenu->addAction(d->m_revertToSavedCurrentEditorContextAction);
+
+ contextMenu->addSeparator();
+
d->m_closeCurrentEditorContextAction->setText(editorIndex.isValid()
? tr("Close \"%1\"").arg(editorIndex.data().toString())
: tr("Close Editor"));
@@ -748,6 +785,27 @@ void EditorManager::addNativeDirActions(QMenu *contextMenu, const QModelIndex &e
contextMenu->addAction(d->m_openTerminalAction);
}
+void EditorManager::saveDocumentFromContextMenu()
+{
+ IEditor *editor = d->m_contextMenuEditorIndex.data(Qt::UserRole).value<Core::IEditor*>();
+ if (editor)
+ saveDocument(editor->document());
+}
+
+void EditorManager::saveDocumentAsFromContextMenu()
+{
+ IEditor *editor = d->m_contextMenuEditorIndex.data(Qt::UserRole).value<Core::IEditor*>();
+ if (editor)
+ saveDocumentAs(editor->document());
+}
+
+void EditorManager::revertToSavedFromContextMenu()
+{
+ IEditor *editor = d->m_contextMenuEditorIndex.data(Qt::UserRole).value<Core::IEditor*>();
+ if (editor)
+ revertToSaved(editor);
+}
+
void EditorManager::closeEditorFromContextMenu()
{
closeEditor(d->m_contextMenuEditorIndex);
@@ -831,7 +889,7 @@ bool EditorManager::closeEditors(const QList<IEditor*> &editorsToClose, bool ask
// add duplicates
QList<IEditor *> duplicates;
- foreach(IEditor *editor, acceptedEditors)
+ foreach (IEditor *editor, acceptedEditors)
duplicates += d->m_editorModel->duplicatesFor(editor);
acceptedEditors += duplicates;
@@ -913,7 +971,7 @@ void EditorManager::closeDuplicate(Core::IEditor *editor)
emit editorAboutToClose(editor);
- if(d->m_splitter->findView(editor)) {
+ if (d->m_splitter->findView(editor)) {
EditorView *view = d->m_splitter->findView(editor)->view();
removeEditor(editor);
view->removeEditor(editor);
@@ -983,9 +1041,8 @@ Core::IEditor *EditorManager::placeEditor(Core::Internal::EditorView *view, Core
view->addEditor(editor);
view->setCurrentEditor(editor);
if (!sourceView->editor()) {
- if (IEditor *replacement = pickUnusedEditor()) {
+ if (IEditor *replacement = pickUnusedEditor())
sourceView->view()->addEditor(replacement);
- }
}
return editor;
} else if (duplicateSupported) {
@@ -1023,9 +1080,8 @@ Core::IEditor *EditorManager::activateEditor(Core::Internal::EditorView *view, C
if (!(flags & NoActivate)) {
setCurrentEditor(editor, (flags & IgnoreNavigationHistory));
- if (flags & ModeSwitch) {
+ if (flags & ModeSwitch)
switchToPreferedMode();
- }
if (isVisible())
editor->widget()->setFocus();
}
@@ -1105,7 +1161,7 @@ template <class EditorFactoryLike>
EditorFactoryLike *findById(const Core::Id &id)
{
const QList<EditorFactoryLike *> factories = ExtensionSystem::PluginManager::getObjects<EditorFactoryLike>();
- foreach(EditorFactoryLike *efl, factories)
+ foreach (EditorFactoryLike *efl, factories)
if (id == efl->id())
return efl;
return 0;
@@ -1176,14 +1232,14 @@ Core::Id EditorManager::getOpenWithEditorId(const QString &fileName,
//Unable to determine mime type of fileName. Falling back to text/plain",
if (!mt)
mt = ICore::mimeDatabase()->findByType(QLatin1String("text/plain"));
- QStringList allEditorIds;
+ QList<Id> allEditorIds;
QStringList allEditorDisplayNames;
QList<Id> externalEditorIds;
// Built-in
const EditorFactoryList editors = editorFactories(mt, false);
const int size = editors.size();
for (int i = 0; i < size; i++) {
- allEditorIds.push_back(editors.at(i)->id().toString());
+ allEditorIds.push_back(editors.at(i)->id());
allEditorDisplayNames.push_back(editors.at(i)->displayName());
}
// External editors
@@ -1191,7 +1247,7 @@ Core::Id EditorManager::getOpenWithEditorId(const QString &fileName,
const int esize = exEditors.size();
for (int i = 0; i < esize; i++) {
externalEditorIds.push_back(exEditors.at(i)->id());
- allEditorIds.push_back(exEditors.at(i)->id().toString());
+ allEditorIds.push_back(exEditors.at(i)->id());
allEditorDisplayNames.push_back(exEditors.at(i)->displayName());
}
if (allEditorIds.empty())
@@ -1203,7 +1259,7 @@ Core::Id EditorManager::getOpenWithEditorId(const QString &fileName,
dialog.setCurrentEditor(0);
if (dialog.exec() != QDialog::Accepted)
return Id();
- const Id selectedId = Id(allEditorIds.at(dialog.editor()));
+ const Id selectedId = allEditorIds.at(dialog.editor());
if (isExternalEditor)
*isExternalEditor = externalEditorIds.contains(selectedId);
return selectedId;
@@ -1394,11 +1450,10 @@ IEditor *EditorManager::openEditorWithContents(const Id &editorId,
QSet<QString> docnames;
foreach (IEditor *editor, m_instance->openedEditors()) {
QString name = editor->document()->fileName();
- if (name.isEmpty()) {
+ if (name.isEmpty())
name = editor->displayName();
- } else {
+ else
name = QFileInfo(name).completeBaseName();
- }
docnames << name;
}
@@ -1485,9 +1540,8 @@ bool EditorManager::saveDocument(IDocument *documentParam)
success = DocumentManager::saveDocument(document);
}
- if (success) {
+ if (success)
addDocumentToRecentFiles(document);
- }
return success;
}
@@ -1567,9 +1621,8 @@ bool EditorManager::saveDocumentAs(IDocument *documentParam)
if (absoluteFilePath != document->fileName()) {
// close existing editors for the new file name
const QList<IEditor *> existList = editorsForFileName(absoluteFilePath);
- if (!existList.isEmpty()) {
+ if (!existList.isEmpty())
closeEditors(existList, false);
- }
}
const bool success = DocumentManager::saveDocument(document, absoluteFilePath);
@@ -1658,9 +1711,8 @@ void EditorManager::updateWindowTitle()
{
QString windowTitle = tr("Qt Creator");
const QString dashSep = QLatin1String(" - ");
- if (!d->m_titleAddition.isEmpty()) {
+ if (!d->m_titleAddition.isEmpty())
windowTitle.prepend(d->m_titleAddition + dashSep);
- }
IEditor *curEditor = currentEditor();
if (curEditor) {
QString editorName = curEditor->displayName();
@@ -1688,80 +1740,101 @@ void EditorManager::handleEditorStateChange()
}
}
-void EditorManager::updateActions()
+void EditorManager::updateMakeWritableWarning()
{
- QString fName;
IEditor *curEditor = currentEditor();
- int openedCount = openedEditors().count() + d->m_editorModel->restoredEditors().count();
-
- if (curEditor) {
+ bool ww = curEditor->document()->isModified() && curEditor->document()->isFileReadOnly();
+ if (ww != curEditor->document()->hasWriteWarning()) {
+ curEditor->document()->setWriteWarning(ww);
+
+ // Do this after setWriteWarning so we don't re-evaluate this part even
+ // if we do not really show a warning.
+ bool promptVCS = false;
+ const QString directory = QFileInfo(curEditor->document()->fileName()).absolutePath();
+ IVersionControl *versionControl = ICore::vcsManager()->findVersionControlForDirectory(directory);
+ if (versionControl && versionControl->supportsOperation(IVersionControl::OpenOperation)) {
+ if (versionControl->settingsFlags() & IVersionControl::AutoOpen) {
+ vcsOpenCurrentEditor();
+ ww = false;
+ } else {
+ promptVCS = true;
+ }
+ }
- if (!curEditor->document()->fileName().isEmpty()) {
- QFileInfo fi(curEditor->document()->fileName());
- fName = fi.fileName();
+ if (ww) {
+ // we are about to change a read-only file, warn user
+ if (promptVCS) {
+ 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(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 {
- fName = curEditor->displayName();
+ curEditor->document()->infoBar()->removeInfo(Id(kMakeWritableWarning));
}
+ }
+}
-#ifdef Q_OS_MAC
- window()->setWindowModified(curEditor->document()->isModified());
-#endif
- bool ww = curEditor->document()->isModified() && curEditor->document()->isFileReadOnly();
- if (ww != curEditor->document()->hasWriteWarning()) {
- curEditor->document()->setWriteWarning(ww);
-
- // Do this after setWriteWarning so we don't re-evaluate this part even
- // if we do not really show a warning.
- bool promptVCS = false;
- const QString directory = QFileInfo(curEditor->document()->fileName()).absolutePath();
- IVersionControl *versionControl = ICore::vcsManager()->findVersionControlForDirectory(directory);
- if (versionControl && versionControl->supportsOperation(IVersionControl::OpenOperation)) {
- if (versionControl->settingsFlags() & IVersionControl::AutoOpen) {
- vcsOpenCurrentEditor();
- ww = false;
- } else {
- promptVCS = true;
- }
- }
+QString EditorManager::fileNameForEditor(IEditor *editor)
+{
+ QString fileName;
- if (ww) {
- // we are about to change a read-only file, warn user
- if (promptVCS) {
- InfoBarEntry info(QLatin1String("Core.EditorManager.MakeWritable"),
- 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("Core.EditorManager.MakeWritable"),
- 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("Core.EditorManager.MakeWritable"));
- }
+ if (editor) {
+ if (!editor->document()->fileName().isEmpty()) {
+ QFileInfo fileInfo(editor->document()->fileName());
+ fileName = fileInfo.fileName();
+ } else {
+ fileName = editor->displayName();
}
-#ifdef Q_OS_MAC
- } else { // curEditor
+ }
+ return fileName;
+}
+
+void EditorManager::setupSaveActions(IEditor *editor, QAction *saveAction, QAction *saveAsAction, QAction *revertToSavedAction)
+{
+ saveAction->setEnabled(editor != 0 && editor->document()->isModified());
+ saveAsAction->setEnabled(editor != 0 && editor->document()->isSaveAsAllowed());
+ revertToSavedAction->setEnabled(editor != 0
+ && !editor->document()->fileName().isEmpty() && editor->document()->isModified());
+
+ const QString fileName = fileNameForEditor(editor);
+ QString quotedName;
+
+ if (!fileName.isEmpty())
+ quotedName = QLatin1Char('"') + fileName + QLatin1Char('"');
+ if (!quotedName.isEmpty()) {
+ saveAction->setText(tr("&Save %1").arg(quotedName));
+ saveAsAction->setText(tr("Save %1 &As...").arg(quotedName));
+ revertToSavedAction->setText(tr("Revert %1 to Saved").arg(quotedName));
+ }
+}
+
+void EditorManager::updateActions()
+{
+ IEditor *curEditor = currentEditor();
+ const QString fileName = fileNameForEditor(curEditor);
+ int openedCount = openedEditors().count() + d->m_editorModel->restoredEditors().count();
+
+ if (curEditor) {
+ if (HostOsInfo::isMacHost())
+ window()->setWindowModified(curEditor->document()->isModified());
+ updateMakeWritableWarning();
+ } else /* curEditor */ if (HostOsInfo::isMacHost()) {
window()->setWindowModified(false);
-#endif
}
setCloseSplitEnabled(d->m_splitter, d->m_splitter->isSplitter());
- d->m_saveAction->setEnabled(curEditor != 0 && curEditor->document()->isModified());
- d->m_saveAsAction->setEnabled(curEditor != 0 && curEditor->document()->isSaveAsAllowed());
- d->m_revertToSavedAction->setEnabled(curEditor != 0
- && !curEditor->document()->fileName().isEmpty() && curEditor->document()->isModified());
-
QString quotedName;
- if (!fName.isEmpty())
- quotedName = QLatin1Char('"') + fName + QLatin1Char('"');
-
- d->m_saveAsAction->setText(tr("Save %1 &As...").arg(quotedName));
- d->m_saveAction->setText(tr("&Save %1").arg(quotedName));
- d->m_revertToSavedAction->setText(tr("Revert %1 to Saved").arg(quotedName));
+ if (!fileName.isEmpty())
+ quotedName = QLatin1Char('"') + fileName + QLatin1Char('"');
+ setupSaveActions(curEditor, d->m_saveAction, d->m_saveAsAction, d->m_revertToSavedAction);
d->m_closeCurrentEditorAction->setEnabled(curEditor != 0);
d->m_closeCurrentEditorAction->setText(tr("Close %1").arg(quotedName));
@@ -1813,9 +1886,8 @@ QList<IEditor*> EditorManager::visibleEditors() const
} while (view && view != firstView);
}
} else {
- if (d->m_splitter->editor()) {
+ if (d->m_splitter->editor())
editors.append(d->m_splitter->editor());
- }
}
return editors;
}
@@ -1946,11 +2018,10 @@ bool EditorManager::restoreState(const QByteArray &state)
if (!fi.exists())
continue;
QFileInfo rfi(autoSaveName(fileName));
- if (rfi.exists() && fi.lastModified() < rfi.lastModified()) {
- openEditor(fileName, Id(QString::fromUtf8(id)));
- } else {
- d->m_editorModel->addRestoredEditor(fileName, displayName, Id(QString::fromUtf8(id)));
- }
+ if (rfi.exists() && fi.lastModified() < rfi.lastModified())
+ openEditor(fileName, Id::fromName(id));
+ else
+ d->m_editorModel->addRestoredEditor(fileName, displayName, Id::fromName(id));
}
}
@@ -2015,13 +2086,17 @@ void EditorManager::readSettings()
void EditorManager::revertToSaved()
{
- IEditor *currEditor = currentEditor();
- if (!currEditor)
+ revertToSaved(currentEditor());
+}
+
+void EditorManager::revertToSaved(Core::IEditor *editor)
+{
+ if (!editor)
return;
- const QString fileName = currEditor->document()->fileName();
+ const QString fileName = editor->document()->fileName();
if (fileName.isEmpty())
return;
- if (currEditor->document()->isModified()) {
+ if (editor->document()->isModified()) {
QMessageBox msgBox(QMessageBox::Question, tr("Revert to Saved"),
tr("You will lose your current changes if you proceed reverting %1.").arg(QDir::toNativeSeparators(fileName)),
QMessageBox::Yes|QMessageBox::No, ICore::mainWindow());
@@ -2034,7 +2109,7 @@ void EditorManager::revertToSaved()
}
QString errorString;
- if (!currEditor->document()->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents))
+ if (!editor->document()->reload(&errorString, IDocument::FlagReload, IDocument::TypeContents))
QMessageBox::critical(ICore::mainWindow(), tr("File Error"), errorString);
}
diff --git a/src/plugins/coreplugin/editormanager/editormanager.h b/src/plugins/coreplugin/editormanager/editormanager.h
index a4cf644548..3a54a38501 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.h
+++ b/src/plugins/coreplugin/editormanager/editormanager.h
@@ -186,7 +186,7 @@ public:
void setWindowTitleAddition(const QString &addition);
QString windowTitleAddition() const;
- void addCloseEditorActions(QMenu *contextMenu, const QModelIndex &editorIndex);
+ void addSaveAndCloseEditorActions(QMenu *contextMenu, const QModelIndex &editorIndex);
void addNativeDirActions(QMenu *contextMenu, const QModelIndex &editorIndex);
signals:
@@ -203,6 +203,7 @@ public slots:
bool saveDocument(Core::IDocument *documentParam = 0);
bool saveDocumentAs(Core::IDocument *documentParam = 0);
void revertToSaved();
+ void revertToSaved(Core::IEditor *editor);
void closeEditor();
void closeOtherEditors();
@@ -218,6 +219,10 @@ private slots:
void updateVariable(const QByteArray &variable);
void autoSave();
+ void saveDocumentFromContextMenu();
+ void saveDocumentAsFromContextMenu();
+ void revertToSavedFromContextMenu();
+
void closeEditorFromContextMenu();
void closeOtherEditorsFromContextMenu();
@@ -263,6 +268,9 @@ private:
void switchToPreferedMode();
void updateAutoSave();
void setCloseSplitEnabled(Internal::SplitterOrView *splitterOrView, bool enable);
+ void updateMakeWritableWarning();
+ QString fileNameForEditor(IEditor *editor);
+ void setupSaveActions(IEditor *editor, QAction *saveAction, QAction *saveAsAction, QAction *revertToSavedAction);
EditorManagerPrivate *d;
diff --git a/src/plugins/coreplugin/editormanager/editorview.cpp b/src/plugins/coreplugin/editormanager/editorview.cpp
index 5a9b84168a..8529541e35 100644
--- a/src/plugins/coreplugin/editormanager/editorview.cpp
+++ b/src/plugins/coreplugin/editormanager/editorview.cpp
@@ -301,7 +301,7 @@ void EditorView::updateEditorHistory(IEditor *editor)
location.id = editor->id();
location.state = QVariant(state);
- for(int i = 0; i < m_editorHistory.size(); ++i) {
+ for (int i = 0; i < m_editorHistory.size(); ++i) {
if (m_editorHistory.at(i).document == 0
|| m_editorHistory.at(i).document == document
){
@@ -320,9 +320,8 @@ QRect EditorView::editorArea() const
void EditorView::addCurrentPositionToNavigationHistory(IEditor *editor, const QByteArray &saveState)
{
- if (editor && editor != currentEditor()) {
+ if (editor && editor != currentEditor())
return; // we only save editor sate for the current editor, when the user interacts
- }
if (!editor)
editor = currentEditor();
@@ -334,11 +333,10 @@ void EditorView::addCurrentPositionToNavigationHistory(IEditor *editor, const QB
return;
QByteArray state;
- if (saveState.isNull()) {
+ if (saveState.isNull())
state = editor->saveState();
- } else {
+ else
state = saveState;
- }
EditLocation location;
location.document = document;
@@ -606,9 +604,8 @@ SplitterOrView *SplitterOrView::findNextView(SplitterOrView *view)
SplitterOrView *SplitterOrView::findNextView_helper(SplitterOrView *view, bool *found)
{
- if (*found && m_view) {
+ if (*found && m_view)
return this;
- }
if (this == view) {
*found = true;
@@ -664,7 +661,7 @@ void SplitterOrView::split(Qt::Orientation orientation)
SplitterOrView *otherView = 0;
if (e) {
- foreach(IEditor *editor, m_view->editors())
+ foreach (IEditor *editor, m_view->editors())
m_view->removeEditor(editor);
m_splitter->addWidget((view = new SplitterOrView(e)));
@@ -721,9 +718,8 @@ void SplitterOrView::unsplitAll_helper()
ICore::editorManager()->emptyView(m_view);
if (m_splitter) {
for (int i = 0; i < m_splitter->count(); ++i) {
- if (SplitterOrView *splitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(i))) {
+ if (SplitterOrView *splitterOrView = qobject_cast<SplitterOrView*>(m_splitter->widget(i)))
splitterOrView->unsplitAll_helper();
- }
}
}
}
@@ -762,14 +758,14 @@ void SplitterOrView::unsplit()
if (parentSplitter) { // not the toplevel splitterOrView
if (parentSplitter->orientation() == Qt::Horizontal) {
if (parentSplitter->widget(0) == this)
- m_view->setCloseSplitIcon(QIcon(Constants::ICON_CLOSE_SPLIT_LEFT));
+ m_view->setCloseSplitIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_LEFT)));
else
- m_view->setCloseSplitIcon(QIcon(Constants::ICON_CLOSE_SPLIT_RIGHT));
+ m_view->setCloseSplitIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_RIGHT)));
} else {
if (parentSplitter->widget(0) == this)
- m_view->setCloseSplitIcon(QIcon(Constants::ICON_CLOSE_SPLIT_TOP));
+ m_view->setCloseSplitIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_TOP)));
else
- m_view->setCloseSplitIcon(QIcon(Constants::ICON_CLOSE_SPLIT_BOTTOM));
+ m_view->setCloseSplitIcon(QIcon(QLatin1String(Constants::ICON_CLOSE_SPLIT_BOTTOM)));
}
}
}
@@ -840,7 +836,7 @@ void SplitterOrView::restoreState(const QByteArray &state)
stream >> fileName >> id >> editorState;
if (!QFile::exists(fileName))
return;
- IEditor *e = em->openEditor(view(), fileName, Id(id), Core::EditorManager::IgnoreNavigationHistory
+ IEditor *e = em->openEditor(view(), fileName, Id::fromString(id), Core::EditorManager::IgnoreNavigationHistory
| Core::EditorManager::NoActivate);
if (!e) {
diff --git a/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp b/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
index 6fc73272e3..a9a3183831 100644
--- a/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
@@ -235,9 +235,8 @@ QList<OpenEditorsModel::Entry> OpenEditorsModel::restoredEditors() const
{
QList<Entry> result;
for (int i = d->m_editors.count()-1; i >= 0; --i) {
- if (!d->m_editors.at(i).editor) {
+ if (!d->m_editors.at(i).editor)
result.append(d->m_editors.at(i));
- }
}
return result;
}
@@ -250,7 +249,7 @@ bool OpenEditorsModel::isDuplicate(IEditor *editor) const
IEditor *OpenEditorsModel::originalForDuplicate(IEditor *duplicate) const
{
IDocument *document = duplicate->document();
- foreach(const Entry &e, d->m_editors)
+ foreach (const Entry &e, d->m_editors)
if (e.editor && e.editor->document() == document)
return e.editor;
return 0;
@@ -260,7 +259,7 @@ QList<IEditor *> OpenEditorsModel::duplicatesFor(IEditor *editor) const
{
QList<IEditor *> result;
IDocument *document = editor->document();
- foreach(IEditor *e, d->m_duplicateEditors)
+ foreach (IEditor *e, d->m_duplicateEditors)
if (e->document() == document)
result += e;
return result;
diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.cpp b/src/plugins/coreplugin/editormanager/openeditorsview.cpp
index c30ace1f86..b65fe1c25f 100644
--- a/src/plugins/coreplugin/editormanager/openeditorsview.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorsview.cpp
@@ -41,6 +41,8 @@
#include <coreplugin/actionmanager/command.h>
#include <utils/qtcassert.h>
+#include <QApplication>
+#include <QGridLayout>
#include <QTimer>
#include <QMenu>
#include <QPainter>
@@ -48,6 +50,7 @@
#include <QStyleOption>
#include <QHeaderView>
#include <QKeyEvent>
+#include <QTreeView>
using namespace Core;
using namespace Core::Internal;
@@ -93,36 +96,36 @@ void OpenEditorsDelegate::paint(QPainter *painter, const QStyleOptionViewItem &o
OpenEditorsWidget::OpenEditorsWidget()
{
- m_ui.setupUi(this);
setWindowTitle(tr("Open Documents"));
setWindowIcon(QIcon(QLatin1String(Constants::ICON_DIR)));
- setFocusProxy(m_ui.editorList);
- m_ui.editorList->viewport()->setAttribute(Qt::WA_Hover);
- m_ui.editorList->setItemDelegate((m_delegate = new OpenEditorsDelegate(this)));
- m_ui.editorList->header()->hide();
- m_ui.editorList->setIndentation(0);
- m_ui.editorList->setTextElideMode(Qt::ElideMiddle);
- m_ui.editorList->setFrameStyle(QFrame::NoFrame);
- m_ui.editorList->setAttribute(Qt::WA_MacShowFocusRect, false);
+ setUniformRowHeights(true);
+ viewport()->setAttribute(Qt::WA_Hover);
+ setItemDelegate((m_delegate = new OpenEditorsDelegate(this)));
+ header()->hide();
+ setIndentation(0);
+ setTextElideMode(Qt::ElideMiddle);
+ setFrameStyle(QFrame::NoFrame);
+ setAttribute(Qt::WA_MacShowFocusRect, false);
EditorManager *em = EditorManager::instance();
- m_ui.editorList->setModel(em->openedEditorsModel());
- m_ui.editorList->setSelectionMode(QAbstractItemView::SingleSelection);
- m_ui.editorList->setSelectionBehavior(QAbstractItemView::SelectRows);
- m_ui.editorList->header()->setStretchLastSection(false);
- m_ui.editorList->header()->setResizeMode(0, QHeaderView::Stretch);
- m_ui.editorList->header()->setResizeMode(1, QHeaderView::Fixed);
- m_ui.editorList->header()->resizeSection(1, 16);
- m_ui.editorList->setContextMenuPolicy(Qt::CustomContextMenu);
- m_ui.editorList->installEventFilter(this);
+ setModel(em->openedEditorsModel());
+ setSelectionMode(QAbstractItemView::SingleSelection);
+ setSelectionBehavior(QAbstractItemView::SelectRows);
+ header()->setStretchLastSection(false);
+ header()->setResizeMode(0, QHeaderView::Stretch);
+ header()->setResizeMode(1, QHeaderView::Fixed);
+ header()->resizeSection(1, 16);
+ setContextMenuPolicy(Qt::CustomContextMenu);
+ installEventFilter(this);
+ viewport()->installEventFilter(this);
connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)),
this, SLOT(updateCurrentItem(Core::IEditor*)));
- connect(m_ui.editorList, SIGNAL(clicked(QModelIndex)),
+ connect(this, SIGNAL(clicked(QModelIndex)),
this, SLOT(handleClicked(QModelIndex)));
- connect(m_ui.editorList, SIGNAL(pressed(QModelIndex)),
+ connect(this, SIGNAL(pressed(QModelIndex)),
this, SLOT(handlePressed(QModelIndex)));
- connect(m_ui.editorList, SIGNAL(customContextMenuRequested(QPoint)),
+ connect(this, SIGNAL(customContextMenuRequested(QPoint)),
this, SLOT(contextMenuRequested(QPoint)));
}
@@ -133,30 +136,41 @@ OpenEditorsWidget::~OpenEditorsWidget()
void OpenEditorsWidget::updateCurrentItem(Core::IEditor *editor)
{
if (!editor) {
- m_ui.editorList->clearSelection();
+ clearSelection();
return;
}
EditorManager *em = EditorManager::instance();
- m_ui.editorList->setCurrentIndex(em->openedEditorsModel()->indexOf(editor));
- m_ui.editorList->selectionModel()->select(m_ui.editorList->currentIndex(),
+ setCurrentIndex(em->openedEditorsModel()->indexOf(editor));
+ selectionModel()->select(currentIndex(),
QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
- m_ui.editorList->scrollTo(m_ui.editorList->currentIndex());
+ scrollTo(currentIndex());
}
bool OpenEditorsWidget::eventFilter(QObject *obj, QEvent *event)
{
- if (obj == m_ui.editorList && event->type() == QEvent::KeyPress
- && m_ui.editorList->currentIndex().isValid()) {
+ if (obj == this && event->type() == QEvent::KeyPress
+ && currentIndex().isValid()) {
QKeyEvent *ke = static_cast<QKeyEvent*>(event);
if ((ke->key() == Qt::Key_Return
|| ke->key() == Qt::Key_Enter)
&& ke->modifiers() == 0) {
- activateEditor(m_ui.editorList->currentIndex());
+ activateEditor(currentIndex());
return true;
} else if ((ke->key() == Qt::Key_Delete
|| ke->key() == Qt::Key_Backspace)
&& ke->modifiers() == 0) {
- closeEditor(m_ui.editorList->currentIndex());
+ closeEditor(currentIndex());
+ }
+ } else if (obj == viewport()
+ && event->type() == QEvent::MouseButtonRelease) {
+ QMouseEvent * me = static_cast<QMouseEvent*>(event);
+ if (me->button() == Qt::MiddleButton
+ && me->modifiers() == Qt::NoModifier) {
+ QModelIndex index = indexAt(me->pos());
+ if (index.isValid()) {
+ closeEditor(index);
+ return true;
+ }
}
}
return false;
@@ -164,11 +178,10 @@ bool OpenEditorsWidget::eventFilter(QObject *obj, QEvent *event)
void OpenEditorsWidget::handlePressed(const QModelIndex &index)
{
- if (index.column() == 0) {
+ if (index.column() == 0)
activateEditor(index);
- } else if (index.column() == 1) {
+ else if (index.column() == 1)
m_delegate->pressedIndex = index;
- }
}
void OpenEditorsWidget::handleClicked(const QModelIndex &index)
@@ -178,7 +191,7 @@ void OpenEditorsWidget::handleClicked(const QModelIndex &index)
// work around a bug in itemviews where the delegate wouldn't get the QStyle::State_MouseOver
QPoint cursorPos = QCursor::pos();
- QWidget *vp = m_ui.editorList->viewport();
+ QWidget *vp = viewport();
QMouseEvent e(QEvent::MouseMove, vp->mapFromGlobal(cursorPos), cursorPos, Qt::NoButton, 0, 0);
QCoreApplication::sendEvent(vp, &e);
}
@@ -186,7 +199,7 @@ void OpenEditorsWidget::handleClicked(const QModelIndex &index)
void OpenEditorsWidget::activateEditor(const QModelIndex &index)
{
- m_ui.editorList->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
+ selectionModel()->select(index, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
EditorManager::instance()->activateEditorForIndex(index, EditorManager::ModeSwitch);
}
@@ -200,11 +213,11 @@ void OpenEditorsWidget::closeEditor(const QModelIndex &index)
void OpenEditorsWidget::contextMenuRequested(QPoint pos)
{
QMenu contextMenu;
- QModelIndex editorIndex = m_ui.editorList->indexAt(pos);
- EditorManager::instance()->addCloseEditorActions(&contextMenu, editorIndex);
+ QModelIndex editorIndex = indexAt(pos);
+ EditorManager::instance()->addSaveAndCloseEditorActions(&contextMenu, editorIndex);
contextMenu.addSeparator();
EditorManager::instance()->addNativeDirActions(&contextMenu, editorIndex);
- contextMenu.exec(m_ui.editorList->mapToGlobal(pos));
+ contextMenu.exec(mapToGlobal(pos));
}
///
diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.h b/src/plugins/coreplugin/editormanager/openeditorsview.h
index ca8ab8f92f..ab32829a7e 100644
--- a/src/plugins/coreplugin/editormanager/openeditorsview.h
+++ b/src/plugins/coreplugin/editormanager/openeditorsview.h
@@ -30,11 +30,10 @@
#ifndef OPENEDITORSVIEW_H
#define OPENEDITORSVIEW_H
-#include "ui_openeditorsview.h"
-
#include <coreplugin/inavigationwidgetfactory.h>
#include <QStyledItemDelegate>
+#include <QTreeView>
namespace Core {
class IEditor;
@@ -43,8 +42,6 @@ namespace Internal {
class OpenEditorsDelegate : public QStyledItemDelegate
{
- Q_OBJECT
-
public:
explicit OpenEditorsDelegate(QObject *parent = 0);
@@ -54,7 +51,7 @@ public:
mutable QModelIndex pressedIndex;
};
-class OpenEditorsWidget : public QWidget
+class OpenEditorsWidget : public QTreeView
{
Q_OBJECT
@@ -73,9 +70,8 @@ private slots:
private:
void activateEditor(const QModelIndex &index);
void closeEditor(const QModelIndex &index);
+ using QAbstractItemView::closeEditor;
- Ui::OpenEditorsView m_ui;
- QWidget *m_widget;
OpenEditorsDelegate *m_delegate;
};
diff --git a/src/plugins/coreplugin/editormanager/openeditorsview.ui b/src/plugins/coreplugin/editormanager/openeditorsview.ui
deleted file mode 100644
index 299538e66a..0000000000
--- a/src/plugins/coreplugin/editormanager/openeditorsview.ui
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>Core::Internal::OpenEditorsView</class>
- <widget class="QWidget" name="Core::Internal::OpenEditorsView">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>263</width>
- <height>217</height>
- </rect>
- </property>
- <layout class="QGridLayout">
- <property name="margin">
- <number>0</number>
- </property>
- <property name="spacing">
- <number>0</number>
- </property>
- <item row="0" column="0">
- <widget class="QTreeView" name="editorList">
- <property name="uniformRowHeights">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
- <resources/>
- <connections/>
-</ui>
diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
index 197c41c4fd..19c230483f 100644
--- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
@@ -33,6 +33,7 @@
#include "editorview.h"
#include "idocument.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QFocusEvent>
@@ -60,16 +61,14 @@ OpenEditorsWindow::OpenEditorsWindow(QWidget *parent) :
m_editorList->setIndentation(0);
m_editorList->setSelectionMode(QAbstractItemView::SingleSelection);
m_editorList->setTextElideMode(Qt::ElideMiddle);
-#ifdef Q_OS_MAC
- m_editorList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ m_editorList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
m_editorList->installEventFilter(this);
// We disable the frame on this list view and use a QFrame around it instead.
// This improves the look with QGTKStyle.
-#ifndef Q_OS_MAC
- setFrameStyle(m_editorList->frameStyle());
-#endif
+ if (!Utils::HostOsInfo::isMacHost())
+ setFrameStyle(m_editorList->frameStyle());
m_editorList->setFrameStyle(QFrame::NoFrame);
QVBoxLayout *layout = new QVBoxLayout(this);
@@ -89,9 +88,8 @@ void OpenEditorsWindow::selectAndHide()
void OpenEditorsWindow::setVisible(bool visible)
{
QWidget::setVisible(visible);
- if (visible) {
+ if (visible)
setFocus();
- }
}
bool OpenEditorsWindow::isCentering()
diff --git a/src/plugins/coreplugin/editortoolbar.cpp b/src/plugins/coreplugin/editortoolbar.cpp
index 554a2d36a5..27b712df2c 100644
--- a/src/plugins/coreplugin/editortoolbar.cpp
+++ b/src/plugins/coreplugin/editortoolbar.cpp
@@ -43,6 +43,7 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
+#include <utils/hostosinfo.h>
#include <utils/parameteraction.h>
#include <utils/qtcassert.h>
#include <utils/styledbar.h>
@@ -133,6 +134,7 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
connect(d->m_goForwardAction, SIGNAL(triggered()), this, SIGNAL(goForwardClicked()));
d->m_editorList->setProperty("hideicon", true);
+ d->m_editorList->setProperty("notelideasterisk", true);
d->m_editorList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
d->m_editorList->setMinimumContentsLength(20);
d->m_editorList->setModel(d->m_editorsListModel);
@@ -151,10 +153,10 @@ EditorToolBar::EditorToolBar(QWidget *parent) :
d->m_forwardButton= new QToolButton(this);
d->m_forwardButton->setDefaultAction(d->m_goForwardAction);
-#ifdef Q_OS_MAC
- d->m_horizontalSplitAction->setIconVisibleInMenu(false);
- d->m_verticalSplitAction->setIconVisibleInMenu(false);
-#endif
+ if (Utils::HostOsInfo::isMacHost()) {
+ d->m_horizontalSplitAction->setIconVisibleInMenu(false);
+ d->m_verticalSplitAction->setIconVisibleInMenu(false);
+ }
d->m_splitButton->setIcon(QIcon(QLatin1String(Constants::ICON_SPLIT_HORIZONTAL)));
d->m_splitButton->setToolTip(tr("Split"));
@@ -331,13 +333,12 @@ void EditorToolBar::listContextMenu(QPoint pos)
QMenu menu;
QAction *copyPath = menu.addAction(tr("Copy Full Path to Clipboard"));
menu.addSeparator();
- EditorManager::instance()->addCloseEditorActions(&menu, index);
+ EditorManager::instance()->addSaveAndCloseEditorActions(&menu, index);
menu.addSeparator();
EditorManager::instance()->addNativeDirActions(&menu, index);
QAction *result = menu.exec(d->m_editorList->mapToGlobal(pos));
- if (result == copyPath) {
+ if (result == copyPath)
QApplication::clipboard()->setText(QDir::toNativeSeparators(fileName));
- }
}
void EditorToolBar::makeEditorWritable()
diff --git a/src/plugins/coreplugin/externaltool.cpp b/src/plugins/coreplugin/externaltool.cpp
index 9c2f984d10..188b4b895e 100644
--- a/src/plugins/coreplugin/externaltool.cpp
+++ b/src/plugins/coreplugin/externaltool.cpp
@@ -441,9 +441,8 @@ ExternalTool * ExternalTool::createFromFile(const QString &fileName, QString *er
if (!reader.fetch(absFileName, errorMessage))
return 0;
ExternalTool *tool = ExternalTool::createFromXml(reader.data(), errorMessage, locale);
- if (!tool) {
+ if (!tool)
return 0;
- }
tool->m_fileName = absFileName;
return tool;
}
@@ -624,9 +623,8 @@ void ExternalToolRunner::run()
void ExternalToolRunner::started()
{
- if (!m_resolvedInput.isEmpty()) {
+ if (!m_resolvedInput.isEmpty())
m_process->write(m_resolvedInput.toLocal8Bit());
- }
m_process->closeWriteChannel();
}
@@ -637,9 +635,8 @@ void ExternalToolRunner::finished(int exitCode, QProcess::ExitStatus status)
|| m_tool->errorHandling() == ExternalTool::ReplaceSelection) {
emit ExternalToolManager::instance()->replaceSelectionRequested(m_processOutput);
}
- if (m_tool->modifiesCurrentDocument()) {
+ if (m_tool->modifiesCurrentDocument())
DocumentManager::unexpectFileChange(m_expectedFileName);
- }
}
ICore::messageManager()->printToOutputPane(
tr("'%1' finished").arg(m_resolvedExecutable), false);
@@ -661,11 +658,10 @@ void ExternalToolRunner::readStandardOutput()
return;
QByteArray data = m_process->readAllStandardOutput();
QString output = m_outputCodec->toUnicode(data.constData(), data.length(), &m_outputCodecState);
- if (m_tool->outputHandling() == ExternalTool::ShowInPane) {
+ if (m_tool->outputHandling() == ExternalTool::ShowInPane)
ICore::messageManager()->printToOutputPane(output, true);
- } else if (m_tool->outputHandling() == ExternalTool::ReplaceSelection) {
+ else if (m_tool->outputHandling() == ExternalTool::ReplaceSelection)
m_processOutput.append(output);
- }
}
void ExternalToolRunner::readStandardError()
@@ -674,11 +670,10 @@ void ExternalToolRunner::readStandardError()
return;
QByteArray data = m_process->readAllStandardError();
QString output = m_outputCodec->toUnicode(data.constData(), data.length(), &m_errorCodecState);
- if (m_tool->errorHandling() == ExternalTool::ShowInPane) {
+ if (m_tool->errorHandling() == ExternalTool::ShowInPane)
ICore::messageManager()->printToOutputPane(output, true);
- } else if (m_tool->errorHandling() == ExternalTool::ReplaceSelection) {
+ else if (m_tool->errorHandling() == ExternalTool::ReplaceSelection)
m_processOutput.append(output);
- }
}
// #pragma mark -- ExternalToolManager
@@ -777,9 +772,8 @@ void ExternalToolManager::menuActivated()
ExternalTool *tool = m_tools.value(action->data().toString());
QTC_ASSERT(tool, return);
ExternalToolRunner *runner = new ExternalToolRunner(tool);
- if (runner->hasError()) {
+ if (runner->hasError())
ICore::messageManager()->printToOutputPane(runner->errorString(), true);
- }
}
QMap<QString, QList<Internal::ExternalTool *> > ExternalToolManager::toolsByCategory() const
@@ -820,7 +814,8 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<Internal:
const QString externalToolsPrefix = QLatin1String("Tools.External.");
while (remainingActions.hasNext()) {
remainingActions.next();
- ActionManager::unregisterAction(remainingActions.value(), Id(externalToolsPrefix + remainingActions.key()));
+ ActionManager::unregisterAction(remainingActions.value(),
+ Id::fromString(externalToolsPrefix + remainingActions.key()));
delete remainingActions.value();
}
m_actions.clear();
@@ -839,11 +834,10 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<Internal:
if (containerName.isEmpty()) { // no displayCategory, so put into external tools menu directly
container = mexternaltools;
} else {
- if (m_containers.contains(containerName)) {
+ if (m_containers.contains(containerName))
container = m_containers.take(containerName); // remove to avoid deletion below
- } else {
- container = ActionManager::createMenu(Id(QLatin1String("Tools.External.Category.") + containerName));
- }
+ else
+ container = ActionManager::createMenu(Id::fromString(QLatin1String("Tools.External.Category.") + containerName));
newContainers.insert(containerName, container);
mexternaltools->addMenu(container, Constants::G_DEFAULT_ONE);
container->menu()->setTitle(containerName);
@@ -855,13 +849,13 @@ void ExternalToolManager::setToolsByCategory(const QMap<QString, QList<Internal:
Command *command = 0;
if (m_actions.contains(toolId)) {
action = m_actions.value(toolId);
- command = ActionManager::command(Id(externalToolsPrefix + toolId));
+ command = ActionManager::command(Id::fromString(externalToolsPrefix + toolId));
} else {
action = new QAction(tool->displayName(), this);
action->setData(toolId);
m_actions.insert(toolId, action);
connect(action, SIGNAL(triggered()), this, SLOT(menuActivated()));
- command = ActionManager::registerAction(action, Id(externalToolsPrefix + toolId), Context(Constants::C_GLOBAL));
+ command = ActionManager::registerAction(action, Id::fromString(externalToolsPrefix + toolId), Context(Constants::C_GLOBAL));
command->setAttribute(Command::CA_UpdateText);
}
action->setText(tool->displayName());
@@ -944,6 +938,5 @@ void ExternalToolManager::writeSettings()
void ExternalToolManager::openPreferences()
{
- ICore::showOptionsDialog(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE),
- QLatin1String(Core::Constants::SETTINGS_ID_TOOLS));
+ ICore::showOptionsDialog(Constants::SETTINGS_CATEGORY_CORE, Constants::SETTINGS_ID_TOOLS);
}
diff --git a/src/plugins/coreplugin/fancyactionbar.cpp b/src/plugins/coreplugin/fancyactionbar.cpp
index 8105692a0b..651683d4cb 100644
--- a/src/plugins/coreplugin/fancyactionbar.cpp
+++ b/src/plugins/coreplugin/fancyactionbar.cpp
@@ -32,6 +32,8 @@
#include <utils/stylehelper.h>
#include <utils/stringutils.h>
+#include <utils/tooltip/tooltip.h>
+#include <utils/tooltip/tipcontents.h>
#include <coreplugin/icore.h>
#include <coreplugin/imode.h>
@@ -70,7 +72,7 @@ void FancyToolButton::forceVisible(bool visible)
bool FancyToolButton::event(QEvent *e)
{
- switch(e->type()) {
+ switch (e->type()) {
case QEvent::Enter:
{
QPropertyAnimation *animation = new QPropertyAnimation(this, "fader");
@@ -87,6 +89,12 @@ bool FancyToolButton::event(QEvent *e)
animation->start(QAbstractAnimation::DeleteWhenStopped);
}
break;
+ case QEvent::ToolTip:
+ {
+ QHelpEvent *he = static_cast<QHelpEvent *>(e);
+ Utils::ToolTip::instance()->show(mapToGlobal(he->pos()), Utils::TextContent(toolTip()), this);
+ return true;
+ }
default:
return QToolButton::event(e);
}
@@ -109,11 +117,10 @@ static QVector<QString> splitInTwoLines(const QString &text, const QFontMetrics
nextSplitPos - text.length() - 1);
if (nextSplitPos != -1) {
int splitCandidate = nextSplitPos + rx.matchedLength();
- if (fontMetrics.width(text.mid(splitCandidate)) <= availableWidth) {
+ if (fontMetrics.width(text.mid(splitCandidate)) <= availableWidth)
splitPos = splitCandidate;
- } else {
+ else
break;
- }
}
} while (nextSplitPos > 0 && fontMetrics.width(text.left(nextSplitPos)) > availableWidth);
// check if we could split at white space at all
diff --git a/src/plugins/coreplugin/fancytabwidget.cpp b/src/plugins/coreplugin/fancytabwidget.cpp
index 898a920cad..dacd8f73e2 100644
--- a/src/plugins/coreplugin/fancytabwidget.cpp
+++ b/src/plugins/coreplugin/fancytabwidget.cpp
@@ -28,6 +28,7 @@
****************************************************************************/
#include "fancytabwidget.h"
+#include <utils/hostosinfo.h>
#include <utils/stylehelper.h>
#include <utils/styledbar.h>
@@ -273,23 +274,23 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
}
QString tabText(this->tabText(tabIndex));
- QRect tabTextRect(tabRect(tabIndex));
+ QRect tabTextRect(rect);
+ const bool drawIcon = rect.height() > 36;
QRect tabIconRect(tabTextRect);
- tabTextRect.translate(0, -2);
+ tabTextRect.translate(0, drawIcon ? -2 : 1);
QFont boldFont(painter->font());
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
boldFont.setBold(true);
painter->setFont(boldFont);
painter->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110));
- int textFlags = Qt::AlignCenter | Qt::AlignBottom | Qt::TextWordWrap;
+ const int textFlags = Qt::AlignCenter | (drawIcon ? Qt::AlignBottom : Qt::AlignVCenter) | Qt::TextWordWrap;
if (enabled) {
painter->drawText(tabTextRect, textFlags, tabText);
painter->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor());
} else {
painter->setPen(selected ? Utils::StyleHelper::panelTextColor() : QColor(255, 255, 255, 120));
}
-#ifndef Q_OS_MAC
- if (!selected && enabled) {
+ if (!Utils::HostOsInfo::isMacHost() && !selected && enabled) {
painter->save();
int fader = int(m_tabs[tabIndex]->fader());
QLinearGradient grad(rect.topLeft(), rect.topRight());
@@ -302,14 +303,15 @@ void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
painter->restore();
}
-#endif
if (!enabled)
painter->setOpacity(0.7);
- int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
- tabIconRect.adjust(0, 4, 0, -textHeight);
- Utils::StyleHelper::drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled);
+ if (drawIcon) {
+ int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
+ tabIconRect.adjust(0, 4, 0, -textHeight);
+ Utils::StyleHelper::drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled);
+ }
painter->translate(0, -1);
painter->drawText(tabTextRect, textFlags, tabText);
diff --git a/src/plugins/coreplugin/featureprovider.h b/src/plugins/coreplugin/featureprovider.h
index 9895eebb5b..f6672794fe 100644
--- a/src/plugins/coreplugin/featureprovider.h
+++ b/src/plugins/coreplugin/featureprovider.h
@@ -38,11 +38,6 @@
#include <QSet>
#include <QStringList>
-
-namespace Utils {
-class AbstractMacroExpander;
-}
-
namespace Core {
class CORE_EXPORT FeatureSet;
@@ -61,10 +56,8 @@ public:
class CORE_EXPORT Feature : public Id
{
-friend class FeatureSet;
public:
- Feature(const char *name) : Id(name) {}
- explicit Feature(const QString &name) : Id(name) {}
+ Feature(Id id) : Id(id) {}
};
class CORE_EXPORT FeatureSet : private QSet<Feature>
@@ -72,12 +65,10 @@ class CORE_EXPORT FeatureSet : private QSet<Feature>
public:
FeatureSet() {}
- FeatureSet(const Feature &feature)
+ FeatureSet(Core::Id id)
{
- if (feature.toString().isEmpty())
- return;
-
- insert(feature);
+ if (id.isValid())
+ insert(id);
}
FeatureSet(const FeatureSet &other) : QSet<Feature>(other) {}
diff --git a/src/plugins/coreplugin/fileiconprovider.cpp b/src/plugins/coreplugin/fileiconprovider.cpp
index 6025ae1dc3..bab2617569 100644
--- a/src/plugins/coreplugin/fileiconprovider.cpp
+++ b/src/plugins/coreplugin/fileiconprovider.cpp
@@ -30,6 +30,7 @@
#include "fileiconprovider.h"
#include "mimedatabase.h"
+#include <utils/hostosinfo.h>
#include <utils/qtcassert.h>
#include <QApplication>
@@ -43,6 +44,8 @@
#include <QIcon>
#include <QStyle>
+using namespace Utils;
+
/*!
\class Core::FileIconProvider
@@ -138,14 +141,13 @@ QIcon FileIconProvider::icon(const QFileInfo &fileInfo) const
}
}
// Get icon from OS.
-#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
- return QFileIconProvider::icon(fileInfo);
-#else
+ if (HostOsInfo::isWindowsHost() || HostOsInfo::isMacHost())
+ return QFileIconProvider::icon(fileInfo);
+
// File icons are unknown on linux systems.
return (fileInfo.isDir()) ?
QFileIconProvider::icon(fileInfo) :
d->m_unknownFileIcon;
-#endif
}
/*!
@@ -178,11 +180,10 @@ void FileIconProvider::registerIconOverlayForSuffix(const QIcon &icon,
const QPixmap fileIconPixmap = overlayIcon(QStyle::SP_FileIcon, icon, QSize(16, 16));
// replace old icon, if it exists
const CacheIterator it = findBySuffix(suffix, d->m_cache.begin(), d->m_cache.end());
- if (it == d->m_cache.end()) {
+ if (it == d->m_cache.end())
d->m_cache.append(StringIconPair(suffix, fileIconPixmap));
- } else {
+ else
(*it).second = fileIconPixmap;
- }
}
/*!
diff --git a/src/plugins/coreplugin/fileutils.cpp b/src/plugins/coreplugin/fileutils.cpp
index 0a8043de42..5f20153c28 100644
--- a/src/plugins/coreplugin/fileutils.cpp
+++ b/src/plugins/coreplugin/fileutils.cpp
@@ -29,41 +29,37 @@
#include "fileutils.h"
+#include <coreplugin/coreconstants.h>
#include <coreplugin/documentmanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/iversioncontrol.h>
#include <coreplugin/removefiledialog.h>
#include <coreplugin/vcsmanager.h>
+#include <utils/consoleprocess.h>
#include <utils/environment.h>
+#include <utils/hostosinfo.h>
+#include <utils/qtcprocess.h>
+#include <utils/unixutils.h>
+#include <QApplication>
#include <QDir>
#include <QFileInfo>
-#include <QProcess>
-#include <QApplication>
#include <QMessageBox>
+#include <QProcess>
+#include <QPushButton>
#include <QWidget>
#if QT_VERSION < 0x050000
#include <QAbstractFileEngine>
#endif
-#ifndef Q_OS_WIN
-#include <utils/consoleprocess.h>
-#include <utils/qtcprocess.h>
-#ifndef Q_OS_MAC
-#include <coreplugin/coreconstants.h>
-#include <utils/unixutils.h>
-#include <QPushButton>
-#endif
-#endif
+using namespace Utils;
-using namespace Core;
+namespace Core {
-#if !defined(Q_OS_WIN) && !defined(Q_OS_MAC)
+#ifndef Q_OS_MAC
// Show error with option to open settings.
-static inline void showGraphicalShellError(QWidget *parent,
- const QString &app,
- const QString &error)
+static void showGraphicalShellError(QWidget *parent, const QString &app, const QString &error)
{
const QString title = QApplication::translate("Core::Internal",
"Launching a file browser failed");
@@ -77,72 +73,71 @@ static inline void showGraphicalShellError(QWidget *parent,
QMessageBox::ActionRole);
mbox.exec();
if (mbox.clickedButton() == settingsButton)
- Core::ICore::showOptionsDialog(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE),
- QLatin1String(Core::Constants::SETTINGS_ID_ENVIRONMENT));
+ ICore::showOptionsDialog(Constants::SETTINGS_CATEGORY_CORE, Constants::SETTINGS_ID_ENVIRONMENT);
}
#endif
void FileUtils::showInGraphicalShell(QWidget *parent, const QString &pathIn)
{
// Mac, Windows support folder or file.
-#if defined(Q_OS_WIN)
- const QString explorer = Utils::Environment::systemEnvironment().searchInPath(QLatin1String("explorer.exe"));
- if (explorer.isEmpty()) {
- QMessageBox::warning(parent,
- QApplication::translate("Core::Internal",
- "Launching Windows Explorer Failed"),
- QApplication::translate("Core::Internal",
- "Could not find explorer.exe in path to launch Windows Explorer."));
- return;
- }
- QStringList param;
- if (!QFileInfo(pathIn).isDir())
- param += QLatin1String("/select,");
- param += QDir::toNativeSeparators(pathIn);
- QProcess::startDetached(explorer, param);
-#elif defined(Q_OS_MAC)
- Q_UNUSED(parent)
- QStringList scriptArgs;
- scriptArgs << QLatin1String("-e")
- << QString::fromLatin1("tell application \"Finder\" to reveal POSIX file \"%1\"")
- .arg(pathIn);
- QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);
- scriptArgs.clear();
- scriptArgs << QLatin1String("-e")
- << QLatin1String("tell application \"Finder\" to activate");
- QProcess::execute("/usr/bin/osascript", scriptArgs);
-#else
- // we cannot select a file here, because no file browser really supports it...
- const QFileInfo fileInfo(pathIn);
- const QString folder = fileInfo.isDir() ? fileInfo.absoluteFilePath() : fileInfo.filePath();
- const QString app = Utils::UnixUtils::fileBrowser(Core::ICore::settings());
- QProcess browserProc;
- const QString browserArgs = Utils::UnixUtils::substituteFileBrowserParameters(app, folder);
- bool success = browserProc.startDetached(browserArgs);
- const QString error = QString::fromLocal8Bit(browserProc.readAllStandardError());
- success = success && error.isEmpty();
- if (!success)
- showGraphicalShellError(parent, app, error);
+ if (HostOsInfo::isWindowsHost()) {
+ const QString explorer = Environment::systemEnvironment().searchInPath(QLatin1String("explorer.exe"));
+ if (explorer.isEmpty()) {
+ QMessageBox::warning(parent,
+ QApplication::translate("Core::Internal",
+ "Launching Windows Explorer Failed"),
+ QApplication::translate("Core::Internal",
+ "Could not find explorer.exe in path to launch Windows Explorer."));
+ return;
+ }
+ QStringList param;
+ if (!QFileInfo(pathIn).isDir())
+ param += QLatin1String("/select,");
+ param += QDir::toNativeSeparators(pathIn);
+ QProcess::startDetached(explorer, param);
+ } else if (HostOsInfo::isMacHost()) {
+ QStringList scriptArgs;
+ scriptArgs << QLatin1String("-e")
+ << QString::fromLatin1("tell application \"Finder\" to reveal POSIX file \"%1\"")
+ .arg(pathIn);
+ QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);
+ scriptArgs.clear();
+ scriptArgs << QLatin1String("-e")
+ << QLatin1String("tell application \"Finder\" to activate");
+ QProcess::execute(QLatin1String("/usr/bin/osascript"), scriptArgs);
+ } else {
+#ifndef Q_OS_MAC
+ // we cannot select a file here, because no file browser really supports it...
+ const QFileInfo fileInfo(pathIn);
+ const QString folder = fileInfo.isDir() ? fileInfo.absoluteFilePath() : fileInfo.filePath();
+ const QString app = UnixUtils::fileBrowser(ICore::settings());
+ QProcess browserProc;
+ const QString browserArgs = UnixUtils::substituteFileBrowserParameters(app, folder);
+ bool success = browserProc.startDetached(browserArgs);
+ const QString error = QString::fromLocal8Bit(browserProc.readAllStandardError());
+ success = success && error.isEmpty();
+ if (!success)
+ showGraphicalShellError(parent, app, error);
#endif
+ }
}
void FileUtils::openTerminal(const QString &path)
{
// Get terminal application
-#ifdef Q_OS_WIN
- const QString terminalEmulator = QString::fromLocal8Bit(qgetenv("COMSPEC"));
- const QStringList args; // none
-#elif defined(Q_OS_MAC)
- const QString terminalEmulator = Core::ICore::resourcePath()
- + QLatin1String("/scripts/openTerminal.command");
+ QString terminalEmulator;
QStringList args;
-#else
- QStringList args = Utils::QtcProcess::splitArgs(
- Utils::ConsoleProcess::terminalEmulator(Core::ICore::settings()));
- const QString terminalEmulator = args.takeFirst();
- const QString shell = QString::fromLocal8Bit(qgetenv("SHELL"));
- args.append(shell);
-#endif
+ if (HostOsInfo::isWindowsHost()) {
+ terminalEmulator = ConsoleProcess::defaultTerminalEmulator();
+ } else if (HostOsInfo::isMacHost()) {
+ terminalEmulator = ICore::resourcePath()
+ + QLatin1String("/scripts/openTerminal.command");
+ } else {
+ args = QtcProcess::splitArgs(ConsoleProcess::terminalEmulator(ICore::settings()));
+ terminalEmulator = args.takeFirst();
+ args.append(QString::fromLocal8Bit(qgetenv("SHELL")));
+ }
+
// Launch terminal with working directory set.
const QFileInfo fileInfo(path);
const QString pwd = QDir::toNativeSeparators(fileInfo.isDir() ?
@@ -153,22 +148,18 @@ void FileUtils::openTerminal(const QString &path)
QString FileUtils::msgGraphicalShellAction()
{
-#if defined(Q_OS_WIN)
- return QApplication::translate("Core::Internal", "Show in Explorer");
-#elif defined(Q_OS_MAC)
- return QApplication::translate("Core::Internal", "Show in Finder");
-#else
+ if (HostOsInfo::isWindowsHost())
+ return QApplication::translate("Core::Internal", "Show in Explorer");
+ if (HostOsInfo::isMacHost())
+ return QApplication::translate("Core::Internal", "Show in Finder");
return QApplication::translate("Core::Internal", "Show Containing Folder");
-#endif
}
QString FileUtils::msgTerminalAction()
{
-#ifdef Q_OS_WIN
- return QApplication::translate("Core::Internal", "Open Command Prompt Here");
-#else
+ if (HostOsInfo::isWindowsHost())
+ return QApplication::translate("Core::Internal", "Open Command Prompt Here");
return QApplication::translate("Core::Internal", "Open Terminal Here");
-#endif
}
void FileUtils::removeFile(const QString &filePath, bool deleteFromFS)
@@ -209,10 +200,10 @@ bool FileUtils::renameFile(const QString &orgFilePath, const QString &newFilePat
return false;
QString dir = QFileInfo(orgFilePath).absolutePath();
- Core::IVersionControl *vc = Core::ICore::vcsManager()->findVersionControlForDirectory(dir);
+ IVersionControl *vc = ICore::vcsManager()->findVersionControlForDirectory(dir);
bool result = false;
- if (vc && vc->supportsOperation(Core::IVersionControl::MoveOperation))
+ if (vc && vc->supportsOperation(IVersionControl::MoveOperation))
result = vc->vcsMove(orgFilePath, newFilePath);
if (!result) // The moving via vcs failed or the vcs does not support moving, fall back
result = fileSystemRenameFile(orgFilePath, newFilePath);
@@ -222,3 +213,5 @@ bool FileUtils::renameFile(const QString &orgFilePath, const QString &newFilePat
}
return result;
}
+
+} // namespace Core
diff --git a/src/plugins/coreplugin/generalsettings.cpp b/src/plugins/coreplugin/generalsettings.cpp
index b57d37be4f..4f3d318bc4 100644
--- a/src/plugins/coreplugin/generalsettings.cpp
+++ b/src/plugins/coreplugin/generalsettings.cpp
@@ -29,13 +29,14 @@
#include "generalsettings.h"
#include "coreconstants.h"
+#include "icore.h"
+#include "infobar.h"
+#include "editormanager/editormanager.h"
#include <utils/stylehelper.h>
#include <utils/qtcolorbutton.h>
#include <utils/consoleprocess.h>
#include <utils/unixutils.h>
-#include <coreplugin/editormanager/editormanager.h>
-#include <coreplugin/icore.h>
#include <QMessageBox>
@@ -54,9 +55,9 @@ using namespace Core::Internal;
GeneralSettings::GeneralSettings():
m_page(0), m_dialog(0)
{
- setId(QLatin1String(Core::Constants::SETTINGS_ID_ENVIRONMENT));
+ setId(Core::Constants::SETTINGS_ID_ENVIRONMENT);
setDisplayName(tr("General"));
- setCategory(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE));
+ setCategory(Core::Constants::SETTINGS_CATEGORY_CORE);
setDisplayCategory(QCoreApplication::translate("Core", Core::Constants::SETTINGS_TR_CATEGORY_CORE));
setCategoryIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
}
@@ -65,9 +66,8 @@ static bool hasQmFilesForLocale(const QString &locale, const QString &creatorTrP
{
static const QString qtTrPath = QLibraryInfo::location(QLibraryInfo::TranslationsPath);
- const QString trFile = QLatin1String("qt_") + locale + QLatin1String(".qm");
- return QFile::exists(qtTrPath + QLatin1Char('/') + trFile)
- || QFile::exists(creatorTrPath + QLatin1Char('/') + trFile);
+ const QString trFile = QLatin1String("/qt_") + locale + QLatin1String(".qm");
+ return QFile::exists(qtTrPath + trFile) || QFile::exists(creatorTrPath + trFile);
}
void GeneralSettings::fillLanguageBox() const
@@ -137,8 +137,10 @@ QWidget *GeneralSettings::createPage(QWidget *parent)
m_page->autoSaveCheckBox->setChecked(EditorManager::instance()->autoSaveEnabled());
m_page->autoSaveInterval->setValue(EditorManager::instance()->autoSaveInterval());
- connect(m_page->resetButton, SIGNAL(clicked()),
+ connect(m_page->resetColorButton, SIGNAL(clicked()),
this, SLOT(resetInterfaceColor()));
+ connect(m_page->resetWarningsButton, SIGNAL(clicked()),
+ this, SLOT(resetWarnings()));
#ifdef Q_OS_UNIX
connect(m_page->resetTerminalButton, SIGNAL(clicked()),
this, SLOT(resetTerminal()));
@@ -202,6 +204,12 @@ void GeneralSettings::resetInterfaceColor()
m_page->colorButton->setColor(StyleHelper::DEFAULT_BASE_COLOR);
}
+void GeneralSettings::resetWarnings()
+{
+ Core::InfoBar::clearGloballySuppressed();
+ QMessageBox::information(0, tr("Reset warnings"), tr("Done"));
+}
+
void GeneralSettings::resetTerminal()
{
#if defined(Q_OS_UNIX)
diff --git a/src/plugins/coreplugin/generalsettings.h b/src/plugins/coreplugin/generalsettings.h
index a3e1696915..c812ac45af 100644
--- a/src/plugins/coreplugin/generalsettings.h
+++ b/src/plugins/coreplugin/generalsettings.h
@@ -58,6 +58,7 @@ public:
private slots:
void resetInterfaceColor();
+ void resetWarnings();
void resetLanguage();
void showHelpForFileBrowser();
void resetFileBrowser();
diff --git a/src/plugins/coreplugin/generalsettings.ui b/src/plugins/coreplugin/generalsettings.ui
index 08b42c94e0..a36954345c 100644
--- a/src/plugins/coreplugin/generalsettings.ui
+++ b/src/plugins/coreplugin/generalsettings.ui
@@ -17,13 +17,66 @@
<string>User Interface</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QLabel" name="colorLabel">
+ <item row="0" column="0">
+ <widget class="QLabel" name="colorLabel">
+ <property name="text">
+ <string>Color:</string>
+ </property>
+ <property name="buddy">
+ <cstring>colorButton</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="Utils::QtColorButton" name="colorButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>64</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="alphaAllowed" stdset="0">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="resetColorButton">
+ <property name="toolTip">
+ <string comment="Color">Reset to default.</string>
+ </property>
+ <property name="text">
+ <string>Reset</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>285</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="languageLabel">
<property name="text">
- <string>Color:</string>
- </property>
- <property name="buddy">
- <cstring>colorButton</cstring>
+ <string>Language:</string>
</property>
</widget>
</item>
@@ -54,56 +107,10 @@
</item>
</layout>
</item>
- <item row="0" column="1">
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="Utils::QtColorButton" name="colorButton">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>64</width>
- <height>0</height>
- </size>
- </property>
- <property name="alphaAllowed" stdset="0">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="resetButton">
- <property name="toolTip">
- <string comment="Color">Reset to default.</string>
- </property>
- <property name="text">
- <string>Reset</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>285</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="languageLabel">
+ <item row="3" column="0">
+ <widget class="QPushButton" name="resetWarningsButton">
<property name="text">
- <string>Language:</string>
+ <string>Reset warnings</string>
</property>
</widget>
</item>
@@ -130,6 +137,16 @@
</property>
</widget>
</item>
+ <item row="0" column="2">
+ <widget class="QPushButton" name="resetTerminalButton">
+ <property name="toolTip">
+ <string comment="Terminal">Reset to default.</string>
+ </property>
+ <property name="text">
+ <string>Reset</string>
+ </property>
+ </widget>
+ </item>
<item row="1" column="0">
<widget class="QLabel" name="externalFileBrowserLabel">
<property name="text">
@@ -140,6 +157,16 @@
<item row="1" column="1">
<widget class="QLineEdit" name="externalFileBrowserEdit"/>
</item>
+ <item row="1" column="2">
+ <widget class="QPushButton" name="resetFileBrowserButton">
+ <property name="toolTip">
+ <string comment="File Browser">Reset to default.</string>
+ </property>
+ <property name="text">
+ <string>Reset</string>
+ </property>
+ </widget>
+ </item>
<item row="1" column="3">
<widget class="QToolButton" name="helpExternalFileBrowserButton">
<property name="text">
@@ -197,26 +224,6 @@
</item>
</layout>
</item>
- <item row="0" column="2">
- <widget class="QPushButton" name="resetTerminalButton">
- <property name="toolTip">
- <string comment="Terminal">Reset to default.</string>
- </property>
- <property name="text">
- <string>Reset</string>
- </property>
- </widget>
- </item>
- <item row="1" column="2">
- <widget class="QPushButton" name="resetFileBrowserButton">
- <property name="toolTip">
- <string comment="File Browser">Reset to default.</string>
- </property>
- <property name="text">
- <string>Reset</string>
- </property>
- </widget>
- </item>
<item row="3" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
@@ -305,17 +312,6 @@
<header location="global">utils/qtcolorbutton.h</header>
</customwidget>
</customwidgets>
- <tabstops>
- <tabstop>colorButton</tabstop>
- <tabstop>resetButton</tabstop>
- <tabstop>languageBox</tabstop>
- <tabstop>terminalComboBox</tabstop>
- <tabstop>resetTerminalButton</tabstop>
- <tabstop>externalFileBrowserEdit</tabstop>
- <tabstop>resetFileBrowserButton</tabstop>
- <tabstop>helpExternalFileBrowserButton</tabstop>
- <tabstop>reloadBehavior</tabstop>
- </tabstops>
<resources>
<include location="core.qrc"/>
</resources>
diff --git a/src/plugins/coreplugin/icontext.cpp b/src/plugins/coreplugin/icontext.cpp
index 152503edbe..3883d166dd 100644
--- a/src/plugins/coreplugin/icontext.cpp
+++ b/src/plugins/coreplugin/icontext.cpp
@@ -28,26 +28,3 @@
****************************************************************************/
#include "icontext.h"
-
-#include "id.h"
-
-#include <QString>
-
-namespace Core {
-
-Context::Context(const char *id, int offset)
-{
- d.append(Id(QLatin1String(id) + QString::number(offset)).uniqueIdentifier());
-}
-
-void Context::add(const char *id)
-{
- d.append(Id(id).uniqueIdentifier());
-}
-
-bool Context::contains(const char *id) const
-{
- return d.contains(Id(id).uniqueIdentifier());
-}
-
-} // namespace Core
diff --git a/src/plugins/coreplugin/icontext.h b/src/plugins/coreplugin/icontext.h
index a7d68cdd72..65206bf082 100644
--- a/src/plugins/coreplugin/icontext.h
+++ b/src/plugins/coreplugin/icontext.h
@@ -31,6 +31,7 @@
#define ICONTEXT_H
#include <coreplugin/core_global.h>
+#include <coreplugin/id.h>
#include <QList>
#include <QObject>
@@ -44,30 +45,27 @@ class CORE_EXPORT Context
public:
Context() {}
- explicit Context(const char *c1) { add(c1); }
- Context(const char *c1, const char *c2) { add(c1); add(c2); }
- Context(const char *c1, const char *c2, const char *c3) { add(c1); add(c2); add(c3); }
- Context(const char *base, int offset);
- void add(const char *c);
- bool contains(const char *c) const;
- bool contains(int c) const { return d.contains(c); }
+ explicit Context(Id c1) { add(c1); }
+ Context(Id c1, Id c2) { add(c1); add(c2); }
+ Context(Id c1, Id c2, Id c3) { add(c1); add(c2); add(c3); }
+ bool contains(Id c) const { return d.contains(c); }
int size() const { return d.size(); }
bool isEmpty() const { return d.isEmpty(); }
- int at(int i) const { return d.at(i); }
+ Id at(int i) const { return d.at(i); }
// FIXME: Make interface slimmer.
- typedef QList<int>::const_iterator const_iterator;
+ typedef QList<Id>::const_iterator const_iterator;
const_iterator begin() const { return d.begin(); }
const_iterator end() const { return d.end(); }
- int indexOf(int c) const { return d.indexOf(c); }
+ int indexOf(Id c) const { return d.indexOf(c); }
void removeAt(int i) { d.removeAt(i); }
- void prepend(int c) { d.prepend(c); }
+ void prepend(Id c) { d.prepend(c); }
void add(const Context &c) { d += c.d; }
- void add(int c) { d.append(c); }
+ void add(Id c) { d.append(c); }
bool operator==(const Context &c) const { return d == c.d; }
private:
- QList<int> d;
+ QList<Id> d;
};
class CORE_EXPORT IContext : public QObject
diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp
index 329e1a6c1b..fc9f1537a4 100644
--- a/src/plugins/coreplugin/icore.cpp
+++ b/src/plugins/coreplugin/icore.cpp
@@ -393,15 +393,15 @@ void ICore::showNewItemDialog(const QString &title,
m_mainwindow->showNewItemDialog(title, wizards, defaultLocation, extraVariables);
}
-bool ICore::showOptionsDialog(const QString &group, const QString &page, QWidget *parent)
+bool ICore::showOptionsDialog(const Id group, const Id page, QWidget *parent)
{
return m_mainwindow->showOptionsDialog(group, page, parent);
}
bool ICore::showWarningWithOptions(const QString &title, const QString &text,
const QString &details,
- const QString &settingsCategory,
- const QString &settingsId,
+ Id settingsCategory,
+ Id settingsId,
QWidget *parent)
{
return m_mainwindow->showWarningWithOptions(title, text,
@@ -532,11 +532,6 @@ void ICore::updateAdditionalContexts(const Context &remove, const Context &add)
m_mainwindow->updateAdditionalContexts(remove, add);
}
-bool ICore::hasContext(int context)
-{
- return m_mainwindow->hasContext(context);
-}
-
void ICore::addContextObject(IContext *context)
{
m_mainwindow->addContextObject(context);
diff --git a/src/plugins/coreplugin/icore.h b/src/plugins/coreplugin/icore.h
index 8554267064..d886ef025a 100644
--- a/src/plugins/coreplugin/icore.h
+++ b/src/plugins/coreplugin/icore.h
@@ -31,6 +31,7 @@
#define ICORE_H
#include "core_global.h"
+#include "id.h"
#include <QObject>
#include <QSettings>
@@ -81,14 +82,12 @@ public:
const QString &defaultLocation = QString(),
const QVariantMap &extraVariables = QVariantMap());
- static bool showOptionsDialog(const QString &group = QString(),
- const QString &page = QString(),
- QWidget *parent = 0);
+ static bool showOptionsDialog(Id group, Id page, QWidget *parent = 0);
static bool showWarningWithOptions(const QString &title, const QString &text,
const QString &details = QString(),
- const QString &settingsCategory = QString(),
- const QString &settingsId = QString(),
+ Id settingsCategory = Id(),
+ Id settingsId = Id(),
QWidget *parent = 0);
static QT_DEPRECATED ActionManager *actionManager(); // Use Actionmanager::... directly.
@@ -118,7 +117,6 @@ public:
// Adds and removes additional active contexts, these contexts are appended
// to the currently active contexts.
static void updateAdditionalContexts(const Context &remove, const Context &add);
- static bool hasContext(int context);
static void addContextObject(IContext *context);
static void removeContextObject(IContext *context);
diff --git a/src/plugins/coreplugin/id.cpp b/src/plugins/coreplugin/id.cpp
index 9dc93e9665..4fac923891 100644
--- a/src/plugins/coreplugin/id.cpp
+++ b/src/plugins/coreplugin/id.cpp
@@ -43,22 +43,39 @@ namespace Core {
/*!
\class Core::Id
- \brief The class Id encapsulates an identifier. It is used as a type-safe
- helper class instead of a \c QString or \c QByteArray. The internal
- representation of the id is assumed to be plain 7-bit-clean ASCII.
+ \brief The class Id encapsulates an identifier that is unique
+ within a specific running Qt Creator process.
+
+ \c{Core::Id} is used as facility to identify objects of interest
+ in a more typesafe and faster manner than a plain \c QString or
+ \c QByteArray would provide.
+
+ An id is internally represented as a 32 bit integer (its \c UID)
+ and associated with a be plain 7-bit-clean ASCII name used
+ for display and persistency.
+
+ Each plugin that is distributed as part of Qt Creator has a
+ private range of 10000 UIDs that are guaranteed to be unique.
+
+ Third party plugins are advised to construct ids from their
+ string representation.
*/
class StringHolder
{
public:
- explicit StringHolder(const char *s)
- : str(s)
+ StringHolder()
+ : n(0), str(0)
+ {}
+
+ StringHolder(const char *s, int length)
+ : n(length), str(s)
{
- n = strlen(s);
- int m = n;
+ if (!n)
+ length = n = strlen(s);
h = 0;
- while (m--) {
+ while (length--) {
h = (h << 4) + *s++;
h ^= (h & 0xf0000000) >> 23;
h &= 0x0fffffff;
@@ -72,7 +89,7 @@ public:
static bool operator==(const StringHolder &sh1, const StringHolder &sh2)
{
// sh.n is unlikely to discriminate better than the hash.
- return sh1.h == sh2.h && strcmp(sh1.str, sh1.str) == 0;
+ return sh1.h == sh2.h && sh1.str && sh2.str && strcmp(sh1.str, sh2.str) == 0;
}
@@ -93,53 +110,228 @@ struct IdCache : public QHash<StringHolder, int>
};
-static int lastUid = 0;
-static QVector<QByteArray> stringFromId;
+static int firstUnusedId = Id::IdsPerPlugin * Id::ReservedPlugins;
+
+static QHash<int, StringHolder> stringFromId;
static IdCache idFromString;
-static int theId(const char *str)
+static int theId(const char *str, int n = 0)
{
QTC_ASSERT(str && *str, return 0);
- StringHolder sh(str);
+ StringHolder sh(str, n);
int res = idFromString.value(sh, 0);
if (res == 0) {
- if (lastUid == 0)
- stringFromId.append(QByteArray());
- res = ++lastUid;
+ res = firstUnusedId++;
sh.str = qstrdup(sh.str);
idFromString[sh] = res;
- stringFromId.append(QByteArray::fromRawData(sh.str, sh.n));
+ stringFromId[res] = sh;
}
return res;
}
+static int theId(const QByteArray &ba)
+{
+ return theId(ba.constData(), ba.size());
+}
+
+/*!
+ \fn Core::Id(int uid)
+
+ \brief Constructs an id given a UID.
+
+ The UID is an integer value that is unique within the running
+ Qt Creator process.
+
+ It is the callers responsibility to ensure the uniqueness of
+ the passed integer. The recommended approach is to use
+ \c{registerId()} with an value taken from the plugin's
+ private range.
+
+ \sa registerId()
+
+*/
+
+/*!
+ Constructs an id given its associated name. The internal
+ representation will be unspecified, but consistent within a
+ Qt Creator process.
+
+*/
Id::Id(const char *name)
- : m_id(theId(name))
+ : m_id(theId(name, 0))
+{}
+
+/*!
+ \overload
+
+*/
+Id::Id(const QByteArray &name)
+ : m_id(theId(name))
{}
+/*!
+ \overload
+ \deprecated
+*/
Id::Id(const QString &name)
: m_id(theId(name.toUtf8()))
{}
+/*!
+ Returns an internal representation of the id.
+*/
+
QByteArray Id::name() const
{
- return stringFromId.at(m_id);
+ return stringFromId.value(m_id).str;
}
+/*!
+ Returns a string representation of the id suitable
+ for UI display.
+
+ This should not be used to create a persistent version
+ of the Id, use \c{toSetting()} instead.
+
+ \sa fromString(), toSetting()
+*/
+
QString Id::toString() const
{
- return QString::fromUtf8(stringFromId.at(m_id));
+ return QString::fromUtf8(stringFromId.value(m_id).str);
+}
+
+/*!
+ Creates an id from a string representation.
+
+ This should not be used to handle a persistent version
+ of the Id, use \c{fromSetting()} instead.
+
+ \deprecated
+
+ \sa toString(), fromSetting()
+*/
+
+Id Id::fromString(const QString &name)
+{
+ return Id(theId(name.toUtf8()));
+}
+
+/*!
+ Creates an id from a string representation.
+
+ This should not be used to handle a persistent version
+ of the Id, use \c{fromSetting()} instead.
+
+ \deprecated
+
+ \sa toString(), fromSetting()
+*/
+
+Id Id::fromName(const QByteArray &name)
+{
+ return Id(theId(name));
+}
+
+/*!
+ Returns a persistent value representing the id which is
+ suitable to be stored in QSettings.
+
+ \sa fromSetting()
+*/
+
+QVariant Id::toSetting() const
+{
+ return QVariant(QString::fromUtf8(stringFromId.value(m_id).str));
+}
+
+/*!
+ Reconstructs an id from a persistent value.
+
+ \sa toSetting()
+*/
+
+Id Id::fromSetting(const QVariant &variant)
+{
+ const QByteArray ba = variant.toString().toUtf8();
+ if (ba.isEmpty())
+ return Id();
+ return Id(theId(ba));
+}
+
+/*!
+ Constructs a derived id.
+
+ This can be used to construct groups of ids logically
+ belonging together. The associated internal name
+ will be generated by appending \c{suffix}.
+*/
+
+Id Id::withSuffix(int suffix) const
+{
+ const QByteArray ba = name() + QByteArray::number(suffix);
+ return Id(ba.constData());
+}
+
+/*!
+ \overload
+*/
+
+Id Id::withSuffix(const char *suffix) const
+{
+ const QByteArray ba = name() + suffix;
+ return Id(ba.constData());
+}
+
+/*!
+ Constructs a derived id.
+
+ This can be used to construct groups of ids logically
+ belonging together. The associated internal name
+ will be generated by prepending \c{prefix}.
+*/
+
+Id Id::withPrefix(const char *prefix) const
+{
+ const QByteArray ba = prefix + name();
+ return Id(ba.constData());
+}
+
+
+/*!
+ Associates a id with its uid and its string
+ representation.
+
+ The uid should be taken from the plugin's private range.
+
+ \sa fromSetting()
+*/
+
+void Id::registerId(int uid, const char *name)
+{
+ StringHolder sh(name, 0);
+ idFromString[sh] = uid;
+ stringFromId[uid] = sh;
}
bool Id::operator==(const char *name) const
{
- return strcmp(stringFromId.at(m_id).constData(), name) == 0;
+ const char *string = stringFromId.value(m_id).str;
+ if (string && name)
+ return strcmp(string, name) == 0;
+ else
+ return false;
}
// For debugging purposes
CORE_EXPORT const char *nameForId(int id)
{
- return (stringFromId.constData() + id)->constData();
+ return stringFromId.value(id).str;
+}
+
+bool Id::alphabeticallyBefore(Id other) const
+{
+ return toString().compare(other.toString(), Qt::CaseInsensitive) < 0;
}
} // namespace Core
diff --git a/src/plugins/coreplugin/id.h b/src/plugins/coreplugin/id.h
index 0185c0cf04..ca23c7f437 100644
--- a/src/plugins/coreplugin/id.h
+++ b/src/plugins/coreplugin/id.h
@@ -34,6 +34,7 @@
#include <QMetaType>
#include <QString>
+#include <QVariant>
namespace Core {
@@ -41,12 +42,21 @@ namespace Core {
class CORE_EXPORT Id
{
public:
+ enum { IdsPerPlugin = 10000, ReservedPlugins = 1000 };
+
Id() : m_id(0) {}
+ Id(int uid) : m_id(uid) {}
Id(const char *name);
- // FIXME: Replace with QByteArray
explicit Id(const QString &name);
+ explicit Id(const QByteArray &name);
+
+ Id withSuffix(int suffix) const;
+ Id withSuffix(const char *name) const;
+ Id withPrefix(const char *name) const;
+
QByteArray name() const;
- QString toString() const;
+ QString toString() const; // Avoid.
+ QVariant toSetting() const; // Good to use.
bool isValid() const { return m_id; }
bool operator==(Id id) const { return m_id == id.m_id; }
bool operator==(const char *name) const;
@@ -54,11 +64,15 @@ public:
bool operator!=(const char *name) const { return !operator==(name); }
bool operator<(Id id) const { return m_id < id.m_id; }
bool operator>(Id id) const { return m_id > id.m_id; }
+ bool alphabeticallyBefore(Id other) const;
int uniqueIdentifier() const { return m_id; }
- static Id fromUniqueIdentifier(int uid) { return Id(uid, uid); }
+ static Id fromUniqueIdentifier(int uid) { return Id(uid); }
+ static Id fromString(const QString &str); // FIXME: avoid.
+ static Id fromName(const QByteArray &ba); // FIXME: avoid.
+ static Id fromSetting(const QVariant &variant); // Good to use.
+ static void registerId(int uid, const char *name);
private:
- Id(int uid, int) : m_id(uid) {}
// Intentionally unimplemented
Id(const QLatin1String &);
int m_id;
diff --git a/src/plugins/coreplugin/idocument.cpp b/src/plugins/coreplugin/idocument.cpp
index 4c3b7dda78..01ec58af3e 100644
--- a/src/plugins/coreplugin/idocument.cpp
+++ b/src/plugins/coreplugin/idocument.cpp
@@ -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));
}
}
}
diff --git a/src/plugins/coreplugin/images/logo/logo.qbs b/src/plugins/coreplugin/images/logo/logo.qbs
index 71737dcffc..c0c401a88b 100644
--- a/src/plugins/coreplugin/images/logo/logo.qbs
+++ b/src/plugins/coreplugin/images/logo/logo.qbs
@@ -2,54 +2,53 @@ import qbs.base 1.0
Product {
condition: qbs.targetOS == "linux"
- type: ["installed_content"]
name: "LogoImages"
Group {
+ qbs.install: true
qbs.installDir: "share/icons/hicolor/16x16/apps"
- fileTags: ["install"]
files: ["16/QtProject-qtcreator.png"]
}
Group {
+ qbs.install: true
qbs.installDir: "share/icons/hicolor/24x24/apps"
- fileTags: ["install"]
files: ["24/QtProject-qtcreator.png"]
}
Group {
+ qbs.install: true
qbs.installDir: "share/icons/hicolor/32x32/apps"
- fileTags: ["install"]
files: ["32/QtProject-qtcreator.png"]
}
Group {
+ qbs.install: true
qbs.installDir: "share/icons/hicolor/48x48/apps"
- fileTags: ["install"]
files: ["48/QtProject-qtcreator.png"]
}
Group {
+ qbs.install: true
qbs.installDir: "share/icons/hicolor/64x64/apps"
- fileTags: ["install"]
files: ["64/QtProject-qtcreator.png"]
}
Group {
+ qbs.install: true
qbs.installDir: "share/icons/hicolor/128x128/apps"
- fileTags: ["install"]
files: ["128/QtProject-qtcreator.png"]
}
Group {
+ qbs.install: true
qbs.installDir: "share/icons/hicolor/256x256/apps"
- fileTags: ["install"]
files: ["256/QtProject-qtcreator.png"]
}
Group {
+ qbs.install: true
qbs.installDir: "share/icons/hicolor/512x512/apps"
- fileTags: ["install"]
files: ["512/QtProject-qtcreator.png"]
}
}
diff --git a/src/plugins/coreplugin/inavigationwidgetfactory.h b/src/plugins/coreplugin/inavigationwidgetfactory.h
index 3292852aae..1f6430ecc5 100644
--- a/src/plugins/coreplugin/inavigationwidgetfactory.h
+++ b/src/plugins/coreplugin/inavigationwidgetfactory.h
@@ -30,7 +30,7 @@
#ifndef INAVIGATIONWIDGET_H
#define INAVIGATIONWIDGET_H
-#include <coreplugin/id.h>
+#include "id.h"
#include <QObject>
#include <QList>
diff --git a/src/plugins/coreplugin/infobar.cpp b/src/plugins/coreplugin/infobar.cpp
index 93c1a08f58..5c028da9ea 100644
--- a/src/plugins/coreplugin/infobar.cpp
+++ b/src/plugins/coreplugin/infobar.cpp
@@ -29,24 +29,30 @@
#include "infobar.h"
-#include <coreplugin/coreconstants.h>
+#include "coreconstants.h"
+#include "icore.h"
#include <QFrame>
#include <QHBoxLayout>
#include <QLabel>
+#include <QSettings>
#include <QToolButton>
-
#include <QVariant>
+static const char C_SUPPRESSED_WARNINGS[] = "SuppressedWarnings";
+
namespace Core {
-InfoBarEntry::InfoBarEntry(const QString &_id, const QString &_infoText)
+QSet<Id> InfoBar::globallySuppressed;
+
+InfoBarEntry::InfoBarEntry(Id _id, const QString &_infoText, GlobalSuppressionMode _globalSuppression)
: id(_id)
, infoText(_infoText)
, object(0)
, buttonPressMember(0)
, cancelObject(0)
, cancelButtonPressMember(0)
+ , globalSuppression(_globalSuppression)
{
}
@@ -77,7 +83,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 +94,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())
@@ -98,6 +104,24 @@ bool InfoBar::containsInfo(const QString &id) const
return false;
}
+// Remove and suppress id
+void InfoBar::suppressInfo(Id id)
+{
+ removeInfo(id);
+ m_suppressed << id;
+}
+
+// Info can not be added more than once, or if it is suppressed
+bool InfoBar::canInfoBeAdded(Id id) const
+{
+ return !containsInfo(id) && !m_suppressed.contains(id) && !globallySuppressed.contains(id);
+}
+
+void InfoBar::enableInfo(Id id)
+{
+ m_suppressed.remove(id);
+}
+
void InfoBar::clear()
{
if (!m_infoBarEntries.isEmpty()) {
@@ -106,6 +130,28 @@ void InfoBar::clear()
}
}
+void InfoBar::globallySuppressInfo(Id id)
+{
+ globallySuppressed.insert(id);
+ QStringList list;
+ foreach (Id i, globallySuppressed)
+ list << QLatin1String(i.name());
+ ICore::settings()->setValue(QLatin1String(C_SUPPRESSED_WARNINGS), list);
+}
+
+void InfoBar::initializeGloballySuppressed()
+{
+ QStringList list = ICore::settings()->value(QLatin1String(C_SUPPRESSED_WARNINGS)).toStringList();
+ foreach (const QString &id, list)
+ globallySuppressed.insert(Id::fromString(id));
+}
+
+void InfoBar::clearGloballySuppressed()
+{
+ globallySuppressed.clear();
+ ICore::settings()->setValue(QLatin1String(C_SUPPRESSED_WARNINGS), QStringList());
+}
+
InfoBarDisplay::InfoBarDisplay(QObject *parent)
: QObject(parent)
@@ -182,8 +228,16 @@ void InfoBarDisplay::update()
hbox->addWidget(infoWidgetButton);
}
+ QToolButton *infoWidgetSuppressButton = 0;
+ if (info.globalSuppression == InfoBarEntry::GlobalSuppressionEnabled) {
+ infoWidgetSuppressButton = new QToolButton;
+ infoWidgetSuppressButton->setProperty("infoId", info.id.uniqueIdentifier());
+ infoWidgetSuppressButton->setText(tr("Do not show again"));
+ connect(infoWidgetSuppressButton, SIGNAL(clicked()), SLOT(suppressButtonClicked()));
+ }
+
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
@@ -196,12 +250,16 @@ void InfoBarDisplay::update()
infoWidgetCloseButton->setAutoRaise(true);
infoWidgetCloseButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_CLEAR)));
infoWidgetCloseButton->setToolTip(tr("Close"));
+ if (infoWidgetSuppressButton)
+ hbox->addWidget(infoWidgetSuppressButton);
+ hbox->addWidget(infoWidgetCloseButton);
} else {
infoWidgetCloseButton->setText(info.cancelButtonText);
+ hbox->addWidget(infoWidgetCloseButton);
+ if (infoWidgetSuppressButton)
+ hbox->addWidget(infoWidgetSuppressButton);
}
- hbox->addWidget(infoWidgetCloseButton);
-
connect(infoWidget, SIGNAL(destroyed()), SLOT(widgetDestroyed()));
m_boxLayout->insertWidget(m_boxIndex, infoWidget);
m_infoWidgets << infoWidget;
@@ -210,13 +268,19 @@ void InfoBarDisplay::update()
void InfoBarDisplay::widgetDestroyed()
{
- // This means that the parent is being deleted
- m_infoWidgets.clear();
+ m_infoWidgets.removeOne(static_cast<QWidget *>(sender()));
}
void InfoBarDisplay::cancelButtonClicked()
{
- m_infoBar->removeInfo(sender()->property("infoId").toString());
+ m_infoBar->suppressInfo(Id::fromUniqueIdentifier(sender()->property("infoId").toInt()));
+}
+
+void InfoBarDisplay::suppressButtonClicked()
+{
+ Id id = Id::fromUniqueIdentifier(sender()->property("infoId").toInt());
+ m_infoBar->removeInfo(id);
+ InfoBar::globallySuppressInfo(id);
}
} // namespace Core
diff --git a/src/plugins/coreplugin/infobar.h b/src/plugins/coreplugin/infobar.h
index bcc71ebc02..cd1043529d 100644
--- a/src/plugins/coreplugin/infobar.h
+++ b/src/plugins/coreplugin/infobar.h
@@ -31,8 +31,10 @@
#define INFOBAR_H
#include "core_global.h"
+#include <coreplugin/id.h>
#include <QObject>
+#include <QSet>
QT_BEGIN_NAMESPACE
class QBoxLayout;
@@ -46,14 +48,20 @@ class InfoBarDisplay;
class CORE_EXPORT InfoBarEntry
{
public:
- InfoBarEntry(const QString &_id, const QString &_infoText);
+ enum GlobalSuppressionMode
+ {
+ GlobalSuppressionDisabled,
+ GlobalSuppressionEnabled
+ };
+
+ InfoBarEntry(Id _id, const QString &_infoText, GlobalSuppressionMode _globalSuppression = GlobalSuppressionDisabled);
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;
@@ -61,6 +69,7 @@ private:
QString cancelButtonText;
QObject *cancelObject;
const char *cancelButtonPressMember;
+ GlobalSuppressionMode globalSuppression;
friend class InfoBar;
friend class InfoBarDisplay;
};
@@ -71,15 +80,23 @@ 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 suppressInfo(Id id);
+ bool canInfoBeAdded(Id id) const;
+ void enableInfo(Id id);
void clear();
+ static void globallySuppressInfo(Id id);
+ static void initializeGloballySuppressed();
+ static void clearGloballySuppressed();
signals:
void changed();
private:
QList<InfoBarEntry> m_infoBarEntries;
+ QSet<Id> m_suppressed;
+ static QSet<Id> globallySuppressed;
friend class InfoBarDisplay;
};
@@ -94,6 +111,7 @@ public:
private slots:
void cancelButtonClicked();
+ void suppressButtonClicked();
void update();
void infoBarDestroyed();
void widgetDestroyed();
diff --git a/src/plugins/coreplugin/iversioncontrol.cpp b/src/plugins/coreplugin/iversioncontrol.cpp
index 170df09053..cfa3033272 100644
--- a/src/plugins/coreplugin/iversioncontrol.cpp
+++ b/src/plugins/coreplugin/iversioncontrol.cpp
@@ -41,4 +41,9 @@ QString IVersionControl::vcsMakeWritableText() const
return QString();
}
+QString IVersionControl::vcsTopic(const QString &)
+{
+ return QString();
+}
+
}
diff --git a/src/plugins/coreplugin/iversioncontrol.h b/src/plugins/coreplugin/iversioncontrol.h
index 9fa86b1b56..acee0f9cb1 100644
--- a/src/plugins/coreplugin/iversioncontrol.h
+++ b/src/plugins/coreplugin/iversioncontrol.h
@@ -137,6 +137,11 @@ public:
virtual QString vcsGetRepositoryURL(const QString &director) = 0;
/*!
+ * Topic (e.g. name of the current branch)
+ */
+ virtual QString vcsTopic(const QString &directory);
+
+ /*!
* Create a snapshot of the current state and return an identifier or
* an empty string in case of failure.
*/
diff --git a/src/plugins/coreplugin/mainwindow.cpp b/src/plugins/coreplugin/mainwindow.cpp
index 7ee1416bca..05160a942c 100644
--- a/src/plugins/coreplugin/mainwindow.cpp
+++ b/src/plugins/coreplugin/mainwindow.cpp
@@ -82,6 +82,7 @@
#include <coreplugin/inavigationwidgetfactory.h>
#include <coreplugin/settingsdatabase.h>
#include <utils/historycompleter.h>
+#include <utils/hostosinfo.h>
#include <utils/pathchooser.h>
#include <utils/stylehelper.h>
#include <utils/stringutils.h>
@@ -179,28 +180,27 @@ MainWindow::MainWindow() :
Utils::HistoryCompleter::setSettings(m_settings);
setWindowTitle(tr("Qt Creator"));
-#ifndef Q_OS_MAC
- QApplication::setWindowIcon(QIcon(QLatin1String(Constants::ICON_QTLOGO_128)));
-#endif
+ if (!Utils::HostOsInfo::isMacHost())
+ QApplication::setWindowIcon(QIcon(QLatin1String(Constants::ICON_QTLOGO_128)));
QCoreApplication::setApplicationName(QLatin1String("QtCreator"));
QCoreApplication::setApplicationVersion(QLatin1String(Core::Constants::IDE_VERSION_LONG));
QCoreApplication::setOrganizationName(QLatin1String(Constants::IDE_SETTINGSVARIANT_STR));
QString baseName = QApplication::style()->objectName();
-#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
- if (baseName == QLatin1String("windows")) {
- // Sometimes we get the standard windows 95 style as a fallback
- if (QStyleFactory::keys().contains("Fusion"))
- baseName = QLatin1String("fusion"); // Qt5
- else { // Qt4
- // e.g. if we are running on a KDE4 desktop
- QByteArray desktopEnvironment = qgetenv("DESKTOP_SESSION");
- if (desktopEnvironment == "kde")
- baseName = QLatin1String("plastique");
- else
- baseName = QLatin1String("cleanlooks");
+ if (Utils::HostOsInfo::isAnyUnixHost() && !Utils::HostOsInfo::isMacHost()) {
+ if (baseName == QLatin1String("windows")) {
+ // Sometimes we get the standard windows 95 style as a fallback
+ if (QStyleFactory::keys().contains(QLatin1String("Fusion")))
+ baseName = QLatin1String("fusion"); // Qt5
+ else { // Qt4
+ // e.g. if we are running on a KDE4 desktop
+ QByteArray desktopEnvironment = qgetenv("DESKTOP_SESSION");
+ if (desktopEnvironment == "kde")
+ baseName = QLatin1String("plastique");
+ else
+ baseName = QLatin1String("cleanlooks");
+ }
}
}
-#endif
qApp->setStyle(new ManhattanStyle(baseName));
setDockNestingEnabled(true);
@@ -430,11 +430,10 @@ static bool isDesktopFileManagerDrop(const QMimeData *d, QStringList *files = 0)
const QString fileName = it->toLocalFile();
if (!fileName.isEmpty()) {
hasFiles = true;
- if (files) {
+ if (files)
files->push_back(fileName);
- } else {
+ else
break; // No result list, sufficient for checking
- }
}
}
return hasFiles;
@@ -442,11 +441,10 @@ static bool isDesktopFileManagerDrop(const QMimeData *d, QStringList *files = 0)
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
{
- if (isDesktopFileManagerDrop(event->mimeData()) && m_filesToOpenDelayed.isEmpty()) {
+ if (isDesktopFileManagerDrop(event->mimeData()) && m_filesToOpenDelayed.isEmpty())
event->accept();
- } else {
+ else
event->ignore();
- }
}
void MainWindow::dropEvent(QDropEvent *event)
@@ -485,9 +483,8 @@ void MainWindow::registerDefaultContainers()
{
ActionContainer *menubar = ActionManager::createMenuBar(Constants::MENU_BAR);
-#ifndef Q_OS_MAC // System menu bar on Mac
- setMenuBar(menubar->menuBar());
-#endif
+ if (!Utils::HostOsInfo::isMacHost()) // System menu bar on Mac
+ setMenuBar(menubar->menuBar());
menubar->appendGroup(Constants::G_FILE);
menubar->appendGroup(Constants::G_EDIT);
menubar->appendGroup(Constants::G_VIEW);
@@ -745,19 +742,18 @@ void MainWindow::registerDefaultActions()
mwindow->addAction(cmd, Constants::G_WINDOW_VIEWS);
m_toggleSideBarAction->setEnabled(false);
+
#if defined(Q_OS_MAC)
- bool fullScreenCheckable = false;
const QString fullScreenActionText(tr("Enter Full Screen"));
bool supportsFullScreen = MacFullScreen::supportsFullScreen();
#else
- bool fullScreenCheckable = true;
const QString fullScreenActionText(tr("Full Screen"));
bool supportsFullScreen = true;
#endif
if (supportsFullScreen) {
// Full Screen Action
m_toggleFullScreenAction = new QAction(fullScreenActionText, this);
- m_toggleFullScreenAction->setCheckable(fullScreenCheckable);
+ m_toggleFullScreenAction->setCheckable(!Utils::HostOsInfo::isMacHost());
cmd = ActionManager::registerAction(m_toggleFullScreenAction, Constants::TOGGLE_FULLSCREEN, globalContext);
cmd->setDefaultKeySequence(QKeySequence(UseMacShortcuts ? tr("Ctrl+Meta+F") : tr("Ctrl+Shift+F11")));
cmd->setAttribute(Command::CA_UpdateText); /* for Mac */
@@ -772,17 +768,15 @@ void MainWindow::registerDefaultActions()
// About IDE Action
icon = QIcon::fromTheme(QLatin1String("help-about"));
-#ifdef Q_OS_MAC
- tmpaction = new QAction(icon, tr("About &Qt Creator"), this); // it's convention not to add dots to the about menu
-#else
- tmpaction = new QAction(icon, tr("About &Qt Creator..."), this);
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ tmpaction = new QAction(icon, tr("About &Qt Creator"), this); // it's convention not to add dots to the about menu
+ else
+ tmpaction = new QAction(icon, tr("About &Qt Creator..."), this);
cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_QTCREATOR, globalContext);
mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
tmpaction->setEnabled(true);
-#ifdef Q_OS_MAC
- cmd->action()->setMenuRole(QAction::ApplicationSpecificRole);
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ cmd->action()->setMenuRole(QAction::ApplicationSpecificRole);
connect(tmpaction, SIGNAL(triggered()), this, SLOT(aboutQtCreator()));
//About Plugins Action
@@ -790,9 +784,8 @@ void MainWindow::registerDefaultActions()
cmd = ActionManager::registerAction(tmpaction, Constants::ABOUT_PLUGINS, globalContext);
mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
tmpaction->setEnabled(true);
-#ifdef Q_OS_MAC
- cmd->action()->setMenuRole(QAction::ApplicationSpecificRole);
-#endif
+ if (Utils::HostOsInfo::isMacHost())
+ cmd->action()->setMenuRole(QAction::ApplicationSpecificRole);
connect(tmpaction, SIGNAL(triggered()), this, SLOT(aboutPlugins()));
// About Qt Action
// tmpaction = new QAction(tr("About &Qt..."), this);
@@ -801,12 +794,12 @@ void MainWindow::registerDefaultActions()
// tmpaction->setEnabled(true);
// connect(tmpaction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
// About sep
-#ifndef Q_OS_MAC // doesn't have the "About" actions in the Help menu
- tmpaction = new QAction(this);
- tmpaction->setSeparator(true);
- cmd = ActionManager::registerAction(tmpaction, "QtCreator.Help.Sep.About", globalContext);
- mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
-#endif
+ if (!Utils::HostOsInfo::isMacHost()) { // doesn't have the "About" actions in the Help menu
+ tmpaction = new QAction(this);
+ tmpaction->setSeparator(true);
+ cmd = ActionManager::registerAction(tmpaction, "QtCreator.Help.Sep.About", globalContext);
+ mhelp->addAction(cmd, Constants::G_HELP_ABOUT);
+ }
}
void MainWindow::newFile()
@@ -965,9 +958,7 @@ void MainWindow::showNewItemDialog(const QString &title,
wizard->runWizard(path, this, selectedPlatform, extraVariables);
}
-bool MainWindow::showOptionsDialog(const QString &category,
- const QString &page,
- QWidget *parent)
+bool MainWindow::showOptionsDialog(Id category, Id page, QWidget *parent)
{
emit m_coreImpl->optionsDialogRequested();
if (!parent)
@@ -999,11 +990,10 @@ void MainWindow::openFileWith()
const Id editorId = editorManager()->getOpenWithEditorId(fileName, &isExternal);
if (!editorId.isValid())
continue;
- if (isExternal) {
+ if (isExternal)
EditorManager::openExternalEditor(fileName, editorId);
- } else {
+ else
EditorManager::openEditor(fileName, editorId, Core::EditorManager::ModeSwitch);
- }
}
}
@@ -1127,9 +1117,8 @@ void MainWindow::updateFocusWidget(QWidget *old, QWidget *now)
return;
IContext *newContext = 0;
- if (focusWidget()) {
+ if (QWidget *p = qApp->focusWidget()) {
IContext *context = 0;
- QWidget *p = focusWidget();
while (p) {
context = m_contextWidgets.value(p);
if (context) {
@@ -1186,9 +1175,8 @@ void MainWindow::readSettings()
QColor(Utils::StyleHelper::DEFAULT_BASE_COLOR)).value<QColor>());
}
- if (!restoreGeometry(m_settings->value(QLatin1String(windowGeometryKey)).toByteArray())) {
+ if (!restoreGeometry(m_settings->value(QLatin1String(windowGeometryKey)).toByteArray()))
resize(1008, 700); // size without window decoration
- }
restoreState(m_settings->value(QLatin1String(windowStateKey)).toByteArray());
m_settings->endGroup();
@@ -1218,31 +1206,26 @@ void MainWindow::writeSettings()
void MainWindow::updateAdditionalContexts(const Context &remove, const Context &add)
{
- foreach (const int context, remove) {
- if (context == 0)
+ foreach (const Id id, remove) {
+ if (!id.isValid())
continue;
- int index = m_additionalContexts.indexOf(context);
+ int index = m_additionalContexts.indexOf(id);
if (index != -1)
m_additionalContexts.removeAt(index);
}
- foreach (const int context, add) {
- if (context == 0)
+ foreach (const Id id, add) {
+ if (!id.isValid())
continue;
- if (!m_additionalContexts.contains(context))
- m_additionalContexts.prepend(context);
+ if (!m_additionalContexts.contains(id))
+ m_additionalContexts.prepend(id);
}
updateContext();
}
-bool MainWindow::hasContext(int context) const
-{
- return ActionManager::hasContext(context);
-}
-
void MainWindow::updateContext()
{
Context contexts;
@@ -1254,9 +1237,9 @@ void MainWindow::updateContext()
Context uniquecontexts;
for (int i = 0; i < contexts.size(); ++i) {
- const int c = contexts.at(i);
- if (!uniquecontexts.contains(c))
- uniquecontexts.add(c);
+ const Id id = contexts.at(i);
+ if (!uniquecontexts.contains(id))
+ uniquecontexts.add(id);
}
m_actionManager->d->setContext(uniquecontexts);
@@ -1354,8 +1337,8 @@ void MainWindow::setFullScreen(bool on)
bool MainWindow::showWarningWithOptions(const QString &title,
const QString &text,
const QString &details,
- const QString &settingsCategory,
- const QString &settingsId,
+ Id settingsCategory,
+ Id settingsId,
QWidget *parent)
{
if (parent == 0)
@@ -1365,11 +1348,10 @@ bool MainWindow::showWarningWithOptions(const QString &title,
if (!details.isEmpty())
msgBox.setDetailedText(details);
QAbstractButton *settingsButton = 0;
- if (!settingsId.isEmpty() || !settingsCategory.isEmpty())
+ if (settingsId.isValid() || settingsCategory.isValid())
settingsButton = msgBox.addButton(tr("Settings..."), QMessageBox::AcceptRole);
msgBox.exec();
- if (settingsButton && msgBox.clickedButton() == settingsButton) {
+ if (settingsButton && msgBox.clickedButton() == settingsButton)
return showOptionsDialog(settingsCategory, settingsId);
- }
return false;
}
diff --git a/src/plugins/coreplugin/mainwindow.h b/src/plugins/coreplugin/mainwindow.h
index ac519bfd8c..48b17eed02 100644
--- a/src/plugins/coreplugin/mainwindow.h
+++ b/src/plugins/coreplugin/mainwindow.h
@@ -115,7 +115,6 @@ public:
QStatusBar *statusBar() const;
void updateAdditionalContexts(const Context &remove, const Context &add);
- bool hasContext(int context) const;
void setSuppressNavigationWidget(bool suppress);
@@ -138,14 +137,12 @@ public slots:
const QString &defaultLocation = QString(),
const QVariantMap &extraVariables = QVariantMap());
- bool showOptionsDialog(const QString &category = QString(),
- const QString &page = QString(),
- QWidget *parent = 0);
+ bool showOptionsDialog(Id category = Id(), Id page = Id(), QWidget *parent = 0);
bool showWarningWithOptions(const QString &title, const QString &text,
const QString &details = QString(),
- const QString &settingsCategory = QString(),
- const QString &settingsId = QString(),
+ Id settingsCategory = Id(),
+ Id settingsId = Id(),
QWidget *parent = 0);
protected:
diff --git a/src/plugins/coreplugin/manhattanstyle.cpp b/src/plugins/coreplugin/manhattanstyle.cpp
index 8d1a1fbeba..69e6ce4888 100644
--- a/src/plugins/coreplugin/manhattanstyle.cpp
+++ b/src/plugins/coreplugin/manhattanstyle.cpp
@@ -718,7 +718,20 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
editRect.adjust(0, 0, -13, 0);
}
- QString text = option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, editRect.width());
+ QLatin1Char asterisk('*');
+ int elideWidth = editRect.width();
+
+ bool notElideAsterisk = widget && widget->property("notelideasterisk").toBool()
+ && cb->currentText.endsWith(asterisk)
+ && option->fontMetrics.width(cb->currentText) > elideWidth;
+
+ QString text;
+ if (notElideAsterisk) {
+ elideWidth -= option->fontMetrics.width(asterisk);
+ text = asterisk;
+ }
+ text.prepend(option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, elideWidth));
+
if ((option->state & State_Enabled)) {
painter->setPen(QColor(0, 0, 0, 70));
painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text);
@@ -852,9 +865,8 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
State bflags = toolbutton->state;
if (bflags & State_AutoRaise) {
- if (!(bflags & State_MouseOver)) {
+ if (!(bflags & State_MouseOver))
bflags &= ~State_Raised;
- }
}
State mflags = bflags;
diff --git a/src/plugins/coreplugin/mimedatabase.cpp b/src/plugins/coreplugin/mimedatabase.cpp
index 74ae41aab1..3066cb2e03 100644
--- a/src/plugins/coreplugin/mimedatabase.cpp
+++ b/src/plugins/coreplugin/mimedatabase.cpp
@@ -1073,11 +1073,10 @@ bool BaseMimeTypeParser::parse(QIODevice *dev, const QString &fileName, QString
switch (ps) {
case ParseMimeType: { // start parsing a type
const QString type = atts.value(QLatin1String(mimeTypeAttributeC)).toString();
- if (type.isEmpty()) {
+ if (type.isEmpty())
reader.raiseError(QString::fromLatin1("Missing 'type'-attribute"));
- } else {
+ else
data.type = type;
- }
}
break;
case ParseGlobPattern:
@@ -1093,12 +1092,11 @@ bool BaseMimeTypeParser::parse(QIODevice *dev, const QString &fileName, QString
case ParseComment: {
// comments have locale attributes. We want the default, English one
QString locale = atts.value(QLatin1String(localeAttributeC)).toString();
- const QString comment = QCoreApplication::translate("MimeType", reader.readElementText().toAscii());
- if (locale.isEmpty()) {
+ const QString comment = QCoreApplication::translate("MimeType", reader.readElementText().toLatin1());
+ if (locale.isEmpty())
data.comment = comment;
- } else {
+ else
data.localeComments.insert(locale, comment);
- }
}
break;
case ParseAlias: {
@@ -1357,14 +1355,13 @@ bool MimeDatabasePrivate::addMimeType(MimeType mt)
}
// insert the type.
m_typeMimeTypeMap.insert(type, MimeMapEntry(mt));
- // Register the children, resolved via alias map. Note that it is still
- // possible that aliases end up in the map if the parent classes are not inserted
- // at this point (thus their aliases not known).
+ // Register the children
+ // Aliases will be resolved later once all mime types are known.
const QStringList subClassesOf = mt.subClassesOf();
if (!subClassesOf.empty()) {
const QStringList::const_iterator socend = subClassesOf.constEnd();
for (QStringList::const_iterator soit = subClassesOf.constBegin(); soit != socend; ++soit)
- m_parentChildrenMap.insert(resolveAlias(*soit), type);
+ m_parentChildrenMap.insert(*soit, type);
}
// register aliasses
const QStringList aliases = mt.aliases();
@@ -1391,7 +1388,9 @@ void MimeDatabasePrivate::raiseLevelRecursion(MimeMapEntry &e, int level)
m_maxLevel = level;
// At all events recurse over children since nodes might have been
// added.
- const QStringList childTypes = m_parentChildrenMap.values(e.type.type());
+ QStringList childTypes = m_parentChildrenMap.values(e.type.type());
+ foreach (const QString &alias, e.type.aliases())
+ childTypes.append(m_parentChildrenMap.values(alias));
if (childTypes.empty())
return;
// look them up in the type->mime type map
@@ -1466,11 +1465,10 @@ MimeType MimeDatabasePrivate::findByFile(const QFileInfo &f) const
qDebug() << '>' << Q_FUNC_INFO << f.absoluteFilePath();
const MimeType rc = findByFile(f, &priority);
if (debugMimeDB) {
- if (rc) {
+ if (rc)
qDebug() << "<MimeDatabase::findByFile: match prio=" << priority << rc.type();
- } else {
+ else
qDebug() << "<MimeDatabase::findByFile: no match";
- }
}
return rc;
}
@@ -1495,8 +1493,8 @@ MimeType MimeDatabasePrivate::findByFile(const QFileInfo &f, unsigned *priorityP
// Pass 1) Try to match on suffix
const TypeMimeTypeMap::const_iterator cend = m_typeMimeTypeMap.constEnd();
- for (int level = m_maxLevel; level >= 0 && candidate.isNull(); level--)
- for (TypeMimeTypeMap::const_iterator it = m_typeMimeTypeMap.constBegin(); it != cend; ++it)
+ for (int level = m_maxLevel; level >= 0 && candidate.isNull(); level--) {
+ for (TypeMimeTypeMap::const_iterator it = m_typeMimeTypeMap.constBegin(); it != cend; ++it) {
if (it.value().level == level) {
const unsigned suffixPriority = it.value().type.matchesFileBySuffix(context);
if (suffixPriority && suffixPriority > *priorityPtr) {
@@ -1506,12 +1504,14 @@ MimeType MimeDatabasePrivate::findByFile(const QFileInfo &f, unsigned *priorityP
return candidate;
}
}
+ }
+ }
// Pass 2) Match on content
if (!f.isReadable())
return candidate;
- for (int level = m_maxLevel; level >= 0; level--)
- for (TypeMimeTypeMap::const_iterator it = m_typeMimeTypeMap.constBegin(); it != cend; ++it)
+ for (int level = m_maxLevel; level >= 0; level--) {
+ for (TypeMimeTypeMap::const_iterator it = m_typeMimeTypeMap.constBegin(); it != cend; ++it) {
if (it.value().level == level) {
const unsigned contentPriority = it.value().type.matchesFileByContent(context);
if (contentPriority && contentPriority > *priorityPtr) {
@@ -1519,6 +1519,8 @@ MimeType MimeDatabasePrivate::findByFile(const QFileInfo &f, unsigned *priorityP
candidate = it.value().type;
}
}
+ }
+ }
return candidate;
}
@@ -1531,11 +1533,10 @@ MimeType MimeDatabasePrivate::findByData(const QByteArray &data) const
qDebug() << '>' << Q_FUNC_INFO << data.left(20).toHex();
const MimeType rc = findByData(data, &priority);
if (debugMimeDB) {
- if (rc) {
+ if (rc)
qDebug() << "<MimeDatabase::findByData: match prio=" << priority << rc.type();
- } else {
+ else
qDebug() << "<MimeDatabase::findByData: no match";
- }
}
return rc;
}
@@ -1672,11 +1673,11 @@ QList<MimeType> MimeDatabasePrivate::readUserModifiedMimeTypes()
switch (reader.readNext()) {
case QXmlStreamReader::StartElement:
atts = reader.attributes();
- if (reader.name() == mimeTypeTagC) {
+ if (reader.name() == QLatin1String(mimeTypeTagC)) {
mimeType.setType(atts.value(mimeTypeAttribute).toString());
const QString &patterns = atts.value(patternAttribute).toString();
mimeType.setGlobPatterns(toGlobPatterns(patterns.split(kSemiColon)));
- } else if (reader.name() == matchTagC) {
+ } else if (reader.name() == QLatin1String(matchTagC)) {
const QString &value = atts.value(matchValueAttribute).toString();
const QString &type = atts.value(matchTypeAttribute).toString();
const QString &offset = atts.value(matchOffsetAttribute).toString();
@@ -1692,7 +1693,7 @@ QList<MimeType> MimeDatabasePrivate::readUserModifiedMimeTypes()
}
break;
case QXmlStreamReader::EndElement:
- if (reader.name() == mimeTypeTagC) {
+ if (reader.name() == QLatin1String(mimeTypeTagC)) {
mimeType.setMagicRuleMatchers(MagicRuleMatcher::createMatchers(rules));
mimeTypes.append(mimeType);
mimeType.clear();
diff --git a/src/plugins/coreplugin/mimetypesettings.cpp b/src/plugins/coreplugin/mimetypesettings.cpp
index 386c524631..11ac480ebb 100644
--- a/src/plugins/coreplugin/mimetypesettings.cpp
+++ b/src/plugins/coreplugin/mimetypesettings.cpp
@@ -232,6 +232,7 @@ public slots:
void removeMagicHeader();
void editMagicHeader();
void resetMimeTypes();
+ void updateMagicHeaderButtons();
public:
static const QChar kSemiColon;
@@ -281,6 +282,11 @@ void MimeTypeSettingsPrivate::configureUi(QWidget *w)
connect(m_ui.removeMagicButton, SIGNAL(clicked()), this, SLOT(removeMagicHeader()));
connect(m_ui.editMagicButton, SIGNAL(clicked()), this, SLOT(editMagicHeader()));
connect(m_ui.resetButton, SIGNAL(clicked()), this, SLOT(resetMimeTypes()));
+ connect(m_ui.magicHeadersTableWidget->selectionModel(),
+ SIGNAL(currentChanged(QModelIndex,QModelIndex)),
+ this,
+ SLOT(updateMagicHeaderButtons()));
+ updateMagicHeaderButtons();
}
void MimeTypeSettingsPrivate::configureTable(QTableView *tableView)
@@ -538,14 +544,23 @@ void MimeTypeSettingsPrivate::resetMimeTypes()
m_reset = true;
}
+void MimeTypeSettingsPrivate::updateMagicHeaderButtons()
+{
+ const QModelIndex &modelIndex = m_ui.magicHeadersTableWidget->selectionModel()->currentIndex();
+ const bool enabled = modelIndex.isValid();
+
+ m_ui.removeMagicButton->setEnabled(enabled);
+ m_ui.editMagicButton->setEnabled(enabled);
+}
+
// MimeTypeSettingsPage
MimeTypeSettings::MimeTypeSettings(QObject *parent)
: IOptionsPage(parent)
, d(new MimeTypeSettingsPrivate)
{
- setId(QLatin1String(Core::Constants::SETTINGS_ID_MIMETYPES));
+ setId(Core::Constants::SETTINGS_ID_MIMETYPES);
setDisplayName(tr("MIME Types"));
- setCategory(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE));
+ setCategory(Core::Constants::SETTINGS_CATEGORY_CORE);
setDisplayCategory(QCoreApplication::translate("Core",
Core::Constants::SETTINGS_TR_CATEGORY_CORE));
setCategoryIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
diff --git a/src/plugins/coreplugin/modemanager.cpp b/src/plugins/coreplugin/modemanager.cpp
index 0294c099e5..b0b10fc1cd 100644
--- a/src/plugins/coreplugin/modemanager.cpp
+++ b/src/plugins/coreplugin/modemanager.cpp
@@ -198,7 +198,7 @@ void ModeManager::objectAdded(QObject *obj)
d->m_modeStack->setTabEnabled(index, mode->isEnabled());
// Register mode shortcut
- const Id shortcutId(QLatin1String("QtCreator.Mode.") + mode->id().toString());
+ const Id shortcutId = mode->id().withPrefix("QtCreator.Mode.");
QShortcut *shortcut = new QShortcut(d->m_mainWindow);
shortcut->setWhatsThis(tr("Switch to <b>%1</b> mode").arg(mode->displayName()));
Command *cmd = ActionManager::registerShortcut(shortcut, shortcutId, Context(Constants::C_GLOBAL));
diff --git a/src/plugins/coreplugin/navigationsubwidget.cpp b/src/plugins/coreplugin/navigationsubwidget.cpp
index 9c748f7229..7f2e979532 100644
--- a/src/plugins/coreplugin/navigationsubwidget.cpp
+++ b/src/plugins/coreplugin/navigationsubwidget.cpp
@@ -174,7 +174,7 @@ void NavigationSubWidget::restoreSettings()
Core::Command *NavigationSubWidget::command(const QString &title) const
{
const QHash<Id, Command *> commandMap = m_parentWidget->commandMap();
- QHash<Id, Command *>::const_iterator r = commandMap.find(Id(title));
+ QHash<Id, Command *>::const_iterator r = commandMap.find(Id::fromString(title));
if (r != commandMap.end())
return r.value();
return 0;
diff --git a/src/plugins/coreplugin/navigationwidget.cpp b/src/plugins/coreplugin/navigationwidget.cpp
index 1513a94bfe..70098f0727 100644
--- a/src/plugins/coreplugin/navigationwidget.cpp
+++ b/src/plugins/coreplugin/navigationwidget.cpp
@@ -195,7 +195,7 @@ void NavigationWidget::setFactories(const QList<INavigationWidgetFactory *> fact
d->m_shortcutMap.insert(shortcut, id);
Command *cmd = ActionManager::registerShortcut(shortcut,
- Id(QLatin1String("QtCreator.Sidebar.") + QLatin1String(id.name())), navicontext);
+ id.withPrefix("QtCreator.Sidebar."), navicontext);
cmd->setDefaultKeySequence(factory->activationSequence());
d->m_commandMap.insert(id, cmd);
@@ -339,7 +339,7 @@ void NavigationWidget::restoreSettings(QSettings *settings)
int position = 0;
foreach (const QString &id, viewIds) {
- int index = factoryIndex(Id(id));
+ int index = factoryIndex(Id::fromString(id));
if (index >= 0) {
// Only add if the id was actually found!
insertSubItem(position, index);
@@ -420,9 +420,8 @@ void NavigationWidget::setSuppressed(bool b)
int NavigationWidget::factoryIndex(const Id &id)
{
for (int row = 0; row < d->m_factoryModel->rowCount(); ++row) {
- if (d->m_factoryModel->data(d->m_factoryModel->index(row, 0), FactoryIdRole).value<Core::Id>() == id) {
+ if (d->m_factoryModel->data(d->m_factoryModel->index(row, 0), FactoryIdRole).value<Core::Id>() == id)
return row;
- }
}
return -1;
}
diff --git a/src/plugins/coreplugin/outputpane.cpp b/src/plugins/coreplugin/outputpane.cpp
index 97b90b0fb6..e046878acf 100644
--- a/src/plugins/coreplugin/outputpane.cpp
+++ b/src/plugins/coreplugin/outputpane.cpp
@@ -113,7 +113,7 @@ void OutputPanePlaceHolder::maximizeOrMinimize(bool maximize)
if (maximize) {
d->m_lastNonMaxSize = sizes[idx];
int sum = 0;
- foreach(int s, sizes)
+ foreach (int s, sizes)
sum += s;
for (int i = 0; i < sizes.count(); ++i) {
sizes[i] = 32;
diff --git a/src/plugins/coreplugin/outputpanemanager.cpp b/src/plugins/coreplugin/outputpanemanager.cpp
index c79c05cde6..c9baeb50a5 100644
--- a/src/plugins/coreplugin/outputpanemanager.cpp
+++ b/src/plugins/coreplugin/outputpanemanager.cpp
@@ -47,6 +47,7 @@
#include <extensionsystem/pluginmanager.h>
+#include <utils/hostosinfo.h>
#include <utils/styledbar.h>
#include <utils/qtcassert.h>
@@ -197,11 +198,7 @@ QWidget *OutputPaneManager::buttonsWidget()
// Return shortcut as Ctrl+<number>
static inline int paneShortCut(int number)
{
-#ifdef Q_OS_MAC
- int modifier = Qt::CTRL;
-#else
- int modifier = Qt::ALT;
-#endif
+ const int modifier = Utils::HostOsInfo::isMacHost() ? Qt::CTRL : Qt::ALT;
return modifier | (Qt::Key_0 + number);
}
@@ -278,7 +275,7 @@ void OutputPaneManager::init()
QString actionId = QLatin1String("QtCreator.Pane.") + outPane->displayName().simplified();
actionId.remove(QLatin1Char(' '));
- Id id(actionId);
+ Id id = Id::fromString(actionId);
QAction *action = new QAction(outPane->displayName(), this);
Command *cmd = ActionManager::registerAction(action, id, globalContext);
@@ -320,11 +317,10 @@ void OutputPaneManager::shortcutTriggered()
// then just give it focus.
int current = currentIndex();
if (OutputPanePlaceHolder::isCurrentVisible() && current == idx) {
- if (!outputPane->hasFocus() && outputPane->canFocus()) {
+ if (!outputPane->hasFocus() && outputPane->canFocus())
outputPane->setFocus();
- } else {
+ else
slotHide();
- }
} else {
// Else do the same as clicking on the button does.
buttonTriggered(idx);
@@ -636,7 +632,7 @@ OutputPaneToggleButton::OutputPaneToggleButton(int number, const QString &text,
fnt.setPixelSize(11);
m_label->setFont(fnt);
m_label->setAlignment(Qt::AlignCenter);
- m_label->setStyleSheet("background-color: #818181; color: white; border-radius: 6; padding-left: 4; padding-right: 4;");
+ m_label->setStyleSheet(QLatin1String("background-color: #818181; color: white; border-radius: 6; padding-left: 4; padding-right: 4;"));
m_label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
m_label->hide();
}
@@ -703,9 +699,11 @@ void OutputPaneToggleButton::checkStateSet()
m_flashTimer->stop();
if (isChecked())
- m_label->setStyleSheet("background-color: #e1e1e1; color: #606060; border-radius: 6; padding-left: 4; padding-right: 4;");
+ m_label->setStyleSheet(QLatin1String("background-color: #e1e1e1; color: #606060; "
+ "border-radius: 6; padding-left: 4; padding-right: 4;"));
else
- m_label->setStyleSheet("background-color: #818181; color: white; border-radius: 6; padding-left: 4; padding-right: 4;");
+ m_label->setStyleSheet(QLatin1String("background-color: #818181; color: white; border-radius: 6; "
+ "padding-left: 4; padding-right: 4;"));
}
void OutputPaneToggleButton::flash(int count)
diff --git a/src/plugins/coreplugin/outputwindow.cpp b/src/plugins/coreplugin/outputwindow.cpp
index 9e94ee3567..1ebada52a1 100644
--- a/src/plugins/coreplugin/outputwindow.cpp
+++ b/src/plugins/coreplugin/outputwindow.cpp
@@ -174,9 +174,8 @@ void OutputWindow::setFormatter(OutputFormatter *formatter)
void OutputWindow::showEvent(QShowEvent *e)
{
QPlainTextEdit::showEvent(e);
- if (m_scrollToBottom) {
+ if (m_scrollToBottom)
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
- }
m_scrollToBottom = false;
}
diff --git a/src/plugins/coreplugin/progressmanager/futureprogress.cpp b/src/plugins/coreplugin/progressmanager/futureprogress.cpp
index 5ee85450a0..f227048db6 100644
--- a/src/plugins/coreplugin/progressmanager/futureprogress.cpp
+++ b/src/plugins/coreplugin/progressmanager/futureprogress.cpp
@@ -164,7 +164,7 @@ FutureProgress::FutureProgress(QWidget *parent) :
connect(&d->m_watcher, SIGNAL(progressValueChanged(int)), this, SLOT(setProgressValue(int)));
connect(&d->m_watcher, SIGNAL(progressTextChanged(QString)),
this, SLOT(setProgressText(QString)));
- connect(d->m_progress, SIGNAL(clicked()), this, SLOT(cancel()));
+ connect(d->m_progress, SIGNAL(clicked()), this, SLOT(cancel()));
}
/*!
@@ -247,11 +247,10 @@ void FutureProgress::setFinished()
d->m_progress->setFinished(true);
- if (d->m_watcher.future().isCanceled()) {
+ if (d->m_watcher.future().isCanceled())
d->m_progress->setError(true);
- } else {
+ else
d->m_progress->setError(false);
- }
emit finished();
d->tryToFadeAway();
}
@@ -363,15 +362,13 @@ QString FutureProgress::type() const
void FutureProgress::setKeepOnFinish(KeepOnFinishType keepType)
{
- if (d->m_keep == keepType) {
+ if (d->m_keep == keepType)
return;
- }
d->m_keep = keepType;
//if it is not finished tryToFadeAway is called by setFinished at the end
- if (d->m_watcher.isFinished()) {
+ if (d->m_watcher.isFinished())
d->tryToFadeAway();
- }
}
bool FutureProgress::keepOnFinish() const
diff --git a/src/plugins/coreplugin/progressmanager/progressbar.cpp b/src/plugins/coreplugin/progressmanager/progressbar.cpp
index 63c54a3ffd..63e75195d9 100644
--- a/src/plugins/coreplugin/progressmanager/progressbar.cpp
+++ b/src/plugins/coreplugin/progressmanager/progressbar.cpp
@@ -57,7 +57,7 @@ ProgressBar::~ProgressBar()
bool ProgressBar::event(QEvent *e)
{
- switch(e->type()) {
+ switch (e->type()) {
case QEvent::Enter:
{
QPropertyAnimation *animation = new QPropertyAnimation(this, "cancelButtonFader");
diff --git a/src/plugins/coreplugin/progressmanager/progressmanager.cpp b/src/plugins/coreplugin/progressmanager/progressmanager.cpp
index 2142c828db..5afa119c82 100644
--- a/src/plugins/coreplugin/progressmanager/progressmanager.cpp
+++ b/src/plugins/coreplugin/progressmanager/progressmanager.cpp
@@ -29,8 +29,8 @@
#include "progressmanager_p.h"
#include "progressview.h"
-#include "coreconstants.h"
-#include "icore.h"
+#include "../coreconstants.h"
+#include "../icore.h"
#include <utils/qtcassert.h>
@@ -272,9 +272,8 @@ void ProgressManagerPrivate::cancelTasks(const QString &type)
delete task.key();
task = m_runningTasks.erase(task);
}
- if (found) {
+ if (found)
emit allTasksFinished(type);
- }
}
void ProgressManagerPrivate::cancelAllRunningTasks()
@@ -330,9 +329,8 @@ void ProgressManagerPrivate::taskFinished()
m_runningTasks.remove(task);
delete task;
- if (!m_runningTasks.key(type, 0)) {
+ if (!m_runningTasks.key(type, 0))
emit allTasksFinished(type);
- }
}
void ProgressManagerPrivate::disconnectApplicationTask()
diff --git a/src/plugins/coreplugin/progressmanager/progressview.cpp b/src/plugins/coreplugin/progressmanager/progressview.cpp
index a821c2a110..b4a273d59a 100644
--- a/src/plugins/coreplugin/progressmanager/progressview.cpp
+++ b/src/plugins/coreplugin/progressmanager/progressview.cpp
@@ -69,11 +69,10 @@ FutureProgress *ProgressView::addTask(const QFuture<void> &future,
m_layout->insertWidget(0, progress);
m_taskList.append(progress);
progress->setType(type);
- if (flags.testFlag(ProgressManager::KeepOnFinish)) {
+ if (flags.testFlag(ProgressManager::KeepOnFinish))
progress->setKeepOnFinish(FutureProgress::KeepOnFinishTillUserInteraction);
- } else {
+ else
progress->setKeepOnFinish(FutureProgress::HideOnFinish);
- }
connect(progress, SIGNAL(removeMe()), this, SLOT(slotRemoveTask()));
return progress;
}
diff --git a/src/plugins/coreplugin/rightpane.cpp b/src/plugins/coreplugin/rightpane.cpp
index 4a0cdbaf19..bd90b80c8d 100644
--- a/src/plugins/coreplugin/rightpane.cpp
+++ b/src/plugins/coreplugin/rightpane.cpp
@@ -176,11 +176,10 @@ void RightPaneWidget::saveSettings(QSettings *settings)
void RightPaneWidget::readSettings(QSettings *settings)
{
- if (settings->contains(QLatin1String("RightPane/Visible"))) {
+ if (settings->contains(QLatin1String("RightPane/Visible")))
setShown(settings->value(QLatin1String("RightPane/Visible")).toBool());
- } else {
+ else
setShown(false);
- }
if (settings->contains(QLatin1String("RightPane/Width"))) {
m_width = settings->value(QLatin1String("RightPane/Width")).toInt();
@@ -190,9 +189,8 @@ void RightPaneWidget::readSettings(QSettings *settings)
m_width = 500; //pixel
}
// Apply
- if (RightPanePlaceHolder::m_current) {
+ if (RightPanePlaceHolder::m_current)
RightPanePlaceHolder::m_current->applyStoredSize(m_width);
- }
}
void RightPaneWidget::setShown(bool b)
diff --git a/src/plugins/coreplugin/scriptmanager/scriptmanager.cpp b/src/plugins/coreplugin/scriptmanager/scriptmanager.cpp
index c3af4894eb..71e6465a78 100644
--- a/src/plugins/coreplugin/scriptmanager/scriptmanager.cpp
+++ b/src/plugins/coreplugin/scriptmanager/scriptmanager.cpp
@@ -95,7 +95,7 @@ static QScriptValue inputDialogGetInteger(QScriptContext *context, QScriptEngine
const int maxValue = argumentCount > 5 ? context->argument(5).toInt32() : INT_MAX;
bool ok;
- const int rc = QInputDialog::getInteger(parent, title, label, defaultValue, minValue, maxValue, 1, &ok);
+ const int rc = QInputDialog::getInt(parent, title, label, defaultValue, minValue, maxValue, 1, &ok);
if (!ok)
return QScriptValue(engine, QScriptValue::NullValue);
return QScriptValue(engine, rc);
diff --git a/src/plugins/coreplugin/settingsdatabase.cpp b/src/plugins/coreplugin/settingsdatabase.cpp
index 6756011773..ccfaae9b94 100644
--- a/src/plugins/coreplugin/settingsdatabase.cpp
+++ b/src/plugins/coreplugin/settingsdatabase.cpp
@@ -244,9 +244,8 @@ QStringList SettingsDatabase::childKeys() const
QMapIterator<QString, QVariant> i(d->m_settings);
while (i.hasNext()) {
const QString &key = i.next().key();
- if (key.startsWith(g) && key.indexOf(QLatin1Char('/'), g.length() + 1) == -1) {
+ if (key.startsWith(g) && key.indexOf(QLatin1Char('/'), g.length() + 1) == -1)
children.append(key.mid(g.length() + 1));
- }
}
return children;
diff --git a/src/plugins/coreplugin/sidebar.cpp b/src/plugins/coreplugin/sidebar.cpp
index f73726a8f3..e6b9bd7f7c 100644
--- a/src/plugins/coreplugin/sidebar.cpp
+++ b/src/plugins/coreplugin/sidebar.cpp
@@ -41,6 +41,7 @@
#include <QLayout>
#include <QToolBar>
#include <QAction>
+#include <QPointer>
#include <QToolButton>
namespace Core {
@@ -79,7 +80,7 @@ struct SideBarPrivate {
SideBarPrivate() :m_closeWhenEmpty(false) {}
QList<Internal::SideBarWidget*> m_widgets;
- QMap<QString, QWeakPointer<SideBarItem> > m_itemMap;
+ QMap<QString, QPointer<SideBarItem> > m_itemMap;
QStringList m_availableItemIds;
QStringList m_availableItemTitles;
QStringList m_unavailableItemIds;
@@ -108,7 +109,7 @@ SideBar::SideBar(QList<SideBarItem*> itemList,
SideBar::~SideBar()
{
- foreach (const QWeakPointer<SideBarItem> &i, d->m_itemMap)
+ foreach (const QPointer<SideBarItem> &i, d->m_itemMap)
if (!i.isNull())
delete i.data();
delete d;
@@ -116,8 +117,8 @@ SideBar::~SideBar()
QString SideBar::idForTitle(const QString &title) const
{
- QMapIterator<QString, QWeakPointer<SideBarItem> > iter(d->m_itemMap);
- while(iter.hasNext()) {
+ QMapIterator<QString, QPointer<SideBarItem> > iter(d->m_itemMap);
+ while (iter.hasNext()) {
iter.next();
if (iter.value().data()->title() == title)
return iter.key();
@@ -151,7 +152,7 @@ void SideBar::setCloseWhenEmpty(bool value)
void SideBar::makeItemAvailable(SideBarItem *item)
{
- typedef QMap<QString, QWeakPointer<SideBarItem> >::const_iterator Iterator;
+ typedef QMap<QString, QPointer<SideBarItem> >::const_iterator Iterator;
const Iterator cend = d->m_itemMap.constEnd();
for (Iterator it = d->m_itemMap.constBegin(); it != cend ; ++it) {
@@ -172,7 +173,7 @@ void SideBar::makeItemAvailable(SideBarItem *item)
void SideBar::setUnavailableItemIds(const QStringList &itemIds)
{
// re-enable previous items
- foreach(const QString &id, d->m_unavailableItemIds) {
+ foreach (const QString &id, d->m_unavailableItemIds) {
d->m_availableItemIds.append(id);
d->m_availableItemTitles.append(d->m_itemMap.value(id).data()->title());
}
@@ -265,7 +266,7 @@ void SideBar::saveSettings(QSettings *settings, const QString &name)
views.append(currentItemId);
}
if (views.isEmpty() && d->m_itemMap.size()) {
- QMapIterator<QString, QWeakPointer<SideBarItem> > iter(d->m_itemMap);
+ QMapIterator<QString, QPointer<SideBarItem> > iter(d->m_itemMap);
iter.next();
views.append(iter.key());
}
@@ -321,7 +322,7 @@ void SideBar::readSettings(QSettings *settings, const QString &name)
void SideBar::activateItem(SideBarItem *item)
{
- typedef QMap<QString, QWeakPointer<SideBarItem> >::const_iterator Iterator;
+ typedef QMap<QString, QPointer<SideBarItem> >::const_iterator Iterator;
QString id;
const Iterator cend = d->m_itemMap.constEnd();
diff --git a/src/plugins/coreplugin/sidebarwidget.cpp b/src/plugins/coreplugin/sidebarwidget.cpp
index 3ff6f1c87c..5b3566472c 100644
--- a/src/plugins/coreplugin/sidebarwidget.cpp
+++ b/src/plugins/coreplugin/sidebarwidget.cpp
@@ -94,7 +94,7 @@ SideBarWidget::SideBarWidget(SideBar *sideBar, const QString &id)
qSort(titleList);
QString t = id;
if (titleList.count()) {
- foreach(const QString &itemTitle, titleList)
+ foreach (const QString &itemTitle, titleList)
m_comboBox->addItem(itemTitle, m_sideBar->idForTitle(itemTitle));
m_comboBox->setCurrentIndex(0);
@@ -160,7 +160,7 @@ void SideBarWidget::updateAvailableItems()
titleList.append(currentTitle);
qSort(titleList);
- foreach(const QString &itemTitle, titleList)
+ foreach (const QString &itemTitle, titleList)
m_comboBox->addItem(itemTitle, m_sideBar->idForTitle(itemTitle));
int idx = m_comboBox->findText(currentTitle);
diff --git a/src/plugins/coreplugin/styleanimator.cpp b/src/plugins/coreplugin/styleanimator.cpp
index 8ad1a783f5..bd1a9ae4c1 100644
--- a/src/plugins/coreplugin/styleanimator.cpp
+++ b/src/plugins/coreplugin/styleanimator.cpp
@@ -128,9 +128,8 @@ void StyleAnimator::timerEvent(QTimerEvent *)
delete a;
}
}
- if (animations.size() == 0 && animationTimer.isActive()) {
+ if (animations.size() == 0 && animationTimer.isActive())
animationTimer.stop();
- }
}
void StyleAnimator::stopAnimation(const QWidget *w)
@@ -148,7 +147,6 @@ void StyleAnimator::startAnimation(Animation *t)
{
stopAnimation(t->widget());
animations.append(t);
- if (animations.size() > 0 && !animationTimer.isActive()) {
+ if (animations.size() > 0 && !animationTimer.isActive())
animationTimer.start(35, this);
- }
}
diff --git a/src/plugins/coreplugin/textdocument.h b/src/plugins/coreplugin/textdocument.h
index 0d2a70ffe0..4490880027 100644
--- a/src/plugins/coreplugin/textdocument.h
+++ b/src/plugins/coreplugin/textdocument.h
@@ -53,6 +53,7 @@ public:
const QTextCodec *codec() const;
void setCodec(const QTextCodec *);
void switchUtf8Bom();
+ virtual bool supportsUtf8Bom() { return true; }
ReadResult read(const QString &fileName, QStringList *plainTextList, QString *errorString);
ReadResult read(const QString &fileName, QString *plainText, QString *errorString);
diff --git a/src/plugins/coreplugin/toolsettings.cpp b/src/plugins/coreplugin/toolsettings.cpp
index ea0064e87a..d76af89a1a 100644
--- a/src/plugins/coreplugin/toolsettings.cpp
+++ b/src/plugins/coreplugin/toolsettings.cpp
@@ -50,9 +50,9 @@ using namespace Core::Internal;
ToolSettings::ToolSettings(QObject *parent) :
IOptionsPage(parent)
{
- setId(QLatin1String(Core::Constants::SETTINGS_ID_TOOLS));
+ setId(Core::Constants::SETTINGS_ID_TOOLS);
setDisplayName(tr("External Tools"));
- setCategory(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE));
+ setCategory(Core::Constants::SETTINGS_CATEGORY_CORE);
setDisplayCategory(QCoreApplication::translate("Core", Constants::SETTINGS_TR_CATEGORY_CORE));
setCategoryIcon(QLatin1String(Core::Constants::SETTINGS_CATEGORY_CORE_ICON));
}
@@ -67,9 +67,8 @@ QWidget *ToolSettings::createPage(QWidget *parent)
{
m_widget = new ExternalToolConfig(parent);
m_widget->setTools(ExternalToolManager::instance()->toolsByCategory());
- if (m_searchKeywords.isEmpty()) {
+ if (m_searchKeywords.isEmpty())
m_searchKeywords = m_widget->searchKeywords();
- }
return m_widget;
}
@@ -151,9 +150,8 @@ void ToolSettings::apply()
ExternalTool *toolToAdd = 0;
if (ExternalTool *originalTool = originalTools.take(tool->id())) {
// check if it has different category and is custom tool
- if (tool->displayCategory() != it.key() && !tool->preset()) {
+ if (tool->displayCategory() != it.key() && !tool->preset())
tool->setDisplayCategory(it.key());
- }
// check if the tool has changed
if ((*originalTool) == (*tool)) {
toolToAdd = originalTool;
diff --git a/src/plugins/coreplugin/variablechooser.cpp b/src/plugins/coreplugin/variablechooser.cpp
index 19f7ced697..a96212c681 100644
--- a/src/plugins/coreplugin/variablechooser.cpp
+++ b/src/plugins/coreplugin/variablechooser.cpp
@@ -60,7 +60,7 @@ VariableChooser::VariableChooser(QWidget *parent) :
VariableManager *vm = VariableManager::instance();
foreach (const QByteArray &variable, vm->variables())
- ui->variableList->addItem(variable);
+ ui->variableList->addItem(QString::fromLatin1(variable));
connect(ui->variableList, SIGNAL(currentTextChanged(QString)),
this, SLOT(updateDescription(QString)));
@@ -87,7 +87,8 @@ void VariableChooser::updateDescription(const QString &variable)
void VariableChooser::updateCurrentEditor(QWidget *old, QWidget *widget)
{
- Q_UNUSED(old)
+ if (old)
+ old->removeEventFilter(this);
if (!widget) // we might loose focus, but then keep the previous state
return;
// prevent children of the chooser itself, and limit to children of chooser's parent
@@ -104,6 +105,7 @@ void VariableChooser::updateCurrentEditor(QWidget *old, QWidget *widget)
}
if (!handle)
return;
+ widget->installEventFilter(this); // for intercepting escape key presses
QLineEdit *previousLineEdit = m_lineEdit;
m_lineEdit = 0;
m_textEdit = 0;
@@ -111,13 +113,12 @@ void VariableChooser::updateCurrentEditor(QWidget *old, QWidget *widget)
QVariant variablesSupportProperty = widget->property(Constants::VARIABLE_SUPPORT_PROPERTY);
bool supportsVariables = (variablesSupportProperty.isValid()
? variablesSupportProperty.toBool() : false);
- if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(widget)) {
+ if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(widget))
m_lineEdit = (supportsVariables ? lineEdit : 0);
- } else if (QTextEdit *textEdit = qobject_cast<QTextEdit *>(widget)) {
+ else if (QTextEdit *textEdit = qobject_cast<QTextEdit *>(widget))
m_textEdit = (supportsVariables ? textEdit : 0);
- } else if (QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(widget)) {
+ else if (QPlainTextEdit *plainTextEdit = qobject_cast<QPlainTextEdit *>(widget))
m_plainTextEdit = (supportsVariables ? plainTextEdit : 0);
- }
if (!(m_lineEdit || m_textEdit || m_plainTextEdit))
hide();
if (m_lineEdit != previousLineEdit) {
@@ -183,10 +184,26 @@ void VariableChooser::insertVariable(const QString &variable)
}
}
-void VariableChooser::keyPressEvent(QKeyEvent *ke)
+static bool handleEscapePressed(QKeyEvent *ke, QWidget *widget)
{
if (ke->key() == Qt::Key_Escape && !ke->modifiers()) {
ke->accept();
- QTimer::singleShot(0, this, SLOT(close()));
+ QTimer::singleShot(0, widget, SLOT(close()));
+ return true;
+ }
+ return false;
+}
+
+void VariableChooser::keyPressEvent(QKeyEvent *ke)
+{
+ handleEscapePressed(ke, this);
+}
+
+bool VariableChooser::eventFilter(QObject *, QEvent *event)
+{
+ if (event->type() == QEvent::KeyPress && isVisible()) {
+ QKeyEvent *ke = static_cast<QKeyEvent *>(event);
+ return handleEscapePressed(ke, this);
}
+ return false;
}
diff --git a/src/plugins/coreplugin/variablechooser.h b/src/plugins/coreplugin/variablechooser.h
index 26ec962537..5fc1d9ac65 100644
--- a/src/plugins/coreplugin/variablechooser.h
+++ b/src/plugins/coreplugin/variablechooser.h
@@ -58,6 +58,7 @@ public:
protected:
void keyPressEvent(QKeyEvent *ke);
+ bool eventFilter(QObject *, QEvent *event);
private slots:
void updateDescription(const QString &variable);
diff --git a/src/plugins/coreplugin/variablemanager.cpp b/src/plugins/coreplugin/variablemanager.cpp
index 00c3e1ed46..59c379ed33 100644
--- a/src/plugins/coreplugin/variablemanager.cpp
+++ b/src/plugins/coreplugin/variablemanager.cpp
@@ -97,18 +97,11 @@ bool VariableManager::remove(const QByteArray &variable)
QString VariableManager::value(const QByteArray &variable, bool *found)
{
emit variableUpdateRequested(variable);
- if (found) {
+ if (found)
*found = d->m_map.contains(variable);
- }
return d->m_map.value(variable);
}
-QString VariableManager::value(const QByteArray &variable, const QString &defaultValue)
-{
- emit variableUpdateRequested(variable);
- return d->m_map.value(variable, defaultValue);
-}
-
Utils::AbstractMacroExpander *VariableManager::macroExpander()
{
return &d->m_macroExpander;
diff --git a/src/plugins/coreplugin/variablemanager.h b/src/plugins/coreplugin/variablemanager.h
index e4c82b7ba5..cddf0b688f 100644
--- a/src/plugins/coreplugin/variablemanager.h
+++ b/src/plugins/coreplugin/variablemanager.h
@@ -56,7 +56,6 @@ public:
void insert(const QByteArray &variable, const QString &value);
bool remove(const QByteArray &variable);
QString value(const QByteArray &variable, bool *found = 0);
- QString value(const QByteArray &variable, const QString &defaultValue);
Utils::AbstractMacroExpander *macroExpander();
void registerVariable(const QByteArray &variable,
diff --git a/src/plugins/coreplugin/vcsmanager.cpp b/src/plugins/coreplugin/vcsmanager.cpp
index 35cf049b8d..0dd926b46f 100644
--- a/src/plugins/coreplugin/vcsmanager.cpp
+++ b/src/plugins/coreplugin/vcsmanager.cpp
@@ -132,7 +132,7 @@ public:
VcsInfo *newInfo = new VcsInfo(vc, topLevel);
bool createdNewInfo(true);
// Do we have a matching VcsInfo already?
- foreach(VcsInfo *i, m_vcsInfoList) {
+ foreach (VcsInfo *i, m_vcsInfoList) {
if (*i == *newInfo) {
delete newInfo;
newInfo = i;
@@ -148,11 +148,10 @@ public:
while (tmpDir.count() >= topLevel.count() && tmpDir.count() > 0) {
m_cachedMatches.insert(tmpDir, newInfo);
const int slashPos = tmpDir.lastIndexOf(slash);
- if (slashPos >= 0) {
+ if (slashPos >= 0)
tmpDir.truncate(slashPos);
- } else {
+ else
tmpDir.clear();
- }
}
}
@@ -208,7 +207,7 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
if (inputDirectory.isEmpty())
return 0;
- // Make sure we a clean absolute path:
+ // Make sure we an absolute path:
const QString directory = QDir(inputDirectory).absolutePath();
VcsManagerPrivate::VcsInfo *cachedData = d->findInCache(directory);
@@ -242,7 +241,7 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
}
// Register Vcs(s) with the cache
- QString tmpDir = directory;
+ QString tmpDir = QFileInfo(directory).canonicalFilePath();
const QChar slash = QLatin1Char('/');
const StringVersionControlPairs::const_iterator cend = allThatCanManage.constEnd();
for (StringVersionControlPairs::const_iterator i = allThatCanManage.constBegin(); i != cend; ++i) {
diff --git a/src/plugins/coreplugin/versiondialog.cpp b/src/plugins/coreplugin/versiondialog.cpp
index 4616c79525..fed1031f15 100644
--- a/src/plugins/coreplugin/versiondialog.cpp
+++ b/src/plugins/coreplugin/versiondialog.cpp
@@ -85,7 +85,7 @@ VersionDialog::VersionDialog(QWidget *parent)
"The program is provided AS IS with NO WARRANTY OF ANY KIND, "
"INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A "
"PARTICULAR PURPOSE.<br/>")
- .arg(version,
+ .arg(version,
QLatin1String(qVersion()), QString::number(QSysInfo::WordSize),
QLatin1String(__DATE__), QLatin1String(__TIME__), QLatin1String(Constants::IDE_YEAR),
(QLatin1String(Constants::IDE_AUTHOR)), ideVersionDescription,