Skip to content

Commit

Permalink
Add link to package folder (Mudlet#2663)
Browse files Browse the repository at this point in the history
* Add link to package folder

* make package path available

* Remove double declaration

* Add HTML escaping
  • Loading branch information
Kebap authored Jun 26, 2019
1 parent fb8e276 commit a387722
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/dlgPackageExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ dlgPackageExporter::dlgPackageExporter(QWidget *parent, Host* pHost)
// Although the Qt Documentation says only that the Windows platform needs
// to NOT use the native dialog to show files, it has also shown to be
// required for KDE on Linux - so has been used for all platforms:
QString packagePath = QFileDialog::getExistingDirectory(nullptr, tr("Where do you want to save the package?"), mudlet::getMudletPath(mudlet::profileHomePath, profileName), QFileDialog::DontUseNativeDialog);
mPackagePath = QFileDialog::getExistingDirectory(nullptr, tr("Where do you want to save the package?"), mudlet::getMudletPath(mudlet::profileHomePath, profileName), QFileDialog::DontUseNativeDialog);

if (packagePath.isEmpty()) {
if (mPackagePath.isEmpty()) {
return;
}
packagePath.replace(QLatin1String(R"(\)"), QLatin1String("/"));
mPackagePath.replace(QLatin1String(R"(\)"), QLatin1String("/"));

mStagingDirName = mudlet::getMudletPath(mudlet::profileDataItemPath, profileName, QStringLiteral("tmp/%1").arg(mPackageName));
QDir packageDir = QDir(mStagingDirName);
if (!packageDir.exists()) {
packageDir.mkpath(mStagingDirName);
}
mPackagePathFileName = QStringLiteral("%1/%2.mpackage").arg(packagePath, mPackageName);
mPackagePathFileName = QStringLiteral("%1/%2.mpackage").arg(mPackagePath, mPackageName);
ui->label_exportFilePath->show();
ui->filePath->setText(mPackagePathFileName);
ui->filePath->show();
Expand Down Expand Up @@ -536,7 +536,9 @@ void dlgPackageExporter::slot_export_package()

if (isOk) {
// Success!
displayResultMessage(tr("Package exported to: \"%1\".").arg(mPackagePathFileName), true);
displayResultMessage(tr("Package \"%1\" exported to: %2")
.arg(mPackageName, QStringLiteral("<a href=\"file:///%1\">%2</a>"))
.arg(mPackagePath.toHtmlEscaped(), mPackagePath.toHtmlEscaped()), true);
// Remove the cancel button and replace it with an ok one
ui->buttonBox->removeButton(mCancelButton);
ui->buttonBox->addButton(QDialogButtonBox::Ok);
Expand Down
1 change: 1 addition & 0 deletions src/dlgPackageExporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public slots:
QTreeWidgetItem* mpButtons;
QString mStagingDirName;
QString mPackageName;
QString mPackagePath;
QString mPackagePathFileName;
};

Expand Down

0 comments on commit a387722

Please sign in to comment.