diff --git a/progress_load.cpp b/progress_load.cpp new file mode 100644 index 0000000..f1cc48a --- /dev/null +++ b/progress_load.cpp @@ -0,0 +1,6 @@ +#include "progress_load.h" + +progress_load::progress_load() +{ + +} diff --git a/progress_load.h b/progress_load.h new file mode 100644 index 0000000..e40c0b8 --- /dev/null +++ b/progress_load.h @@ -0,0 +1,12 @@ +#ifndef PROGRESS_LOAD_H +#define PROGRESS_LOAD_H + +#include + +class progress_load +{ +public: + progress_load(); +}; + +#endif // PROGRESS_LOAD_H diff --git a/progressload.cpp b/progressload.cpp new file mode 100644 index 0000000..c0b6231 --- /dev/null +++ b/progressload.cpp @@ -0,0 +1,21 @@ +#include "progressload.h" + +ProgressLoad::ProgressLoad(QWidget *parent) : QWidget(parent) +{ + m_progess=new QWidget; + m_progess->setStyleSheet("background-color:#999999"); + m_progess->move(0,0); + timer=new QTimer; + value=0; + timer->setInterval(100); + timer->start(); + connect(timer,&QTimer::timeout,[=](){ + m_progess->setFixedWidth(width()/100*value); + }); +} + +void ProgressLoad::setValue(int v) +{ + value=v; + m_progess->setFixedWidth(width()/100*value); +} diff --git a/progressload.h b/progressload.h new file mode 100644 index 0000000..2b1626c --- /dev/null +++ b/progressload.h @@ -0,0 +1,21 @@ +#ifndef PROGRESSLOAD_H +#define PROGRESSLOAD_H + +#include +#include +class ProgressLoad : public QWidget +{ + Q_OBJECT +public: + explicit ProgressLoad(QWidget *parent = nullptr); + void setValue(int v); +signals: + +public slots: +private: + QWidget *m_progess; + int value; + QTimer *timer; +}; + +#endif // PROGRESSLOAD_H diff --git a/spark-store.pro b/spark-store.pro index dd043a8..58044a5 100644 --- a/spark-store.pro +++ b/spark-store.pro @@ -4,10 +4,13 @@ # #------------------------------------------------- -QT += core gui webkitwidgets network concurrent +QT += core gui webkitwidgets network concurrent webenginewidgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets +CONFIG += link_pkgconfig +PKGCONFIG += dtkwidget + TARGET = spark-store TEMPLATE = app @@ -27,16 +30,17 @@ SOURCES += main.cpp\ widget.cpp \ downloadlist.cpp \ image_show.cpp \ - big_image.cpp + big_image.cpp \ + progressload.cpp HEADERS += \ widget.h \ downloadlist.h \ image_show.h \ - big_image.h + big_image.h \ + progressload.h + -CONFIG += link_pkgconfig -PKGCONFIG += dtkwidget CONFIG += c++11 diff --git a/spark-store.pro.user b/spark-store.pro.user index b02f53e..dafdb2a 100644 --- a/spark-store.pro.user +++ b/spark-store.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -293,14 +293,15 @@ 2 - - Custom Executable + spark-store - ProjectExplorer.CustomExecutableRunConfiguration + Qt4ProjectManager.Qt4RunConfiguration:/home/maicss/git/spark/spark-store/spark-store.pro + spark-store.pro 3768 false true + true false false true diff --git a/widget.cpp b/widget.cpp index 75277cf..0b8af52 100644 --- a/widget.cpp +++ b/widget.cpp @@ -37,6 +37,7 @@ Widget::Widget(DBlurEffectWidget *parent) : initUI(); initConfig(); manager = new QNetworkAccessManager(this);//下载管理 + m_loadweb=ui->progressload; connect(ui->menu_main,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(0);}); connect(ui->menu_network,&QPushButton::clicked,[=](){Widget::chooseLeftMenu(1);}); @@ -99,6 +100,11 @@ Widget::Widget(DBlurEffectWidget *parent) : size2=download_size; } }); + + + // + m_loadweb->show(); + m_loadweb->setValue(50); } @@ -173,19 +179,20 @@ void Widget::initUI() //初始化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); +// QHBoxLayout *m_weblayout=new QHBoxLayout; +// m_weblayout->addWidget(m_loadweb); +// m_weblayout->addWidget(m_loaderror); +// m_loadweb->hide(); +// m_loadweb->setParent(ui->webEngineView); +// 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->webEngineView->setLayout(m_weblayout); // ui->stackedWidget->setLayout(m_weblayout); ui->label_show->hide(); @@ -233,12 +240,13 @@ void Widget::initConfig() //web控件初始化 - ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); //用来激活接受linkClicked信号 - ui->webView->page()->settings()->setAttribute(QWebSettings::JavascriptEnabled,true); +// ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); //用来激活接受linkClicked信号 +// ui->webView->page()->settings()->setAttribute(QWebSettings::JavascriptEnabled,true); ui->webfoot->hide(); //初始化首页 - ui->webView->setUrl(menuUrl[0]); + ui->webEngineView->setUrl(menuUrl[0]); +// ui->webEngineView->setUrl(menuUrl[1]); chooseLeftMenu(0); //给下载列表赋值到数组,方便调用 @@ -265,7 +273,7 @@ void Widget::setTheme(bool isDark,QColor color) if(isDark){ //黑色模式 themeIsDark=true; - ui->webView->setStyleSheet("background-color:#282828"); + ui->webEngineView->setStyleSheet("background-color:#282828"); ui->btn_openDir->setStyleSheet("color:#8B91A1;background-color:#2E2F30;border:0px"); ui->webfoot->setStyleSheet("background-color:#252525"); ui->label->setStyleSheet("background-color:#252525"); @@ -278,7 +286,7 @@ void Widget::setTheme(bool isDark,QColor color) }else { //亮色模式 themeIsDark=false; - ui->webView->setStyleSheet("background-color:#FFFFFF"); + ui->webEngineView->setStyleSheet("background-color:#FFFFFF"); ui->webfoot->setStyleSheet("background-color:#FFFFFF"); ui->btn_openDir->setStyleSheet("color:#505050;background-color:#FBFBFB;border:0px"); ui->label->setStyleSheet("background-color:#FFFFFF"); @@ -300,35 +308,6 @@ DTitlebar* Widget::getTitlebar() { return ui->titlebar; } - -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();//打开并发加载线程前关闭正在执行的线程 - - 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::updateUI() { if(themeIsDark){ @@ -423,8 +402,6 @@ void Widget::chooseLeftMenu(int index) { nowMenu=index; -// setfoot(); -// updatefoot(); updateUI(); left_list[index]->setStyleSheet("color:#FFFFFF;background-color:"+main_color.name()+";border-radius:8;border:0px"); @@ -437,10 +414,11 @@ void Widget::chooseLeftMenu(int index) darkurl+=tmp[i]+"/"; } darkurl+="dark"+tmp[tmp.size()-1]; - ui->webView->setUrl(darkurl); + ui->webEngineView->setUrl(darkurl); qDebug()<webView->setUrl(menuUrl[index]); + ui->webEngineView->setUrl(menuUrl[index]); + } ui->stackedWidget->setCurrentIndex(0); @@ -475,6 +453,7 @@ void Widget::loadappinfo(QUrl arg1) ui->screen_2->hide(); ui->screen_3->hide(); ui->screen_4->hide(); + ui->label_appicon->clear(); //置UI状态 ui->pushButton_uninstall->hide(); @@ -881,7 +860,7 @@ void Widget::opensetting() void Widget::openUrl(QUrl u) { QString app=serverUrl + "store"+u.path()+"/app.json"; - ui->webView->setUrl(app); + ui->webEngineView->setUrl(app); } @@ -892,25 +871,6 @@ void Widget::on_pushButton_website_clicked() } -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); - if(progress>=90){ - m_loadweb->hide(); - } -} - void Widget::on_pushButton_clicked() { QString share_url; @@ -936,3 +896,57 @@ void Widget::on_stackedWidget_currentChanged(int arg1) ui->pushButton_return->setEnabled(true); } } + +void Widget::on_webEngineView_urlChanged(const QUrl &arg1) +{ + //分析出服务器中的分类名称 + QStringList url_=arg1.path().split("/"); + QString pname; + if(url_.size()>3){ + type_name=url_[2]; + pname=url_[3]; + } + //如果是app.json就打开详情页 + if(arg1.path().right(8)=="app.json"){ + load.cancel();//打开并发加载线程前关闭正在执行的线程 + + ui->label_more->setText("");//清空详情介绍 + ui->label_info->setText(""); + ui->label_appname->setText(""); + ui->pushButton_download->setEnabled(false); + ui->stackedWidget->setCurrentIndex(2); + qDebug()<<"https://demo-one-vert.vercel.app/"+type_name+"/"+pname; + load.cancel();//打开并发加载线程前关闭正在执行的线程 + load = QtConcurrent::run([=](){ + + loadappinfo(arg1); + }); + } +} + +void Widget::on_webEngineView_loadStarted() +{ +// m_loadweb->setValue(0); +// m_loadweb->show(); +// m_loaderror->hide(); +// ui->label_show->hide(); +} + +void Widget::on_webEngineView_loadProgress(int progress) +{ +// m_loadweb->setValue(progress); +// if(progress>=90){ +// m_loadweb->hide(); +// } +} + +void Widget::on_webEngineView_loadFinished(bool arg1) +{ +// if(arg1){ +// m_loadweb->hide(); +// }else { +// m_loadweb->hide(); +// m_loaderror->show(); +// } + +} diff --git a/widget.h b/widget.h index 3bd38a3..040fb32 100644 --- a/widget.h +++ b/widget.h @@ -19,6 +19,7 @@ #include #include #include +#include #define LIST_MAX 99 //一次最多下载数量 #define TMP_PATH "/tmp/spark-store" @@ -53,15 +54,12 @@ private slots: void updateDataReadProgress(qint64,qint64); 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(); @@ -69,6 +67,14 @@ private slots: void on_stackedWidget_currentChanged(int arg1); + void on_webEngineView_urlChanged(const QUrl &arg1); + + void on_webEngineView_loadStarted(); + + void on_webEngineView_loadProgress(int progress); + + void on_webEngineView_loadFinished(bool arg1); + public: QUrl url; @@ -101,7 +107,7 @@ private: private: QPushButton * left_list[15]; QUrl menuUrl[13]; - DWaterProgress *m_loadweb=new DWaterProgress; + ProgressLoad *m_loadweb; QLabel *m_loaderror=new QLabel; QString serverUrl; bool configCanSave=false; diff --git a/widget.ui b/widget.ui index fec4597..875bb27 100644 --- a/widget.ui +++ b/widget.ui @@ -29,7 +29,7 @@ 0 - + @@ -147,6 +147,13 @@ + + + + 编程开发 + + + @@ -164,13 +171,6 @@ - - - - 编程开发 - - - @@ -278,7 +278,7 @@ - + @@ -287,7 +287,7 @@ 0 - 3 + 2 @@ -307,263 +307,10 @@ 0 - - - - - - - - 65 - 77 - 104 - - - - - - - 3 - 3 - 3 - - - - - - - 46 - 46 - 46 - - - - - - - 65 - 77 - 104 - - - - - - - 65 - 77 - 104 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 28 - 28 - 28 - - - - - - - 0 - 0 - 0 - - - - - - - - - 138 - 145 - 161 - - - - - - - 3 - 3 - 3 - - - - - - - 46 - 46 - 46 - - - - - - - 138 - 145 - 161 - - - - - - - 138 - 145 - 161 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 28 - 28 - 28 - - - - - - - 0 - 0 - 0 - - - - - - - - - 46 - 46 - 46 - - - - - - - 3 - 3 - 3 - - - - - - - 46 - 46 - 46 - - - - - - - 46 - 46 - 46 - - - - - - - 46 - 46 - 46 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 28 - 28 - 28 - - - - - - - 0 - 0 - 0 - - - - - - + - http://0.0.0.1/ + about:blank @@ -657,7 +404,7 @@ 0 - 0 + 10 @@ -674,7 +421,7 @@ 0 - 0 + -228 901 849 @@ -1385,13 +1132,32 @@ + + + + + 0 + 10 + + + + + 16777215 + 10 + + + + background-color:#000000 + + + - QWebView + QWebEngineView QWidget -
QtWebKitWidgets/QWebView
+
QtWebEngineWidgets/QWebEngineView
image_show @@ -1405,6 +1171,12 @@
dtitlebar.h
1
+ + ProgressLoad + QWidget +
progressload.h
+ 1 +