mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-07-10 23:55:58 +08:00
跟随
This commit is contained in:
parent
b1c2b1bbc6
commit
82f49c4aa9
@ -5,6 +5,7 @@
|
||||
#include <QPixmap>
|
||||
#include <QtConcurrent>
|
||||
#include <QProcess>
|
||||
#include <QTextBrowser>
|
||||
bool downloadlist::isInstall=false;
|
||||
|
||||
downloadlist::downloadlist(QWidget *parent) :
|
||||
@ -17,6 +18,8 @@ downloadlist::downloadlist(QWidget *parent) :
|
||||
ui->label_filename->hide();
|
||||
ui->pushButton->hide();
|
||||
ui->pushButton_3->hide();
|
||||
ui->widget_spinner->start();
|
||||
ui->widget_spinner->hide();
|
||||
}
|
||||
|
||||
downloadlist::~downloadlist()
|
||||
@ -26,8 +29,8 @@ downloadlist::~downloadlist()
|
||||
|
||||
void downloadlist::setValue(long long value)
|
||||
{
|
||||
ui->progressBar->setValue(value);
|
||||
ui->label_2->setText(QString::number((double)value/100)+"% ("+speed+")");
|
||||
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("已完成,等待安装");
|
||||
}
|
||||
@ -35,7 +38,7 @@ void downloadlist::setValue(long long value)
|
||||
|
||||
void downloadlist::setMax(long long max)
|
||||
{
|
||||
ui->progressBar->setMaximum(max);
|
||||
ui->progressBar->setMaximum(int(max));
|
||||
}
|
||||
|
||||
void downloadlist::setName(QString name)
|
||||
@ -83,29 +86,29 @@ void downloadlist::on_pushButton_clicked()
|
||||
{
|
||||
if(!isInstall){
|
||||
isInstall=true;
|
||||
ui->pushButton->setEnabled(false);
|
||||
ui->pushButton->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 ssinstall /tmp/spark-store/"+ui->label_filename->text().toUtf8());
|
||||
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.start("pkexec gdebi -n /tmp/spark-store/"+ui->label_filename->text().toUtf8());
|
||||
}
|
||||
|
||||
installer.waitForFinished();
|
||||
error=installer.readAllStandardError();
|
||||
out=installer.readAllStandardOutput();
|
||||
QStringList everyError=error.split("\n");
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -119,17 +122,18 @@ void downloadlist::on_pushButton_clicked()
|
||||
ui->pushButton_3->show();
|
||||
}else {
|
||||
ui->pushButton->show();
|
||||
ui->pushButton->setEnabled(true);
|
||||
ui->pushButton->show();
|
||||
ui->pushButton->setText("重装");
|
||||
ui->label_2->setText("安装出现错误,可重新安装");
|
||||
ui->pushButton_3->show();
|
||||
}
|
||||
if(notRoot){
|
||||
ui->label_2->setText("安装被终止,可重新安装");
|
||||
ui->pushButton->setEnabled(true);
|
||||
ui->pushButton->show();
|
||||
ui->pushButton->show();
|
||||
ui->pushButton_3->hide();
|
||||
}
|
||||
ui->widget_spinner->hide();
|
||||
downloadlist::isInstall=false;
|
||||
|
||||
});
|
||||
@ -149,6 +153,14 @@ void downloadlist::on_pushButton_2_clicked()
|
||||
|
||||
void downloadlist::on_pushButton_3_clicked()
|
||||
{
|
||||
output_w.setoutput(out+"\nERROR:\n"+error);
|
||||
|
||||
|
||||
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,7 +2,9 @@
|
||||
#define DOWNLOADLIST_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <outputwindow.h>
|
||||
#include <DDialog>
|
||||
#include <QTextBrowser>
|
||||
DWIDGET_USE_NAMESPACE
|
||||
namespace Ui {
|
||||
class downloadlist;
|
||||
}
|
||||
@ -27,9 +29,9 @@ public:
|
||||
int num;
|
||||
bool close=false;
|
||||
QString out;
|
||||
outputwindow output_w;
|
||||
DDialog output_w;
|
||||
QTextBrowser *textbrowser=new QTextBrowser;
|
||||
bool reinstall=false;
|
||||
QString error;
|
||||
QString pkgName;
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
@ -181,6 +181,16 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="DSpinner" name="widget_spinner" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>60</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="minimumSize">
|
||||
@ -240,6 +250,14 @@
|
||||
</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>
|
||||
|
48
image_show.cpp
Normal file
48
image_show.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
#include "image_show.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <QPainter>
|
||||
#include <DDialog>
|
||||
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);
|
||||
//防止图片尺寸过大导致窗口覆盖整个屏幕
|
||||
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 *)
|
||||
{
|
||||
image.setPixmap(m_image);
|
||||
m_dialog->setTitle("截图预览");
|
||||
image.setAlignment(Qt::AlignCenter);
|
||||
m_dialog->layout()->addWidget(&image);
|
||||
m_dialog->layout()->setMargin(10);
|
||||
image.setMaximumSize(1024,768);
|
||||
m_dialog->setWindowFlags(m_dialog->windowFlags() | Qt::WindowStaysOnTopHint);//设置图片对话框总在最前
|
||||
image.show();
|
||||
m_dialog->hide();
|
||||
m_dialog->exec();
|
||||
}
|
29
image_show.h
Normal file
29
image_show.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef IMAGE_SHOW_H
|
||||
#define IMAGE_SHOW_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMouseEvent>
|
||||
#include <QLabel>
|
||||
#include <QPixmap>
|
||||
#include <DDialog>
|
||||
|
||||
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;
|
||||
DDialog *m_dialog=new DDialog;
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
};
|
||||
|
||||
#endif // IMAGE_SHOW_H
|
12
main.cpp
12
main.cpp
@ -9,13 +9,14 @@ int main(int argc, char *argv[])
|
||||
DApplication a(argc, argv);
|
||||
a.setAttribute(Qt::AA_UseHighDpiPixmaps);
|
||||
a.loadTranslator();
|
||||
a.setOrganizationName("community");
|
||||
a.setApplicationVersion(DApplication::buildVersion("1.0-beta5.1"));
|
||||
a.setApplicationAcknowledgementPage("https://gitee.com/deepin-community-store/deepin-community-store");
|
||||
a.setOrganizationName("spark-union");
|
||||
a.setApplicationVersion(DApplication::buildVersion("1.0-beta5.4"));
|
||||
a.setApplicationAcknowledgementPage("https://gitee.com/deepin-community-store/spark-store");
|
||||
a.setProductIcon(QIcon::fromTheme("spark-store")); //设置Logo
|
||||
a.setProductName("Spark应用商店");
|
||||
a.setApplicationName("Spark应用商店"); //只有在这儿修改窗口标题才有效
|
||||
|
||||
a.setProductName("Spark应用商店");
|
||||
a.setApplicationDescription("深度社区驱动的一款为deepin打造的第三方商店");
|
||||
a.setApplicationName("Spark应用商店"); //只有在这儿修改窗口标题才有效
|
||||
MainWindow w;
|
||||
QDesktopWidget *s=DApplication::desktop();
|
||||
int d_w=s->width();
|
||||
@ -46,6 +47,5 @@ int main(int argc, char *argv[])
|
||||
//让打开时界面显示在正中
|
||||
Dtk::Widget::moveToCenter(&w);
|
||||
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
@ -2,6 +2,11 @@
|
||||
|
||||
#include <DMainWindow>
|
||||
#include <QDesktopWidget>
|
||||
#include <DTitlebar>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include <DFileServices>
|
||||
#include <DApplicationHelper>
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent)
|
||||
@ -10,12 +15,47 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
w = new Widget;
|
||||
|
||||
resize(w->size()); //设置窗口大小
|
||||
|
||||
// setMinimumSize(950,700);
|
||||
setCentralWidget(w);
|
||||
// searchEdit->setParent(this);
|
||||
// searchEdit->move(1,1);
|
||||
// searchEdit->show();
|
||||
|
||||
//添加搜索框
|
||||
DMainWindow::titlebar()->addWidget(searchEdit);
|
||||
DMainWindow::titlebar()->setIcon(QIcon::fromTheme("spark-store"));
|
||||
DMainWindow::titlebar()->setTitle("星火应用商店");
|
||||
searchEdit->setMaximumWidth(300);
|
||||
|
||||
//添加菜单项
|
||||
QAction *setting=new QAction("设置");
|
||||
QMenu *menu=new QMenu;
|
||||
menu->addAction(setting);
|
||||
DMainWindow::titlebar()->setMenu(menu);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//链接信号和槽
|
||||
connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::themeTypeChanged, this, [ = ](DGuiApplicationHelper::ColorType themeType) {
|
||||
if(themeType==DGuiApplicationHelper::DarkType){
|
||||
qDebug()<<"Dark";
|
||||
}else {
|
||||
qDebug()<<"White";
|
||||
}
|
||||
});
|
||||
// if(DGuiApplicationHelper::instance()-==DGuiApplicationHelper::ColorType::LightType){
|
||||
|
||||
// }
|
||||
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()
|
||||
|
@ -5,6 +5,8 @@
|
||||
#include "widget.h"
|
||||
#include <QThread>
|
||||
#include <DSearchEdit>
|
||||
#include <DBlurEffectWidget>
|
||||
#include <DTitlebar>
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
class MainWindow : public DMainWindow
|
||||
@ -15,7 +17,8 @@ class MainWindow : public DMainWindow
|
||||
public:
|
||||
MainWindow(QWidget *parent = nullptr);
|
||||
~MainWindow();
|
||||
// DSearchEdit *searchEdit=new DSearchEdit;
|
||||
DSearchEdit *searchEdit=new DSearchEdit;
|
||||
DTitlebar *titlebar=new DTitlebar;
|
||||
private:
|
||||
|
||||
Widget *w;
|
||||
|
@ -1,24 +0,0 @@
|
||||
#include "outputwindow.h"
|
||||
#include "ui_outputwindow.h"
|
||||
#include <QDebug>
|
||||
#include <QDesktopWidget>
|
||||
outputwindow::outputwindow(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::outputwindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowTitle("安装详情");
|
||||
QDesktopWidget *desktop = QApplication::desktop();
|
||||
move((desktop->width() - width())/ 2, (desktop->height() - height()) /2);
|
||||
}
|
||||
|
||||
outputwindow::~outputwindow()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void outputwindow::setoutput(QString output)
|
||||
{
|
||||
qDebug()<<output;
|
||||
ui->textBrowser->setText(output);
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
#ifndef OUTPUTWINDOW_H
|
||||
#define OUTPUTWINDOW_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
class outputwindow;
|
||||
}
|
||||
|
||||
class outputwindow : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit outputwindow(QWidget *parent = nullptr);
|
||||
~outputwindow();
|
||||
void setoutput(QString);
|
||||
private:
|
||||
Ui::outputwindow *ui;
|
||||
};
|
||||
|
||||
#endif // OUTPUTWINDOW_H
|
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>outputwindow</class>
|
||||
<widget class="QWidget" name="outputwindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>391</width>
|
||||
<height>372</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QTextBrowser" name="textBrowser"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -27,12 +27,12 @@ SOURCES += main.cpp\
|
||||
mainwindow.cpp \
|
||||
widget.cpp \
|
||||
downloadlist.cpp \
|
||||
outputwindow.cpp
|
||||
image_show.cpp
|
||||
|
||||
HEADERS += mainwindow.h \
|
||||
widget.h \
|
||||
downloadlist.h \
|
||||
outputwindow.h
|
||||
image_show.h
|
||||
|
||||
CONFIG += link_pkgconfig
|
||||
PKGCONFIG += dtkwidget
|
||||
@ -41,5 +41,4 @@ CONFIG += c++11
|
||||
|
||||
FORMS += \
|
||||
widget.ui \
|
||||
downloadlist.ui \
|
||||
outputwindow.ui
|
||||
downloadlist.ui
|
||||
|
461
widget.cpp
461
widget.cpp
@ -18,86 +18,25 @@
|
||||
#include <QIcon>
|
||||
#include <QWebFrame>
|
||||
#include <QGraphicsOpacityEffect>
|
||||
#include <QDesktopServices>
|
||||
#include <DSettings>
|
||||
#include <DSettingsOption>
|
||||
#include <DSettingsDialog>
|
||||
#include "image_show.h"
|
||||
#include <DBlurEffectWidget>
|
||||
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();
|
||||
ui->pushButton_5->hide();
|
||||
ui->line1_widget->setStyleSheet("background-color:#808080");
|
||||
ui->line2_widget->setStyleSheet("background-color:#808080");
|
||||
manager = new QNetworkAccessManager(this);
|
||||
//初始化菜单数组
|
||||
left_list[0]=ui->menu_btn_main;left_menu_bg[0]=ui->menu_bg_main;
|
||||
left_list[1]=ui->menu_btn_network;left_menu_bg[1]=ui->menu_bg_network;
|
||||
left_list[2]=ui->menu_btn_chat;left_menu_bg[2]=ui->menu_bg_chat;
|
||||
left_list[3]=ui->menu_btn_music;left_menu_bg[3]=ui->menu_bg_music;
|
||||
left_list[4]=ui->menu_btn_video;left_menu_bg[4]=ui->menu_bg_video;
|
||||
left_list[5]=ui->menu_btn_photo;left_menu_bg[5]=ui->menu_bg_photo;
|
||||
left_list[6]=ui->menu_btn_game;left_menu_bg[6]=ui->menu_bg_game;
|
||||
left_list[7]=ui->menu_btn_office;left_menu_bg[7]=ui->menu_bg_office;
|
||||
left_list[8]=ui->menu_btn_read;left_menu_bg[8]=ui->menu_bg_read;
|
||||
left_list[9]=ui->menu_btn_dev;left_menu_bg[9]=ui->menu_bg_dev;
|
||||
left_list[10]=ui->menu_btn_system;left_menu_bg[10]=ui->menu_bg_system;
|
||||
left_list[11]=ui->menu_btn_other;left_menu_bg[11]=ui->menu_bg_other;
|
||||
left_list[12]=ui->menu_btn_theme;left_menu_bg[12]=ui->menu_bg_theme;
|
||||
left_list[13]=ui->menu_btn_download;left_menu_bg[13]=ui->menu_bg_download;
|
||||
left_list[14]=ui->menu_btn_settings;left_menu_bg[14]=ui->menu_bg_settings;
|
||||
|
||||
server.open(QDir::homePath().toUtf8()+"/.config/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/");
|
||||
}
|
||||
|
||||
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/";
|
||||
}
|
||||
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";
|
||||
configCanSeve=true;
|
||||
qDebug()<<serverUrl;
|
||||
|
||||
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;
|
||||
opacityEffect_1->setOpacity(0.2);
|
||||
opacityEffect_2->setOpacity(0.2);
|
||||
ui->line1_widget->setGraphicsEffect(opacityEffect_1);
|
||||
ui->line2_widget->setGraphicsEffect(opacityEffect_2);
|
||||
initUI();
|
||||
initConfig();
|
||||
manager = new QNetworkAccessManager(this);//下载管理
|
||||
//计算显示下载速度
|
||||
download_speed.setInterval(1000);
|
||||
download_speed.start();
|
||||
//计算显示网速
|
||||
connect(&download_speed,&QTimer::timeout,[=](){
|
||||
if(isdownload){
|
||||
size1=download_size;
|
||||
@ -117,7 +56,122 @@ Widget::Widget(QWidget *parent) :
|
||||
size2=download_size;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Widget::~Widget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
void Widget::initUI()
|
||||
{
|
||||
//ui初始化
|
||||
|
||||
ui->stackedWidget->setCurrentIndex(0);
|
||||
ui->listWidget->hide();
|
||||
ui->label_setting1->hide();
|
||||
ui->pushButton_uninstall->hide();
|
||||
ui->line1_widget->setStyleSheet("background-color:#808080");
|
||||
ui->line2_widget->setStyleSheet("background-color:#808080");
|
||||
|
||||
|
||||
//初始化分界线
|
||||
QGraphicsOpacityEffect *opacityEffect_1=new QGraphicsOpacityEffect;
|
||||
QGraphicsOpacityEffect *opacityEffect_2=new QGraphicsOpacityEffect;
|
||||
opacityEffect_1->setOpacity(0.2);
|
||||
opacityEffect_2->setOpacity(0.2);
|
||||
ui->line1_widget->setGraphicsEffect(opacityEffect_1);
|
||||
ui->line2_widget->setGraphicsEffect(opacityEffect_2);
|
||||
|
||||
|
||||
|
||||
|
||||
//初始化菜单数组
|
||||
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;
|
||||
|
||||
// DBlurEffectWidget *bwidget=new DBlurEffectWidget;
|
||||
// bwidget->show();
|
||||
|
||||
//初始化web加载动画
|
||||
QHBoxLayout *m_weblayout=new QHBoxLayout;
|
||||
m_weblayout->addWidget(m_loadweb);
|
||||
m_loadweb->hide();
|
||||
m_loadweb->start();
|
||||
m_loadweb->setMaximumSize(60,60);
|
||||
ui->webView->setLayout(m_weblayout);
|
||||
}
|
||||
|
||||
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并初始化菜单项的链接
|
||||
QString serverUrl;
|
||||
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/#/others/";
|
||||
menuUrl[12]=serverUrl + "store/#/themes";
|
||||
|
||||
|
||||
//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()){
|
||||
@ -126,38 +180,33 @@ Widget::Widget(QWidget *parent) :
|
||||
ui->label_aptserver->setText("不存在");
|
||||
}
|
||||
aptserver.close();
|
||||
|
||||
}
|
||||
|
||||
Widget::~Widget()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
void Widget::on_webView_loadStarted()
|
||||
{
|
||||
|
||||
|
||||
m_loadweb->show();
|
||||
QUrl arg1=ui->webView->page()->mainFrame()->requestedUrl().toString();
|
||||
//判断,如果末尾是/就直接访问,如果是app.json就打开详情页
|
||||
if(arg1.path().right(8)=="app.json"){
|
||||
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
||||
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([=](){
|
||||
@ -167,11 +216,12 @@ void Widget::on_webView_loadStarted()
|
||||
}
|
||||
void Widget::loadappinfo(QUrl arg1)
|
||||
{
|
||||
ui->pushButton_5->hide();
|
||||
|
||||
|
||||
//置UI状态
|
||||
ui->pushButton_uninstall->hide();
|
||||
ui->label_show->setText("正在加载,请稍候");
|
||||
ui->label_show->show();
|
||||
ui->pushButton_website->hide();
|
||||
|
||||
QProcess get_json;
|
||||
QDir dir("/tmp");
|
||||
dir.mkdir("spark-store");
|
||||
@ -206,6 +256,8 @@ void Widget::loadappinfo(QUrl arg1)
|
||||
|
||||
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";
|
||||
@ -218,11 +270,11 @@ void Widget::loadappinfo(QUrl arg1)
|
||||
isInstall.waitForFinished();
|
||||
int error=QString::fromStdString(isInstall.readAllStandardError().toStdString()).length();
|
||||
if(error==0){
|
||||
ui->pushButton->setText("重新安装");
|
||||
ui->pushButton_5->show();
|
||||
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");
|
||||
@ -230,53 +282,37 @@ void Widget::loadappinfo(QUrl arg1)
|
||||
QPixmap appicon;
|
||||
qDebug()<<appicon.load("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);
|
||||
ui->screen_2->hide();
|
||||
ui->screen_3->hide();
|
||||
ui->screen_4->hide();
|
||||
ui->screen_5->hide();
|
||||
|
||||
}
|
||||
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);
|
||||
ui->screen_3->hide();
|
||||
ui->screen_4->hide();
|
||||
ui->screen_5->hide();
|
||||
}
|
||||
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);
|
||||
ui->screen_4->hide();
|
||||
ui->screen_5->hide();
|
||||
}
|
||||
get_json.start("wget "+urladdress+"screen_4.png");
|
||||
get_json.waitForFinished();
|
||||
if(screen[3].load("screen_4.png")){
|
||||
ui->screen_4->show();
|
||||
ui->screen_4->setPixmap(screen[3]);
|
||||
ui->screen_4->setScaledContents(true);
|
||||
ui->screen_5->hide();
|
||||
}
|
||||
get_json.start("wget "+urladdress+"screen_5.png");
|
||||
get_json.waitForFinished();
|
||||
if(screen[4].load("screen_5.png")){
|
||||
ui->screen_5->show();
|
||||
ui->screen_5->setPixmap(screen[4]);
|
||||
ui->screen_5->setScaledContents(true);
|
||||
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("wget "+urladdress+"screen_"+QString::number(i)+".png");
|
||||
get_json.waitForFinished();
|
||||
if(screen[i].load("screen_"+QString::number(i)+".png")){
|
||||
qDebug()<<"加载第"+QString::number(i)+"张图片";
|
||||
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();
|
||||
@ -285,31 +321,10 @@ void Widget::loadappinfo(QUrl arg1)
|
||||
|
||||
}
|
||||
|
||||
void Widget::chooseLeftMenu(int index)
|
||||
{
|
||||
|
||||
nowMenu=index;
|
||||
for (int i=0;i<15;i++) {
|
||||
left_list[i]->setStyleSheet("");
|
||||
left_list[i]->setFont(QFont("",11));
|
||||
left_menu_bg[i]->setStyleSheet("");
|
||||
}
|
||||
left_list[index]->setStyleSheet("color:#FFFFFF");
|
||||
left_menu_bg[index]->setStyleSheet("background-color:#0081FF;border-radius:8");
|
||||
if(index<=12){
|
||||
ui->webView->setUrl(menuUrl[index]);
|
||||
qDebug()<<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();
|
||||
allDownload+=1;
|
||||
@ -344,7 +359,7 @@ void Widget::on_pushButton_clicked()
|
||||
nowDownload+=1;
|
||||
startRequest(urList.at(nowDownload-1)); //进行链接请求
|
||||
}
|
||||
if(ui->pushButton->text()=="重新安装"){
|
||||
if(ui->pushButton_download->text()=="重新安装"){
|
||||
download_list[allDownload-1].reinstall=true;
|
||||
}
|
||||
}
|
||||
@ -363,6 +378,11 @@ void Widget::startRequest(QUrl url)
|
||||
|
||||
}
|
||||
|
||||
void Widget::searchApp(QString text)
|
||||
{
|
||||
ui->webView->setUrl(QUrl("http://www.baidu.com/s?wd="+text));
|
||||
}
|
||||
|
||||
|
||||
void Widget::httpReadyRead()
|
||||
{
|
||||
@ -376,10 +396,9 @@ void Widget::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
|
||||
download_list[nowDownload-1].setMax(10000); //最大值
|
||||
download_list[nowDownload-1].setValue((bytesRead*10000)/totalBytes); //当前值
|
||||
download_size=bytesRead;
|
||||
if(download_list[nowDownload-1].close){
|
||||
if(download_list[nowDownload-1].close){ //随时检测下载是否被取消
|
||||
download_list[nowDownload-1].closeDownload();
|
||||
httpFinished();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -396,7 +415,7 @@ void Widget::httpFinished() //完成下载
|
||||
isBusy=false;
|
||||
download_list[nowDownload-1].readyInstall();
|
||||
download_list[nowDownload-1].free=true;
|
||||
if(nowDownload<allDownload){
|
||||
if(nowDownload<allDownload){ //如果有排队则下载下一个
|
||||
nowDownload+=1;
|
||||
while (download_list[nowDownload-1].close) {
|
||||
nowDownload+=1;
|
||||
@ -414,6 +433,27 @@ void Widget::httpFinished() //完成下载
|
||||
}
|
||||
|
||||
//菜单切换逻辑
|
||||
|
||||
void Widget::chooseLeftMenu(int index)
|
||||
{
|
||||
|
||||
nowMenu=index;
|
||||
for (int i=0;i<14;i++) {
|
||||
left_list[i]->setStyleSheet("");
|
||||
left_list[i]->setFont(QFont("",11));
|
||||
left_menu_bg[i]->setStyleSheet("");
|
||||
}
|
||||
left_list[index]->setStyleSheet("color:#FFFFFF");
|
||||
left_menu_bg[index]->setStyleSheet("background-color:#0081FF;border-radius:8");
|
||||
if(index<=12){
|
||||
ui->webView->setUrl(menuUrl[index]);
|
||||
qDebug()<<menuUrl[index];
|
||||
ui->stackedWidget->setCurrentIndex(0);
|
||||
}else if (index==13) {
|
||||
ui->stackedWidget->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
}
|
||||
void Widget::on_menu_btn_main_clicked() //主页
|
||||
{
|
||||
chooseLeftMenu(0);
|
||||
@ -470,23 +510,7 @@ void Widget::on_menu_btn_download_clicked()
|
||||
{
|
||||
chooseLeftMenu(13);
|
||||
}
|
||||
void Widget::on_menu_btn_settings_clicked()
|
||||
{
|
||||
chooseLeftMenu(14);
|
||||
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);
|
||||
}
|
||||
void Widget::on_pushButton_2_clicked()
|
||||
void Widget::on_pushButton_return_clicked()
|
||||
{
|
||||
ui->webView->setUrl(menuUrl[nowMenu]);
|
||||
ui->stackedWidget->setCurrentIndex(0);
|
||||
@ -503,17 +527,17 @@ void Widget::on_webView_loadFinished()
|
||||
}
|
||||
void Widget::on_comboBox_server_currentIndexChanged(const QString &arg1)
|
||||
{
|
||||
if(configCanSeve){
|
||||
if(configCanSave){
|
||||
ui->label_setting1->show();
|
||||
QSettings *setConfig=new QSettings(QDir::homePath()+"/.config/spark-store/config.ini",QSettings::IniFormat);
|
||||
qDebug()<<arg1;
|
||||
setConfig->setValue("server/choose",arg1);
|
||||
}
|
||||
}
|
||||
void Widget::on_pushButton_3_clicked()
|
||||
void Widget::on_pushButton_updateServer_clicked()
|
||||
{
|
||||
QtConcurrent::run([=](){
|
||||
ui->pushButton_3->setEnabled(false);
|
||||
ui->pushButton_updateServer->setEnabled(false);
|
||||
ui->comboBox_server->clear();
|
||||
QFile::remove(QDir::homePath().toUtf8()+"/.config/spark-store/server.list");
|
||||
system("wget -P "+QDir::homePath().toUtf8()+"/.config/spark-store http://dcstore.shenmo.tech/store/server.list");
|
||||
@ -527,15 +551,15 @@ void Widget::on_pushButton_3_clicked()
|
||||
}else {
|
||||
ui->comboBox_server->addItem("http://store.jerrywang.top/");
|
||||
}
|
||||
ui->pushButton_3->setEnabled(true);
|
||||
ui->pushButton_updateServer->setEnabled(true);
|
||||
ui->comboBox_server->setCurrentIndex(0);
|
||||
});
|
||||
}
|
||||
|
||||
void Widget::on_pushButton_4_clicked()
|
||||
void Widget::on_pushButton_updateApt_clicked()
|
||||
{
|
||||
QtConcurrent::run([=](){
|
||||
ui->pushButton_4->setEnabled(false);
|
||||
ui->pushButton_updateApt->setEnabled(false);
|
||||
ui->label_aptserver->setText("请稍等,正在更新");
|
||||
std::fstream sourcesList;
|
||||
QDir tmpdir("/tmp");
|
||||
@ -573,31 +597,31 @@ void Widget::on_pushButton_4_clicked()
|
||||
qDebug()<<"更新源失败";
|
||||
}
|
||||
|
||||
ui->pushButton_4->setEnabled(true);
|
||||
ui->pushButton_updateApt->setEnabled(true);
|
||||
});
|
||||
}
|
||||
|
||||
void Widget::on_pushButton_5_clicked()
|
||||
void Widget::on_pushButton_uninstall_clicked()
|
||||
{
|
||||
QtConcurrent::run([=](){
|
||||
ui->pushButton->setEnabled(false);
|
||||
ui->pushButton_5->setEnabled(false);
|
||||
ui->pushButton_download->setEnabled(false);
|
||||
ui->pushButton_uninstall->setEnabled(false);
|
||||
QProcess uninstall;
|
||||
uninstall.start("pkexec apt purge -y "+pkgName);
|
||||
uninstall.waitForFinished();
|
||||
ui->pushButton->setEnabled(true);
|
||||
ui->pushButton->setText("安装");
|
||||
ui->pushButton_5->hide();
|
||||
ui->pushButton_5->setEnabled(true);
|
||||
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_6_clicked()//清空临时缓存目录
|
||||
void Widget::on_pushButton_clear_clicked()//清空临时缓存目录
|
||||
{
|
||||
QtConcurrent::run([=](){
|
||||
ui->pushButton_6->setEnabled(false);
|
||||
ui->pushButton_clear->setEnabled(false);
|
||||
QDir tmpdir("/tmp/spark-store");
|
||||
tmpdir.setFilter(QDir::Files);
|
||||
int quantity=int(tmpdir.count());
|
||||
@ -605,8 +629,8 @@ void Widget::on_pushButton_6_clicked()//清空临时缓存目录
|
||||
tmpdir.remove(tmpdir[i]);
|
||||
}
|
||||
system("notify-send 已清除所有临时缓存 --icon=spark-store");
|
||||
ui->pushButton_6->setEnabled(true);
|
||||
on_menu_btn_settings_clicked();
|
||||
ui->pushButton_clear->setEnabled(true);
|
||||
Widget::opensetting();
|
||||
});
|
||||
}
|
||||
|
||||
@ -618,7 +642,7 @@ quint64 Widget::dirFileSize(const QString &path)
|
||||
foreach(QFileInfo fileInfo, dir.entryInfoList(QDir::Files))
|
||||
{
|
||||
//计算文件大小
|
||||
size += fileInfo.size();
|
||||
size += quint64(fileInfo.size());
|
||||
}
|
||||
//dir.entryList(QDir::Dirs|QDir::NoDotAndDotDot)返回所有子目录,并进行过滤
|
||||
foreach(QString subDir, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))
|
||||
@ -628,3 +652,38 @@ quint64 Widget::dirFileSize(const QString &path)
|
||||
}
|
||||
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::on_pushButton_website_clicked()
|
||||
{
|
||||
QDesktopServices::openUrl(QUrl(appweb));
|
||||
}
|
||||
|
||||
|
||||
void Widget::on_webView_loadFinished(bool arg1)
|
||||
{
|
||||
m_loadweb->hide();
|
||||
}
|
||||
|
53
widget.h
53
widget.h
@ -12,10 +12,13 @@
|
||||
#include <QFuture>
|
||||
#include <QToolButton>
|
||||
#include <QTimer>
|
||||
|
||||
#include <DSettings>
|
||||
#include <DBlurEffectWidget>
|
||||
#include <DSpinner>
|
||||
#define LIST_MAX 99
|
||||
#define TMP_PATH "/tmp/spark-store"
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
namespace Ui {
|
||||
class Widget;
|
||||
}
|
||||
@ -30,6 +33,7 @@ public:
|
||||
explicit Widget(QWidget *parent = 0);
|
||||
~Widget();
|
||||
void startRequest(QUrl url);
|
||||
void searchApp(QString);
|
||||
int nowDownload=0;
|
||||
int allDownload=0;
|
||||
int isdownload=false;
|
||||
@ -39,6 +43,7 @@ public:
|
||||
QPixmap screen[5];
|
||||
QFuture<void> load;
|
||||
QTimer download_speed;
|
||||
void opensetting();
|
||||
|
||||
private slots:
|
||||
|
||||
@ -46,54 +51,35 @@ private slots:
|
||||
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_pushButton_clicked();
|
||||
|
||||
void on_pushButton_2_clicked();
|
||||
|
||||
void on_pushButton_download_clicked();
|
||||
void on_pushButton_return_clicked();
|
||||
void on_webView_loadStarted();
|
||||
|
||||
void on_webView_loadFinished();
|
||||
|
||||
void on_menu_btn_theme_clicked();
|
||||
|
||||
void on_menu_btn_settings_clicked();
|
||||
|
||||
void on_comboBox_server_currentIndexChanged(const QString &arg1);
|
||||
void on_pushButton_updateServer_clicked();
|
||||
void on_pushButton_updateApt_clicked();
|
||||
void on_pushButton_uninstall_clicked();
|
||||
void on_pushButton_clear_clicked();
|
||||
void on_pushButton_website_clicked();
|
||||
|
||||
void on_pushButton_3_clicked();
|
||||
|
||||
void on_pushButton_4_clicked();
|
||||
|
||||
void on_pushButton_5_clicked();
|
||||
|
||||
void on_pushButton_6_clicked();
|
||||
void on_webView_loadFinished(bool arg1);
|
||||
|
||||
public:
|
||||
void initUI();
|
||||
void initConfig();
|
||||
QUrl url;
|
||||
bool isBusy=false;
|
||||
downloadlist download_list[LIST_MAX];
|
||||
@ -105,15 +91,18 @@ public:
|
||||
QString appName;
|
||||
QString urladdress;
|
||||
QString pkgName;
|
||||
QString appweb;
|
||||
QToolButton * left_list[15];
|
||||
QWidget * left_menu_bg[15];
|
||||
QUrl menuUrl[13];
|
||||
bool configCanSeve=false;
|
||||
bool configCanSave=false;
|
||||
int nowMenu=0;
|
||||
long download_size=0;
|
||||
long size1=0;
|
||||
long size2=0;
|
||||
|
||||
Dtk::Core::DSettings *jsonConfig=new Dtk::Core::DSettings;
|
||||
private:
|
||||
DSpinner *m_loadweb=new DSpinner;
|
||||
|
||||
};
|
||||
|
||||
|
340
widget.ui
340
widget.ui
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>943</width>
|
||||
<height>640</height>
|
||||
<width>1018</width>
|
||||
<height>685</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -730,52 +730,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="menu_bg_settings" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_21">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QToolButton" name="menu_btn_settings">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>高级设置</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
@ -836,7 +790,7 @@
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
@ -934,8 +888,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>781</width>
|
||||
<height>815</height>
|
||||
<width>856</width>
|
||||
<height>864</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_17">
|
||||
@ -944,12 +898,12 @@
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>300</height>
|
||||
<height>350</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<widget class="QPushButton" name="pushButton_return">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
@ -961,7 +915,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<item row="2" column="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -977,7 +931,7 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="2" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
@ -993,14 +947,14 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<item row="4" column="1">
|
||||
<widget class="QPushButton" name="pushButton_download">
|
||||
<property name="text">
|
||||
<string>安装</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1" rowspan="2">
|
||||
<item row="6" column="1" rowspan="2">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -1013,7 +967,75 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<item row="3" column="1">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</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 row="5" column="1">
|
||||
<widget class="QPushButton" name="pushButton_uninstall">
|
||||
<property name="text">
|
||||
<string>卸载</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="7">
|
||||
<spacer name="horizontalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="6">
|
||||
<widget class="QPushButton" name="pushButton_website">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>70</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>官网</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="5">
|
||||
<spacer name="horizontalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="3" colspan="2">
|
||||
<widget class="QLabel" name="label_appname">
|
||||
<property name="font">
|
||||
<font>
|
||||
@ -1026,7 +1048,41 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="2" column="3" rowspan="5" colspan="5">
|
||||
<widget class="QLabel" name="label_info">
|
||||
<property name="font">
|
||||
<font>
|
||||
<kerning>true</kerning>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><br/></p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<spacer name="verticalSpacer_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</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 row="2" column="1">
|
||||
<widget class="QLabel" name="label_appicon">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
@ -1054,47 +1110,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3" rowspan="5">
|
||||
<widget class="QLabel" name="label_info">
|
||||
<property name="font">
|
||||
<font>
|
||||
<kerning>true</kerning>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><br/></p></body></html></string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</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 row="4" column="1">
|
||||
<widget class="QPushButton" name="pushButton_5">
|
||||
<property name="text">
|
||||
<string>卸载</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -1172,105 +1187,25 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>747</width>
|
||||
<width>822</width>
|
||||
<height>325</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="screen_1">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="image_show" name="screen_0" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="screen_2">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="image_show" name="screen_1" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="screen_3">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="image_show" name="screen_2" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="screen_4">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="image_show" name="screen_3" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="screen_5">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="image_show" name="screen_4" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@ -1300,8 +1235,23 @@
|
||||
</widget>
|
||||
<widget class="QWidget" name="page_4">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QScrollArea" name="scrollArea_2">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -1313,8 +1263,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>765</width>
|
||||
<height>846</height>
|
||||
<width>687</width>
|
||||
<height>830</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_23">
|
||||
@ -1366,7 +1316,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_3">
|
||||
<widget class="QPushButton" name="pushButton_updateServer">
|
||||
<property name="text">
|
||||
<string>刷新</string>
|
||||
</property>
|
||||
@ -1418,7 +1368,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pushButton_4">
|
||||
<widget class="QPushButton" name="pushButton_updateApt">
|
||||
<property name="text">
|
||||
<string>更新源</string>
|
||||
</property>
|
||||
@ -1489,7 +1439,7 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pushButton_6">
|
||||
<widget class="QPushButton" name="pushButton_clear">
|
||||
<property name="text">
|
||||
<string>清空</string>
|
||||
</property>
|
||||
@ -1595,6 +1545,12 @@
|
||||
<extends>QWidget</extends>
|
||||
<header>QtWebKitWidgets/QWebView</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>image_show</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">image_show.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user