feat(ui): install the Flatpak files dropped or opened with PacManager
The window accepts a drop and the desktop entry's %U hands over the file the user picked, so both gestures end up as the same request. The frame asks the core which files it can install and never names a format itself; dropped files queue up because the core runs one operation at a time, and the search and log fields stop swallowing drops so a file dropped on them reaches the window. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
5 files changed
+187
No files matched your search
@@ -3,6 +3,7 @@
|
||||
#include <QHash>
|
||||
#include <QMainWindow>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QSystemTrayIcon>
|
||||
|
||||
#include <vector>
|
||||
@@ -12,8 +13,12 @@
|
||||
|
||||
class QAction;
|
||||
class QButtonGroup;
|
||||
class QDragEnterEvent;
|
||||
class QDragMoveEvent;
|
||||
class QDropEvent;
|
||||
class QFrame;
|
||||
class QLabel;
|
||||
class QMimeData;
|
||||
class QProgressBar;
|
||||
class QPushButton;
|
||||
class QStackedWidget;
|
||||
@@ -43,6 +48,19 @@ public:
|
||||
explicit MainWindow(QWidget* parent = nullptr);
|
||||
~MainWindow();
|
||||
|
||||
// Installs the Flatpak files handed over by the desktop: dropped on the
|
||||
// window, or opened from the file manager ("Ouvrir avec PacManager", which
|
||||
// passes them on the command line). One install runs at a time; the rest
|
||||
// wait in line. Paths the core does not recognise are reported and skipped.
|
||||
void installLocalFiles(const QStringList& paths);
|
||||
|
||||
protected:
|
||||
// Dragging a .flatpakref / .flatpakrepo / .flatpak onto the window is the
|
||||
// same request as opening it from the file manager.
|
||||
void dragEnterEvent(QDragEnterEvent* event) override;
|
||||
void dragMoveEvent(QDragMoveEvent* event) override;
|
||||
void dropEvent(QDropEvent* event) override;
|
||||
|
||||
private slots:
|
||||
void onNavChanged(int id);
|
||||
void onRefresh();
|
||||
@@ -117,6 +135,13 @@ private:
|
||||
void showActionError(const QString& title, const QString& error, bool locked);
|
||||
void applyCredentialMode(AppCore::CredentialMode mode);
|
||||
|
||||
// The files a drag carries that the core can install; empty when the drop is
|
||||
// nothing the app handles (which is also how dragEnterEvent refuses it).
|
||||
QStringList installableDroppedFiles(const QMimeData* mimeData) const;
|
||||
// Takes the next queued file and asks the core to install it. A core busy
|
||||
// with another operation leaves it queued: onCoreActionFinished calls back.
|
||||
void startNextFileInstall();
|
||||
|
||||
// Logic layer: it owns the providers, the workers, the history, the
|
||||
// credentials and the self-updater. The frame never talks to them directly.
|
||||
AppCore* m_core = nullptr;
|
||||
@@ -155,6 +180,11 @@ private:
|
||||
int m_progressValue = 0;
|
||||
int m_progressGeneration = 0;
|
||||
|
||||
// Files waiting to be installed (dropped or opened), and whether one is
|
||||
// being installed right now.
|
||||
QStringList m_pendingFileInstalls;
|
||||
bool m_fileInstallRunning = false;
|
||||
|
||||
// Tray (optional: hidden when the desktop has no system tray)
|
||||
QSystemTrayIcon* m_tray = nullptr;
|
||||
// Last update count already announced in a tray notification, so repeated
|
||||
|
||||
Reference in new issue
Block a user