完成获取应用列表、获取内置app列表

master
Mike Solar 2023-08-10 15:36:08 +08:00
parent 0ecf1bdf6a
commit b8da134809
22 changed files with 920 additions and 547 deletions

View File

@ -8,7 +8,11 @@ MyButton::MyButton(ButtonStruct &buttonStruct,int width,int height,QList<MyButto
this->width2=width;
this->height2=height;
this->text=buttonStruct.text;
this->op = buttonStruct.op;
this->func = buttonStruct.func;
this->url = buttonStruct.url;
this->path = buttonStruct.path;
this->initial_position = buttonStruct.initial_position;
this->logo=buttonStruct.image;
this->logo_cover = buttonStruct.image_cover;
this->background_color = buttonStruct.background_color;
@ -82,6 +86,6 @@ void MyButton::mouseReleaseEvent(QMouseEvent *event) {
checked=false;
else
checked=true;
emit clicked1(text, url);
emit clicked1(op, func, url, path, initial_position);
}

View File

@ -16,7 +16,7 @@
class MyButton: public QPushButton{
Q_OBJECT
signals:
void clicked1(QString text, QString url);
void clicked1(QString op, QString func, QString url, QString path, QString initial_position);
public:
MyButton(ButtonStruct &buttonStruct,int width,int height,QList<MyButton *> *buttons,QWidget *parent=nullptr);
~MyButton() override;
@ -58,6 +58,10 @@ private:
QVBoxLayout *layout;
QString text;
QString url;
QString op;
QString path;
QString initial_position;
QString func;
int width2;
int height2;
int logicalwidth;

View File

@ -72,9 +72,6 @@
</QtMoc>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="mainscreen.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -102,6 +99,9 @@
<ClCompile Include="MyButton.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtUic Include="navbar.ui">

View File

@ -5,7 +5,7 @@
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<QtLastBackgroundBuild>2023-08-06T14:26:06.9540300Z</QtLastBackgroundBuild>
<QtLastBackgroundBuild>2023-08-08T01:58:42.4896992Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<QtLastBackgroundBuild>2023-08-08T01:58:34.1935757Z</QtLastBackgroundBuild>

View File

@ -16,5 +16,8 @@ typedef struct taButtonStruct{
QColor text_color;
QColor text_cover_color;
QString path;
QString initial_position;
QString op;
QString func;
}ButtonStruct;
#endif //OFFICEASSISTANT_BUTTONSTRUCT_H

View File

@ -11,7 +11,7 @@
#define DEFAULT_FILE "/config/default_navbar.kmd" //默认导航栏文件位置
#define KEY "3b046cfe4a2a3e62141a4840f2006210a3224e3615312bef6e19f4983921abe0" //Key
#define NAME "办公助手" //中文名
#define LOGO_TITLEBAR "/icon/logo_navbar.png" //깃痙으暠깃
#define LOGO_TITLEBAR "/images/icon/logo_navbar.png" //깃痙으暠깃
#define ENG_NAME "OfficeAssistant" //英文名
#define LENG_NAME L"OfficeAssistant" //英文名(宽字符)
#define ADD_AUTOSTART 1
@ -19,4 +19,6 @@
#define VERSION "1.0.0" //软件版本
#define RELEASE "20230801" //Release
#define SOFTWARE_URL "http://softapi.1.y01.cn/addons/Kmdsoft/Index/soft"
#define DEFAULT_COLOR "#3399FF"
#define DEFAULT_IMAGE "/images/icon/default.svg"
#endif //OFFICEASSISTANT_CONFIG_H

View File

View File

@ -1,5 +1,4 @@
#include "mainwindow.h"
#include <QApplication>
#include <Windows.h>
double scale;

View File

@ -76,9 +76,9 @@ void MainScreen::firstUrl(QString url)
QString url_full = BASE_URL + url + url_param;
emit changeUrl(url_full);
}
void MainScreen::clickButton1(QString text, QString url) {
void MainScreen::clickButton1(QString op,QString url) {
QString url_full = BASE_URL + url + url_param;
if (text == QString::fromLocal8Bit("微信多开")) {
if (op == "openwechat") {
widget->setHidden(false);
miniblink->setHidden(false);
emit changeUrl(url_full);
@ -91,7 +91,7 @@ void MainScreen::clickButton1(QString text, QString url) {
}
void MainScreen::startWeChat() {
QString path = QApplication::applicationDirPath();
QString exe = path + "/app/wxdk.exe";
QString exe = path + "/app/wxdk/wxdk.exe";
path.replace("/", "\\");
ShellExecute(GetDesktopWindow(), L"open", exe.toStdWString().c_str(), L"79c86fb12b36dfa33d1a537c9af100b4c7928a9c", path.toStdWString().c_str(), SW_SHOW);
}

View File

@ -27,7 +27,7 @@ public:
explicit MainScreen(QWidget *parent = nullptr);
~MainScreen() override;
public slots:
void clickButton1(QString text, QString url);
void clickButton1(QString op, QString url);
void firstUrl(QString url);
protected:
//void resizeEvent(QResizeEvent *event) override;

View File

@ -7,16 +7,18 @@
#include "mainwindowlayout.h"
#include "ui_MainWindowLayout.h"
#include "mysettingsdialog.h"
#include "netio.h"
#include "sqlitehelper.h"
MainWindowLayout::MainWindowLayout(QWidget *parent) :
QWidget(parent), ui(new Ui::MainWindowLayout) {
ui->setupUi(this);
setContentsMargins(0, 0, 0, 0);
SQLiteHelper sqlite_helper;
sqlite_helper.update_app();
sqlite_helper.update_software();
layout=new QVBoxLayout(this);
mainWindowLayout = this;
SQLiteHelper sqlite_helper;
QList<ButtonStruct> list;
sqlite_helper.get_software(&list);
ConfigRequest *configRequest = new ConfigRequest;
configResponse = new ConfigResponse;
configRequest->sendRequest(configResponse);
@ -54,20 +56,35 @@ void MainWindowLayout::resizeEvent(QResizeEvent *event) {
//layout->setAlignment(Qt::AlignmentFlag::AlignHCenter);
}
void MainWindowLayout::clickButton(QString text, QString url) {
QString path = QApplication::applicationDirPath();
path += "/app/startcalc.exe";
void MainWindowLayout::clickButton(QString op, QString func, QString url,QString path,QString initial_position) {
QString root_path = QApplication::applicationDirPath();
if(op=="app")
{
if(func=="openwechat")
{
emit clickButton1("openwechat", url);
}else
{
path = root_path + path;
path.replace("/", "\\");
if (text== QString::fromLocal8Bit("计算器")) {
WinExec(path.toStdString().c_str(), SW_SHOW);
emit clickButton1(op, url);
}
else if (text == QString::fromLocal8Bit("软件设置")) {
MySettingsDialog *settings = new MySettingsDialog;
}
else if (op == "self") {
if(func=="settings")
{
MySettingsDialog* settings = new MySettingsDialog;
settings->exec();
delete settings;
}
else{
emit clickButton1(text, url);
}
else if(op=="soft"){
ShellExecute(GetDesktopWindow(), L"open",path.toStdWString().c_str(),L"",initial_position.toStdWString().c_str(),SW_SHOW);
emit clickButton1(op, url);
}else
{
emit clickButton1(op, url);
}
}

View File

@ -19,13 +19,13 @@ QT_END_NAMESPACE
class MainWindowLayout : public QWidget {
Q_OBJECT
signals:
void clickButton1(QString text, QString url);
void clickButton1(QString op,QString url);
public:
explicit MainWindowLayout(QWidget *parent = nullptr);
~MainWindowLayout() override;
public slots:
void clickButton(QString text, QString url);
void clickButton(QString op, QString func, QString url, QString path, QString initial_position);
protected:
void resizeEvent(QResizeEvent *event) override;
//void paintEvent(QPaintEvent *event) override;

View File

@ -2,6 +2,7 @@
#include <Windows.h>
#include <QClipBoard>
#include "netio.h"
#include "sqlitehelper.h"
#include "config.h"
#include "globalvariables.h"
MySettingsDialog::MySettingsDialog(QWidget *parent)

View File

@ -12,6 +12,7 @@
#include <QPixmap>
#include "mainwindowlayout.h"
#include "globalvariables.h"
#include "sqlitehelper.h"
#ifdef _DEBUG
#pragma comment(lib, "Qt5Svgd.lib")
#pragma comment(lib, "Qt5Sqld.lib")
@ -48,10 +49,16 @@ NavBar::NavBar(ConfigResponse *configResponse, MainScreen *mainScreen,QWidget *p
setStyleSheet(style);*/
//setStyleSheet("margin:0");
setContentsMargins(0, 0, 0, 0);
if (configResponse->succeed&&configResponse->buttons.empty()!=true) {
getLogoFromInternet(configResponse);
}
else {
ConfigResponse config_response;
ConfigRequest config_request;
config_request.sendRequest(&config_response);
SQLiteHelper sqlite_helper;
sqlite_helper.get_software(&buttonStructs, &config_response);
if(config_response.succeed==true)
{
getLogoFromInternet(&config_response);
}else
{
getLogoFromLocal();
}
layout2 = new QHBoxLayout;
@ -143,68 +150,9 @@ void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
logo = new QImage();
logo->loadFromData(*buffer);
buffer->clear();
for (auto button : configResponse->buttons) {
QUrl url_image(button.img);
QNetworkRequest *request_image = new QNetworkRequest(url_image);
reply = manager->get(*request_image);
QTimer timer;
timer.setInterval(5000);
connect(reply, &QNetworkReply::finished, &eventLoop, &QEventLoop::quit);
connect(&timer, &QTimer::timeout, this, &NavBar::cancelDownload);
eventLoop.exec();
timer.stop();
if (!downloadSuccess) {
break;
}
*buffer = reply->readAll();
QSvgRenderer *render_image = new QSvgRenderer(*buffer);
QImage *image = new QImage(200, 200, QImage::Format_ARGB32);
QPainter painter_image(image);
painter_image.setCompositionMode(QPainter::CompositionMode_Clear); // 清除画布
painter_image.fillRect(rect(), Qt::transparent); // 填充透明色
painter_image.setCompositionMode(QPainter::CompositionMode_SourceOver); // 恢复默认值
render_image->render(&painter_image);
buffer->clear();
reply->close();
QUrl url_image_cover(button.img_cover);
QNetworkRequest *request_image_cover = new QNetworkRequest(url_image_cover);
reply = manager->get(*request_image_cover);
timer.setInterval(5000);
connect(reply, &QNetworkReply::finished, &eventLoop, &QEventLoop::quit);
connect(&timer, &QTimer::timeout, this, &NavBar::cancelDownload);
if (!downloadSuccess) {
break;
}
eventLoop.exec();
*buffer = reply->readAll();
qDebug() << *buffer;
QSvgRenderer *render_image_cover = new QSvgRenderer(*buffer);
QImage *image_cover = new QImage(200, 200, QImage::Format_ARGB32);
QPainter painter_image_cover(image_cover);
painter_image_cover.setCompositionMode(QPainter::CompositionMode_Clear); // 清除画布
painter_image_cover.fillRect(rect(), Qt::transparent); // 填充透明色
painter_image_cover.setCompositionMode(QPainter::CompositionMode_SourceOver); // 恢复默认值
render_image_cover->render(&painter_image_cover);
buffer->clear();
reply->close();
ButtonStruct buttonStruct;
buttonStruct.image = image;
buttonStruct.image_cover = image_cover;
buttonStruct.text = button.title;
buttonStruct.url = button.url;
buttonStruct.background_color = configResponse->basic.backgroud_color;
buttonStruct.text_color.setNamedColor(configResponse->basic.title_color);
buttonStruct.text_cover_color.setNamedColor(configResponse->basic.title_cover_color);
buttonStructs << buttonStruct;
delete request_image;
delete render_image;
delete request_image_cover;
delete render_image_cover;
}
}else
{
getLogoFromLocal();
}
delete manager;
manager = nullptr;
@ -242,16 +190,6 @@ void NavBar::getLogoFromLocal() {
QString color= obj_root->value("basic").toObject().value("backgroud_color").toString();
qColor.setNamedColor(color);
QJsonArray *array = new QJsonArray;
*array = obj_root->value("menu").toArray();
for (auto obj : *array) {
ButtonStruct buttonStruct;
buttonStruct.text = obj.toObject().value("title").toString();
buttonStruct.url = QString(BASE_URL)+obj.toObject().value("url").toString();
buttonStruct.image = new QImage(obj.toObject().value("img").toString());
buttonStruct.image_cover = new QImage(obj.toObject().value("img_cover").toString());
buttonStructs << buttonStruct;
}
delete array;
}
else {
QMessageBox::warning(nullptr, QString::fromLocal8Bit("´íÎó"), QString::fromLocal8Bit("ÅäÖÃÎļþËð»µ"));

View File

@ -585,10 +585,13 @@ bool SoftwareRequest::sendRequest(QHash<QString, Record> *records)
QJsonArray array;
for(auto record : *records)
{
array.append(record.orig_name);
QJsonObject object;
object.insert("orig_name", record.orig_name);
object.insert("path", record.path);
array.append(object);
}
QJsonObject obj_root = qJsonDocument.object();
obj_root.insert("orig_names", array);
obj_root.insert("software", array);
qJsonDocument.setObject(obj_root);
QString url = SOFTWARE_URL;
requestInfo.setUrl(url);
@ -626,9 +629,8 @@ bool SoftwareRequest::sendRequest(QHash<QString, Record> *records)
QJsonObject object = value.toObject();
QString orig_name = object.value("orig_name").toString();
(*records)[orig_name].logo = object.value("img").toString();
(*records)[orig_name].op = object.value("op").toString();
(*records)[orig_name].func = object.value("func").toString();
(*records)[orig_name].url = object.value("url").toString();
(*records)[orig_name].path = object.value("path").toString();
}
}
else {

View File

@ -25,7 +25,7 @@ typedef struct {
QString func;
QString url;
} Button;
typedef struct {
struct ConfigResponse {
bool succeed;
struct {
QString logo_url;
@ -37,7 +37,7 @@ typedef struct {
QString title_cover_color;
}basic;
QList<Button> buttons;
}ConfigResponse;
};
class RequestBodyBase:public QObject{
Q_OBJECT;

File diff suppressed because it is too large Load Diff

View File

@ -6,9 +6,11 @@
#include <QObject>
#include <QDate>
#include <QtNetwork/QtNetwork>
#include "buttonstruct.h"
typedef struct {
struct ConfigResponse;
class ConfigRequest;
class SoftwareRequest;
typedef struct tagRecord{
int id;
int sort;
QString app_id;
@ -26,7 +28,9 @@ typedef struct {
QString func;
QString path;
QString url;
bool status;
}Record;
#include "netio.h"
class SQLiteHelper : public QObject
{
@ -35,8 +39,8 @@ class SQLiteHelper : public QObject
public:
SQLiteHelper(QObject *parent = nullptr);
bool update_software();
bool get_software(QList<ButtonStruct>* buttons);
bool update_others();
bool get_software(QList<ButtonStruct>* buttons, ConfigResponse* config_response);
bool update_app();
~SQLiteHelper();
private:

Binary file not shown.

View File

@ -28,7 +28,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v141_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
@ -71,14 +71,14 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)\app\</OutDir>
<OutDir>$(SolutionDir)$(Configuration)\app\startcalc\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)\app</OutDir>
<OutDir>$(SolutionDir)$(Configuration)\app\startcalc\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>

View File

@ -22,7 +22,7 @@
<ProjectGuid>{EB7371E8-27B1-4A15-9EE5-7BE1BC109FFB}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>wxdk</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>7.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
@ -71,14 +71,14 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)\app\</OutDir>
<OutDir>$(SolutionDir)$(Configuration)\app\wxdk\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)\app</OutDir>
<OutDir>$(SolutionDir)$(Configuration)\app\wxdk\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>