diff --git a/OfficeAssistant_msvc.VC.db b/OfficeAssistant_msvc.VC.db index 1105217..3ceebf0 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 16734b1..654475d 100644 --- a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj +++ b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj @@ -101,9 +101,7 @@ - - - + @@ -118,22 +116,18 @@ - + - - + - - - diff --git a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters index 3216add..90781a1 100644 --- a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters +++ b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.filters @@ -63,13 +63,7 @@ Header Files - - Header Files - - - Header Files - - + Header Files @@ -98,13 +92,7 @@ Source Files - - Source Files - - - Source Files - - + Source Files @@ -121,17 +109,11 @@ Form Files - - Form Files - - - Form Files - - - Form Files - Form Files + + Form Files + \ No newline at end of file diff --git a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user index c1d4815..9add229 100644 --- a/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user +++ b/OfficeAssistant_msvc/OfficeAssistant_msvc.vcxproj.user @@ -5,9 +5,9 @@ WindowsLocalDebugger - 2023-07-30T18:20:21.4819233Z + 2023-08-01T03:05:45.8140795Z - 2023-07-30T18:20:22.3001457Z + 2023-08-01T03:05:46.4588999Z \ No newline at end of file diff --git a/OfficeAssistant_msvc/mainscreen.cpp b/OfficeAssistant_msvc/mainscreen.cpp index b37abc0..b296a86 100644 --- a/OfficeAssistant_msvc/mainscreen.cpp +++ b/OfficeAssistant_msvc/mainscreen.cpp @@ -11,7 +11,6 @@ #include #include #include "globalvariables.h" -#include "settingsscreen.h" #include "mythread.h" #include "config.h" @@ -33,12 +32,8 @@ MainScreen::MainScreen(QWidget *parent) : button->setText(QString::fromLocal8Bit("打开微信")); layout = new QHBoxLayout; miniblink = new QMiniBlink(this); - settingScreen = new SettingsScreen; - settingScreen->setMinimumHeight(height()); - settingScreen->setHidden(true); layout->addWidget(widget, 1); layout->addWidget(miniblink, 4); - layout->addWidget(settingScreen); this->setLayout(layout); layout->setMargin(0); //miniblink->setAttribute(Qt::WA_DeleteOnClose); @@ -65,10 +60,8 @@ MainScreen::~MainScreen() { delete button; emit ondestroy(); layout->removeWidget(miniblink); - layout->removeWidget(settingScreen); layout->removeWidget(widget); delete miniblink; - delete settingScreen; delete widget; delete layout; delete ui; @@ -83,26 +76,17 @@ void MainScreen::clickButton1(QString text, QString url) { if (text == QString::fromLocal8Bit("微信多开")) { widget->setHidden(false); miniblink->setHidden(false); - settingScreen->setHidden(true); emit changeUrl(url_full); - - } - else if (text == QString::fromLocal8Bit("软件设置")){ - miniblink->setHidden(true); - widget->setHidden(true); - settingScreen->setHidden(false); - } else { widget->setHidden(true); miniblink->setHidden(false); - settingScreen->setHidden(true); emit changeUrl(url_full); } } void MainScreen::startWeChat() { QString path = QApplication::applicationDirPath(); - QString exe = path + "/wxdk.exe"; + QString exe = path + "/app/wxdk.exe"; ShellExecute(GetDesktopWindow(), L"open", exe.toStdWString().c_str(), L"79c86fb12b36dfa33d1a537c9af100b4c7928a9c", path.toStdWString().c_str(), SW_SHOW); } //void MainScreen::resizeEvent(QResizeEvent *event) { diff --git a/OfficeAssistant_msvc/mainscreen.h b/OfficeAssistant_msvc/mainscreen.h index 7ebf923..5a087f3 100644 --- a/OfficeAssistant_msvc/mainscreen.h +++ b/OfficeAssistant_msvc/mainscreen.h @@ -11,7 +11,6 @@ #include #include "wke.h" #include "qminiblink.h" -#include "settingsscreen.h" class MyThread; QT_BEGIN_NAMESPACE namespace Ui { class MainScreen; } @@ -43,7 +42,6 @@ private: QWidget *widget; MyThread *thread; QMiniBlink *miniblink; - SettingsScreen *settingScreen; private slots: void startWeChat(); diff --git a/OfficeAssistant_msvc/mainwindowlayout.cpp b/OfficeAssistant_msvc/mainwindowlayout.cpp index 210ae5c..0ceb15e 100644 --- a/OfficeAssistant_msvc/mainwindowlayout.cpp +++ b/OfficeAssistant_msvc/mainwindowlayout.cpp @@ -6,6 +6,7 @@ #include "mainwindowlayout.h" #include "ui_MainWindowLayout.h" +#include "mysettingsdialog.h" MainWindowLayout::MainWindowLayout(QWidget *parent) : QWidget(parent), ui(new Ui::MainWindowLayout) { @@ -47,10 +48,15 @@ void MainWindowLayout::resizeEvent(QResizeEvent *event) { void MainWindowLayout::clickButton(QString text, QString url) { QString path = QApplication::applicationDirPath(); - path += "/startcalc.exe"; + path += "/app/startcalc.exe"; if (text== QString::fromLocal8Bit("计算器")) { WinExec(path.toStdString().c_str(), SW_SHOW); } + else if (text == QString::fromLocal8Bit("软件设置")) { + MySettingsDialog *settings = new MySettingsDialog; + settings->exec(); + delete settings; + } else{ emit clickButton1(text, url); } diff --git a/OfficeAssistant_msvc/mysettingsdialog.cpp b/OfficeAssistant_msvc/mysettingsdialog.cpp new file mode 100644 index 0000000..307afa7 --- /dev/null +++ b/OfficeAssistant_msvc/mysettingsdialog.cpp @@ -0,0 +1,107 @@ +#include "mysettingsdialog.h" +#include +#include +#include "netio.h" +#include "globalvariables.h" +MySettingsDialog::MySettingsDialog(QWidget *parent) + : QDialog(parent) +{ + ui.setupUi(this); + this->setFixedSize(width(), height()); + 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) { + ui.autostart->setDisabled(true); + } + QString app = QApplication::applicationFilePath(); + app.replace("/", "\\"); + DWORD size=128; + wchar_t reg[128]; + lRet = RegGetValue(hRoot, szSubKey, L"OfficeAssistant", RRF_RT_ANY, nullptr, reg, &size); + if (wcscmp(reg,app.toStdWString().c_str())==0) { + ui.autostart->setChecked(true); + } + copyButton = ui.copy; + connect(copyButton, &QPushButton::clicked, this, &MySettingsDialog::copyToCLipboard); + connect(ui.autostart, &QCheckBox::stateChanged, this, &MySettingsDialog::autoStart); + connect(ui.addshortcut, &QPushButton::clicked, this, &MySettingsDialog::createShortcut); + connect(ui.law_button, &QPushButton::clicked, this, &MySettingsDialog::law); + ui.code->setText(QString(QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5).toHex())); +} + +MySettingsDialog::~MySettingsDialog() +{ +} + +void MySettingsDialog::autoStart(int state) +{ + if (state == Qt::Checked) { + 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(); + app.replace("/", "\\"); + qDebug() << app.toStdWString().c_str(); + lRet = RegSetValueEx(hKey, L"OfficeAssistant", 0, REG_SZ, (BYTE*)app.toStdWString().c_str(), app.length()*sizeof(wchar_t)); + if (lRet == ERROR_SUCCESS) + { + QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建开机启动项成功")); + } + RegCloseKey(hKey); + } + else if (state == Qt::Unchecked) { + 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"OfficeAssistant"); + if (lRet == ERROR_SUCCESS) + { + QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("移除开机启动项成功。")); + } + RegCloseKey(hKey); + } +} + +void MySettingsDialog::law() +{ + QString path = QApplication::applicationDirPath(); + QString license = path + "/license.txt"; + license.replace("/", "\\"); + ShellExecute(GetDesktopWindow(), L"open", L"notepad.exe" , license.toStdWString().c_str(), nullptr, SW_SHOW); +} + +void MySettingsDialog::copyToCLipboard() { + QClipboard *clip = QApplication::clipboard(); + clip->setText(QString(QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5).toHex())); +} +void MySettingsDialog::createShortcut() { + QString deskTopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation); + deskTopPath = deskTopPath + QString::fromLocal8Bit("/办公助手.lnk"); + QString srcFile = QApplication::applicationFilePath(); + bool succeed=QFile::link(srcFile, deskTopPath); + if (succeed) { + QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建快捷方式成功。")); + } + else { + QMessageBox::information(this, QString::fromLocal8Bit("提示"), QString::fromLocal8Bit("创建快捷方式失败。")); + } +} \ No newline at end of file diff --git a/OfficeAssistant_msvc/mysettingsdialog.h b/OfficeAssistant_msvc/mysettingsdialog.h new file mode 100644 index 0000000..34ec556 --- /dev/null +++ b/OfficeAssistant_msvc/mysettingsdialog.h @@ -0,0 +1,23 @@ +#pragma once + +#include +#include "ui_mysettingsdialog.h" +#include + +class MySettingsDialog : public QDialog +{ + Q_OBJECT + +public: + MySettingsDialog(QWidget *parent = Q_NULLPTR); + ~MySettingsDialog(); + +private: + Ui::MySettingsDialog ui; + QPushButton *copyButton; +public slots: + void copyToCLipboard(); + void createShortcut(); + void autoStart(int state); + void law(); +}; diff --git a/OfficeAssistant_msvc/mysettingsdialog.ui b/OfficeAssistant_msvc/mysettingsdialog.ui new file mode 100644 index 0000000..cef95d5 --- /dev/null +++ b/OfficeAssistant_msvc/mysettingsdialog.ui @@ -0,0 +1,158 @@ + + + MySettingsDialog + + + + 0 + 0 + 736 + 540 + + + + + 0 + 0 + + + + 璁剧疆 + + + true + + + + + 70 + 70 + 581 + 381 + + + + + + + + 0 + 1 + + + + 纭欢淇℃伅 + + + + + 20 + 40 + 108 + 21 + + + + 纭欢ID + + + + + + 130 + 40 + 401 + 24 + + + + TextLabel + + + + + + 130 + 70 + 141 + 31 + + + + 澶嶅埗 + + + + + + + + + 0 + 1 + + + + 璁剧疆 + + + + + 20 + 30 + 138 + 28 + + + + 寮鏈哄惎鍔 + + + + + + 20 + 60 + 291 + 41 + + + + 鍒涘缓妗岄潰蹇嵎鏂瑰紡 + + + + + + + + + 0 + 1 + + + + 娉曞緥澹版槑 + + + + + 20 + 30 + 291 + 46 + + + + 鏌ョ湅娉曞緥澹版槑鍜岃鍙崗璁 + + + + + + + + + + + diff --git a/OfficeAssistant_msvc/netio.cpp b/OfficeAssistant_msvc/netio.cpp index c3ec4ad..590327c 100644 --- a/OfficeAssistant_msvc/netio.cpp +++ b/OfficeAssistant_msvc/netio.cpp @@ -70,12 +70,6 @@ RequestBodyBase::RequestBodyBase(){ exit(1); } release=obj_root.value("release").toString(); - if(obj_root.value("version")==QJsonValue::Undefined){ - QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏")); - exit(1); - } - version=obj_root.value("version").toString(); - device_id=obj_root.value("device_id").toString(); }else{ //处理错误 QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("配置文件损坏")); @@ -113,30 +107,14 @@ RequestBodyBase::RequestBodyBase(){ default: os_version="Unknown"; } - //如果device_id是空值 - if(device_id.isEmpty()){ - //读取MachineGUID并取MD5作为device_id - QByteArray hash = QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5); - device_id=hash.toHex(); - infFile=new QFile(dir + "/config/information.kmd"); - if(!infFile->open(QIODevice::WriteOnly|QIODevice::Text)){ - //处理错误 - QMessageBox::warning(nullptr, QString::fromLocal8Bit("错误"), QString::fromLocal8Bit("无法覆写配置文件")); - infFile->close(); - delete infFile; - exit(1); - } - //加入json序列 - QJsonValue value=device_id; - QJsonObject obj_root = qJsonDocument.object(); - obj_root.insert("device_id",value); - qJsonDocument.setObject(obj_root); - //写入配置文件 - infFile->write(qJsonDocument.toJson()); - //关闭文件; - infFile->close(); - delete infFile; - } + //读取MachineGUID并取MD5作为device_id + QByteArray hash = QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5); + device_id = hash.toHex(); + //加入json序列 + QJsonValue value = device_id; + QJsonObject obj_root = qJsonDocument.object(); + obj_root.insert("device_id", value); + qJsonDocument.setObject(obj_root); QJsonValue os_json(this->os); QJsonValue os_version_json(this->os_version); QString key_hash = QCryptographicHash::hash(QString(KEY).toUtf8(), QCryptographicHash::Md5).toHex(); @@ -145,7 +123,7 @@ RequestBodyBase::RequestBodyBase(){ sign = sign_byte.toHex(); QJsonValue sign_json(sign); QJsonValue requestId_json=QJsonValue(request_id); - QJsonObject obj_root=qJsonDocument.object(); + obj_root=qJsonDocument.object(); //插入request_id obj_root.insert(QString::fromLocal8Bit("request_id"),requestId_json); obj_root.insert(QString::fromLocal8Bit("os"), os_json); diff --git a/OfficeAssistant_msvc/qtwidgetsclass.ui b/OfficeAssistant_msvc/qtwidgetsclass.ui deleted file mode 100644 index 119587c..0000000 --- a/OfficeAssistant_msvc/qtwidgetsclass.ui +++ /dev/null @@ -1,23 +0,0 @@ - - QtWidgetsClass - - - QtWidgetsClass - - - - 0 - 0 - 400 - 300 - - - - QtWidgetsClass - - - - - - - diff --git a/OfficeAssistant_msvc/settingsscreen.cpp b/OfficeAssistant_msvc/settingsscreen.cpp deleted file mode 100644 index 6000ef8..0000000 --- a/OfficeAssistant_msvc/settingsscreen.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#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; - inf_str+= QString::fromLocal8Bit("\n本软件采用了Qt,Qt是The Qt Company的产品,采用LGPL协议发布。\n"); - inf_str += QString::fromLocal8Bit("本软件采用了MiniBlink,MiniBlink是珠海独角兽科技有限公司的产品,采用Apache 2.0协议发布。\n"); - 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 deleted file mode 100644 index 6fda898..0000000 --- a/OfficeAssistant_msvc/settingsscreen.h +++ /dev/null @@ -1,31 +0,0 @@ -#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 deleted file mode 100644 index ce895e4..0000000 --- a/OfficeAssistant_msvc/settingsscreen.ui +++ /dev/null @@ -1,23 +0,0 @@ - - SettingsScreen - - - SettingsScreen - - - - 0 - 0 - 400 - 300 - - - - SettingsScreen - - - - - - - diff --git a/OfficeAssistant_msvc/switchbutton.cpp b/OfficeAssistant_msvc/switchbutton.cpp deleted file mode 100644 index f504653..0000000 --- a/OfficeAssistant_msvc/switchbutton.cpp +++ /dev/null @@ -1,188 +0,0 @@ -#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 deleted file mode 100644 index 4fd8be1..0000000 --- a/OfficeAssistant_msvc/switchbutton.h +++ /dev/null @@ -1,41 +0,0 @@ -#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 deleted file mode 100644 index 0133b8d..0000000 --- a/OfficeAssistant_msvc/switchbutton.ui +++ /dev/null @@ -1,23 +0,0 @@ - - SwitchButton - - - SwitchButton - - - - 0 - 0 - 400 - 300 - - - - SwitchButton - - - - - - - diff --git a/startcalc/startcalc.vcxproj b/startcalc/startcalc.vcxproj index b9e40bb..3aa10b0 100644 --- a/startcalc/startcalc.vcxproj +++ b/startcalc/startcalc.vcxproj @@ -71,12 +71,14 @@ true + $(SolutionDir)$(Configuration)\app\ true false + $(SolutionDir)$(Configuration)\app false diff --git a/wxdk/wxdk.vcxproj b/wxdk/wxdk.vcxproj index 5173ea8..15609ff 100644 --- a/wxdk/wxdk.vcxproj +++ b/wxdk/wxdk.vcxproj @@ -71,12 +71,14 @@ true + $(SolutionDir)$(Configuration)\app\ true false + $(SolutionDir)$(Configuration)\app false