Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline
@@ -11,7 +11,7 @@
|
||||
Development Environment (IDE) to develop Qt projects. It is available for
|
||||
the Linux, Mac OS X and Windows platforms.
|
||||
|
||||
\note The current version of Qt Creator is 0.9.1 (Beta). It is
|
||||
\note The current version of Qt Creator is 0.9.2 (Beta). It is
|
||||
possible to edit source code, compile, run and debug applications; other
|
||||
features are still under development. Please send bug reports and
|
||||
suggestions to qt-creator@trolltech.com. To subscribe, send a
|
||||
@@ -1245,7 +1245,7 @@
|
||||
\bold{Display Signals and Slots}
|
||||
|
||||
If you have an instance of a class that is derived from QObject, and you
|
||||
you would like to find all other objects connected to one of your object's
|
||||
would like to find all other objects connected to one of your object's
|
||||
slots using Qt's signals and slots mechanism -- you can enable
|
||||
\gui{Use Custom Display for Qt Objects} feature under the \gui Debug menu.
|
||||
|
||||
|
@@ -17,15 +17,15 @@ sources.fileextensions = "qtcreator.qdoc"
|
||||
|
||||
qhp.projects = QtCreator
|
||||
qhp.QtCreator.file = qtcreator.qhp
|
||||
qhp.QtCreator.namespace = com.nokia.qtcreator.091
|
||||
qhp.QtCreator.namespace = com.nokia.qtcreator.092
|
||||
qhp.QtCreator.virtualFolder = doc
|
||||
qhp.QtCreator.indexTitle = Qt Creator
|
||||
qhp.QtCreator.indexRoot =
|
||||
qhp.QtCreator.extraFiles = classic.css \
|
||||
images/qt-logo.png
|
||||
qhp.QtCreator.filterAttributes = qtcreator 0.9.1
|
||||
qhp.QtCreator.customFilters.QtCreator.name = Qt Creator 0.9.1
|
||||
qhp.QtCreator.customFilters.QtCreator.filterAttributes = qtcreator 0.9.1
|
||||
qhp.QtCreator.filterAttributes = qtcreator 0.9.2
|
||||
qhp.QtCreator.customFilters.QtCreator.name = Qt Creator 0.9.2
|
||||
qhp.QtCreator.customFilters.QtCreator.filterAttributes = qtcreator 0.9.2
|
||||
|
||||
# macros.qdocconf
|
||||
|
||||
@@ -201,5 +201,5 @@ HTML.footer = "<p /><address><hr /><div align=\"center\">\n" \
|
||||
"<table width=\"100%\" cellspacing=\"0\" border=\"0\"><tr class=\"address\">\n" \
|
||||
"<td width=\"30%\" align=\"left\">Copyright © 2008 Nokia</td>\n" \
|
||||
"<td width=\"40%\" align=\"center\"> </td>\n" \
|
||||
"<td width=\"30%\" align=\"right\"><div align=\"right\">Qt Creator 0.9.1</div></td>\n" \
|
||||
"<td width=\"30%\" align=\"right\"><div align=\"right\">Qt Creator 0.9.2</div></td>\n" \
|
||||
"</tr></table></div></address>"
|
||||
|
@@ -25,6 +25,12 @@ NEW_MINOR=`sed 's/^[0-9]\+\.\([0-9]\+\)\.[0-9]\+$/\1/' <<<"$2"`
|
||||
OLD_RELEASE=`sed 's/^[0-9]\+\.[0-9]\+\.\([0-9]\+\)$/\1/' <<<"$1"`
|
||||
NEW_RELEASE=`sed 's/^[0-9]\+\.[0-9]\+\.\([0-9]\+\)$/\1/' <<<"$2"`
|
||||
|
||||
OLD_THREE="${OLD_MAJOR}${OLD_MINOR}${OLD_RELEASE}"
|
||||
NEW_THREE="${NEW_MAJOR}${NEW_MINOR}${NEW_RELEASE}"
|
||||
|
||||
OLD_DOT_THREE="${OLD_MAJOR}\\.${OLD_MINOR}\\.${OLD_RELEASE}"
|
||||
NEW_DOT_THREE="${NEW_MAJOR}\\.${NEW_MINOR}\\.${NEW_RELEASE}"
|
||||
|
||||
OLD_DOT_FOUR="${OLD_MAJOR}\\.${OLD_MINOR}\\.${OLD_RELEASE}\\.0"
|
||||
NEW_DOT_FOUR="${NEW_MAJOR}\\.${NEW_MINOR}\\.${NEW_RELEASE}\\.0"
|
||||
|
||||
@@ -38,8 +44,10 @@ echo "# Major '${OLD_MAJOR}' -> '${NEW_MAJOR}'"
|
||||
echo "# Minor '${OLD_MINOR}' -> '${NEW_MINOR}'"
|
||||
echo "# Release '${OLD_RELEASE}' -> '${NEW_RELEASE}'"
|
||||
echo "#-----------------------------------------------"
|
||||
echo "# Dots '${OLD_DOT_FOUR}' -> '${NEW_DOT_FOUR}'"
|
||||
echo "# Comma '${OLD_COMMA_FOUR}' -> '${NEW_COMMA_FOUR}'"
|
||||
echo "# 3 '${OLD_THREE}' -> '${NEW_THREE}'"
|
||||
echo "# Dot 3 '${OLD_DOT_THREE}' -> '${NEW_DOT_THREE}'"
|
||||
echo "# Dot 4 '${OLD_DOT_FOUR}' -> '${NEW_DOT_FOUR}'"
|
||||
echo "# Comma 4 '${OLD_COMMA_FOUR}' -> '${NEW_COMMA_FOUR}'"
|
||||
echo "#==============================================="
|
||||
echo
|
||||
|
||||
@@ -85,7 +93,7 @@ sed \
|
||||
mv -f "${TMPFILE}" "${INSTALLER_RC}"
|
||||
|
||||
|
||||
## Patch installer.rc
|
||||
## Patch Info.plist
|
||||
TMPFILE=`mktemp`
|
||||
INFO_PLIST="${SCRIPT_DIR}/src/app/Info.plist"
|
||||
echo "Patching \`${INFO_PLIST}'"
|
||||
@@ -95,6 +103,27 @@ sed \
|
||||
mv -f "${TMPFILE}" "${INFO_PLIST}"
|
||||
|
||||
|
||||
## Patch qtcreator.qdocconf
|
||||
TMPFILE=`mktemp`
|
||||
QDOCCONF="${SCRIPT_DIR}/doc/qtcreator.qdocconf"
|
||||
echo "Patching \`${QDOCCONF}'"
|
||||
sed \
|
||||
-e "s/"${OLD_DOT_THREE}"/"${NEW_DOT_THREE}"/" \
|
||||
-e "s/"${OLD_THREE}"/"${NEW_THREE}"/" \
|
||||
"${QDOCCONF}" > "${TMPFILE}"
|
||||
mv -f "${TMPFILE}" "${QDOCCONF}"
|
||||
|
||||
|
||||
## Patch qtcreator.qdoc
|
||||
TMPFILE=`mktemp`
|
||||
QDOC="${SCRIPT_DIR}/doc/qtcreator.qdoc"
|
||||
echo "Patching \`${QDOC}'"
|
||||
sed \
|
||||
-e 's/\(The current version of Qt Creator is \)'${OLD_DOT_THREE}'/\1'${NEW_DOT_THREE}'/' \
|
||||
"${QDOC}" > "${TMPFILE}"
|
||||
mv -f "${TMPFILE}" "${QDOC}"
|
||||
|
||||
|
||||
## Go back to original $PWD
|
||||
echo "Leaving directory \`${SCRIPT_DIR}'"
|
||||
popd &>/dev/null || exit 1
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
version=4.4.3
|
||||
workdir=/home/berlin/dev/qt-${version}-temp
|
||||
destdir=/home/berlin/dev/qt-${version}-shipping
|
||||
destdir=/home/berlin/dev/qt-${version}-shipping/qt # "/qt" suffix for Bitrock
|
||||
dir=qt-x11-opensource-src-${version}
|
||||
file_tar="${dir}.tar"
|
||||
file_tar_gz="${file_tar}.gz"
|
||||
|
@@ -1,7 +1,7 @@
|
||||
IDE_BUILD_TREE = $$OUT_PWD/../../
|
||||
|
||||
include(../qworkbench.pri)
|
||||
include(../../shared/qtsingleapplication/qtsingleapplication.pri)
|
||||
include(../shared/qtsingleapplication/qtsingleapplication.pri)
|
||||
|
||||
macx {
|
||||
CONFIG(debug, debug|release):LIBS *= -lExtensionSystem_debug -lAggregation_debug
|
||||
|
@@ -162,8 +162,26 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
|
||||
if (QualifiedNameId *q = name->asQualifiedNameId()) {
|
||||
QList<Symbol *> candidates;
|
||||
QList<Scope *> scopes = visibleScopes;
|
||||
Identifier *id = identifier(name);
|
||||
for (unsigned i = 0; i < q->nameCount(); ++i) {
|
||||
Name *name = q->nameAt(i);
|
||||
|
||||
if (i + 1 == q->nameCount())
|
||||
candidates = resolve(name, scopes, mode);
|
||||
else
|
||||
candidates = resolveClassOrNamespace(name, scopes);
|
||||
|
||||
if (candidates.isEmpty() || i + 1 == q->nameCount())
|
||||
break;
|
||||
|
||||
scopes.clear();
|
||||
foreach (Symbol *candidate, candidates) {
|
||||
if (ScopedSymbol *scoped = candidate->asScopedSymbol()) {
|
||||
expand(scoped->members(), visibleScopes, &scopes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Identifier *id = identifier(name);
|
||||
foreach (Scope *scope, visibleScopes) {
|
||||
Symbol *symbol = scope->lookat(id);
|
||||
for (; symbol; symbol = symbol->next()) {
|
||||
@@ -189,26 +207,7 @@ QList<Symbol *> LookupContext::resolve(Name *name, const QList<Scope *> &visible
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < q->nameCount(); ++i) {
|
||||
Name *name = q->nameAt(i);
|
||||
|
||||
if (i + 1 == q->nameCount())
|
||||
candidates += resolve(name, scopes, mode);
|
||||
else
|
||||
candidates += resolveClassOrNamespace(name, scopes);
|
||||
|
||||
if (candidates.isEmpty() || i + 1 == q->nameCount())
|
||||
return candidates;
|
||||
|
||||
scopes.clear();
|
||||
foreach (Symbol *candidate, candidates) {
|
||||
if (ScopedSymbol *scoped = candidate->asScopedSymbol()) {
|
||||
expand(scoped->members(), visibleScopes, &scopes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return QList<Symbol *>();
|
||||
}
|
||||
|
||||
QList<Symbol *> candidates;
|
||||
|
@@ -1,3 +1,3 @@
|
||||
INCLUDEPATH += $$PWD/../../../shared/cplusplus
|
||||
INCLUDEPATH += $$PWD/../../shared/cplusplus
|
||||
DEFINES += HAVE_QT CPLUSPLUS_WITH_NAMESPACE
|
||||
LIBS *= -l$$qtLibraryTarget(CPlusPlus)
|
||||
|
@@ -7,7 +7,7 @@ DEFINES += NDEBUG
|
||||
unix:QMAKE_CXXFLAGS_DEBUG += -O3
|
||||
|
||||
include(../../qworkbenchlibrary.pri)
|
||||
include(../../../shared/cplusplus/cplusplus.pri)
|
||||
include(../../shared/cplusplus/cplusplus.pri)
|
||||
|
||||
HEADERS += \
|
||||
SimpleLexer.h \
|
||||
|
123
src/plugins/cmakeprojectmanager/cmakeconfigurewidget.cpp
Normal file
@@ -0,0 +1,123 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** Non-Open Source Usage
|
||||
**
|
||||
** Licensees may use this file in accordance with the Qt Beta Version
|
||||
** License Agreement, Agreement version 2.2 provided with the Software or,
|
||||
** alternatively, in accordance with the terms contained in a written
|
||||
** agreement between you and Nokia.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License versions 2.0 or 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
||||
** of this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
**
|
||||
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt GPL Exception
|
||||
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
***************************************************************************/
|
||||
|
||||
#include "cmakeconfigurewidget.h"
|
||||
#include "cmakeprojectmanager.h"
|
||||
#include <projectexplorer/environment.h>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QLineEdit>
|
||||
#include <QtGui/QSpacerItem>
|
||||
|
||||
using namespace CMakeProjectManager;
|
||||
using namespace CMakeProjectManager::Internal;
|
||||
|
||||
CMakeConfigureWidget::CMakeConfigureWidget(QWidget *parent, CMakeManager *manager, const QString &sourceDirectory)
|
||||
: QWidget(parent), m_configureSucceded(false), m_cmakeManager(manager), m_sourceDirectory(sourceDirectory)
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
m_ui.buildDirectoryLineEdit->setPath(sourceDirectory + "/qtcreator-build");
|
||||
|
||||
connect(m_ui.configureButton, SIGNAL(clicked()), this, SLOT(runCMake()));
|
||||
// TODO make the configure button do stuff
|
||||
// TODO set initial settings
|
||||
// TODO note if there's already a build in that directory
|
||||
// detect which generators we have
|
||||
// let the user select generator
|
||||
}
|
||||
|
||||
QString CMakeConfigureWidget::buildDirectory()
|
||||
{
|
||||
return m_ui.buildDirectoryLineEdit->path();
|
||||
}
|
||||
|
||||
QStringList CMakeConfigureWidget::arguments()
|
||||
{
|
||||
return ProjectExplorer::Environment::parseCombinedArgString(m_ui.cmakeArgumentsLineEdit->text());
|
||||
}
|
||||
|
||||
bool CMakeConfigureWidget::configureSucceded()
|
||||
{
|
||||
return m_configureSucceded;
|
||||
}
|
||||
|
||||
void CMakeConfigureWidget::runCMake()
|
||||
{
|
||||
// TODO run project createCbp()
|
||||
// get output and display it
|
||||
|
||||
// TODO analyse wheter this worked out
|
||||
m_ui.cmakeOutput->setPlainText(tr("Waiting for cmake..."));
|
||||
QString string = m_cmakeManager->createXmlFile(arguments(), m_sourceDirectory, buildDirectory());
|
||||
m_ui.cmakeOutput->setPlainText(string);
|
||||
}
|
||||
|
||||
//////
|
||||
// CMakeConfigureDialog
|
||||
/////
|
||||
|
||||
CMakeConfigureDialog::CMakeConfigureDialog(QWidget *parent, CMakeManager *manager, const QString &sourceDirectory)
|
||||
: QDialog(parent)
|
||||
{
|
||||
QVBoxLayout *vbox = new QVBoxLayout(this);
|
||||
setLayout(vbox);
|
||||
|
||||
m_cmakeConfigureWidget = new CMakeConfigureWidget(this, manager, sourceDirectory);
|
||||
vbox->addWidget(m_cmakeConfigureWidget);
|
||||
|
||||
QHBoxLayout *hboxlayout = new QHBoxLayout(this);
|
||||
hboxlayout->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Fixed));
|
||||
|
||||
|
||||
QPushButton *okButton = new QPushButton(this);
|
||||
okButton->setText(tr("Ok"));
|
||||
okButton->setDefault(true);
|
||||
connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
|
||||
|
||||
hboxlayout->addWidget(okButton);
|
||||
vbox->addLayout(hboxlayout);
|
||||
}
|
||||
|
||||
QString CMakeConfigureDialog::buildDirectory()
|
||||
{
|
||||
return m_cmakeConfigureWidget->buildDirectory();
|
||||
}
|
||||
|
||||
QStringList CMakeConfigureDialog::arguments()
|
||||
{
|
||||
return m_cmakeConfigureWidget->arguments();
|
||||
}
|
||||
|
||||
bool CMakeConfigureDialog::configureSucceded()
|
||||
{
|
||||
return m_cmakeConfigureWidget->configureSucceded();
|
||||
}
|
81
src/plugins/cmakeprojectmanager/cmakeconfigurewidget.h
Normal file
@@ -0,0 +1,81 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** Non-Open Source Usage
|
||||
**
|
||||
** Licensees may use this file in accordance with the Qt Beta Version
|
||||
** License Agreement, Agreement version 2.2 provided with the Software or,
|
||||
** alternatively, in accordance with the terms contained in a written
|
||||
** agreement between you and Nokia.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License versions 2.0 or 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
||||
** of this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
**
|
||||
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt GPL Exception
|
||||
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef CMAKECONFIGUREWIDGET_H
|
||||
#define CMAKECONFIGUREWIDGET_H
|
||||
|
||||
#include "ui_cmakeconfigurewidget.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QDialog>
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class CMakeManager;
|
||||
|
||||
class CMakeConfigureWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CMakeConfigureWidget(QWidget *parent, CMakeManager *manager, const QString &sourceDirectory);
|
||||
Ui::CMakeConfigureWidget m_ui;
|
||||
|
||||
QString buildDirectory();
|
||||
QStringList arguments();
|
||||
bool configureSucceded();
|
||||
|
||||
private slots:
|
||||
void runCMake();
|
||||
private:
|
||||
bool m_configureSucceded;
|
||||
CMakeManager *m_cmakeManager;
|
||||
QString m_sourceDirectory;
|
||||
};
|
||||
|
||||
class CMakeConfigureDialog : public QDialog
|
||||
{
|
||||
public:
|
||||
CMakeConfigureDialog(QWidget *parent, CMakeManager *manager, const QString &sourceDirectory);
|
||||
|
||||
QString buildDirectory();
|
||||
QStringList arguments();
|
||||
bool configureSucceded();
|
||||
|
||||
private:
|
||||
CMakeConfigureWidget *m_cmakeConfigureWidget;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CMAKECONFIGUREWIDGET_H
|
95
src/plugins/cmakeprojectmanager/cmakeconfigurewidget.ui
Normal file
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CMakeProjectManager::Internal::CMakeConfigureWidget</class>
|
||||
<widget class="QWidget" name="CMakeProjectManager::Internal::CMakeConfigureWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>521</width>
|
||||
<height>662</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="labelCommandArguments">
|
||||
<property name="text">
|
||||
<string>CMake Arguments:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="cmakeArgumentsLineEdit"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Builddirectory:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="Core::Utils::PathChooser" name="buildDirectoryLineEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="configureButton">
|
||||
<property name="text">
|
||||
<string>Run cmake</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="cmakeOutput"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Core::Utils::PathChooser</class>
|
||||
<extends>QLineEdit</extends>
|
||||
<header location="global">utils/pathchooser.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@@ -32,21 +32,24 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "cmakeproject.h"
|
||||
|
||||
#include "ui_cmakeconfigurewidget.h"
|
||||
#include "cmakeconfigurewidget.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
#include "cmakeprojectnodes.h"
|
||||
#include "cmakerunconfiguration.h"
|
||||
#include "cmakestep.h"
|
||||
#include "makestep.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <cpptools/cppmodelmanagerinterface.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <coreplugin/icore.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QDir>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtGui/QFormLayout>
|
||||
#include <QtGui/QMainWindow>
|
||||
|
||||
using namespace CMakeProjectManager;
|
||||
using namespace CMakeProjectManager::Internal;
|
||||
@@ -67,8 +70,6 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
|
||||
: m_manager(manager), m_fileName(fileName), m_rootNode(new CMakeProjectNode(m_fileName))
|
||||
{
|
||||
m_file = new CMakeFile(this, fileName);
|
||||
QDir dir = QFileInfo(m_fileName).absoluteDir();
|
||||
parseCMakeLists(dir);
|
||||
}
|
||||
|
||||
CMakeProject::~CMakeProject()
|
||||
@@ -78,12 +79,12 @@ CMakeProject::~CMakeProject()
|
||||
|
||||
// TODO also call this method if the CMakeLists.txt file changed, which is also called if the CMakeList.txt is updated
|
||||
// TODO make this function work even if it is reparsing
|
||||
void CMakeProject::parseCMakeLists(const QDir &directory)
|
||||
void CMakeProject::parseCMakeLists()
|
||||
{
|
||||
createCbpFile(buildDirectory(QString()));
|
||||
|
||||
QString cbpFile = findCbpFile(buildDirectory(QString()));
|
||||
QString sourceDirectory = QFileInfo(m_fileName).absolutePath();
|
||||
m_manager->createXmlFile(cmakeStep()->userArguments(activeBuildConfiguration()), sourceDirectory, buildDirectory(activeBuildConfiguration()));
|
||||
|
||||
QString cbpFile = findCbpFile(buildDirectory(activeBuildConfiguration()));
|
||||
CMakeCbpParser cbpparser;
|
||||
qDebug()<<"Parsing file "<<cbpFile;
|
||||
if (cbpparser.parseCbpFile(cbpFile)) {
|
||||
@@ -142,24 +143,6 @@ QString CMakeProject::findCbpFile(const QDir &directory)
|
||||
return QString::null;
|
||||
}
|
||||
|
||||
void CMakeProject::createCbpFile(const QDir &directory)
|
||||
{
|
||||
// We create a cbp file, only if we didn't find a cbp file in the base directory
|
||||
// Yet that can still override cbp files in subdirectories
|
||||
// And we are creating tons of files in the source directories
|
||||
// All of that is not really nice.
|
||||
// The mid term plan is to move away from the CodeBlocks Generator and use our own
|
||||
// QtCreator generator, which actually can be very similar to the CodeBlock Generator
|
||||
|
||||
// TODO we need to pass on the same paremeters as the cmakestep
|
||||
qDebug()<<"Creating cbp file";
|
||||
directory.mkpath(directory.absolutePath());
|
||||
QProcess cmake;
|
||||
cmake.setWorkingDirectory(directory.absolutePath());
|
||||
cmake.start("cmake", QStringList() << ".." << "-GCodeBlocks - Unix Makefiles");
|
||||
cmake.waitForFinished(-1);
|
||||
qDebug()<<"cmake output: \n"<<cmake.readAll();
|
||||
}
|
||||
|
||||
void CMakeProject::buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list)
|
||||
{
|
||||
@@ -300,8 +283,20 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
|
||||
{
|
||||
// TODO
|
||||
Project::restoreSettingsImpl(reader);
|
||||
if (buildConfigurations().isEmpty()) {
|
||||
// No build configuration, adding those
|
||||
bool hasUserFile = !buildConfigurations().isEmpty();
|
||||
if (!hasUserFile) {
|
||||
// Ask the user for where he wants to build it
|
||||
// and the cmake command line
|
||||
|
||||
// TODO check wheter there's already a CMakeCache.txt in the src directory,
|
||||
// then we don't need to ask, we simply need to build in the src directory
|
||||
|
||||
CMakeConfigureDialog ccd(Core::ICore::instance()->mainWindow(), m_manager, QFileInfo(m_fileName).absolutePath());
|
||||
ccd.exec();
|
||||
|
||||
qDebug()<<"ccd.buildDirectory()"<<ccd.buildDirectory();
|
||||
|
||||
// Now create a standard build configuration
|
||||
CMakeStep *cmakeStep = new CMakeStep(this);
|
||||
MakeStep *makeStep = new MakeStep(this);
|
||||
|
||||
@@ -311,7 +306,14 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
|
||||
addBuildConfiguration("all");
|
||||
setActiveBuildConfiguration("all");
|
||||
makeStep->setBuildTarget("all", "all", true);
|
||||
if (!ccd.buildDirectory().isEmpty())
|
||||
setValue("all", "buildDirectory", ccd.buildDirectory());
|
||||
cmakeStep->setUserArguments("all", ccd.arguments());
|
||||
}
|
||||
|
||||
parseCMakeLists(); // Gets the directory from the active buildconfiguration
|
||||
|
||||
if (!hasUserFile) {
|
||||
// Create run configurations for m_targets
|
||||
qDebug()<<"Create run configurations of m_targets";
|
||||
bool setActive = false;
|
||||
@@ -328,7 +330,6 @@ void CMakeProject::restoreSettingsImpl(ProjectExplorer::PersistentSettingsReader
|
||||
}
|
||||
|
||||
}
|
||||
// Restoring is fine
|
||||
}
|
||||
|
||||
|
||||
|
@@ -106,9 +106,8 @@ public:
|
||||
QStringList targets() const;
|
||||
|
||||
private:
|
||||
void parseCMakeLists(const QDir &directory);
|
||||
void parseCMakeLists();
|
||||
QString findCbpFile(const QDir &);
|
||||
void createCbpFile(const QDir &);
|
||||
|
||||
void buildTree(CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
|
||||
ProjectExplorer::FolderNode *findOrCreateFolder(CMakeProjectNode *rootNode, QString directory);
|
||||
|
@@ -36,18 +36,30 @@
|
||||
#include "cmakeproject.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/uniqueidmanager.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/environment.h>
|
||||
#include <qtconcurrent/QtConcurrentTools>
|
||||
#include <QtCore/QtConcurrentRun>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QFormLayout>
|
||||
|
||||
using namespace CMakeProjectManager::Internal;
|
||||
|
||||
CMakeManager::CMakeManager()
|
||||
CMakeManager::CMakeManager(CMakeSettingsPage *cmakeSettingsPage)
|
||||
: m_settingsPage(cmakeSettingsPage)
|
||||
{
|
||||
Core::UniqueIDManager *uidm = Core::UniqueIDManager::instance();
|
||||
m_projectContext = uidm->uniqueIdentifier(CMakeProjectManager::Constants::PROJECTCONTEXT);
|
||||
m_projectLanguage = uidm->uniqueIdentifier(ProjectExplorer::Constants::LANG_CXX);
|
||||
}
|
||||
|
||||
CMakeSettingsPage::~CMakeSettingsPage()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int CMakeManager::projectContext() const
|
||||
{
|
||||
return m_projectContext;
|
||||
@@ -61,6 +73,14 @@ int CMakeManager::projectLanguage() const
|
||||
ProjectExplorer::Project *CMakeManager::openProject(const QString &fileName)
|
||||
{
|
||||
// TODO check wheter this project is already opened
|
||||
// Check that we have a cmake executable first
|
||||
// Look at the settings first
|
||||
QString cmakeExecutable = m_settingsPage->cmakeExecutable();
|
||||
if (cmakeExecutable.isNull())
|
||||
m_settingsPage->askUserForCMakeExecutable();
|
||||
cmakeExecutable = m_settingsPage->cmakeExecutable();
|
||||
if (cmakeExecutable.isNull())
|
||||
return 0;
|
||||
return new CMakeProject(this, fileName);
|
||||
}
|
||||
|
||||
@@ -68,3 +88,204 @@ QString CMakeManager::mimeType() const
|
||||
{
|
||||
return Constants::CMAKEMIMETYPE;
|
||||
}
|
||||
|
||||
QString CMakeManager::cmakeExecutable() const
|
||||
{
|
||||
return m_settingsPage->cmakeExecutable();
|
||||
}
|
||||
|
||||
// TODO need to refactor this out
|
||||
// we probably want the process instead of this function
|
||||
// cmakeproject then could even run the cmake process in the background, adding the files afterwards
|
||||
// sounds like a plan
|
||||
QString CMakeManager::createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory)
|
||||
{
|
||||
// We create a cbp file, only if we didn't find a cbp file in the base directory
|
||||
// Yet that can still override cbp files in subdirectories
|
||||
// And we are creating tons of files in the source directories
|
||||
// All of that is not really nice.
|
||||
// The mid term plan is to move away from the CodeBlocks Generator and use our own
|
||||
// QtCreator generator, which actually can be very similar to the CodeBlock Generator
|
||||
|
||||
|
||||
// TODO we need to pass on the same paremeters as the cmakestep
|
||||
QString buildDirectoryPath = buildDirectory.absolutePath();
|
||||
qDebug()<<"Creating cbp file in"<<buildDirectoryPath;
|
||||
buildDirectory.mkpath(buildDirectoryPath);
|
||||
QProcess cmake;
|
||||
cmake.setWorkingDirectory(buildDirectoryPath);
|
||||
cmake.start(cmakeExecutable(), QStringList() << sourceDirectory << arguments << "-GCodeBlocks - Unix Makefiles");
|
||||
qDebug()<<cmakeExecutable()<<sourceDirectory << arguments;
|
||||
cmake.waitForFinished(-1);
|
||||
cmake.setProcessChannelMode(QProcess::MergedChannels);
|
||||
QString output = cmake.readAll();
|
||||
qDebug()<<"cmake output: \n"<<output;
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
/////
|
||||
// CMakeRunner
|
||||
////
|
||||
// TODO give a better name, what this class is to update cached information
|
||||
// about a cmake executable, with qtconcurrent
|
||||
// The nifty feature of this class is that it does so in a seperate thread,
|
||||
// not blocking the main thread
|
||||
|
||||
CMakeRunner::CMakeRunner()
|
||||
: m_cacheUpToDate(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CMakeRunner::run(QFutureInterface<void> &fi)
|
||||
{
|
||||
m_mutex.lock();
|
||||
QString executable = m_executable;
|
||||
m_mutex.unlock();
|
||||
QProcess cmake;
|
||||
cmake.start(executable, QStringList()<<"--help");
|
||||
cmake.waitForFinished();
|
||||
QString response = cmake.readAll();
|
||||
QRegExp versionRegexp("^cmake version ([*\\d\\.]*)-(|patch (\\d*))(|\\r)\\n");
|
||||
versionRegexp.indexIn(response);
|
||||
|
||||
m_mutex.lock();
|
||||
m_supportsQtCreator = response.contains("QtCreator");
|
||||
m_version = versionRegexp.cap(1);
|
||||
if (!versionRegexp.capturedTexts().size()>3)
|
||||
m_version += "." + versionRegexp.cap(3);
|
||||
m_cacheUpToDate = true;
|
||||
m_mutex.unlock();
|
||||
fi.reportFinished();
|
||||
}
|
||||
|
||||
void CMakeRunner::setExecutable(const QString &executable)
|
||||
{
|
||||
waitForUpToDate();
|
||||
m_mutex.lock();
|
||||
m_executable = executable;
|
||||
m_cacheUpToDate = false;
|
||||
m_mutex.unlock();
|
||||
m_future = QtConcurrent::run(&CMakeRunner::run, this);
|
||||
}
|
||||
|
||||
QString CMakeRunner::executable() const
|
||||
{
|
||||
waitForUpToDate();
|
||||
m_mutex.lock();
|
||||
QString result = m_executable;
|
||||
m_mutex.unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
QString CMakeRunner::version() const
|
||||
{
|
||||
waitForUpToDate();
|
||||
m_mutex.lock();
|
||||
QString result = m_version;
|
||||
m_mutex.unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CMakeRunner::supportsQtCreator() const
|
||||
{
|
||||
waitForUpToDate();
|
||||
m_mutex.lock();
|
||||
bool result = m_supportsQtCreator;
|
||||
m_mutex.unlock();
|
||||
return result;
|
||||
}
|
||||
|
||||
void CMakeRunner::waitForUpToDate() const
|
||||
{
|
||||
m_future.waitForFinished();
|
||||
}
|
||||
|
||||
/////
|
||||
// CMakeSettingsPage
|
||||
////
|
||||
|
||||
|
||||
CMakeSettingsPage::CMakeSettingsPage()
|
||||
{
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
QSettings * settings = core->settings();
|
||||
settings->beginGroup("CMakeSettings");
|
||||
m_cmakeRunner.setExecutable(settings->value("cmakeExecutable").toString());
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
QString CMakeSettingsPage::findCmakeExecutable() const
|
||||
{
|
||||
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
||||
return env.searchInPath("cmake");
|
||||
}
|
||||
|
||||
|
||||
QString CMakeSettingsPage::name() const
|
||||
{
|
||||
return "CMake";
|
||||
}
|
||||
|
||||
QString CMakeSettingsPage::category() const
|
||||
{
|
||||
return "CMake";
|
||||
}
|
||||
|
||||
QString CMakeSettingsPage::trCategory() const
|
||||
{
|
||||
return tr("CMake");
|
||||
}
|
||||
|
||||
QWidget *CMakeSettingsPage::createPage(QWidget *parent)
|
||||
{
|
||||
QWidget *w = new QWidget(parent);
|
||||
QFormLayout *fl = new QFormLayout(w);
|
||||
m_pathchooser = new Core::Utils::PathChooser(w);
|
||||
m_pathchooser->setExpectedKind(Core::Utils::PathChooser::Command);
|
||||
fl->addRow("CMake executable", m_pathchooser);
|
||||
m_pathchooser->setPath(cmakeExecutable());
|
||||
return w;
|
||||
}
|
||||
|
||||
void CMakeSettingsPage::saveSettings() const
|
||||
{
|
||||
QSettings *settings = Core::ICore::instance()->settings();
|
||||
settings->beginGroup("CMakeSettings");
|
||||
settings->setValue("cmakeExecutable", m_cmakeRunner.executable());
|
||||
settings->endGroup();
|
||||
}
|
||||
|
||||
void CMakeSettingsPage::apply()
|
||||
{
|
||||
m_cmakeRunner.setExecutable(m_pathchooser->path());
|
||||
saveSettings();
|
||||
}
|
||||
|
||||
void CMakeSettingsPage::finish()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QString CMakeSettingsPage::cmakeExecutable() const
|
||||
{
|
||||
if (m_cmakeRunner.executable().isEmpty()) {
|
||||
QString cmakeExecutable = findCmakeExecutable();
|
||||
if (!cmakeExecutable.isEmpty()) {
|
||||
m_cmakeRunner.setExecutable(cmakeExecutable);
|
||||
saveSettings();
|
||||
}
|
||||
}
|
||||
return m_cmakeRunner.executable();
|
||||
}
|
||||
|
||||
void CMakeSettingsPage::askUserForCMakeExecutable()
|
||||
{
|
||||
// TODO implement
|
||||
// That is ideally add a label to the settings page, which says something
|
||||
// to the effect: please configure the cmake executable
|
||||
// and show the settings page
|
||||
// ensure that we rehide the label in the finish() function
|
||||
// But to test that i need an environment without cmake, e.g. windows
|
||||
}
|
||||
|
@@ -34,27 +34,82 @@
|
||||
#ifndef CMAKEPROJECTMANAGER_H
|
||||
#define CMAKEPROJECTMANAGER_H
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <projectexplorer/iprojectmanager.h>
|
||||
#include <utils/pathchooser.h>
|
||||
#include <QtCore/QFuture>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QDir>
|
||||
|
||||
namespace CMakeProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class CMakeSettingsPage;
|
||||
class CMakeRunner;
|
||||
|
||||
class CMakeManager : public ProjectExplorer::IProjectManager
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CMakeManager();
|
||||
CMakeManager(CMakeSettingsPage *cmakeSettingsPage);
|
||||
|
||||
virtual int projectContext() const;
|
||||
virtual int projectLanguage() const;
|
||||
|
||||
//virtual bool canOpenProject(const QString &fileName);
|
||||
virtual ProjectExplorer::Project *openProject(const QString &fileName);
|
||||
virtual QString mimeType() const;
|
||||
//virtual QString fileFilter() const;
|
||||
QString cmakeExecutable() const;
|
||||
|
||||
QString createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory);
|
||||
private:
|
||||
int m_projectContext;
|
||||
int m_projectLanguage;
|
||||
CMakeSettingsPage *m_settingsPage;
|
||||
};
|
||||
|
||||
class CMakeRunner
|
||||
{
|
||||
public:
|
||||
CMakeRunner();
|
||||
void run(QFutureInterface<void> &fi);
|
||||
void setExecutable(const QString &executable);
|
||||
QString executable() const;
|
||||
QString version() const;
|
||||
bool supportsQtCreator() const;
|
||||
void waitForUpToDate() const;
|
||||
|
||||
private:
|
||||
QString m_executable;
|
||||
QString m_version;
|
||||
bool m_supportsQtCreator;
|
||||
bool m_cacheUpToDate;
|
||||
mutable QFuture<void> m_future;
|
||||
mutable QMutex m_mutex;
|
||||
};
|
||||
|
||||
class CMakeSettingsPage : public Core::IOptionsPage
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CMakeSettingsPage();
|
||||
virtual ~CMakeSettingsPage();
|
||||
virtual QString name() const;
|
||||
virtual QString category() const;
|
||||
virtual QString trCategory() const;
|
||||
|
||||
virtual QWidget *createPage(QWidget *parent);
|
||||
virtual void apply();
|
||||
virtual void finish();
|
||||
|
||||
QString cmakeExecutable() const;
|
||||
void askUserForCMakeExecutable();
|
||||
private:
|
||||
void updateCachedInformation() const;
|
||||
void saveSettings() const;
|
||||
QString findCmakeExecutable() const;
|
||||
|
||||
mutable CMakeRunner m_cmakeRunner;
|
||||
Core::Utils::PathChooser *m_pathchooser;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -9,12 +9,15 @@ HEADERS = cmakeproject.h \
|
||||
cmakeprojectnodes.h \
|
||||
cmakestep.h \
|
||||
makestep.h \
|
||||
cmakerunconfiguration.h
|
||||
cmakerunconfiguration.h \
|
||||
cmakeconfigurewidget.h
|
||||
SOURCES = cmakeproject.cpp \
|
||||
cmakeprojectplugin.cpp \
|
||||
cmakeprojectmanager.cpp \
|
||||
cmakeprojectnodes.cpp \
|
||||
cmakestep.cpp \
|
||||
makestep.cpp \
|
||||
cmakerunconfiguration.cpp
|
||||
cmakerunconfiguration.cpp \
|
||||
cmakeconfigurewidget.cpp
|
||||
RESOURCES += cmakeproject.qrc
|
||||
FORMS += cmakeconfigurewidget.ui
|
||||
|
@@ -59,7 +59,9 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
if (!core->mimeDatabase()->addMimeTypes(QLatin1String(":cmakeproject/CMakeProject.mimetypes.xml"), errorMessage))
|
||||
return false;
|
||||
addAutoReleasedObject(new CMakeManager());
|
||||
CMakeSettingsPage *cmp = new CMakeSettingsPage();
|
||||
addAutoReleasedObject(cmp);
|
||||
addAutoReleasedObject(new CMakeManager(cmp));
|
||||
addAutoReleasedObject(new CMakeBuildStepFactory());
|
||||
addAutoReleasedObject(new MakeBuildStepFactory());
|
||||
addAutoReleasedObject(new CMakeRunConfigurationFactory());
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include "cmakeproject.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
|
||||
#include <projectexplorer/environment.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <QtGui/QFormLayout>
|
||||
#include <QtGui/QLineEdit>
|
||||
@@ -56,7 +57,10 @@ bool CMakeStep::init(const QString &buildConfiguration)
|
||||
{
|
||||
setEnabled(buildConfiguration, true);
|
||||
setWorkingDirectory(buildConfiguration, m_pro->buildDirectory(buildConfiguration));
|
||||
setCommand(buildConfiguration, "cmake"); // TODO give full path here?
|
||||
|
||||
CMakeManager *cmakeProjectManager = static_cast<CMakeManager *>(m_pro->projectManager());
|
||||
|
||||
setCommand(buildConfiguration, cmakeProjectManager->cmakeExecutable());
|
||||
|
||||
QString sourceDir = QFileInfo(m_pro->file()->fileName()).absolutePath();
|
||||
setArguments(buildConfiguration,
|
||||
@@ -99,14 +103,14 @@ bool CMakeStep::immutable() const
|
||||
return true;
|
||||
}
|
||||
|
||||
QString CMakeStep::userArguments(const QString &buildConfiguration) const
|
||||
QStringList CMakeStep::userArguments(const QString &buildConfiguration) const
|
||||
{
|
||||
return ProjectExplorer::Environment::joinArgumentList(value(buildConfiguration, "userArguments").toStringList());
|
||||
return value(buildConfiguration, "userArguments").toStringList();
|
||||
}
|
||||
|
||||
void CMakeStep::setUserArguments(const QString &buildConfiguration, const QString &arguments)
|
||||
void CMakeStep::setUserArguments(const QString &buildConfiguration, const QStringList &arguments)
|
||||
{
|
||||
setValue(buildConfiguration, "userArguments", ProjectExplorer::Environment::parseCombinedArgString(arguments));
|
||||
setValue(buildConfiguration, "userArguments", arguments);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -132,13 +136,13 @@ void CMakeBuildStepConfigWidget::init(const QString &buildConfiguration)
|
||||
{
|
||||
m_buildConfiguration = buildConfiguration;
|
||||
disconnect(m_arguments, SIGNAL(textChanged(QString)), this, SLOT(argumentsLineEditChanged()));
|
||||
m_arguments->setText(m_cmakeStep->userArguments(buildConfiguration));
|
||||
m_arguments->setText(ProjectExplorer::Environment::joinArgumentList(m_cmakeStep->userArguments(buildConfiguration)));
|
||||
connect(m_arguments, SIGNAL(textChanged(QString)), this, SLOT(argumentsLineEditChanged()));
|
||||
}
|
||||
|
||||
void CMakeBuildStepConfigWidget::argumentsLineEditChanged()
|
||||
{
|
||||
m_cmakeStep->setUserArguments(m_buildConfiguration, m_arguments->text());
|
||||
m_cmakeStep->setUserArguments(m_buildConfiguration, ProjectExplorer::Environment::parseCombinedArgString(m_arguments->text()));
|
||||
}
|
||||
|
||||
//
|
||||
|
@@ -63,8 +63,8 @@ public:
|
||||
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget();
|
||||
virtual bool immutable() const;
|
||||
|
||||
void setUserArguments(const QString &buildConfiguration, const QString &arguments);
|
||||
QString userArguments(const QString &buildConfiguration) const;
|
||||
void setUserArguments(const QString &buildConfiguration, const QStringList &arguments);
|
||||
QStringList userArguments(const QString &buildConfiguration) const;
|
||||
private:
|
||||
CMakeProject *m_pro;
|
||||
};
|
||||
|
@@ -205,10 +205,11 @@ ActionManagerPrivate* ActionManagerPrivate::m_instance = 0;
|
||||
\internal
|
||||
*/
|
||||
|
||||
ActionManagerPrivate::ActionManagerPrivate(MainWindow *mainWnd, UniqueIDManager *uidmgr) :
|
||||
ActionManager(mainWnd),
|
||||
ActionManagerPrivate::ActionManagerPrivate(MainWindow *mainWnd)
|
||||
: ActionManager(mainWnd),
|
||||
m_mainWnd(mainWnd)
|
||||
{
|
||||
UniqueIDManager *uidmgr = UniqueIDManager::instance();
|
||||
m_defaultGroups << uidmgr->uniqueIdentifier(Constants::G_DEFAULT_ONE);
|
||||
m_defaultGroups << uidmgr->uniqueIdentifier(Constants::G_DEFAULT_TWO);
|
||||
m_defaultGroups << uidmgr->uniqueIdentifier(Constants::G_DEFAULT_THREE);
|
||||
@@ -258,7 +259,7 @@ void ActionManagerPrivate::setContext(const QList<int> &context)
|
||||
it.value()->setCurrentContext(m_context);
|
||||
|
||||
const IdContainerMap::const_iterator acend = m_idContainerMap.constEnd();
|
||||
for ( IdContainerMap::const_iterator it = m_idContainerMap.constBegin(); it != acend; ++it)
|
||||
for (IdContainerMap::const_iterator it = m_idContainerMap.constBegin(); it != acend; ++it)
|
||||
it.value()->update();
|
||||
}
|
||||
|
||||
@@ -273,7 +274,7 @@ bool ActionManagerPrivate::hasContext(QList<int> context) const
|
||||
|
||||
ActionContainer *ActionManagerPrivate::createMenu(const QString &id)
|
||||
{
|
||||
const int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
|
||||
const int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
|
||||
const IdContainerMap::const_iterator it = m_idContainerMap.constFind(uid);
|
||||
if (it != m_idContainerMap.constEnd())
|
||||
return it.value();
|
||||
@@ -291,7 +292,7 @@ ActionContainer *ActionManagerPrivate::createMenu(const QString &id)
|
||||
|
||||
ActionContainer *ActionManagerPrivate::createMenuBar(const QString &id)
|
||||
{
|
||||
const int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
|
||||
const int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
|
||||
const IdContainerMap::const_iterator it = m_idContainerMap.constFind(uid);
|
||||
if (it != m_idContainerMap.constEnd())
|
||||
return it.value();
|
||||
@@ -320,7 +321,7 @@ Command *ActionManagerPrivate::registerAction(QAction *action, const QString &id
|
||||
Command *ActionManagerPrivate::registerOverridableAction(QAction *action, const QString &id, bool checkUnique)
|
||||
{
|
||||
OverrideableAction *a = 0;
|
||||
const int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
|
||||
const int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
|
||||
if (CommandPrivate *c = m_idCmdMap.value(uid, 0)) {
|
||||
if (c->type() != Command::CT_OverridableAction) {
|
||||
qWarning() << "registerAction: id" << id << "is registered with a different command type.";
|
||||
@@ -366,7 +367,7 @@ Command *ActionManagerPrivate::registerOverridableAction(QAction *action, const
|
||||
Command *ActionManagerPrivate::registerShortcut(QShortcut *shortcut, const QString &id, const QList<int> &context)
|
||||
{
|
||||
Shortcut *sc = 0;
|
||||
int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
|
||||
int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
|
||||
if (CommandPrivate *c = m_idCmdMap.value(uid, 0)) {
|
||||
if (c->type() != Command::CT_Shortcut) {
|
||||
qWarning() << "registerShortcut: id" << id << "is registered with a different command type.";
|
||||
@@ -402,7 +403,7 @@ Command *ActionManagerPrivate::registerShortcut(QShortcut *shortcut, const QStri
|
||||
|
||||
Command *ActionManagerPrivate::command(const QString &id) const
|
||||
{
|
||||
const int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
|
||||
const int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
|
||||
const IdCmdMap::const_iterator it = m_idCmdMap.constFind(uid);
|
||||
if (it == m_idCmdMap.constEnd()) {
|
||||
if (warnAboutFindFailures)
|
||||
@@ -414,9 +415,9 @@ Command *ActionManagerPrivate::command(const QString &id) const
|
||||
|
||||
ActionContainer *ActionManagerPrivate::actionContainer(const QString &id) const
|
||||
{
|
||||
const int uid = m_mainWnd->uniqueIDManager()->uniqueIdentifier(id);
|
||||
const int uid = UniqueIDManager::instance()->uniqueIdentifier(id);
|
||||
const IdContainerMap::const_iterator it = m_idContainerMap.constFind(uid);
|
||||
if ( it == m_idContainerMap.constEnd()) {
|
||||
if (it == m_idContainerMap.constEnd()) {
|
||||
if (warnAboutFindFailures)
|
||||
qWarning() << "ActionManagerPrivate::actionContainer(): failed to find :" << id << '/' << uid;
|
||||
return 0;
|
||||
@@ -429,7 +430,7 @@ Command *ActionManagerPrivate::command(int uid) const
|
||||
const IdCmdMap::const_iterator it = m_idCmdMap.constFind(uid);
|
||||
if (it == m_idCmdMap.constEnd()) {
|
||||
if (warnAboutFindFailures)
|
||||
qWarning() << "ActionManagerPrivate::command(): failed to find :" << m_mainWnd->uniqueIDManager()->stringForUniqueIdentifier(uid) << '/' << uid;
|
||||
qWarning() << "ActionManagerPrivate::command(): failed to find :" << UniqueIDManager::instance()->stringForUniqueIdentifier(uid) << '/' << uid;
|
||||
return 0;
|
||||
}
|
||||
return it.value();
|
||||
@@ -440,7 +441,7 @@ ActionContainer *ActionManagerPrivate::actionContainer(int uid) const
|
||||
const IdContainerMap::const_iterator it = m_idContainerMap.constFind(uid);
|
||||
if (it == m_idContainerMap.constEnd()) {
|
||||
if (warnAboutFindFailures)
|
||||
qWarning() << "ActionManagerPrivate::actionContainer(): failed to find :" << m_mainWnd->uniqueIDManager()->stringForUniqueIdentifier(uid) << uid;
|
||||
qWarning() << "ActionManagerPrivate::actionContainer(): failed to find :" << UniqueIDManager::instance()->stringForUniqueIdentifier(uid) << uid;
|
||||
return 0;
|
||||
}
|
||||
return it.value();
|
||||
@@ -458,7 +459,7 @@ void ActionManagerPrivate::initialize()
|
||||
settings->setArrayIndex(i);
|
||||
const QString sid = settings->value(QLatin1String(idKey)).toString();
|
||||
const QKeySequence key(settings->value(QLatin1String(sequenceKey)).toString());
|
||||
const int id = m_mainWnd->uniqueIDManager()->uniqueIdentifier(sid);
|
||||
const int id = UniqueIDManager::instance()->uniqueIdentifier(sid);
|
||||
|
||||
Command *cmd = command(id);
|
||||
if (cmd)
|
||||
@@ -478,7 +479,7 @@ void ActionManagerPrivate::saveSettings(QSettings *settings)
|
||||
CommandPrivate *cmd = j.value();
|
||||
QKeySequence key = cmd->keySequence();
|
||||
if (key != cmd->defaultKeySequence()) {
|
||||
const QString sid = m_mainWnd->uniqueIDManager()->stringForUniqueIdentifier(id);
|
||||
const QString sid = UniqueIDManager::instance()->stringForUniqueIdentifier(id);
|
||||
settings->setArrayIndex(count);
|
||||
settings->setValue(QLatin1String(idKey), sid);
|
||||
settings->setValue(QLatin1String(sequenceKey), key.toString());
|
||||
|
@@ -65,7 +65,7 @@ class ActionManagerPrivate : public Core::ActionManager
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ActionManagerPrivate(MainWindow *mainWnd, UniqueIDManager *uidmgr);
|
||||
explicit ActionManagerPrivate(MainWindow *mainWnd);
|
||||
~ActionManagerPrivate();
|
||||
|
||||
void setContext(const QList<int> &context);
|
||||
|
@@ -82,29 +82,10 @@ BaseView::BaseView(QObject *parent)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn BaseView::BaseView(const char *name, QWidget *widget, const QList<int> &context, Qt::DockWidgetArea position, QObject *parent)
|
||||
|
||||
Creates a view with the given properties.
|
||||
|
||||
\a name
|
||||
\a widget
|
||||
\a context
|
||||
\a position
|
||||
\a parent
|
||||
*/
|
||||
|
||||
BaseView::BaseView(const char *name, QWidget *widget, const QList<int> &context, IView::ViewPosition position, QObject *parent)
|
||||
: IView(parent),
|
||||
m_viewName(name),
|
||||
m_widget(widget),
|
||||
m_context(context),
|
||||
m_defaultPosition(position)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn BaseView::~BaseView()
|
||||
|
||||
Destructor also destroys the widget.
|
||||
*/
|
||||
BaseView::~BaseView()
|
||||
{
|
||||
|
@@ -40,14 +40,12 @@
|
||||
|
||||
namespace Core {
|
||||
|
||||
class CORE_EXPORT BaseView
|
||||
: public IView
|
||||
class CORE_EXPORT BaseView : public IView
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BaseView(QObject *parent = 0);
|
||||
BaseView(const char *name, QWidget *widget, const QList<int> &context, IView::ViewPosition position, QObject *parent = 0);
|
||||
~BaseView();
|
||||
|
||||
QList<int> context() const;
|
||||
|
@@ -67,5 +67,6 @@
|
||||
<file>images/undo.png</file>
|
||||
<file>images/unknownfile.png</file>
|
||||
<file>images/unlocked.png</file>
|
||||
<file>images/extension.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@@ -93,11 +93,6 @@ MessageManager *CoreImpl::messageManager() const
|
||||
return m_mainwindow->messageManager();
|
||||
}
|
||||
|
||||
ExtensionSystem::PluginManager *CoreImpl::pluginManager() const
|
||||
{
|
||||
return m_mainwindow->pluginManager();
|
||||
}
|
||||
|
||||
EditorManager *CoreImpl::editorManager() const
|
||||
{
|
||||
return m_mainwindow->editorManager();
|
||||
|
@@ -58,7 +58,6 @@ public:
|
||||
FileManager *fileManager() const ;
|
||||
UniqueIDManager *uniqueIDManager() const;
|
||||
MessageManager *messageManager() const;
|
||||
ExtensionSystem::PluginManager *pluginManager() const;
|
||||
EditorManager *editorManager() const;
|
||||
ProgressManager *progressManager() const;
|
||||
ScriptManager *scriptManager() const;
|
||||
|
@@ -50,7 +50,7 @@
|
||||
using namespace Core::Internal;
|
||||
|
||||
CorePlugin::CorePlugin() :
|
||||
m_mainWindow(new MainWindow), m_welcomeMode(0), m_editMode(0), m_pm(0)
|
||||
m_mainWindow(new MainWindow), m_welcomeMode(0), m_editMode(0)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -71,10 +71,10 @@ CorePlugin::~CorePlugin()
|
||||
delete m_mainWindow;
|
||||
}
|
||||
|
||||
bool CorePlugin::initialize(const QStringList & /*arguments*/, QString *error_message)
|
||||
bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
{
|
||||
m_pm = ExtensionSystem::PluginManager::instance();
|
||||
const bool success = m_mainWindow->init(m_pm, error_message);
|
||||
Q_UNUSED(arguments);
|
||||
const bool success = m_mainWindow->init(errorMessage);
|
||||
if (success) {
|
||||
#if !defined(QT_NO_WEBKIT)
|
||||
QWebSettings *webSettings = QWebSettings::globalSettings();
|
||||
|
@@ -51,7 +51,7 @@ public:
|
||||
CorePlugin();
|
||||
~CorePlugin();
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *error_message = 0);
|
||||
bool initialize(const QStringList &arguments, QString *errorMessage = 0);
|
||||
void extensionsInitialized();
|
||||
|
||||
public slots:
|
||||
@@ -61,8 +61,6 @@ private:
|
||||
MainWindow *m_mainWindow;
|
||||
WelcomeMode *m_welcomeMode;
|
||||
EditMode *m_editMode;
|
||||
|
||||
ExtensionSystem::PluginManager *m_pm;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -7,7 +7,7 @@ QT += xml \
|
||||
|
||||
include(../../qworkbenchplugin.pri)
|
||||
include(../../libs/utils/utils.pri)
|
||||
include(../../../shared/scriptwrapper/scriptwrapper.pri)
|
||||
include(../../shared/scriptwrapper/scriptwrapper.pri)
|
||||
include(coreplugin_dependencies.pri)
|
||||
INCLUDEPATH += dialogs \
|
||||
actionmanager \
|
||||
|
@@ -42,23 +42,25 @@ namespace Core {
|
||||
|
||||
/*!
|
||||
\class Core::ICoreListener
|
||||
\brief Provides a hook for plugins to veto on certain events emitted from the core plugin.
|
||||
|
||||
You implement this interface if you want to prevent certain events from occurring, e.g.
|
||||
if you want to prevent the closing of the whole application or to prevent the closing
|
||||
of an editor window under certain conditions.
|
||||
\brief Provides a hook for plugins to veto on certain events emitted from
|
||||
the core plugin.
|
||||
|
||||
You implement this interface if you want to prevent certain events from
|
||||
occurring, e.g. if you want to prevent the closing of the whole application
|
||||
or to prevent the closing of an editor window under certain conditions.
|
||||
|
||||
If e.g. the application window requests a close, then first
|
||||
ICoreListener::coreAboutToClose() is called (in arbitrary order)
|
||||
on all registered objects implementing this interface. If one if these calls returns
|
||||
false, the process is aborted and the event is ignored.
|
||||
If all calls return true, the corresponding signal is emitted and the event is accepted/performed.
|
||||
ICoreListener::coreAboutToClose() is called (in arbitrary order) on all
|
||||
registered objects implementing this interface. If one if these calls returns
|
||||
false, the process is aborted and the event is ignored. If all calls return
|
||||
true, the corresponding signal is emitted and the event is accepted/performed.
|
||||
|
||||
Guidelines for implementing:
|
||||
\list
|
||||
\o Return false from the implemented method if you want to prevent the event.
|
||||
\o You need to add your implementing object to the plugin managers objects:
|
||||
ICore::pluginManager()->addObject(yourImplementingObject);
|
||||
ExtensionSystem::PluginManager::instance()->addObject(yourImplementingObject);
|
||||
\o Don't forget to remove the object again at deconstruction (e.g. in the destructor of
|
||||
your plugin).
|
||||
*/
|
||||
|
BIN
src/plugins/coreplugin/images/extension.png
Normal file
After Width: | Height: | Size: 345 B |
Before Width: | Height: | Size: 230 B After Width: | Height: | Size: 592 B |
Before Width: | Height: | Size: 147 B After Width: | Height: | Size: 435 B |
@@ -33,6 +33,8 @@
|
||||
|
||||
#include "inavigationwidgetfactory.h"
|
||||
|
||||
#include <QtGui/QKeySequence>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
INavigationWidgetFactory::INavigationWidgetFactory()
|
||||
|
@@ -37,16 +37,17 @@
|
||||
#include <coreplugin/core_global.h>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QList>
|
||||
#include <QtGui/QKeySequence>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QToolButton;
|
||||
class QKeySequence;
|
||||
class QWidget;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
|
||||
struct NavigationView {
|
||||
struct NavigationView
|
||||
{
|
||||
QWidget *widget;
|
||||
QList<QToolButton *> doockToolBarWidgets;
|
||||
};
|
||||
|
@@ -36,14 +36,11 @@
|
||||
|
||||
#include "core_global.h"
|
||||
|
||||
#include <QtGui/QKeySequence>
|
||||
|
||||
#include <coreplugin/icontext.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
class CORE_EXPORT IView
|
||||
: public IContext
|
||||
class CORE_EXPORT IView : public IContext
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
@@ -116,7 +116,7 @@ MainWindow::MainWindow() :
|
||||
m_additionalContexts(m_globalContext),
|
||||
m_settings(new QSettings(QSettings::IniFormat, QSettings::UserScope, QLatin1String("Nokia"), QLatin1String("QtCreator"), this)),
|
||||
m_printer(0),
|
||||
m_actionManager(new ActionManagerPrivate(this, m_uniqueIDManager)),
|
||||
m_actionManager(new ActionManagerPrivate(this)),
|
||||
m_editorManager(0),
|
||||
m_fileManager(new FileManager(this)),
|
||||
m_progressManager(new ProgressManagerPrivate()),
|
||||
@@ -130,8 +130,6 @@ MainWindow::MainWindow() :
|
||||
m_rightPaneWidget(0),
|
||||
m_versionDialog(0),
|
||||
m_activeContext(0),
|
||||
m_pluginManager(0),
|
||||
m_outputPane(new OutputPane(m_globalContext)),
|
||||
m_outputMode(0),
|
||||
m_generalSettings(new GeneralSettings),
|
||||
m_shortcutSettings(new ShortcutSettings),
|
||||
@@ -150,8 +148,28 @@ MainWindow::MainWindow() :
|
||||
#endif
|
||||
m_toggleSideBarButton(new QToolButton)
|
||||
{
|
||||
OutputPaneManager::create();
|
||||
|
||||
setWindowTitle(tr("Qt Creator"));
|
||||
qApp->setWindowIcon(QIcon(":/core/images/qtcreator_logo_128.png"));
|
||||
QCoreApplication::setApplicationName(QLatin1String("QtCreator"));
|
||||
QCoreApplication::setApplicationVersion(QLatin1String(Core::Constants::IDE_VERSION_LONG));
|
||||
QCoreApplication::setOrganizationName(QLatin1String("Nokia"));
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
QString baseName = qApp->style()->objectName();
|
||||
#ifdef Q_WS_X11
|
||||
if (baseName == "windows") {
|
||||
// Sometimes we get the standard windows 95 style as a fallback
|
||||
// e.g. if we are running on a KDE4 desktop
|
||||
QByteArray desktopEnvironment = qgetenv("DESKTOP_SESSION");
|
||||
if (desktopEnvironment == "kde")
|
||||
baseName = "plastique";
|
||||
else
|
||||
baseName = "cleanlooks";
|
||||
}
|
||||
#endif
|
||||
qApp->setStyle(new ManhattanStyle(baseName));
|
||||
|
||||
setDockNestingEnabled(true);
|
||||
|
||||
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
||||
@@ -183,23 +201,6 @@ MainWindow::MainWindow() :
|
||||
//signal(SIGINT, handleSigInt);
|
||||
#endif
|
||||
|
||||
QCoreApplication::setApplicationName(QLatin1String("QtCreator"));
|
||||
QCoreApplication::setApplicationVersion(QLatin1String(Core::Constants::IDE_VERSION_LONG));
|
||||
QCoreApplication::setOrganizationName(QLatin1String("Nokia"));
|
||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||
QString baseName = qApp->style()->objectName();
|
||||
#ifdef Q_WS_X11
|
||||
if (baseName == "windows") {
|
||||
// Sometimes we get the standard windows 95 style as a fallback
|
||||
// e.g. if we are running on a KDE4 desktop
|
||||
QByteArray desktopEnvironment = qgetenv("DESKTOP_SESSION");
|
||||
if (desktopEnvironment == "kde")
|
||||
baseName = "plastique";
|
||||
else
|
||||
baseName = "cleanlooks";
|
||||
}
|
||||
#endif
|
||||
qApp->setStyle(new ManhattanStyle(baseName));
|
||||
statusBar()->setProperty("p_styled", true);
|
||||
}
|
||||
|
||||
@@ -224,8 +225,9 @@ void MainWindow::setSuppressNavigationWidget(bool suppress)
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
hide();
|
||||
m_pluginManager->removeObject(m_shortcutSettings);
|
||||
m_pluginManager->removeObject(m_generalSettings);
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
pm->removeObject(m_shortcutSettings);
|
||||
pm->removeObject(m_generalSettings);
|
||||
delete m_messageManager;
|
||||
m_messageManager = 0;
|
||||
delete m_shortcutSettings;
|
||||
@@ -240,17 +242,17 @@ MainWindow::~MainWindow()
|
||||
m_uniqueIDManager = 0;
|
||||
delete m_vcsManager;
|
||||
m_vcsManager = 0;
|
||||
m_pluginManager->removeObject(m_outputMode);
|
||||
pm->removeObject(m_outputMode);
|
||||
delete m_outputMode;
|
||||
m_outputMode = 0;
|
||||
//we need to delete editormanager and viewmanager explicitly before the end of the destructor,
|
||||
//because they might trigger stuff that tries to access data from editorwindow, like removeContextWidget
|
||||
|
||||
// All modes are now gone
|
||||
delete OutputPane::instance();
|
||||
OutputPaneManager::destroy();
|
||||
|
||||
// Now that the OutputPane is gone, is a good time to delete the view
|
||||
m_pluginManager->removeObject(m_outputView);
|
||||
// Now that the OutputPaneManager is gone, is a good time to delete the view
|
||||
pm->removeObject(m_outputView);
|
||||
delete m_outputView;
|
||||
|
||||
delete m_editorManager;
|
||||
@@ -259,7 +261,7 @@ MainWindow::~MainWindow()
|
||||
m_viewManager = 0;
|
||||
delete m_progressManager;
|
||||
m_progressManager = 0;
|
||||
m_pluginManager->removeObject(m_coreImpl);
|
||||
pm->removeObject(m_coreImpl);
|
||||
delete m_coreImpl;
|
||||
m_coreImpl = 0;
|
||||
|
||||
@@ -275,10 +277,12 @@ MainWindow::~MainWindow()
|
||||
m_mimeDatabase = 0;
|
||||
}
|
||||
|
||||
bool MainWindow::init(ExtensionSystem::PluginManager *pm, QString *)
|
||||
bool MainWindow::init(QString *errorMessage)
|
||||
{
|
||||
m_pluginManager = pm;
|
||||
m_pluginManager->addObject(m_coreImpl);
|
||||
Q_UNUSED(errorMessage);
|
||||
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
pm->addObject(m_coreImpl);
|
||||
m_viewManager->init();
|
||||
m_modeManager->init();
|
||||
m_progressManager->init();
|
||||
@@ -299,15 +303,18 @@ bool MainWindow::init(ExtensionSystem::PluginManager *pm, QString *)
|
||||
outputModeWidget->layout()->addWidget(new Core::FindToolBarPlaceHolder(m_outputMode));
|
||||
outputModeWidget->setFocusProxy(oph);
|
||||
|
||||
m_outputMode->setContext(m_outputPane->context());
|
||||
m_pluginManager->addObject(m_outputMode);
|
||||
m_pluginManager->addObject(m_generalSettings);
|
||||
m_pluginManager->addObject(m_shortcutSettings);
|
||||
m_outputMode->setContext(m_globalContext);
|
||||
pm->addObject(m_outputMode);
|
||||
pm->addObject(m_generalSettings);
|
||||
pm->addObject(m_shortcutSettings);
|
||||
|
||||
// Add widget to the bottom, we create the view here instead of inside the OutputPane, since
|
||||
// the ViewManager needs to be initilized before
|
||||
m_outputView = new Core::BaseView("OutputWindow.Buttons", m_outputPane->buttonsWidget(), QList<int>(), Core::IView::Second);
|
||||
m_pluginManager->addObject(m_outputView);
|
||||
// Add widget to the bottom, we create the view here instead of inside the
|
||||
// OutputPaneManager, since the ViewManager needs to be initilized before
|
||||
m_outputView = new Core::BaseView;
|
||||
m_outputView->setUniqueViewName("OutputWindow.Buttons");
|
||||
m_outputView->setWidget(OutputPaneManager::instance()->buttonsWidget());
|
||||
m_outputView->setDefaultPosition(Core::IView::Second);
|
||||
pm->addObject(m_outputView);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -317,8 +324,8 @@ void MainWindow::extensionsInitialized()
|
||||
|
||||
m_viewManager->extensionsInitalized();
|
||||
|
||||
m_messageManager->init(m_pluginManager);
|
||||
m_outputPane->init(m_pluginManager);
|
||||
m_messageManager->init();
|
||||
OutputPaneManager::instance()->init();
|
||||
|
||||
m_actionManager->initialize();
|
||||
readSettings();
|
||||
@@ -341,7 +348,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
}
|
||||
|
||||
const QList<ICoreListener *> listeners =
|
||||
pluginManager()->getObjects<ICoreListener>();
|
||||
ExtensionSystem::PluginManager::instance()->getObjects<ICoreListener>();
|
||||
foreach (ICoreListener *listener, listeners) {
|
||||
if (!listener->coreAboutToClose()) {
|
||||
event->ignore();
|
||||
@@ -756,7 +763,7 @@ void MainWindow::setFocusToEditor()
|
||||
if (focusWidget && focusWidget == qApp->focusWidget()) {
|
||||
if (FindToolBarPlaceHolder::getCurrent())
|
||||
FindToolBarPlaceHolder::getCurrent()->hide();
|
||||
m_outputPane->slotHide();
|
||||
OutputPaneManager::instance()->slotHide();
|
||||
RightPaneWidget::instance()->setShown(false);
|
||||
}
|
||||
}
|
||||
@@ -883,11 +890,6 @@ MimeDatabase *MainWindow::mimeDatabase() const
|
||||
return m_mimeDatabase;
|
||||
}
|
||||
|
||||
ExtensionSystem::PluginManager *MainWindow::pluginManager() const
|
||||
{
|
||||
return m_pluginManager;
|
||||
}
|
||||
|
||||
IContext *MainWindow::contextObject(QWidget *widget)
|
||||
{
|
||||
return m_contextWidgets.value(widget);
|
||||
@@ -1115,7 +1117,7 @@ void MainWindow::destroyVersionDialog()
|
||||
|
||||
void MainWindow::aboutPlugins()
|
||||
{
|
||||
PluginDialog dialog(ExtensionSystem::PluginManager::instance(), this);
|
||||
PluginDialog dialog(this);
|
||||
dialog.exec();
|
||||
}
|
||||
|
||||
|
@@ -49,10 +49,6 @@ class QSettings;
|
||||
class QShortcut;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ExtensionSystem {
|
||||
class PluginManager;
|
||||
}
|
||||
|
||||
namespace Core {
|
||||
|
||||
class ActionManager;
|
||||
@@ -80,7 +76,6 @@ class CoreImpl;
|
||||
class FancyTabWidget;
|
||||
class GeneralSettings;
|
||||
class NavigationWidget;
|
||||
class OutputPane;
|
||||
class ProgressManagerPrivate;
|
||||
class ShortcutSettings;
|
||||
class ViewManager;
|
||||
@@ -94,7 +89,7 @@ public:
|
||||
MainWindow();
|
||||
~MainWindow();
|
||||
|
||||
bool init(ExtensionSystem::PluginManager *pm, QString *error_message);
|
||||
bool init(QString *errorMessage);
|
||||
void extensionsInitialized();
|
||||
|
||||
IContext *contextObject(QWidget *widget);
|
||||
@@ -104,12 +99,10 @@ public:
|
||||
|
||||
void openFiles(const QStringList &fileNames);
|
||||
|
||||
inline ExtensionSystem::PluginManager *pluginManager() { return m_pluginManager; }
|
||||
Core::ActionManager *actionManager() const;
|
||||
Core::FileManager *fileManager() const;
|
||||
Core::UniqueIDManager *uniqueIDManager() const;
|
||||
Core::MessageManager *messageManager() const;
|
||||
ExtensionSystem::PluginManager *pluginManager() const;
|
||||
Core::EditorManager *editorManager() const;
|
||||
Core::ProgressManager *progressManager() const;
|
||||
Core::ScriptManager *scriptManager() const;
|
||||
@@ -196,9 +189,6 @@ private:
|
||||
|
||||
QMap<QWidget *, IContext *> m_contextWidgets;
|
||||
|
||||
ExtensionSystem::PluginManager *m_pluginManager;
|
||||
|
||||
OutputPane *m_outputPane;
|
||||
BaseMode *m_outputMode;
|
||||
GeneralSettings *m_generalSettings;
|
||||
ShortcutSettings *m_shortcutSettings;
|
||||
|
@@ -345,12 +345,11 @@ void ManhattanStyle::polish(QPalette &pal)
|
||||
QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
|
||||
const QWidget *widget) const
|
||||
{
|
||||
static const QIcon closeButton(":/core/images/closebutton.png");
|
||||
QIcon icon;
|
||||
switch (standardIcon) {
|
||||
case QStyle::SP_TitleBarCloseButton:
|
||||
icon = closeButton;
|
||||
break;
|
||||
case QStyle::SP_ToolBarHorizontalExtensionButton:
|
||||
return QIcon(standardPixmap(standardIcon, option, widget));
|
||||
default:
|
||||
icon = d->style->standardIcon(standardIcon, option, widget);
|
||||
}
|
||||
@@ -360,11 +359,20 @@ QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, co
|
||||
QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
|
||||
const QWidget *widget) const
|
||||
{
|
||||
static const QPixmap closeButton(":/core/images/closebutton.png");
|
||||
if (widget && !panelWidget(widget))
|
||||
return d->style->standardPixmap(standardPixmap, opt, widget);
|
||||
|
||||
QPixmap pixmap;
|
||||
switch (standardPixmap) {
|
||||
case QStyle::SP_TitleBarCloseButton:
|
||||
case QStyle::SP_ToolBarHorizontalExtensionButton: {
|
||||
static const QPixmap extButton(":/core/images/extension.png");
|
||||
pixmap = extButton;
|
||||
}
|
||||
break;
|
||||
case QStyle::SP_TitleBarCloseButton: {
|
||||
static const QPixmap closeButton(":/core/images/closebutton.png");
|
||||
pixmap = closeButton;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
pixmap = d->style->standardPixmap(standardPixmap, opt, widget);
|
||||
@@ -593,6 +601,84 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
case PE_IndicatorArrowUp:
|
||||
case PE_IndicatorArrowDown:
|
||||
case PE_IndicatorArrowRight:
|
||||
case PE_IndicatorArrowLeft:
|
||||
{
|
||||
// From windowsstyle but modified to enable AA
|
||||
if (option->rect.width() <= 1 || option->rect.height() <= 1)
|
||||
break;
|
||||
|
||||
QRect r = option->rect;
|
||||
int size = qMin(r.height(), r.width());
|
||||
QPixmap pixmap;
|
||||
QString pixmapName;
|
||||
pixmapName.sprintf("%s-%s-%d-%d-%d-%lld",
|
||||
"$qt_ia", metaObject()->className(),
|
||||
uint(option->state), element,
|
||||
size, option->palette.cacheKey());
|
||||
if (!QPixmapCache::find(pixmapName, pixmap)) {
|
||||
int border = size/5;
|
||||
int sqsize = 2*(size/2);
|
||||
QImage image(sqsize, sqsize, QImage::Format_ARGB32);
|
||||
image.fill(Qt::transparent);
|
||||
QPainter imagePainter(&image);
|
||||
imagePainter.setRenderHint(QPainter::Antialiasing, true);
|
||||
imagePainter.translate(0.5, 0.5);
|
||||
QPolygon a;
|
||||
switch (element) {
|
||||
case PE_IndicatorArrowUp:
|
||||
a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize - border, sqsize/2);
|
||||
break;
|
||||
case PE_IndicatorArrowDown:
|
||||
a.setPoints(3, border, sqsize/2, sqsize/2, sqsize - border, sqsize - border, sqsize/2);
|
||||
break;
|
||||
case PE_IndicatorArrowRight:
|
||||
a.setPoints(3, sqsize - border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
|
||||
break;
|
||||
case PE_IndicatorArrowLeft:
|
||||
a.setPoints(3, border, sqsize/2, sqsize/2, border, sqsize/2, sqsize - border);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
int bsx = 0;
|
||||
int bsy = 0;
|
||||
|
||||
if (option->state & State_Sunken) {
|
||||
bsx = pixelMetric(PM_ButtonShiftHorizontal);
|
||||
bsy = pixelMetric(PM_ButtonShiftVertical);
|
||||
}
|
||||
|
||||
QRect bounds = a.boundingRect();
|
||||
int sx = sqsize / 2 - bounds.center().x() - 1;
|
||||
int sy = sqsize / 2 - bounds.center().y() - 1;
|
||||
imagePainter.translate(sx + bsx, sy + bsy);
|
||||
imagePainter.setPen(option->palette.buttonText().color());
|
||||
imagePainter.setBrush(option->palette.buttonText());
|
||||
|
||||
if (!(option->state & State_Enabled)) {
|
||||
imagePainter.translate(1, 1);
|
||||
imagePainter.setBrush(option->palette.light().color());
|
||||
imagePainter.setPen(option->palette.light().color());
|
||||
imagePainter.drawPolygon(a);
|
||||
imagePainter.translate(-1, -1);
|
||||
imagePainter.setBrush(option->palette.mid().color());
|
||||
imagePainter.setPen(option->palette.mid().color());
|
||||
}
|
||||
|
||||
imagePainter.drawPolygon(a);
|
||||
imagePainter.end();
|
||||
pixmap = QPixmap::fromImage(image);
|
||||
QPixmapCache::insert(pixmapName, pixmap);
|
||||
}
|
||||
int xOffset = r.x() + (r.width() - size)/2;
|
||||
int yOffset = r.y() + (r.height() - size)/2;
|
||||
painter->drawPixmap(xOffset, yOffset, pixmap);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
d->style->drawPrimitive(element, option, painter, widget);
|
||||
@@ -902,7 +988,7 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
||||
newBtn.palette = panelPalette(option->palette);
|
||||
newBtn.rect = QRect(ir.right() - arrowSize - 1,
|
||||
ir.height() - arrowSize - 2, arrowSize, arrowSize);
|
||||
QWindowsStyle::drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
|
||||
drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -929,7 +1015,7 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
||||
pal.setBrush(QPalette::All, QPalette::ButtonText, StyleHelper::panelTextColor());
|
||||
arrowOpt.palette = pal;
|
||||
|
||||
QWindowsStyle::drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
|
||||
drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
@@ -44,26 +44,26 @@ using namespace Core;
|
||||
MessageManager *MessageManager::m_instance = 0;
|
||||
|
||||
MessageManager::MessageManager()
|
||||
: m_pm(0), m_messageOutputWindow(0)
|
||||
: m_messageOutputWindow(0)
|
||||
{
|
||||
m_instance = this;
|
||||
}
|
||||
|
||||
MessageManager::~MessageManager()
|
||||
{
|
||||
if (m_pm && m_messageOutputWindow) {
|
||||
m_pm->removeObject(m_messageOutputWindow);
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
if (pm && m_messageOutputWindow) {
|
||||
pm->removeObject(m_messageOutputWindow);
|
||||
delete m_messageOutputWindow;
|
||||
}
|
||||
|
||||
m_instance = 0;
|
||||
}
|
||||
|
||||
void MessageManager::init(ExtensionSystem::PluginManager *pm)
|
||||
void MessageManager::init()
|
||||
{
|
||||
m_pm = pm;
|
||||
m_messageOutputWindow = new Internal::MessageOutputWindow;
|
||||
pm->addObject(m_messageOutputWindow);
|
||||
ExtensionSystem::PluginManager::instance()->addObject(m_messageOutputWindow);
|
||||
}
|
||||
|
||||
void MessageManager::showOutputPane()
|
||||
|
@@ -37,8 +37,6 @@
|
||||
#include "core_global.h"
|
||||
#include <QtCore/QObject>
|
||||
|
||||
namespace ExtensionSystem { class PluginManager; }
|
||||
|
||||
namespace Core {
|
||||
|
||||
namespace Internal {
|
||||
@@ -53,7 +51,7 @@ public:
|
||||
MessageManager();
|
||||
~MessageManager();
|
||||
|
||||
void init(ExtensionSystem::PluginManager *pm);
|
||||
void init();
|
||||
|
||||
static MessageManager *instance() { return m_instance; }
|
||||
|
||||
@@ -64,7 +62,6 @@ public slots:
|
||||
void printToOutputPane(const QString &text, bool bringToForeground = true);
|
||||
|
||||
private:
|
||||
ExtensionSystem::PluginManager *m_pm;
|
||||
Internal::MessageOutputWindow *m_messageOutputWindow;
|
||||
|
||||
static MessageManager *m_instance;
|
||||
|
@@ -120,7 +120,8 @@ private:
|
||||
* Extensions:
|
||||
* - List of suffixes and preferred suffix (derived from glob patterns).
|
||||
*/
|
||||
class CORE_EXPORT MimeType {
|
||||
class CORE_EXPORT MimeType
|
||||
{
|
||||
public:
|
||||
/* Return value of a glob match, which is higher than magic */
|
||||
enum { GlobMatchPriority = 101 };
|
||||
|
@@ -81,7 +81,7 @@ private:
|
||||
OutputPanePlaceHolder *OutputPanePlaceHolder::m_current = 0;
|
||||
|
||||
OutputPanePlaceHolder::OutputPanePlaceHolder(Core::IMode *mode, QWidget *parent)
|
||||
:QWidget(parent), m_mode(mode), m_closeable(true)
|
||||
: QWidget(parent), m_mode(mode), m_closeable(true)
|
||||
{
|
||||
setVisible(false);
|
||||
setLayout(new QVBoxLayout);
|
||||
@@ -98,8 +98,8 @@ OutputPanePlaceHolder::OutputPanePlaceHolder(Core::IMode *mode, QWidget *parent)
|
||||
OutputPanePlaceHolder::~OutputPanePlaceHolder()
|
||||
{
|
||||
if (m_current == this) {
|
||||
OutputPane::instance()->setParent(0);
|
||||
OutputPane::instance()->hide();
|
||||
OutputPaneManager::instance()->setParent(0);
|
||||
OutputPaneManager::instance()->hide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,45 +117,54 @@ void OutputPanePlaceHolder::currentModeChanged(Core::IMode *mode)
|
||||
{
|
||||
if (m_current == this) {
|
||||
m_current = 0;
|
||||
OutputPane::instance()->setParent(0);
|
||||
OutputPane::instance()->hide();
|
||||
OutputPane::instance()->updateStatusButtons(false);
|
||||
OutputPaneManager::instance()->setParent(0);
|
||||
OutputPaneManager::instance()->hide();
|
||||
OutputPaneManager::instance()->updateStatusButtons(false);
|
||||
}
|
||||
if (m_mode == mode) {
|
||||
m_current = this;
|
||||
layout()->addWidget(OutputPane::instance());
|
||||
OutputPane::instance()->show();
|
||||
OutputPane::instance()->updateStatusButtons(isVisible());
|
||||
OutputPane::instance()->setCloseable(m_closeable);
|
||||
layout()->addWidget(OutputPaneManager::instance());
|
||||
OutputPaneManager::instance()->show();
|
||||
OutputPaneManager::instance()->updateStatusButtons(isVisible());
|
||||
OutputPaneManager::instance()->setCloseable(m_closeable);
|
||||
}
|
||||
}
|
||||
|
||||
////
|
||||
// OutputPane
|
||||
// OutputPaneManager
|
||||
////
|
||||
|
||||
OutputPane *OutputPane::m_instance = 0;
|
||||
static OutputPaneManager *m_instance = 0;
|
||||
|
||||
OutputPane *OutputPane::instance()
|
||||
void OutputPaneManager::create()
|
||||
{
|
||||
m_instance = new OutputPaneManager;
|
||||
}
|
||||
|
||||
void OutputPaneManager::destroy()
|
||||
{
|
||||
delete m_instance;
|
||||
m_instance = 0;
|
||||
}
|
||||
|
||||
OutputPaneManager *OutputPaneManager::instance()
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
|
||||
void OutputPane::updateStatusButtons(bool visible)
|
||||
void OutputPaneManager::updateStatusButtons(bool visible)
|
||||
{
|
||||
int idx = m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt();
|
||||
if (m_buttons.value(idx))
|
||||
m_buttons.value(idx)->setChecked(visible);
|
||||
}
|
||||
|
||||
OutputPane::OutputPane(const QList<int> &context, QWidget *parent) :
|
||||
OutputPaneManager::OutputPaneManager(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
m_context(context),
|
||||
m_widgetComboBox(new QComboBox),
|
||||
m_clearButton(new QToolButton),
|
||||
m_closeButton(new QToolButton),
|
||||
m_closeAction(0),
|
||||
m_pluginManager(0),
|
||||
m_lastIndex(-1),
|
||||
m_outputWidgetPane(new QStackedWidget),
|
||||
m_opToolBarWidgets(new QStackedWidget)
|
||||
@@ -191,24 +200,19 @@ OutputPane::OutputPane(const QList<int> &context, QWidget *parent) :
|
||||
#else
|
||||
m_buttonsWidget->layout()->setSpacing(4);
|
||||
#endif
|
||||
|
||||
m_instance = this;
|
||||
}
|
||||
|
||||
OutputPane::~OutputPane()
|
||||
OutputPaneManager::~OutputPaneManager()
|
||||
{
|
||||
m_instance = 0;
|
||||
}
|
||||
|
||||
QWidget *OutputPane::buttonsWidget()
|
||||
QWidget *OutputPaneManager::buttonsWidget()
|
||||
{
|
||||
return m_buttonsWidget;
|
||||
}
|
||||
|
||||
void OutputPane::init(ExtensionSystem::PluginManager *pm)
|
||||
void OutputPaneManager::init()
|
||||
{
|
||||
m_pluginManager = pm;
|
||||
|
||||
ActionManager *am = Core::ICore::instance()->actionManager();
|
||||
ActionContainer *mwindow = am->actionContainer(Constants::M_WINDOW);
|
||||
|
||||
@@ -217,7 +221,8 @@ void OutputPane::init(ExtensionSystem::PluginManager *pm)
|
||||
mwindow->addMenu(mpanes, Constants::G_WINDOW_PANES);
|
||||
mpanes->menu()->setTitle(tr("Output &Panes"));
|
||||
|
||||
QList<IOutputPane*> panes = m_pluginManager->getObjects<IOutputPane>();
|
||||
QList<IOutputPane*> panes = ExtensionSystem::PluginManager::instance()
|
||||
->getObjects<IOutputPane>();
|
||||
QMultiMap<int, IOutputPane*> sorted;
|
||||
foreach (IOutputPane* outPane, panes)
|
||||
sorted.insertMulti(outPane->priorityInStatusBar(), outPane);
|
||||
@@ -251,7 +256,7 @@ void OutputPane::init(ExtensionSystem::PluginManager *pm)
|
||||
actionId.remove(QLatin1Char(' '));
|
||||
QAction *action = new QAction(outPane->name(), this);
|
||||
|
||||
Command *cmd = am->registerAction(action, actionId, m_context);
|
||||
Command *cmd = am->registerAction(action, actionId, QList<int>() << Constants::C_GLOBAL_ID);
|
||||
if (outPane->priorityInStatusBar() != -1) {
|
||||
#ifdef Q_OS_MAC
|
||||
cmd->setDefaultKeySequence(QKeySequence("Ctrl+" + QString::number(shortcutNumber)));
|
||||
@@ -281,7 +286,7 @@ void OutputPane::init(ExtensionSystem::PluginManager *pm)
|
||||
changePage();
|
||||
}
|
||||
|
||||
void OutputPane::shortcutTriggered()
|
||||
void OutputPaneManager::shortcutTriggered()
|
||||
{
|
||||
QAction *action = qobject_cast<QAction*>(sender());
|
||||
if (action && m_actions.contains(action)) {
|
||||
@@ -305,7 +310,7 @@ void OutputPane::shortcutTriggered()
|
||||
}
|
||||
}
|
||||
|
||||
void OutputPane::buttonTriggered()
|
||||
void OutputPaneManager::buttonTriggered()
|
||||
{
|
||||
QPushButton *button = qobject_cast<QPushButton *>(sender());
|
||||
QMap<int, QPushButton *>::const_iterator it, end;
|
||||
@@ -327,7 +332,7 @@ void OutputPane::buttonTriggered()
|
||||
}
|
||||
}
|
||||
|
||||
void OutputPane::updateToolTip()
|
||||
void OutputPaneManager::updateToolTip()
|
||||
{
|
||||
QAction *action = qobject_cast<QAction*>(sender());
|
||||
if (action) {
|
||||
@@ -337,7 +342,7 @@ void OutputPane::updateToolTip()
|
||||
}
|
||||
}
|
||||
|
||||
void OutputPane::slotHide()
|
||||
void OutputPaneManager::slotHide()
|
||||
{
|
||||
if (OutputPanePlaceHolder::m_current) {
|
||||
OutputPanePlaceHolder::m_current->setVisible(false);
|
||||
@@ -349,7 +354,7 @@ void OutputPane::slotHide()
|
||||
}
|
||||
}
|
||||
|
||||
int OutputPane::findIndexForPage(IOutputPane *out)
|
||||
int OutputPaneManager::findIndexForPage(IOutputPane *out)
|
||||
{
|
||||
if (!out)
|
||||
return -1;
|
||||
@@ -369,7 +374,7 @@ int OutputPane::findIndexForPage(IOutputPane *out)
|
||||
return -1;
|
||||
}
|
||||
|
||||
void OutputPane::ensurePageVisible(int idx)
|
||||
void OutputPaneManager::ensurePageVisible(int idx)
|
||||
{
|
||||
if (m_widgetComboBox->itemData(m_widgetComboBox->currentIndex()).toInt() != idx) {
|
||||
m_widgetComboBox->setCurrentIndex(m_widgetComboBox->findData(idx));
|
||||
@@ -379,13 +384,13 @@ void OutputPane::ensurePageVisible(int idx)
|
||||
}
|
||||
|
||||
|
||||
void OutputPane::showPage(bool focus)
|
||||
void OutputPaneManager::showPage(bool focus)
|
||||
{
|
||||
int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender()));
|
||||
showPage(idx, focus);
|
||||
}
|
||||
|
||||
void OutputPane::showPage(int idx, bool focus)
|
||||
void OutputPaneManager::showPage(int idx, bool focus)
|
||||
{
|
||||
IOutputPane *out = m_pageMap.value(idx);
|
||||
if (idx > -1) {
|
||||
@@ -404,7 +409,7 @@ void OutputPane::showPage(int idx, bool focus)
|
||||
}
|
||||
}
|
||||
|
||||
void OutputPane::togglePage(bool focus)
|
||||
void OutputPaneManager::togglePage(bool focus)
|
||||
{
|
||||
int idx = findIndexForPage(qobject_cast<IOutputPane*>(sender()));
|
||||
if (OutputPanePlaceHolder::m_current
|
||||
@@ -416,23 +421,23 @@ void OutputPane::togglePage(bool focus)
|
||||
}
|
||||
}
|
||||
|
||||
void OutputPane::setCloseable(bool b)
|
||||
void OutputPaneManager::setCloseable(bool b)
|
||||
{
|
||||
m_closeAction->setVisible(b);
|
||||
}
|
||||
|
||||
bool OutputPane::closeable()
|
||||
bool OutputPaneManager::closeable()
|
||||
{
|
||||
return m_closeButton->isVisibleTo(m_closeButton->parentWidget());
|
||||
}
|
||||
|
||||
void OutputPane::focusInEvent(QFocusEvent *e)
|
||||
void OutputPaneManager::focusInEvent(QFocusEvent *e)
|
||||
{
|
||||
if (m_outputWidgetPane->currentWidget())
|
||||
m_outputWidgetPane->currentWidget()->setFocus(e->reason());
|
||||
}
|
||||
|
||||
void OutputPane::changePage()
|
||||
void OutputPaneManager::changePage()
|
||||
{
|
||||
if (m_outputWidgetPane->count() <= 0)
|
||||
return;
|
||||
@@ -469,7 +474,7 @@ void OutputPane::changePage()
|
||||
m_lastIndex = idx;
|
||||
}
|
||||
|
||||
void OutputPane::clearPage()
|
||||
void OutputPaneManager::clearPage()
|
||||
{
|
||||
if (m_pageMap.contains(m_outputWidgetPane->currentIndex()))
|
||||
m_pageMap.value(m_outputWidgetPane->currentIndex())->clearContents();
|
||||
|
@@ -47,21 +47,20 @@ class QStackedWidget;
|
||||
class QPushButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ExtensionSystem { class PluginManager; }
|
||||
|
||||
namespace Core {
|
||||
|
||||
class IMode;
|
||||
class IOutputPane;
|
||||
|
||||
namespace Internal {
|
||||
class OutputPane;
|
||||
class OutputPaneManager;
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
|
||||
class CORE_EXPORT OutputPanePlaceHolder : public QWidget
|
||||
{
|
||||
friend class Core::Internal::OutputPane; // needs to set m_visible and thus access m_current
|
||||
friend class Core::Internal::OutputPaneManager; // needs to set m_visible and thus access m_current
|
||||
Q_OBJECT
|
||||
public:
|
||||
OutputPanePlaceHolder(Core::IMode *mode, QWidget *parent = 0);
|
||||
@@ -80,17 +79,13 @@ private:
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class OutputPane
|
||||
: public QWidget
|
||||
class OutputPaneManager : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
OutputPane(const QList<int> &context, QWidget *parent = 0);
|
||||
~OutputPane();
|
||||
void init(ExtensionSystem::PluginManager *pm);
|
||||
static OutputPane *instance();
|
||||
const QList<int> &context() const { return m_context; }
|
||||
void init();
|
||||
static OutputPaneManager *instance();
|
||||
void setCloseable(bool b);
|
||||
bool closeable();
|
||||
QWidget *buttonsWidget();
|
||||
@@ -103,7 +98,7 @@ public slots:
|
||||
protected:
|
||||
void focusInEvent(QFocusEvent *e);
|
||||
|
||||
private slots:;
|
||||
private slots:
|
||||
void changePage();
|
||||
void showPage(bool focus);
|
||||
void togglePage(bool focus);
|
||||
@@ -112,17 +107,23 @@ private slots:;
|
||||
void buttonTriggered();
|
||||
|
||||
private:
|
||||
// the only class that is allowed to create and destroy
|
||||
friend class MainWindow;
|
||||
|
||||
static void create();
|
||||
static void destroy();
|
||||
|
||||
OutputPaneManager(QWidget *parent = 0);
|
||||
~OutputPaneManager();
|
||||
|
||||
void showPage(int idx, bool focus);
|
||||
void ensurePageVisible(int idx);
|
||||
int findIndexForPage(IOutputPane *out);
|
||||
const QList<int> m_context;
|
||||
QComboBox *m_widgetComboBox;
|
||||
QToolButton *m_clearButton;
|
||||
QToolButton *m_closeButton;
|
||||
QAction *m_closeAction;
|
||||
|
||||
ExtensionSystem::PluginManager *m_pluginManager;
|
||||
|
||||
QMap<int, Core::IOutputPane*> m_pageMap;
|
||||
int m_lastIndex;
|
||||
|
||||
@@ -131,8 +132,6 @@ private:
|
||||
QWidget *m_buttonsWidget;
|
||||
QMap<int, QPushButton *> m_buttons;
|
||||
QMap<QAction *, int> m_actions;
|
||||
|
||||
static OutputPane *m_instance;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -48,9 +48,9 @@
|
||||
|
||||
using namespace Core::Internal;
|
||||
|
||||
PluginDialog::PluginDialog(ExtensionSystem::PluginManager *manager, QWidget *parent)
|
||||
PluginDialog::PluginDialog(QWidget *parent)
|
||||
: QDialog(parent),
|
||||
m_view(new ExtensionSystem::PluginView(manager, this))
|
||||
m_view(new ExtensionSystem::PluginView(ExtensionSystem::PluginManager::instance(), this))
|
||||
{
|
||||
QVBoxLayout *vl = new QVBoxLayout(this);
|
||||
vl->addWidget(m_view);
|
||||
|
@@ -41,7 +41,6 @@ class QPushButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace ExtensionSystem {
|
||||
class PluginManager;
|
||||
class PluginSpec;
|
||||
class PluginView;
|
||||
}
|
||||
@@ -54,7 +53,7 @@ class PluginDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
PluginDialog(ExtensionSystem::PluginManager *manager, QWidget *parent);
|
||||
explicit PluginDialog(QWidget *parent);
|
||||
|
||||
private slots:
|
||||
void updateButtons();
|
||||
|
@@ -44,41 +44,51 @@ namespace Core {
|
||||
class IMode;
|
||||
class RightPaneWidget;
|
||||
|
||||
// TODO: The right pane works only for the help plugin atm.
|
||||
// It can't cope with more than one plugin publishing objects they want in the right pane
|
||||
// For that the API would need to be different. (Might be that instead of adding objects
|
||||
// to the pool, there should be a method RightPaneWidget::setWidget(QWidget *w)
|
||||
// Anyway if a second plugin wants to show something there, redesign this API
|
||||
// TODO: The right pane works only for the help plugin atm. It can't cope
|
||||
// with more than one plugin publishing objects they want in the right pane
|
||||
// For that the API would need to be different. (Might be that instead of
|
||||
// adding objects to the pool, there should be a method
|
||||
// RightPaneWidget::setWidget(QWidget *w) Anyway if a second plugin wants to
|
||||
// show something there, redesign this API
|
||||
|
||||
class CORE_EXPORT RightPanePlaceHolder : public QWidget
|
||||
{
|
||||
friend class Core::RightPaneWidget;
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RightPanePlaceHolder(Core::IMode *mode, QWidget *parent = 0);
|
||||
~RightPanePlaceHolder();
|
||||
static RightPanePlaceHolder *current();
|
||||
|
||||
private slots:
|
||||
void currentModeChanged(Core::IMode *);
|
||||
|
||||
private:
|
||||
void applyStoredSize(int width);
|
||||
Core::IMode *m_mode;
|
||||
static RightPanePlaceHolder* m_current;
|
||||
};
|
||||
|
||||
|
||||
class CORE_EXPORT BaseRightPaneWidget : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
BaseRightPaneWidget(QWidget *widget);
|
||||
~BaseRightPaneWidget();
|
||||
QWidget *widget() const;
|
||||
|
||||
private:
|
||||
QWidget *m_widget;
|
||||
};
|
||||
|
||||
|
||||
class CORE_EXPORT RightPaneWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RightPaneWidget();
|
||||
~RightPaneWidget();
|
||||
@@ -89,11 +99,13 @@ public:
|
||||
bool isShown();
|
||||
void setShown(bool b);
|
||||
|
||||
static RightPaneWidget* instance();
|
||||
static RightPaneWidget *instance();
|
||||
|
||||
int storedWidth();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
private slots:
|
||||
void objectAdded(QObject *obj);
|
||||
void aboutToRemoveObject(QObject *obj);
|
||||
|
@@ -54,25 +54,25 @@ void Animation::paint(QPainter *painter, const QStyleOption *option)
|
||||
|
||||
void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha)
|
||||
{
|
||||
if (_secondaryImage.isNull() || _primaryImage.isNull())
|
||||
if (m_secondaryImage.isNull() || m_primaryImage.isNull())
|
||||
return;
|
||||
|
||||
if (_tempImage.isNull())
|
||||
_tempImage = _secondaryImage;
|
||||
if (m_tempImage.isNull())
|
||||
m_tempImage = m_secondaryImage;
|
||||
|
||||
const int a = qRound(alpha*256);
|
||||
const int ia = 256 - a;
|
||||
const int sw = _primaryImage.width();
|
||||
const int sh = _primaryImage.height();
|
||||
const int bpl = _primaryImage.bytesPerLine();
|
||||
switch (_primaryImage.depth()) {
|
||||
const int sw = m_primaryImage.width();
|
||||
const int sh = m_primaryImage.height();
|
||||
const int bpl = m_primaryImage.bytesPerLine();
|
||||
switch (m_primaryImage.depth()) {
|
||||
case 32:
|
||||
{
|
||||
uchar *mixed_data = _tempImage.bits();
|
||||
const uchar *back_data = _primaryImage.bits();
|
||||
const uchar *front_data = _secondaryImage.bits();
|
||||
uchar *mixed_data = m_tempImage.bits();
|
||||
const uchar *back_data = m_primaryImage.bits();
|
||||
const uchar *front_data = m_secondaryImage.bits();
|
||||
for (int sy = 0; sy < sh; sy++) {
|
||||
quint32* mixed = (quint32*)mixed_data;
|
||||
quint32 *mixed = (quint32*)mixed_data;
|
||||
const quint32* back = (const quint32*)back_data;
|
||||
const quint32* front = (const quint32*)front_data;
|
||||
for (int sx = 0; sx < sw; sx++) {
|
||||
@@ -91,27 +91,28 @@ void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
painter->drawImage(rect, _tempImage);
|
||||
painter->drawImage(rect, m_tempImage);
|
||||
}
|
||||
|
||||
void Transition::paint(QPainter *painter, const QStyleOption *option)
|
||||
{
|
||||
float alpha = 1.0;
|
||||
if (_duration > 0) {
|
||||
if (m_duration > 0) {
|
||||
QTime current = QTime::currentTime();
|
||||
|
||||
if (_startTime > current)
|
||||
_startTime = current;
|
||||
if (m_startTime > current)
|
||||
m_startTime = current;
|
||||
|
||||
int timeDiff = _startTime.msecsTo(current);
|
||||
alpha = timeDiff/(float)_duration;
|
||||
if (timeDiff > _duration) {
|
||||
_running = false;
|
||||
int timeDiff = m_startTime.msecsTo(current);
|
||||
alpha = timeDiff/(float)m_duration;
|
||||
if (timeDiff > m_duration) {
|
||||
m_running = false;
|
||||
alpha = 1.0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_running = false; }
|
||||
m_running = false;
|
||||
}
|
||||
drawBlendedImage(painter, option->rect, alpha);
|
||||
}
|
||||
|
||||
|
@@ -51,24 +51,24 @@
|
||||
class Animation
|
||||
{
|
||||
public :
|
||||
Animation() : _running(true) { }
|
||||
Animation() : m_running(true) { }
|
||||
virtual ~Animation() { }
|
||||
QWidget * widget() const { return _widget; }
|
||||
bool running() const { return _running; }
|
||||
const QTime &startTime() const { return _startTime; }
|
||||
void setRunning(bool val) { _running = val; }
|
||||
void setWidget(QWidget *widget) { _widget = widget; }
|
||||
void setStartTime(const QTime &startTime) { _startTime = startTime; }
|
||||
QWidget * widget() const { return m_widget; }
|
||||
bool running() const { return m_running; }
|
||||
const QTime &startTime() const { return m_startTime; }
|
||||
void setRunning(bool val) { m_running = val; }
|
||||
void setWidget(QWidget *widget) { m_widget = widget; }
|
||||
void setStartTime(const QTime &startTime) { m_startTime = startTime; }
|
||||
virtual void paint(QPainter *painter, const QStyleOption *option);
|
||||
|
||||
protected:
|
||||
void drawBlendedImage(QPainter *painter, QRect rect, float value);
|
||||
QTime _startTime;
|
||||
QPointer<QWidget> _widget;
|
||||
QImage _primaryImage;
|
||||
QImage _secondaryImage;
|
||||
QImage _tempImage;
|
||||
bool _running;
|
||||
QTime m_startTime;
|
||||
QPointer<QWidget> m_widget;
|
||||
QImage m_primaryImage;
|
||||
QImage m_secondaryImage;
|
||||
QImage m_tempImage;
|
||||
bool m_running;
|
||||
};
|
||||
|
||||
// Handles state transition animations
|
||||
@@ -76,13 +76,13 @@ class Transition : public Animation
|
||||
{
|
||||
public :
|
||||
Transition() : Animation() {}
|
||||
virtual ~Transition() { }
|
||||
void setDuration(int duration) { _duration = duration; }
|
||||
void setStartImage(const QImage &image) { _primaryImage = image; }
|
||||
void setEndImage(const QImage &image) { _secondaryImage = image; }
|
||||
virtual ~Transition() {}
|
||||
void setDuration(int duration) { m_duration = duration; }
|
||||
void setStartImage(const QImage &image) { m_primaryImage = image; }
|
||||
void setEndImage(const QImage &image) { m_secondaryImage = image; }
|
||||
virtual void paint(QPainter *painter, const QStyleOption *option);
|
||||
int duration() const { return _duration; }
|
||||
int _duration; //set time in ms to complete a state transition
|
||||
int duration() const { return m_duration; }
|
||||
int m_duration; //set time in ms to complete a state transition
|
||||
};
|
||||
|
||||
class StyleAnimator : public QObject
|
||||
|
@@ -69,9 +69,7 @@ public:
|
||||
static void menuGradient(QPainter *painter, const QRect &spanRect, const QRect &clipRect);
|
||||
|
||||
// Pixmap cache should only be enabled for X11 due to slow gradients
|
||||
static bool usePixmapCache() {
|
||||
return true;
|
||||
}
|
||||
static bool usePixmapCache() { return true; }
|
||||
|
||||
private:
|
||||
static QColor m_baseColor;
|
||||
|
@@ -36,8 +36,6 @@
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
#define TABPOSITIONINDICATOR_WIDTH 2
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
||||
@@ -46,6 +44,8 @@ class TabPositionIndicator : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum { TABPOSITIONINDICATOR_WIDTH = 2 };
|
||||
|
||||
TabPositionIndicator();
|
||||
int indicatorWidth() { return TABPOSITIONINDICATOR_WIDTH; }
|
||||
|
||||
|
@@ -115,7 +115,8 @@ void ViewManager::saveSettings(QSettings *settings)
|
||||
|
||||
IView *ViewManager::view(const QString &id)
|
||||
{
|
||||
QList<IView *> list = m_mainWnd->pluginManager()->getObjects<IView>();
|
||||
QList<IView *> list =
|
||||
ExtensionSystem::PluginManager::instance()->getObjects<IView>();
|
||||
foreach (IView *view, list) {
|
||||
if (view->uniqueViewName() == id)
|
||||
return view;
|
||||
|
@@ -41,7 +41,6 @@
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QWidget;
|
||||
class QUrl;
|
||||
class QLabel;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
@@ -77,8 +76,7 @@ public:
|
||||
const char* uniqueModeName() const;
|
||||
QList<int> context() const;
|
||||
void activated();
|
||||
QString contextHelpId() const
|
||||
{ return QLatin1String("Qt Creator"); }
|
||||
QString contextHelpId() const { return QLatin1String("Qt Creator"); }
|
||||
|
||||
signals:
|
||||
void requestProject(const QString &project);
|
||||
|
@@ -12,4 +12,4 @@ SOURCES += cpasterplugin.cpp \
|
||||
FORMS += settingspage.ui \
|
||||
pasteselect.ui
|
||||
|
||||
include(../../../shared/cpaster/cpaster.pri)
|
||||
include(../../shared/cpaster/cpaster.pri)
|
||||
|
@@ -3,6 +3,7 @@ TARGET = CppEditor
|
||||
DEFINES += CPPEDITOR_LIBRARY
|
||||
CONFIG += help
|
||||
include(../../libs/utils/utils.pri)
|
||||
include(../../shared/indenter/indenter.pri)
|
||||
include(../../qworkbenchplugin.pri)
|
||||
include(cppeditor_dependencies.pri)
|
||||
HEADERS += cppplugin.h \
|
||||
|
@@ -435,15 +435,15 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
||||
m_startPosition = findStartOfName(editor);
|
||||
m_completionOperator = T_EOF_SYMBOL;
|
||||
|
||||
int endOfExpression = m_startPosition;
|
||||
int endOfOperator = m_startPosition;
|
||||
|
||||
// Skip whitespace preceding this position
|
||||
while (editor->characterAt(endOfExpression - 1).isSpace())
|
||||
--endOfExpression;
|
||||
while (editor->characterAt(endOfOperator - 1).isSpace())
|
||||
--endOfOperator;
|
||||
|
||||
endOfExpression = startOfOperator(editor, endOfExpression,
|
||||
int endOfExpression = startOfOperator(editor, endOfOperator,
|
||||
&m_completionOperator,
|
||||
/*want function call =*/ editor->position() == endOfExpression);
|
||||
/*want function call =*/ true);
|
||||
|
||||
Core::IFile *file = editor->file();
|
||||
QString fileName = file->fileName();
|
||||
@@ -464,6 +464,11 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
||||
m_completionOperator = T_SIGNAL;
|
||||
else if (expression.endsWith(QLatin1String("SLOT")))
|
||||
m_completionOperator = T_SLOT;
|
||||
else if (editor->position() != endOfOperator) {
|
||||
// We don't want a function completion when the cursor isn't at the opening brace
|
||||
expression.clear();
|
||||
m_completionOperator = T_EOF_SYMBOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -913,8 +913,9 @@ void DebuggerPlugin::readSettings()
|
||||
#if defined(Q_OS_WIN32)
|
||||
defaultCommand.append(".exe");
|
||||
#endif
|
||||
QString defaultScript = ICore::instance()->resourcePath() +
|
||||
QLatin1String("/gdb/qt4macros");
|
||||
//QString defaultScript = ICore::instance()->resourcePath() +
|
||||
// QLatin1String("/gdb/qt4macros");
|
||||
QString defaultScript;
|
||||
|
||||
s->beginGroup(QLatin1String("DebugMode"));
|
||||
QByteArray ba = s->value("State", QByteArray()).toByteArray();
|
||||
|
@@ -2,7 +2,7 @@ TEMPLATE = lib
|
||||
TARGET = Designer
|
||||
|
||||
include(../../qworkbenchplugin.pri)
|
||||
include(../../../shared/designerintegrationv2/designerintegration.pri)
|
||||
include(../../shared/designerintegrationv2/designerintegration.pri)
|
||||
include(cpp/cpp.pri)
|
||||
include(designer_dependencies.pri)
|
||||
|
||||
|
@@ -8,7 +8,7 @@ include(../../plugins/projectexplorer/projectexplorer.pri)
|
||||
include(../../plugins/coreplugin/coreplugin.pri)
|
||||
include(../../plugins/texteditor/texteditor.pri)
|
||||
include(../../plugins/texteditor/cppeditor.pri)
|
||||
include(../../../shared/indenter/indenter.pri)
|
||||
include(../../shared/indenter/indenter.pri)
|
||||
|
||||
# DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII
|
||||
QT += gui
|
||||
|
@@ -45,6 +45,7 @@
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtCore/QProcess>
|
||||
#include <QtCore/QRegExp>
|
||||
#include <QtCore/QTextStream>
|
||||
@@ -157,6 +158,13 @@ QDebug &operator<<(QDebug &ts, const EditOperation &op)
|
||||
return ts;
|
||||
}
|
||||
|
||||
QDebug &operator<<(QDebug &ts, const QList<QTextEdit::ExtraSelection> &sels)
|
||||
{
|
||||
foreach (QTextEdit::ExtraSelection sel, sels)
|
||||
ts << "SEL: " << sel.cursor.anchor() << sel.cursor.position();
|
||||
return ts;
|
||||
}
|
||||
|
||||
int lineCount(const QString &text)
|
||||
{
|
||||
//return text.count(QChar(ParagraphSeparator));
|
||||
@@ -166,11 +174,14 @@ int lineCount(const QString &text)
|
||||
class FakeVimHandler::Private
|
||||
{
|
||||
public:
|
||||
Private(FakeVimHandler *parent);
|
||||
Private(FakeVimHandler *parent, QWidget *widget);
|
||||
|
||||
bool handleEvent(QKeyEvent *ev);
|
||||
void handleExCommand(const QString &cmd);
|
||||
|
||||
void setupWidget();
|
||||
void restoreWidget();
|
||||
|
||||
private:
|
||||
friend class FakeVimHandler;
|
||||
static int shift(int key) { return key + 32; }
|
||||
@@ -190,7 +201,8 @@ private:
|
||||
int count() const { return mvCount() * opCount(); }
|
||||
int leftDist() const { return m_tc.position() - m_tc.block().position(); }
|
||||
int rightDist() const { return m_tc.block().length() - leftDist() - 1; }
|
||||
bool atEndOfLine() const { return m_tc.atBlockEnd() && m_tc.block().length()>1; }
|
||||
bool atEndOfLine() const
|
||||
{ return m_tc.atBlockEnd() && m_tc.block().length() > 1; }
|
||||
|
||||
int lastPositionInDocument() const;
|
||||
int positionForLine(int line) const; // 1 based line, 0 based pos
|
||||
@@ -207,7 +219,7 @@ private:
|
||||
|
||||
// helper functions for indenting
|
||||
bool isElectricCharacter(QChar c) const
|
||||
{ return (c == '{' || c == '}' || c == '#'); }
|
||||
{ return c == '{' || c == '}' || c == '#'; }
|
||||
int indentDist() const;
|
||||
void indentRegion(QTextBlock first, QTextBlock last, QChar typedChar=0);
|
||||
void indentCurrentLine(QChar typedChar);
|
||||
@@ -238,9 +250,9 @@ private:
|
||||
int readLineCode(QString &cmd);
|
||||
void selectRange(int beginLine, int endLine);
|
||||
|
||||
void setWidget(QWidget *ob);
|
||||
void enterInsertMode();
|
||||
void enterCommandMode();
|
||||
void enterExMode();
|
||||
void showRedMessage(const QString &msg);
|
||||
void showBlackMessage(const QString &msg);
|
||||
void notImplementedYet();
|
||||
@@ -305,6 +317,11 @@ public:
|
||||
// extra data for '.'
|
||||
QString m_dotCommand;
|
||||
|
||||
// extra data for ';'
|
||||
QString m_semicolonCount;
|
||||
int m_semicolonType; // 'f', 'F', 't', 'T'
|
||||
int m_semicolonKey;
|
||||
|
||||
// history for '/'
|
||||
QString lastSearchString() const;
|
||||
QStringList m_searchHistory;
|
||||
@@ -328,12 +345,18 @@ public:
|
||||
// for restoring cursor position
|
||||
int m_savedYankPosition;
|
||||
int m_desiredColumn;
|
||||
|
||||
QPointer<QObject> m_extraData;
|
||||
int m_cursorWidth;
|
||||
};
|
||||
|
||||
FakeVimHandler::Private::Private(FakeVimHandler *parent)
|
||||
FakeVimHandler::Private::Private(FakeVimHandler *parent, QWidget *widget)
|
||||
{
|
||||
q = parent;
|
||||
|
||||
m_textedit = qobject_cast<QTextEdit *>(widget);
|
||||
m_plaintextedit = qobject_cast<QPlainTextEdit *>(widget);
|
||||
|
||||
m_mode = CommandMode;
|
||||
m_submode = NoSubMode;
|
||||
m_subsubmode = NoSubSubMode;
|
||||
@@ -341,13 +364,12 @@ FakeVimHandler::Private::Private(FakeVimHandler *parent)
|
||||
m_lastSearchForward = true;
|
||||
m_register = '"';
|
||||
m_gflag = false;
|
||||
m_textedit = 0;
|
||||
m_plaintextedit = 0;
|
||||
m_visualMode = NoVisualMode;
|
||||
m_desiredColumn = 0;
|
||||
m_moveType = MoveInclusive;
|
||||
m_anchor = 0;
|
||||
m_savedYankPosition = 0;
|
||||
m_cursorWidth = EDITOR(cursorWidth());
|
||||
|
||||
m_config[ConfigStartOfLine] = ConfigOn;
|
||||
m_config[ConfigTabStop] = "8";
|
||||
@@ -403,6 +425,29 @@ bool FakeVimHandler::Private::handleEvent(QKeyEvent *ev)
|
||||
return handled;
|
||||
}
|
||||
|
||||
void FakeVimHandler::Private::setupWidget()
|
||||
{
|
||||
enterCommandMode();
|
||||
EDITOR(installEventFilter(q));
|
||||
//EDITOR(setCursorWidth(QFontMetrics(ed->font()).width(QChar('x')));
|
||||
if (m_textedit) {
|
||||
m_textedit->setLineWrapMode(QTextEdit::NoWrap);
|
||||
} else if (m_plaintextedit) {
|
||||
m_plaintextedit->setLineWrapMode(QPlainTextEdit::NoWrap);
|
||||
}
|
||||
m_wasReadOnly = EDITOR(isReadOnly());
|
||||
showBlackMessage("vi emulation mode.");
|
||||
updateMiniBuffer();
|
||||
}
|
||||
|
||||
void FakeVimHandler::Private::restoreWidget()
|
||||
{
|
||||
//showBlackMessage(QString());
|
||||
//updateMiniBuffer();
|
||||
EDITOR(removeEventFilter(q));
|
||||
EDITOR(setReadOnly(m_wasReadOnly));
|
||||
}
|
||||
|
||||
bool FakeVimHandler::Private::handleKey(int key, int unmodified, const QString &text)
|
||||
{
|
||||
//qDebug() << "KEY: " << key << text << "POS: " << m_tc.position();
|
||||
@@ -419,11 +464,12 @@ bool FakeVimHandler::Private::handleKey(int key, int unmodified, const QString &
|
||||
|
||||
void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
||||
{
|
||||
//qDebug() << "ANCHOR: " << m_anchor;
|
||||
if (m_submode == FilterSubMode) {
|
||||
int beginLine = lineForPosition(anchor());
|
||||
int endLine = lineForPosition(position());
|
||||
m_tc.setPosition(qMin(anchor(), position()));
|
||||
m_mode = ExMode;
|
||||
enterExMode();
|
||||
m_commandBuffer = QString(".,+%1!").arg(qAbs(endLine - beginLine));
|
||||
m_commandHistory.append(QString());
|
||||
m_commandHistoryIndex = m_commandHistory.size() - 1;
|
||||
@@ -443,6 +489,8 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
||||
m_mode = InsertMode;
|
||||
m_submode = NoSubMode;
|
||||
} else if (m_submode == DeleteSubMode) {
|
||||
if (m_moveType == MoveInclusive)
|
||||
moveRight(); // correct
|
||||
if (!dotCommand.isEmpty())
|
||||
m_dotCommand = "d" + dotCommand;
|
||||
m_registers[m_register] = recordRemoveSelectedText();
|
||||
@@ -467,10 +515,8 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
||||
m_tc.setPosition(startBlock.position());
|
||||
moveToFirstNonBlankOnLine();
|
||||
m_submode = NoSubMode;
|
||||
} else if (m_moveType == MoveExclusive) {
|
||||
moveLeft(); // correct
|
||||
m_moveType = MoveInclusive;
|
||||
}
|
||||
m_moveType = MoveInclusive;
|
||||
m_mvcount.clear();
|
||||
m_opcount.clear();
|
||||
m_gflag = false;
|
||||
@@ -489,10 +535,13 @@ void FakeVimHandler::Private::updateSelection()
|
||||
QTextEdit::ExtraSelection sel;
|
||||
sel.cursor = m_tc;
|
||||
sel.format = m_tc.blockCharFormat();
|
||||
//sel.format.setFontWeight(QFont::Bold);
|
||||
//sel.format.setFontUnderline(true);
|
||||
#if 0
|
||||
sel.format.setFontWeight(QFont::Bold);
|
||||
sel.format.setFontUnderline(true);
|
||||
#else
|
||||
sel.format.setForeground(Qt::white);
|
||||
sel.format.setBackground(Qt::black);
|
||||
#endif
|
||||
int cursorPos = m_tc.position();
|
||||
int anchorPos = m_marks['<'];
|
||||
//qDebug() << "POS: " << cursorPos << " ANCHOR: " << anchorPos;
|
||||
@@ -529,7 +578,8 @@ void FakeVimHandler::Private::updateSelection()
|
||||
}
|
||||
}
|
||||
}
|
||||
emit q->selectionChanged(editor(), selections);
|
||||
//qDebug() << "SELECTION: " << selections;
|
||||
emit q->selectionChanged(selections);
|
||||
}
|
||||
|
||||
void FakeVimHandler::Private::updateMiniBuffer()
|
||||
@@ -648,9 +698,11 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
||||
}
|
||||
m_submode = NoSubMode;
|
||||
} else if (m_subsubmode == FtSubSubMode) {
|
||||
m_semicolonType = m_subsubdata;
|
||||
m_semicolonKey = key;
|
||||
handleFfTt(key);
|
||||
m_subsubmode = NoSubSubMode;
|
||||
finishMovement(QString(QChar(m_subsubdata)) + QChar(key));
|
||||
finishMovement();
|
||||
} else if (m_submode == ReplaceSubMode) {
|
||||
if (count() < rightDist() && text.size() == 1
|
||||
&& (text.at(0).isPrint() || text.at(0).isSpace())) {
|
||||
@@ -688,8 +740,22 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
||||
} else {
|
||||
m_mvcount.append(QChar(key));
|
||||
}
|
||||
} else if (0 && key == ',') {
|
||||
// FIXME: fakevim uses ',' by itself, so it is incompatible
|
||||
m_subsubmode = FtSubSubMode;
|
||||
// HACK: toggle 'f' <-> 'F', 't' <-> 'T'
|
||||
m_subsubdata = m_semicolonType ^ 32;
|
||||
handleFfTt(m_semicolonKey);
|
||||
m_subsubmode = NoSubSubMode;
|
||||
finishMovement();
|
||||
} else if (key == ';') {
|
||||
m_subsubmode = FtSubSubMode;
|
||||
m_subsubdata = m_semicolonType;
|
||||
handleFfTt(m_semicolonKey);
|
||||
m_subsubmode = NoSubSubMode;
|
||||
finishMovement();
|
||||
} else if (key == ':') {
|
||||
m_mode = ExMode;
|
||||
enterExMode();
|
||||
m_commandBuffer.clear();
|
||||
if (m_visualMode != NoVisualMode)
|
||||
m_commandBuffer = "'<,'>";
|
||||
@@ -722,7 +788,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
||||
} else if (key == '!' && m_visualMode == NoVisualMode) {
|
||||
m_submode = FilterSubMode;
|
||||
} else if (key == '!' && m_visualMode == VisualLineMode) {
|
||||
m_mode = ExMode;
|
||||
enterExMode();
|
||||
m_commandBuffer = "'<,'>!";
|
||||
m_commandHistory.append(QString());
|
||||
m_commandHistoryIndex = m_commandHistory.size() - 1;
|
||||
@@ -770,9 +836,11 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
||||
recordBeginGroup();
|
||||
m_lastInsertion.clear();
|
||||
} else if (key == 'b') {
|
||||
m_moveType = MoveExclusive;
|
||||
moveToWordBoundary(false, false);
|
||||
finishMovement();
|
||||
} else if (key == 'B') {
|
||||
m_moveType = MoveExclusive;
|
||||
moveToWordBoundary(true, false);
|
||||
finishMovement();
|
||||
} else if (key == 'c') {
|
||||
@@ -795,7 +863,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
||||
m_mvcount.clear();
|
||||
m_submode = DeleteSubMode;
|
||||
} else if (key == 'd') {
|
||||
setAnchor();
|
||||
//setAnchor();
|
||||
leaveVisualMode();
|
||||
int beginLine = lineForPosition(m_marks['<']);
|
||||
int endLine = lineForPosition(m_marks['>']);
|
||||
@@ -809,10 +877,11 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
||||
moveRight(rightDist());
|
||||
finishMovement();
|
||||
} else if (key == 'e') {
|
||||
m_moveType = MoveInclusive;
|
||||
moveToWordBoundary(false, true);
|
||||
m_moveType = MoveExclusive;
|
||||
finishMovement();
|
||||
} else if (key == 'E') {
|
||||
m_moveType = MoveInclusive;
|
||||
moveToWordBoundary(true, true);
|
||||
finishMovement();
|
||||
} else if (key == 'f' || key == 'F') {
|
||||
@@ -1009,13 +1078,22 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
||||
recordRemoveSelectedText();
|
||||
}
|
||||
finishMovement();
|
||||
} else if (key == 'y') {
|
||||
} else if (key == 'y' && m_visualMode == NoVisualMode) {
|
||||
m_savedYankPosition = m_tc.position();
|
||||
if (atEndOfLine())
|
||||
moveLeft();
|
||||
recordBeginGroup();
|
||||
setAnchor();
|
||||
m_submode = YankSubMode;
|
||||
} else if (key == 'y' && m_visualMode == VisualLineMode) {
|
||||
int beginLine = lineForPosition(m_marks['<']);
|
||||
int endLine = lineForPosition(m_marks['>']);
|
||||
selectRange(beginLine, endLine);
|
||||
m_registers[m_register] = selectedText();
|
||||
m_tc.setPosition(qMin(position(), anchor()));
|
||||
moveToStartOfLine();
|
||||
leaveVisualMode();
|
||||
updateSelection();
|
||||
} else if (key == 'Y') {
|
||||
moveToStartOfLine();
|
||||
setAnchor();
|
||||
@@ -1036,6 +1114,20 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
||||
}
|
||||
recordInsertText(str);
|
||||
recordEndGroup();
|
||||
} else if (key == control('d')) {
|
||||
int sline = cursorLineOnScreen();
|
||||
// FIXME: this should use the "scroll" option, and "count"
|
||||
moveDown(linesOnScreen() / 2);
|
||||
moveToFirstNonBlankOnLine();
|
||||
scrollToLineInDocument(cursorLineInDocument() - sline);
|
||||
finishMovement();
|
||||
} else if (key == control('u')) {
|
||||
int sline = cursorLineOnScreen();
|
||||
// FIXME: this should use the "scroll" option, and "count"
|
||||
moveUp(linesOnScreen() / 2);
|
||||
moveToFirstNonBlankOnLine();
|
||||
scrollToLineInDocument(cursorLineInDocument() - sline);
|
||||
finishMovement();
|
||||
} else if (key == Key_PageDown || key == control('f')) {
|
||||
moveDown(count() * (linesOnScreen() - 2));
|
||||
finishMovement();
|
||||
@@ -1271,12 +1363,12 @@ int FakeVimHandler::Private::readLineCode(QString &cmd)
|
||||
|
||||
void FakeVimHandler::Private::selectRange(int beginLine, int endLine)
|
||||
{
|
||||
m_tc.setPosition(positionForLine(beginLine), MoveAnchor);
|
||||
m_anchor = positionForLine(beginLine);
|
||||
if (endLine == linesInDocument()) {
|
||||
m_tc.setPosition(positionForLine(endLine), KeepAnchor);
|
||||
m_tc.movePosition(EndOfLine, KeepAnchor);
|
||||
m_tc.setPosition(positionForLine(endLine), MoveAnchor);
|
||||
m_tc.movePosition(EndOfLine, MoveAnchor);
|
||||
} else {
|
||||
m_tc.setPosition(positionForLine(endLine + 1), KeepAnchor);
|
||||
m_tc.setPosition(positionForLine(endLine + 1), MoveAnchor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1329,21 +1421,40 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
|
||||
beginLine = 0;
|
||||
if (endLine == -1)
|
||||
endLine = linesInDocument();
|
||||
//qDebug() << "LINES: " << beginLine << endLine;
|
||||
qDebug() << "LINES: " << beginLine << endLine;
|
||||
bool forced = cmd.startsWith("w!");
|
||||
QString fileName = reWrite.cap(2);
|
||||
if (fileName.isEmpty())
|
||||
fileName = m_currentFileName;
|
||||
QFile file(fileName);
|
||||
bool exists = file.exists();
|
||||
QFile file1(fileName);
|
||||
bool exists = file1.exists();
|
||||
if (exists && !forced && !noArgs) {
|
||||
showRedMessage(tr("File '%1' exists (add ! to override)").arg(fileName));
|
||||
} else if (file.open(QIODevice::ReadWrite)) {
|
||||
} else if (file1.open(QIODevice::ReadWrite)) {
|
||||
file1.close();
|
||||
QTextCursor tc = m_tc;
|
||||
selectRange(beginLine, endLine);
|
||||
emit q->writeFile(fileName, selectedText());
|
||||
// check by reading back
|
||||
file.open(QIODevice::ReadOnly);
|
||||
QByteArray ba = file.readAll();
|
||||
QString contents = selectedText();
|
||||
m_tc = tc;
|
||||
qDebug() << "LINES: " << beginLine << endLine;
|
||||
bool handled = false;
|
||||
emit q->writeFileRequested(&handled, fileName, contents);
|
||||
// nobody cared, so act ourselves
|
||||
if (!handled) {
|
||||
//qDebug() << "HANDLING MANUAL SAVE TO " << fileName;
|
||||
QFile::remove(fileName);
|
||||
QFile file2(fileName);
|
||||
if (file2.open(QIODevice::ReadWrite)) {
|
||||
QTextStream ts(&file2);
|
||||
ts << contents;
|
||||
} else {
|
||||
showRedMessage(tr("Cannot open file '%1' for writing").arg(fileName));
|
||||
}
|
||||
}
|
||||
// check result by reading back
|
||||
QFile file3(fileName);
|
||||
file3.open(QIODevice::ReadOnly);
|
||||
QByteArray ba = file3.readAll();
|
||||
showBlackMessage(tr("\"%1\" %2 %3L, %4C written")
|
||||
.arg(fileName).arg(exists ? " " : " [New] ")
|
||||
.arg(ba.count('\n')).arg(ba.size()));
|
||||
@@ -1401,7 +1512,7 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
|
||||
QString info;
|
||||
foreach (const QString &key, m_config.keys())
|
||||
info += key + ": " + m_config.value(key) + "\n";
|
||||
emit q->extraInformationChanged(editor(), info);
|
||||
emit q->extraInformationChanged(info);
|
||||
} else {
|
||||
notImplementedYet();
|
||||
}
|
||||
@@ -1417,7 +1528,7 @@ void FakeVimHandler::Private::handleExCommand(const QString &cmd0)
|
||||
++i;
|
||||
info += QString("%1 %2\n").arg(i, -8).arg(item);
|
||||
}
|
||||
emit q->extraInformationChanged(editor(), info);
|
||||
emit q->extraInformationChanged(info);
|
||||
} else {
|
||||
notImplementedYet();
|
||||
}
|
||||
@@ -1566,8 +1677,7 @@ void FakeVimHandler::Private::moveToWordBoundary(bool simple, bool forward)
|
||||
int n = forward ? lastPositionInDocument() - 1 : 0;
|
||||
int lastClass = -1;
|
||||
while (true) {
|
||||
forward ? moveRight() : moveLeft();
|
||||
QChar c = doc->characterAt(m_tc.position());
|
||||
QChar c = doc->characterAt(m_tc.position() + (forward ? 1 : -1));
|
||||
int thisClass = charClass(c, simple);
|
||||
if (thisClass != lastClass && lastClass != 0)
|
||||
--repeat;
|
||||
@@ -1576,6 +1686,7 @@ void FakeVimHandler::Private::moveToWordBoundary(bool simple, bool forward)
|
||||
lastClass = thisClass;
|
||||
if (m_tc.position() == n)
|
||||
break;
|
||||
forward ? moveRight() : moveLeft();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1752,6 +1863,7 @@ int FakeVimHandler::Private::lineForPosition(int pos) const
|
||||
|
||||
void FakeVimHandler::Private::enterVisualMode(VisualMode visualMode)
|
||||
{
|
||||
setAnchor();
|
||||
m_visualMode = visualMode;
|
||||
m_marks['<'] = m_tc.position();
|
||||
m_marks['>'] = m_tc.position();
|
||||
@@ -1927,6 +2039,7 @@ void FakeVimHandler::Private::recordRemove(int position, const QString &data)
|
||||
|
||||
void FakeVimHandler::Private::enterInsertMode()
|
||||
{
|
||||
EDITOR(setCursorWidth(m_cursorWidth));
|
||||
EDITOR(setOverwriteMode(false));
|
||||
m_mode = InsertMode;
|
||||
m_lastInsertion.clear();
|
||||
@@ -1935,32 +2048,34 @@ void FakeVimHandler::Private::enterInsertMode()
|
||||
|
||||
void FakeVimHandler::Private::enterCommandMode()
|
||||
{
|
||||
if (editor())
|
||||
EDITOR(setCursorWidth(m_cursorWidth));
|
||||
EDITOR(setOverwriteMode(true));
|
||||
m_mode = CommandMode;
|
||||
}
|
||||
|
||||
void FakeVimHandler::Private::quit()
|
||||
void FakeVimHandler::Private::enterExMode()
|
||||
{
|
||||
showBlackMessage(QString());
|
||||
EDITOR(setCursorWidth(0));
|
||||
EDITOR(setOverwriteMode(false));
|
||||
q->quitRequested(editor());
|
||||
m_mode = ExMode;
|
||||
}
|
||||
|
||||
void FakeVimHandler::Private::setWidget(QWidget *ob)
|
||||
void FakeVimHandler::Private::quit()
|
||||
{
|
||||
m_textedit = qobject_cast<QTextEdit *>(ob);
|
||||
m_plaintextedit = qobject_cast<QPlainTextEdit *>(ob);
|
||||
EDITOR(setCursorWidth(m_cursorWidth));
|
||||
EDITOR(setOverwriteMode(false));
|
||||
q->quitRequested();
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// FakeVimHandler
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
FakeVimHandler::FakeVimHandler(QObject *parent)
|
||||
: QObject(parent), d(new Private(this))
|
||||
FakeVimHandler::FakeVimHandler(QWidget *widget, QObject *parent)
|
||||
: QObject(parent), d(new Private(this, widget))
|
||||
{}
|
||||
|
||||
FakeVimHandler::~FakeVimHandler()
|
||||
@@ -1993,40 +2108,18 @@ bool FakeVimHandler::eventFilter(QObject *ob, QEvent *ev)
|
||||
return QObject::eventFilter(ob, ev);
|
||||
}
|
||||
|
||||
void FakeVimHandler::addWidget(QWidget *widget)
|
||||
void FakeVimHandler::setupWidget()
|
||||
{
|
||||
widget->installEventFilter(this);
|
||||
d->setWidget(widget);
|
||||
d->enterCommandMode();
|
||||
if (QTextEdit *ed = qobject_cast<QTextEdit *>(widget)) {
|
||||
//ed->setCursorWidth(QFontMetrics(ed->font()).width(QChar('x')));
|
||||
ed->setLineWrapMode(QTextEdit::NoWrap);
|
||||
d->m_wasReadOnly = ed->isReadOnly();
|
||||
} else if (QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(widget)) {
|
||||
//ed->setCursorWidth(QFontMetrics(ed->font()).width(QChar('x')));
|
||||
ed->setLineWrapMode(QPlainTextEdit::NoWrap);
|
||||
d->m_wasReadOnly = ed->isReadOnly();
|
||||
}
|
||||
d->showBlackMessage("vi emulation mode.");
|
||||
d->updateMiniBuffer();
|
||||
d->setupWidget();
|
||||
}
|
||||
|
||||
void FakeVimHandler::removeWidget(QWidget *widget)
|
||||
void FakeVimHandler::restoreWidget()
|
||||
{
|
||||
d->setWidget(widget);
|
||||
d->showBlackMessage(QString());
|
||||
d->updateMiniBuffer();
|
||||
widget->removeEventFilter(this);
|
||||
if (QTextEdit *ed = qobject_cast<QTextEdit *>(widget)) {
|
||||
ed->setReadOnly(d->m_wasReadOnly);
|
||||
} else if (QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(widget)) {
|
||||
ed->setReadOnly(d->m_wasReadOnly);
|
||||
}
|
||||
d->restoreWidget();
|
||||
}
|
||||
|
||||
void FakeVimHandler::handleCommand(QWidget *widget, const QString &cmd)
|
||||
void FakeVimHandler::handleCommand(const QString &cmd)
|
||||
{
|
||||
d->setWidget(widget);
|
||||
d->handleExCommand(cmd);
|
||||
}
|
||||
|
||||
@@ -2044,3 +2137,19 @@ void FakeVimHandler::setCurrentFileName(const QString &fileName)
|
||||
{
|
||||
d->m_currentFileName = fileName;
|
||||
}
|
||||
|
||||
QWidget *FakeVimHandler::widget()
|
||||
{
|
||||
return d->editor();
|
||||
}
|
||||
|
||||
void FakeVimHandler::setExtraData(QObject *data)
|
||||
{
|
||||
d->m_extraData = data;
|
||||
}
|
||||
|
||||
QObject *FakeVimHandler::extraData() const
|
||||
{
|
||||
return d->m_extraData;
|
||||
}
|
||||
|
||||
|
@@ -50,30 +50,35 @@ class FakeVimHandler : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FakeVimHandler(QObject *parent = 0);
|
||||
FakeVimHandler(QWidget *widget, QObject *parent = 0);
|
||||
~FakeVimHandler();
|
||||
|
||||
QWidget *widget();
|
||||
|
||||
void setExtraData(QObject *data);
|
||||
QObject *extraData() const;
|
||||
|
||||
public slots:
|
||||
// The same handler can be installed on several widgets
|
||||
// FIXME: good idea?
|
||||
void addWidget(QWidget *widget);
|
||||
void removeWidget(QWidget *widget);
|
||||
void setCurrentFileName(const QString &fileName);
|
||||
|
||||
// This executes an "ex" style command taking context
|
||||
// information from \p widget;
|
||||
void handleCommand(QWidget *widget, const QString &cmd);
|
||||
void quit();
|
||||
// information from widget;
|
||||
void handleCommand(const QString &cmd);
|
||||
void setConfigValue(const QString &key, const QString &value);
|
||||
void quit();
|
||||
|
||||
// Convenience
|
||||
void setupWidget();
|
||||
void restoreWidget();
|
||||
|
||||
signals:
|
||||
void commandBufferChanged(const QString &msg);
|
||||
void statusDataChanged(const QString &msg);
|
||||
void extraInformationChanged(QWidget *widget, const QString &msg);
|
||||
void quitRequested(QWidget *widget);
|
||||
void selectionChanged(QWidget *widget,
|
||||
const QList<QTextEdit::ExtraSelection> &selection);
|
||||
void writeFile(const QString &fileName, const QString &contents);
|
||||
void extraInformationChanged(const QString &msg);
|
||||
void quitRequested();
|
||||
void selectionChanged(const QList<QTextEdit::ExtraSelection> &selection);
|
||||
void writeFileRequested(bool *handled,
|
||||
const QString &fileName, const QString &contents);
|
||||
|
||||
private:
|
||||
bool eventFilter(QObject *ob, QEvent *ev);
|
||||
|
@@ -53,6 +53,7 @@
|
||||
#include <texteditor/basetextmark.h>
|
||||
#include <texteditor/itexteditor.h>
|
||||
#include <texteditor/texteditorconstants.h>
|
||||
#include <texteditor/interactionsettings.h>
|
||||
#include <texteditor/tabsettings.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
|
||||
@@ -106,27 +107,26 @@ public:
|
||||
~FakeVimPluginPrivate();
|
||||
friend class FakeVimPlugin;
|
||||
|
||||
bool initialize(const QStringList &arguments, QString *error_message);
|
||||
bool initialize();
|
||||
void shutdown();
|
||||
|
||||
private slots:
|
||||
void installHandler();
|
||||
void installHandler(QWidget *widget);
|
||||
void removeHandler(QWidget *widget);
|
||||
void showCommandBuffer(const QString &contents);
|
||||
void showExtraInformation(QWidget *, const QString &msg);
|
||||
void editorOpened(Core::IEditor *);
|
||||
void editorAboutToClose(Core::IEditor *);
|
||||
void changeSelection(QWidget *widget,
|
||||
const QList<QTextEdit::ExtraSelection> &selections);
|
||||
void writeFile(const QString &fileName, const QString &contents);
|
||||
|
||||
void installHandlerOnCurrentEditor();
|
||||
void installHandler(Core::IEditor *editor);
|
||||
void removeHandler();
|
||||
|
||||
void showCommandBuffer(const QString &contents);
|
||||
void showExtraInformation(const QString &msg);
|
||||
void changeSelection(const QList<QTextEdit::ExtraSelection> &selections);
|
||||
void writeFile(bool *handled, const QString &fileName, const QString &contents);
|
||||
|
||||
private:
|
||||
FakeVimPlugin *q;
|
||||
FakeVimHandler *m_handler;
|
||||
QAction *m_installHandlerAction;
|
||||
Core::ICore *m_core;
|
||||
Core::IFile *m_currentFile;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
@@ -135,10 +135,8 @@ private:
|
||||
FakeVimPluginPrivate::FakeVimPluginPrivate(FakeVimPlugin *plugin)
|
||||
{
|
||||
q = plugin;
|
||||
m_handler = 0;
|
||||
m_installHandlerAction = 0;
|
||||
m_core = 0;
|
||||
m_currentFile = 0;
|
||||
}
|
||||
|
||||
FakeVimPluginPrivate::~FakeVimPluginPrivate()
|
||||
@@ -147,17 +145,10 @@ FakeVimPluginPrivate::~FakeVimPluginPrivate()
|
||||
|
||||
void FakeVimPluginPrivate::shutdown()
|
||||
{
|
||||
delete m_handler;
|
||||
m_handler = 0;
|
||||
}
|
||||
|
||||
bool FakeVimPluginPrivate::initialize(const QStringList &arguments, QString *error_message)
|
||||
bool FakeVimPluginPrivate::initialize()
|
||||
{
|
||||
Q_UNUSED(arguments);
|
||||
Q_UNUSED(error_message);
|
||||
|
||||
m_handler = new FakeVimHandler;
|
||||
|
||||
m_core = Core::ICore::instance();
|
||||
QTC_ASSERT(m_core, return false);
|
||||
|
||||
@@ -180,7 +171,7 @@ bool FakeVimPluginPrivate::initialize(const QStringList &arguments, QString *err
|
||||
advancedMenu->addAction(cmd, Core::Constants::G_EDIT_EDITOR);
|
||||
|
||||
connect(m_installHandlerAction, SIGNAL(triggered()),
|
||||
this, SLOT(installHandler()));
|
||||
this, SLOT(installHandlerOnCurrentEditor()));
|
||||
|
||||
// EditorManager
|
||||
QObject *editorManager = m_core->editorManager();
|
||||
@@ -192,104 +183,133 @@ bool FakeVimPluginPrivate::initialize(const QStringList &arguments, QString *err
|
||||
return true;
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::installHandler()
|
||||
void FakeVimPluginPrivate::installHandler(Core::IEditor *editor)
|
||||
{
|
||||
if (Core::IEditor *editor = m_core->editorManager()->currentEditor())
|
||||
installHandler(editor->widget());
|
||||
}
|
||||
QWidget *widget = editor->widget();
|
||||
|
||||
void FakeVimPluginPrivate::installHandler(QWidget *widget)
|
||||
{
|
||||
connect(m_handler, SIGNAL(extraInformationChanged(QWidget *, QString)),
|
||||
this, SLOT(showExtraInformation(QWidget *, QString)));
|
||||
connect(m_handler, SIGNAL(commandBufferChanged(QString)),
|
||||
FakeVimHandler *handler = new FakeVimHandler(widget, this);
|
||||
|
||||
connect(handler, SIGNAL(extraInformationChanged(QString)),
|
||||
this, SLOT(showExtraInformation(QString)));
|
||||
connect(handler, SIGNAL(commandBufferChanged(QString)),
|
||||
this, SLOT(showCommandBuffer(QString)));
|
||||
connect(m_handler, SIGNAL(quitRequested(QWidget *)),
|
||||
this, SLOT(removeHandler(QWidget *)));
|
||||
connect(m_handler,
|
||||
SIGNAL(selectionChanged(QWidget*,QList<QTextEdit::ExtraSelection>)),
|
||||
this, SLOT(changeSelection(QWidget*,QList<QTextEdit::ExtraSelection>)));
|
||||
connect(handler, SIGNAL(quitRequested()),
|
||||
this, SLOT(removeHandler()), Qt::QueuedConnection);
|
||||
connect(handler, SIGNAL(writeFileRequested(bool*,QString,QString)),
|
||||
this, SLOT(writeFile(bool*,QString,QString)));
|
||||
connect(handler, SIGNAL(selectionChanged(QList<QTextEdit::ExtraSelection>)),
|
||||
this, SLOT(changeSelection(QList<QTextEdit::ExtraSelection>)));
|
||||
|
||||
m_handler->addWidget(widget);
|
||||
TextEditor::BaseTextEditor* editor =
|
||||
qobject_cast<TextEditor::BaseTextEditor*>(widget);
|
||||
if (editor) {
|
||||
m_currentFile = editor->file();
|
||||
m_handler->setCurrentFileName(editor->file()->fileName());
|
||||
}
|
||||
handler->setupWidget();
|
||||
handler->setExtraData(editor);
|
||||
|
||||
BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(widget);
|
||||
if (bt) {
|
||||
if (BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(widget)) {
|
||||
using namespace TextEditor;
|
||||
using namespace FakeVim::Constants;
|
||||
handler->setCurrentFileName(editor->file()->fileName());
|
||||
TabSettings settings = bt->tabSettings();
|
||||
m_handler->setConfigValue(ConfigTabStop,
|
||||
handler->setConfigValue(ConfigTabStop,
|
||||
QString::number(settings.m_tabSize));
|
||||
m_handler->setConfigValue(ConfigShiftWidth,
|
||||
handler->setConfigValue(ConfigShiftWidth,
|
||||
QString::number(settings.m_indentSize));
|
||||
m_handler->setConfigValue(ConfigExpandTab,
|
||||
handler->setConfigValue(ConfigExpandTab,
|
||||
settings.m_spacesForTabs ? ConfigOn : ConfigOff);
|
||||
m_handler->setConfigValue(ConfigSmartTab,
|
||||
handler->setConfigValue(ConfigSmartTab,
|
||||
settings.m_smartBackspace ? ConfigOn : ConfigOff);
|
||||
m_handler->setConfigValue(ConfigAutoIndent,
|
||||
handler->setConfigValue(ConfigAutoIndent,
|
||||
settings.m_autoIndent ? ConfigOn : ConfigOff);
|
||||
}
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::writeFile(const QString &fileName,
|
||||
const QString &contents)
|
||||
void FakeVimPluginPrivate::installHandlerOnCurrentEditor()
|
||||
{
|
||||
if (m_currentFile && fileName == m_currentFile->fileName()) {
|
||||
installHandler(EditorManager::instance()->currentEditor());
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::writeFile(bool *handled,
|
||||
const QString &fileName, const QString &contents)
|
||||
{
|
||||
Q_UNUSED(contents);
|
||||
|
||||
FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender());
|
||||
if (!handler)
|
||||
return;
|
||||
|
||||
Core::IEditor *editor = qobject_cast<Core::IEditor *>(handler->extraData());
|
||||
if (editor && editor->file()->fileName() == fileName) {
|
||||
// Handle that as a special case for nicer interaction with core
|
||||
m_core->fileManager()->blockFileChange(m_currentFile);
|
||||
m_currentFile->save(fileName);
|
||||
m_core->fileManager()->unblockFileChange(m_currentFile);
|
||||
} else {
|
||||
QFile file(fileName);
|
||||
file.open(QIODevice::ReadWrite);
|
||||
{ QTextStream ts(&file); ts << contents; }
|
||||
file.close();
|
||||
Core::IFile *file = editor->file();
|
||||
m_core->fileManager()->blockFileChange(file);
|
||||
file->save(fileName);
|
||||
m_core->fileManager()->unblockFileChange(file);
|
||||
*handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::removeHandler(QWidget *widget)
|
||||
void FakeVimPluginPrivate::removeHandler()
|
||||
{
|
||||
Q_UNUSED(widget);
|
||||
m_handler->removeWidget(widget);
|
||||
if (FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender())) {
|
||||
handler->restoreWidget();
|
||||
handler->deleteLater();
|
||||
}
|
||||
Core::EditorManager::instance()->hideEditorInfoBar(
|
||||
QLatin1String(Constants::MINI_BUFFER));
|
||||
m_currentFile = 0;
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::editorOpened(Core::IEditor *editor)
|
||||
{
|
||||
Q_UNUSED(editor);
|
||||
//qDebug() << "OPENING: " << editor << editor->widget();
|
||||
//installHandler(editor->widget());
|
||||
//installHandler(editor);
|
||||
|
||||
#if 1
|
||||
QSettings *s = ICore::instance()->settings();
|
||||
bool automatic = s->value("textInteractionSettings/UseVim").toBool();
|
||||
//qDebug() << "USE VIM: " << automatic;
|
||||
if (automatic)
|
||||
installHandler(editor);
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
QWidget *widget = editor->widget();
|
||||
if (BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(widget)) {
|
||||
InteractionSettings settings = bt->interactionSettings();
|
||||
qDebug() << "USE VIM: " << settings.m_useVim;
|
||||
if (settings.m_useVim)
|
||||
installHandler(editor);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::editorAboutToClose(Core::IEditor *editor)
|
||||
{
|
||||
//qDebug() << "CLOSING: " << editor << editor->widget();
|
||||
removeHandler(editor->widget());
|
||||
Q_UNUSED(editor);
|
||||
//qDebug() << "CLOSING: " << editor;
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::showCommandBuffer(const QString &contents)
|
||||
{
|
||||
//qDebug() << "SHOW COMMAND BUFFER" << contents;
|
||||
FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender());
|
||||
if (handler) {
|
||||
Core::EditorManager::instance()->showEditorInfoBar(
|
||||
QLatin1String(Constants::MINI_BUFFER), contents,
|
||||
tr("Quit FakeVim"), m_handler, SLOT(quit()));
|
||||
tr("Quit FakeVim"), handler, SLOT(quit()));
|
||||
}
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::showExtraInformation(QWidget *widget, const QString &text)
|
||||
void FakeVimPluginPrivate::showExtraInformation(const QString &text)
|
||||
{
|
||||
QMessageBox::information(widget, tr("FakeVim Information"), text);
|
||||
FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender());
|
||||
if (handler)
|
||||
QMessageBox::information(handler->widget(), tr("FakeVim Information"), text);
|
||||
}
|
||||
|
||||
void FakeVimPluginPrivate::changeSelection(QWidget *widget,
|
||||
const QList<QTextEdit::ExtraSelection> &selection)
|
||||
void FakeVimPluginPrivate::changeSelection
|
||||
(const QList<QTextEdit::ExtraSelection> &selection)
|
||||
{
|
||||
if (BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(widget))
|
||||
if (FakeVimHandler *handler = qobject_cast<FakeVimHandler *>(sender()))
|
||||
if (BaseTextEditor *bt = qobject_cast<BaseTextEditor *>(handler->widget()))
|
||||
bt->setExtraSelections(BaseTextEditor::FakeVimSelection, selection);
|
||||
}
|
||||
|
||||
@@ -309,9 +329,11 @@ FakeVimPlugin::~FakeVimPlugin()
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool FakeVimPlugin::initialize(const QStringList &arguments, QString *error_message)
|
||||
bool FakeVimPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
{
|
||||
return d->initialize(arguments, error_message);
|
||||
Q_UNUSED(arguments);
|
||||
Q_UNUSED(errorMessage);
|
||||
return d->initialize();
|
||||
}
|
||||
|
||||
void FakeVimPlugin::shutdown()
|
||||
|
@@ -30,7 +30,7 @@ SOURCES += helpplugin.cpp \
|
||||
FORMS += docsettingspage.ui \
|
||||
filtersettingspage.ui
|
||||
RESOURCES += help.qrc
|
||||
include(../../../shared/help/help.pri)
|
||||
include(../../shared/help/help.pri)
|
||||
|
||||
contains(QT_CONFIG, webkit) {
|
||||
QT += webkit
|
||||
|
@@ -183,15 +183,14 @@ void Environment::clear()
|
||||
m_values.clear();
|
||||
}
|
||||
|
||||
// currently it returns the string that was passed in, except
|
||||
// under windows and if the executable does not end in .exe
|
||||
// then it returns executable appended with .exe
|
||||
// that is clearly wrong
|
||||
QString Environment::searchInPath(QString executable)
|
||||
{
|
||||
// qDebug()<<"looking for "<<executable<< "in PATH: "<<m_values.value("PATH");
|
||||
if (executable.isEmpty())
|
||||
return QString::null;
|
||||
QFileInfo fi(executable);
|
||||
if (fi.isAbsolute() && fi.exists())
|
||||
return executable;
|
||||
#ifdef Q_OS_WIN
|
||||
if (!executable.endsWith(QLatin1String(".exe")))
|
||||
executable.append(QLatin1String(".exe"));
|
||||
|
Before Width: | Height: | Size: 194 B After Width: | Height: | Size: 494 B |
@@ -4,7 +4,7 @@ QT += xml \
|
||||
script
|
||||
include(../../qworkbenchplugin.pri)
|
||||
include(projectexplorer_dependencies.pri)
|
||||
include(../../../shared/scriptwrapper/scriptwrapper.pri)
|
||||
include(../../shared/scriptwrapper/scriptwrapper.pri)
|
||||
HEADERS += projectexplorer.h \
|
||||
projectexplorer_export.h \
|
||||
projectwindow.h \
|
||||
|
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>521</width>
|
||||
<width>551</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -35,7 +35,7 @@
|
||||
<item>
|
||||
<widget class="QComboBox" name="runConfigurationCombo">
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToMinimumContentsLength</enum>
|
||||
<enum>QComboBox::AdjustToContents</enum>
|
||||
</property>
|
||||
<property name="minimumContentsLength">
|
||||
<number>30</number>
|
||||
|
@@ -65,13 +65,13 @@ void GdbMacrosBuildStep::run(QFutureInterface<bool> & fi)
|
||||
{
|
||||
QVariant v = value("clean");
|
||||
if (v.isNull() || v.toBool() == false) {
|
||||
addToOutputWindow("<b>Creating gdb macros library...</b>");
|
||||
// Normal run
|
||||
QString dumperPath = Core::ICore::instance()->resourcePath() + "/gdbmacros/";
|
||||
QStringList files;
|
||||
files << "gdbmacros.cpp"
|
||||
<< "gdbmacros.pro";
|
||||
|
||||
|
||||
QString destDir = m_buildDirectory + "/qtc-gdbmacros/";
|
||||
QDir dir;
|
||||
dir.mkpath(destDir);
|
||||
@@ -124,7 +124,6 @@ void GdbMacrosBuildStep::run(QFutureInterface<bool> & fi)
|
||||
qmake.start(m_qmake, QStringList()<<"-spec"<<mkspec<<configarguments<<"gdbmacros.pro");
|
||||
qmake.waitForFinished();
|
||||
|
||||
|
||||
qmake.start(qt4Project->qtVersion(m_buildConfiguration)->makeCommand(), makeArguments);
|
||||
qmake.waitForFinished();
|
||||
|
||||
|
@@ -93,5 +93,5 @@ FORMS = qtversionmanager.ui \
|
||||
qt4buildenvironmentwidget.ui
|
||||
RESOURCES = qt4projectmanager.qrc \
|
||||
wizards/wizards.qrc
|
||||
include(../../../shared/proparser/proparser.pri)
|
||||
include(../../shared/proparser/proparser.pri)
|
||||
DEFINES += QT_NO_CAST_TO_ASCII
|
||||
|
@@ -3,10 +3,10 @@ TARGET = QtScriptEditor
|
||||
QT += script
|
||||
|
||||
include(../../qworkbenchplugin.pri)
|
||||
include(../../plugins/texteditor/texteditor.pri)
|
||||
include(../../../shared/qscripthighlighter/qscripthighlighter.pri)
|
||||
include(../../../shared/indenter/indenter.pri)
|
||||
include(../../plugins/coreplugin/coreplugin.pri)
|
||||
include(../../plugins/texteditor/texteditor.pri)
|
||||
include(../../shared/qscripthighlighter/qscripthighlighter.pri)
|
||||
include(../../shared/indenter/indenter.pri)
|
||||
|
||||
HEADERS += qtscripteditor.h \
|
||||
qtscripteditorfactory.h \
|
||||
|
@@ -57,6 +57,7 @@
|
||||
using namespace QuickOpen;
|
||||
using namespace QuickOpen::Internal;
|
||||
|
||||
|
||||
namespace {
|
||||
static bool filterLessThan(const IQuickOpenFilter *first, const IQuickOpenFilter *second)
|
||||
{
|
||||
@@ -89,10 +90,12 @@ bool QuickOpenPlugin::initialize(const QStringList &, QString *)
|
||||
|
||||
m_quickOpenToolWindow = new QuickOpenToolWindow(this);
|
||||
m_quickOpenToolWindow->setEnabled(false);
|
||||
Core::BaseView *view = new Core::BaseView("QuickOpen.ToolWindow",
|
||||
m_quickOpenToolWindow,
|
||||
QList<int>() << core->uniqueIDManager()->uniqueIdentifier(QLatin1String("QuickOpenToolWindow")),
|
||||
Core::IView::First);
|
||||
Core::BaseView *view = new Core::BaseView;
|
||||
view->setUniqueViewName("QuickOpen.ToolWindow");
|
||||
view->setWidget(m_quickOpenToolWindow);
|
||||
view->setContext(QList<int>() << core->uniqueIDManager()
|
||||
->uniqueIdentifier(QLatin1String("QuickOpenToolWindow")));
|
||||
view->setDefaultPosition(Core::IView::First);
|
||||
addAutoReleasedObject(view);
|
||||
|
||||
const QString actionId = QLatin1String("QtCreator.View.QuickOpen.ToolWindow");
|
||||
|
@@ -6,7 +6,7 @@ qtAddLibrary(QtDesigner)
|
||||
include(../../qworkbenchplugin.pri)
|
||||
include(../../libs/utils/utils.pri)
|
||||
include(../../plugins/coreplugin/coreplugin.pri)
|
||||
include(../../../shared/qrceditor/qrceditor.pri)
|
||||
include(../../shared/qrceditor/qrceditor.pri)
|
||||
|
||||
INCLUDEPATH += $$PWD/../../tools/utils
|
||||
|
||||
|
@@ -330,7 +330,7 @@ void BaseTextDocument::cleanWhitespace(QTextCursor& cursor, bool inEntireDocumen
|
||||
cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor, trailing);
|
||||
cursor.removeSelectedText();
|
||||
}
|
||||
if (!m_tabSettings.isIndentationClean(blockText)) {
|
||||
if (m_storageSettings.m_cleanIndentation && !m_tabSettings.isIndentationClean(blockText)) {
|
||||
cursor.setPosition(block.position());
|
||||
int firstNonSpace = m_tabSettings.firstNonSpace(blockText);
|
||||
if (firstNonSpace == blockText.length()) {
|
||||
|
@@ -2709,6 +2709,10 @@ const DisplaySettings &BaseTextEditor::displaySettings() const
|
||||
return d->m_displaySettings;
|
||||
}
|
||||
|
||||
const InteractionSettings &BaseTextEditor::interactionSettings() const
|
||||
{
|
||||
return d->m_interactionSettings;
|
||||
}
|
||||
|
||||
|
||||
void BaseTextEditor::indentOrUnindent(bool doIndent)
|
||||
|
@@ -37,6 +37,7 @@
|
||||
|
||||
#include "displaysettings.h"
|
||||
#include "tabsettings.h"
|
||||
#include "interactionsettings.h"
|
||||
#include "itexteditable.h"
|
||||
|
||||
#include <QtGui/QPlainTextEdit>
|
||||
@@ -88,7 +89,8 @@ struct TEXTEDITOR_EXPORT Parenthesis
|
||||
|
||||
|
||||
|
||||
class TEXTEDITOR_EXPORT TextBlockUserData : public QTextBlockUserData {
|
||||
class TEXTEDITOR_EXPORT TextBlockUserData : public QTextBlockUserData
|
||||
{
|
||||
public:
|
||||
|
||||
enum CollapseMode { NoCollapse , CollapseThis, CollapseAfter };
|
||||
@@ -382,9 +384,9 @@ public:
|
||||
virtual void extraAreaMouseEvent(QMouseEvent *);
|
||||
virtual void extraAreaLeaveEvent(QEvent *);
|
||||
|
||||
|
||||
const TabSettings &tabSettings() const;
|
||||
const DisplaySettings &displaySettings() const;
|
||||
const InteractionSettings &interactionSettings() const;
|
||||
|
||||
void markBlocksAsChanged(QList<int> blockNumbers);
|
||||
|
||||
@@ -402,17 +404,19 @@ public:
|
||||
void setExtraSelections(ExtraSelectionKind kind, const QList<QTextEdit::ExtraSelection> &selections);
|
||||
QList<QTextEdit::ExtraSelection> extraSelections(ExtraSelectionKind kind) const;
|
||||
|
||||
struct BlockRange {
|
||||
BlockRange():first(0), last(-1){}
|
||||
BlockRange(int first_position, int last_position):first(first_position), last(last_position){}
|
||||
struct BlockRange
|
||||
{
|
||||
BlockRange() : first(0), last(-1) {}
|
||||
BlockRange(int first_position, int last_position)
|
||||
: first(first_position), last(last_position)
|
||||
{}
|
||||
int first;
|
||||
int last;
|
||||
inline bool isNull() const { return last < first; }
|
||||
};
|
||||
|
||||
// the blocks list must be sorted
|
||||
void setIfdefedOutBlocks(const QList<BaseTextEditor::BlockRange> &blocks);
|
||||
|
||||
void setIfdefedOutBlocks(const QList<BlockRange> &blocks);
|
||||
|
||||
public slots:
|
||||
virtual void setTabSettings(const TextEditor::TabSettings &);
|
||||
@@ -442,8 +446,6 @@ protected slots:
|
||||
virtual void slotCursorPositionChanged();
|
||||
virtual void slotUpdateBlockNotify(const QTextBlock &);
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
void requestBlockUpdate(const QTextBlock &);
|
||||
void requestAutoCompletion(ITextEditable *editor, bool forced);
|
||||
|
@@ -165,6 +165,7 @@ public:
|
||||
|
||||
QWidget *m_extraArea;
|
||||
DisplaySettings m_displaySettings;
|
||||
InteractionSettings m_interactionSettings;
|
||||
|
||||
int extraAreaSelectionAnchorBlockNumber;
|
||||
int extraAreaToggleMarkBlockNumber;
|
||||
|
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "displaysettings.h"
|
||||
#include "generalsettingspage.h"
|
||||
#include "interactionsettings.h"
|
||||
#include "storagesettings.h"
|
||||
#include "tabsettings.h"
|
||||
#include "ui_generalsettingspage.h"
|
||||
@@ -53,6 +54,7 @@ struct GeneralSettingsPage::GeneralSettingsPagePrivate
|
||||
TabSettings m_tabSettings;
|
||||
StorageSettings m_storageSettings;
|
||||
DisplaySettings m_displaySettings;
|
||||
InteractionSettings m_interactionSettings;
|
||||
};
|
||||
|
||||
GeneralSettingsPage::GeneralSettingsPagePrivate::GeneralSettingsPagePrivate
|
||||
@@ -63,6 +65,7 @@ GeneralSettingsPage::GeneralSettingsPagePrivate::GeneralSettingsPagePrivate
|
||||
m_tabSettings.fromSettings(m_parameters.settingsPrefix, s);
|
||||
m_storageSettings.fromSettings(m_parameters.settingsPrefix, s);
|
||||
m_displaySettings.fromSettings(m_parameters.settingsPrefix, s);
|
||||
m_interactionSettings.fromSettings(m_parameters.settingsPrefix, s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,13 +109,17 @@ void GeneralSettingsPage::apply()
|
||||
TabSettings newTabSettings;
|
||||
StorageSettings newStorageSettings;
|
||||
DisplaySettings newDisplaySettings;
|
||||
InteractionSettings newInteractionSettings;
|
||||
|
||||
settingsFromUI(newTabSettings, newStorageSettings, newDisplaySettings,
|
||||
newInteractionSettings);
|
||||
|
||||
settingsFromUI(newTabSettings, newStorageSettings, newDisplaySettings);
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
QSettings *s = core->settings();
|
||||
|
||||
if (newTabSettings != m_d->m_tabSettings) {
|
||||
m_d->m_tabSettings = newTabSettings;
|
||||
if (QSettings *s = core->settings())
|
||||
if (s)
|
||||
m_d->m_tabSettings.toSettings(m_d->m_parameters.settingsPrefix, s);
|
||||
|
||||
emit tabSettingsChanged(newTabSettings);
|
||||
@@ -120,7 +127,7 @@ void GeneralSettingsPage::apply()
|
||||
|
||||
if (newStorageSettings != m_d->m_storageSettings) {
|
||||
m_d->m_storageSettings = newStorageSettings;
|
||||
if (QSettings *s = core->settings())
|
||||
if (s)
|
||||
m_d->m_storageSettings.toSettings(m_d->m_parameters.settingsPrefix, s);
|
||||
|
||||
emit storageSettingsChanged(newStorageSettings);
|
||||
@@ -128,16 +135,24 @@ void GeneralSettingsPage::apply()
|
||||
|
||||
if (newDisplaySettings != m_d->m_displaySettings) {
|
||||
m_d->m_displaySettings = newDisplaySettings;
|
||||
if (QSettings *s = core->settings())
|
||||
if (s)
|
||||
m_d->m_displaySettings.toSettings(m_d->m_parameters.settingsPrefix, s);
|
||||
|
||||
emit displaySettingsChanged(newDisplaySettings);
|
||||
}
|
||||
|
||||
if (newInteractionSettings != m_d->m_interactionSettings) {
|
||||
m_d->m_interactionSettings = newInteractionSettings;
|
||||
if (s)
|
||||
m_d->m_interactionSettings.toSettings(m_d->m_parameters.settingsPrefix, s);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::settingsFromUI(TabSettings &rc,
|
||||
StorageSettings &storageSettings,
|
||||
DisplaySettings &displaySettings) const
|
||||
DisplaySettings &displaySettings,
|
||||
InteractionSettings &interactionSettings) const
|
||||
{
|
||||
rc.m_spacesForTabs = m_d->m_page.insertSpaces->isChecked();
|
||||
rc.m_autoIndent = m_d->m_page.autoIndent->isChecked();
|
||||
@@ -147,6 +162,7 @@ void GeneralSettingsPage::settingsFromUI(TabSettings &rc,
|
||||
|
||||
storageSettings.m_cleanWhitespace = m_d->m_page.cleanWhitespace->isChecked();
|
||||
storageSettings.m_inEntireDocument = m_d->m_page.inEntireDocument->isChecked();
|
||||
storageSettings.m_cleanIndentation = m_d->m_page.cleanIndentation->isChecked();
|
||||
storageSettings.m_addFinalNewLine = m_d->m_page.addFinalNewLine->isChecked();
|
||||
|
||||
displaySettings.m_displayLineNumbers = m_d->m_page.displayLineNumbers->isChecked();
|
||||
@@ -156,6 +172,8 @@ void GeneralSettingsPage::settingsFromUI(TabSettings &rc,
|
||||
displaySettings.m_visualizeWhitespace = m_d->m_page.visualizeWhitespace->isChecked();
|
||||
displaySettings.m_displayFoldingMarkers = m_d->m_page.displayFoldingMarkers->isChecked();
|
||||
displaySettings.m_highlightCurrentLine = m_d->m_page.highlightCurrentLine->isChecked();
|
||||
|
||||
interactionSettings.m_useVim = m_d->m_page.useVim->isChecked();
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::settingsToUI()
|
||||
@@ -170,6 +188,7 @@ void GeneralSettingsPage::settingsToUI()
|
||||
StorageSettings storageSettings = m_d->m_storageSettings;
|
||||
m_d->m_page.cleanWhitespace->setChecked(storageSettings.m_cleanWhitespace);
|
||||
m_d->m_page.inEntireDocument->setChecked(storageSettings.m_inEntireDocument);
|
||||
m_d->m_page.cleanIndentation->setChecked(storageSettings.m_cleanIndentation);
|
||||
m_d->m_page.addFinalNewLine->setChecked(storageSettings.m_addFinalNewLine);
|
||||
|
||||
DisplaySettings displaySettings = m_d->m_displaySettings;
|
||||
@@ -180,6 +199,9 @@ void GeneralSettingsPage::settingsToUI()
|
||||
m_d->m_page.visualizeWhitespace->setChecked(displaySettings.m_visualizeWhitespace);
|
||||
m_d->m_page.displayFoldingMarkers->setChecked(displaySettings.m_displayFoldingMarkers);
|
||||
m_d->m_page.highlightCurrentLine->setChecked(displaySettings.m_highlightCurrentLine);
|
||||
|
||||
InteractionSettings interactionSettings = m_d->m_interactionSettings;
|
||||
m_d->m_page.useVim->setChecked(interactionSettings.m_useVim);
|
||||
}
|
||||
|
||||
TabSettings GeneralSettingsPage::tabSettings() const
|
||||
@@ -197,6 +219,11 @@ DisplaySettings GeneralSettingsPage::displaySettings() const
|
||||
return m_d->m_displaySettings;
|
||||
}
|
||||
|
||||
InteractionSettings GeneralSettingsPage::interactionSettings() const
|
||||
{
|
||||
return m_d->m_interactionSettings;
|
||||
}
|
||||
|
||||
void GeneralSettingsPage::setDisplaySettings(const DisplaySettings &newDisplaySettings)
|
||||
{
|
||||
if (newDisplaySettings != m_d->m_displaySettings) {
|
||||
|
@@ -45,6 +45,7 @@ namespace TextEditor {
|
||||
struct TabSettings;
|
||||
struct StorageSettings;
|
||||
struct DisplaySettings;
|
||||
struct InteractionSettings;
|
||||
|
||||
struct TEXTEDITOR_EXPORT GeneralSettingsPageParameters
|
||||
{
|
||||
@@ -74,6 +75,7 @@ public:
|
||||
TabSettings tabSettings() const;
|
||||
StorageSettings storageSettings() const;
|
||||
DisplaySettings displaySettings() const;
|
||||
InteractionSettings interactionSettings() const;
|
||||
|
||||
void setDisplaySettings(const DisplaySettings &);
|
||||
|
||||
@@ -85,7 +87,9 @@ signals:
|
||||
private:
|
||||
void settingsFromUI(TabSettings &rc,
|
||||
StorageSettings &storageSettings,
|
||||
DisplaySettings &displaySettings) const;
|
||||
DisplaySettings &displaySettings,
|
||||
InteractionSettings &interactionSettings
|
||||
) const;
|
||||
void settingsToUI();
|
||||
struct GeneralSettingsPagePrivate;
|
||||
GeneralSettingsPagePrivate *m_d;
|
||||
|
@@ -7,15 +7,15 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>514</width>
|
||||
<height>427</height>
|
||||
<height>475</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_3">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBoxTabAndIndentSettings">
|
||||
<property name="title">
|
||||
<string>Tab/Indent Settings</string>
|
||||
</property>
|
||||
@@ -171,8 +171,8 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_2">
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="groupBoxStorageSettings">
|
||||
<property name="title">
|
||||
<string>Storage Settings</string>
|
||||
</property>
|
||||
@@ -214,6 +214,36 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>30</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cleanIndentation">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clean indentation</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="addFinalNewLine">
|
||||
<property name="text">
|
||||
@@ -224,8 +254,8 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<item row="2" column="0">
|
||||
<widget class="QGroupBox" name="groupBoxDisplaySettings">
|
||||
<property name="title">
|
||||
<string>Display Settings</string>
|
||||
</property>
|
||||
@@ -289,15 +319,31 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer>
|
||||
<item row="3" column="0">
|
||||
<widget class="QGroupBox" name="groupBoxInteractionSettings">
|
||||
<property name="title">
|
||||
<string>Interaction Settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="useVim">
|
||||
<property name="text">
|
||||
<string>Use "vi" style editing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>351</width>
|
||||
<height>0</height>
|
||||
<width>20</width>
|
||||
<height>8</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
@@ -322,6 +368,12 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>cleanWhitespace</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
<receiver>cleanIndentation</receiver>
|
||||
<slot>setEnabled(bool)</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>showWrapColumn</sender>
|
||||
<signal>toggled(bool)</signal>
|
||||
|
73
src/plugins/texteditor/interactionsettings.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** Non-Open Source Usage
|
||||
**
|
||||
** Licensees may use this file in accordance with the Qt Beta Version
|
||||
** License Agreement, Agreement version 2.2 provided with the Software or,
|
||||
** alternatively, in accordance with the terms contained in a written
|
||||
** agreement between you and Nokia.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License versions 2.0 or 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
||||
** of this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
**
|
||||
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt GPL Exception
|
||||
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
***************************************************************************/
|
||||
|
||||
#include "interactionsettings.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
static const char *useVimKey = "UseVim";
|
||||
static const char *groupPostfix = "InteractionSettings";
|
||||
|
||||
InteractionSettings::InteractionSettings()
|
||||
: m_useVim(false)
|
||||
{
|
||||
}
|
||||
|
||||
void InteractionSettings::toSettings(const QString &category, QSettings *s) const
|
||||
{
|
||||
QString group = QLatin1String(groupPostfix);
|
||||
if (!category.isEmpty())
|
||||
group.insert(0, category);
|
||||
s->beginGroup(group);
|
||||
s->setValue(QLatin1String(useVimKey), m_useVim);
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
void InteractionSettings::fromSettings(const QString &category, const QSettings *s)
|
||||
{
|
||||
QString group = QLatin1String(groupPostfix);
|
||||
if (!category.isEmpty())
|
||||
group.insert(0, category);
|
||||
group += QLatin1Char('/');
|
||||
m_useVim = s->value(group + QLatin1String(useVimKey), m_useVim).toBool();
|
||||
}
|
||||
|
||||
bool InteractionSettings::equals(const InteractionSettings &ts) const
|
||||
{
|
||||
return m_useVim == ts.m_useVim;
|
||||
}
|
||||
|
||||
} // namespace TextEditor
|
62
src/plugins/texteditor/interactionsettings.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/***************************************************************************
|
||||
**
|
||||
** This file is part of Qt Creator
|
||||
**
|
||||
** Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
||||
**
|
||||
** Contact: Qt Software Information (qt-info@nokia.com)
|
||||
**
|
||||
**
|
||||
** Non-Open Source Usage
|
||||
**
|
||||
** Licensees may use this file in accordance with the Qt Beta Version
|
||||
** License Agreement, Agreement version 2.2 provided with the Software or,
|
||||
** alternatively, in accordance with the terms contained in a written
|
||||
** agreement between you and Nokia.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
**
|
||||
** Alternatively, this file may be used under the terms of the GNU General
|
||||
** Public License versions 2.0 or 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the packaging
|
||||
** of this file. Please review the following information to ensure GNU
|
||||
** General Public Licensing requirements will be met:
|
||||
**
|
||||
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
|
||||
** http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** In addition, as a special exception, Nokia gives you certain additional
|
||||
** rights. These rights are described in the Nokia Qt GPL Exception
|
||||
** version 1.3, included in the file GPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef INTERACTIONSETTINGS_H
|
||||
#define INTERACTIONSETTINGS_H
|
||||
|
||||
#include "texteditor_global.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
struct TEXTEDITOR_EXPORT InteractionSettings
|
||||
{
|
||||
InteractionSettings();
|
||||
|
||||
void toSettings(const QString &category, QSettings *s) const;
|
||||
void fromSettings(const QString &category, const QSettings *s);
|
||||
|
||||
bool equals(const InteractionSettings &ts) const;
|
||||
|
||||
bool m_useVim;
|
||||
};
|
||||
|
||||
inline bool operator==(const InteractionSettings &t1, const InteractionSettings &t2) { return t1.equals(t2); }
|
||||
inline bool operator!=(const InteractionSettings &t1, const InteractionSettings &t2) { return !t1.equals(t2); }
|
||||
|
||||
} // namespace TextEditor
|
||||
|
||||
#endif // INTERACTIONSETTINGS_H
|
@@ -43,10 +43,9 @@ using namespace QuickOpen;
|
||||
using namespace TextEditor;
|
||||
using namespace TextEditor::Internal;
|
||||
|
||||
LineNumberFilter::LineNumberFilter(EditorManager *editorManager, QObject *parent):
|
||||
IQuickOpenFilter(parent)
|
||||
LineNumberFilter::LineNumberFilter(QObject *parent)
|
||||
: IQuickOpenFilter(parent)
|
||||
{
|
||||
m_editorManager = editorManager;
|
||||
setShortcutString("l");
|
||||
setIncludedByDefault(true);
|
||||
}
|
||||
@@ -65,17 +64,19 @@ void LineNumberFilter::accept(FilterEntry selection) const
|
||||
{
|
||||
ITextEditor *editor = currentTextEditor();
|
||||
if (editor) {
|
||||
m_editorManager->ensureEditorManagerVisible();
|
||||
m_editorManager->addCurrentPositionToNavigationHistory(true);
|
||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||
editorManager->ensureEditorManagerVisible();
|
||||
editorManager->addCurrentPositionToNavigationHistory(true);
|
||||
editor->gotoLine(selection.internalData.toInt());
|
||||
m_editorManager->addCurrentPositionToNavigationHistory();
|
||||
editorManager->addCurrentPositionToNavigationHistory();
|
||||
editor->widget()->setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
ITextEditor *LineNumberFilter::currentTextEditor() const
|
||||
{
|
||||
if (!m_editorManager->currentEditor())
|
||||
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
||||
if (!editorManager->currentEditor())
|
||||
return 0;
|
||||
return qobject_cast<TextEditor::ITextEditor*>(m_editorManager->currentEditor());
|
||||
return qobject_cast<TextEditor::ITextEditor*>(editorManager->currentEditor());
|
||||
}
|
||||
|
@@ -38,13 +38,7 @@
|
||||
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QFutureInterface>
|
||||
#include <QtGui/QWidget>
|
||||
|
||||
namespace Core {
|
||||
class EditorManager;
|
||||
}
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
@@ -57,7 +51,8 @@ class LineNumberFilter : public QuickOpen::IQuickOpenFilter
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LineNumberFilter(Core::EditorManager *editorManager, QObject *parent = 0);
|
||||
explicit LineNumberFilter(QObject *parent = 0);
|
||||
|
||||
QString trName() const { return tr("Line in current document"); }
|
||||
QString name() const { return "Line in current document"; }
|
||||
QuickOpen::IQuickOpenFilter::Priority priority() const { return QuickOpen::IQuickOpenFilter::High; }
|
||||
@@ -67,8 +62,6 @@ public:
|
||||
|
||||
private:
|
||||
ITextEditor *currentTextEditor() const;
|
||||
|
||||
Core::EditorManager *m_editorManager;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -41,12 +41,14 @@ namespace TextEditor {
|
||||
static const char * const cleanWhitespaceKey = "cleanWhitespace";
|
||||
static const char * const inEntireDocumentKey = "inEntireDocument";
|
||||
static const char * const addFinalNewLineKey = "addFinalNewLine";
|
||||
static const char * const cleanIndentationKey = "cleanIndentation";
|
||||
static const char * const groupPostfix = "StorageSettings";
|
||||
|
||||
StorageSettings::StorageSettings()
|
||||
: m_cleanWhitespace(true),
|
||||
m_inEntireDocument(false),
|
||||
m_addFinalNewLine(true)
|
||||
m_addFinalNewLine(true),
|
||||
m_cleanIndentation(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -59,6 +61,7 @@ void StorageSettings::toSettings(const QString &category, QSettings *s) const
|
||||
s->setValue(QLatin1String(cleanWhitespaceKey), m_cleanWhitespace);
|
||||
s->setValue(QLatin1String(inEntireDocumentKey), m_inEntireDocument);
|
||||
s->setValue(QLatin1String(addFinalNewLineKey), m_addFinalNewLine);
|
||||
s->setValue(QLatin1String(cleanIndentationKey), m_cleanIndentation);
|
||||
s->endGroup();
|
||||
}
|
||||
|
||||
@@ -71,13 +74,15 @@ void StorageSettings::fromSettings(const QString &category, const QSettings *s)
|
||||
m_cleanWhitespace = s->value(group + QLatin1String(cleanWhitespaceKey), m_cleanWhitespace).toBool();
|
||||
m_inEntireDocument = s->value(group + QLatin1String(inEntireDocumentKey), m_inEntireDocument).toBool();
|
||||
m_addFinalNewLine = s->value(group + QLatin1String(addFinalNewLineKey), m_addFinalNewLine).toBool();
|
||||
m_cleanIndentation = s->value(group + QLatin1String(cleanIndentationKey), m_cleanIndentation).toBool();
|
||||
}
|
||||
|
||||
bool StorageSettings::equals(const StorageSettings &ts) const
|
||||
{
|
||||
return m_addFinalNewLine == ts.m_addFinalNewLine
|
||||
&& m_cleanWhitespace == ts.m_cleanWhitespace
|
||||
&& m_inEntireDocument == ts.m_inEntireDocument;
|
||||
&& m_inEntireDocument == ts.m_inEntireDocument
|
||||
&& m_cleanIndentation == ts.m_cleanIndentation;
|
||||
}
|
||||
|
||||
} // namespace TextEditor
|
||||
|
@@ -54,6 +54,7 @@ struct TEXTEDITOR_EXPORT StorageSettings
|
||||
bool m_cleanWhitespace;
|
||||
bool m_inEntireDocument;
|
||||
bool m_addFinalNewLine;
|
||||
bool m_cleanIndentation;
|
||||
};
|
||||
|
||||
inline bool operator==(const StorageSettings &t1, const StorageSettings &t2) { return t1.equals(t2); }
|
||||
|
@@ -33,18 +33,18 @@
|
||||
|
||||
#include "tabsettings.h"
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtCore/QString>
|
||||
#include <QtGui/QTextCursor>
|
||||
#include <QtGui/QTextDocument>
|
||||
#include <QDebug>
|
||||
|
||||
static const char* spacesForTabsKey = "SpacesForTabs";
|
||||
static const char* smartBackspaceKey = "SmartBackspace";
|
||||
static const char* autoIndentKey = "AutoIndent";
|
||||
static const char* tabSizeKey = "TabSize";
|
||||
static const char* indentSizeKey = "IndentSize";
|
||||
static const char* groupPostfix = "TabSettings";
|
||||
static const char *spacesForTabsKey = "SpacesForTabs";
|
||||
static const char *smartBackspaceKey = "SmartBackspace";
|
||||
static const char *autoIndentKey = "AutoIndent";
|
||||
static const char *tabSizeKey = "TabSize";
|
||||
static const char *indentSizeKey = "IndentSize";
|
||||
static const char *groupPostfix = "TabSettings";
|
||||
|
||||
namespace TextEditor {
|
||||
|
||||
|
@@ -13,6 +13,7 @@ SOURCES += texteditorplugin.cpp \
|
||||
completionsupport.cpp \
|
||||
completionwidget.cpp \
|
||||
fontsettingspage.cpp \
|
||||
interactionsettings.cpp \
|
||||
tabsettings.cpp \
|
||||
storagesettings.cpp \
|
||||
displaysettings.cpp \
|
||||
@@ -37,6 +38,7 @@ HEADERS += texteditorplugin.h \
|
||||
texteditoractionhandler.h \
|
||||
fontsettingspage.h \
|
||||
icompletioncollector.h \
|
||||
interactionsettings.h \
|
||||
texteditorconstants.h \
|
||||
tabsettings.h \
|
||||
storagesettings.h \
|
||||
|
@@ -42,6 +42,7 @@
|
||||
#include "plaintexteditorfactory.h"
|
||||
#include "plaintexteditor.h"
|
||||
#include "storagesettings.h"
|
||||
#include "interactionsettings.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
@@ -104,7 +105,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
addAutoReleasedObject(m_wizard);
|
||||
|
||||
|
||||
m_settings = new TextEditorSettings(this, this);
|
||||
m_settings = new TextEditorSettings(this);
|
||||
|
||||
// Add plain text editor factory
|
||||
m_editorFactory = new PlainTextEditorFactory;
|
||||
@@ -112,7 +113,7 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
|
||||
|
||||
// Goto line functionality for quick open
|
||||
Core::ICore *core = Core::ICore::instance();
|
||||
m_lineNumberFilter = new LineNumberFilter(core->editorManager());
|
||||
m_lineNumberFilter = new LineNumberFilter;
|
||||
addAutoReleasedObject(m_lineNumberFilter);
|
||||
|
||||
int contextId = core->uniqueIDManager()->uniqueIdentifier(TextEditor::Constants::C_TEXTEDITOR);
|
||||
|
@@ -51,8 +51,7 @@ using namespace TextEditor::Constants;
|
||||
|
||||
TextEditorSettings *TextEditorSettings::m_instance = 0;
|
||||
|
||||
TextEditorSettings::TextEditorSettings(Internal::TextEditorPlugin *plugin,
|
||||
QObject *parent)
|
||||
TextEditorSettings::TextEditorSettings(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
QTC_ASSERT(!m_instance, return);
|
||||
|
@@ -47,10 +47,6 @@ struct TabSettings;
|
||||
struct StorageSettings;
|
||||
struct DisplaySettings;
|
||||
|
||||
namespace Internal {
|
||||
class TextEditorPlugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* This class provides a central place for basic text editor settings. These
|
||||
* settings include font settings, tab settings, storage settings and display
|
||||
@@ -61,7 +57,7 @@ class TEXTEDITOR_EXPORT TextEditorSettings : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TextEditorSettings(Internal::TextEditorPlugin *plugin, QObject *parent);
|
||||
explicit TextEditorSettings(QObject *parent);
|
||||
~TextEditorSettings();
|
||||
|
||||
static TextEditorSettings *instance();
|
||||
|
@@ -7,7 +7,7 @@ win32 {
|
||||
|
||||
DESTDIR = $$IDE_LIBRARY_PATH
|
||||
|
||||
include(../rpath.pri)
|
||||
include(rpath.pri)
|
||||
|
||||
TARGET = $$qtLibraryTarget($$TARGET)
|
||||
|
||||
|
@@ -9,5 +9,3 @@ macx {
|
||||
QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,$${IDE_PLUGIN_RPATH}\'
|
||||
QMAKE_RPATHDIR =
|
||||
}
|
||||
|
||||
|
||||
|