mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-12-15 21:32:05 +08:00
Compare commits
27 Commits
1.0
...
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 | |||
| a3ca04ddc5 | |||
| 147258a7ac | |||
| 68269577c0 | |||
| 58304f2c19 |
42
README.md
42
README.md
@@ -1,32 +1,52 @@
|
||||
# 深度社区应用商店
|
||||
# 星火商店
|
||||
|
||||
#### 介绍
|
||||
deepin社区商店,由社区维护
|
||||
星火商店商店,由深度社区爱好者维护
|
||||
web页面部分正在开发当中,详情请见[web仓库](https://gitee.com/deepin-community-store/DCSAPP_WEB)
|
||||
#### 编译指导
|
||||
依赖:dtk2版(适用于ubuntu/15.11):qt5-default g++ libdtkcore2-dev libdtkwidget2-dev libqt5webkit5-dev libdtkgui2-dev
|
||||
dtk5版(适用于20beta):qt5-default g++ libdtkwidget5-dev libdtkcore5-dev libdtkgui5-dev libqt5webkit5-dev
|
||||
|
||||
#### 说明
|
||||
|
||||
需要在运行目录下放置服务器线路列表`server.list`,每行一个,在末尾需要添加“/”
|
||||
|
||||
当前服务器线路列表(项目中包含):
|
||||
|
||||
```
|
||||
http://dcstore.shenmo.tech/
|
||||
http://store.shenmo.tech/
|
||||
http://store2.shenmo.tech/
|
||||
http://store.moshengren.xyz/
|
||||
http://store.jerrywang.top/
|
||||
```
|
||||
|
||||
#### 参数
|
||||
|
||||
参数只有一个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/`中。
|
||||
|
||||
配置文件被储存到`~/.config/deepin-community-store/`中。
|
||||
|
||||
线路文件:当前运行目录下的`./server.list`
|
||||
线路文件:新版的线路文件被放置于源服务器中,可随时刷新更新源列表
|
||||
|
||||
#### 参与贡献
|
||||
|
||||
|
||||
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
|
||||
203
downloadlist.cpp
203
downloadlist.cpp
@@ -5,6 +5,7 @@
|
||||
#include <QPixmap>
|
||||
#include <QtConcurrent>
|
||||
#include <QProcess>
|
||||
#include <QTextBrowser>
|
||||
bool downloadlist::isInstall=false;
|
||||
|
||||
downloadlist::downloadlist(QWidget *parent) :
|
||||
@@ -12,11 +13,19 @@ downloadlist::downloadlist(QWidget *parent) :
|
||||
ui(new Ui::downloadlist)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->pushButton->setEnabled(false);
|
||||
ui->pushButton_install->setEnabled(false);
|
||||
ui->progressBar->setValue(0);
|
||||
ui->label_filename->hide();
|
||||
ui->pushButton->hide();
|
||||
ui->label->setStyleSheet("color:#000000");
|
||||
ui->pushButton_install->hide();
|
||||
ui->pushButton_3->hide();
|
||||
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()
|
||||
@@ -26,16 +35,16 @@ downloadlist::~downloadlist()
|
||||
|
||||
void downloadlist::setValue(long long value)
|
||||
{
|
||||
ui->progressBar->setValue(value);
|
||||
ui->label_2->setText(QString::number((double)value/100)+"%");
|
||||
if(ui->label_2->text()=="100%"){
|
||||
ui->progressBar->setValue(int(value));
|
||||
ui->label_2->setText(QString::number(double(value)/100)+"% ("+speed+")");
|
||||
if(ui->label_2->text().left(4)=="100%"){
|
||||
ui->label_2->setText("已完成,等待安装");
|
||||
}
|
||||
}
|
||||
|
||||
void downloadlist::setMax(long long max)
|
||||
{
|
||||
ui->progressBar->setMaximum(max);
|
||||
ui->progressBar->setMaximum(int(max));
|
||||
}
|
||||
|
||||
void downloadlist::setName(QString name)
|
||||
@@ -50,24 +59,24 @@ QString downloadlist::getName()
|
||||
|
||||
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){
|
||||
ui->progressBar->hide();
|
||||
ui->pushButton->setEnabled(true);
|
||||
ui->pushButton->show();
|
||||
ui->pushButton_install->setEnabled(true);
|
||||
ui->pushButton_install->show();
|
||||
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)
|
||||
@@ -85,46 +94,154 @@ void downloadlist::closeDownload()
|
||||
on_pushButton_2_clicked();
|
||||
}
|
||||
|
||||
void downloadlist::on_pushButton_clicked()
|
||||
void downloadlist::setSpeed(QString s)
|
||||
{
|
||||
speed=s;
|
||||
}
|
||||
|
||||
void downloadlist::install(int t)
|
||||
{
|
||||
if(!isInstall){
|
||||
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("正在安装,请稍候");
|
||||
QtConcurrent::run([=](){
|
||||
QProcess installer;
|
||||
installer.start("pkexec apt install -y /tmp/deepin-community-store/"+ui->label_filename->text().toUtf8());
|
||||
if(reinstall){
|
||||
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 {
|
||||
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();
|
||||
QString error=QString::fromStdString(installer.readAllStandardError().toStdString());
|
||||
QStringList everyError=error.split("\n");
|
||||
out=installer.readAllStandardOutput();
|
||||
QStringList everyOut=out.split("\n");
|
||||
bool haveError=false;
|
||||
bool notRoot=false;
|
||||
for (int i=0;i<everyError.size();i++) {
|
||||
qDebug()<<everyError[i].left(2);
|
||||
if(everyError[i].left(2)=="E:"){
|
||||
for (int i=0;i<everyOut.size();i++) {
|
||||
qDebug()<<everyOut[i].left(2);
|
||||
if(everyOut[i].left(2)=="E:"){
|
||||
haveError=true;
|
||||
}
|
||||
if(everyError[i].right(14)=="Not authorized"){
|
||||
if(everyOut[i].right(14)=="Not authorized"){
|
||||
notRoot=true;
|
||||
}
|
||||
}
|
||||
if(!haveError && !notRoot){
|
||||
ui->pushButton->hide();
|
||||
QProcess isInstall;
|
||||
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("安装完成");
|
||||
}else if(haveError){
|
||||
ui->pushButton->hide();
|
||||
ui->label_2->setText("安装出现错误");
|
||||
ui->pushButton_3->show();
|
||||
}else {
|
||||
ui->label_2->setText("安装被终止");
|
||||
ui->pushButton_install->show();
|
||||
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;
|
||||
|
||||
});
|
||||
// system("x-terminal-emulator -e sudo apt install -y ./"+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()
|
||||
{
|
||||
ui->label_2->setText("已取消下载");
|
||||
@@ -132,3 +249,15 @@ void downloadlist::on_pushButton_2_clicked()
|
||||
ui->progressBar->hide();
|
||||
close=true;
|
||||
}
|
||||
|
||||
void downloadlist::on_pushButton_3_clicked()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
#define DOWNLOADLIST_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <DDialog>
|
||||
#include <QTextBrowser>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
DWIDGET_USE_NAMESPACE
|
||||
namespace Ui {
|
||||
class downloadlist;
|
||||
}
|
||||
@@ -18,23 +23,33 @@ public:
|
||||
void setName(QString);
|
||||
QString getName();
|
||||
void readyInstall();
|
||||
void choose(bool);
|
||||
bool free;
|
||||
void setFileName(QString);
|
||||
void seticon(const QPixmap);
|
||||
void closeDownload();
|
||||
void setSpeed(QString);
|
||||
int num;
|
||||
bool close=false;
|
||||
|
||||
QString out;
|
||||
DDialog output_w;
|
||||
QTextBrowser *textbrowser=new QTextBrowser;
|
||||
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:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_pushButton_install_clicked();
|
||||
void on_pushButton_maninst_clicked();
|
||||
void on_pushButton_2_clicked();
|
||||
|
||||
void on_pushButton_3_clicked();
|
||||
|
||||
private:
|
||||
Ui::downloadlist *ui;
|
||||
static bool isInstall;
|
||||
QString speed;
|
||||
|
||||
|
||||
};
|
||||
//bool downloadlist::isInstall=false;
|
||||
|
||||
206
downloadlist.ui
206
downloadlist.ui
@@ -6,29 +6,128 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>744</width>
|
||||
<width>776</width>
|
||||
<height>54</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>54</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<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>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>48</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>icon</string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<widget class="QLabel" name="label_filename">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>80</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>名称</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>350</width>
|
||||
<width>280</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
@@ -61,7 +160,7 @@
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>350</width>
|
||||
<width>300</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
@@ -97,8 +196,8 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
@@ -113,24 +212,18 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<item>
|
||||
<widget class="DSpinner" name="widget_spinner" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
<width>30</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_install">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
@@ -148,47 +241,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>13</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>名称</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>icon</string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="8">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@@ -207,8 +260,35 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>详情</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>DSpinner</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">dspinner.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</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
|
||||
46
main.cpp
46
main.cpp
@@ -1,28 +1,54 @@
|
||||
#include "mainwindow.h"
|
||||
#include <DApplication>
|
||||
#include <DWidgetUtil> //Dtk::Widget::moveToCenter(&w); 要调用它,就得引用DWidgetUtil
|
||||
|
||||
#include <QDesktopWidget>
|
||||
DWIDGET_USE_NAMESPACE
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
DApplication::loadDXcbPlugin(); //让bar处在标题栏中
|
||||
DApplication a(argc, argv);
|
||||
|
||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
a.loadTranslator();
|
||||
a.setOrganizationName("deepin");
|
||||
a.setApplicationVersion(DApplication::buildVersion("1.0"));
|
||||
a.setApplicationAcknowledgementPage("https://gitee.com/deepin-community-store/deepin-community-store");
|
||||
a.setProductIcon(QIcon::fromTheme("deepin-community-store")); //设置Logo
|
||||
a.setProductName("深度社区应用商店");
|
||||
a.setApplicationName("社区应用商店"); //只有在这儿修改窗口标题才有效
|
||||
a.setOrganizationName("spark-union");
|
||||
a.setApplicationVersion(DApplication::buildVersion("1.0-beta5.6"));
|
||||
a.setApplicationAcknowledgementPage("https://gitee.com/deepin-community-store/spark-store");
|
||||
a.setProductIcon(QIcon::fromTheme("spark-store")); //设置Logo
|
||||
|
||||
a.setProductName("Spark应用商店");
|
||||
a.setApplicationDescription("深度社区驱动的一款为deepin打造的第三方商店");
|
||||
a.setApplicationName("Spark应用商店"); //只有在这儿修改窗口标题才有效
|
||||
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);
|
||||
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <DMainWindow>
|
||||
|
||||
#include <QDesktopWidget>
|
||||
#include <DTitlebar>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <DFileServices>
|
||||
#include <DApplicationHelper>
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
@@ -10,11 +15,65 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
w = new Widget;
|
||||
|
||||
resize(w->size()); //设置窗口大小
|
||||
setMinimumSize(900,750);
|
||||
setCentralWidget(w);
|
||||
|
||||
//添加搜索框
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MainWindow::openUrl(QUrl url)
|
||||
{
|
||||
w->openUrl(url);
|
||||
|
||||
}
|
||||
|
||||
|
||||
12
mainwindow.h
12
mainwindow.h
@@ -3,18 +3,26 @@
|
||||
|
||||
#include <DMainWindow>
|
||||
#include "widget.h"
|
||||
|
||||
#include <QThread>
|
||||
#include <DSearchEdit>
|
||||
#include <DBlurEffectWidget>
|
||||
#include <DTitlebar>
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
class MainWindow : public DMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
MainWindow(QWidget *parent = 0);
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
DSearchEdit *searchEdit=new DSearchEdit;
|
||||
DTitlebar *titlebar=new DTitlebar;
|
||||
void openUrl(QUrl);
|
||||
|
||||
private:
|
||||
|
||||
Widget *w;
|
||||
};
|
||||
|
||||
|
||||
@@ -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/#/
|
||||
@@ -8,7 +8,7 @@ QT += core gui webkitwidgets network concurrent
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
TARGET = deepin-community-store
|
||||
TARGET = spark-store
|
||||
TEMPLATE = app
|
||||
|
||||
# The following define makes your compiler emit warnings if you use
|
||||
@@ -26,11 +26,15 @@ DEFINES += QT_DEPRECATED_WARNINGS
|
||||
SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
widget.cpp \
|
||||
downloadlist.cpp
|
||||
downloadlist.cpp \
|
||||
image_show.cpp \
|
||||
big_image.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
widget.h \
|
||||
downloadlist.h
|
||||
downloadlist.h \
|
||||
image_show.h \
|
||||
big_image.h
|
||||
|
||||
CONFIG += link_pkgconfig
|
||||
PKGCONFIG += dtkwidget
|
||||
2
ssinstall
Executable file
2
ssinstall
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
dpkg -i $1 || apt install -yf || dpkg -P $1
|
||||
845
widget.cpp
845
widget.cpp
@@ -18,144 +18,248 @@
|
||||
#include <QIcon>
|
||||
#include <QWebFrame>
|
||||
#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) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Widget)
|
||||
{
|
||||
QString serverUrl;
|
||||
std::fstream server;
|
||||
|
||||
ui->setupUi(this);
|
||||
ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);//用来激活接受linkClicked信号
|
||||
ui->webView->page()->settings()->setAttribute(QWebSettings::JavascriptEnabled,true);
|
||||
ui->stackedWidget->setCurrentIndex(0);
|
||||
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("server.list",std::ios::in);
|
||||
std::string lineTmp;
|
||||
while (getline(server,lineTmp)) {
|
||||
ui->comboBox_server->addItem(QString::fromStdString(lineTmp));
|
||||
}
|
||||
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[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()<<" ";}));
|
||||
initUI();
|
||||
initConfig();
|
||||
manager = new QNetworkAccessManager(this);//下载管理
|
||||
|
||||
connect(ui->menu_main,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(0);});
|
||||
connect(ui->menu_network,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(1);});
|
||||
connect(ui->menu_chat,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(2);});
|
||||
connect(ui->menu_music,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(3);});
|
||||
connect(ui->menu_video,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(4);});
|
||||
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);});
|
||||
|
||||
//计算显示下载速度
|
||||
download_speed.setInterval(1000);
|
||||
download_speed.start();
|
||||
connect(&download_speed,&QTimer::timeout,[=](){
|
||||
if(isdownload){
|
||||
size1=download_size;
|
||||
QString theSpeed;
|
||||
double bspeed;
|
||||
bspeed=size1-size2;
|
||||
if(bspeed<1024){
|
||||
theSpeed=QString::number(bspeed)+"B/s";
|
||||
}else if (bspeed<(1024*1024)) {
|
||||
theSpeed=QString::number(0.01*int(100*(bspeed/1024)))+"KB/s";
|
||||
}else if (bspeed<(1024*1024*1024)) {
|
||||
theSpeed=QString::number(0.01*int(100*(bspeed/(1024*1024))))+"MB/s";
|
||||
}else {
|
||||
theSpeed=QString::number(0.01*int(100*(bspeed/(1024*1024*1024))))+"GB/s";
|
||||
}
|
||||
download_list[nowDownload-1].setSpeed(theSpeed);
|
||||
size2=download_size;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Widget::~Widget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void Widget::on_webView_linkClicked(const QUrl &arg1)
|
||||
void Widget::initUI()
|
||||
{
|
||||
//这里通过获取url的方式和现有web不符,
|
||||
// qDebug()<<arg1;
|
||||
// //判断,如果末尾是/就直接访问,如果是app.json就打开详情页
|
||||
// if(arg1.path().right(1)=="/"){
|
||||
// ui->webView->setUrl(arg1);
|
||||
// }else if(arg1.path().right(8)=="app.json"){
|
||||
// load.cancel();//打开并发加载线程前关闭正在执行的线程
|
||||
//// load.waitForFinished();
|
||||
// QPixmap pixmap_null;//一个空的图片指针,用来清空先有内容
|
||||
// ui->label_appicon->setPixmap(pixmap_null);
|
||||
// ui->screen_1->setPixmap(pixmap_null);
|
||||
// ui->screen_2->setPixmap(pixmap_null);
|
||||
// ui->screen_3->setPixmap(pixmap_null);
|
||||
// ui->screen_4->setPixmap(pixmap_null);
|
||||
// ui->screen_5->setPixmap(pixmap_null);
|
||||
// //先隐藏详情页负责显示截图的label
|
||||
// ui->screen_1->hide();
|
||||
// ui->screen_2->hide();
|
||||
// ui->screen_3->hide();
|
||||
// ui->screen_4->hide();
|
||||
// ui->screen_5->hide();
|
||||
// ui->label_more->setText("");//清空详情介绍
|
||||
// ui->label_info->setText("");
|
||||
// ui->label_appname->setText("");
|
||||
// ui->pushButton->setEnabled(false);
|
||||
// ui->stackedWidget->setCurrentIndex(2);
|
||||
// load.cancel();//打开并发加载线程前关闭正在执行的线程
|
||||
// load = QtConcurrent::run([=](){
|
||||
// loadappinfo(arg1);
|
||||
// });
|
||||
// }
|
||||
//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);
|
||||
|
||||
//给下载列表赋值到数组,方便调用
|
||||
for (int i =0; i<LIST_MAX;i++){
|
||||
download_list[i].num=i;
|
||||
}
|
||||
|
||||
//初始化apt源显示
|
||||
QFile aptserver("/etc/apt/sources.list.d/sparkstore.list");
|
||||
aptserver.open(QIODevice::ReadOnly);
|
||||
if(aptserver.isOpen()){
|
||||
ui->label_aptserver->setText(aptserver.readAll());
|
||||
}else {
|
||||
ui->label_aptserver->setText("不存在");
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
void Widget::on_webView_loadStarted()
|
||||
{
|
||||
|
||||
ui->label_show->setText("正在加载,请稍候");
|
||||
ui->label_show->show();
|
||||
m_loadweb->setValue(0);
|
||||
m_loadweb->show();
|
||||
m_loaderror->hide();
|
||||
ui->label_show->hide();
|
||||
|
||||
//分析出服务器中的分类名称
|
||||
QUrl arg1=ui->webView->page()->mainFrame()->requestedUrl().toString();
|
||||
qDebug()<<arg1;
|
||||
//判断,如果末尾是/就直接访问,如果是app.json就打开详情页
|
||||
QStringList url_=arg1.path().split("/");
|
||||
if(url_.size()>3){
|
||||
type_name=url_[2];
|
||||
}
|
||||
//如果是app.json就打开详情页
|
||||
if(arg1.path().right(8)=="app.json"){
|
||||
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
||||
load.waitForFinished();
|
||||
QPixmap pixmap_null;//一个空的图片指针,用来清空先有内容
|
||||
QPixmap pixmap_null;//一个空的图片,用来清空现有内容
|
||||
ui->label_appicon->setPixmap(pixmap_null);
|
||||
ui->screen_1->setPixmap(pixmap_null);
|
||||
ui->screen_2->setPixmap(pixmap_null);
|
||||
ui->screen_3->setPixmap(pixmap_null);
|
||||
ui->screen_4->setPixmap(pixmap_null);
|
||||
ui->screen_5->setPixmap(pixmap_null);
|
||||
ui->screen_0->setImage(pixmap_null);
|
||||
ui->screen_1->setImage(pixmap_null);
|
||||
ui->screen_2->setImage(pixmap_null);
|
||||
ui->screen_3->setImage(pixmap_null);
|
||||
ui->screen_4->setImage(pixmap_null);
|
||||
//先隐藏详情页负责显示截图的label
|
||||
ui->screen_0->hide();
|
||||
ui->screen_1->hide();
|
||||
ui->screen_2->hide();
|
||||
ui->screen_3->hide();
|
||||
ui->screen_4->hide();
|
||||
ui->screen_5->hide();
|
||||
ui->label_more->setText("");//清空详情介绍
|
||||
ui->label_info->setText("");
|
||||
ui->label_appname->setText("");
|
||||
ui->pushButton->setEnabled(false);
|
||||
ui->pushButton_download->setEnabled(false);
|
||||
ui->stackedWidget->setCurrentIndex(2);
|
||||
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
||||
load = QtConcurrent::run([=](){
|
||||
@@ -163,97 +267,128 @@ void Widget::on_webView_loadStarted()
|
||||
});
|
||||
}
|
||||
}
|
||||
void Widget::loadappinfo(QUrl arg1)
|
||||
//菜单切换逻辑
|
||||
|
||||
void Widget::chooseLeftMenu(int index)
|
||||
{
|
||||
|
||||
ui->label_show->setText("正在加载,请稍候");
|
||||
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->show();
|
||||
ui->pushButton_website->hide();
|
||||
|
||||
QProcess get_json;
|
||||
QDir dir;
|
||||
dir.cd("/tmp");
|
||||
dir.mkdir("deepin-community-store");
|
||||
QDir::setCurrent("/tmp/deepin-community-store");
|
||||
get_json.start("wget -O app.json "+arg1.toString());
|
||||
QDir dir("/tmp");
|
||||
dir.mkdir("spark-store");
|
||||
QDir::setCurrent("/tmp/spark-store");
|
||||
get_json.start("curl -o app.json "+arg1.toString());
|
||||
get_json.waitForFinished();
|
||||
QFile app_json("app.json");
|
||||
if(app_json.open(QIODevice::ReadOnly)){
|
||||
// //成功得到json文件
|
||||
// //成功得到json文件
|
||||
QByteArray json_array=app_json.readAll();
|
||||
//将路径转化为相应源的下载路径
|
||||
urladdress=arg1.toString().left(arg1.toString().length()-8);
|
||||
QStringList downloadurl=urladdress.split("/");
|
||||
urladdress=ui->comboBox_server->currentText();
|
||||
QString deburl=urladdress;
|
||||
urladdress="http://img.shenmo.tech:38324/";//使用图片专用服务器请保留这行,删除后将使用源服务器
|
||||
|
||||
for (int i=3;i<downloadurl.size();i++) {
|
||||
urladdress+="/"+downloadurl[i];
|
||||
deburl+="/"+downloadurl[i];
|
||||
}
|
||||
//路径转化完成
|
||||
QJsonObject json= QJsonDocument::fromJson(json_array).object();
|
||||
appName = json["Name"].toString();
|
||||
url=urladdress + json["Filename"].toString();
|
||||
url=deburl + json["Filename"].toString();
|
||||
qDebug()<<url;
|
||||
ui->label_appname->setText(appName);
|
||||
system("rm -r *.png");
|
||||
ui->label_show->show();
|
||||
//软件信息加载
|
||||
QString info;
|
||||
info="包名:"+json["Pkgname"].toString()+"\n";
|
||||
info+="版本号:"+json["Version"].toString()+"\n";
|
||||
info="包名: "+json["Pkgname"].toString()+"\n";
|
||||
info+="版本号: "+json["Version"].toString()+"\n";
|
||||
if(json["Author"].toString()!="" && json["Author"].toString()!=" "){
|
||||
info+="作者:"+json["Author"].toString()+"\n";
|
||||
info+="作者: "+json["Author"].toString()+"\n";
|
||||
}
|
||||
|
||||
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["Update"].toString()+"\n";
|
||||
info+="大小:"+json["Size"].toString()+"\n";
|
||||
info+="投稿者: "+json["Contributor"].toString()+"\n";
|
||||
info+="更新时间: "+json["Update"].toString()+"\n";
|
||||
info+="大小: "+json["Size"].toString()+"\n";
|
||||
ui->label_info->setText(info);
|
||||
ui->label_more->setText(json["More"].toString());
|
||||
QProcess isInstall;
|
||||
pkgName=json["Pkgname"].toString();
|
||||
isInstall.start("dpkg -s "+json["Pkgname"].toString());
|
||||
isInstall.waitForFinished();
|
||||
int error=QString::fromStdString(isInstall.readAllStandardError().toStdString()).length();
|
||||
if(error==0){
|
||||
ui->pushButton->setText("重新安装");
|
||||
ui->pushButton_download->setText("重新安装");
|
||||
ui->pushButton_uninstall->show();
|
||||
|
||||
}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();
|
||||
QPixmap appicon;
|
||||
qDebug()<<appicon.load("icon.png");
|
||||
QPixmap appicon(QString::fromUtf8(TMP_PATH)+"/icon.png");
|
||||
ui->label_appicon->setPixmap(appicon);
|
||||
ui->pushButton->setEnabled(true);
|
||||
ui->pushButton_download->setEnabled(true);
|
||||
//截图展示加载
|
||||
get_json.start("wget "+urladdress+"screen_1.png");
|
||||
get_json.waitForFinished();
|
||||
if(screen[0].load("screen_1.png")){
|
||||
ui->screen_1->show();
|
||||
ui->screen_1->setPixmap(screen[0]);
|
||||
ui->screen_1->setScaledContents(true);
|
||||
}
|
||||
get_json.start("wget "+urladdress+"screen_2.png");
|
||||
get_json.waitForFinished();
|
||||
if(screen[1].load("screen_2.png")){
|
||||
ui->screen_2->show();
|
||||
ui->screen_2->setPixmap(screen[1]);
|
||||
ui->screen_2->setScaledContents(true);
|
||||
}
|
||||
get_json.start("wget "+urladdress+"screen_3.png");
|
||||
get_json.waitForFinished();
|
||||
if(screen[2].load("screen_3.png")){
|
||||
ui->screen_3->show();
|
||||
ui->screen_3->setPixmap(screen[2]);
|
||||
ui->screen_3->setScaledContents(true);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
image_show *label_screen[5];
|
||||
label_screen[0]=ui->screen_0;
|
||||
label_screen[1]=ui->screen_1;
|
||||
label_screen[2]=ui->screen_2;
|
||||
label_screen[3]=ui->screen_3;
|
||||
label_screen[4]=ui->screen_4;
|
||||
ui->screen_0->hide();
|
||||
ui->screen_1->hide();
|
||||
ui->screen_2->hide();
|
||||
ui->screen_3->hide();
|
||||
ui->screen_4->hide();
|
||||
for (int i=0;i<5;i++) {
|
||||
get_json.start("curl -o screen_"+QString::number(i)+".png "+urladdress+"screen_"+QString::number(i)+".png");
|
||||
get_json.waitForFinished();
|
||||
if(screen[i].load("screen_"+QString::number(i)+".png")){
|
||||
label_screen[i]->setImage(screen[i]);
|
||||
label_screen[i]->show();
|
||||
switch(i){ //故意为之,为了清除多余截图
|
||||
case 0:
|
||||
label_screen[1]->hide();
|
||||
case 1:
|
||||
label_screen[2]->hide();
|
||||
case 2:
|
||||
label_screen[3]->hide();
|
||||
case 3:
|
||||
label_screen[4]->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
ui->label_show->setText("");
|
||||
ui->label_show->hide();
|
||||
@@ -262,41 +397,25 @@ void Widget::loadappinfo(QUrl arg1)
|
||||
|
||||
}
|
||||
|
||||
void Widget::chooseLeftMenu(int index)
|
||||
{
|
||||
nowMenu=index;
|
||||
for (int i=0;i<15;i++) {
|
||||
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
||||
left_list[i]->setStyleSheet("");
|
||||
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;
|
||||
QFileInfo info(url.path());
|
||||
QString fileName(info.fileName()); //获取文件名
|
||||
download_list[allDownload-1].pkgName=pkgName;
|
||||
if(fileName.isEmpty())
|
||||
{
|
||||
fileName = "index.html";
|
||||
system("notify-send 获取失败 --icon=spark-store");
|
||||
return;
|
||||
}
|
||||
|
||||
download_list[allDownload-1].setParent(ui->listWidget);
|
||||
QListWidgetItem *item=new QListWidgetItem(ui->listWidget);
|
||||
item->setSizeHint(download_list[allDownload-1].size());
|
||||
item->setFlags(item->flags() & ~Qt::ItemIsEnabled & ~Qt::ItemIsSelectable);
|
||||
ui->listWidget->setItemWidget(item,&download_list[allDownload-1]);
|
||||
urList.append(url);
|
||||
download_list[allDownload-1].setName(appName);
|
||||
@@ -315,6 +434,9 @@ void Widget::on_pushButton_clicked()
|
||||
nowDownload+=1;
|
||||
startRequest(urList.at(nowDownload-1)); //进行链接请求
|
||||
}
|
||||
if(ui->pushButton_download->text()=="重新安装"){
|
||||
download_list[allDownload-1].reinstall=true;
|
||||
}
|
||||
}
|
||||
|
||||
void Widget::startRequest(QUrl url)
|
||||
@@ -331,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()
|
||||
{
|
||||
@@ -343,140 +478,242 @@ void Widget::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
|
||||
{
|
||||
download_list[nowDownload-1].setMax(10000); //最大值
|
||||
download_list[nowDownload-1].setValue((bytesRead*10000)/totalBytes); //当前值
|
||||
if(download_list[nowDownload-1].close){
|
||||
download_size=bytesRead;
|
||||
if(download_list[nowDownload-1].close){ //随时检测下载是否被取消
|
||||
download_list[nowDownload-1].closeDownload();
|
||||
httpFinished();
|
||||
|
||||
}
|
||||
// download_list[nowDownload-1].setMax(bytesRead/10);
|
||||
// download_list[nowDownload-1].setValue(totalBytes/10);
|
||||
}
|
||||
|
||||
void Widget::httpFinished() //完成下载
|
||||
{
|
||||
|
||||
file->flush();
|
||||
file->close();
|
||||
reply->deleteLater();
|
||||
reply = nullptr;
|
||||
delete file;
|
||||
file = nullptr;
|
||||
isdownload=false;
|
||||
isBusy=false;
|
||||
download_list[nowDownload-1].readyInstall();
|
||||
download_list[nowDownload-1].free=true;
|
||||
if(nowDownload<allDownload){
|
||||
nowDownload+=1;
|
||||
while (download_list[nowDownload-1].close) {
|
||||
file->flush();
|
||||
file->close();
|
||||
reply->deleteLater();
|
||||
reply = nullptr;
|
||||
delete file;
|
||||
file = nullptr;
|
||||
isdownload=false;
|
||||
isBusy=false;
|
||||
download_list[nowDownload-1].readyInstall();
|
||||
download_list[nowDownload-1].free=true;
|
||||
if(nowDownload<allDownload){ //如果有排队则下载下一个
|
||||
nowDownload+=1;
|
||||
while (download_list[nowDownload-1].close) {
|
||||
nowDownload+=1;
|
||||
}
|
||||
QString fileName=download_list[nowDownload-1].getName();
|
||||
file = new QFile(fileName);
|
||||
if(!file->open(QIODevice::WriteOnly))
|
||||
{
|
||||
delete file;
|
||||
file = nullptr;
|
||||
return ;
|
||||
}
|
||||
startRequest(urList.at(nowDownload-1));
|
||||
}
|
||||
QString fileName=download_list[nowDownload-1].getName();
|
||||
file = new QFile(fileName);
|
||||
if(!file->open(QIODevice::WriteOnly))
|
||||
{
|
||||
qDebug()<<"file open error";
|
||||
delete file;
|
||||
file = nullptr;
|
||||
return ;
|
||||
}
|
||||
startRequest(urList.at(nowDownload-1));
|
||||
}
|
||||
}
|
||||
void Widget::on_listWidget_currentRowChanged(int currentRow)
|
||||
{
|
||||
qDebug()<<currentRow;
|
||||
for (int i=0;i<allDownload;i++) {
|
||||
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()
|
||||
|
||||
|
||||
|
||||
void Widget::on_pushButton_return_clicked()
|
||||
{
|
||||
ui->webView->setUrl(menuUrl[nowMenu]);
|
||||
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)
|
||||
{
|
||||
if(configCanSeve){
|
||||
if(configCanSave){
|
||||
ui->label_setting1->show();
|
||||
QSettings *setConfig=new QSettings(QDir::homePath()+"/.config/deepin-community-store/config.ini",QSettings::IniFormat);
|
||||
qDebug()<<arg1;
|
||||
QSettings *setConfig=new QSettings(QDir::homePath()+"/.config/spark-store/config.ini",QSettings::IniFormat);
|
||||
setConfig->setValue("server/choose",arg1);
|
||||
}
|
||||
}
|
||||
void Widget::on_pushButton_updateServer_clicked()
|
||||
{
|
||||
QtConcurrent::run([=](){
|
||||
ui->pushButton_updateServer->setEnabled(false);
|
||||
ui->comboBox_server->clear();
|
||||
QFile::remove(QDir::homePath().toUtf8()+"/.config/spark-store/server.list");
|
||||
system("curl -o "+QDir::homePath().toUtf8()+"/.config/spark-store/server.list http://dcstore.shenmo.tech/store/server.list");
|
||||
std::fstream server;
|
||||
server.open(QDir::homePath().toUtf8()+"/.config/spark-store/server.list",std::ios::in);
|
||||
std::string lineTmp;
|
||||
if(server){
|
||||
while (getline(server,lineTmp)) {
|
||||
ui->comboBox_server->addItem(QString::fromStdString(lineTmp));
|
||||
}
|
||||
}else {
|
||||
ui->comboBox_server->addItem("http://store.jerrywang.top/");
|
||||
}
|
||||
ui->pushButton_updateServer->setEnabled(true);
|
||||
ui->comboBox_server->setCurrentIndex(0);
|
||||
});
|
||||
}
|
||||
|
||||
void Widget::on_pushButton_updateApt_clicked()
|
||||
{
|
||||
QtConcurrent::run([=](){
|
||||
ui->pushButton_updateApt->setEnabled(false);
|
||||
ui->label_aptserver->setText("请稍等,正在更新");
|
||||
std::fstream sourcesList;
|
||||
QDir tmpdir("/tmp");
|
||||
tmpdir.mkpath("spark-store");
|
||||
sourcesList.open(QString::fromUtf8(TMP_PATH).toStdString()+"/sparkstore.list",std::ios::out);
|
||||
if(sourcesList){
|
||||
sourcesList<<"deb [by-hash=force] ";
|
||||
sourcesList<<QString::fromUtf8(ui->comboBox_server->currentText().toUtf8()).toStdString();
|
||||
sourcesList<<" /";
|
||||
std::fstream update;
|
||||
update.open(QString::fromUtf8(TMP_PATH).toStdString()+"/update.sh",std::ios::out);
|
||||
update<<"#!/bin/sh\n";
|
||||
update<<"mv "+QString::fromUtf8(TMP_PATH).toStdString()+"/sparkstore.list /etc/apt/sources.list.d/sparkstore.list && apt update";
|
||||
update.close();
|
||||
system("chmod +x "+QString::fromUtf8(TMP_PATH).toUtf8()+"/update.sh");
|
||||
QProcess runupdate;
|
||||
runupdate.start("pkexec "+QString::fromUtf8(TMP_PATH)+"/update.sh");
|
||||
runupdate.waitForFinished();
|
||||
QString error=QString::fromStdString(runupdate.readAllStandardError().toStdString());
|
||||
QStringList everyError=error.split("\n");
|
||||
bool haveError=false;
|
||||
for (int i=0;i<everyError.size();i++) {
|
||||
if(everyError[i].left(2)=="E:"){
|
||||
haveError=true;
|
||||
}
|
||||
}
|
||||
if(!haveError){
|
||||
ui->label_aptserver->setText("deb [by-hash=force] "+ui->comboBox_server->currentText().toUtf8()+" /");
|
||||
}else {
|
||||
ui->label_aptserver->setText("更新中发生错误,请在终端使用apt update来查看错误原因");
|
||||
}
|
||||
}else {
|
||||
ui->label_aptserver->setText("服务器错误");
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
110
widget.h
110
widget.h
@@ -11,79 +11,63 @@
|
||||
#include <QProcess>
|
||||
#include <QFuture>
|
||||
#include <QToolButton>
|
||||
#define LIST_MAX 99
|
||||
#include <QTimer>
|
||||
#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 {
|
||||
class Widget;
|
||||
}
|
||||
|
||||
|
||||
|
||||
class Widget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Widget(QWidget *parent = 0);
|
||||
explicit Widget(QWidget *parent = nullptr);
|
||||
~Widget();
|
||||
void startRequest(QUrl url);
|
||||
void searchApp(QString);
|
||||
int nowDownload=0;
|
||||
int allDownload=0;
|
||||
int isdownload=false;
|
||||
void loadappinfo(QUrl);
|
||||
void chooseLeftMenu(int index);
|
||||
QPixmap screen[5];
|
||||
QFuture<void> load;
|
||||
|
||||
void opensetting(); //打开设置页面
|
||||
void openUrl(QUrl);
|
||||
void setTheme(bool,QColor);
|
||||
|
||||
private slots:
|
||||
|
||||
void on_webView_linkClicked(const QUrl &arg1);
|
||||
void httpFinished();
|
||||
void httpReadyRead();
|
||||
void updateDataReadProgress(qint64,qint64);
|
||||
void on_menu_btn_main_clicked();
|
||||
|
||||
void on_menu_btn_network_clicked();
|
||||
|
||||
void on_menu_btn_download_clicked();
|
||||
|
||||
void on_menu_btn_chat_clicked();
|
||||
|
||||
void on_menu_btn_music_clicked();
|
||||
|
||||
void on_menu_btn_video_clicked();
|
||||
|
||||
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_download_clicked();
|
||||
void on_pushButton_return_clicked();
|
||||
void on_webView_loadStarted();
|
||||
void on_comboBox_server_currentIndexChanged(const QString &arg1);
|
||||
void on_pushButton_updateServer_clicked();
|
||||
void on_pushButton_updateApt_clicked();
|
||||
void on_pushButton_uninstall_clicked();
|
||||
void on_pushButton_clear_clicked();
|
||||
void on_pushButton_website_clicked();
|
||||
void on_webView_loadFinished(bool arg1);
|
||||
void on_webView_loadProgress(int progress);
|
||||
|
||||
void on_pushButton_clicked();
|
||||
|
||||
void on_pushButton_2_clicked();
|
||||
void on_btn_openDir_clicked();
|
||||
|
||||
void on_webView_loadStarted();
|
||||
public:
|
||||
|
||||
void on_webView_loadFinished();
|
||||
|
||||
void on_menu_btn_theme_clicked();
|
||||
|
||||
void on_menu_btn_settings_clicked();
|
||||
|
||||
void on_comboBox_server_currentIndexChanged(const QString &arg1);
|
||||
|
||||
private:
|
||||
QUrl url;
|
||||
bool isBusy=false;
|
||||
|
||||
downloadlist download_list[LIST_MAX];
|
||||
Ui::Widget *ui;
|
||||
QNetworkAccessManager *manager;
|
||||
@@ -92,11 +76,33 @@ private:
|
||||
QFile *file;
|
||||
QString appName;
|
||||
QString urladdress;
|
||||
QToolButton * left_list[15];
|
||||
QWidget * left_menu_bg[15];
|
||||
QString pkgName;
|
||||
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];
|
||||
bool configCanSeve=false;
|
||||
int nowMenu=0;
|
||||
DWaterProgress *m_loadweb=new DWaterProgress;
|
||||
QLabel *m_loaderror=new QLabel;
|
||||
QString serverUrl;
|
||||
bool configCanSave=false;
|
||||
bool isBusy=false;
|
||||
int nowMenu=0; //定位当前菜单
|
||||
long download_size=0;
|
||||
long size1=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