From 9a3a3d4711f5caadf3fdc2a91f33b0af8fd9d0e4 Mon Sep 17 00:00:00 2001 From: Tobias Hunger <tobias.hunger@digia.com> Date: Tue, 16 Sep 2014 17:43:03 +0200 Subject: [PATCH] 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> --- .../templates/wizards/files/scratch/file.txt | 0 .../wizards/files/scratch/wizard.json | 29 +++++++++++ .../wizards/global/genericfilewizard.png | Bin 0 -> 977 bytes src/plugins/texteditor/texteditorplugin.cpp | 47 ------------------ 4 files changed, 29 insertions(+), 47 deletions(-) create mode 100644 share/qtcreator/templates/wizards/files/scratch/file.txt create mode 100644 share/qtcreator/templates/wizards/files/scratch/wizard.json create mode 100644 share/qtcreator/templates/wizards/global/genericfilewizard.png 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 00000000000..e69de29bb2d 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 00000000000..7516925d09b --- /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 GIT binary patch literal 977 zcmeAS@N?(olHy`uVBq!ia0y~yU{C;I4mJh`hT^KKFANL}Ea{HEjtmUfZd~z?Fk)a} zkSuYHC<)F_D=AMbN@Z|N$xljE@XSq2PYp^<OsOn9nQFtpz?|&q;usQf_~`Vr`O={x zN9)VeCUst}xw2NAQ{j?tXrKT`V9O~k&Kn9x76pmxXsKvqo9RsWC4ZoacZD^J&W$F4 zRkvJOQ`k9J7MeJ;3g#(p6`u3#@Yc(f?_<S2zv-EKWZBmc*_U2&nKsYw6rbDuzITPz z_fK3qj)#A#m#g}3TKVaj*u>B!2B(CN39V9M2t42;Veop&0V}Dirgqi8i=Q<vTeZva z{WM3hIkmCpY<`^JUT?L0;VL$MncA{DmZBl739C%Rd&S?&a~^7%v9_)5<Gs#T<=y}H z{eBo;!*nI|>NnPatNTj7nb@ydwaO}f+v+({xm)wHw(eSTOk(e*52c@;b=Um<vv?1a z$Zg+uq0Gh)rU>XH)L35ny@jRQaC=1DI>9!@cDX7mtDnc%`(@`nd^)}Fql|%~Qqgfm zpS{=gE^Lu`5TLV)^K6<jZ>Y$}4<9ElUVi`AkC{7#mNz&%B%TPJz|`n!IM0De;>hHa z&vNhY<Lt93Rnqe<lCj|O;oHh3(w=bXO5XG7A(9+SM`wtM>&GSJ<~A!d{QcdX5z>=b z$~S{yRr#8R6rBrxazeLmO2~?)rSV_Nxpwo;n#40|t%o?)KGTZ(m*K&>Cfvcg*4wRB zA>`d`T|?8K7RMwOX(;va7u2zwO%>ogSMGC+%~g;^RY0+?)#6-~t(!#2lFKqi6Mk%8 zvfx&Gp4Yjj=3Terwp-^nd-&^Ymlpj$e+~x+-`R)@Y74Ee9X69a8QyrM>7PpV%cmX= ze;-WLW8UTX(sS0cOvf<Bn@f|cIG(O^n8kScWnfvSjNP<LoXgMNZ@L$^RQQ-k)$hu^ z(p)OmPu_it*)5iSj_b{wmR+xlZ{BtOEbr2sbp7vdJ)T8tKL4GP!T%;^dg3loeyfMa z4_E}G<f;}(`$p}|b+guO_~K#NX3!h7BrI~{)T5`rE!VgATBq~x!j6)u_6?y4*&eJ{ z<Q+s+S-3cYHP}~#hP^%XXXlga`F5sHiz@%Vw>o|Q|H=HPTB#4D3M3=sjhGkoEc9V! zw|&vd_d@^rikMX&eqZAK$CPzI=tIAK+ttRiilP=yYd7VHKRf@PwMur!E63Ld+Su=2 zVvM(A=3HZL`Tg9=Ltnm1-<Yqh^OkYfqtrZx&U?qi-yiTd7Sv=s-f;MUF29Ayi?>1& mjLZIByj7Li&U7~JKjY5~fj+_TG8F~}1_n=8KbLh*2~7YwJGfc^ literal 0 HcmV?d00001 diff --git a/src/plugins/texteditor/texteditorplugin.cpp b/src/plugins/texteditor/texteditorplugin.cpp index c0fca6a83f6..5a989890ed3 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" -- GitLab