diff --git a/.gitignore b/.gitignore
index 90b4410..315d613 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,4 +14,5 @@ OfficeAssistant_msvc.sdf
startcalc/Debug/
startcalc/Release/
wxdk/Debug/
-wxdk/Release/
\ No newline at end of file
+wxdk/Release/
+officeassistant-cppcheck-build-dir/
\ No newline at end of file
diff --git a/OfficeAssistant_msvc.VC.db b/OfficeAssistant_msvc.VC.db
index 466f82c..1105217 100644
Binary files a/OfficeAssistant_msvc.VC.db and b/OfficeAssistant_msvc.VC.db differ
diff --git a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj
index 0474516..16734b1 100644
--- a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj
+++ b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj
@@ -23,7 +23,7 @@
Application
- v140
+ v140_xp
@@ -101,6 +101,9 @@
+
+
+
@@ -115,9 +118,12 @@
+
+
+
@@ -125,6 +131,9 @@
+
+
+
diff --git a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters
index 61eef75..3216add 100644
--- a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters
+++ b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters
@@ -17,7 +17,7 @@
{99349809-55BA-4b9d-BF79-8FDBB0286EB3}
ui
-
+
{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}
ts
@@ -63,6 +63,15 @@
Header Files
+
+ Header Files
+
+
+ Header Files
+
+
+ Header Files
+
@@ -89,6 +98,15 @@
Source Files
+
+ Source Files
+
+
+ Source Files
+
+
+ Source Files
+
@@ -103,6 +121,15 @@
Form Files
+
+ Form Files
+
+
+ Form Files
+
+
+ Form Files
+
Form Files
diff --git a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user
index 93cae60..c1d4815 100644
--- a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user
+++ b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user
@@ -5,9 +5,9 @@
WindowsLocalDebugger
- 2023-07-30T09:15:49.0117730Z
+ 2023-07-30T18:20:21.4819233Z
- 2023-07-30T09:15:57.3451755Z
+ 2023-07-30T18:20:22.3001457Z
\ No newline at end of file
diff --git a/OfficeAssistant_msvc/config.h b/OfficeAssistant_msvc/config.h
index 73c9636..a20eac7 100644
--- a/OfficeAssistant_msvc/config.h
+++ b/OfficeAssistant_msvc/config.h
@@ -9,4 +9,7 @@
#define DEVICE_URL "http://softapi.s103.y01.cn/addons/Kmdsoft/Index/device"
#define BASE_URL "http://softapi.s103.y01.cn/"
#define DEFAULT_FILE "/config/default_navbar.kmd"
+
+#define ADD_AUTOSTART 1
+#define ADD_SHORTCUT 2
#endif //OFFICEASSISTANT_CONFIG_H
diff --git a/OfficeAssistant_msvc/mainscreen.cpp b/OfficeAssistant_msvc/mainscreen.cpp
index 1ee0f69..288ca0d 100644
--- a/OfficeAssistant_msvc/mainscreen.cpp
+++ b/OfficeAssistant_msvc/mainscreen.cpp
@@ -10,65 +10,93 @@
#include
#include
#include
+#include "globalvariables.h"
+#include "settingsscreen.h"
+#include "mythread.h"
+
MainScreen::MainScreen(QWidget *parent) :
QWidget(parent), ui(new Ui::MainScreen) {
ui->setupUi(this);
- broswer = new QWidget(this);
+ setContentsMargins(0, 0, 0, 0);
button = new QPushButton(this);
button->setHidden(true);
button->setStyleSheet("border-style:none;padding:10px;border-radius:5px;background-color:#FFFFFF");
//Plus Math icon by Icons8
QString dir = QApplication::applicationDirPath();
- icon = new QIcon(dir + "/images/add.png");
+ icon = new QIcon(dir + QString::fromLocal8Bit("/images/add.png"));
button->setIcon(*icon);
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);
- //QSizePolicy sizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::QSizePolicy::Expanding);
- //broswer->setSizePolicy(sizePolicy);
- miniblink = new QMiniBlink(broswer,this);
+ layout->setMargin(0);
+ //miniblink->setAttribute(Qt::WA_DeleteOnClose);
miniblink->show();
//miniblink->setSizePolicy(sizePolicy);
- thread = new QThread;
- miniblink->moveToThread(thread);
- connect(thread, &QThread::started, miniblink, &QMiniBlink::init);
- connect(thread, &QThread::finished, thread, &QThread::deleteLater);
- connect(this, &MainScreen::destroy, miniblink, &QMiniBlink::destroy);
+ //thread = new MyThread(this,&miniblink);
+ //thread->start();
+ //miniblink->moveToThread(thread);
+ connect(this, &MainScreen::ondestroy, miniblink, &QMiniBlink::ondestroy);
+ 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);
- thread->start();
+ emit started();
}
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;
}
+void MainScreen::firstUrl(QString url)
+{
+ emit changeUrl(url);
+}
void MainScreen::clickButton1(QString text, QString url) {
if (text == QString::fromLocal8Bit("微信多开")) {
button->setHidden(false);
- connect(button, &QPushButton::click, this, &MainScreen::startWeChat);
- if (button->layout() == nullptr) {
- layout->insertWidget(1, button);
- }
- if (broswer->layout() == nullptr) {
- layout->addWidget(broswer, 4);
- }
+ miniblink->setHidden(false);
+ settingScreen->setHidden(true);
emit changeUrl(url);
+ }
+ else if (text == QString::fromLocal8Bit("软件设置")){
+ miniblink->setHidden(true);
+ button->setHidden(true);
+ settingScreen->setHidden(false);
+
}
else {
- if (button->layout() != nullptr) {
- layout->removeWidget(button);
- button->setHidden(true);
- }
+ button->setHidden(true);
+ miniblink->setHidden(false);
+ settingScreen->setHidden(true);
emit changeUrl(url);
}
}
void MainScreen::startWeChat() {
QString path = QApplication::applicationDirPath();
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) {
// QWidget::resizeEvent(event);
diff --git a/OfficeAssistant_msvc/mainscreen.h b/OfficeAssistant_msvc/mainscreen.h
index 52882a1..317b7be 100644
--- a/OfficeAssistant_msvc/mainscreen.h
+++ b/OfficeAssistant_msvc/mainscreen.h
@@ -11,7 +11,8 @@
#include
#include "wke.h"
#include "qminiblink.h"
-
+#include "settingsscreen.h"
+class MyThread;
QT_BEGIN_NAMESPACE
namespace Ui { class MainScreen; }
QT_END_NAMESPACE
@@ -19,13 +20,16 @@ QT_END_NAMESPACE
class MainScreen : public QWidget {
Q_OBJECT
signals:
- void destroy();
+ void started();
+ void ondestroy();
void changeUrl(QString url);
+ void initMiniBlink();
public:
explicit MainScreen(QWidget *parent = nullptr);
~MainScreen() override;
public slots:
void clickButton1(QString text, QString url);
+ void firstUrl(QString url);
protected:
//void resizeEvent(QResizeEvent *event) override;
private:
@@ -36,11 +40,12 @@ private:
QIcon *icon;
QWidget *broswer;
static bool isInited();
- QThread *thread;
+ MyThread *thread;
QMiniBlink *miniblink;
+ SettingsScreen *settingScreen;
+
private slots:
void startWeChat();
-
};
diff --git a/OfficeAssistant_msvc/mainwindow.cpp b/OfficeAssistant_msvc/mainwindow.cpp
index 39df1eb..9211661 100644
--- a/OfficeAssistant_msvc/mainwindow.cpp
+++ b/OfficeAssistant_msvc/mainwindow.cpp
@@ -17,18 +17,13 @@ MainWindow::MainWindow(QWidget *parent) :
//delete desktopWidget;
mainWindowLayout=new MainWindowLayout(this);
setCentralWidget(mainWindowLayout);
- if(deskRect.width()*scale>1920){
- resize(1600,1080);
- //this->setMaximumWidth(1600);
- }else{
- resize(800, 540);
- //this->setMaximumWidth(800);
- }
+ setWindowState(Qt::WindowMaximized);
}
MainWindow::~MainWindow() {
+ this->setCentralWidget(nullptr);
delete mainWindowLayout;
delete ui;
}
diff --git a/OfficeAssistant_msvc/mainwindowlayout.cpp b/OfficeAssistant_msvc/mainwindowlayout.cpp
index 3d89ab2..210ae5c 100644
--- a/OfficeAssistant_msvc/mainwindowlayout.cpp
+++ b/OfficeAssistant_msvc/mainwindowlayout.cpp
@@ -13,23 +13,29 @@ MainWindowLayout::MainWindowLayout(QWidget *parent) :
layout=new QVBoxLayout(this);
mainWindowLayout = this;
ConfigRequest *configRequest = new ConfigRequest;
- ConfigResponse *configResponse = new ConfigResponse;
+ configResponse = new ConfigResponse;
configRequest->sendRequest(configResponse);
- navBar=new NavBar(configResponse,this);
- mainScreen=new MainScreen();
-
+ mainScreen = new MainScreen(this);
+ 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->addWidget(navBar,1);
layout->addWidget(mainScreen,7);
setLayout(layout);
- connect(this, &MainWindowLayout::clickButton1, mainScreen, &MainScreen::clickButton1);
+ connect(this,&MainWindowLayout::clickButton1,mainScreen,&MainScreen::clickButton1);
}
MainWindowLayout::~MainWindowLayout() {
-
+ delete configResponse;
+ layout->removeWidget(mainScreen);
+ layout->removeWidget(navBar);
+ delete mainScreen;
//delete[] list[0];
delete navBar;
- //delete layout;
+ delete layout;
delete ui;
}
diff --git a/OfficeAssistant_msvc/mainwindowlayout.h b/OfficeAssistant_msvc/mainwindowlayout.h
index e442a36..dc62507 100644
--- a/OfficeAssistant_msvc/mainwindowlayout.h
+++ b/OfficeAssistant_msvc/mainwindowlayout.h
@@ -37,6 +37,7 @@ private:
NavBar *navBar;
ButtonStruct *buttons;
MainScreen *mainScreen;
+ ConfigResponse *configResponse;
};
diff --git a/OfficeAssistant_msvc/mythread.cpp b/OfficeAssistant_msvc/mythread.cpp
new file mode 100644
index 0000000..5da9eb4
--- /dev/null
+++ b/OfficeAssistant_msvc/mythread.cpp
@@ -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;
+}
diff --git a/OfficeAssistant_msvc/mythread.h b/OfficeAssistant_msvc/mythread.h
new file mode 100644
index 0000000..0f248ff
--- /dev/null
+++ b/OfficeAssistant_msvc/mythread.h
@@ -0,0 +1,19 @@
+#pragma once
+class MainScreen;
+#include
+#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();
+};
+
diff --git a/OfficeAssistant_msvc/navbar.cpp b/OfficeAssistant_msvc/navbar.cpp
index e23eca8..3f96beb 100644
--- a/OfficeAssistant_msvc/navbar.cpp
+++ b/OfficeAssistant_msvc/navbar.cpp
@@ -14,11 +14,12 @@
#ifdef _DEBUG
#pragma comment(lib, "Qt5Svgd.lib")
#else
-#pragma comment(lib, "QtSvg.lib")
+#pragma comment(lib, "Qt5Svg.lib")
#endif
-NavBar::NavBar(ConfigResponse *configResponse,QWidget *parent) :
+NavBar::NavBar(ConfigResponse *configResponse, MainScreen *mainScreen,QWidget *parent) :
QWidget(parent), ui(new Ui::NavBar) {
ui->setupUi(this);
+ this->setAttribute(Qt::WA_DeleteOnClose);
buffer = new QByteArray;
if (configResponse->succeed&&configResponse->menus.empty()!=true) {
getLogoFromInternet(configResponse);
@@ -37,6 +38,10 @@ NavBar::NavBar(ConfigResponse *configResponse,QWidget *parent) :
x += height();
buttons << myButton;
}
+ if (!buttonStructs.empty()) {
+ connect(this, &NavBar::firstUrl, mainScreen, &MainScreen::firstUrl);
+ emit firstUrl(buttonStructs[0].url);
+ }
}
NavBar::~NavBar() {
@@ -76,7 +81,7 @@ void NavBar::resizeEvent(QResizeEvent *event) {
}
void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
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);
manager = new QNetworkAccessManager;
reply = manager->get(*request_logo);
@@ -84,24 +89,27 @@ void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
timer.setInterval(5000);
connect(reply, &QNetworkReply::finished, &eventLoop,&QEventLoop::quit);
connect(&timer, &QTimer::timeout,this, &NavBar::cancelDownload);
+ eventLoop.exec();
timer.stop();
buffer = new QByteArray;
delete request_logo;
if (downloadSuccess == true) {
*buffer = reply->readAll();
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);
render_logo->render(&painter_logo);
buffer->clear();
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);
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;
}
@@ -111,7 +119,7 @@ void NavBar::getLogoFromInternet(ConfigResponse *configResponse) {
QPainter painter_image(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);
reply = manager->get(*request_image_cover);
timer.setInterval(5000);
diff --git a/OfficeAssistant_msvc/navbar.h b/OfficeAssistant_msvc/navbar.h
index b28e5b7..be04d3f 100644
--- a/OfficeAssistant_msvc/navbar.h
+++ b/OfficeAssistant_msvc/navbar.h
@@ -15,6 +15,7 @@
#include
#include "buttonstruct.h"
#include
+#include "mainscreen.h"
#include "mainwindowlayout.h"
@@ -24,9 +25,10 @@ QT_END_NAMESPACE
class NavBar : public QWidget {
Q_OBJECT
-
+signals:
+ void firstUrl(QString url);
public:
- NavBar(ConfigResponse *configResponse,QWidget *parent = nullptr);
+ NavBar(ConfigResponse *configResponse,MainScreen *mainScreen,QWidget *parent = nullptr);
~NavBar() override;
protected:
@@ -38,6 +40,8 @@ protected:
private:
Ui::NavBar *ui;
QColor qColor;
+ QColor text_color;
+ QColor text_cover_color;
QList buttons;
QList buttonStructs;
QByteArray *buffer;
@@ -50,6 +54,7 @@ private:
bool downloadSuccess=true;
void getLogoFromInternet(ConfigResponse *configResponse);
void getLogoFromLocal();
+ MainScreen *mainScreen;
private slots:
void storeToBuffer();
void cancelDownload();
diff --git a/OfficeAssistant_msvc/netio.cpp b/OfficeAssistant_msvc/netio.cpp
index 581a310..3cd6558 100644
--- a/OfficeAssistant_msvc/netio.cpp
+++ b/OfficeAssistant_msvc/netio.cpp
@@ -30,17 +30,7 @@
#endif
#pragma comment(lib,"comsuppw.lib")
//读取注册表获取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(){
wchar_t unix_time[65]={0};
@@ -182,7 +172,6 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
timer->stop();
//delete httpMgr;
QJsonDocument result;
- configResponse=new ConfigResponse;
configResponse->succeed = false;
//memset(configResponse,0,sizeof(*configResponse));
auto error = reply->error();
@@ -203,8 +192,16 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
if(result.isObject()){
QJsonObject obj_root=result.object();
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;
for(auto value:array){
QJsonObject object=value.toObject();
@@ -217,6 +214,7 @@ void ConfigRequest::sendRequest(ConfigResponse *configResponse) {
configResponse->menus << menu;
i++;
}
+ configResponse->succeed = true;
}else{
//数据不完整
configResponse->succeed=false;
diff --git a/OfficeAssistant_msvc/netio.h b/OfficeAssistant_msvc/netio.h
index e4d6657..9ebe15c 100644
--- a/OfficeAssistant_msvc/netio.h
+++ b/OfficeAssistant_msvc/netio.h
@@ -98,6 +98,16 @@ class OpenMulitiWechat:public RequestBodyBase{
public:
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
diff --git a/OfficeAssistant_msvc/qminiblink.cpp b/OfficeAssistant_msvc/qminiblink.cpp
index 0455c06..2802e75 100644
--- a/OfficeAssistant_msvc/qminiblink.cpp
+++ b/OfficeAssistant_msvc/qminiblink.cpp
@@ -1,27 +1,43 @@
#include "qminiblink.h"
+#include
+#include
#pragma comment (lib,"Comctl32.lib")
-QMiniBlink::QMiniBlink(QWidget *broswer,QWidget *parent)
+QMiniBlink::QMiniBlink(QWidget *parent)
: QWidget(parent){
- this->broswer = broswer;
+
+ this->parent = parent;
+ wkeView = nullptr;
//QSizePolicy sizePolicy(QSizePolicy::Policy::Expanding, QSizePolicy::QSizePolicy::Expanding);
//setSizePolicy(sizePolicy);
}
void QMiniBlink::init() {
ui.setupUi(this);
wkeInit();
- wkeView = wkeCreateWebWindow(WKE_WINDOW_TYPE_CONTROL, (HWND)this->winId(), 0, 0, this->width(), this->height());
- wkeSetNavigationToNewWindowEnable(wkeView, false);
- wkeShowWindow(wkeView, TRUE);
- SetParent(wkeGetWindowHandle(wkeView), (HWND)this->winId());
- SetWindowSubclass((HWND)this->winId(), subClassProc, 0, (DWORD_PTR)this);
- wkeRunMessageLoop();
-}
-QMiniBlink::~QMiniBlink(){}
-void QMiniBlink::destroy() {
- wkeDestroyWebView(wkeView);
-}
+ RECT rect;
+ GetWindowRect((HWND)this->winId(), &rect);
+ resize(rect.right - rect.left, rect.bottom - rect.top);
+ this->wkeView = wkeCreateWebWindow(WKE_WINDOW_TYPE_CONTROL, (HWND)this->winId(), 0, 0, rect.right - rect.left, rect.bottom - rect.top);
+ 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) {
wkeLoadURL(wkeView, url.toStdString().c_str());
}
diff --git a/OfficeAssistant_msvc/qminiblink.h b/OfficeAssistant_msvc/qminiblink.h
index a6bd85b..72e7ef4 100644
--- a/OfficeAssistant_msvc/qminiblink.h
+++ b/OfficeAssistant_msvc/qminiblink.h
@@ -11,16 +11,20 @@ class QMiniBlink : public QWidget
Q_OBJECT
public:
- QMiniBlink(QWidget *broswer,QWidget *parent = Q_NULLPTR);
+ QMiniBlink(QWidget *parent = nullptr);
~QMiniBlink();
void init();
- void destroy();
+
void autojustWebViewSize();
+ QString firstUrl;
public slots:
+ void ondestroy();
void switchUrl(QString url);
private:
Ui::QMiniBlink ui;
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);
};
diff --git a/OfficeAssistant_msvc/qminiblink.ui b/OfficeAssistant_msvc/qminiblink.ui
index c221d42..e3401da 100644
--- a/OfficeAssistant_msvc/qminiblink.ui
+++ b/OfficeAssistant_msvc/qminiblink.ui
@@ -1,23 +1,20 @@
-
+
+
QMiniBlink
-
-
- QMiniBlink
-
-
+
+
- 0
- 0
- 400
- 300
+ 0
+ 0
+ 1142
+ 806
-
+
QMiniBlink
-
-
+
-
+
diff --git a/OfficeAssistant_msvc/qtwidgetsclass.ui b/OfficeAssistant_msvc/qtwidgetsclass.ui
new file mode 100644
index 0000000..119587c
--- /dev/null
+++ b/OfficeAssistant_msvc/qtwidgetsclass.ui
@@ -0,0 +1,23 @@
+
+ QtWidgetsClass
+
+
+ QtWidgetsClass
+
+
+
+ 0
+ 0
+ 400
+ 300
+
+
+
+ QtWidgetsClass
+
+
+
+
+
+
+
diff --git a/OfficeAssistant_msvc/settingsscreen.cpp b/OfficeAssistant_msvc/settingsscreen.cpp
new file mode 100644
index 0000000..62fd163
--- /dev/null
+++ b/OfficeAssistant_msvc/settingsscreen.cpp
@@ -0,0 +1,56 @@
+#include "settingsscreen.h"
+#include "config.h"
+#include
+#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;
+}
diff --git a/OfficeAssistant_msvc/settingsscreen.h b/OfficeAssistant_msvc/settingsscreen.h
new file mode 100644
index 0000000..6fda898
--- /dev/null
+++ b/OfficeAssistant_msvc/settingsscreen.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+#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();
+};
diff --git a/OfficeAssistant_msvc/settingsscreen.ui b/OfficeAssistant_msvc/settingsscreen.ui
new file mode 100644
index 0000000..ce895e4
--- /dev/null
+++ b/OfficeAssistant_msvc/settingsscreen.ui
@@ -0,0 +1,23 @@
+
+ SettingsScreen
+
+
+ SettingsScreen
+
+
+
+ 0
+ 0
+ 400
+ 300
+
+
+
+ SettingsScreen
+
+
+
+
+
+
+
diff --git a/OfficeAssistant_msvc/switchbutton.cpp b/OfficeAssistant_msvc/switchbutton.cpp
new file mode 100644
index 0000000..f504653
--- /dev/null
+++ b/OfficeAssistant_msvc/switchbutton.cpp
@@ -0,0 +1,188 @@
+#include "switchbutton.h"
+#include "config.h"
+#include
+#include
+#include
+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()
+{
+}
diff --git a/OfficeAssistant_msvc/switchbutton.h b/OfficeAssistant_msvc/switchbutton.h
new file mode 100644
index 0000000..4fd8be1
--- /dev/null
+++ b/OfficeAssistant_msvc/switchbutton.h
@@ -0,0 +1,41 @@
+#pragma once
+
+#include
+#include
+#include
+#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 *);
+
+
+
+};
diff --git a/OfficeAssistant_msvc/switchbutton.ui b/OfficeAssistant_msvc/switchbutton.ui
new file mode 100644
index 0000000..0133b8d
--- /dev/null
+++ b/OfficeAssistant_msvc/switchbutton.ui
@@ -0,0 +1,23 @@
+
+ SwitchButton
+
+
+ SwitchButton
+
+
+
+ 0
+ 0
+ 400
+ 300
+
+
+
+ SwitchButton
+
+
+
+
+
+
+
diff --git a/images/address.png b/images/address.png
deleted file mode 100644
index 875b34a..0000000
Binary files a/images/address.png and /dev/null differ
diff --git a/images/close-small.png b/images/close-small.png
deleted file mode 100644
index c8c864d..0000000
Binary files a/images/close-small.png and /dev/null differ
diff --git a/images/close.png b/images/close.png
deleted file mode 100644
index dcc9b40..0000000
Binary files a/images/close.png and /dev/null differ
diff --git a/images/home.png b/images/home.png
deleted file mode 100644
index 4b774e2..0000000
Binary files a/images/home.png and /dev/null differ
diff --git a/images/maxsize.png b/images/maxsize.png
deleted file mode 100644
index d2539ed..0000000
Binary files a/images/maxsize.png and /dev/null differ
diff --git a/images/minsize.png b/images/minsize.png
deleted file mode 100644
index f08070f..0000000
Binary files a/images/minsize.png and /dev/null differ
diff --git a/images/money.png b/images/money.png
deleted file mode 100644
index 93c1567..0000000
Binary files a/images/money.png and /dev/null differ
diff --git a/images/personalcenter.png b/images/personalcenter.png
deleted file mode 100644
index e37d1c7..0000000
Binary files a/images/personalcenter.png and /dev/null differ
diff --git a/officeassistant.cppcheck b/officeassistant.cppcheck
new file mode 100644
index 0000000..8ff65e5
--- /dev/null
+++ b/officeassistant.cppcheck
@@ -0,0 +1,14 @@
+
+
+ officeassistant-cppcheck-build-dir
+ OfficeAssistant_msvc.sln
+ true
+ true
+ true
+ 2
+ 100
+
+ Debug
+ Release
+
+
diff --git a/startcalc/startcalc.vcxproj b/startcalc/startcalc.vcxproj
index d2b9f78..b9e40bb 100644
--- a/startcalc/startcalc.vcxproj
+++ b/startcalc/startcalc.vcxproj
@@ -34,7 +34,7 @@
Application
false
- v140
+ v140_xp
true
Unicode
diff --git a/wxdk/wxdk.vcxproj b/wxdk/wxdk.vcxproj
index 21e7970..5173ea8 100644
--- a/wxdk/wxdk.vcxproj
+++ b/wxdk/wxdk.vcxproj
@@ -34,7 +34,7 @@
Application
false
- v140
+ v140_xp
true
Unicode