diff --git a/Resource.qrc b/Resource.qrc index 669f148..8a64271 100644 --- a/Resource.qrc +++ b/Resource.qrc @@ -23,5 +23,6 @@ <file>Donate/Alipay.jpg</file> <file>Donate/QQ.png</file> <file>Donate/Wechat.png</file> + <file>icon/tux.png</file> </qresource> </RCC> diff --git a/gxde-kernel-manager.pro b/gxde-kernel-manager.pro index fe0dd9e..79cabea 100644 --- a/gxde-kernel-manager.pro +++ b/gxde-kernel-manager.pro @@ -12,6 +12,7 @@ SOURCES += \ aboutwindow.cpp \ aptpkginfo.cpp \ kernelinformation.cpp \ + kernelinformationdialog.cpp \ kernelinstaller.cpp \ main.cpp \ mainwindow.cpp \ @@ -21,12 +22,14 @@ HEADERS += \ aboutwindow.h \ aptpkginfo.h \ kernelinformation.h \ + kernelinformationdialog.h \ kernelinstaller.h \ mainwindow.h \ programinfo.h FORMS += \ aboutwindow.ui \ + kernelinformationdialog.ui \ kernelinstaller.ui \ mainwindow.ui diff --git a/icon/tux.png b/icon/tux.png new file mode 100644 index 0000000..f0e2895 Binary files /dev/null and b/icon/tux.png differ diff --git a/kernelinformationdialog.cpp b/kernelinformationdialog.cpp new file mode 100644 index 0000000..2c5cf9a --- /dev/null +++ b/kernelinformationdialog.cpp @@ -0,0 +1,16 @@ +#include "kernelinformationdialog.h" +#include "ui_kernelinformationdialog.h" + +KernelInformationDialog::KernelInformationDialog(QJsonObject data, QWidget *parent) : + QDialog(parent), + ui(new Ui::KernelInformationDialog) +{ + ui->setupUi(this); + // 解析数据 + +} + +KernelInformationDialog::~KernelInformationDialog() +{ + delete ui; +} diff --git a/kernelinformationdialog.h b/kernelinformationdialog.h new file mode 100644 index 0000000..0839885 --- /dev/null +++ b/kernelinformationdialog.h @@ -0,0 +1,23 @@ +#ifndef KERNELINFORMATIONDIALOG_H +#define KERNELINFORMATIONDIALOG_H + +#include <QDialog> +#include <QJsonObject> + +namespace Ui { +class KernelInformationDialog; +} + +class KernelInformationDialog : public QDialog +{ + Q_OBJECT + +public: + explicit KernelInformationDialog(QJsonObject data, QWidget *parent = nullptr); + ~KernelInformationDialog(); + +private: + Ui::KernelInformationDialog *ui; +}; + +#endif // KERNELINFORMATIONDIALOG_H diff --git a/kernelinformationdialog.ui b/kernelinformationdialog.ui new file mode 100644 index 0000000..7484d0c --- /dev/null +++ b/kernelinformationdialog.ui @@ -0,0 +1,85 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>KernelInformationDialog</class> + <widget class="QDialog" name="KernelInformationDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="linuxIconShower"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string><html><head/><body><p><img src=":/icon/tux.png"/></p></body></html></string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + </widget> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="m_kernelName"> + <property name="text"> + <string>Kernel Name:</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Kernel Version:</string> + </property> + </widget> + </item> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + </layout> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui> diff --git a/mainwindow.cpp b/mainwindow.cpp index f45d78e..ec4d28b 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -8,6 +8,8 @@ #include <QStandardItemModel> #include <qdesktopservices.h> +#include "kernelinformationdialog.h" + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) @@ -210,3 +212,23 @@ void MainWindow::on_actionDonate_triggered() QDesktopServices::openUrl(QUrl("https://gitee.com/GXDE-OS#%E8%AF%B7%E4%BD%9C%E8%80%85%E5%96%9D%E6%9D%AF%E8%8C%B6")); } + +void MainWindow::on_m_kernelShow_doubleClicked(const QModelIndex &index) +{ + // 显示具体信息 + QModelIndex list = index; + int row = list.row(); + if(row < 0) { + // 未选中任何内容 + QMessageBox::critical(this, tr("Error"), tr("Nothing to choose")); + return; + } + // 获取 ID + QModelIndex chooseIndex = ui->m_kernelShow->model()->index(row, 0); + int id = ui->m_kernelShow->model()->data(chooseIndex).toUInt(); + // 获取选中行 + KernelInformationDialog dialog(kernelInformation->get_kernelData(id)); + dialog.exec(); + +} + diff --git a/mainwindow.h b/mainwindow.h index 810f6ff..d48e22f 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -45,6 +45,8 @@ private slots: void on_actionDonate_triggered(); + void on_m_kernelShow_doubleClicked(const QModelIndex &index); + private: Ui::MainWindow *ui; KernelInformation *kernelInformation;