第一阶段初稿+修复部分内容
|
@ -14,4 +14,5 @@ OfficeAssistant_msvc.sdf
|
||||||
startcalc/Debug/
|
startcalc/Debug/
|
||||||
startcalc/Release/
|
startcalc/Release/
|
||||||
wxdk/Debug/
|
wxdk/Debug/
|
||||||
wxdk/Release/
|
wxdk/Release/
|
||||||
|
officeassistant-cppcheck-build-dir/
|
|
@ -23,7 +23,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<PlatformToolset>v140</PlatformToolset>
|
<PlatformToolset>v140_xp</PlatformToolset>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||||
<ImportGroup Condition="Exists('$(QtMsBuild)\qt_defaults.props')">
|
<ImportGroup Condition="Exists('$(QtMsBuild)\qt_defaults.props')">
|
||||||
|
@ -101,6 +101,9 @@
|
||||||
<ClInclude Include="config.h" />
|
<ClInclude Include="config.h" />
|
||||||
<ClInclude Include="globalvariables.h" />
|
<ClInclude Include="globalvariables.h" />
|
||||||
<QtMoc Include="qminiblink.h" />
|
<QtMoc Include="qminiblink.h" />
|
||||||
|
<QtMoc Include="settingsscreen.h" />
|
||||||
|
<QtMoc Include="switchbutton.h" />
|
||||||
|
<QtMoc Include="mythread.h" />
|
||||||
<ClInclude Include="wke.h" />
|
<ClInclude Include="wke.h" />
|
||||||
<QtMoc Include="mainwindowlayout.h" />
|
<QtMoc Include="mainwindowlayout.h" />
|
||||||
<QtMoc Include="mainwindow.h" />
|
<QtMoc Include="mainwindow.h" />
|
||||||
|
@ -115,9 +118,12 @@
|
||||||
<ClCompile Include="mainwindow.cpp" />
|
<ClCompile Include="mainwindow.cpp" />
|
||||||
<ClCompile Include="mainwindowlayout.cpp" />
|
<ClCompile Include="mainwindowlayout.cpp" />
|
||||||
<ClCompile Include="MyButton.cpp" />
|
<ClCompile Include="MyButton.cpp" />
|
||||||
|
<ClCompile Include="mythread.cpp" />
|
||||||
<ClCompile Include="navbar.cpp" />
|
<ClCompile Include="navbar.cpp" />
|
||||||
<ClCompile Include="netio.cpp" />
|
<ClCompile Include="netio.cpp" />
|
||||||
<ClCompile Include="qminiblink.cpp" />
|
<ClCompile Include="qminiblink.cpp" />
|
||||||
|
<ClCompile Include="settingsscreen.cpp" />
|
||||||
|
<ClCompile Include="switchbutton.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtUic Include="mainscreen.ui" />
|
<QtUic Include="mainscreen.ui" />
|
||||||
|
@ -125,6 +131,9 @@
|
||||||
<QtUic Include="mainwindowlayout.ui" />
|
<QtUic Include="mainwindowlayout.ui" />
|
||||||
<QtUic Include="navbar.ui" />
|
<QtUic Include="navbar.ui" />
|
||||||
<QtUic Include="qminiblink.ui" />
|
<QtUic Include="qminiblink.ui" />
|
||||||
|
<QtUic Include="qtwidgetsclass.ui" />
|
||||||
|
<QtUic Include="settingsscreen.ui" />
|
||||||
|
<QtUic Include="switchbutton.ui" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
|
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
|
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
|
||||||
<Extensions>ui</Extensions>
|
<Extensions>ui</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Translation Files">
|
<Filter Include="Source Files\Translation Files">
|
||||||
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
|
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
|
||||||
<Extensions>ts</Extensions>
|
<Extensions>ts</Extensions>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
@ -63,6 +63,15 @@
|
||||||
<QtMoc Include="qminiblink.h">
|
<QtMoc Include="qminiblink.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
|
<QtMoc Include="settingsscreen.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="switchbutton.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
|
<QtMoc Include="mythread.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="main.cpp">
|
<ClCompile Include="main.cpp">
|
||||||
|
@ -89,6 +98,15 @@
|
||||||
<ClCompile Include="qminiblink.cpp">
|
<ClCompile Include="qminiblink.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="settingsscreen.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="switchbutton.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="mythread.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtUic Include="navbar.ui">
|
<QtUic Include="navbar.ui">
|
||||||
|
@ -103,6 +121,15 @@
|
||||||
<QtUic Include="mainwindowlayout.ui">
|
<QtUic Include="mainwindowlayout.ui">
|
||||||
<Filter>Form Files</Filter>
|
<Filter>Form Files</Filter>
|
||||||
</QtUic>
|
</QtUic>
|
||||||
|
<QtUic Include="settingsscreen.ui">
|
||||||
|
<Filter>Form Files</Filter>
|
||||||
|
</QtUic>
|
||||||
|
<QtUic Include="qtwidgetsclass.ui">
|
||||||
|
<Filter>Form Files</Filter>
|
||||||
|
</QtUic>
|
||||||
|
<QtUic Include="switchbutton.ui">
|
||||||
|
<Filter>Form Files</Filter>
|
||||||
|
</QtUic>
|
||||||
<QtUic Include="qminiblink.ui">
|
<QtUic Include="qminiblink.ui">
|
||||||
<Filter>Form Files</Filter>
|
<Filter>Form Files</Filter>
|
||||||
</QtUic>
|
</QtUic>
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||||
<QtLastBackgroundBuild>2023-07-30T09:15:49.0117730Z</QtLastBackgroundBuild>
|
<QtLastBackgroundBuild>2023-07-30T18:20:21.4819233Z</QtLastBackgroundBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||||
<QtLastBackgroundBuild>2023-07-30T09:15:57.3451755Z</QtLastBackgroundBuild>
|
<QtLastBackgroundBuild>2023-07-30T18:20:22.3001457Z</QtLastBackgroundBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -9,4 +9,7 @@
|
||||||
#define DEVICE_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/device"
|
#define DEVICE_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/device"
|
||||||
#define BASE_URL "http://softapi.s103.y01.cn/"
|
#define BASE_URL "http://softapi.s103.y01.cn/"
|
||||||
#define DEFAULT_FILE "/config/default_navbar.kmd"
|
#define DEFAULT_FILE "/config/default_navbar.kmd"
|
||||||
|
|
||||||
|
#define ADD_AUTOSTART 1
|
||||||
|
#define ADD_SHORTCUT 2
|
||||||
#endif //OFFICEASSISTANT_CONFIG_H
|
#endif //OFFICEASSISTANT_CONFIG_H
|
||||||
|
|
|
@ -10,65 +10,93 @@
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
|
#include "globalvariables.h"
|
||||||
|
#include "settingsscreen.h"
|
||||||
|
#include "mythread.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MainScreen::MainScreen(QWidget *parent) :
|
MainScreen::MainScreen(QWidget *parent) :
|
||||||
QWidget(parent), ui(new Ui::MainScreen) {
|
QWidget(parent), ui(new Ui::MainScreen) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
broswer = new QWidget(this);
|
setContentsMargins(0, 0, 0, 0);
|
||||||
button = new QPushButton(this);
|
button = new QPushButton(this);
|
||||||
button->setHidden(true);
|
button->setHidden(true);
|
||||||
button->setStyleSheet("border-style:none;padding:10px;border-radius:5px;background-color:#FFFFFF");
|
button->setStyleSheet("border-style:none;padding:10px;border-radius:5px;background-color:#FFFFFF");
|
||||||
//Plus Math icon by Icons8
|
//Plus Math icon by Icons8
|
||||||
QString dir = QApplication::applicationDirPath();
|
QString dir = QApplication::applicationDirPath();
|
||||||
icon = new QIcon(dir + "/images/add.png");
|
icon = new QIcon(dir + QString::fromLocal8Bit("/images/add.png"));
|
||||||
button->setIcon(*icon);
|
button->setIcon(*icon);
|
||||||
layout = new QHBoxLayout;
|
layout = new QHBoxLayout;
|
||||||
layout->addWidget(broswer,4);
|
QSizePolicy sizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::QSizePolicy::Expanding);
|
||||||
|
button->setSizePolicy(sizePolicy);
|
||||||
|
miniblink = new QMiniBlink(this);
|
||||||
|
settingScreen = new SettingsScreen;
|
||||||
|
settingScreen->setHidden(true);
|
||||||
|
layout->addWidget(button, 1);
|
||||||
|
layout->addWidget(miniblink, 4);
|
||||||
|
layout->addWidget(settingScreen);
|
||||||
this->setLayout(layout);
|
this->setLayout(layout);
|
||||||
//QSizePolicy sizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::QSizePolicy::Expanding);
|
layout->setMargin(0);
|
||||||
//broswer->setSizePolicy(sizePolicy);
|
//miniblink->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
miniblink = new QMiniBlink(broswer,this);
|
|
||||||
miniblink->show();
|
miniblink->show();
|
||||||
//miniblink->setSizePolicy(sizePolicy);
|
//miniblink->setSizePolicy(sizePolicy);
|
||||||
thread = new QThread;
|
//thread = new MyThread(this,&miniblink);
|
||||||
miniblink->moveToThread(thread);
|
//thread->start();
|
||||||
connect(thread, &QThread::started, miniblink, &QMiniBlink::init);
|
//miniblink->moveToThread(thread);
|
||||||
connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
connect(this, &MainScreen::ondestroy, miniblink, &QMiniBlink::ondestroy);
|
||||||
connect(this, &MainScreen::destroy, miniblink, &QMiniBlink::destroy);
|
connect(button, &QPushButton::pressed, this, &MainScreen::startWeChat);
|
||||||
|
connect(this, &MainScreen::started, miniblink, &QMiniBlink::init);
|
||||||
|
//connect(miniblink, SIGNAL(finish()), miniblink, SLOT(deleteLater()));
|
||||||
|
//connect(miniblink, SIGNAL(destroyed()), thread, SLOT(quit()));
|
||||||
|
//connect(thread, &QThread::finished, thread, &QThread::deleteLater);
|
||||||
|
while(miniblink==nullptr){}
|
||||||
connect(this, &MainScreen::changeUrl, miniblink, &QMiniBlink::switchUrl);
|
connect(this, &MainScreen::changeUrl, miniblink, &QMiniBlink::switchUrl);
|
||||||
thread->start();
|
emit started();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainScreen::~MainScreen() {
|
MainScreen::~MainScreen() {
|
||||||
|
emit ondestroy();
|
||||||
|
layout->removeWidget(miniblink);
|
||||||
|
layout->removeWidget(settingScreen);
|
||||||
|
layout->removeWidget(button);
|
||||||
|
button->setIcon(QIcon(nullptr));
|
||||||
|
delete miniblink;
|
||||||
|
delete settingScreen;
|
||||||
|
delete button;
|
||||||
|
delete icon;
|
||||||
|
delete layout;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
void MainScreen::firstUrl(QString url)
|
||||||
|
{
|
||||||
|
emit changeUrl(url);
|
||||||
|
}
|
||||||
void MainScreen::clickButton1(QString text, QString url) {
|
void MainScreen::clickButton1(QString text, QString url) {
|
||||||
if (text == QString::fromLocal8Bit("΢ÐŶ࿪")) {
|
if (text == QString::fromLocal8Bit("΢ÐŶ࿪")) {
|
||||||
button->setHidden(false);
|
button->setHidden(false);
|
||||||
connect(button, &QPushButton::click, this, &MainScreen::startWeChat);
|
miniblink->setHidden(false);
|
||||||
if (button->layout() == nullptr) {
|
settingScreen->setHidden(true);
|
||||||
layout->insertWidget(1, button);
|
|
||||||
}
|
|
||||||
if (broswer->layout() == nullptr) {
|
|
||||||
layout->addWidget(broswer, 4);
|
|
||||||
}
|
|
||||||
emit changeUrl(url);
|
emit changeUrl(url);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (text == QString::fromLocal8Bit("Èí¼þÉèÖÃ")){
|
||||||
|
miniblink->setHidden(true);
|
||||||
|
button->setHidden(true);
|
||||||
|
settingScreen->setHidden(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (button->layout() != nullptr) {
|
button->setHidden(true);
|
||||||
layout->removeWidget(button);
|
miniblink->setHidden(false);
|
||||||
button->setHidden(true);
|
settingScreen->setHidden(true);
|
||||||
}
|
|
||||||
emit changeUrl(url);
|
emit changeUrl(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void MainScreen::startWeChat() {
|
void MainScreen::startWeChat() {
|
||||||
QString path = QApplication::applicationDirPath();
|
QString path = QApplication::applicationDirPath();
|
||||||
QString exe = path + "/wxdk.exe";
|
QString exe = path + "/wxdk.exe";
|
||||||
ShellExecute(GetDesktopWindow(), L"open", exe.toStdWString().c_str(), L"", path.toStdWString().c_str(), SW_SHOW);
|
ShellExecute(GetDesktopWindow(), L"open", exe.toStdWString().c_str(), L"79c86fb12b36dfa33d1a537c9af100b4c7928a9c", path.toStdWString().c_str(), SW_SHOW);
|
||||||
}
|
}
|
||||||
//void MainScreen::resizeEvent(QResizeEvent *event) {
|
//void MainScreen::resizeEvent(QResizeEvent *event) {
|
||||||
// QWidget::resizeEvent(event);
|
// QWidget::resizeEvent(event);
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include "wke.h"
|
#include "wke.h"
|
||||||
#include "qminiblink.h"
|
#include "qminiblink.h"
|
||||||
|
#include "settingsscreen.h"
|
||||||
|
class MyThread;
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainScreen; }
|
namespace Ui { class MainScreen; }
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -19,13 +20,16 @@ QT_END_NAMESPACE
|
||||||
class MainScreen : public QWidget {
|
class MainScreen : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
signals:
|
signals:
|
||||||
void destroy();
|
void started();
|
||||||
|
void ondestroy();
|
||||||
void changeUrl(QString url);
|
void changeUrl(QString url);
|
||||||
|
void initMiniBlink();
|
||||||
public:
|
public:
|
||||||
explicit MainScreen(QWidget *parent = nullptr);
|
explicit MainScreen(QWidget *parent = nullptr);
|
||||||
~MainScreen() override;
|
~MainScreen() override;
|
||||||
public slots:
|
public slots:
|
||||||
void clickButton1(QString text, QString url);
|
void clickButton1(QString text, QString url);
|
||||||
|
void firstUrl(QString url);
|
||||||
protected:
|
protected:
|
||||||
//void resizeEvent(QResizeEvent *event) override;
|
//void resizeEvent(QResizeEvent *event) override;
|
||||||
private:
|
private:
|
||||||
|
@ -36,11 +40,12 @@ private:
|
||||||
QIcon *icon;
|
QIcon *icon;
|
||||||
QWidget *broswer;
|
QWidget *broswer;
|
||||||
static bool isInited();
|
static bool isInited();
|
||||||
QThread *thread;
|
MyThread *thread;
|
||||||
QMiniBlink *miniblink;
|
QMiniBlink *miniblink;
|
||||||
|
SettingsScreen *settingScreen;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void startWeChat();
|
void startWeChat();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,18 +17,13 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
//delete desktopWidget;
|
//delete desktopWidget;
|
||||||
mainWindowLayout=new MainWindowLayout(this);
|
mainWindowLayout=new MainWindowLayout(this);
|
||||||
setCentralWidget(mainWindowLayout);
|
setCentralWidget(mainWindowLayout);
|
||||||
if(deskRect.width()*scale>1920){
|
setWindowState(Qt::WindowMaximized);
|
||||||
resize(1600,1080);
|
|
||||||
//this->setMaximumWidth(1600);
|
|
||||||
}else{
|
|
||||||
resize(800, 540);
|
|
||||||
//this->setMaximumWidth(800);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
|
this->setCentralWidget(nullptr);
|
||||||
delete mainWindowLayout;
|
delete mainWindowLayout;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,23 +13,29 @@ MainWindowLayout::MainWindowLayout(QWidget *parent) :
|
||||||
layout=new QVBoxLayout(this);
|
layout=new QVBoxLayout(this);
|
||||||
mainWindowLayout = this;
|
mainWindowLayout = this;
|
||||||
ConfigRequest *configRequest = new ConfigRequest;
|
ConfigRequest *configRequest = new ConfigRequest;
|
||||||
ConfigResponse *configResponse = new ConfigResponse;
|
configResponse = new ConfigResponse;
|
||||||
configRequest->sendRequest(configResponse);
|
configRequest->sendRequest(configResponse);
|
||||||
navBar=new NavBar(configResponse,this);
|
mainScreen = new MainScreen(this);
|
||||||
mainScreen=new MainScreen();
|
navBar=new NavBar(configResponse,mainScreen,this);
|
||||||
|
navBar->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
delete configRequest;
|
||||||
|
//QSizePolicy sizePolicy(QSizePolicy::Policy::Fixed, QSizePolicy::QSizePolicy::Fixed);
|
||||||
|
//navBar->setSizePolicy(sizePolicy);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
layout->addWidget(navBar,1);
|
layout->addWidget(navBar,1);
|
||||||
layout->addWidget(mainScreen,7);
|
layout->addWidget(mainScreen,7);
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
connect(this, &MainWindowLayout::clickButton1, mainScreen, &MainScreen::clickButton1);
|
connect(this,&MainWindowLayout::clickButton1,mainScreen,&MainScreen::clickButton1);
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindowLayout::~MainWindowLayout() {
|
MainWindowLayout::~MainWindowLayout() {
|
||||||
|
delete configResponse;
|
||||||
|
layout->removeWidget(mainScreen);
|
||||||
|
layout->removeWidget(navBar);
|
||||||
|
delete mainScreen;
|
||||||
//delete[] list[0];
|
//delete[] list[0];
|
||||||
delete navBar;
|
delete navBar;
|
||||||
//delete layout;
|
delete layout;
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ private:
|
||||||
NavBar *navBar;
|
NavBar *navBar;
|
||||||
ButtonStruct *buttons;
|
ButtonStruct *buttons;
|
||||||
MainScreen *mainScreen;
|
MainScreen *mainScreen;
|
||||||
|
ConfigResponse *configResponse;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
#include "mythread.h"
|
||||||
|
#include "qminiblink.h"
|
||||||
|
#include "mainscreen.h"
|
||||||
|
|
||||||
|
MyThread::MyThread(MainScreen * mainScreen, QMiniBlink *(*miniblink),QObject *parent)
|
||||||
|
: QThread(parent)
|
||||||
|
{
|
||||||
|
this->mainScreen = mainScreen;
|
||||||
|
this->miniblink = miniblink;
|
||||||
|
}
|
||||||
|
|
||||||
|
MyThread::~MyThread()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyThread::run() {
|
||||||
|
*miniblink = new QMiniBlink(mainScreen);
|
||||||
|
(*miniblink)->init();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MyThread::onstop() {
|
||||||
|
(*miniblink)->ondestroy();
|
||||||
|
delete miniblink;
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
#pragma once
|
||||||
|
class MainScreen;
|
||||||
|
#include <QThread>
|
||||||
|
#include "qminiblink.h"
|
||||||
|
class MyThread : public QThread
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
MyThread(MainScreen * mainScreen,QMiniBlink **miniblink,QObject *parent=nullptr);
|
||||||
|
MainScreen *mainScreen;
|
||||||
|
QMiniBlink *(*miniblink);
|
||||||
|
~MyThread();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void run() override;
|
||||||
|
public slots:
|
||||||
|
void onstop();
|
||||||
|
};
|
||||||
|
|
|
@ -14,11 +14,12 @@
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
#pragma comment(lib, "Qt5Svgd.lib")
|
#pragma comment(lib, "Qt5Svgd.lib")
|
||||||
#else
|
#else
|
||||||
#pragma comment(lib, "QtSvg.lib")
|
#pragma comment(lib, "Qt5Svg.lib")
|
||||||
#endif
|
#endif
|
||||||
NavBar::NavBar(ConfigResponse *configResponse,QWidget *parent) :
|
NavBar::NavBar(ConfigResponse *configResponse, MainScreen *mainScreen,QWidget *parent) :
|
||||||
QWidget(parent), ui(new Ui::NavBar) {
|
QWidget(parent), ui(new Ui::NavBar) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
this->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
buffer = new QByteArray;
|
buffer = new QByteArray;
|
||||||
if (configResponse->succeed&&configResponse->menus.empty()!=true) {
|
if (configResponse->succeed&&configResponse->menus.empty()!=true) {
|
||||||
getLogoFromInternet(configResponse);
|
getLogoFromInternet(configResponse);
|
||||||
|
@ -37,6 +38,10 @@ NavBar::NavBar(ConfigResponse *configResponse,QWidget *parent) :
|
||||||
x += height();
|
x += height();
|
||||||
buttons << myButton;
|
buttons << myButton;
|
||||||
}
|
}
|
||||||
|
if (!buttonStructs.empty()) {
|
||||||
|
connect(this, &NavBar::firstUrl, mainScreen, &MainScreen::firstUrl);
|
||||||
|
emit firstUrl(buttonStructs[0].url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NavBar::~NavBar() {
|
NavBar::~NavBar() {
|
||||||
|
@ -76,7 +81,7 @@ void NavBar::resizeEvent(QResizeEvent *event) {
|
||||||
}
|
}
|
||||||
void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
|
void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
|
||||||
qColor.setNamedColor(configResponse->basic.backgroud_color);
|
qColor.setNamedColor(configResponse->basic.backgroud_color);
|
||||||
QUrl url_logo(QString(BASE_URL) + configResponse->basic.logo_url);
|
QUrl url_logo(configResponse->basic.logo_url);
|
||||||
QNetworkRequest *request_logo = new QNetworkRequest(url_logo);
|
QNetworkRequest *request_logo = new QNetworkRequest(url_logo);
|
||||||
manager = new QNetworkAccessManager;
|
manager = new QNetworkAccessManager;
|
||||||
reply = manager->get(*request_logo);
|
reply = manager->get(*request_logo);
|
||||||
|
@ -84,24 +89,27 @@ void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
|
||||||
timer.setInterval(5000);
|
timer.setInterval(5000);
|
||||||
connect(reply, &QNetworkReply::finished, &eventLoop,&QEventLoop::quit);
|
connect(reply, &QNetworkReply::finished, &eventLoop,&QEventLoop::quit);
|
||||||
connect(&timer, &QTimer::timeout,this, &NavBar::cancelDownload);
|
connect(&timer, &QTimer::timeout,this, &NavBar::cancelDownload);
|
||||||
|
eventLoop.exec();
|
||||||
timer.stop();
|
timer.stop();
|
||||||
buffer = new QByteArray;
|
buffer = new QByteArray;
|
||||||
delete request_logo;
|
delete request_logo;
|
||||||
if (downloadSuccess == true) {
|
if (downloadSuccess == true) {
|
||||||
*buffer = reply->readAll();
|
*buffer = reply->readAll();
|
||||||
QSvgRenderer *render_logo = new QSvgRenderer(*buffer);
|
QSvgRenderer *render_logo = new QSvgRenderer(*buffer);
|
||||||
logo = new QImage(200, 200, QImage::Format_ARGB32);
|
logo = new QImage(400, 200, QImage::Format_ARGB32);
|
||||||
QPainter painter_logo(logo);
|
QPainter painter_logo(logo);
|
||||||
render_logo->render(&painter_logo);
|
render_logo->render(&painter_logo);
|
||||||
buffer->clear();
|
buffer->clear();
|
||||||
for (auto button : configResponse->menus) {
|
for (auto button : configResponse->menus) {
|
||||||
QUrl url_image(QString(BASE_URL) + button.img);
|
QUrl url_image(button.img);
|
||||||
QNetworkRequest *request_image = new QNetworkRequest(url_image);
|
QNetworkRequest *request_image = new QNetworkRequest(url_image);
|
||||||
reply = manager->get(*request_image);
|
reply = manager->get(*request_image);
|
||||||
QTimer timer;
|
QTimer timer;
|
||||||
timer.setInterval(5000);
|
timer.setInterval(5000);
|
||||||
connect(reply, &QNetworkReply::finished, &eventLoop, &QEventLoop::quit);
|
connect(reply, &QNetworkReply::finished, &eventLoop, &QEventLoop::quit);
|
||||||
connect(&timer, &QTimer::timeout, this, &NavBar::cancelDownload);
|
connect(&timer, &QTimer::timeout, this, &NavBar::cancelDownload);
|
||||||
|
eventLoop.exec();
|
||||||
|
timer.stop();
|
||||||
if (!downloadSuccess) {
|
if (!downloadSuccess) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +119,7 @@ void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
|
||||||
QPainter painter_image(image);
|
QPainter painter_image(image);
|
||||||
render_image->render(&painter_image);
|
render_image->render(&painter_image);
|
||||||
|
|
||||||
QUrl url_image_cover(QString(BASE_URL) + button.img_cover);
|
QUrl url_image_cover(button.img_cover);
|
||||||
QNetworkRequest *request_image_cover = new QNetworkRequest(url_image_cover);
|
QNetworkRequest *request_image_cover = new QNetworkRequest(url_image_cover);
|
||||||
reply = manager->get(*request_image_cover);
|
reply = manager->get(*request_image_cover);
|
||||||
timer.setInterval(5000);
|
timer.setInterval(5000);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include "buttonstruct.h"
|
#include "buttonstruct.h"
|
||||||
#include <QtNetwork/QtNetwork>
|
#include <QtNetwork/QtNetwork>
|
||||||
|
#include "mainscreen.h"
|
||||||
#include "mainwindowlayout.h"
|
#include "mainwindowlayout.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,9 +25,10 @@ QT_END_NAMESPACE
|
||||||
|
|
||||||
class NavBar : public QWidget {
|
class NavBar : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
signals:
|
||||||
|
void firstUrl(QString url);
|
||||||
public:
|
public:
|
||||||
NavBar(ConfigResponse *configResponse,QWidget *parent = nullptr);
|
NavBar(ConfigResponse *configResponse,MainScreen *mainScreen,QWidget *parent = nullptr);
|
||||||
|
|
||||||
~NavBar() override;
|
~NavBar() override;
|
||||||
protected:
|
protected:
|
||||||
|
@ -38,6 +40,8 @@ protected:
|
||||||
private:
|
private:
|
||||||
Ui::NavBar *ui;
|
Ui::NavBar *ui;
|
||||||
QColor qColor;
|
QColor qColor;
|
||||||
|
QColor text_color;
|
||||||
|
QColor text_cover_color;
|
||||||
QList<MyButton *> buttons;
|
QList<MyButton *> buttons;
|
||||||
QList<ButtonStruct> buttonStructs;
|
QList<ButtonStruct> buttonStructs;
|
||||||
QByteArray *buffer;
|
QByteArray *buffer;
|
||||||
|
@ -50,6 +54,7 @@ private:
|
||||||
bool downloadSuccess=true;
|
bool downloadSuccess=true;
|
||||||
void getLogoFromInternet(ConfigResponse *configResponse);
|
void getLogoFromInternet(ConfigResponse *configResponse);
|
||||||
void getLogoFromLocal();
|
void getLogoFromLocal();
|
||||||
|
MainScreen *mainScreen;
|
||||||
private slots:
|
private slots:
|
||||||
void storeToBuffer();
|
void storeToBuffer();
|
||||||
void cancelDownload();
|
void cancelDownload();
|
||||||
|
|
|
@ -30,17 +30,7 @@
|
||||||
#endif
|
#endif
|
||||||
#pragma comment(lib,"comsuppw.lib")
|
#pragma comment(lib,"comsuppw.lib")
|
||||||
//读取注册表获取MachineUUID
|
//读取注册表获取MachineUUID
|
||||||
inline QString getMachineGUID(){
|
|
||||||
HKEY hKey;
|
|
||||||
RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography",
|
|
||||||
0,KEY_READ | KEY_WOW64_64KEY, &hKey);
|
|
||||||
DWORD dwType1 = REG_SZ;
|
|
||||||
DWORD dwLen = MAX_PATH;
|
|
||||||
WCHAR buf[100];
|
|
||||||
RegQueryValueExA(hKey, "MachineGuid" ,0 ,&dwType1, (LPBYTE)buf, &dwLen);
|
|
||||||
QString guid=QString::fromWCharArray(buf);
|
|
||||||
return guid;
|
|
||||||
}
|
|
||||||
|
|
||||||
RequestBodyBase::RequestBodyBase(){
|
RequestBodyBase::RequestBodyBase(){
|
||||||
wchar_t unix_time[65]={0};
|
wchar_t unix_time[65]={0};
|
||||||
|
@ -182,7 +172,6 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
|
||||||
timer->stop();
|
timer->stop();
|
||||||
//delete httpMgr;
|
//delete httpMgr;
|
||||||
QJsonDocument result;
|
QJsonDocument result;
|
||||||
configResponse=new ConfigResponse;
|
|
||||||
configResponse->succeed = false;
|
configResponse->succeed = false;
|
||||||
//memset(configResponse,0,sizeof(*configResponse));
|
//memset(configResponse,0,sizeof(*configResponse));
|
||||||
auto error = reply->error();
|
auto error = reply->error();
|
||||||
|
@ -203,8 +192,16 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
|
||||||
if(result.isObject()){
|
if(result.isObject()){
|
||||||
QJsonObject obj_root=result.object();
|
QJsonObject obj_root=result.object();
|
||||||
QJsonArray array;
|
QJsonArray array;
|
||||||
array = obj_root.value("menu").toArray();
|
|
||||||
|
array = obj_root.value("data").toObject().value("menu").toArray();
|
||||||
|
QJsonObject obj_basic = obj_root.value("basic").toObject();
|
||||||
|
configResponse->basic.logo_url = obj_basic.value("logo_url").toString();
|
||||||
|
configResponse->basic.device_id = obj_basic.value("device_id").toString();
|
||||||
|
configResponse->basic.dev_id = obj_basic.value("dev_id").toString();
|
||||||
|
configResponse->basic.token = obj_basic.value("token").toString();
|
||||||
|
configResponse->basic.backgroud_color = obj_basic.value("backgroud_color").toString();
|
||||||
|
configResponse->basic.title_color = obj_basic.value("title_color").toString();
|
||||||
|
configResponse->basic.title_cover_color = obj_basic.value("title_cover_color").toString();
|
||||||
auto i=0;
|
auto i=0;
|
||||||
for(auto value:array){
|
for(auto value:array){
|
||||||
QJsonObject object=value.toObject();
|
QJsonObject object=value.toObject();
|
||||||
|
@ -217,6 +214,7 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
|
||||||
configResponse->menus << menu;
|
configResponse->menus << menu;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
configResponse->succeed = true;
|
||||||
}else{
|
}else{
|
||||||
//数据不完整
|
//数据不完整
|
||||||
configResponse->succeed=false;
|
configResponse->succeed=false;
|
||||||
|
|
|
@ -98,6 +98,16 @@ class OpenMulitiWechat:public RequestBodyBase{
|
||||||
public:
|
public:
|
||||||
OpenMulitiWechat(): RequestBodyBase(){}
|
OpenMulitiWechat(): RequestBodyBase(){}
|
||||||
};
|
};
|
||||||
|
inline QString getMachineGUID() {
|
||||||
|
HKEY hKey;
|
||||||
|
RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography",
|
||||||
|
0, KEY_READ | KEY_WOW64_64KEY, &hKey);
|
||||||
|
DWORD dwType1 = REG_SZ;
|
||||||
|
DWORD dwLen = MAX_PATH;
|
||||||
|
WCHAR buf[100];
|
||||||
|
RegQueryValueExA(hKey, "MachineGuid", 0, &dwType1, (LPBYTE)buf, &dwLen);
|
||||||
|
QString guid = QString::fromWCharArray(buf);
|
||||||
|
return guid;
|
||||||
|
}
|
||||||
|
|
||||||
#endif //OFFICEASSISTANT_NETIO_H
|
#endif //OFFICEASSISTANT_NETIO_H
|
||||||
|
|
|
@ -1,27 +1,43 @@
|
||||||
#include "qminiblink.h"
|
#include "qminiblink.h"
|
||||||
|
#include <QThread>
|
||||||
|
#include <QDebug>
|
||||||
#pragma comment (lib,"Comctl32.lib")
|
#pragma comment (lib,"Comctl32.lib")
|
||||||
|
|
||||||
QMiniBlink::QMiniBlink(QWidget *broswer,QWidget *parent)
|
QMiniBlink::QMiniBlink(QWidget *parent)
|
||||||
: QWidget(parent){
|
: QWidget(parent){
|
||||||
this->broswer = broswer;
|
|
||||||
|
this->parent = parent;
|
||||||
|
wkeView = nullptr;
|
||||||
//QSizePolicy sizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::QSizePolicy::Expanding);
|
//QSizePolicy sizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::QSizePolicy::Expanding);
|
||||||
//setSizePolicy(sizePolicy);
|
//setSizePolicy(sizePolicy);
|
||||||
}
|
}
|
||||||
void QMiniBlink::init() {
|
void QMiniBlink::init() {
|
||||||
ui.setupUi(this);
|
ui.setupUi(this);
|
||||||
wkeInit();
|
wkeInit();
|
||||||
wkeView = wkeCreateWebWindow(WKE_WINDOW_TYPE_CONTROL, (HWND)this->winId(), 0, 0, this->width(), this->height());
|
RECT rect;
|
||||||
wkeSetNavigationToNewWindowEnable(wkeView, false);
|
GetWindowRect((HWND)this->winId(), &rect);
|
||||||
wkeShowWindow(wkeView, TRUE);
|
resize(rect.right - rect.left, rect.bottom - rect.top);
|
||||||
SetParent(wkeGetWindowHandle(wkeView), (HWND)this->winId());
|
this->wkeView = wkeCreateWebWindow(WKE_WINDOW_TYPE_CONTROL, (HWND)this->winId(), 0, 0, rect.right - rect.left, rect.bottom - rect.top);
|
||||||
SetWindowSubclass((HWND)this->winId(), subClassProc, 0, (DWORD_PTR)this);
|
|
||||||
wkeRunMessageLoop();
|
|
||||||
}
|
|
||||||
QMiniBlink::~QMiniBlink(){}
|
|
||||||
void QMiniBlink::destroy() {
|
|
||||||
wkeDestroyWebView(wkeView);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
wkeSetNavigationToNewWindowEnable(this->wkeView, false);
|
||||||
|
wkeShowWindow(this->wkeView, TRUE);
|
||||||
|
SetParent(wkeGetWindowHandle(this->wkeView), (HWND)this->winId());
|
||||||
|
wkeMoveWindow(this->wkeView, 0, 0, rect.right - rect.left, rect.bottom - rect.top);
|
||||||
|
//while(this->firstUrl.isEmpty()){}
|
||||||
|
//wkeLoadURL(this->wkeView, this->firstUrl.toStdString().c_str());
|
||||||
|
SetWindowSubclass((HWND)this->winId(), subClassProc, 0, (DWORD_PTR)this);
|
||||||
|
//wkeRunMessageLoop();
|
||||||
|
}
|
||||||
|
QMiniBlink::~QMiniBlink(){
|
||||||
|
qDebug() << "Destroyed";
|
||||||
|
}
|
||||||
|
void QMiniBlink::ondestroy() {
|
||||||
|
if (this->wkeView != nullptr) {
|
||||||
|
wkeDestroyWebView(wkeView);
|
||||||
|
qDebug() << "Destroyed";
|
||||||
|
}
|
||||||
|
wkeShutdown();
|
||||||
|
}
|
||||||
void QMiniBlink::switchUrl(QString url) {
|
void QMiniBlink::switchUrl(QString url) {
|
||||||
wkeLoadURL(wkeView, url.toStdString().c_str());
|
wkeLoadURL(wkeView, url.toStdString().c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,16 +11,20 @@ class QMiniBlink : public QWidget
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QMiniBlink(QWidget *broswer,QWidget *parent = Q_NULLPTR);
|
QMiniBlink(QWidget *parent = nullptr);
|
||||||
~QMiniBlink();
|
~QMiniBlink();
|
||||||
void init();
|
void init();
|
||||||
void destroy();
|
|
||||||
void autojustWebViewSize();
|
void autojustWebViewSize();
|
||||||
|
QString firstUrl;
|
||||||
public slots:
|
public slots:
|
||||||
|
void ondestroy();
|
||||||
void switchUrl(QString url);
|
void switchUrl(QString url);
|
||||||
private:
|
private:
|
||||||
Ui::QMiniBlink ui;
|
Ui::QMiniBlink ui;
|
||||||
wkeWebView wkeView;
|
wkeWebView wkeView;
|
||||||
QWidget *broswer;
|
QWidget *parent;
|
||||||
|
int w;
|
||||||
|
int h;
|
||||||
static LRESULT CALLBACK subClassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
|
static LRESULT CALLBACK subClassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,23 +1,20 @@
|
||||||
<UI version="4.0" >
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
<class>QMiniBlink</class>
|
<class>QMiniBlink</class>
|
||||||
<widget class="QWidget" name="QMiniBlink" >
|
<widget class="QWidget" name="QMiniBlink">
|
||||||
<property name="objectName" >
|
<property name="geometry">
|
||||||
<string notr="true">QMiniBlink</string>
|
|
||||||
</property>
|
|
||||||
<property name="geometry" >
|
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>1142</width>
|
||||||
<height>300</height>
|
<height>806</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle">
|
||||||
<string>QMiniBlink</string>
|
<string>QMiniBlink</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutDefault spacing="6" margin="11" />
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<pixmapfunction></pixmapfunction>
|
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</UI>
|
</ui>
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<UI version="4.0" >
|
||||||
|
<class>QtWidgetsClass</class>
|
||||||
|
<widget class="QWidget" name="QtWidgetsClass" >
|
||||||
|
<property name="objectName" >
|
||||||
|
<string notr="true">QtWidgetsClass</string>
|
||||||
|
</property>
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle" >
|
||||||
|
<string>QtWidgetsClass</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<layoutDefault spacing="6" margin="11" />
|
||||||
|
<pixmapfunction></pixmapfunction>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</UI>
|
|
@ -0,0 +1,56 @@
|
||||||
|
#include "settingsscreen.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
#include "netio.h"
|
||||||
|
SettingsScreen::SettingsScreen(QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
{
|
||||||
|
ui.setupUi(this);
|
||||||
|
autoStart = new SwitchButton(ADD_AUTOSTART,this);
|
||||||
|
addDesktopLink = new QPushButton(this);
|
||||||
|
addDesktopLink->setText(QString::fromLocal8Bit("创建桌面快捷方式"));
|
||||||
|
connect(addDesktopLink, &QPushButton::pressed, this, &SettingsScreen::createShortCut);
|
||||||
|
layout = new QHBoxLayout(this);
|
||||||
|
left = new QVBoxLayout(this);
|
||||||
|
addDesktopLink_label = new QLabel(QString::fromLocal8Bit("添加桌面快捷方式"),this);
|
||||||
|
autoStart_label = new QLabel(QString::fromLocal8Bit("开机启动"),this);
|
||||||
|
autoStart->setMaximumSize(100, 50);
|
||||||
|
autoStart->setMinimumSize(50, 25);
|
||||||
|
left->addWidget(autoStart_label);
|
||||||
|
left->addWidget(autoStart);
|
||||||
|
left->addWidget(addDesktopLink_label);
|
||||||
|
left->addWidget(addDesktopLink);
|
||||||
|
left->setAlignment(Qt::AlignCenter);
|
||||||
|
left->setMargin(0);
|
||||||
|
layout->addLayout(left);
|
||||||
|
information = new QLabel;
|
||||||
|
QString device_id = QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5).toHex();
|
||||||
|
QString inf_str = QString::fromLocal8Bit("硬件ID:\n");
|
||||||
|
inf_str += device_id;
|
||||||
|
information->setText(inf_str);
|
||||||
|
layout->addWidget(information);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsScreen::createShortCut() {
|
||||||
|
QString deskTopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
|
||||||
|
deskTopPath = deskTopPath + QString::fromLocal8Bit("/办公助手.lnk");
|
||||||
|
QString srcFile = QApplication::applicationFilePath();
|
||||||
|
QFile::link(srcFile, deskTopPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsScreen::~SettingsScreen()
|
||||||
|
{
|
||||||
|
left->removeWidget(autoStart);
|
||||||
|
left->removeWidget(addDesktopLink);
|
||||||
|
left->removeWidget(addDesktopLink_label);
|
||||||
|
left->removeWidget(autoStart_label);
|
||||||
|
delete autoStart;
|
||||||
|
delete addDesktopLink;
|
||||||
|
delete addDesktopLink_label;
|
||||||
|
delete autoStart_label;
|
||||||
|
layout->removeItem(left);
|
||||||
|
delete left;
|
||||||
|
layout->removeWidget(information);
|
||||||
|
delete information;
|
||||||
|
delete layout;
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QVboxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QLabel>
|
||||||
|
#include "ui_settingsscreen.h"
|
||||||
|
#include "switchbutton.h"
|
||||||
|
|
||||||
|
|
||||||
|
class SettingsScreen : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SettingsScreen(QWidget *parent = Q_NULLPTR);
|
||||||
|
~SettingsScreen();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::SettingsScreen ui;
|
||||||
|
QLabel *autoStart_label;
|
||||||
|
QLabel *addDesktopLink_label;
|
||||||
|
QPushButton *addDesktopLink;
|
||||||
|
SwitchButton *autoStart;
|
||||||
|
QHBoxLayout *layout;
|
||||||
|
QVBoxLayout *left;
|
||||||
|
QLabel *information;
|
||||||
|
private slots:
|
||||||
|
void createShortCut();
|
||||||
|
};
|
|
@ -0,0 +1,23 @@
|
||||||
|
<UI version="4.0" >
|
||||||
|
<class>SettingsScreen</class>
|
||||||
|
<widget class="QWidget" name="SettingsScreen" >
|
||||||
|
<property name="objectName" >
|
||||||
|
<string notr="true">SettingsScreen</string>
|
||||||
|
</property>
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle" >
|
||||||
|
<string>SettingsScreen</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<layoutDefault spacing="6" margin="11" />
|
||||||
|
<pixmapfunction></pixmapfunction>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</UI>
|
|
@ -0,0 +1,188 @@
|
||||||
|
#include "switchbutton.h"
|
||||||
|
#include "config.h"
|
||||||
|
#include <Windows.h>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QFile>
|
||||||
|
SwitchButton::SwitchButton(int action,QWidget *parent=nullptr)
|
||||||
|
: QWidget(parent)
|
||||||
|
{
|
||||||
|
ui.setupUi(this);
|
||||||
|
checked = false;
|
||||||
|
this->action = action;
|
||||||
|
//开、闭时背景颜色
|
||||||
|
bgColorOff = QColor(225, 225, 225);
|
||||||
|
bgColorOn = QColor(250, 250, 250);
|
||||||
|
|
||||||
|
//开、闭时滑块颜色
|
||||||
|
sliderColorOff = QColor(100, 100, 100);
|
||||||
|
sliderColorOn = QColor(100, 184, 255);
|
||||||
|
|
||||||
|
space = 2; //背景间隔
|
||||||
|
rectRadius = 5;
|
||||||
|
|
||||||
|
step = width() / 50; //步长
|
||||||
|
|
||||||
|
//起始、目标位置
|
||||||
|
startX = 0;
|
||||||
|
endX = 0;
|
||||||
|
|
||||||
|
timer = new QTimer(this);
|
||||||
|
timer->setInterval(10);
|
||||||
|
connect(timer, &QTimer::timeout, this, &SwitchButton::updateValue);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwitchButton::updateValue()
|
||||||
|
{
|
||||||
|
if (checked) {
|
||||||
|
if (startX < endX) {
|
||||||
|
startX = startX + step;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
startX = endX;
|
||||||
|
timer->stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (startX > endX) {
|
||||||
|
startX = startX - step;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
startX = endX;
|
||||||
|
timer->stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
void SwitchButton::mousePressEvent(QMouseEvent *event)
|
||||||
|
{
|
||||||
|
QWidget::mousePressEvent(event);
|
||||||
|
checked = !checked;
|
||||||
|
if (action == ADD_AUTOSTART) {
|
||||||
|
if (checked == true) {
|
||||||
|
HKEY hRoot = HKEY_CURRENT_USER;
|
||||||
|
wchar_t *szSubKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
||||||
|
HKEY hKey;
|
||||||
|
DWORD dwDisposition = REG_OPENED_EXISTING_KEY; // 如果不存在不创建
|
||||||
|
LONG lRet = RegCreateKeyEx(hRoot, szSubKey, 0, NULL,
|
||||||
|
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
|
||||||
|
if (lRet != ERROR_SUCCESS) {
|
||||||
|
QMessageBox::critical(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建开机启动项失败"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QString app = QApplication::applicationFilePath();
|
||||||
|
lRet = RegSetValueEx(hKey, L"SelfRun", 0, REG_SZ, (BYTE*)app.toStdWString().c_str(), app.length());
|
||||||
|
if (lRet == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建开机启动项成功"));
|
||||||
|
}
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
HKEY hRoot = HKEY_CURRENT_USER;
|
||||||
|
wchar_t *szSubKey = L"Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
||||||
|
HKEY hKey;
|
||||||
|
DWORD dwDisposition = REG_OPENED_EXISTING_KEY; // 如果不存在不创建
|
||||||
|
LONG lRet = RegCreateKeyEx(hRoot, szSubKey, 0, NULL,
|
||||||
|
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition);
|
||||||
|
if (lRet != ERROR_SUCCESS) {
|
||||||
|
QMessageBox::critical(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("移除开机启动项失败"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
QString app = QApplication::applicationFilePath();
|
||||||
|
lRet = RegDeleteValue(hKey, L"SelfRun");
|
||||||
|
if (lRet == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("移除开机启动项成功"));
|
||||||
|
}
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//每次移动的步长为宽度的 50分之一
|
||||||
|
step = width() / 50;
|
||||||
|
|
||||||
|
//状态切换改变后自动计算终点坐标
|
||||||
|
if (checked)
|
||||||
|
{
|
||||||
|
endX = width() - width() / 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
endX = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
timer->start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwitchButton::resizeEvent(QResizeEvent *event)
|
||||||
|
{
|
||||||
|
QWidget::resizeEvent(event);
|
||||||
|
//每次移动的步长为宽度的 50分之一
|
||||||
|
step = width() / 50;
|
||||||
|
|
||||||
|
//尺寸大小改变后自动设置起点坐标为终点
|
||||||
|
if (checked)
|
||||||
|
{
|
||||||
|
startX = width() - width() / 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
startX = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
void SwitchButton::paintEvent(QPaintEvent *event)
|
||||||
|
{
|
||||||
|
QWidget::paintEvent(event);
|
||||||
|
//绘制准备工作,启用反锯齿
|
||||||
|
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
//绘制背景
|
||||||
|
drawBg(&painter);
|
||||||
|
//绘制滑块
|
||||||
|
drawSlider(&painter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwitchButton::drawBg(QPainter *painter)
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
painter->setPen(Qt::NoPen);
|
||||||
|
if (!checked)
|
||||||
|
{
|
||||||
|
painter->setBrush(bgColorOff);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
painter->setBrush(bgColorOn);
|
||||||
|
}
|
||||||
|
painter->drawRoundedRect(rect(), rectRadius, rectRadius);
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
void SwitchButton::drawSlider(QPainter *painter)
|
||||||
|
{
|
||||||
|
painter->save();
|
||||||
|
|
||||||
|
painter->setPen(Qt::NoPen);
|
||||||
|
if (!checked) {
|
||||||
|
painter->setBrush(sliderColorOff);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
painter->setBrush(sliderColorOn);
|
||||||
|
}
|
||||||
|
int sliderWidth = width() / 2 - space * 2;
|
||||||
|
int sliderHeight = height() - space * 2;
|
||||||
|
QRect sliderRect(startX + space, space, sliderWidth, sliderHeight);
|
||||||
|
painter->drawRoundedRect(sliderRect, rectRadius, rectRadius);
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
SwitchButton::~SwitchButton()
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QTimer>
|
||||||
|
#include "ui_switchbutton.h"
|
||||||
|
|
||||||
|
class SwitchButton : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
SwitchButton(int action, QWidget * parent);
|
||||||
|
~SwitchButton();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int action;
|
||||||
|
Ui::SwitchButton ui;
|
||||||
|
bool checked;
|
||||||
|
QColor bgColorOff;
|
||||||
|
QColor bgColorOn;
|
||||||
|
QColor sliderColorOff;
|
||||||
|
QColor sliderColorOn;
|
||||||
|
int space;
|
||||||
|
int rectRadius;
|
||||||
|
int step;
|
||||||
|
int startX;
|
||||||
|
int endX;
|
||||||
|
QTimer *timer;
|
||||||
|
|
||||||
|
void updateValue();
|
||||||
|
void drawBg(QPainter * painter);
|
||||||
|
void drawSlider(QPainter * painter);
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *);
|
||||||
|
void resizeEvent(QResizeEvent *);
|
||||||
|
void mousePressEvent(QMouseEvent *);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
};
|
|
@ -0,0 +1,23 @@
|
||||||
|
<UI version="4.0" >
|
||||||
|
<class>SwitchButton</class>
|
||||||
|
<widget class="QWidget" name="SwitchButton" >
|
||||||
|
<property name="objectName" >
|
||||||
|
<string notr="true">SwitchButton</string>
|
||||||
|
</property>
|
||||||
|
<property name="geometry" >
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle" >
|
||||||
|
<string>SwitchButton</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<layoutDefault spacing="6" margin="11" />
|
||||||
|
<pixmapfunction></pixmapfunction>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</UI>
|
Before Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 2.4 KiB |
BIN
images/close.png
Before Width: | Height: | Size: 2.7 KiB |
BIN
images/home.png
Before Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 1.7 KiB |
BIN
images/money.png
Before Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 3.8 KiB |
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="1">
|
||||||
|
<builddir>officeassistant-cppcheck-build-dir</builddir>
|
||||||
|
<importproject>OfficeAssistant_msvc.sln</importproject>
|
||||||
|
<analyze-all-vs-configs>true</analyze-all-vs-configs>
|
||||||
|
<check-headers>true</check-headers>
|
||||||
|
<check-unused-templates>true</check-unused-templates>
|
||||||
|
<max-ctu-depth>2</max-ctu-depth>
|
||||||
|
<max-template-recursion>100</max-template-recursion>
|
||||||
|
<vs-configurations>
|
||||||
|
<config>Debug</config>
|
||||||
|
<config>Release</config>
|
||||||
|
</vs-configurations>
|
||||||
|
</project>
|
|
@ -34,7 +34,7 @@
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v140</PlatformToolset>
|
<PlatformToolset>v140_xp</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
<ConfigurationType>Application</ConfigurationType>
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
<UseDebugLibraries>false</UseDebugLibraries>
|
||||||
<PlatformToolset>v140</PlatformToolset>
|
<PlatformToolset>v140_xp</PlatformToolset>
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
<CharacterSet>Unicode</CharacterSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|