mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-15 13:22:04 +08:00
Compare commits
23 Commits
1.0beta4
...
1.0beta5.6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e387acfb6 | ||
|
|
c043542c04 | ||
|
|
25b37ec0f2 | ||
|
|
a732269b62 | ||
|
|
6d63ef60ac | ||
|
|
25456a413c | ||
|
|
ec1c91f021 | ||
|
|
46c1609d58 | ||
|
|
9c5421133f | ||
|
|
114489c3d6 | ||
|
|
101a6bc370 | ||
|
|
9b47e4dd70 | ||
|
|
6a555b06b9 | ||
|
|
145b1b8e30 | ||
|
|
23d8e9ea82 | ||
|
|
f723007166 | ||
|
|
e0639a5855 | ||
|
|
514be30e04 | ||
|
|
817d497f4a | ||
| 8158159bf9 | |||
| 82f49c4aa9 | |||
| b1c2b1bbc6 | |||
| 892766470c |
30
README.md
30
README.md
@@ -10,10 +10,36 @@ web页面部分正在开发当中,详情请见[web仓库](https://gitee.com/de
|
|||||||
|
|
||||||
```
|
```
|
||||||
http://dcstore.shenmo.tech/
|
http://dcstore.shenmo.tech/
|
||||||
http://store.shenmo.tech/
|
http://store.jerrywang.top/
|
||||||
http://store2.shenmo.tech/
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### 参数
|
||||||
|
|
||||||
|
参数只有一个Url,该url应当遵循这种格式:`spk://<任意合法字符>/web分类/包名`
|
||||||
|
|
||||||
|
例如:
|
||||||
|
|
||||||
|
[spk://abcdefg/network/firefox-zh](spk://abcdefg/network/firefox-zh)
|
||||||
|
|
||||||
|
[spk://higklmn/network/firefox-zh](spk://higklmn/network/firefox-zh)
|
||||||
|
|
||||||
|
可选的web分类:
|
||||||
|
|
||||||
|
| 分类名称 | web分类 |
|
||||||
|
| -------- | -------------- |
|
||||||
|
| 网络应用 | network |
|
||||||
|
| 社交沟通 | chat |
|
||||||
|
| 音乐欣赏 | music |
|
||||||
|
| 视频播放 | video |
|
||||||
|
| 图形图像 | image_graphics |
|
||||||
|
| 游戏娱乐 | games |
|
||||||
|
| 办公学习 | office |
|
||||||
|
| 阅读翻译 | reading |
|
||||||
|
| 编程开发 | development |
|
||||||
|
| 系统工具 | tools |
|
||||||
|
| 主题美化 | themes |
|
||||||
|
| 其他应用 | others |
|
||||||
|
|
||||||
#### 目录结构
|
#### 目录结构
|
||||||
|
|
||||||
安装软件过程中产生的包,图标,截图等被储存到`/tmp/deepin-community-store/`中。
|
安装软件过程中产生的包,图标,截图等被储存到`/tmp/deepin-community-store/`中。
|
||||||
|
|||||||
37
big_image.cpp
Normal file
37
big_image.cpp
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#include "big_image.h"
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QtConcurrent>
|
||||||
|
big_image::big_image(DBlurEffectWidget *parent) : DBlurEffectWidget(parent)
|
||||||
|
{
|
||||||
|
// m_image->setParent(this);
|
||||||
|
QHBoxLayout *layout=new QHBoxLayout;
|
||||||
|
setLayout(layout);
|
||||||
|
layout->addWidget(m_image);
|
||||||
|
layout->setMargin(0);
|
||||||
|
m_image->setAlignment(Qt::AlignCenter);
|
||||||
|
// m_image->setMaximumSize(1360,768);
|
||||||
|
setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint);//设置图片对话框总在最前
|
||||||
|
setRadius(0);
|
||||||
|
setMaskAlpha(60);
|
||||||
|
setMaskColor(QColor("#000000"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void big_image::mousePressEvent(QMouseEvent *)
|
||||||
|
{
|
||||||
|
hide();
|
||||||
|
m_image->clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void big_image::setimage(QPixmap image)
|
||||||
|
{
|
||||||
|
m_image->setPixmap(image);
|
||||||
|
}
|
||||||
|
|
||||||
|
void big_image::focusOutEvent(QFocusEvent *)
|
||||||
|
{
|
||||||
|
hide();
|
||||||
|
m_image->clear();
|
||||||
|
}
|
||||||
25
big_image.h
Normal file
25
big_image.h
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef BIG_IMAGE_H
|
||||||
|
#define BIG_IMAGE_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <DBlurEffectWidget>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QLabel>
|
||||||
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
|
class big_image : public DBlurEffectWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit big_image(DBlurEffectWidget *parent = nullptr);
|
||||||
|
void mousePressEvent(QMouseEvent *event);
|
||||||
|
QLabel *m_image=new QLabel;
|
||||||
|
void setimage(QPixmap);
|
||||||
|
void focusOutEvent(QFocusEvent *event);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // BIG_IMAGE_H
|
||||||
190
downloadlist.cpp
190
downloadlist.cpp
@@ -5,6 +5,7 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <QTextBrowser>
|
||||||
bool downloadlist::isInstall=false;
|
bool downloadlist::isInstall=false;
|
||||||
|
|
||||||
downloadlist::downloadlist(QWidget *parent) :
|
downloadlist::downloadlist(QWidget *parent) :
|
||||||
@@ -12,12 +13,19 @@ downloadlist::downloadlist(QWidget *parent) :
|
|||||||
ui(new Ui::downloadlist)
|
ui(new Ui::downloadlist)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->pushButton->setEnabled(false);
|
ui->pushButton_install->setEnabled(false);
|
||||||
ui->progressBar->setValue(0);
|
ui->progressBar->setValue(0);
|
||||||
ui->label_filename->hide();
|
ui->label_filename->hide();
|
||||||
ui->pushButton->hide();
|
ui->pushButton_install->hide();
|
||||||
ui->pushButton_3->hide();
|
ui->pushButton_3->hide();
|
||||||
ui->label->setStyleSheet("color:#000000");
|
ui->widget_spinner->start();
|
||||||
|
ui->widget_spinner->hide();
|
||||||
|
action_dpkg->setText("dpkg");
|
||||||
|
action_gdebi->setText("gdebi");
|
||||||
|
connect(action_dpkg,&QAction::triggered,[=](){downloadlist::install(1);});
|
||||||
|
connect(action_gdebi,&QAction::triggered,[=](){downloadlist::install(0);});
|
||||||
|
menu_install->addAction(action_gdebi);
|
||||||
|
menu_install->addAction(action_dpkg);
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadlist::~downloadlist()
|
downloadlist::~downloadlist()
|
||||||
@@ -27,16 +35,16 @@ downloadlist::~downloadlist()
|
|||||||
|
|
||||||
void downloadlist::setValue(long long value)
|
void downloadlist::setValue(long long value)
|
||||||
{
|
{
|
||||||
ui->progressBar->setValue(value);
|
ui->progressBar->setValue(int(value));
|
||||||
ui->label_2->setText(QString::number((double)value/100)+"% ("+speed+")");
|
ui->label_2->setText(QString::number(double(value)/100)+"% ("+speed+")");
|
||||||
if(ui->label_2->text()=="100%"){
|
if(ui->label_2->text().left(4)=="100%"){
|
||||||
ui->label_2->setText("已完成,等待安装");
|
ui->label_2->setText("已完成,等待安装");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void downloadlist::setMax(long long max)
|
void downloadlist::setMax(long long max)
|
||||||
{
|
{
|
||||||
ui->progressBar->setMaximum(max);
|
ui->progressBar->setMaximum(int(max));
|
||||||
}
|
}
|
||||||
|
|
||||||
void downloadlist::setName(QString name)
|
void downloadlist::setName(QString name)
|
||||||
@@ -51,24 +59,24 @@ QString downloadlist::getName()
|
|||||||
|
|
||||||
void downloadlist::readyInstall()
|
void downloadlist::readyInstall()
|
||||||
{
|
{
|
||||||
|
if(ui->progressBar->value()!= ui->progressBar->maximum() && !close){
|
||||||
|
ui->progressBar->hide();
|
||||||
|
ui->pushButton_install->show();
|
||||||
|
ui->pushButton_2->hide();
|
||||||
|
system("notify-send \""+ui->label->text().toUtf8()+"下载失败\"" +" --icon=/tmp/spark-store/icon_"+QString::number(num).toUtf8()+".png");
|
||||||
|
ui->label_2->setText("下载失败,可能是网络错误");
|
||||||
|
ui->pushButton_install->setEnabled(false);
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
if(!close){
|
if(!close){
|
||||||
ui->progressBar->hide();
|
ui->progressBar->hide();
|
||||||
ui->pushButton->setEnabled(true);
|
ui->pushButton_install->setEnabled(true);
|
||||||
ui->pushButton->show();
|
ui->pushButton_install->show();
|
||||||
ui->pushButton_2->hide();
|
ui->pushButton_2->hide();
|
||||||
system("notify-send \""+ui->label->text().toUtf8()+"下载完成,等待安装\"" +" --icon=/tmp/deepin-community-store/icon_"+QString::number(num).toUtf8()+".png");
|
system("notify-send \""+ui->label->text().toUtf8()+"下载完成,等待安装\"" +" --icon=/tmp/spark-store/icon_"+QString::number(num).toUtf8()+".png");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void downloadlist::choose(bool isChoosed)
|
|
||||||
{
|
|
||||||
if(isChoosed){
|
|
||||||
ui->label->setStyleSheet("color:#FFFFFF");
|
|
||||||
ui->label_2->setStyleSheet("color:#FFFFFF");
|
|
||||||
}else {
|
|
||||||
ui->label->setStyleSheet("color:#000000");
|
|
||||||
ui->label_2->setStyleSheet("color:#000000");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void downloadlist::setFileName(QString fileName)
|
void downloadlist::setFileName(QString fileName)
|
||||||
@@ -91,55 +99,149 @@ void downloadlist::setSpeed(QString s)
|
|||||||
speed=s;
|
speed=s;
|
||||||
}
|
}
|
||||||
|
|
||||||
void downloadlist::on_pushButton_clicked()
|
void downloadlist::install(int t)
|
||||||
{
|
{
|
||||||
if(!isInstall){
|
if(!isInstall){
|
||||||
isInstall=true;
|
isInstall=true;
|
||||||
ui->pushButton->setEnabled(false);
|
ui->pushButton_install->hide();
|
||||||
|
ui->widget_spinner->show();
|
||||||
|
qDebug()<<"/tmp/spark-store/"+ui->label_filename->text().toUtf8();
|
||||||
ui->label_2->setText("正在安装,请稍候");
|
ui->label_2->setText("正在安装,请稍候");
|
||||||
QtConcurrent::run([=](){
|
QtConcurrent::run([=](){
|
||||||
QProcess installer;
|
QProcess installer;
|
||||||
if(reinstall){
|
if(reinstall){
|
||||||
installer.start("pkexec apt reinstall -y /tmp/deepin-community-store/"+ui->label_filename->text().toUtf8());
|
if(t==0){
|
||||||
|
installer.start("pkexec gdebi -n /tmp/spark-store/"+ui->label_filename->text().toUtf8());
|
||||||
|
}else {
|
||||||
|
installer.start("pkexec ssinstall /tmp/spark-store/"+ui->label_filename->text().toUtf8());
|
||||||
|
}
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
installer.start("pkexec apt install -y /tmp/deepin-community-store/"+ui->label_filename->text().toUtf8());
|
if(t==0){
|
||||||
|
installer.start("pkexec gdebi -n /tmp/spark-store/"+ui->label_filename->text().toUtf8());
|
||||||
|
}else {
|
||||||
|
installer.start("pkexec ssinstall /tmp/spark-store/"+ui->label_filename->text().toUtf8());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
installer.waitForFinished();
|
installer.waitForFinished();
|
||||||
QString error=QString::fromStdString(installer.readAllStandardError().toStdString());
|
|
||||||
out=installer.readAllStandardOutput();
|
out=installer.readAllStandardOutput();
|
||||||
QStringList everyError=error.split("\n");
|
QStringList everyOut=out.split("\n");
|
||||||
bool haveError=false;
|
bool haveError=false;
|
||||||
bool notRoot=false;
|
bool notRoot=false;
|
||||||
for (int i=0;i<everyError.size();i++) {
|
for (int i=0;i<everyOut.size();i++) {
|
||||||
qDebug()<<everyError[i].left(2);
|
qDebug()<<everyOut[i].left(2);
|
||||||
if(everyError[i].left(2)=="E:"){
|
if(everyOut[i].left(2)=="E:"){
|
||||||
haveError=true;
|
haveError=true;
|
||||||
}
|
}
|
||||||
if(everyError[i].right(14)=="Not authorized"){
|
if(everyOut[i].right(14)=="Not authorized"){
|
||||||
notRoot=true;
|
notRoot=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!haveError && !notRoot){
|
QProcess isInstall;
|
||||||
ui->pushButton->hide();
|
isInstall.start("dpkg -s "+pkgName);
|
||||||
|
isInstall.waitForFinished();
|
||||||
|
int error=QString::fromStdString(isInstall.readAllStandardError().toStdString()).length();
|
||||||
|
if(error==0){
|
||||||
|
ui->pushButton_install->hide();
|
||||||
ui->label_2->setText("安装完成");
|
ui->label_2->setText("安装完成");
|
||||||
ui->pushButton_3->show();
|
ui->pushButton_3->show();
|
||||||
}else if(haveError){
|
|
||||||
ui->pushButton->hide();
|
|
||||||
ui->label_2->setText("安装出现错误");
|
|
||||||
ui->pushButton_3->show();
|
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
ui->label_2->setText("安装被终止");
|
ui->pushButton_install->show();
|
||||||
ui->pushButton->setEnabled(true);
|
ui->pushButton_install->setText("重装");
|
||||||
|
ui->label_2->setText("安装出现错误,可重新安装");
|
||||||
|
ui->pushButton_3->show();
|
||||||
}
|
}
|
||||||
isInstall=false;
|
if(notRoot){
|
||||||
|
ui->label_2->setText("安装被终止,可重新安装");
|
||||||
|
ui->pushButton_install->show();
|
||||||
|
ui->pushButton_3->hide();
|
||||||
|
}
|
||||||
|
ui->widget_spinner->hide();
|
||||||
|
downloadlist::isInstall=false;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
qDebug()<<ui->label_filename->text().toUtf8();
|
qDebug()<<ui->label_filename->text().toUtf8();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void downloadlist::on_pushButton_install_clicked()
|
||||||
|
{
|
||||||
|
//弹出菜单
|
||||||
|
// menu_install->show();
|
||||||
|
menu_install->exec(cursor().pos());
|
||||||
|
}
|
||||||
|
void downloadlist::on_pushButton_maninst_clicked()
|
||||||
|
{
|
||||||
|
if(!isInstall)
|
||||||
|
{
|
||||||
|
isInstall = true;
|
||||||
|
ui->pushButton_install->hide();
|
||||||
|
ui->widget_spinner->show();
|
||||||
|
qDebug() << "/tmp/spark-store/" + ui->label_filename->text().toUtf8();
|
||||||
|
ui->label_2->setText("正在安装,请稍候");
|
||||||
|
QtConcurrent::run([=]()
|
||||||
|
{
|
||||||
|
QProcess installer;
|
||||||
|
if(reinstall)
|
||||||
|
{
|
||||||
|
installer.start("pkexec apt reinstall /tmp/spark-store/" + ui->label_filename->text().toUtf8());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
installer.start("pkexec apt install /tmp/spark-store/" + ui->label_filename->text().toUtf8());
|
||||||
|
}
|
||||||
|
installer.waitForFinished();
|
||||||
|
out = installer.readAllStandardOutput();
|
||||||
|
installer.close();
|
||||||
|
QStringList everyOut = out.split("\n");
|
||||||
|
bool haveError = false;
|
||||||
|
bool notRoot = false;
|
||||||
|
for (int i = 0; i < everyOut.size(); i++)
|
||||||
|
{
|
||||||
|
qDebug() << everyOut[i].left(2);
|
||||||
|
if(everyOut[i].left(2) == "E:")
|
||||||
|
{
|
||||||
|
haveError = true;
|
||||||
|
}
|
||||||
|
if(everyOut[i].right(14) == "Not authorized")
|
||||||
|
{
|
||||||
|
notRoot = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QProcess isInstall;
|
||||||
|
isInstall.start("dpkg -s " + pkgName);
|
||||||
|
isInstall.waitForFinished();
|
||||||
|
int error = QString::fromStdString(isInstall.readAllStandardError().toStdString()).length();
|
||||||
|
isInstall.close();
|
||||||
|
if(error == 0)
|
||||||
|
{
|
||||||
|
ui->pushButton_install->hide();
|
||||||
|
ui->label_2->setText("安装完成");
|
||||||
|
ui->pushButton_3->show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->pushButton_install->show();
|
||||||
|
ui->pushButton_install->setText("重装");
|
||||||
|
ui->label_2->setText("安装出现错误,可重新安装");
|
||||||
|
ui->pushButton_3->show();
|
||||||
|
}
|
||||||
|
if(notRoot)
|
||||||
|
{
|
||||||
|
ui->label_2->setText("安装被终止,可重新安装");
|
||||||
|
ui->pushButton_install->show();
|
||||||
|
ui->pushButton_3->hide();
|
||||||
|
}
|
||||||
|
ui->widget_spinner->hide();
|
||||||
|
downloadlist::isInstall = false;
|
||||||
|
});
|
||||||
|
qDebug() << ui->label_filename->text().toUtf8();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void downloadlist::on_pushButton_2_clicked()
|
void downloadlist::on_pushButton_2_clicked()
|
||||||
{
|
{
|
||||||
ui->label_2->setText("已取消下载");
|
ui->label_2->setText("已取消下载");
|
||||||
@@ -150,6 +252,12 @@ void downloadlist::on_pushButton_2_clicked()
|
|||||||
|
|
||||||
void downloadlist::on_pushButton_3_clicked()
|
void downloadlist::on_pushButton_3_clicked()
|
||||||
{
|
{
|
||||||
output_w.setoutput(out);
|
output_w.layout()->addWidget(textbrowser);
|
||||||
|
textbrowser->setLineWidth(0);
|
||||||
|
textbrowser->setText(out);
|
||||||
|
output_w.layout()->setMargin(20);
|
||||||
|
output_w.setTitle(ui->label->text());
|
||||||
|
output_w.setMinimumHeight(600);
|
||||||
|
output_w.setAttribute(Qt::WA_TranslucentBackground);
|
||||||
output_w.show();
|
output_w.show();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,11 @@
|
|||||||
#define DOWNLOADLIST_H
|
#define DOWNLOADLIST_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <outputwindow.h>
|
#include <DDialog>
|
||||||
|
#include <QTextBrowser>
|
||||||
|
#include <QMenu>
|
||||||
|
#include <QAction>
|
||||||
|
DWIDGET_USE_NAMESPACE
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class downloadlist;
|
class downloadlist;
|
||||||
}
|
}
|
||||||
@@ -19,7 +23,6 @@ public:
|
|||||||
void setName(QString);
|
void setName(QString);
|
||||||
QString getName();
|
QString getName();
|
||||||
void readyInstall();
|
void readyInstall();
|
||||||
void choose(bool);
|
|
||||||
bool free;
|
bool free;
|
||||||
void setFileName(QString);
|
void setFileName(QString);
|
||||||
void seticon(const QPixmap);
|
void seticon(const QPixmap);
|
||||||
@@ -28,14 +31,18 @@ public:
|
|||||||
int num;
|
int num;
|
||||||
bool close=false;
|
bool close=false;
|
||||||
QString out;
|
QString out;
|
||||||
outputwindow output_w;
|
DDialog output_w;
|
||||||
|
QTextBrowser *textbrowser=new QTextBrowser;
|
||||||
bool reinstall=false;
|
bool reinstall=false;
|
||||||
|
QString pkgName;
|
||||||
|
QMenu *menu_install=new QMenu;
|
||||||
|
QAction *action_gdebi=new QAction;
|
||||||
|
QAction *action_dpkg=new QAction;
|
||||||
|
void install(int);
|
||||||
private slots:
|
private slots:
|
||||||
void on_pushButton_clicked();
|
void on_pushButton_install_clicked();
|
||||||
|
void on_pushButton_maninst_clicked();
|
||||||
void on_pushButton_2_clicked();
|
void on_pushButton_2_clicked();
|
||||||
|
|
||||||
|
|
||||||
void on_pushButton_3_clicked();
|
void on_pushButton_3_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -6,10 +6,16 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>786</width>
|
<width>776</width>
|
||||||
<height>54</height>
|
<height>54</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>16777215</width>
|
||||||
|
<height>54</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -17,11 +23,26 @@
|
|||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>2</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>4</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>48</width>
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@@ -33,6 +54,22 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_filename">
|
<widget class="QLabel" name="label_filename">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
@@ -50,7 +87,7 @@
|
|||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>150</width>
|
<width>80</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@@ -71,7 +108,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
@@ -80,7 +117,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>20</width>
|
||||||
<height>20</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@@ -90,7 +127,7 @@
|
|||||||
<widget class="QWidget" name="widget" native="true">
|
<widget class="QWidget" name="widget" native="true">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>350</width>
|
<width>280</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@@ -123,7 +160,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>350</width>
|
<width>300</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@@ -160,7 +197,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer_2">
|
<spacer name="horizontalSpacer_3">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
@@ -176,7 +213,17 @@
|
|||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="DSpinner" name="widget_spinner" native="true">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>30</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="pushButton_install">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>60</width>
|
<width>60</width>
|
||||||
@@ -234,6 +281,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>DSpinner</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header location="global">dspinner.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
53
image_show.cpp
Normal file
53
image_show.cpp
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#include "image_show.h"
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <DDialog>
|
||||||
|
#include <DBlurEffectWidget>
|
||||||
|
#include <DWidgetUtil>
|
||||||
|
#include <DApplication>
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
DWIDGET_USE_NAMESPACE
|
||||||
|
image_show::image_show(QWidget *parent) : QWidget(parent)
|
||||||
|
{
|
||||||
|
QHBoxLayout *layout=new QHBoxLayout;
|
||||||
|
layout->addWidget(m_label);
|
||||||
|
setLayout(layout);
|
||||||
|
m_label->setText("layout");
|
||||||
|
}
|
||||||
|
|
||||||
|
void image_show::setImage(QPixmap image)
|
||||||
|
{
|
||||||
|
|
||||||
|
QImage screen0;
|
||||||
|
screen0=image.toImage();
|
||||||
|
// QPainter painter(&screen0);
|
||||||
|
QImage re_screen1;
|
||||||
|
QImage re_screen0=screen0.scaled(QSize(400,300),Qt::KeepAspectRatio,Qt::SmoothTransformation);
|
||||||
|
int desktop_w=DApplication::desktop()->width();
|
||||||
|
int desktop_h=DApplication::desktop()->height();
|
||||||
|
if(screen0.width()>(desktop_w-20) || screen0.height()>(desktop_h-20)){
|
||||||
|
re_screen1=screen0.scaled(QSize(desktop_w-20,desktop_h-20),Qt::KeepAspectRatio,Qt::SmoothTransformation);
|
||||||
|
m_image=QPixmap::fromImage(re_screen1);
|
||||||
|
}else {
|
||||||
|
m_image=image;
|
||||||
|
}
|
||||||
|
//防止图片尺寸过大导致窗口覆盖整个屏幕
|
||||||
|
// if(screen0.width()>1024 || screen0.height()>768){
|
||||||
|
// re_screen1=screen0.scaled(QSize(1024,768),Qt::KeepAspectRatio,Qt::SmoothTransformation);
|
||||||
|
// }else {
|
||||||
|
// re_screen1=screen0;
|
||||||
|
|
||||||
|
// }
|
||||||
|
// m_image=QPixmap::fromImage(re_screen1);
|
||||||
|
|
||||||
|
m_label->setPixmap(QPixmap::fromImage(re_screen0));
|
||||||
|
}
|
||||||
|
|
||||||
|
void image_show::mousePressEvent(QMouseEvent *)
|
||||||
|
{
|
||||||
|
m_dialog->setimage(m_image);
|
||||||
|
m_dialog->showFullScreen();
|
||||||
|
moveToCenter(m_dialog);
|
||||||
|
|
||||||
|
}
|
||||||
30
image_show.h
Normal file
30
image_show.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#ifndef IMAGE_SHOW_H
|
||||||
|
#define IMAGE_SHOW_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QMouseEvent>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <DDialog>
|
||||||
|
#include <DBlurEffectWidget>
|
||||||
|
#include <big_image.h>
|
||||||
|
DWIDGET_USE_NAMESPACE
|
||||||
|
class image_show : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit image_show(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
void setImage(QPixmap);
|
||||||
|
private:
|
||||||
|
QLabel *m_label=new QLabel;
|
||||||
|
QPixmap m_image;
|
||||||
|
QLabel image;
|
||||||
|
big_image *m_dialog=new big_image;
|
||||||
|
void mousePressEvent(QMouseEvent *event);
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // IMAGE_SHOW_H
|
||||||
43
main.cpp
43
main.cpp
@@ -1,7 +1,7 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <DApplication>
|
#include <DApplication>
|
||||||
#include <DWidgetUtil> //Dtk::Widget::moveToCenter(&w); 要调用它,就得引用DWidgetUtil
|
#include <DWidgetUtil> //Dtk::Widget::moveToCenter(&w); 要调用它,就得引用DWidgetUtil
|
||||||
|
#include <QDesktopWidget>
|
||||||
DWIDGET_USE_NAMESPACE
|
DWIDGET_USE_NAMESPACE
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@@ -9,19 +9,46 @@ int main(int argc, char *argv[])
|
|||||||
DApplication a(argc, argv);
|
DApplication a(argc, argv);
|
||||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||||
a.loadTranslator();
|
a.loadTranslator();
|
||||||
a.setOrganizationName("community");
|
a.setOrganizationName("spark-union");
|
||||||
a.setApplicationVersion(DApplication::buildVersion("1.0-beta3.2"));
|
a.setApplicationVersion(DApplication::buildVersion("1.0-beta5.6"));
|
||||||
a.setApplicationAcknowledgementPage("https://gitee.com/deepin-community-store/deepin-community-store");
|
a.setApplicationAcknowledgementPage("https://gitee.com/deepin-community-store/spark-store");
|
||||||
a.setProductIcon(QIcon::fromTheme("spark-store")); //设置Logo
|
a.setProductIcon(QIcon::fromTheme("spark-store")); //设置Logo
|
||||||
a.setProductName("星火应用商店");
|
|
||||||
a.setApplicationName("星火应用商店"); //只有在这儿修改窗口标题才有效
|
|
||||||
|
|
||||||
|
a.setProductName("Spark应用商店");
|
||||||
|
a.setApplicationDescription("深度社区驱动的一款为deepin打造的第三方商店");
|
||||||
|
a.setApplicationName("Spark应用商店"); //只有在这儿修改窗口标题才有效
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
QDesktopWidget *s=DApplication::desktop();
|
||||||
|
int d_w=s->width();
|
||||||
|
int d_h=s->height();
|
||||||
|
if(d_w<=1366){
|
||||||
|
w.setMinimumWidth(820);
|
||||||
|
w.resize(820,640);
|
||||||
|
}else if(d_w<=1920){
|
||||||
|
w.setMinimumWidth(1140);
|
||||||
|
w.resize(1140,760);
|
||||||
|
}else {
|
||||||
|
w.setMinimumWidth(1140);
|
||||||
|
w.resize(1140,760);
|
||||||
|
}
|
||||||
|
if(d_h<=768){
|
||||||
|
w.setMinimumHeight(640);
|
||||||
|
w.resize(820,640);
|
||||||
|
}else if(d_h<=1080){
|
||||||
|
w.setMinimumHeight(760);
|
||||||
|
w.resize(1140,760);
|
||||||
|
}else {
|
||||||
|
w.setMinimumHeight(760);
|
||||||
|
w.resize(1140,760);
|
||||||
|
}
|
||||||
|
|
||||||
|
w.show();
|
||||||
|
QString arg1=argv[1];
|
||||||
|
if(arg1.left(6)=="spk://"){
|
||||||
|
w.openUrl(QUrl(argv[1]));
|
||||||
|
}
|
||||||
//让打开时界面显示在正中
|
//让打开时界面显示在正中
|
||||||
Dtk::Widget::moveToCenter(&w);
|
Dtk::Widget::moveToCenter(&w);
|
||||||
|
|
||||||
|
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,12 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include <DMainWindow>
|
#include <DMainWindow>
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
#include <DTitlebar>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <DFileServices>
|
||||||
|
#include <DApplicationHelper>
|
||||||
DWIDGET_USE_NAMESPACE
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent)
|
MainWindow::MainWindow(QWidget *parent)
|
||||||
@@ -10,11 +15,55 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
w = new Widget;
|
w = new Widget;
|
||||||
|
|
||||||
resize(w->size()); //设置窗口大小
|
resize(w->size()); //设置窗口大小
|
||||||
setMinimumSize(950,700);
|
|
||||||
setCentralWidget(w);
|
setCentralWidget(w);
|
||||||
// searchEdit->setParent(this);
|
|
||||||
// searchEdit->move(1,1);
|
//添加搜索框
|
||||||
// searchEdit->show();
|
DMainWindow::titlebar()->addWidget(searchEdit);
|
||||||
|
DMainWindow::titlebar()->setIcon(QIcon::fromTheme("spark-store"));
|
||||||
|
DMainWindow::titlebar()->setTitle("星火应用商店");
|
||||||
|
searchEdit->setPlaceholderText("搜索或打开链接");
|
||||||
|
searchEdit->setMaximumWidth(300);
|
||||||
|
|
||||||
|
//添加菜单项
|
||||||
|
QAction *setting=new QAction("设置");
|
||||||
|
QMenu *menu=new QMenu;
|
||||||
|
menu->addAction(setting);
|
||||||
|
DMainWindow::titlebar()->setMenu(menu);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// connect(DGuiApplicationHelper::instance(),&DGuiApplicationHelper::instance()->applicationPalette().highlight().color()::)
|
||||||
|
|
||||||
|
|
||||||
|
//链接信号和槽
|
||||||
|
|
||||||
|
//设置活动颜色和明暗模式
|
||||||
|
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [=](DGuiApplicationHelper::ColorType themeType) {
|
||||||
|
QColor main_color;
|
||||||
|
main_color=DGuiApplicationHelper::instance()->applicationPalette().highlight().color();
|
||||||
|
if(themeType==DGuiApplicationHelper::DarkType){
|
||||||
|
qDebug()<<"Dark";
|
||||||
|
w->setTheme(true,main_color);
|
||||||
|
}else {
|
||||||
|
qDebug()<<"White";
|
||||||
|
w->setTheme(false,main_color);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//设置菜单
|
||||||
|
connect(setting,&QAction::triggered,w,&Widget::opensetting);
|
||||||
|
//搜索事件
|
||||||
|
connect(searchEdit,&DSearchEdit::editingFinished,this,[=](){
|
||||||
|
QString searchtext=searchEdit->text();
|
||||||
|
if(searchtext!=""){
|
||||||
|
qDebug()<<searchEdit->text();
|
||||||
|
w->searchApp(searchtext);
|
||||||
|
}
|
||||||
|
searchEdit->clearEdit();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@@ -22,3 +71,9 @@ MainWindow::~MainWindow()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::openUrl(QUrl url)
|
||||||
|
{
|
||||||
|
w->openUrl(url);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <DSearchEdit>
|
#include <DSearchEdit>
|
||||||
|
#include <DBlurEffectWidget>
|
||||||
|
#include <DTitlebar>
|
||||||
DWIDGET_USE_NAMESPACE
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
class MainWindow : public DMainWindow
|
class MainWindow : public DMainWindow
|
||||||
@@ -15,7 +17,10 @@ class MainWindow : public DMainWindow
|
|||||||
public:
|
public:
|
||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent = nullptr);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
// DSearchEdit *searchEdit=new DSearchEdit;
|
DSearchEdit *searchEdit=new DSearchEdit;
|
||||||
|
DTitlebar *titlebar=new DTitlebar;
|
||||||
|
void openUrl(QUrl);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
Widget *w;
|
Widget *w;
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
#include "outputwindow.h"
|
|
||||||
#include "ui_outputwindow.h"
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDesktopWidget>
|
|
||||||
outputwindow::outputwindow(QWidget *parent) :
|
|
||||||
QWidget(parent),
|
|
||||||
ui(new Ui::outputwindow)
|
|
||||||
{
|
|
||||||
ui->setupUi(this);
|
|
||||||
setWindowTitle("安装详情");
|
|
||||||
QDesktopWidget *desktop = QApplication::desktop();
|
|
||||||
move((desktop->width() - width())/ 2, (desktop->height() - height()) /2);
|
|
||||||
}
|
|
||||||
|
|
||||||
outputwindow::~outputwindow()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
|
|
||||||
void outputwindow::setoutput(QString output)
|
|
||||||
{
|
|
||||||
qDebug()<<output;
|
|
||||||
ui->textBrowser->setText(output);
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
#ifndef OUTPUTWINDOW_H
|
|
||||||
#define OUTPUTWINDOW_H
|
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
|
|
||||||
namespace Ui {
|
|
||||||
class outputwindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
class outputwindow : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit outputwindow(QWidget *parent = nullptr);
|
|
||||||
~outputwindow();
|
|
||||||
void setoutput(QString);
|
|
||||||
private:
|
|
||||||
Ui::outputwindow *ui;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // OUTPUTWINDOW_H
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>outputwindow</class>
|
|
||||||
<widget class="QWidget" name="outputwindow">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>391</width>
|
|
||||||
<height>372</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Form</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QTextBrowser" name="textBrowser"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections/>
|
|
||||||
</ui>
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
http://dcstore.shenmo.tech/
|
|
||||||
http://store.shenmo.tech/
|
|
||||||
http://store2.shenmo.tech/
|
|
||||||
http://store.moshengren.xyz/
|
|
||||||
http://127.0.0.1:8000/#/
|
|
||||||
@@ -27,12 +27,14 @@ SOURCES += main.cpp\
|
|||||||
mainwindow.cpp \
|
mainwindow.cpp \
|
||||||
widget.cpp \
|
widget.cpp \
|
||||||
downloadlist.cpp \
|
downloadlist.cpp \
|
||||||
outputwindow.cpp
|
image_show.cpp \
|
||||||
|
big_image.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h \
|
HEADERS += mainwindow.h \
|
||||||
widget.h \
|
widget.h \
|
||||||
downloadlist.h \
|
downloadlist.h \
|
||||||
outputwindow.h
|
image_show.h \
|
||||||
|
big_image.h
|
||||||
|
|
||||||
CONFIG += link_pkgconfig
|
CONFIG += link_pkgconfig
|
||||||
PKGCONFIG += dtkwidget
|
PKGCONFIG += dtkwidget
|
||||||
@@ -41,5 +43,4 @@ CONFIG += c++11
|
|||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
widget.ui \
|
widget.ui \
|
||||||
downloadlist.ui \
|
downloadlist.ui
|
||||||
outputwindow.ui
|
|
||||||
|
|||||||
2
ssinstall
Executable file
2
ssinstall
Executable file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
dpkg -i $1 || apt install -yf || dpkg -P $1
|
||||||
715
widget.cpp
715
widget.cpp
@@ -18,84 +18,41 @@
|
|||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QWebFrame>
|
#include <QWebFrame>
|
||||||
#include <QGraphicsOpacityEffect>
|
#include <QGraphicsOpacityEffect>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <DSettings>
|
||||||
|
#include <DSettingsOption>
|
||||||
|
#include <DSettingsDialog>
|
||||||
|
#include "image_show.h"
|
||||||
|
#include <DBlurEffectWidget>
|
||||||
|
#include <QClipboard>
|
||||||
|
#include <DGuiApplicationHelper>
|
||||||
|
DWIDGET_USE_NAMESPACE
|
||||||
|
|
||||||
Widget::Widget(QWidget *parent) :
|
Widget::Widget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::Widget)
|
ui(new Ui::Widget)
|
||||||
{
|
{
|
||||||
QString serverUrl;
|
|
||||||
std::fstream server;
|
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);//用来激活接受linkClicked信号
|
initUI();
|
||||||
ui->webView->page()->settings()->setAttribute(QWebSettings::JavascriptEnabled,true);
|
initConfig();
|
||||||
ui->stackedWidget->setCurrentIndex(0);
|
manager = new QNetworkAccessManager(this);//下载管理
|
||||||
ui->listWidget->hide();
|
|
||||||
ui->label_setting1->hide();
|
|
||||||
manager = new QNetworkAccessManager(this);
|
|
||||||
left_list[0]=ui->menu_btn_main;left_menu_bg[0]=ui->menu_bg_main;
|
|
||||||
left_list[1]=ui->menu_btn_network;left_menu_bg[1]=ui->menu_bg_network;
|
|
||||||
left_list[2]=ui->menu_btn_chat;left_menu_bg[2]=ui->menu_bg_chat;
|
|
||||||
left_list[3]=ui->menu_btn_music;left_menu_bg[3]=ui->menu_bg_music;
|
|
||||||
left_list[4]=ui->menu_btn_video;left_menu_bg[4]=ui->menu_bg_video;
|
|
||||||
left_list[5]=ui->menu_btn_photo;left_menu_bg[5]=ui->menu_bg_photo;
|
|
||||||
left_list[6]=ui->menu_btn_game;left_menu_bg[6]=ui->menu_bg_game;
|
|
||||||
left_list[7]=ui->menu_btn_office;left_menu_bg[7]=ui->menu_bg_office;
|
|
||||||
left_list[8]=ui->menu_btn_read;left_menu_bg[8]=ui->menu_bg_read;
|
|
||||||
left_list[9]=ui->menu_btn_dev;left_menu_bg[9]=ui->menu_bg_dev;
|
|
||||||
left_list[10]=ui->menu_btn_system;left_menu_bg[10]=ui->menu_bg_system;
|
|
||||||
left_list[11]=ui->menu_btn_other;left_menu_bg[11]=ui->menu_bg_other;
|
|
||||||
left_list[12]=ui->menu_btn_theme;left_menu_bg[12]=ui->menu_bg_theme;
|
|
||||||
left_list[13]=ui->menu_btn_download;left_menu_bg[13]=ui->menu_bg_download;
|
|
||||||
left_list[14]=ui->menu_btn_settings;left_menu_bg[14]=ui->menu_bg_settings;
|
|
||||||
server.open(QDir::homePath().toUtf8()+"/.config/deepin-community-store/server.list",std::ios::in);
|
|
||||||
// system("mkdir /etc/deepin-community-store/");
|
|
||||||
// server.open("/etc/deepin-community-store/server.list",std::ios::in);
|
|
||||||
std::string lineTmp;
|
|
||||||
|
|
||||||
if(server){
|
connect(ui->menu_main,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(0);});
|
||||||
while (getline(server,lineTmp)) {
|
connect(ui->menu_network,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(1);});
|
||||||
ui->comboBox_server->addItem(QString::fromStdString(lineTmp));
|
connect(ui->menu_chat,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(2);});
|
||||||
}
|
connect(ui->menu_music,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(3);});
|
||||||
}else {
|
connect(ui->menu_video,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(4);});
|
||||||
ui->comboBox_server->addItem("http://dcstore.shenmo.tech/");
|
connect(ui->menu_photo,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(5);});
|
||||||
}
|
connect(ui->menu_game,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(6);});
|
||||||
|
connect(ui->menu_office,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(7);});
|
||||||
|
connect(ui->menu_read,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(8);});
|
||||||
|
connect(ui->menu_dev,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(9);});
|
||||||
|
connect(ui->menu_system,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(10);});
|
||||||
|
connect(ui->menu_theme,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(11);});
|
||||||
|
connect(ui->menu_other,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(12);});
|
||||||
|
connect(ui->menu_download,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(13);});
|
||||||
|
|
||||||
QSettings readConfig(QDir::homePath()+"/.config/deepin-community-store/config.ini",QSettings::IniFormat);
|
//计算显示下载速度
|
||||||
if(readConfig.value("server/choose").toString()!=""){
|
|
||||||
ui->comboBox_server->setCurrentText(readConfig.value("server/choose").toString());
|
|
||||||
serverUrl=readConfig.value("server/choose").toString();
|
|
||||||
}else {
|
|
||||||
serverUrl="http://dcstore.shenmo.tech/";
|
|
||||||
}
|
|
||||||
configCanSeve=true;
|
|
||||||
qDebug()<<serverUrl;
|
|
||||||
menuUrl[0]=serverUrl + "store/#/";
|
|
||||||
// menuUrl[0]="http://127.0.0.1:8000/#/relations";
|
|
||||||
menuUrl[1]=serverUrl + "store/#/network/";
|
|
||||||
menuUrl[2]=serverUrl + "store/#/relations";
|
|
||||||
menuUrl[3]=serverUrl + "store/#/musicandsound";
|
|
||||||
menuUrl[4]=serverUrl + "store/#/videos";
|
|
||||||
menuUrl[5]=serverUrl + "store/#/photos";
|
|
||||||
menuUrl[6]=serverUrl + "store/#/games/";
|
|
||||||
menuUrl[7]=serverUrl + "store/#/office";
|
|
||||||
menuUrl[8]=serverUrl + "store/#/reading/";
|
|
||||||
menuUrl[9]=serverUrl + "store/#/programming";
|
|
||||||
menuUrl[10]=serverUrl + "store/#/tools/";
|
|
||||||
menuUrl[11]=serverUrl + "store/#/others/";
|
|
||||||
menuUrl[12]=serverUrl + "store/#/themes";
|
|
||||||
ui->webView->setUrl(menuUrl[0]);
|
|
||||||
for (int i =0; i<15;i++){
|
|
||||||
download_list[i].num=i;
|
|
||||||
}
|
|
||||||
QGraphicsOpacityEffect *opacityEffect_1=new QGraphicsOpacityEffect;
|
|
||||||
QGraphicsOpacityEffect *opacityEffect_2=new QGraphicsOpacityEffect;
|
|
||||||
ui->line1_widget->setStyleSheet("background-color:#808080");
|
|
||||||
ui->line2_widget->setStyleSheet("background-color:#808080");
|
|
||||||
opacityEffect_1->setOpacity(0.2);
|
|
||||||
opacityEffect_2->setOpacity(0.2);
|
|
||||||
ui->line1_widget->setGraphicsEffect(opacityEffect_1);
|
|
||||||
ui->line2_widget->setGraphicsEffect(opacityEffect_2);
|
|
||||||
connect(ui->webView->page(),SIGNAL(javaScriptWindowObjectCleared()),this,SLOT([=](){qDebug()<<" ";}));
|
|
||||||
download_speed.setInterval(1000);
|
download_speed.setInterval(1000);
|
||||||
download_speed.start();
|
download_speed.start();
|
||||||
connect(&download_speed,&QTimer::timeout,[=](){
|
connect(&download_speed,&QTimer::timeout,[=](){
|
||||||
@@ -105,19 +62,139 @@ Widget::Widget(QWidget *parent) :
|
|||||||
double bspeed;
|
double bspeed;
|
||||||
bspeed=size1-size2;
|
bspeed=size1-size2;
|
||||||
if(bspeed<1024){
|
if(bspeed<1024){
|
||||||
theSpeed=QString::number(bspeed)+"B";
|
theSpeed=QString::number(bspeed)+"B/s";
|
||||||
}else if (bspeed<(1024*1024)) {
|
}else if (bspeed<(1024*1024)) {
|
||||||
theSpeed=QString::number(0.01*int(100*(bspeed/1024)))+"KB";
|
theSpeed=QString::number(0.01*int(100*(bspeed/1024)))+"KB/s";
|
||||||
}else if (bspeed<(1024*1024*1024)) {
|
}else if (bspeed<(1024*1024*1024)) {
|
||||||
theSpeed=QString::number(0.01*int(100*(bspeed/(1024*1024))))+"MB";
|
theSpeed=QString::number(0.01*int(100*(bspeed/(1024*1024))))+"MB/s";
|
||||||
}else {
|
}else {
|
||||||
theSpeed=QString::number(0.01*int(100*(bspeed/(1024*1024*1024))))+"GB";
|
theSpeed=QString::number(0.01*int(100*(bspeed/(1024*1024*1024))))+"GB/s";
|
||||||
}
|
}
|
||||||
download_list[nowDownload-1].setSpeed(theSpeed);
|
download_list[nowDownload-1].setSpeed(theSpeed);
|
||||||
size2=download_size;
|
size2=download_size;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Widget::~Widget()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
void Widget::initUI()
|
||||||
|
{
|
||||||
|
//ui初始化
|
||||||
|
|
||||||
|
ui->stackedWidget->setCurrentIndex(0);
|
||||||
|
ui->listWidget->hide();
|
||||||
|
ui->label_setting1->hide();
|
||||||
|
ui->pushButton_uninstall->hide();
|
||||||
|
ui->line1_widget->setStyleSheet("background-color:#808080");
|
||||||
|
ui->line2_widget->setStyleSheet("background-color:#808080");
|
||||||
|
|
||||||
|
|
||||||
|
//初始化分界线
|
||||||
|
QGraphicsOpacityEffect *opacityEffect_1=new QGraphicsOpacityEffect;
|
||||||
|
QGraphicsOpacityEffect *opacityEffect_2=new QGraphicsOpacityEffect;
|
||||||
|
opacityEffect_1->setOpacity(0.1);
|
||||||
|
opacityEffect_2->setOpacity(0.1);
|
||||||
|
ui->line1_widget->setGraphicsEffect(opacityEffect_1);
|
||||||
|
ui->line2_widget->setGraphicsEffect(opacityEffect_2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//初始化菜单数组
|
||||||
|
left_list[0]=ui->menu_main;
|
||||||
|
left_list[1]=ui->menu_network;
|
||||||
|
left_list[2]=ui->menu_chat;
|
||||||
|
left_list[3]=ui->menu_music;
|
||||||
|
left_list[4]=ui->menu_video;
|
||||||
|
left_list[5]=ui->menu_photo;
|
||||||
|
left_list[6]=ui->menu_game;
|
||||||
|
left_list[7]=ui->menu_office;
|
||||||
|
left_list[8]=ui->menu_read;
|
||||||
|
left_list[9]=ui->menu_dev;
|
||||||
|
left_list[10]=ui->menu_system;
|
||||||
|
left_list[11]=ui->menu_theme;
|
||||||
|
left_list[12]=ui->menu_other;
|
||||||
|
left_list[13]=ui->menu_download;
|
||||||
|
|
||||||
|
|
||||||
|
//初始化web加载动画
|
||||||
|
QHBoxLayout *m_weblayout=new QHBoxLayout;
|
||||||
|
m_weblayout->addWidget(m_loadweb);
|
||||||
|
m_weblayout->addWidget(m_loaderror);
|
||||||
|
m_loadweb->hide();
|
||||||
|
m_loaderror->hide();
|
||||||
|
m_loadweb->start();
|
||||||
|
m_loadweb->setMaximumSize(50,50);
|
||||||
|
m_loadweb->setMinimumSize(50,50);
|
||||||
|
m_loadweb->setTextVisible(false);
|
||||||
|
m_loaderror->setPixmap(QIcon::fromTheme("dialog-error").pixmap(50,50));
|
||||||
|
m_loaderror->setAlignment(Qt::AlignCenter);
|
||||||
|
|
||||||
|
ui->webView->setLayout(m_weblayout);
|
||||||
|
ui->label_show->hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::initConfig()
|
||||||
|
{
|
||||||
|
//读取服务器列表并初始化
|
||||||
|
std::fstream serverList;
|
||||||
|
serverList.open(QDir::homePath().toUtf8()+"/.config/spark-store/server.list",std::ios::in);
|
||||||
|
std::string lineTmp;
|
||||||
|
if(serverList){
|
||||||
|
while (getline(serverList,lineTmp)) {
|
||||||
|
ui->comboBox_server->addItem(QString::fromStdString(lineTmp));
|
||||||
|
}
|
||||||
|
}else {
|
||||||
|
ui->comboBox_server->addItem("http://store.jerrywang.top/");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//读取服务器URL并初始化菜单项的链接
|
||||||
|
QSettings readConfig(QDir::homePath()+"/.config/spark-store/config.ini",QSettings::IniFormat);
|
||||||
|
if(readConfig.value("server/choose").toString()!=""){
|
||||||
|
ui->comboBox_server->setCurrentText(readConfig.value("server/choose").toString());
|
||||||
|
serverUrl=readConfig.value("server/choose").toString();
|
||||||
|
}else {
|
||||||
|
serverUrl="http://store.jerrywang.top/";//默认URL
|
||||||
|
}
|
||||||
|
configCanSave=true; //防止出发保存配置信号
|
||||||
|
// ui->
|
||||||
|
// menuUrl[0]="https://mp.weixin.qq.com/s/1OmCgJ13yVDSRebdgtW9fg";
|
||||||
|
menuUrl[0]=serverUrl + "store/#";
|
||||||
|
menuUrl[1]=serverUrl + "store/#/network";
|
||||||
|
menuUrl[2]=serverUrl + "store/#/relations";
|
||||||
|
menuUrl[3]=serverUrl + "store/#/musicandsound";
|
||||||
|
menuUrl[4]=serverUrl + "store/#/videos";
|
||||||
|
menuUrl[5]=serverUrl + "store/#/photos";
|
||||||
|
menuUrl[6]=serverUrl + "store/#/games";
|
||||||
|
menuUrl[7]=serverUrl + "store/#/office";
|
||||||
|
menuUrl[8]=serverUrl + "store/#/reading";
|
||||||
|
menuUrl[9]=serverUrl + "store/#/programming";
|
||||||
|
menuUrl[10]=serverUrl + "store/#/tools";
|
||||||
|
menuUrl[11]=serverUrl + "store/#/themes";
|
||||||
|
menuUrl[12]=serverUrl + "store/#/others";
|
||||||
|
|
||||||
|
|
||||||
|
//web控件初始化
|
||||||
|
ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); //用来激活接受linkClicked信号
|
||||||
|
ui->webView->page()->settings()->setAttribute(QWebSettings::JavascriptEnabled,true);
|
||||||
|
|
||||||
|
|
||||||
|
//初始化首页
|
||||||
|
ui->webView->setUrl(menuUrl[0]);
|
||||||
chooseLeftMenu(0);
|
chooseLeftMenu(0);
|
||||||
|
|
||||||
|
//给下载列表赋值到数组,方便调用
|
||||||
|
for (int i =0; i<LIST_MAX;i++){
|
||||||
|
download_list[i].num=i;
|
||||||
|
}
|
||||||
|
|
||||||
|
//初始化apt源显示
|
||||||
QFile aptserver("/etc/apt/sources.list.d/sparkstore.list");
|
QFile aptserver("/etc/apt/sources.list.d/sparkstore.list");
|
||||||
aptserver.open(QIODevice::ReadOnly);
|
aptserver.open(QIODevice::ReadOnly);
|
||||||
if(aptserver.isOpen()){
|
if(aptserver.isOpen()){
|
||||||
@@ -127,37 +204,62 @@ Widget::Widget(QWidget *parent) :
|
|||||||
}
|
}
|
||||||
aptserver.close();
|
aptserver.close();
|
||||||
|
|
||||||
|
//新建临时文件夹
|
||||||
|
QDir dir("/tmp");
|
||||||
|
dir.mkdir("spark-store");
|
||||||
|
}
|
||||||
|
void Widget::setTheme(bool isDark,QColor color)
|
||||||
|
{
|
||||||
|
if(isDark){
|
||||||
|
//黑色模式
|
||||||
|
ui->widget_menuList->setStyleSheet("background-color:#282828");
|
||||||
|
ui->webView->setStyleSheet("background-color:#282828");
|
||||||
|
ui->btn_openDir->setStyleSheet("color:#8B91A1;background-color:#2E2F30;border:0px");
|
||||||
|
|
||||||
|
}else {
|
||||||
|
//亮色模式
|
||||||
|
ui->widget_menuList->setStyleSheet("background-color:#FFFFFF");
|
||||||
|
ui->webView->setStyleSheet("background-color:#FFFFFF");
|
||||||
|
ui->btn_openDir->setStyleSheet("color:#505050;background-color:#FBFBFB;border:0px");
|
||||||
|
}
|
||||||
|
main_color=color;
|
||||||
|
left_list[nowMenu]->setStyleSheet("color:#FFFFFF;background-color:"+main_color.name()+";border-radius:8;border:0px");
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget::~Widget()
|
|
||||||
{
|
|
||||||
delete ui;
|
|
||||||
}
|
|
||||||
void Widget::on_webView_loadStarted()
|
void Widget::on_webView_loadStarted()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
m_loadweb->setValue(0);
|
||||||
|
m_loadweb->show();
|
||||||
|
m_loaderror->hide();
|
||||||
|
ui->label_show->hide();
|
||||||
|
|
||||||
|
//分析出服务器中的分类名称
|
||||||
QUrl arg1=ui->webView->page()->mainFrame()->requestedUrl().toString();
|
QUrl arg1=ui->webView->page()->mainFrame()->requestedUrl().toString();
|
||||||
//判断,如果末尾是/就直接访问,如果是app.json就打开详情页
|
QStringList url_=arg1.path().split("/");
|
||||||
|
if(url_.size()>3){
|
||||||
|
type_name=url_[2];
|
||||||
|
}
|
||||||
|
//如果是app.json就打开详情页
|
||||||
if(arg1.path().right(8)=="app.json"){
|
if(arg1.path().right(8)=="app.json"){
|
||||||
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
||||||
QPixmap pixmap_null;//一个空的图片指针,用来清空先有内容
|
QPixmap pixmap_null;//一个空的图片,用来清空现有内容
|
||||||
ui->label_appicon->setPixmap(pixmap_null);
|
ui->label_appicon->setPixmap(pixmap_null);
|
||||||
ui->screen_1->setPixmap(pixmap_null);
|
ui->screen_0->setImage(pixmap_null);
|
||||||
ui->screen_2->setPixmap(pixmap_null);
|
ui->screen_1->setImage(pixmap_null);
|
||||||
ui->screen_3->setPixmap(pixmap_null);
|
ui->screen_2->setImage(pixmap_null);
|
||||||
ui->screen_4->setPixmap(pixmap_null);
|
ui->screen_3->setImage(pixmap_null);
|
||||||
ui->screen_5->setPixmap(pixmap_null);
|
ui->screen_4->setImage(pixmap_null);
|
||||||
//先隐藏详情页负责显示截图的label
|
//先隐藏详情页负责显示截图的label
|
||||||
|
ui->screen_0->hide();
|
||||||
ui->screen_1->hide();
|
ui->screen_1->hide();
|
||||||
ui->screen_2->hide();
|
ui->screen_2->hide();
|
||||||
ui->screen_3->hide();
|
ui->screen_3->hide();
|
||||||
ui->screen_4->hide();
|
ui->screen_4->hide();
|
||||||
ui->screen_5->hide();
|
|
||||||
ui->label_more->setText("");//清空详情介绍
|
ui->label_more->setText("");//清空详情介绍
|
||||||
ui->label_info->setText("");
|
ui->label_info->setText("");
|
||||||
ui->label_appname->setText("");
|
ui->label_appname->setText("");
|
||||||
ui->pushButton->setEnabled(false);
|
ui->pushButton_download->setEnabled(false);
|
||||||
ui->stackedWidget->setCurrentIndex(2);
|
ui->stackedWidget->setCurrentIndex(2);
|
||||||
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
||||||
load = QtConcurrent::run([=](){
|
load = QtConcurrent::run([=](){
|
||||||
@@ -165,17 +267,39 @@ void Widget::on_webView_loadStarted()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Widget::loadappinfo(QUrl arg1)
|
//菜单切换逻辑
|
||||||
|
|
||||||
|
void Widget::chooseLeftMenu(int index)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
nowMenu=index;
|
||||||
|
for (int i=0;i<14;i++) {
|
||||||
|
left_list[i]->setStyleSheet("border:0px");
|
||||||
|
left_list[i]->setFont(QFont("",11));
|
||||||
|
left_list[i]->setMinimumHeight(30);
|
||||||
|
}
|
||||||
|
left_list[index]->setStyleSheet("color:#FFFFFF;background-color:"+main_color.name()+";border-radius:8;border:0px");
|
||||||
|
if(index<=12){
|
||||||
|
ui->webView->setUrl(menuUrl[index]);
|
||||||
|
ui->stackedWidget->setCurrentIndex(0);
|
||||||
|
}else if (index==13) {
|
||||||
|
ui->stackedWidget->setCurrentIndex(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
void Widget::loadappinfo(QUrl arg1)
|
||||||
|
{
|
||||||
|
//置UI状态
|
||||||
|
ui->pushButton_uninstall->hide();
|
||||||
ui->label_show->setText("正在加载,请稍候");
|
ui->label_show->setText("正在加载,请稍候");
|
||||||
ui->label_show->show();
|
ui->label_show->show();
|
||||||
|
ui->pushButton_website->hide();
|
||||||
|
|
||||||
QProcess get_json;
|
QProcess get_json;
|
||||||
QDir dir;
|
QDir dir("/tmp");
|
||||||
dir.cd("/tmp");
|
dir.mkdir("spark-store");
|
||||||
dir.mkdir("deepin-community-store");
|
QDir::setCurrent("/tmp/spark-store");
|
||||||
QDir::setCurrent("/tmp/deepin-community-store");
|
get_json.start("curl -o app.json "+arg1.toString());
|
||||||
get_json.start("wget -O app.json "+arg1.toString());
|
|
||||||
get_json.waitForFinished();
|
get_json.waitForFinished();
|
||||||
QFile app_json("app.json");
|
QFile app_json("app.json");
|
||||||
if(app_json.open(QIODevice::ReadOnly)){
|
if(app_json.open(QIODevice::ReadOnly)){
|
||||||
@@ -185,13 +309,18 @@ void Widget::loadappinfo(QUrl arg1)
|
|||||||
urladdress=arg1.toString().left(arg1.toString().length()-8);
|
urladdress=arg1.toString().left(arg1.toString().length()-8);
|
||||||
QStringList downloadurl=urladdress.split("/");
|
QStringList downloadurl=urladdress.split("/");
|
||||||
urladdress=ui->comboBox_server->currentText();
|
urladdress=ui->comboBox_server->currentText();
|
||||||
|
QString deburl=urladdress;
|
||||||
|
urladdress="http://img.shenmo.tech:38324/";//使用图片专用服务器请保留这行,删除后将使用源服务器
|
||||||
|
|
||||||
for (int i=3;i<downloadurl.size();i++) {
|
for (int i=3;i<downloadurl.size();i++) {
|
||||||
urladdress+="/"+downloadurl[i];
|
urladdress+="/"+downloadurl[i];
|
||||||
|
deburl+="/"+downloadurl[i];
|
||||||
}
|
}
|
||||||
//路径转化完成
|
//路径转化完成
|
||||||
QJsonObject json= QJsonDocument::fromJson(json_array).object();
|
QJsonObject json= QJsonDocument::fromJson(json_array).object();
|
||||||
appName = json["Name"].toString();
|
appName = json["Name"].toString();
|
||||||
url=urladdress + json["Filename"].toString();
|
url=deburl + json["Filename"].toString();
|
||||||
|
qDebug()<<url;
|
||||||
ui->label_appname->setText(appName);
|
ui->label_appname->setText(appName);
|
||||||
system("rm -r *.png");
|
system("rm -r *.png");
|
||||||
ui->label_show->show();
|
ui->label_show->show();
|
||||||
@@ -205,6 +334,8 @@ void Widget::loadappinfo(QUrl arg1)
|
|||||||
|
|
||||||
if(json["Website"].toString()!="" && json["Website"].toString()!=" "){
|
if(json["Website"].toString()!="" && json["Website"].toString()!=" "){
|
||||||
info+="官网: "+json["Website"].toString()+"\n";
|
info+="官网: "+json["Website"].toString()+"\n";
|
||||||
|
ui->pushButton_website->show();
|
||||||
|
appweb=json["Website"].toString();
|
||||||
}
|
}
|
||||||
info+="投稿者: "+json["Contributor"].toString()+"\n";
|
info+="投稿者: "+json["Contributor"].toString()+"\n";
|
||||||
info+="更新时间: "+json["Update"].toString()+"\n";
|
info+="更新时间: "+json["Update"].toString()+"\n";
|
||||||
@@ -212,68 +343,52 @@ void Widget::loadappinfo(QUrl arg1)
|
|||||||
ui->label_info->setText(info);
|
ui->label_info->setText(info);
|
||||||
ui->label_more->setText(json["More"].toString());
|
ui->label_more->setText(json["More"].toString());
|
||||||
QProcess isInstall;
|
QProcess isInstall;
|
||||||
|
pkgName=json["Pkgname"].toString();
|
||||||
isInstall.start("dpkg -s "+json["Pkgname"].toString());
|
isInstall.start("dpkg -s "+json["Pkgname"].toString());
|
||||||
isInstall.waitForFinished();
|
isInstall.waitForFinished();
|
||||||
int error=QString::fromStdString(isInstall.readAllStandardError().toStdString()).length();
|
int error=QString::fromStdString(isInstall.readAllStandardError().toStdString()).length();
|
||||||
if(error==0){
|
if(error==0){
|
||||||
ui->pushButton->setText("重新安装");
|
ui->pushButton_download->setText("重新安装");
|
||||||
|
ui->pushButton_uninstall->show();
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
ui->pushButton->setText("安装");
|
ui->pushButton_download->setText("安装");
|
||||||
}
|
}
|
||||||
//图标加载
|
//图标加载
|
||||||
get_json.start("wget -O icon.png "+urladdress+"icon.png");
|
get_json.start("curl -o icon.png "+urladdress+"icon.png");
|
||||||
get_json.waitForFinished();
|
get_json.waitForFinished();
|
||||||
QPixmap appicon;
|
QPixmap appicon(QString::fromUtf8(TMP_PATH)+"/icon.png");
|
||||||
qDebug()<<appicon.load("icon.png");
|
|
||||||
ui->label_appicon->setPixmap(appicon);
|
ui->label_appicon->setPixmap(appicon);
|
||||||
ui->pushButton->setEnabled(true);
|
ui->pushButton_download->setEnabled(true);
|
||||||
//截图展示加载
|
//截图展示加载
|
||||||
get_json.start("wget "+urladdress+"screen_1.png");
|
image_show *label_screen[5];
|
||||||
get_json.waitForFinished();
|
label_screen[0]=ui->screen_0;
|
||||||
if(screen[0].load("screen_1.png")){
|
label_screen[1]=ui->screen_1;
|
||||||
ui->screen_1->show();
|
label_screen[2]=ui->screen_2;
|
||||||
ui->screen_1->setPixmap(screen[0]);
|
label_screen[3]=ui->screen_3;
|
||||||
ui->screen_1->setScaledContents(true);
|
label_screen[4]=ui->screen_4;
|
||||||
ui->screen_2->hide();
|
ui->screen_0->hide();
|
||||||
ui->screen_3->hide();
|
ui->screen_1->hide();
|
||||||
ui->screen_4->hide();
|
ui->screen_2->hide();
|
||||||
ui->screen_5->hide();
|
ui->screen_3->hide();
|
||||||
|
ui->screen_4->hide();
|
||||||
}
|
for (int i=0;i<5;i++) {
|
||||||
get_json.start("wget "+urladdress+"screen_2.png");
|
get_json.start("curl -o screen_"+QString::number(i)+".png "+urladdress+"screen_"+QString::number(i)+".png");
|
||||||
get_json.waitForFinished();
|
get_json.waitForFinished();
|
||||||
if(screen[1].load("screen_2.png")){
|
if(screen[i].load("screen_"+QString::number(i)+".png")){
|
||||||
ui->screen_2->show();
|
label_screen[i]->setImage(screen[i]);
|
||||||
ui->screen_2->setPixmap(screen[1]);
|
label_screen[i]->show();
|
||||||
ui->screen_2->setScaledContents(true);
|
switch(i){ //故意为之,为了清除多余截图
|
||||||
ui->screen_3->hide();
|
case 0:
|
||||||
ui->screen_4->hide();
|
label_screen[1]->hide();
|
||||||
ui->screen_5->hide();
|
case 1:
|
||||||
}
|
label_screen[2]->hide();
|
||||||
get_json.start("wget "+urladdress+"screen_3.png");
|
case 2:
|
||||||
get_json.waitForFinished();
|
label_screen[3]->hide();
|
||||||
if(screen[2].load("screen_3.png")){
|
case 3:
|
||||||
ui->screen_3->show();
|
label_screen[4]->hide();
|
||||||
ui->screen_3->setPixmap(screen[2]);
|
}
|
||||||
ui->screen_3->setScaledContents(true);
|
}
|
||||||
ui->screen_4->hide();
|
|
||||||
ui->screen_5->hide();
|
|
||||||
}
|
|
||||||
get_json.start("wget "+urladdress+"screen_4.png");
|
|
||||||
get_json.waitForFinished();
|
|
||||||
if(screen[3].load("screen_4.png")){
|
|
||||||
ui->screen_4->show();
|
|
||||||
ui->screen_4->setPixmap(screen[3]);
|
|
||||||
ui->screen_4->setScaledContents(true);
|
|
||||||
ui->screen_5->hide();
|
|
||||||
}
|
|
||||||
get_json.start("wget "+urladdress+"screen_5.png");
|
|
||||||
get_json.waitForFinished();
|
|
||||||
if(screen[4].load("screen_5.png")){
|
|
||||||
ui->screen_5->show();
|
|
||||||
ui->screen_5->setPixmap(screen[4]);
|
|
||||||
ui->screen_5->setScaledContents(true);
|
|
||||||
}
|
}
|
||||||
ui->label_show->setText("");
|
ui->label_show->setText("");
|
||||||
ui->label_show->hide();
|
ui->label_show->hide();
|
||||||
@@ -282,41 +397,25 @@ void Widget::loadappinfo(QUrl arg1)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::chooseLeftMenu(int index)
|
|
||||||
{
|
|
||||||
|
|
||||||
nowMenu=index;
|
|
||||||
for (int i=0;i<15;i++) {
|
|
||||||
left_list[i]->setStyleSheet("");
|
|
||||||
left_list[i]->setFont(QFont("",11));
|
|
||||||
left_menu_bg[i]->setStyleSheet("");
|
|
||||||
}
|
|
||||||
left_list[index]->setStyleSheet("color:#FFFFFF");
|
|
||||||
left_menu_bg[index]->setStyleSheet("background-color:#0081FF;border-radius:8");
|
|
||||||
if(index<=12){
|
|
||||||
ui->webView->setUrl(menuUrl[index]);
|
|
||||||
ui->stackedWidget->setCurrentIndex(0);
|
|
||||||
}else if (index==13) {
|
|
||||||
ui->stackedWidget->setCurrentIndex(1);
|
|
||||||
}else if (index==14) {
|
|
||||||
ui->stackedWidget->setCurrentIndex(3);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
void Widget::on_pushButton_clicked()
|
void Widget::on_pushButton_download_clicked()
|
||||||
{
|
{
|
||||||
on_menu_btn_download_clicked();
|
chooseLeftMenu(13);
|
||||||
allDownload+=1;
|
allDownload+=1;
|
||||||
QFileInfo info(url.path());
|
QFileInfo info(url.path());
|
||||||
QString fileName(info.fileName()); //获取文件名
|
QString fileName(info.fileName()); //获取文件名
|
||||||
|
download_list[allDownload-1].pkgName=pkgName;
|
||||||
if(fileName.isEmpty())
|
if(fileName.isEmpty())
|
||||||
{
|
{
|
||||||
fileName = "index.html";
|
system("notify-send 获取失败 --icon=spark-store");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
download_list[allDownload-1].setParent(ui->listWidget);
|
download_list[allDownload-1].setParent(ui->listWidget);
|
||||||
QListWidgetItem *item=new QListWidgetItem(ui->listWidget);
|
QListWidgetItem *item=new QListWidgetItem(ui->listWidget);
|
||||||
item->setSizeHint(download_list[allDownload-1].size());
|
item->setSizeHint(download_list[allDownload-1].size());
|
||||||
|
item->setFlags(item->flags() & ~Qt::ItemIsEnabled & ~Qt::ItemIsSelectable);
|
||||||
ui->listWidget->setItemWidget(item,&download_list[allDownload-1]);
|
ui->listWidget->setItemWidget(item,&download_list[allDownload-1]);
|
||||||
urList.append(url);
|
urList.append(url);
|
||||||
download_list[allDownload-1].setName(appName);
|
download_list[allDownload-1].setName(appName);
|
||||||
@@ -335,7 +434,7 @@ void Widget::on_pushButton_clicked()
|
|||||||
nowDownload+=1;
|
nowDownload+=1;
|
||||||
startRequest(urList.at(nowDownload-1)); //进行链接请求
|
startRequest(urList.at(nowDownload-1)); //进行链接请求
|
||||||
}
|
}
|
||||||
if(ui->pushButton->text()=="重新安装"){
|
if(ui->pushButton_download->text()=="重新安装"){
|
||||||
download_list[allDownload-1].reinstall=true;
|
download_list[allDownload-1].reinstall=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -354,6 +453,19 @@ void Widget::startRequest(QUrl url)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::searchApp(QString text)
|
||||||
|
{
|
||||||
|
if(text.left(6)=="spk://"){
|
||||||
|
openUrl(text);
|
||||||
|
}else {
|
||||||
|
system("notify-send 目前仅支持商店专用链接的打开,搜索功能正在开发,请期待以后的版本! --icon=spark-store");
|
||||||
|
// ui->webView->setUrl(QUrl("http://www.baidu.com/s?wd="+text));
|
||||||
|
// ui->stackedWidget->setCurrentIndex(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Widget::httpReadyRead()
|
void Widget::httpReadyRead()
|
||||||
{
|
{
|
||||||
@@ -367,10 +479,9 @@ void Widget::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
|
|||||||
download_list[nowDownload-1].setMax(10000); //最大值
|
download_list[nowDownload-1].setMax(10000); //最大值
|
||||||
download_list[nowDownload-1].setValue((bytesRead*10000)/totalBytes); //当前值
|
download_list[nowDownload-1].setValue((bytesRead*10000)/totalBytes); //当前值
|
||||||
download_size=bytesRead;
|
download_size=bytesRead;
|
||||||
if(download_list[nowDownload-1].close){
|
if(download_list[nowDownload-1].close){ //随时检测下载是否被取消
|
||||||
download_list[nowDownload-1].closeDownload();
|
download_list[nowDownload-1].closeDownload();
|
||||||
httpFinished();
|
httpFinished();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,7 +498,7 @@ void Widget::httpFinished() //完成下载
|
|||||||
isBusy=false;
|
isBusy=false;
|
||||||
download_list[nowDownload-1].readyInstall();
|
download_list[nowDownload-1].readyInstall();
|
||||||
download_list[nowDownload-1].free=true;
|
download_list[nowDownload-1].free=true;
|
||||||
if(nowDownload<allDownload){
|
if(nowDownload<allDownload){ //如果有排队则下载下一个
|
||||||
nowDownload+=1;
|
nowDownload+=1;
|
||||||
while (download_list[nowDownload-1].close) {
|
while (download_list[nowDownload-1].close) {
|
||||||
nowDownload+=1;
|
nowDownload+=1;
|
||||||
@@ -403,168 +514,206 @@ void Widget::httpFinished() //完成下载
|
|||||||
startRequest(urList.at(nowDownload-1));
|
startRequest(urList.at(nowDownload-1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Widget::on_listWidget_currentRowChanged(int currentRow)
|
|
||||||
{
|
|
||||||
qDebug()<<currentRow;
|
|
||||||
for (int i=0;i<allDownload;i++) {
|
void Widget::on_pushButton_return_clicked()
|
||||||
download_list[i].choose(false);
|
|
||||||
}
|
|
||||||
download_list[currentRow].choose(true);
|
|
||||||
}
|
|
||||||
//菜单切换逻辑
|
|
||||||
void Widget::on_menu_btn_main_clicked() //主页
|
|
||||||
{
|
|
||||||
chooseLeftMenu(0);
|
|
||||||
}
|
|
||||||
void Widget::on_menu_btn_network_clicked() //网络应用
|
|
||||||
{
|
|
||||||
chooseLeftMenu(1);
|
|
||||||
}
|
|
||||||
void Widget::on_menu_btn_chat_clicked()//社交沟通
|
|
||||||
{
|
|
||||||
chooseLeftMenu(2);
|
|
||||||
}
|
|
||||||
void Widget::on_menu_btn_music_clicked()//音乐欣赏
|
|
||||||
{
|
|
||||||
chooseLeftMenu(3);
|
|
||||||
}
|
|
||||||
void Widget::on_menu_btn_video_clicked()//视频播放
|
|
||||||
{
|
|
||||||
chooseLeftMenu(4);
|
|
||||||
}
|
|
||||||
void Widget::on_menu_btn_photo_clicked()//图形图像
|
|
||||||
{
|
|
||||||
chooseLeftMenu(5);
|
|
||||||
}
|
|
||||||
void Widget::on_menu_btn_game_clicked()//游戏娱乐
|
|
||||||
{
|
|
||||||
chooseLeftMenu(6);
|
|
||||||
}
|
|
||||||
void Widget::on_menu_btn_office_clicked()//办公学习
|
|
||||||
{
|
|
||||||
chooseLeftMenu(7);
|
|
||||||
}
|
|
||||||
void Widget::on_menu_btn_read_clicked()//阅读翻译
|
|
||||||
{
|
|
||||||
chooseLeftMenu(8);
|
|
||||||
}
|
|
||||||
void Widget::on_menu_btn_dev_clicked()//编程开发
|
|
||||||
{
|
|
||||||
chooseLeftMenu(9);
|
|
||||||
}
|
|
||||||
void Widget::on_menu_btn_system_clicked()//系统管理
|
|
||||||
{
|
|
||||||
chooseLeftMenu(10);
|
|
||||||
}
|
|
||||||
void Widget::on_menu_btn_other_clicked()//其他软件
|
|
||||||
{
|
|
||||||
chooseLeftMenu(11);
|
|
||||||
}
|
|
||||||
void Widget::on_menu_btn_theme_clicked()
|
|
||||||
{
|
|
||||||
chooseLeftMenu(12);
|
|
||||||
}
|
|
||||||
void Widget::on_menu_btn_download_clicked()
|
|
||||||
{
|
|
||||||
chooseLeftMenu(13);
|
|
||||||
}
|
|
||||||
void Widget::on_menu_btn_settings_clicked()
|
|
||||||
{
|
|
||||||
chooseLeftMenu(14);
|
|
||||||
}
|
|
||||||
void Widget::on_pushButton_2_clicked()
|
|
||||||
{
|
{
|
||||||
ui->webView->setUrl(menuUrl[nowMenu]);
|
ui->webView->setUrl(menuUrl[nowMenu]);
|
||||||
ui->stackedWidget->setCurrentIndex(0);
|
ui->stackedWidget->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Widget::on_webView_loadFinished()
|
|
||||||
{
|
|
||||||
if(ui->webView->page()->mainFrame()->requestedUrl().toString().right(5)!=".json"){
|
|
||||||
ui->label_show->setText("正在加载,请稍候");
|
|
||||||
ui->label_show->hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Widget::on_comboBox_server_currentIndexChanged(const QString &arg1)
|
void Widget::on_comboBox_server_currentIndexChanged(const QString &arg1)
|
||||||
{
|
{
|
||||||
if(configCanSeve){
|
if(configCanSave){
|
||||||
ui->label_setting1->show();
|
ui->label_setting1->show();
|
||||||
QSettings *setConfig=new QSettings(QDir::homePath()+"/.config/deepin-community-store/config.ini",QSettings::IniFormat);
|
QSettings *setConfig=new QSettings(QDir::homePath()+"/.config/spark-store/config.ini",QSettings::IniFormat);
|
||||||
qDebug()<<arg1;
|
|
||||||
setConfig->setValue("server/choose",arg1);
|
setConfig->setValue("server/choose",arg1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void Widget::on_pushButton_updateServer_clicked()
|
||||||
|
|
||||||
void Widget::on_pushButton_3_clicked()
|
|
||||||
{
|
{
|
||||||
QtConcurrent::run([=](){
|
QtConcurrent::run([=](){
|
||||||
ui->pushButton_3->setEnabled(false);
|
ui->pushButton_updateServer->setEnabled(false);
|
||||||
ui->comboBox_server->clear();
|
ui->comboBox_server->clear();
|
||||||
system(QDir::homePath().toUtf8()+"/.config/deepin-community-store/server.list");
|
QFile::remove(QDir::homePath().toUtf8()+"/.config/spark-store/server.list");
|
||||||
system("wget -P "+QDir::homePath().toUtf8()+"/.config/deepin-community-store http://store2.shenmo.tech/store/server.list");
|
system("curl -o "+QDir::homePath().toUtf8()+"/.config/spark-store/server.list http://dcstore.shenmo.tech/store/server.list");
|
||||||
std::fstream server;
|
std::fstream server;
|
||||||
server.open(QDir::homePath().toUtf8()+"/.config/deepin-community-store/server.list",std::ios::in);
|
server.open(QDir::homePath().toUtf8()+"/.config/spark-store/server.list",std::ios::in);
|
||||||
std::string lineTmp;
|
std::string lineTmp;
|
||||||
if(server){
|
if(server){
|
||||||
while (getline(server,lineTmp)) {
|
while (getline(server,lineTmp)) {
|
||||||
ui->comboBox_server->addItem(QString::fromStdString(lineTmp));
|
ui->comboBox_server->addItem(QString::fromStdString(lineTmp));
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
ui->comboBox_server->addItem("http://dcstore.shenmo.tech/");
|
ui->comboBox_server->addItem("http://store.jerrywang.top/");
|
||||||
}
|
}
|
||||||
ui->pushButton_3->setEnabled(true);
|
ui->pushButton_updateServer->setEnabled(true);
|
||||||
ui->comboBox_server->setCurrentIndex(0);
|
ui->comboBox_server->setCurrentIndex(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::on_pushButton_4_clicked()
|
void Widget::on_pushButton_updateApt_clicked()
|
||||||
{
|
{
|
||||||
QtConcurrent::run([=](){
|
QtConcurrent::run([=](){
|
||||||
ui->pushButton_4->setEnabled(false);
|
ui->pushButton_updateApt->setEnabled(false);
|
||||||
ui->label_aptserver->setText("请稍等,正在更新");
|
ui->label_aptserver->setText("请稍等,正在更新");
|
||||||
std::fstream sourcesList;
|
std::fstream sourcesList;
|
||||||
system("mkdir /tmp/spark-store");
|
QDir tmpdir("/tmp");
|
||||||
sourcesList.open("/tmp/spark-store/sparkstore.list",std::ios::out);
|
tmpdir.mkpath("spark-store");
|
||||||
|
sourcesList.open(QString::fromUtf8(TMP_PATH).toStdString()+"/sparkstore.list",std::ios::out);
|
||||||
if(sourcesList){
|
if(sourcesList){
|
||||||
sourcesList<<"deb [by-hash=force] ";
|
sourcesList<<"deb [by-hash=force] ";
|
||||||
sourcesList<<QString::fromUtf8(ui->comboBox_server->currentText().toUtf8()).toStdString();
|
sourcesList<<QString::fromUtf8(ui->comboBox_server->currentText().toUtf8()).toStdString();
|
||||||
sourcesList<<" ./";
|
sourcesList<<" /";
|
||||||
std::fstream update;
|
std::fstream update;
|
||||||
update.open("/tmp/spark-store/update.sh",std::ios::out);
|
update.open(QString::fromUtf8(TMP_PATH).toStdString()+"/update.sh",std::ios::out);
|
||||||
update<<"#!/bin/sh\n";
|
update<<"#!/bin/sh\n";
|
||||||
update<<"mv /tmp/spark-store/sparkstore.list /etc/apt/sources.list.d/sparkstore.list && apt update";
|
update<<"mv "+QString::fromUtf8(TMP_PATH).toStdString()+"/sparkstore.list /etc/apt/sources.list.d/sparkstore.list && apt update";
|
||||||
update.close();
|
update.close();
|
||||||
system("chmod +x /tmp/spark-store/update.sh");
|
system("chmod +x "+QString::fromUtf8(TMP_PATH).toUtf8()+"/update.sh");
|
||||||
QProcess runupdate;
|
QProcess runupdate;
|
||||||
runupdate.start("pkexec /tmp/spark-store/update.sh");
|
runupdate.start("pkexec "+QString::fromUtf8(TMP_PATH)+"/update.sh");
|
||||||
runupdate.waitForFinished();
|
runupdate.waitForFinished();
|
||||||
qDebug()<<runupdate.readAllStandardError();
|
|
||||||
QString error=QString::fromStdString(runupdate.readAllStandardError().toStdString());
|
QString error=QString::fromStdString(runupdate.readAllStandardError().toStdString());
|
||||||
QStringList everyError=error.split("\n");
|
QStringList everyError=error.split("\n");
|
||||||
bool haveError=false;
|
bool haveError=false;
|
||||||
for (int i=0;i<everyError.size();i++) {
|
for (int i=0;i<everyError.size();i++) {
|
||||||
qDebug()<<everyError[i].left(2);
|
|
||||||
if(everyError[i].left(2)=="E:"){
|
if(everyError[i].left(2)=="E:"){
|
||||||
haveError=true;
|
haveError=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!haveError){
|
if(!haveError){
|
||||||
ui->label_aptserver->setText("deb [by-hash=force] "+ui->comboBox_server->currentText().toUtf8()+" ./");
|
ui->label_aptserver->setText("deb [by-hash=force] "+ui->comboBox_server->currentText().toUtf8()+" /");
|
||||||
}else {
|
}else {
|
||||||
ui->label_aptserver->setText("更新中发生错误,请在终端使用apt update来查看错误原因");
|
ui->label_aptserver->setText("更新中发生错误,请在终端使用apt update来查看错误原因");
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
qDebug()<<"更新源失败";
|
ui->label_aptserver->setText("服务器错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->pushButton_4->setEnabled(true);
|
ui->pushButton_updateApt->setEnabled(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::on_pushButton_uninstall_clicked()
|
||||||
|
{
|
||||||
|
QtConcurrent::run([=](){
|
||||||
|
ui->pushButton_download->setEnabled(false);
|
||||||
|
ui->pushButton_uninstall->setEnabled(false);
|
||||||
|
QProcess uninstall;
|
||||||
|
uninstall.start("pkexec apt purge -y "+pkgName);
|
||||||
|
uninstall.waitForFinished();
|
||||||
|
ui->pushButton_download->setEnabled(true);
|
||||||
|
ui->pushButton_download->setText("安装");
|
||||||
|
ui->pushButton_uninstall->hide();
|
||||||
|
ui->pushButton_uninstall->setEnabled(true);
|
||||||
|
updatesEnabled();
|
||||||
|
system("notify-send 卸载完成 --icon=spark-store");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::on_pushButton_clear_clicked()//清空临时缓存目录
|
||||||
|
{
|
||||||
|
QtConcurrent::run([=](){
|
||||||
|
ui->pushButton_clear->setEnabled(false);
|
||||||
|
QDir tmpdir("/tmp/spark-store");
|
||||||
|
tmpdir.setFilter(QDir::Files);
|
||||||
|
int quantity=int(tmpdir.count());
|
||||||
|
for (int i=0;i<quantity;i++) {
|
||||||
|
tmpdir.remove(tmpdir[i]);
|
||||||
|
}
|
||||||
|
system("notify-send 已清除所有临时缓存 --icon=spark-store");
|
||||||
|
ui->pushButton_clear->setEnabled(true);
|
||||||
|
Widget::opensetting();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
quint64 Widget::dirFileSize(const QString &path)
|
||||||
|
{
|
||||||
|
QDir dir(path);
|
||||||
|
quint64 size = 0;
|
||||||
|
//dir.entryInfoList(QDir::Files)返回文件信息
|
||||||
|
foreach(QFileInfo fileInfo, dir.entryInfoList(QDir::Files))
|
||||||
|
{
|
||||||
|
//计算文件大小
|
||||||
|
size += quint64(fileInfo.size());
|
||||||
|
}
|
||||||
|
//dir.entryList(QDir::Dirs|QDir::NoDotAndDotDot)返回所有子目录,并进行过滤
|
||||||
|
foreach(QString subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
||||||
|
{
|
||||||
|
//若存在子目录,则递归调用dirFileSize()函数
|
||||||
|
size += dirFileSize(path + QDir::separator() + subDir);
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::opensetting()
|
||||||
|
{
|
||||||
|
//防止下载时文件被删除
|
||||||
|
if(isdownload){
|
||||||
|
ui->pushButton_clear->setEnabled(false);
|
||||||
|
}else {
|
||||||
|
ui->pushButton_clear->setEnabled(true);
|
||||||
|
}
|
||||||
|
//显示缓存占用空间
|
||||||
|
quint64 tmp_size=dirFileSize(QString::fromUtf8(TMP_PATH));
|
||||||
|
QString tmp_size_str;
|
||||||
|
if(tmp_size<1024){
|
||||||
|
tmp_size_str=QString::number(tmp_size)+"B";
|
||||||
|
}else if (tmp_size<(1024*1024)) {
|
||||||
|
tmp_size_str=QString::number(0.01*int(100*(tmp_size/1024)))+"KB";
|
||||||
|
}else if (tmp_size<(1024*1024*1024)) {
|
||||||
|
tmp_size_str=QString::number(0.01*int(100*(tmp_size/(1024*1024))))+"MB";
|
||||||
|
}else {
|
||||||
|
tmp_size_str=QString::number(0.01*int(100*(tmp_size/(1024*1024*1024))))+"GB";
|
||||||
|
}
|
||||||
|
ui->tmp_size_ui->setText(tmp_size_str);
|
||||||
|
ui->stackedWidget->setCurrentIndex(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::openUrl(QUrl u)
|
||||||
|
{
|
||||||
|
QString app=serverUrl + "store"+u.path()+"/app.json";
|
||||||
|
ui->webView->setUrl(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void Widget::on_pushButton_website_clicked()
|
||||||
|
{
|
||||||
|
QDesktopServices::openUrl(QUrl(appweb));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Widget::on_webView_loadFinished(bool arg1)
|
||||||
|
{
|
||||||
|
if(arg1){
|
||||||
|
m_loadweb->hide();
|
||||||
|
}else {
|
||||||
|
m_loadweb->hide();
|
||||||
|
m_loaderror->show();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::on_webView_loadProgress(int progress)
|
||||||
|
{
|
||||||
|
m_loadweb->setValue(progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::on_pushButton_clicked()
|
||||||
|
{
|
||||||
|
QString share_url;
|
||||||
|
share_url="spk://store/"+type_name+"/"+pkgName;
|
||||||
|
qDebug()<<"Share"<<share_url;
|
||||||
|
QClipboard *clipboard=QApplication::clipboard();
|
||||||
|
system("notify-send 链接已经复制到剪贴板 --icon=spark-store");
|
||||||
|
clipboard->setText(share_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::on_btn_openDir_clicked()
|
||||||
|
{
|
||||||
|
|
||||||
|
QDesktopServices::openUrl(QUrl("file:///tmp/spark-store", QUrl::TolerantMode));
|
||||||
|
}
|
||||||
|
|||||||
106
widget.h
106
widget.h
@@ -12,7 +12,15 @@
|
|||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#define LIST_MAX 99
|
#include <DSettings>
|
||||||
|
#include <DBlurEffectWidget>
|
||||||
|
#include <DSpinner>
|
||||||
|
#include <DWaterProgress>
|
||||||
|
#include <QLabel>
|
||||||
|
#define LIST_MAX 99 //一次最多下载数量
|
||||||
|
#define TMP_PATH "/tmp/spark-store"
|
||||||
|
|
||||||
|
DWIDGET_USE_NAMESPACE
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class Widget;
|
class Widget;
|
||||||
}
|
}
|
||||||
@@ -24,72 +32,42 @@ class Widget : public QWidget
|
|||||||
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit Widget(QWidget *parent = 0);
|
explicit Widget(QWidget *parent = nullptr);
|
||||||
~Widget();
|
~Widget();
|
||||||
void startRequest(QUrl url);
|
void startRequest(QUrl url);
|
||||||
|
void searchApp(QString);
|
||||||
int nowDownload=0;
|
int nowDownload=0;
|
||||||
int allDownload=0;
|
int allDownload=0;
|
||||||
int isdownload=false;
|
int isdownload=false;
|
||||||
void loadappinfo(QUrl);
|
void opensetting(); //打开设置页面
|
||||||
void chooseLeftMenu(int index);
|
void openUrl(QUrl);
|
||||||
QPixmap screen[5];
|
void setTheme(bool,QColor);
|
||||||
QFuture<void> load;
|
|
||||||
QTimer download_speed;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void httpFinished();
|
void httpFinished();
|
||||||
void httpReadyRead();
|
void httpReadyRead();
|
||||||
void updateDataReadProgress(qint64,qint64);
|
void updateDataReadProgress(qint64,qint64);
|
||||||
void on_menu_btn_main_clicked();
|
void on_pushButton_download_clicked();
|
||||||
|
void on_pushButton_return_clicked();
|
||||||
void on_menu_btn_network_clicked();
|
void on_webView_loadStarted();
|
||||||
|
void on_comboBox_server_currentIndexChanged(const QString &arg1);
|
||||||
void on_menu_btn_download_clicked();
|
void on_pushButton_updateServer_clicked();
|
||||||
|
void on_pushButton_updateApt_clicked();
|
||||||
void on_menu_btn_chat_clicked();
|
void on_pushButton_uninstall_clicked();
|
||||||
|
void on_pushButton_clear_clicked();
|
||||||
void on_menu_btn_music_clicked();
|
void on_pushButton_website_clicked();
|
||||||
|
void on_webView_loadFinished(bool arg1);
|
||||||
void on_menu_btn_video_clicked();
|
void on_webView_loadProgress(int progress);
|
||||||
|
|
||||||
void on_menu_btn_photo_clicked();
|
|
||||||
|
|
||||||
void on_menu_btn_game_clicked();
|
|
||||||
|
|
||||||
void on_menu_btn_office_clicked();
|
|
||||||
|
|
||||||
void on_menu_btn_read_clicked();
|
|
||||||
|
|
||||||
void on_menu_btn_dev_clicked();
|
|
||||||
|
|
||||||
void on_menu_btn_system_clicked();
|
|
||||||
|
|
||||||
void on_menu_btn_other_clicked();
|
|
||||||
|
|
||||||
void on_listWidget_currentRowChanged(int currentRow);
|
|
||||||
|
|
||||||
void on_pushButton_clicked();
|
void on_pushButton_clicked();
|
||||||
|
|
||||||
void on_pushButton_2_clicked();
|
void on_btn_openDir_clicked();
|
||||||
|
|
||||||
void on_webView_loadStarted();
|
|
||||||
|
|
||||||
void on_webView_loadFinished();
|
|
||||||
|
|
||||||
void on_menu_btn_theme_clicked();
|
|
||||||
|
|
||||||
void on_menu_btn_settings_clicked();
|
|
||||||
|
|
||||||
void on_comboBox_server_currentIndexChanged(const QString &arg1);
|
|
||||||
|
|
||||||
void on_pushButton_3_clicked();
|
|
||||||
|
|
||||||
void on_pushButton_4_clicked();
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
bool isBusy=false;
|
|
||||||
downloadlist download_list[LIST_MAX];
|
downloadlist download_list[LIST_MAX];
|
||||||
Ui::Widget *ui;
|
Ui::Widget *ui;
|
||||||
QNetworkAccessManager *manager;
|
QNetworkAccessManager *manager;
|
||||||
@@ -98,15 +76,33 @@ public:
|
|||||||
QFile *file;
|
QFile *file;
|
||||||
QString appName;
|
QString appName;
|
||||||
QString urladdress;
|
QString urladdress;
|
||||||
QToolButton * left_list[15];
|
QString pkgName;
|
||||||
QWidget * left_menu_bg[15];
|
QString appweb;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void initUI();
|
||||||
|
void initConfig();
|
||||||
|
void loadappinfo(QUrl);
|
||||||
|
void chooseLeftMenu(int index);
|
||||||
|
quint64 dirFileSize(const QString &path);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPushButton * left_list[15];
|
||||||
QUrl menuUrl[13];
|
QUrl menuUrl[13];
|
||||||
bool configCanSeve=false;
|
DWaterProgress *m_loadweb=new DWaterProgress;
|
||||||
int nowMenu=0;
|
QLabel *m_loaderror=new QLabel;
|
||||||
|
QString serverUrl;
|
||||||
|
bool configCanSave=false;
|
||||||
|
bool isBusy=false;
|
||||||
|
int nowMenu=0; //定位当前菜单
|
||||||
long download_size=0;
|
long download_size=0;
|
||||||
long size1=0;
|
long size1=0;
|
||||||
long size2=0;
|
long size2=0;
|
||||||
|
QPixmap screen[5];
|
||||||
|
QFuture<void> load;
|
||||||
|
QTimer download_speed;
|
||||||
|
QString type_name;
|
||||||
|
QColor main_color;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user