mirror of
https://github.com/oguzhaninan/Stacer.git
synced 2026-04-21 15:07:39 -04:00
added change apt source status
This commit is contained in:
@@ -13,7 +13,7 @@ void DiskInfo::updateDiskInfo()
|
||||
{
|
||||
disks.clear();
|
||||
try {
|
||||
QStringList result = CommandUtil::exec("df -Pl").split(QChar('\n'));
|
||||
QStringList result = CommandUtil::exec("df", { "-Pl" }).split(QChar('\n'));
|
||||
|
||||
QRegExp sep("\\s+");
|
||||
for (const QString &line : result.filter(QRegExp("^/")))
|
||||
|
||||
@@ -22,6 +22,31 @@ void AptSourceTool::removeAPTSource(const QString source)
|
||||
}
|
||||
}
|
||||
|
||||
void AptSourceTool::changeStatus(const APTSourcePtr aptSource, const bool status)
|
||||
{
|
||||
QStringList sourceFileContent = FileUtil::readListFromFile(aptSource->filePath);
|
||||
|
||||
int pos = sourceFileContent.indexOf(aptSource->source);
|
||||
|
||||
if (pos != -1) {
|
||||
QString line = sourceFileContent.at(pos);
|
||||
|
||||
line.replace("#", "").trimmed();
|
||||
|
||||
if (status) {
|
||||
sourceFileContent.replace(pos, line);
|
||||
} else {
|
||||
sourceFileContent.replace(pos, "# " + line);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList args = { aptSource->filePath };
|
||||
|
||||
QByteArray data = sourceFileContent.join('\n').toUtf8();
|
||||
|
||||
CommandUtil::sudoExec("tee", args, data);
|
||||
}
|
||||
|
||||
QList<APTSourcePtr> AptSourceTool::getSourceList()
|
||||
{
|
||||
QList<APTSourcePtr> aptSourceList;
|
||||
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
static bool checkSourceRepository();
|
||||
static QList<APTSourcePtr> getSourceList();
|
||||
static void removeAPTSource(const QString source);
|
||||
static void changeStatus(const APTSourcePtr aptSource, const bool status);
|
||||
};
|
||||
|
||||
#endif // AptSourceTool_H
|
||||
|
||||
@@ -122,5 +122,8 @@ void ToolManager::removeAPTSource(const QString source)
|
||||
AptSourceTool::removeAPTSource(source);
|
||||
}
|
||||
|
||||
|
||||
void ToolManager::changeStatus(const APTSourcePtr aptSource, const bool status)
|
||||
{
|
||||
AptSourceTool::changeStatus(aptSource, status);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ public slots:
|
||||
bool checkSourceRepository() const;
|
||||
QList<APTSourcePtr> getSourceList() const;
|
||||
void removeAPTSource(const QString source);
|
||||
void changeStatus(const APTSourcePtr aptSource, const bool status);
|
||||
|
||||
signals:
|
||||
void uninstallFinished();
|
||||
|
||||
@@ -52,5 +52,5 @@ void APTSourceRepositoryItem::on_deleteAptSourceBtn_clicked()
|
||||
|
||||
void APTSourceRepositoryItem::on_aptSourceCheck_clicked(bool checked)
|
||||
{
|
||||
|
||||
ToolManager::ins()->changeStatus(mAptSource, checked);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user