Commit 9a3a3d47 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

JsonWizard: Remove scratchfile wizard



Replace it with a json wizard based implementation.

Todo: This removes the keyboard shortcut available to trigger
this wizard. We should make sure all wizards are available
for binding keyboard shortcuts to them instead.

Change-Id: I1aa76222d08371e79c40b52aeb26705f3ccb4899
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 7d1e27a9
{
"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
}
}
]
}
......@@ -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"
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