mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-05-28 03:10:28 -04:00
feat: Update dialog offer open plugin folder
This commit is contained in:
parent
5b99e68e53
commit
4bf955462f
@ -159,11 +159,19 @@ void PluginUpdater::handleDownloadFinished()
|
||||
return;
|
||||
}
|
||||
|
||||
QString downloadPath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
||||
QString downloadPath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)
|
||||
+ QDir::separator() + "QodeAssist_v" + m_lastUpdateInfo.version;
|
||||
QDir().mkpath(downloadPath);
|
||||
|
||||
QString filePath = downloadPath + QDir::separator() + m_lastUpdateInfo.fileName;
|
||||
|
||||
if (QFile::exists(filePath)) {
|
||||
emit downloadError(tr("Update file already exists: %1").arg(filePath));
|
||||
reply->deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
QString filePath = downloadPath + "/" + m_lastUpdateInfo.fileName;
|
||||
QFile file(filePath);
|
||||
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
emit downloadError(tr("Could not save the update file"));
|
||||
reply->deleteLater();
|
||||
@ -174,7 +182,6 @@ void PluginUpdater::handleDownloadFinished()
|
||||
file.close();
|
||||
|
||||
emit downloadFinished(filePath);
|
||||
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,11 @@
|
||||
|
||||
#include "UpdateDialog.hpp"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include <extensionsystem/pluginspec.h>
|
||||
#include <QDesktopServices>
|
||||
|
||||
namespace QodeAssist {
|
||||
|
||||
UpdateDialog::UpdateDialog(QWidget *parent)
|
||||
@ -166,7 +171,32 @@ void UpdateDialog::updateProgress(qint64 received, qint64 total)
|
||||
void UpdateDialog::handleDownloadFinished(const QString &path)
|
||||
{
|
||||
m_progress->setVisible(false);
|
||||
QMessageBox::information(this, tr("Update Successful"), tr("Update has been downloaded."));
|
||||
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setWindowTitle(tr("Update Downloaded"));
|
||||
msgBox.setText(tr("The update has been downloaded successfully.\n"
|
||||
"Would you like to close Qt Creator now and open the plugin folder?"));
|
||||
msgBox.setInformativeText(tr("To complete the update:\n\n"
|
||||
"1. Close Qt Creator completely\n"
|
||||
"2. Navigate to the plugin folder\n"
|
||||
"3. Remove the old version of QodeAssist plugin\n"
|
||||
"4. Install plugin as usual via About plugin menu"));
|
||||
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
||||
msgBox.setDefaultButton(QMessageBox::Yes);
|
||||
msgBox.setIcon(QMessageBox::Information);
|
||||
|
||||
if (msgBox.exec() == QMessageBox::Yes) {
|
||||
const auto pluginSpecs = ExtensionSystem::PluginManager::plugins();
|
||||
for (const ExtensionSystem::PluginSpec *spec : pluginSpecs) {
|
||||
if (spec->name() == QLatin1String("QodeAssist")) {
|
||||
const auto pluginPath = spec->filePath().path();
|
||||
QFileInfo fileInfo(pluginPath);
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(fileInfo.absolutePath()));
|
||||
Core::ICore::exit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
accept();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user