优化对话框

This commit is contained in:
2024-01-28 22:08:26 +08:00
parent d067983c0d
commit 6d8e706e39
7 changed files with 116 additions and 22 deletions

View File

@@ -4,20 +4,42 @@
#include "messagebox.h"
#include <qtermwidget5/qtermwidget.h>
#include <QMessageBox>
#include <qapt/debfile.h>
using namespace QApt;
#include <QFile>
#include <DTitlebar>
#include <QDesktopServices>
#include <DApplication>
MainWindow::MainWindow(QWidget *parent)
: DMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
/*MessageBox *message = new MessageBox();
message->information("A", "B");
this->close();*/
//QApt::DebFile *a = new QApt::DebFile();
//DebFile *abc = new DebFile("/tmp/apt_2.6.0-1deepin5_amd64.deb");
//QMessageBox::information(this, "", abc->version());
// 自定义标题栏
DTitlebar *bar = this->titlebar();
bar->setTitle("应用安装器");
bar->setIcon(QIcon(":/Icon/deepin-wine-runner.svg"));
bar->setBackgroundTransparent(true);
QMenu *openProgramWebsite = bar->menu()->addMenu("项目地址");
QAction *openProgramGitee = new QAction(DApplication::style()->standardIcon(QStyle::SP_DirLinkOpenIcon), "Gitee");
QAction *openProgramGithub = new QAction("Github");
QAction *openProgramSourceforge = new QAction("Sourceforge");
openProgramWebsite->addAction(openProgramGitee);
openProgramWebsite->addAction(openProgramGithub);
openProgramWebsite->addAction(openProgramSourceforge);
connect(openProgramGitee, &QAction::triggered, this, [](){
QDesktopServices::openUrl(QUrl("https://gitee.com/gfdgd-xi/deep-wine-runner"));
});
connect(openProgramGithub, &QAction::triggered, this, [](){
QDesktopServices::openUrl(QUrl("https://github.com/gfdgd-xi/deep-wine-runner"));
});
connect(openProgramSourceforge, &QAction::triggered, this, [](){
QDesktopServices::openUrl(QUrl("https://sourceforge.net/project/deep-wine-runner"));
});
terminal = new QTermWidget(0);
terminal->setColorScheme("DarkPastels");
terminal->setAutoClose(0);
ui->gridLayout->addWidget(terminal, 1, 0);
}
MainWindow::~MainWindow()
@@ -28,13 +50,21 @@ MainWindow::~MainWindow()
void MainWindow::on_installPath_clicked()
{
QTermWidget *terminal = new QTermWidget(0);
terminal->setColorScheme("DarkPastels");
terminal->setAutoClose(1);
if(ui->debPath->text().replace(" ", "") == ""){
MessageBox *message = new MessageBox(this);
message->critical("提示", "您没有输入 deb 包,无法继续");
return;
}
if(!QFile::exists(ui->debPath->text())){
MessageBox *message = new MessageBox(this);
message->critical("提示", "您选择的 deb 包不存在");
return;
}
InstallDEB *deb = new InstallDEB(terminal, this);
deb->AddCommand("aptss update");
deb->AddCommand("aptss install \"" + ui->debPath->text() + "\"");
deb->AddCommand("aptss install \"" + ui->debPath->text() + "\" -y");
deb->RunCommand(1);
ui->gridLayout->addWidget(terminal, 1, 0);
}