forked from qt-creator/qt-creator
Implement (un)commenting selection of .pro files
Reviewed-by: Leandro Melo <leandro.melo@nokia.com> Task-number: QTCREATORBUG-119
This commit is contained in:
@@ -34,6 +34,9 @@
|
|||||||
#include "qt4projectmanagerconstants.h"
|
#include "qt4projectmanagerconstants.h"
|
||||||
#include "profileeditorfactory.h"
|
#include "profileeditorfactory.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
#include <coreplugin/uniqueidmanager.h>
|
#include <coreplugin/uniqueidmanager.h>
|
||||||
#include <texteditor/fontsettings.h>
|
#include <texteditor/fontsettings.h>
|
||||||
#include <texteditor/texteditoractionhandler.h>
|
#include <texteditor/texteditoractionhandler.h>
|
||||||
@@ -41,6 +44,7 @@
|
|||||||
#include <texteditor/texteditorsettings.h>
|
#include <texteditor/texteditorsettings.h>
|
||||||
|
|
||||||
#include <QtCore/QFileInfo>
|
#include <QtCore/QFileInfo>
|
||||||
|
#include <QtGui/QMenu>
|
||||||
|
|
||||||
using namespace Qt4ProjectManager;
|
using namespace Qt4ProjectManager;
|
||||||
using namespace Qt4ProjectManager::Internal;
|
using namespace Qt4ProjectManager::Internal;
|
||||||
@@ -91,17 +95,41 @@ ProFileEditor::ProFileEditor(QWidget *parent, ProFileEditorFactory *factory, Tex
|
|||||||
ah->setupActions(this);
|
ah->setupActions(this);
|
||||||
|
|
||||||
baseTextDocument()->setSyntaxHighlighter(new ProFileHighlighter);
|
baseTextDocument()->setSyntaxHighlighter(new ProFileHighlighter);
|
||||||
|
m_commentDefinition.clearCommentStyles();
|
||||||
|
m_commentDefinition.setSingleLine(QString(QLatin1Char('#')));
|
||||||
}
|
}
|
||||||
|
|
||||||
ProFileEditor::~ProFileEditor()
|
ProFileEditor::~ProFileEditor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProFileEditor::unCommentSelection()
|
||||||
|
{
|
||||||
|
Utils::unCommentSelection(this, m_commentDefinition);
|
||||||
|
}
|
||||||
|
|
||||||
TextEditor::BaseTextEditorEditable *ProFileEditor::createEditableInterface()
|
TextEditor::BaseTextEditorEditable *ProFileEditor::createEditableInterface()
|
||||||
{
|
{
|
||||||
return new ProFileEditorEditable(this);
|
return new ProFileEditorEditable(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProFileEditor::contextMenuEvent(QContextMenuEvent *e)
|
||||||
|
{
|
||||||
|
QMenu *menu = new QMenu();
|
||||||
|
|
||||||
|
Core::ActionManager *am = Core::ICore::instance()->actionManager();
|
||||||
|
Core::ActionContainer *mcontext = am->actionContainer(Qt4ProjectManager::Constants::M_CONTEXT);
|
||||||
|
QMenu *contextMenu = mcontext->menu();
|
||||||
|
|
||||||
|
foreach (QAction *action, contextMenu->actions())
|
||||||
|
menu->addAction(action);
|
||||||
|
|
||||||
|
appendStandardContextMenuActions(menu);
|
||||||
|
|
||||||
|
menu->exec(e->globalPos());
|
||||||
|
delete menu;
|
||||||
|
}
|
||||||
|
|
||||||
void ProFileEditor::setFontSettings(const TextEditor::FontSettings &fs)
|
void ProFileEditor::setFontSettings(const TextEditor::FontSettings &fs)
|
||||||
{
|
{
|
||||||
TextEditor::BaseTextEditor::setFontSettings(fs);
|
TextEditor::BaseTextEditor::setFontSettings(fs);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
#include <texteditor/basetextdocument.h>
|
#include <texteditor/basetextdocument.h>
|
||||||
#include <texteditor/basetexteditor.h>
|
#include <texteditor/basetexteditor.h>
|
||||||
|
#include <utils/uncommentselection.h>
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
class FontSettings;
|
class FontSettings;
|
||||||
@@ -78,8 +79,12 @@ public:
|
|||||||
|
|
||||||
ProFileEditorFactory *factory() { return m_factory; }
|
ProFileEditorFactory *factory() { return m_factory; }
|
||||||
TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; }
|
TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; }
|
||||||
|
|
||||||
|
void unCommentSelection();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TextEditor::BaseTextEditorEditable *createEditableInterface();
|
TextEditor::BaseTextEditorEditable *createEditableInterface();
|
||||||
|
void contextMenuEvent(QContextMenuEvent *);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setFontSettings(const TextEditor::FontSettings &);
|
virtual void setFontSettings(const TextEditor::FontSettings &);
|
||||||
@@ -87,6 +92,7 @@ public slots:
|
|||||||
private:
|
private:
|
||||||
ProFileEditorFactory *m_factory;
|
ProFileEditorFactory *m_factory;
|
||||||
TextEditor::TextEditorActionHandler *m_ah;
|
TextEditor::TextEditorActionHandler *m_ah;
|
||||||
|
Utils::CommentDefinition m_commentDefinition;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProFileDocument : public TextEditor::BaseTextDocument
|
class ProFileDocument : public TextEditor::BaseTextDocument
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ namespace Constants {
|
|||||||
const char * const C_PROFILEEDITOR = ".pro File Editor";
|
const char * const C_PROFILEEDITOR = ".pro File Editor";
|
||||||
const char * const C_PROFILEEDITOR_PANEL = ".pro File Editor (embedded)";
|
const char * const C_PROFILEEDITOR_PANEL = ".pro File Editor (embedded)";
|
||||||
|
|
||||||
|
// menus
|
||||||
|
const char * const M_CONTEXT = "ProFileEditor.ContextMenu";
|
||||||
|
|
||||||
// kinds
|
// kinds
|
||||||
const char * const PROJECT_ID = "Qt4.Qt4Project";
|
const char * const PROJECT_ID = "Qt4.Qt4Project";
|
||||||
const char * const PROFILE_EDITOR_ID = "Qt4.proFileEditor";
|
const char * const PROFILE_EDITOR_ID = "Qt4.proFileEditor";
|
||||||
|
|||||||
@@ -66,6 +66,7 @@
|
|||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
#include <coreplugin/actionmanager/command.h>
|
#include <coreplugin/actionmanager/command.h>
|
||||||
#include <texteditor/texteditoractionhandler.h>
|
#include <texteditor/texteditoractionhandler.h>
|
||||||
|
#include <texteditor/texteditorconstants.h>
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
# include <QTest>
|
# include <QTest>
|
||||||
@@ -117,7 +118,8 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
|
|||||||
addObject(m_qt4ProjectManager);
|
addObject(m_qt4ProjectManager);
|
||||||
|
|
||||||
TextEditor::TextEditorActionHandler *editorHandler
|
TextEditor::TextEditorActionHandler *editorHandler
|
||||||
= new TextEditor::TextEditorActionHandler(Constants::C_PROFILEEDITOR);
|
= new TextEditor::TextEditorActionHandler(Constants::C_PROFILEEDITOR,
|
||||||
|
TextEditor::TextEditorActionHandler::UnCommentSelection);
|
||||||
|
|
||||||
m_proFileEditorFactory = new ProFileEditorFactory(m_qt4ProjectManager, editorHandler);
|
m_proFileEditorFactory = new ProFileEditorFactory(m_qt4ProjectManager, editorHandler);
|
||||||
addObject(m_proFileEditorFactory);
|
addObject(m_proFileEditorFactory);
|
||||||
@@ -222,6 +224,13 @@ bool Qt4ProjectManagerPlugin::initialize(const QStringList &arguments, QString *
|
|||||||
connect(m_projectExplorer, SIGNAL(currentProjectChanged(ProjectExplorer::Project *)),
|
connect(m_projectExplorer, SIGNAL(currentProjectChanged(ProjectExplorer::Project *)),
|
||||||
this, SLOT(currentProjectChanged()));
|
this, SLOT(currentProjectChanged()));
|
||||||
|
|
||||||
|
Core::ActionContainer *contextMenu= am->createMenu(Qt4ProjectManager::Constants::M_CONTEXT);
|
||||||
|
|
||||||
|
Core::Command *cmd;
|
||||||
|
|
||||||
|
cmd = am->command(TextEditor::Constants::UN_COMMENT_SELECTION);
|
||||||
|
contextMenu->addAction(cmd);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user