Changeset View
Changeset View
Standalone View
Standalone View
plugins/appwizard/appwizardplugin.cpp
Show All 14 Lines | |||||
15 | 15 | | |||
16 | #include <QAction> | 16 | #include <QAction> | ||
17 | #include <QDir> | 17 | #include <QDir> | ||
18 | #include <QDirIterator> | 18 | #include <QDirIterator> | ||
19 | #include <QFile> | 19 | #include <QFile> | ||
20 | #include <QFileInfo> | 20 | #include <QFileInfo> | ||
21 | #include <QMimeType> | 21 | #include <QMimeType> | ||
22 | #include <QMimeDatabase> | 22 | #include <QMimeDatabase> | ||
23 | #include <QPointer> | ||||
23 | #include <QStandardPaths> | 24 | #include <QStandardPaths> | ||
24 | #include <QTemporaryDir> | 25 | #include <QTemporaryDir> | ||
25 | #include <QTextCodec> | 26 | #include <QTextCodec> | ||
26 | #include <QTextStream> | 27 | #include <QTextStream> | ||
27 | #include <qplatformdefs.h> | 28 | #include <qplatformdefs.h> | ||
28 | 29 | | |||
29 | #include <KActionCollection> | 30 | #include <KActionCollection> | ||
30 | #include <KConfigGroup> | 31 | #include <KConfigGroup> | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
79 | AppWizardPlugin::~AppWizardPlugin() | 80 | AppWizardPlugin::~AppWizardPlugin() | ||
80 | { | 81 | { | ||
81 | } | 82 | } | ||
82 | 83 | | |||
83 | void AppWizardPlugin::slotNewProject() | 84 | void AppWizardPlugin::slotNewProject() | ||
84 | { | 85 | { | ||
85 | model()->refresh(); | 86 | model()->refresh(); | ||
86 | 87 | | |||
87 | AppWizardDialog dlg(core()->pluginController(), m_templatesModel); | 88 | QPointer<AppWizardDialog> dlg = new AppWizardDialog(core()->pluginController(), m_templatesModel); | ||
88 | 89 | | |||
89 | if (dlg.exec() == QDialog::Accepted) | 90 | if (dlg->exec() == QDialog::Accepted) | ||
90 | { | 91 | { | ||
91 | QString project = createProject( dlg.appInfo() ); | 92 | QString project = createProject( dlg->appInfo() ); | ||
92 | if (!project.isEmpty()) | 93 | if (!project.isEmpty()) | ||
93 | { | 94 | { | ||
94 | core()->projectController()->openProject(QUrl::fromLocalFile(project)); | 95 | core()->projectController()->openProject(QUrl::fromLocalFile(project)); | ||
95 | 96 | | |||
96 | KConfig templateConfig(dlg.appInfo().appTemplate); | 97 | KConfig templateConfig(dlg->appInfo().appTemplate); | ||
97 | KConfigGroup general(&templateConfig, "General"); | 98 | KConfigGroup general(&templateConfig, "General"); | ||
98 | const QStringList fileArgs = general.readEntry("ShowFilesAfterGeneration").split(QLatin1Char(','), QString::SkipEmptyParts); | 99 | const QStringList fileArgs = general.readEntry("ShowFilesAfterGeneration").split(QLatin1Char(','), QString::SkipEmptyParts); | ||
99 | for (const auto& fileArg : fileArgs) { | 100 | for (const auto& fileArg : fileArgs) { | ||
100 | QString file = KMacroExpander::expandMacros(fileArg.trimmed(), m_variables); | 101 | QString file = KMacroExpander::expandMacros(fileArg.trimmed(), m_variables); | ||
101 | if (QDir::isRelativePath(file)) { | 102 | if (QDir::isRelativePath(file)) { | ||
102 | file = m_variables[QStringLiteral("PROJECTDIR")] + QLatin1Char('/') + file; | 103 | file = m_variables[QStringLiteral("PROJECTDIR")] + QLatin1Char('/') + file; | ||
103 | } | 104 | } | ||
104 | core()->documentController()->openDocument(QUrl::fromUserInput(file)); | 105 | core()->documentController()->openDocument(QUrl::fromUserInput(file)); | ||
105 | } | 106 | } | ||
106 | } else { | 107 | } else { | ||
107 | KMessageBox::error( ICore::self()->uiController()->activeMainWindow(), i18n("Could not create project from template\n"), i18n("Failed to create project") ); | 108 | KMessageBox::error( ICore::self()->uiController()->activeMainWindow(), i18n("Could not create project from template\n"), i18n("Failed to create project") ); | ||
108 | } | 109 | } | ||
109 | } | 110 | } | ||
111 | | ||||
112 | delete dlg; | ||||
110 | } | 113 | } | ||
111 | 114 | | |||
112 | namespace | 115 | namespace | ||
113 | { | 116 | { | ||
114 | 117 | | |||
115 | IDistributedVersionControl* toDVCS(IPlugin* plugin) | 118 | IDistributedVersionControl* toDVCS(IPlugin* plugin) | ||
116 | { | 119 | { | ||
117 | Q_ASSERT(plugin); | 120 | Q_ASSERT(plugin); | ||
▲ Show 20 Lines • Show All 442 Lines • Show Last 20 Lines |