支持读取本地内核
This commit is contained in:
@@ -55,6 +55,11 @@ QString KernelInformation::get_des(int value) const
|
|||||||
return get_kernelData(value).value("Des").toString().replace("\\n", "\n");
|
return get_kernelData(value).value("Des").toString().replace("\\n", "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString KernelInformation::get_ver(int value) const
|
||||||
|
{
|
||||||
|
return get_kernelData(value).value("Ver").toString();
|
||||||
|
}
|
||||||
|
|
||||||
QStringList KernelInformation::get_pkgName(int value) const
|
QStringList KernelInformation::get_pkgName(int value) const
|
||||||
{
|
{
|
||||||
QJsonArray list = get_kernelData(value).value("PkgName").toArray();
|
QJsonArray list = get_kernelData(value).value("PkgName").toArray();
|
||||||
@@ -87,3 +92,14 @@ QStringList KernelInformation::get_arch(int value) const
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString KernelInformation::localKernelName() const
|
||||||
|
{
|
||||||
|
QProcess process;
|
||||||
|
process.start("uname", QStringList() << "-r");
|
||||||
|
process.waitForStarted();
|
||||||
|
process.waitForFinished();
|
||||||
|
QString result = process.readAllStandardOutput().replace("\n", "").replace(" ", "");
|
||||||
|
process.close();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
|
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
class KernelInformation : public QObject
|
class KernelInformation : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -25,10 +27,13 @@ public:
|
|||||||
QString get_name(int value) const;
|
QString get_name(int value) const;
|
||||||
QString get_author(int value) const;
|
QString get_author(int value) const;
|
||||||
QString get_des(int value) const;
|
QString get_des(int value) const;
|
||||||
|
QString get_ver(int value) const;
|
||||||
QStringList get_pkgName(int value) const;
|
QStringList get_pkgName(int value) const;
|
||||||
QStringList get_system(int value) const;
|
QStringList get_system(int value) const;
|
||||||
QStringList get_arch(int value) const;
|
QStringList get_arch(int value) const;
|
||||||
|
|
||||||
|
QString localKernelName() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void loadFinished(QNetworkReply *reply);
|
void loadFinished(QNetworkReply *reply);
|
||||||
|
|
||||||
|
|||||||
8
main.cpp
8
main.cpp
@@ -10,6 +10,7 @@
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
#ifdef __linux__
|
||||||
// 风险提示
|
// 风险提示
|
||||||
if(!QFile::exists(QDir::homePath() + "/.config/gxde-kernel-manager/read_already")) {
|
if(!QFile::exists(QDir::homePath() + "/.config/gxde-kernel-manager/read_already")) {
|
||||||
QMessageBox::warning(NULL, QObject::tr("Waring"), QObject::tr("It is danger because it may make your system unboot.\nPress 'OK' to countinue"));
|
QMessageBox::warning(NULL, QObject::tr("Waring"), QObject::tr("It is danger because it may make your system unboot.\nPress 'OK' to countinue"));
|
||||||
@@ -17,4 +18,11 @@ int main(int argc, char *argv[])
|
|||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
|
#else
|
||||||
|
// 其它系统不支持该工具
|
||||||
|
QMessageBox::critical(NULL, QObject::tr("Error"), QObject::tr("It unsupport Windows"));
|
||||||
|
return a.exec();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
void MainWindow::RefreshKernelList()
|
void MainWindow::RefreshKernelList()
|
||||||
{
|
{
|
||||||
KernelInformation *information = new KernelInformation();
|
KernelInformation *information = new KernelInformation();
|
||||||
|
ui->m_nowKernel->setText(tr("Kernel: ") + information->localKernelName());
|
||||||
connect(information, &KernelInformation::loadFinished, this, [this, information](){
|
connect(information, &KernelInformation::loadFinished, this, [this, information](){
|
||||||
qDebug() << information->get_listData();
|
qDebug() << information->get_listData();
|
||||||
RefreshKernelListView(information);
|
RefreshKernelListView(information);
|
||||||
|
|||||||
@@ -11,13 +11,44 @@
|
|||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>MainWindow</string>
|
<string>Kerne Manager</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralwidget">
|
<widget class="QWidget" name="centralwidget">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTableView" name="m_kernelShow"/>
|
<widget class="QTableView" name="m_kernelShow"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="m_nowKernel">
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>PushButton</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
|
|||||||
Reference in New Issue
Block a user