安装模块窗口
This commit is contained in:
parent
9909e472d5
commit
cae8205d95
@ -10,17 +10,21 @@ CONFIG += c++17
|
|||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
kernelinformation.cpp \
|
kernelinformation.cpp \
|
||||||
|
kernelinstaller.cpp \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
mainwindow.cpp
|
mainwindow.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
kernelinformation.h \
|
kernelinformation.h \
|
||||||
|
kernelinstaller.h \
|
||||||
mainwindow.h
|
mainwindow.h
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
|
kernelinstaller.ui \
|
||||||
mainwindow.ui
|
mainwindow.ui
|
||||||
|
|
||||||
# Default rules for deployment.
|
# Default rules for deployment.
|
||||||
qnx: target.path = /tmp/$${TARGET}/bin
|
qnx: target.path = /tmp/$${TARGET}/bin
|
||||||
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
else: unix:!android: target.path = /opt/$${TARGET}/bin
|
||||||
!isEmpty(target.path): INSTALLS += target
|
!isEmpty(target.path): INSTALLS += target
|
||||||
|
unix:!macx: LIBS += -lqtermwidget5
|
||||||
|
38
kernelinstaller.cpp
Normal file
38
kernelinstaller.cpp
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#include "kernelinstaller.h"
|
||||||
|
#include "ui_kernelinstaller.h"
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <QFile>
|
||||||
|
|
||||||
|
#define MAX_TMP_NUM 1024
|
||||||
|
#define MIN_TMP_NUM 1024
|
||||||
|
|
||||||
|
KernelInstaller::KernelInstaller(QStringList kernelList, QWidget *parent) :
|
||||||
|
QMainWindow(parent),
|
||||||
|
ui(new Ui::KernelInstaller)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
this->kernelList = kernelList;
|
||||||
|
terminal = new QTermWidget(0);
|
||||||
|
terminal->setColorScheme("DarkPastels");
|
||||||
|
ui->verticalLayout->addWidget(terminal);
|
||||||
|
StartInstaller();
|
||||||
|
}
|
||||||
|
|
||||||
|
void KernelInstaller::StartInstaller()
|
||||||
|
{
|
||||||
|
// 随机生成目录
|
||||||
|
srand(time(0));
|
||||||
|
int randomNumber = (rand() % (MAX_TMP_NUM - MIN_TMP_NUM)) + 1; // 左闭右闭
|
||||||
|
QString tempPath = tempDir + "/gxde-kernel-manager-installer-" + QString::number(randomNumber) + ".sh";
|
||||||
|
QFile file(tempPath);
|
||||||
|
file.open(QFile::WriteOnly);
|
||||||
|
//file.write("#/bin/bash")
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
KernelInstaller::~KernelInstaller()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
30
kernelinstaller.h
Normal file
30
kernelinstaller.h
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#ifndef KERNELINSTALLER_H
|
||||||
|
#define KERNELINSTALLER_H
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
#include <qtermwidget5/qtermwidget.h>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class KernelInstaller;
|
||||||
|
}
|
||||||
|
|
||||||
|
class KernelInstaller : public QMainWindow
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit KernelInstaller(QStringList kernelList, QWidget *parent = nullptr);
|
||||||
|
~KernelInstaller();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::KernelInstaller *ui;
|
||||||
|
QTermWidget *terminal;
|
||||||
|
QStringList kernelList;
|
||||||
|
|
||||||
|
QString tempDir = "/tmp";
|
||||||
|
|
||||||
|
void StartInstaller();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // KERNELINSTALLER_H
|
49
kernelinstaller.ui
Normal file
49
kernelinstaller.ui
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>KernelInstaller</class>
|
||||||
|
<widget class="QMainWindow" name="KernelInstaller">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>800</width>
|
||||||
|
<height>600</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>MainWindow</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QWidget" name="centralwidget">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="m_statue">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QProgressBar" name="m_installProcess">
|
||||||
|
<property name="value">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="textDirection">
|
||||||
|
<enum>QProgressBar::TopToBottom</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
@ -10,19 +10,18 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
, ui(new Ui::MainWindow)
|
, ui(new Ui::MainWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
kernelInformation = new KernelInformation();
|
||||||
RefreshKernelList();
|
RefreshKernelList();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::RefreshKernelList()
|
void MainWindow::RefreshKernelList()
|
||||||
{
|
{
|
||||||
KernelInformation *information = new KernelInformation();
|
ui->m_nowKernel->setText(tr("Kernel: ") + kernelInformation->localKernelName());
|
||||||
ui->m_nowKernel->setText(tr("Kernel: ") + information->localKernelName());
|
connect(kernelInformation, &KernelInformation::loadFinished, this, [this](){
|
||||||
connect(information, &KernelInformation::loadFinished, this, [this, information](){
|
qDebug() << this->kernelInformation->get_listData();
|
||||||
qDebug() << information->get_listData();
|
RefreshKernelListView(kernelInformation);
|
||||||
RefreshKernelListView(information);
|
|
||||||
delete information;
|
|
||||||
});
|
});
|
||||||
information->LoadInfo();
|
kernelInformation->LoadInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::RefreshKernelListView(KernelInformation *info)
|
void MainWindow::RefreshKernelListView(KernelInformation *info)
|
||||||
@ -30,10 +29,11 @@ void MainWindow::RefreshKernelListView(KernelInformation *info)
|
|||||||
// 更新列表
|
// 更新列表
|
||||||
int count = info->get_count();
|
int count = info->get_count();
|
||||||
QStandardItemModel *model = new QStandardItemModel();
|
QStandardItemModel *model = new QStandardItemModel();
|
||||||
model->setHorizontalHeaderLabels(QStringList() << tr("Kernel Name") << tr("Author"));
|
model->setHorizontalHeaderLabels(QStringList() << tr("ID") << tr("Kernel Name") << tr("Author"));
|
||||||
for(int i = 0; i < count; i++) {
|
for(int i = 0; i < count; i++) {
|
||||||
model->setItem(i, 0, new QStandardItem(info->get_name(i)));
|
model->setItem(i, 0, new QStandardItem(QString::number(i)));
|
||||||
model->setItem(i, 1, new QStandardItem(info->get_author(i)));
|
model->setItem(i, 1, new QStandardItem(info->get_name(i)));
|
||||||
|
model->setItem(i, 2, new QStandardItem(info->get_author(i)));
|
||||||
}
|
}
|
||||||
ui->m_kernelShow->setModel(model);
|
ui->m_kernelShow->setModel(model);
|
||||||
}
|
}
|
||||||
@ -43,3 +43,16 @@ MainWindow::~MainWindow()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_m_refreshButton_clicked()
|
||||||
|
{
|
||||||
|
RefreshKernelList();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_m_installButton_clicked()
|
||||||
|
{
|
||||||
|
KernelInstaller *installer = new KernelInstaller(kernelInformation->get_pkgName(0));
|
||||||
|
installer->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include "kernelinformation.h"
|
#include "kernelinformation.h"
|
||||||
|
#include "kernelinstaller.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
@ -16,8 +17,14 @@ public:
|
|||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_m_refreshButton_clicked();
|
||||||
|
|
||||||
|
void on_m_installButton_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
KernelInformation *kernelInformation;
|
||||||
void RefreshKernelList();
|
void RefreshKernelList();
|
||||||
void RefreshKernelListView(KernelInformation *info);
|
void RefreshKernelListView(KernelInformation *info);
|
||||||
};
|
};
|
||||||
|
@ -16,7 +16,20 @@
|
|||||||
<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">
|
||||||
|
<property name="editTriggers">
|
||||||
|
<set>QAbstractItemView::NoEditTriggers</set>
|
||||||
|
</property>
|
||||||
|
<property name="selectionBehavior">
|
||||||
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<attribute name="verticalHeaderVisible">
|
||||||
|
<bool>false</bool>
|
||||||
|
</attribute>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
@ -41,9 +54,16 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QPushButton" name="m_refreshButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>PushButton</string>
|
<string>Refresh</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="m_installButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Install</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user