forked from qt-creator/qt-creator
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: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
29
share/qtcreator/templates/wizards/files/scratch/wizard.json
Normal file
29
share/qtcreator/templates/wizards/files/scratch/wizard.json
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
BIN
share/qtcreator/templates/wizards/global/genericfilewizard.png
Normal file
BIN
share/qtcreator/templates/wizards/global/genericfilewizard.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 977 B |
@@ -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"
|
||||
|
Reference in New Issue
Block a user