feat(files): confirm dropped files and refuse the ones already installed
A drop — or "Ouvrir avec PacManager" — answered nothing: a Flatpak install walked off into the background and a plugin package landed without a sound, so the gesture read as ignored. Both now open a dialog saying what was taken and what it starts. A file the machine already has is refused before anything runs, and named. The application a file would install is read out of the file itself (the [Flatpak Ref] section of a .flatpakref, the header of a .flatpak bundle, the manifest of a .fwspacm) and compared with what the provider has, so nothing is started to find out: Flatpak would otherwise skip the install and report a success the user never got, and a plugin package would silently replace the one in place.
This commit is contained in:
16 files changed
+557
-9
No files matched your search
+83
-1
@@ -1070,14 +1070,36 @@ void MainWindow::dropEvent(QDropEvent* event) {
|
||||
void MainWindow::installLocalFiles(const QStringList& paths) {
|
||||
if (paths.isEmpty()) return;
|
||||
|
||||
QStringList files;
|
||||
QStringList files; // handed to a provider, one at a time
|
||||
QStringList plugins; // installed on the spot
|
||||
QStringList installedPackages; // already on the machine: refused
|
||||
QStringList installedPlugins;
|
||||
QStringList rejected;
|
||||
|
||||
for (const QString& path : paths) {
|
||||
// A file whose application is already there is refused before anything
|
||||
// runs: flatpak would skip it and report a success the user did not
|
||||
// get, and re-installing a plugin package would silently replace the
|
||||
// one in place.
|
||||
const AppCore::FileTarget target = m_core->fileTarget(path);
|
||||
if (target.installed) {
|
||||
(target.plugin ? installedPlugins : installedPackages) << target.name;
|
||||
LogManager::instance().logEvent(
|
||||
QStringLiteral("fichier"),
|
||||
tr("%1 : déjà installé, rien à faire").arg(target.name));
|
||||
continue;
|
||||
}
|
||||
|
||||
// A plugin package is installed by the core straight away: it needs no
|
||||
// provider, no password and no queue, and the registry is reloaded when
|
||||
// it lands (see AppCore::installPluginPackage).
|
||||
if (m_core->isPluginPackage(path)) {
|
||||
m_core->installPluginPackage(path);
|
||||
// Only announced when its manifest could be read: a package the
|
||||
// reader refuses installs nothing and is reported by the Plugins
|
||||
// screen, and the window must not promise an install that is not
|
||||
// happening.
|
||||
if (!target.name.isEmpty()) plugins << path;
|
||||
continue;
|
||||
}
|
||||
if (m_core->canInstallFile(path)) files << path;
|
||||
@@ -1094,6 +1116,11 @@ void MainWindow::installLocalFiles(const QStringList& paths) {
|
||||
.arg(QFileInfo(rejected.first()).fileName()));
|
||||
}
|
||||
|
||||
// Nothing else in the window would tell the user their gesture landed: a
|
||||
// drop starts a background install, or a plugin goes in without a sound.
|
||||
announceAcceptedFiles(files, plugins);
|
||||
announceInstalledFiles(installedPackages, installedPlugins);
|
||||
|
||||
if (files.isEmpty()) return;
|
||||
|
||||
LogManager::instance().logEvent(
|
||||
@@ -1103,6 +1130,61 @@ void MainWindow::installLocalFiles(const QStringList& paths) {
|
||||
if (!m_fileInstallRunning) startNextFileInstall();
|
||||
}
|
||||
|
||||
// What the window says about the files it just took. Without it, a drop that
|
||||
// starts a background install — or a plugin that lands silently — reads as a
|
||||
// gesture the application ignored.
|
||||
void MainWindow::announceAcceptedFiles(const QStringList& installing,
|
||||
const QStringList& plugins) {
|
||||
if (installing.isEmpty() && plugins.isEmpty()) return;
|
||||
|
||||
QStringList lines;
|
||||
for (const QString& path : installing) {
|
||||
lines << tr("<b>%1</b> pris en compte : l'installation démarre, sa "
|
||||
"progression s'affiche en bas de la fenêtre.")
|
||||
.arg(QFileInfo(path).fileName());
|
||||
}
|
||||
for (const QString& path : plugins) {
|
||||
lines << tr("<b>%1</b> pris en compte : le plugin est installé et "
|
||||
"utilisable sans redémarrer.")
|
||||
.arg(QFileInfo(path).fileName());
|
||||
}
|
||||
|
||||
QMessageBox box(this);
|
||||
box.setWindowTitle(tr("Fichiers pris en compte"));
|
||||
box.setIcon(QMessageBox::Information);
|
||||
box.setTextFormat(Qt::RichText);
|
||||
box.setText(lines.join(QStringLiteral("<br>")));
|
||||
box.setStandardButtons(QMessageBox::Ok);
|
||||
box.exec();
|
||||
}
|
||||
|
||||
// The other half of the answer: a file the machine already has is refused, and
|
||||
// the user is told which one it is and what to do instead.
|
||||
void MainWindow::announceInstalledFiles(const QStringList& packages,
|
||||
const QStringList& plugins) {
|
||||
if (packages.isEmpty() && plugins.isEmpty()) return;
|
||||
|
||||
QStringList lines;
|
||||
for (const QString& name : packages) {
|
||||
lines << tr("<b>%1</b> est déjà installé : il n'y a rien à installer. "
|
||||
"Sa mise à jour se fait depuis l'écran des mises à jour.")
|
||||
.arg(name);
|
||||
}
|
||||
for (const QString& name : plugins) {
|
||||
lines << tr("<b>%1</b> : ce plugin est déjà installé. Supprimez-le "
|
||||
"depuis l'écran Extensions pour en installer un autre.")
|
||||
.arg(name);
|
||||
}
|
||||
|
||||
QMessageBox box(this);
|
||||
box.setWindowTitle(tr("Déjà installé"));
|
||||
box.setIcon(QMessageBox::Information);
|
||||
box.setTextFormat(Qt::RichText);
|
||||
box.setText(lines.join(QStringLiteral("<br>")));
|
||||
box.setStandardButtons(QMessageBox::Ok);
|
||||
box.exec();
|
||||
}
|
||||
|
||||
void MainWindow::startNextFileInstall() {
|
||||
if (m_pendingFileInstalls.isEmpty()) {
|
||||
m_fileInstallRunning = false;
|
||||
|
||||
Reference in new issue
Block a user