Compare commits

..

32 Commits

Author SHA1 Message Date
Maicss
0e387acfb6 修复ssinstall安装参数问题 2020-08-04 14:41:57 +08:00
Maicss
c043542c04 更换 详情页专有服务器 2020-08-04 13:34:42 +08:00
Maicss
25b37ec0f2 更新 2020-08-04 10:27:06 +08:00
Maicss
a732269b62 新增 安装方式选择 2020-08-04 10:01:05 +08:00
Maicss
6d63ef60ac 新增 安装方式选择 2020-08-04 09:57:21 +08:00
张天怿
25456a413c 添加“手动安装”按钮
添加手动安装按钮来处理部分 gdebi 无法正确安装的应用(主要是 wine 应用)。
2020-08-03 18:25:08 +08:00
Maicss
ec1c91f021 修复 截图放大后可能会溢出屏幕 2020-07-29 20:51:18 +08:00
Maicss
46c1609d58 修改 截图预览背景参数 2020-07-28 17:31:00 +08:00
Maicss
9c5421133f 新增 预览截图时背景模糊
新增 打开下载文件夹功能
修复 取消下载被判定为下载失败
2020-07-28 17:08:47 +08:00
Maicss
114489c3d6 重写了截图查看窗口 2020-07-28 13:58:48 +08:00
Maicss
101a6bc370 修复 因ObjectName更改导致无法自动连接的问题 2020-07-28 13:04:49 +08:00
Maicss
9b47e4dd70 修改 左侧菜单为QPushButton 2020-07-28 12:56:15 +08:00
Maicss
6a555b06b9 修改 左侧菜单跟随系统活动色 2020-07-28 11:48:40 +08:00
Maicss
145b1b8e30 修复 下载未完成时断网,会显示下载成功 2020-07-28 10:38:03 +08:00
Maicss
23d8e9ea82 更新 版本号 2020-07-28 08:26:06 +08:00
Maicss
f723007166 优化 UI 2020-07-27 12:05:40 +08:00
Maicss
e0639a5855 修改 搜索框事件 2020-07-27 10:26:12 +08:00
Maicss
514be30e04 新增 链接分享 2020-07-27 10:20:50 +08:00
Maicss
817d497f4a 更新 文档中Url列表错误 2020-07-27 09:41:26 +08:00
8158159bf9 跟随 2020-07-26 11:32:48 +08:00
82f49c4aa9 跟随 2020-07-24 10:00:05 +08:00
b1c2b1bbc6 跟随到5.2 2020-07-13 19:26:09 +08:00
892766470c 跟随到beta5 2020-07-09 09:05:50 +08:00
a3ca04ddc5 更新到spark,加入apt-list的修改功能 2020-07-04 12:09:35 +08:00
147258a7ac SparkProject 2020-07-03 20:53:58 +08:00
68269577c0 beta3更新 2020-07-03 11:53:47 +08:00
58304f2c19 优化了app.json解析 2020-07-01 20:54:42 +08:00
4a4c1ce5a6 更新readme 2020-06-27 16:27:45 +08:00
536377d013 对接了web 2020-06-26 18:34:15 +08:00
72501163d4 更新 2020-06-26 14:34:49 +08:00
8e3f235910 跟随
提交者:沫 <jifengshenmo@outlook.com>
	修改:     downloadlist.cpp
	修改:     downloadlist.h
	修改:     downloadlist.ui
	新文件:   server.list
	修改:     widget.cpp
	修改:     widget.h
	修改:     widget.ui
2020-06-26 08:22:04 +08:00
5c8ee91a76 优化下载列表 2020-06-25 18:43:28 +08:00
17 changed files with 1820 additions and 1509 deletions

View File

@@ -1,22 +1,53 @@
# deepin-community-store
# 星火商店
#### 介绍
deepin社区商店由社区维护
web页面部分正在开发当中
星火商店商店,由深度社区爱好者维护
web页面部分正在开发当中,详情请见[web仓库](https://gitee.com/deepin-community-store/DCSAPP_WEB)
#### 说明
需要在运行目录下放置服务器线路列表`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/`中。
线路文件:新版的线路文件被放置于源服务器中,可随时刷新更新源列表
#### 参与贡献
1. Fork 本仓库

37
big_image.cpp Normal file
View 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
View 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

View File

@@ -1,326 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.8.2, 2020-06-25T14:44:37. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{964ed9bf-1dd7-4af2-8a95-0a12891624cd}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
<value type="int">0</value>
</data>
<data>
<variable>ProjectExplorer.Project.EditorSettings</variable>
<valuemap type="QVariantMap">
<value type="bool" key="EditorConfiguration.AutoIndent">true</value>
<value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
<value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
<value type="QString" key="language">Cpp</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
</valuemap>
</valuemap>
<valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
<value type="QString" key="language">QmlJS</value>
<valuemap type="QVariantMap" key="value">
<value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
</valuemap>
</valuemap>
<value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
<value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
<value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
<value type="int" key="EditorConfiguration.IndentSize">4</value>
<value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
<value type="int" key="EditorConfiguration.MarginColumn">80</value>
<value type="bool" key="EditorConfiguration.MouseHiding">true</value>
<value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
<value type="int" key="EditorConfiguration.PaddingMode">1</value>
<value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
<value type="bool" key="EditorConfiguration.ShowMargin">false</value>
<value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
<value type="bool" key="EditorConfiguration.SmartSelectionChanging">true</value>
<value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
<value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
<value type="int" key="EditorConfiguration.TabSize">8</value>
<value type="bool" key="EditorConfiguration.UseGlobal">true</value>
<value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
<value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
<value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
<value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
<value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.PluginSettings</variable>
<valuemap type="QVariantMap">
<valuelist type="QVariantList" key="ClangCodeModel.CustomCommandLineKey"/>
<value type="bool" key="ClangCodeModel.UseGlobalConfig">true</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">桌面</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{10c1a6c8-39fd-4308-b111-0e790b25d916}</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/vsesm/Desktop/新建文件夹/build-deepin-community-store-unknown-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/vsesm/Desktop/新建文件夹/build-deepin-community-store-unknown-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Release</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.2">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/vsesm/Desktop/新建文件夹/build-deepin-community-store-unknown-Profile</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">true</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
<valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.BuildTargets"/>
<value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
<value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
<value type="bool" key="Qt4ProjectManager.MakeStep.OverrideMakeflags">false</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
<value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
<valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Profile</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
<value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">3</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">部署</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
</valuemap>
<value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy Configuration</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.PluginSettings"/>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
<value type="bool" key="Analyzer.QmlProfiler.AggregateTraces">false</value>
<value type="bool" key="Analyzer.QmlProfiler.FlushEnabled">false</value>
<value type="uint" key="Analyzer.QmlProfiler.FlushInterval">1000</value>
<value type="QString" key="Analyzer.QmlProfiler.LastTraceFile"></value>
<value type="bool" key="Analyzer.QmlProfiler.Settings.UseGlobalSettings">true</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
<value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
<value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
<value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
<value type="int" key="Analyzer.Valgrind.LeakCheckOnFinish">1</value>
<value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
<value type="int" key="Analyzer.Valgrind.SelfModifyingCodeDetection">1</value>
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
<value type="int">5</value>
<value type="int">6</value>
<value type="int">7</value>
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">deepin-community-store</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/vsesm/Desktop/新建文件夹/deepin-community-store/deepin-community-store.pro</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">deepin-community-store.pro</value>
<value type="QString" key="RunConfiguration.Arguments"></value>
<value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
<value type="bool" key="RunConfiguration.UseCppDebugger">false</value>
<value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value>
<value type="bool" key="RunConfiguration.UseLibrarySearchPath">true</value>
<value type="bool" key="RunConfiguration.UseMultiProcess">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
<value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">true</value>
<value type="QString" key="RunConfiguration.WorkingDirectory"></value>
<value type="QString" key="RunConfiguration.WorkingDirectory.default">/home/vsesm/Desktop/新建文件夹/build-deepin-community-store-unknown-Debug</value>
</valuemap>
<value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
</valuemap>
</data>
<data>
<variable>ProjectExplorer.Project.TargetCount</variable>
<value type="int">1</value>
</data>
<data>
<variable>ProjectExplorer.Project.Updater.FileVersion</variable>
<value type="int">20</value>
</data>
<data>
<variable>Version</variable>
<value type="int">20</value>
</data>
</qtcreator>

View File

@@ -1,15 +1,31 @@
#include "downloadlist.h"
#include "ui_downloadlist.h"
#include <QDebug>
#include <QIcon>
#include <QPixmap>
#include <QtConcurrent>
#include <QProcess>
#include <QTextBrowser>
bool downloadlist::isInstall=false;
downloadlist::downloadlist(QWidget *parent) :
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->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()
@@ -19,12 +35,16 @@ downloadlist::~downloadlist()
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+")");
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)
@@ -39,18 +59,24 @@ QString downloadlist::getName()
void downloadlist::readyInstall()
{
ui->progressBar->hide();
ui->pushButton->setEnabled(true);
system("notify-send \""+ui->label->text().toUtf8()+"下载完成,等待安装\"");
}
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;
void downloadlist::choose(bool isChoosed)
{
if(isChoosed){
ui->label->setStyleSheet("color:#FFFFFF");
}else {
ui->label->setStyleSheet("color:#000000");
}
if(!close){
ui->progressBar->hide();
ui->pushButton_install->setEnabled(true);
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");
}
}
void downloadlist::setFileName(QString fileName)
@@ -58,8 +84,180 @@ void downloadlist::setFileName(QString fileName)
ui->label_filename->setText(fileName);
}
void downloadlist::on_pushButton_clicked()
void downloadlist::seticon(const QPixmap icon)
{
system("x-terminal-emulator -e sudo apt install -y ./"+ui->label_filename->text().toUtf8());
qDebug()<<ui->label_filename->text().toUtf8();
ui->label_3->setPixmap(icon);
}
void downloadlist::closeDownload()
{
on_pushButton_2_clicked();
}
void downloadlist::setSpeed(QString s)
{
speed=s;
}
void downloadlist::install(int t)
{
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){
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();
out=installer.readAllStandardOutput();
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();
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_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("已取消下载");
ui->pushButton_2->setEnabled(false);
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();
}

View File

@@ -2,7 +2,11 @@
#define DOWNLOADLIST_H
#include <QWidget>
#include <DDialog>
#include <QTextBrowser>
#include <QMenu>
#include <QAction>
DWIDGET_USE_NAMESPACE
namespace Ui {
class downloadlist;
}
@@ -19,16 +23,34 @@ public:
void setName(QString);
QString getName();
void readyInstall();
void choose(bool);
bool free;
void setFileName(QString);
public: signals:
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;
#endif // DOWNLOADLIST_H

View File

@@ -6,69 +6,88 @@
<rect>
<x>0</x>
<y>0</y>
<width>636</width>
<height>52</height>
<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="3">
<widget class="QProgressBar" name="progressBar">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>350</width>
<height>0</height>
</size>
</property>
<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>500</width>
<height>10</height>
</size>
</property>
<property name="value">
<number>24</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QPushButton" name="pushButton">
<property name="minimumSize">
<size>
<width>80</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>80</width>
<width>48</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>安装</string>
<string>icon</string>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<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>
<widget class="QLabel" name="label">
<property name="minimumSize">
<size>
<width>150</width>
<width>80</width>
<height>0</height>
</size>
</property>
@@ -88,8 +107,97 @@
</property>
</widget>
</item>
<item row="0" column="4">
<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>280</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>16777215</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>2</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>300</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>500</width>
<height>10</height>
</size>
</property>
<property name="value">
<number>24</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="text">
<string>等待开始下载</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -104,28 +212,83 @@
</property>
</spacer>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</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="0">
<widget class="QLabel" name="label_filename">
<item>
<widget class="QPushButton" name="pushButton_install">
<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>TextLabel</string>
<string>安装</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_2">
<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>
<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
View 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
View 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

View File

@@ -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("deepin-community-store");
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();
}

View File

@@ -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,700);
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);
}

View File

@@ -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;
};

View File

@@ -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
View File

@@ -0,0 +1,2 @@
#!/bin/sh
dpkg -i $1 || apt install -yf || dpkg -P $1

View File

@@ -15,185 +15,380 @@
#include <QPixmap>
#include <QtConcurrent> //并发
#include <QSettings>
#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->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/";
}
ui->webView->setUrl(serverUrl+"store/");
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);});
configCanSeve=true;
qDebug()<<serverUrl;
menuUrl[0]=serverUrl + "store/frontpage/";
menuUrl[1]=serverUrl + "store/network/";
menuUrl[2]=serverUrl + "store/chat/";
menuUrl[3]=serverUrl + "store/music/";
menuUrl[4]=serverUrl + "store/video";
menuUrl[5]=serverUrl + "store/image_graphics/";
menuUrl[6]=serverUrl + "store/games/";
menuUrl[7]=serverUrl + "store/office/";
menuUrl[8]=serverUrl + "store/reading/";
menuUrl[9]=serverUrl + "store/development/";
menuUrl[10]=serverUrl + "store/tools/";
menuUrl[11]=serverUrl + "store/others/";
menuUrl[12]=serverUrl + "store/themes/";
//计算显示下载速度
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()
{
//判断,如果末尾是/就直接访问如果是app.json就打开详情页
if(arg1.path().right(1)=="/"){
ui->webView->setUrl(arg1);
}else if(arg1.path().right(8)=="app.json"){
//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()
{
m_loadweb->setValue(0);
m_loadweb->show();
m_loaderror->hide();
ui->label_show->hide();
//分析出服务器中的分类名称
QUrl arg1=ui->webView->page()->mainFrame()->requestedUrl().toString();
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_download->setEnabled(false);
ui->stackedWidget->setCurrentIndex(2);
load.cancel();//打开并发加载线程前关闭正在执行的线程
load = QtConcurrent::run([=](){
loadappinfo(arg1);
});
}
}
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["Version"].toString()+"\n";
info+="作者:"+json["Author"].toString()+"\n";
info+="官网:"+json["Website"].toString()+"\n";
info+="投稿者:"+json["Contributor"].toString()+"\n";
info+="更新时间:"+json["Update"].toString()+"\n";
info+="大小:"+json["Size"].toString()+"\n";
info="包名: "+json["Pkgname"].toString()+"\n";
info+="版本号: "+json["Version"].toString()+"\n";
if(json["Author"].toString()!="" && json["Author"].toString()!=" "){
info+="者: "+json["Author"].toString()+"\n";
}
if(json["Website"].toString()!="" && json["Website"].toString()!=" "){
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";
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_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();
@@ -202,53 +397,46 @@ void Widget::loadappinfo(QUrl arg1)
}
void Widget::chooseLeftMenu(int index)
{
for (int i=0;i<15;i++) {
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);
download_list[allDownload-1].setFileName(fileName);
QPixmap icon;
icon.load("icon.png");
system("cp icon.png icon_"+QString::number(allDownload-1).toUtf8()+".png");
download_list[allDownload-1].seticon(icon);
if(!isBusy){
file = new QFile(fileName);
if(!file->open(QIODevice::WriteOnly)){
delete file;
file = 0;
file = nullptr;
return ;
}
nowDownload+=1;
startRequest(urList.at(nowDownload-1)); //进行链接请求
}
if(ui->pushButton_download->text()=="重新安装"){
download_list[allDownload-1].reinstall=true;
}
}
void Widget::startRequest(QUrl url)
@@ -257,6 +445,7 @@ void Widget::startRequest(QUrl url)
ui->label->hide();
isBusy=true;
isdownload=true;
download_list[allDownload-1].free=false;
reply = manager->get(QNetworkRequest(url));
connect(reply,SIGNAL(finished()),this,SLOT(httpFinished()));
connect(reply,SIGNAL(readyRead()),this,SLOT(httpReadyRead()));
@@ -264,8 +453,16 @@ void Widget::startRequest(QUrl url)
}
void Widget::closeList(int)
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);
}
}
@@ -279,134 +476,244 @@ void Widget::httpReadyRead()
}
void Widget::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
{
download_list[nowDownload-1].setMax(1000); //最大值
download_list[nowDownload-1].setValue((bytesRead*1000)/totalBytes); //当前值
// download_list[nowDownload-1].setMax(bytesRead/10);
// download_list[nowDownload-1].setValue(totalBytes/10);
download_list[nowDownload-1].setMax(10000); //最大值
download_list[nowDownload-1].setValue((bytesRead*10000)/totalBytes); //当前值
download_size=bytesRead;
if(download_list[nowDownload-1].close){ //随时检测下载是否被取消
download_list[nowDownload-1].closeDownload();
httpFinished();
}
}
void Widget::httpFinished() //完成下载
{
file->flush();
file->close();
reply->deleteLater();
reply = 0;
delete file;
file = 0;
isdownload=false;
isBusy=false;
download_list[nowDownload-1].readyInstall();
if(nowDownload<allDownload){
QString fileName=download_list[nowDownload].getName();
file = new QFile(fileName);
if(!file->open(QIODevice::WriteOnly))
{
qDebug()<<"file open error";
delete file;
file = 0;
return ;
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));
}
nowDownload+=1;
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_loadStarted()
{
ui->label_show->setText("正在加载,请稍候");
ui->label_show->show();
}
void Widget::on_webView_loadFinished(bool arg1)
{
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
View File

@@ -11,80 +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 closeList(int);
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(bool arg1);
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;
@@ -93,10 +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;
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;
};

1208
widget.ui

File diff suppressed because it is too large Load Diff