Commit 13b0ca00 authored by Lorenz Haas's avatar Lorenz Haas Committed by David Schulz
Browse files

Add keyboard shortcut for "New Scratch Buffer"



Task-number: QTCREATORBUG-9039
Change-Id: Iff7d821f863f2691786acaea44137d291d3dbf67
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 44931c09
......@@ -94,6 +94,7 @@ namespace Constants {
const char C_TEXTEDITOR[] = "Text Editor";
const char COMPLETE_THIS[] = "TextEditor.CompleteThis";
const char QUICKFIX_THIS[] = "TextEditor.QuickFix";
const char CREATE_SCRATCH_BUFFER[] = "TextEditor.CreateScratchBuffer";
const char VISUALIZE_WHITESPACE[] = "TextEditor.VisualizeWhitespace";
const char CLEAN_WHITESPACE[] = "TextEditor.CleanWhitespace";
const char TEXT_WRAPPING[] = "TextEditor.TextWrapping";
......
......@@ -99,6 +99,8 @@ static inline QString wizardDisplayCategory()
// based on a temporary file without prompting for a path.
class ScratchFileWizard : public Core::IWizard
{
Q_OBJECT
public:
virtual WizardKind kind() const { return FileWizard; }
virtual QIcon icon() const { return QIcon(); }
......@@ -118,13 +120,15 @@ public:
{ return Core::FeatureSet(); }
virtual WizardFlags flags() const
{ return Core::IWizard::PlatformIndependent; }
virtual void runWizard(const QString &, QWidget *, const QString &, const QVariantMap &)
{ createFile(); }
virtual void runWizard(const QString &path, QWidget *parent, const QString &platform, const QVariantMap &extraValues);
public Q_SLOTS:
virtual void createFile();
};
void ScratchFileWizard::runWizard(const QString &, QWidget *, const QString &, const QVariantMap &extraValues)
void ScratchFileWizard::createFile()
{
Q_UNUSED(extraValues)
QString tempPattern = QDir::tempPath();
if (!tempPattern.endsWith(QLatin1Char('/')))
tempPattern += QLatin1Char('/');
......@@ -156,7 +160,8 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
wizardParameters);
// Add text file wizard
addAutoReleasedObject(wizard);
addAutoReleasedObject(new ScratchFileWizard);
ScratchFileWizard *scratchFile = new ScratchFileWizard;
addAutoReleasedObject(scratchFile);
m_settings = new TextEditorSettings(this);
......@@ -188,6 +193,13 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe
quickFixCommand->setDefaultKeySequence(QKeySequence(tr("Alt+Return")));
connect(quickFixShortcut, SIGNAL(activated()), this, SLOT(invokeQuickFix()));
// Add shortcut for create a scratch buffer
QShortcut *scratchBufferShortcut = new QShortcut(Core::ICore::mainWindow());
scratchBufferShortcut->setWhatsThis(tr("Creates a scratch buffer using a temporary file."));
scratchBufferShortcut->setContext(Qt::ApplicationShortcut);
Core::ActionManager::registerShortcut(scratchBufferShortcut, Constants::CREATE_SCRATCH_BUFFER, context);
connect(scratchBufferShortcut, SIGNAL(activated()), scratchFile, SLOT(createFile()));
// Generic highlighter.
connect(Core::ICore::instance(), SIGNAL(coreOpened()),
Manager::instance(), SLOT(registerMimeTypes()));
......@@ -327,3 +339,5 @@ void TextEditorPlugin::updateCurrentSelection(const QString &text)
}
Q_EXPORT_PLUGIN(TextEditorPlugin)
#include "texteditorplugin.moc"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment