diff --git a/share/qtcreator/templates/wizards/files/scratch/file.txt b/share/qtcreator/templates/wizards/files/scratch/file.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/share/qtcreator/templates/wizards/files/scratch/wizard.json b/share/qtcreator/templates/wizards/files/scratch/wizard.json new file mode 100644 index 0000000000000000000000000000000000000000..7516925d09b72a45aded48178bcf18be4d469dbb --- /dev/null +++ b/share/qtcreator/templates/wizards/files/scratch/wizard.json @@ -0,0 +1,29 @@ +{ + "version": 1, + "kind": "file", + "id": "Z.ScratchFile", + "category": "U.General", + "trDescription": "Creates a scratch buffer using a temporary file.", + "trDisplayName": "Scratch Buffer", + "trDisplayCategory": "General", + "icon": "../../global/genericfilewizard.png", + "platformIndependent": true, + "featuresRequired": [ "Plugin.TextEditor" ], + + "options": [ { "key": "TargetPath", "value": "%{JS: Util.mktemp('scratch-XXXXXX.txt')}" } ], + + "pages" : [], + "generators" : + [ + { + "typeId": "File", + "data": + { + "source": "file.txt", + "target": "%{TargetPath}", + "overwrite": true, + "openInEditor": true + } + } + ] +} diff --git a/share/qtcreator/templates/wizards/global/genericfilewizard.png b/share/qtcreator/templates/wizards/global/genericfilewizard.png new file mode 100644 index 0000000000000000000000000000000000000000..dd795cfffc5c1ce273b3afedb5ed01da3fc5668c Binary files /dev/null and b/share/qtcreator/templates/wizards/global/genericfilewizard.png differ diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp index c0fca6a83f65aef117a005fde656abccc5ea8fff..5a989890ed35e183c3b4a6cd182fa899dba84631 100644 --- a/src/plugins/texteditor/texteditorplugin.cpp +++ b/src/plugins/texteditor/texteditorplugin.cpp @@ -90,44 +90,6 @@ static inline QString wizardDisplayCategory() return TextEditorPlugin::tr("General"); } -// A wizard that quickly creates a scratch buffer -// based on a temporary file without prompting for a path. -class ScratchFileWizard : public IWizardFactory -{ - Q_OBJECT - -public: - ScratchFileWizard() - { - setWizardKind(FileWizard); - setDescription(TextEditorPlugin::tr("Creates a scratch buffer using a temporary file.")); - setDisplayName(TextEditorPlugin::tr("Scratch Buffer")); - setId(QLatin1String("Z.ScratchFile")); - setCategory(QLatin1String(wizardCategoryC)); - setDisplayCategory(wizardDisplayCategory()); - setFlags(IWizardFactory::PlatformIndependent); - } - - void runWizard(const QString &, QWidget *, const QString &, const QVariantMap &) - { createFile(); } - -public Q_SLOTS: - virtual void createFile(); -}; - -void ScratchFileWizard::createFile() -{ - QString tempPattern = QDir::tempPath(); - if (!tempPattern.endsWith(QLatin1Char('/'))) - tempPattern += QLatin1Char('/'); - tempPattern += QLatin1String("scratchXXXXXX.txt"); - QTemporaryFile file(tempPattern); - file.setAutoRemove(false); - QTC_ASSERT(file.open(), return; ); - file.close(); - EditorManager::openEditor(file.fileName()); -} - // ExtensionSystem::PluginInterface bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMessage) { @@ -148,8 +110,6 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe // Add text file wizard addAutoReleasedObject(wizard); - ScratchFileWizard *scratchFile = new ScratchFileWizard; - addAutoReleasedObject(scratchFile); m_settings = new TextEditorSettings(this); @@ -180,11 +140,6 @@ bool TextEditorPlugin::initialize(const QStringList &arguments, QString *errorMe editor->editorWidget()->invokeAssist(QuickFix); }); - // Add shortcut for create a scratch buffer - QAction *scratchBufferAction = new QAction(tr("Create Scratch Buffer Using a Temporary File"), this); - ActionManager::registerAction(scratchBufferAction, Constants::CREATE_SCRATCH_BUFFER, context); - connect(scratchBufferAction, &QAction::triggered, scratchFile, &ScratchFileWizard::createFile); - // Generic highlighter. connect(ICore::instance(), &ICore::coreOpened, Manager::instance(), &Manager::registerMimeTypes); @@ -306,5 +261,3 @@ void TextEditorPlugin::updateCurrentSelection(const QString &text) } // namespace Internal } // namespace TextEditor - -#include "texteditorplugin.moc"