mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-14 04:42:03 +08:00
完善了APT包管理器后端的功能,基本实现安装
This commit is contained in:
@@ -22,11 +22,15 @@ namespace SpkUi
|
||||
|
||||
virtual void Activated() override;
|
||||
|
||||
private slots:
|
||||
|
||||
private:
|
||||
QScrollArea *mMainArea;
|
||||
QVBoxLayout *mMainLay;
|
||||
QWidget *mSettingsWidget;
|
||||
Ui::SpkUiSettings *mSettingsUi;
|
||||
|
||||
QString mRepoListUrl;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "spkpkgmgrbase.h"
|
||||
#include <QProcess>
|
||||
|
||||
class SpkPkgMgrApt : public SpkPkgMgrBase
|
||||
class SpkPkgMgrApt final : public SpkPkgMgrBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -21,10 +22,15 @@ class SpkPkgMgrApt : public SpkPkgMgrBase
|
||||
private:
|
||||
void CheckInstallerAvailability();
|
||||
|
||||
private slots:
|
||||
void InstallerExited(int, QProcess::ExitStatus);
|
||||
|
||||
private:
|
||||
QAction *mActAptitudeTerm,
|
||||
*mActAptTerm,
|
||||
*mActGdebi,
|
||||
*mActDeepinPkgInst;
|
||||
|
||||
QProcess mInstaller;
|
||||
|
||||
};
|
||||
|
||||
@@ -20,8 +20,10 @@ class SpkPkgMgrBase : public QObject
|
||||
Q_ASSERT(mInstance == nullptr);
|
||||
mInstance = this;
|
||||
|
||||
mActOpen = new QAction(tr("Open package"), this);
|
||||
mActOpenDir = new QAction(tr("Open containing directory"), this);
|
||||
mMenu = new QMenu(tr("Package Actions"));
|
||||
mMenu->addAction(mActOpen);
|
||||
mMenu->addAction(mActOpenDir);
|
||||
mMenu->setAttribute(Qt::WA_TranslucentBackground);
|
||||
mMenu->setWindowFlags(Qt::Popup | Qt::FramelessWindowHint);
|
||||
@@ -47,9 +49,12 @@ class SpkPkgMgrBase : public QObject
|
||||
*/
|
||||
virtual PkgInstallResult ExecuteInstallation(QString pkgPath, int entryId)
|
||||
{
|
||||
Q_UNUSED(entryId);
|
||||
auto item = mMenu->exec(QCursor::pos());
|
||||
if(item == mActOpenDir)
|
||||
QDesktopServices::openUrl(QUrl(SpkUtils::CutPath(pkgPath)));
|
||||
else if(item == mActOpen)
|
||||
QDesktopServices::openUrl(QUrl(pkgPath));
|
||||
return Ignored;
|
||||
}
|
||||
|
||||
@@ -60,7 +65,11 @@ class SpkPkgMgrBase : public QObject
|
||||
*/
|
||||
virtual PkgInstallResult CliInstall(QString pkgPath)
|
||||
{
|
||||
// TODO: print message
|
||||
qInfo() << tr("Spark Store cannot install your package because no supported "
|
||||
"packaging system has been found. You shall decide what you "
|
||||
"want to do with the downloaded package.\n\n"
|
||||
"File path:")
|
||||
<< pkgPath;
|
||||
return Ignored;
|
||||
}
|
||||
|
||||
@@ -68,15 +77,15 @@ class SpkPkgMgrBase : public QObject
|
||||
static SpkPkgMgrBase *Instance() { return mInstance; }
|
||||
|
||||
protected:
|
||||
QAction *mActOpenDir, *mActDesc;
|
||||
QAction *mActOpenDir, *mActOpen, *mActDesc;
|
||||
QMenu *mMenu;
|
||||
int mCurrentItemId; ///< ID of currently installing download item
|
||||
|
||||
private:
|
||||
static SpkPkgMgrBase *mInstance;
|
||||
|
||||
signals:
|
||||
void InstallationEnded(int entryId,
|
||||
SpkPkgMgrBase::PkgInstallResult success,
|
||||
QString message);
|
||||
|
||||
void ReportInstallResult(int entryId,
|
||||
SpkPkgMgrBase::PkgInstallResult result,
|
||||
int exitCode);
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "spkpkgmgrbase.h"
|
||||
|
||||
class SpkPkgMgrPacman : public SpkPkgMgrBase
|
||||
class SpkPkgMgrPacman final : public SpkPkgMgrBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
@@ -29,5 +29,7 @@ namespace SpkUtils
|
||||
QString BytesToSize(size_t s, int prec = 2);
|
||||
bool EnsureDirExists(QString path);
|
||||
|
||||
void FillWidget(QWidget* widget, QVariant val);
|
||||
bool FindViableTerminal();
|
||||
|
||||
extern QPair<QString, QString> AvailableTerminal;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user