mirror of
https://gitee.com/spark-store-project/spark-store
synced 2025-09-03 01:42:20 +08:00
详情页面添加翻译按钮
This commit is contained in:
parent
d027d513a3
commit
1cbabe7cc5
27
widget.cpp
27
widget.cpp
@ -18,6 +18,7 @@
|
|||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QGraphicsOpacityEffect>
|
#include <QGraphicsOpacityEffect>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QMessageBox>
|
||||||
#include <DSettings>
|
#include <DSettings>
|
||||||
#include <DSettingsOption>
|
#include <DSettingsOption>
|
||||||
#include <DSettingsDialog>
|
#include <DSettingsDialog>
|
||||||
@ -161,7 +162,6 @@ void Widget::initUI()
|
|||||||
[=](){QDesktopServices::openUrl(QUrl("https://upload.spark-app.store/"));});
|
[=](){QDesktopServices::openUrl(QUrl("https://upload.spark-app.store/"));});
|
||||||
connect(setting,&QAction::triggered,this,&Widget::opensetting);
|
connect(setting,&QAction::triggered,this,&Widget::opensetting);
|
||||||
|
|
||||||
|
|
||||||
// 初始化菜单数组
|
// 初始化菜单数组
|
||||||
left_list[0]=ui->menu_main;
|
left_list[0]=ui->menu_main;
|
||||||
left_list[1]=ui->menu_network;
|
left_list[1]=ui->menu_network;
|
||||||
@ -462,9 +462,11 @@ int Widget::loadappinfo(QUrl arg1)
|
|||||||
|
|
||||||
// 重置UI状态
|
// 重置UI状态
|
||||||
ui->pushButton_uninstall->hide();
|
ui->pushButton_uninstall->hide();
|
||||||
|
ui->pushButton_website->setEnabled(false);
|
||||||
|
ui->pushButton->setEnabled(false);
|
||||||
|
ui->pushButton_translate->setEnabled(false);
|
||||||
ui->label_show->setText("Loading...");
|
ui->label_show->setText("Loading...");
|
||||||
ui->label_show->show();
|
ui->label_show->show();
|
||||||
ui->pushButton_website->hide();
|
|
||||||
|
|
||||||
QProcess get_json;
|
QProcess get_json;
|
||||||
QDir dir("/tmp");
|
QDir dir("/tmp");
|
||||||
@ -561,6 +563,9 @@ int Widget::loadappinfo(QUrl arg1)
|
|||||||
QPixmap appicon(QString::fromUtf8(TMP_PATH)+"/icon.png");
|
QPixmap appicon(QString::fromUtf8(TMP_PATH)+"/icon.png");
|
||||||
ui->label_appicon->setPixmap(appicon);
|
ui->label_appicon->setPixmap(appicon);
|
||||||
ui->pushButton_download->setEnabled(true);
|
ui->pushButton_download->setEnabled(true);
|
||||||
|
ui->pushButton->setEnabled(true);
|
||||||
|
ui->pushButton_translate->setEnabled(true);
|
||||||
|
ui->pushButton_website->setEnabled(true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
sendNotification(tr("Failed to load application icon."));
|
sendNotification(tr("Failed to load application icon."));
|
||||||
@ -575,9 +580,11 @@ int Widget::loadappinfo(QUrl arg1)
|
|||||||
label_screen[4]=ui->screen_4;
|
label_screen[4]=ui->screen_4;
|
||||||
for (int i=0;i<5;i++) {
|
for (int i=0;i<5;i++) {
|
||||||
QString cmd = "curl -o screen_"+QString::number(i+1)+".png "+urladdress+"screen_"+QString::number(i+1)+".png";
|
QString cmd = "curl -o screen_"+QString::number(i+1)+".png "+urladdress+"screen_"+QString::number(i+1)+".png";
|
||||||
|
get_json.terminate();
|
||||||
get_json.start(cmd);
|
get_json.start(cmd);
|
||||||
get_json.waitForFinished();
|
get_json.waitForFinished();
|
||||||
if(screen[i].load("screen_"+QString::number(i+1)+".png")){
|
bool s = screen[i].load("screen_"+QString::number(i+1)+".png");
|
||||||
|
if(s){
|
||||||
label_screen[i]->setImage(screen[i]);
|
label_screen[i]->setImage(screen[i]);
|
||||||
label_screen[i]->show();
|
label_screen[i]->show();
|
||||||
switch(i){ // 故意为之,为了清除多余截图
|
switch(i){ // 故意为之,为了清除多余截图
|
||||||
@ -978,7 +985,6 @@ void Widget::on_webEngineView_urlChanged(const QUrl &arg1)
|
|||||||
qDebug()<<"https://demo-one-vert.vercel.app/"+type_name+"/"+pname;
|
qDebug()<<"https://demo-one-vert.vercel.app/"+type_name+"/"+pname;
|
||||||
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
load.cancel();//打开并发加载线程前关闭正在执行的线程
|
||||||
load = QtConcurrent::run([=](){
|
load = QtConcurrent::run([=](){
|
||||||
|
|
||||||
int loadresult = loadappinfo(arg1);
|
int loadresult = loadappinfo(arg1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -1010,3 +1016,16 @@ void Widget::on_webEngineView_loadFinished(bool arg1)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::on_pushButton_translate_clicked()
|
||||||
|
{
|
||||||
|
if(QMessageBox::information(nullptr, tr("Information for Contributors"),
|
||||||
|
tr("Currently the translation contribution is limited to English, "
|
||||||
|
"and you will be redirected to our Gitee repository at which you are "
|
||||||
|
"supposed to be creating pull requests to contribute app info "
|
||||||
|
"translations.\n\nClick yes to continue."),
|
||||||
|
QMessageBox::StandardButton::Yes | QMessageBox::StandardButton::No)
|
||||||
|
== QMessageBox::Yes)
|
||||||
|
QDesktopServices::openUrl("https://gitee.com/deepin-community-store/json/tree/master/store/" +
|
||||||
|
type_name + '/' + pkgName);
|
||||||
|
}
|
||||||
|
13
widget.h
13
widget.h
@ -10,6 +10,7 @@
|
|||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QFuture>
|
#include <QFuture>
|
||||||
|
#include <QFutureWatcher>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <DSettings>
|
#include <DSettings>
|
||||||
@ -63,24 +64,17 @@ private slots:
|
|||||||
void on_pushButton_uninstall_clicked();
|
void on_pushButton_uninstall_clicked();
|
||||||
void on_pushButton_clear_clicked();
|
void on_pushButton_clear_clicked();
|
||||||
void on_pushButton_website_clicked();
|
void on_pushButton_website_clicked();
|
||||||
|
|
||||||
void on_pushButton_clicked();
|
void on_pushButton_clicked();
|
||||||
|
|
||||||
void on_btn_openDir_clicked();
|
void on_btn_openDir_clicked();
|
||||||
|
|
||||||
void on_stackedWidget_currentChanged(int arg1);
|
void on_stackedWidget_currentChanged(int arg1);
|
||||||
|
|
||||||
void on_webEngineView_urlChanged(const QUrl &arg1);
|
void on_webEngineView_urlChanged(const QUrl &arg1);
|
||||||
|
|
||||||
void on_webEngineView_loadStarted();
|
void on_webEngineView_loadStarted();
|
||||||
|
|
||||||
void on_webEngineView_loadProgress(int progress);
|
void on_webEngineView_loadProgress(int progress);
|
||||||
|
|
||||||
void on_webEngineView_loadFinished(bool arg1);
|
void on_webEngineView_loadFinished(bool arg1);
|
||||||
|
|
||||||
void on_pushButton_refresh_clicked();
|
void on_pushButton_refresh_clicked();
|
||||||
|
void on_pushButton_translate_clicked();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
|
|
||||||
@ -123,6 +117,7 @@ private:
|
|||||||
long size2=0;
|
long size2=0;
|
||||||
QPixmap screen[5];
|
QPixmap screen[5];
|
||||||
QFuture<void> load;
|
QFuture<void> load;
|
||||||
|
QFutureWatcher<void> watchScreenshotLoad;
|
||||||
QTimer download_speed;
|
QTimer download_speed;
|
||||||
QString type_name;
|
QString type_name;
|
||||||
QColor main_color;
|
QColor main_color;
|
||||||
|
116
widget.ui
116
widget.ui
@ -216,12 +216,15 @@
|
|||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Home </string>
|
<string>Home </string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="flat">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0" colspan="6">
|
<item row="7" column="0" colspan="6">
|
||||||
<widget class="QPushButton" name="menu_photo">
|
<widget class="QPushButton" name="menu_photo">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Graphic</string>
|
<string>Graphics</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -453,9 +456,9 @@
|
|||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>-90</y>
|
||||||
<width>903</width>
|
<width>889</width>
|
||||||
<height>849</height>
|
<height>854</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_17">
|
<layout class="QVBoxLayout" name="verticalLayout_17">
|
||||||
@ -474,6 +477,45 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="3" column="0">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Maximum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>70</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="2">
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Maximum</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QPushButton" name="pushButton_download">
|
||||||
|
<property name="text">
|
||||||
|
<string>Install</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="3" colspan="2">
|
<item row="0" column="3" colspan="2">
|
||||||
<widget class="QLabel" name="label_appname">
|
<widget class="QLabel" name="label_appname">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
@ -487,7 +529,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="3" rowspan="5" colspan="7">
|
<item row="3" column="3" rowspan="5" colspan="8">
|
||||||
<widget class="QLabel" name="label_info">
|
<widget class="QLabel" name="label_info">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
@ -533,7 +575,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="9">
|
<item row="0" column="10">
|
||||||
<spacer name="horizontalSpacer_6">
|
<spacer name="horizontalSpacer_6">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
@ -546,45 +588,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="2">
|
|
||||||
<spacer name="horizontalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Maximum</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>60</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="0">
|
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Maximum</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>70</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="1">
|
|
||||||
<widget class="QPushButton" name="pushButton_download">
|
|
||||||
<property name="text">
|
|
||||||
<string>Install</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="7" column="1" rowspan="2">
|
<item row="7" column="1" rowspan="2">
|
||||||
<spacer name="verticalSpacer_2">
|
<spacer name="verticalSpacer_2">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@ -669,7 +672,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="3" colspan="7">
|
<item row="0" column="8">
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Share</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3" colspan="8">
|
||||||
<widget class="QWidget" name="widget" native="true">
|
<widget class="QWidget" name="widget" native="true">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
@ -852,10 +862,10 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="8">
|
<item row="0" column="9">
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QPushButton" name="pushButton_translate">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Share</string>
|
<string>Contribute translation</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -936,8 +946,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>869</width>
|
<width>851</width>
|
||||||
<height>325</height>
|
<height>323</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
@ -1066,8 +1076,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>738</width>
|
<width>743</width>
|
||||||
<height>896</height>
|
<height>902</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_23">
|
<layout class="QVBoxLayout" name="verticalLayout_23">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user