diff --git a/README.md b/README.md index 818a358..09b0e05 100644 --- a/README.md +++ b/README.md @@ -18,22 +18,6 @@   该软件如果没有任何插件,仅支持添加热键使用默认方式打开任何文件。插件的强大决定着该软件的上限,通过热键可以配置使用热键调用插件借口;默认通过鼠标中键配合`Ctrl`键可以调出工具窗口,选择合适的工具;也可以通过热键调出窗口工具,点击打开所需的文件或者软件,而不必从启动器翻找,避免任务栏图标过多以及桌面文件过多的情况。 -## TODO - -  现在工具处于开发状态,很多功能并没有完成: - -1. 配置相关(已完成 95%) -2. 语言本地化(已完成 0%) - -  如下是已完成的功能: - -1. 插件系统的设计 -2. 热键调用功能 -3. 工具窗口 -4. 窗口工具 - -  待功能基本完成的时候,我会同步到我使用的所有代码托管平台。 - ### 协议   本软件如果是开源版本将遵循`AGPL-3.0`协议,请勿用于该协议之外的用途。如果你想将本软件的代码用于闭源的商业代码,想要解除`GPL`系列的必须开源的限制,请必须亲自咨询我,商讨商业授权相关事宜。 @@ -44,10 +28,6 @@ ## 效果图 -  还没做完,就不放效果图了…… - -  还是放个草图吧,以免有人惦记: -

diff --git a/TestPlugin/TestPlugin.pro b/TestPlugin/TestPlugin.pro index 9b19988..9d8875d 100644 --- a/TestPlugin/TestPlugin.pro +++ b/TestPlugin/TestPlugin.pro @@ -33,4 +33,3 @@ DISTFILES += TestPlugin.json RESOURCES += \ resources.qrc - diff --git a/WingTool.pro b/WingTool.pro index 46975d4..4241a81 100644 --- a/WingTool.pro +++ b/WingTool.pro @@ -48,3 +48,7 @@ HEADERS += \ dialog/tooleditdialog.h \ class/hotkey.h \ dialog/toolswapdialog.h + + +TRANSLATIONS += \ + $$PWD/lang/zh.ts diff --git a/class/settingmanager.cpp b/class/settingmanager.cpp index 6a26402..a351550 100644 --- a/class/settingmanager.cpp +++ b/class/settingmanager.cpp @@ -12,7 +12,17 @@ SettingManager::SettingManager(QObject *parent) m_toolBox( QKeySequence(Qt::KeyboardModifier::ShiftModifier | Qt::Key_Space)), m_toolwinMod(Qt::KeyboardModifier::ControlModifier), - m_toolMouse(Qt::MouseButton::MidButton) { + m_toolMouse(Qt::MouseButton::MidButton), ismod(false), loaded(false) { + + auto pathdir = + QString("%1/%2/%3") + .arg(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)) + .arg(qApp->organizationName()) + .arg(qApp->applicationName()); + QDir().mkpath(pathdir); + + configfile = pathdir + "/config.conf"; + m_instance = this; } @@ -21,18 +31,12 @@ SettingManager *SettingManager::instance() { return m_instance; } bool SettingManager::loadSettings(QString filename) { #define CORRECTINFO(info) \ - info.pluginIndex = plgsys->pluginIndexByProvider(info.provider); \ if (info.isPlugin) { \ + info.pluginIndex = plgsys->pluginIndexByProvider(info.provider); \ info.process = plgsys->plugin(info.pluginIndex)->pluginName(); \ } - QString strConfigPath = filename.isEmpty() - ? QString("%1/%2/%3/config.conf") - .arg(QStandardPaths::writableLocation( - QStandardPaths::ConfigLocation)) - .arg(qApp->organizationName()) - .arg(qApp->applicationName()) - : filename; + QString strConfigPath = filename.isEmpty() ? configfile : filename; QFile f(strConfigPath); QDataStream stream(&f); @@ -46,6 +50,22 @@ bool SettingManager::loadSettings(QString filename) { return false; } + // 读取配置文件 + char ver; + stream.readRawData(&ver, 1); + + if (ver != CONFIGVER) { + f.close(); + return false; + } + + if (filename.length()) + ismod = true; + + // 如果已经加载了设置,重置重新加载 + if (loaded) + resetSettings(); + auto plgsys = PluginSystem::instance(); // General @@ -55,6 +75,8 @@ bool SettingManager::loadSettings(QString filename) { // 读取结束,提示可以加载基础配置内容了 emit loadedGeneral(); + QVector hashes; + // 读取 Hotkey 的相关信息 int len; stream >> len; // 先读取一下有几个 @@ -68,7 +90,17 @@ bool SettingManager::loadSettings(QString filename) { buf.provider = QString::fromUtf8(arr); stream >> arr; buf.params = QString::fromUtf8(arr); - stream >> arr; + + bool isStored; + stream >> isStored; + if (isStored) { + int index; + stream >> index; + arr = hashes[index]; + } else { + stream >> arr; + hashes.append(arr); + } auto pi = plgsys->pluginIndexByProvider(buf.provider); // 找不到了,插件丢失或者不兼容 @@ -110,6 +142,18 @@ bool SettingManager::loadSettings(QString filename) { buf.provider = QString::fromUtf8(arr); stream >> arr; buf.params = QString::fromUtf8(arr); + + bool isStored; + stream >> isStored; + if (isStored) { + int index; + stream >> index; + arr = hashes[index]; + } else { + stream >> arr; + hashes.append(arr); + } + auto pi = plgsys->pluginIndexByProvider(buf.provider); // 找不到了,插件丢失或者不兼容 if (pi < 0) @@ -146,7 +190,18 @@ bool SettingManager::loadSettings(QString filename) { buf.provider = QString::fromUtf8(arr); stream >> arr; buf.params = QString::fromUtf8(arr); - stream >> arr; + + bool isStored; + stream >> isStored; + if (isStored) { + int index; + stream >> index; + arr = hashes[index]; + } else { + stream >> arr; + hashes.append(arr); + } + auto pi = plgsys->pluginIndexByProvider(buf.provider); // 找不到了,插件丢失或者不兼容 if (pi < 0) @@ -173,16 +228,17 @@ bool SettingManager::loadSettings(QString filename) { emit loadedGeneral(); } f.close(); + loaded = true; return true; } bool SettingManager::saveSettings() { - QString strConfigPath = - QString("%1/%2/%3/config.conf") - .arg(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)) - .arg(qApp->organizationName()) - .arg(qApp->applicationName()); - return exportSettings(strConfigPath); + if (!ismod && QFile::exists(configfile)) + return true; + auto res = exportSettings(configfile); + if (res) + ismod = false; + return res; } bool SettingManager::exportSettings(QString filename) { @@ -190,8 +246,8 @@ bool SettingManager::exportSettings(QString filename) { QDataStream stream(&f); if (f.open(QFile::WriteOnly)) { // 写文件头 - static char header[] = "WINGTOOL"; - stream.writeRawData(header, 8); + static char header[] = {'W', 'I', 'N', 'G', 'T', 'O', 'O', 'L', CONFIGVER}; + stream.writeRawData(header, sizeof(header)); // General stream << m_toolwin << m_wintool << m_toolGridSize << m_toolBox << m_toolwinMod << m_toolMouse; @@ -204,13 +260,34 @@ bool SettingManager::exportSettings(QString filename) { return false; } -void SettingManager::resetSettings() {} +void SettingManager::resetSettings() { + emit sigReset(); + m_toolwin = true; + m_wintool = true; + m_toolGridSize = TOOLGRIDSIZE; + + m_toolBox = QKeySequence(Qt::KeyboardModifier::ShiftModifier | Qt::Key_Space); + m_toolwinMod = Qt::KeyboardModifier::ControlModifier; + m_toolMouse = Qt::MouseButton::MidButton; + ismod = true; + + // 更新 UI + emit sigToolwinEnabledChanged(m_toolwin); + emit sigWintoolEnabledChanged(m_wintool); + emit sigToolGridSizeChanged(m_toolGridSize); + emit sigToolBoxHotkeyChanged(m_toolBox); + emit sigToolwinModChanged(m_toolwinMod); + emit sigToolwinMouseBtnChanged(m_toolMouse); +} + +void SettingManager::setModified() { ismod = true; } int SettingManager::toolGridSize() const { return m_toolGridSize; } void SettingManager::setToolGridSize(const int v) { if (v > 0) { m_toolGridSize = v; + ismod = true; emit sigToolGridSizeChanged(v); } } @@ -219,6 +296,7 @@ QKeySequence SettingManager::toolBoxHotkey() const { return m_toolBox; } void SettingManager::setToolBoxHotkey(const QKeySequence seq) { m_toolBox = seq; + ismod = true; emit sigToolBoxHotkeyChanged(seq); } @@ -226,6 +304,7 @@ Qt::KeyboardModifier SettingManager::toolwinMod() const { return m_toolwinMod; } void SettingManager::setToolwinMod(const Qt::KeyboardModifier &toolwinMod) { m_toolwinMod = toolwinMod; + ismod = true; emit sigToolwinModChanged(toolwinMod); } @@ -233,6 +312,7 @@ Qt::MouseButton SettingManager::toolwinMouseBtn() const { return m_toolMouse; } void SettingManager::setToolMouseBtn(const Qt::MouseButton &toolMouse) { m_toolMouse = toolMouse; + ismod = true; emit sigToolwinMouseBtnChanged(toolMouse); } @@ -240,6 +320,7 @@ bool SettingManager::toolwinEnabled() const { return m_toolwin; } void SettingManager::setToolwinEnabled(bool toolwin) { m_toolwin = toolwin; + ismod = true; emit sigToolwinEnabledChanged(toolwin); } @@ -247,5 +328,6 @@ bool SettingManager::wintoolEnabled() const { return m_wintool; } void SettingManager::setWintoolEnabled(bool wintool) { m_wintool = wintool; + ismod = true; emit sigWintoolEnabledChanged(wintool); } diff --git a/class/settingmanager.h b/class/settingmanager.h index 3f4a533..4360b0b 100644 --- a/class/settingmanager.h +++ b/class/settingmanager.h @@ -7,6 +7,7 @@ #include #define TOOLGRIDSIZE 40 +#define CONFIGVER char(0) class SettingManager : public QObject { Q_OBJECT @@ -22,6 +23,8 @@ public: void resetSettings(); public: + void setModified(); + int toolGridSize() const; void setToolGridSize(const int v); @@ -55,6 +58,8 @@ signals: void setToolWinInfo(int index, ToolStructInfo &info); void addWinToolInfo(ToolStructInfo &info); + void sigReset(); // 回归出厂配置信号 + private: static SettingManager *m_instance; @@ -65,6 +70,10 @@ private: Qt::KeyboardModifier m_toolwinMod; Qt::MouseButton m_toolMouse; + + bool ismod, loaded; + + QString configfile; }; #endif // SETTINGMANAGER_H diff --git a/class/wingapplication.h b/class/wingapplication.h index 4b87931..866984c 100644 --- a/class/wingapplication.h +++ b/class/wingapplication.h @@ -6,6 +6,7 @@ DWIDGET_USE_NAMESPACE class WingApplication : public DApplication { + Q_OBJECT public: WingApplication(int &argc, char **argv); diff --git a/dialog/centerwindow.cpp b/dialog/centerwindow.cpp index 9579f67..c95e357 100644 --- a/dialog/centerwindow.cpp +++ b/dialog/centerwindow.cpp @@ -294,6 +294,7 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) { if (d.exec()) { auto res = d.getResult(); this->setoolWinInfo(sellbl, res); + sm->setModified(); emit lbls[sellbl]->toggled(true); } }); @@ -401,7 +402,12 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) { AddMenuAction(tr("Down"), &CenterWindow::on_downWinTool); lscmenu.append(a); AddMenuAction(tr("TopMost"), [=] { + if (lstoolwin->count() == 1) + return; + auto sels = lstoolwin->selectionModel()->selectedRows(); + if (sels.isEmpty()) + return; QVector nums; for (auto &item : sels) { nums.append(item.row()); @@ -425,10 +431,16 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) { lstoolwin->insertItem(i, item); wintool.mvItem(pi, i); } + sm->setModified(); }); lscmenu.append(a); AddMenuAction(tr("DownMost"), [=] { + if (lstoolwin->count() == 1) + return; + auto sels = lstoolwin->selectionModel()->selectedRows(); + if (sels.isEmpty()) + return; QVector nums; for (auto &item : sels) { nums.append(item.row()); @@ -440,6 +452,7 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) { int i = 0; auto len = nums.count(); if (nums.first() == lstoolwin->count() - 1) { + i++; int pi = nums.first(); for (; i < len; i++) { pi--; @@ -456,6 +469,7 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) { lstoolwin->insertItem(i, item); wintool.mvItem(pi, i); } + sm->setModified(); }); lscmenu.append(a); lstoolwin->setContextMenuPolicy(Qt::CustomContextMenu); @@ -642,6 +656,7 @@ void CenterWindow::editTask(int index) { task = res; manager->editHotkey(hk, res.seq); + sm->setModified(); } } @@ -669,6 +684,7 @@ void CenterWindow::on_removeHotkey() { manager->unregisterHotkey(hk); tbhotkeys->removeRow(row); } + sm->setModified(); } void CenterWindow::on_clearHotkey() { @@ -676,6 +692,7 @@ void CenterWindow::on_clearHotkey() { hotkeys.clear(); manager->clearHotkey(); tbhotkeys->setRowCount(0); + sm->setModified(); DMessageManager::instance()->sendMessage(this, ProgramIcon, tr("ClearSuccess")); } @@ -705,6 +722,7 @@ void CenterWindow::on_addHotkey() { wt = new QTableWidgetItem(res.params); wt->setToolTip(res.params); tbhotkeys->setItem(index, 3, wt); + sm->setModified(); } } @@ -712,6 +730,7 @@ void CenterWindow::enableSelectedHotkeys(bool enable) { auto selrows = tbhotkeys->selectionModel()->selectedRows(); for (auto &item : selrows) { manager->enableHotKey(hotkeys[item.row()], enable); + sm->setModified(); } } @@ -728,15 +747,20 @@ void CenterWindow::on_editWinTool() { auto res = d.getResult(); wintoolinfos[index] = res; auto item = lstoolwin->item(index); - item->setIcon( - Utilities::trimIconFromInfo(plgsys->plugin(res.pluginIndex), res)); - item->setText(Utilities::getProgramName(res)); + auto plg = plgsys->plugin(res.pluginIndex); + item->setIcon(Utilities::trimIconFromInfo(plg, res)); + item->setText(Utilities::getProgramName(plg, res)); item->setToolTip(res.process); + sm->setModified(); } } void CenterWindow::on_removeWinTool() { auto sels = lstoolwin->selectionModel()->selectedRows(); + + if (sels.isEmpty()) + return; + QVector nums; for (auto &item : sels) { nums.append(item.row()); @@ -750,12 +774,14 @@ void CenterWindow::on_removeWinTool() { delete item; wintool.rmItem(index); } + sm->setModified(); } void CenterWindow::on_clearWinTool() { lstoolwin->clear(); wintoolinfos.clear(); wintool.rmItem(-1); // 清空数据 + sm->setModified(); DMessageManager::instance()->sendMessage(this, ProgramIcon, tr("ClearSuccess")); } @@ -767,27 +793,32 @@ void CenterWindow::on_addWinTool() { auto index = lstoolwin->currentRow(); if (index < 0) { wintoolinfos.append(res); - auto item = new QListWidgetItem( - Utilities::trimIconFromInfo(plgsys->plugin(res.pluginIndex), res), - Utilities::getProgramName(res)); - item->setToolTip(res.process); + auto plg = plgsys->plugin(res.pluginIndex); + auto item = new QListWidgetItem(Utilities::trimIconFromInfo(plg, res), + Utilities::getProgramName(plg, res)); + item->setToolTip(Utilities::getToolTipContent(plg, res)); lstoolwin->addItem(item); wintool.addItem(res); } else { wintoolinfos.insert(index + 1, res); - - auto item = new QListWidgetItem( - Utilities::trimIconFromInfo(plgsys->plugin(res.pluginIndex), res), - Utilities::getProgramName(res)); - item->setToolTip(res.process); + auto plg = plgsys->plugin(res.pluginIndex); + auto item = new QListWidgetItem(Utilities::trimIconFromInfo(plg, res), + Utilities::getProgramName(plg, res)); + item->setToolTip(Utilities::getToolTipContent(plg, res)); lstoolwin->insertItem(index + 1, item); wintool.addItem(res, index + 1); } + sm->setModified(); } } void CenterWindow::on_upWinTool() { + if (lstoolwin->count() == 1) + return; + auto sels = lstoolwin->selectionModel()->selectedRows(); + if (sels.isEmpty()) + return; QVector nums; for (auto &item : sels) { nums.append(item.row()); @@ -811,10 +842,17 @@ void CenterWindow::on_upWinTool() { lstoolwin->insertItem(p - 1, item); wintool.mvItem(p, p - 1); } + + sm->setModified(); } void CenterWindow::on_downWinTool() { + if (lstoolwin->count() == 1) + return; + auto sels = lstoolwin->selectionModel()->selectedRows(); + if (sels.isEmpty()) + return; QVector nums; for (auto &item : sels) { nums.append(item.row()); @@ -826,6 +864,7 @@ void CenterWindow::on_downWinTool() { int i = 0; auto len = nums.count(); if (nums.first() == lstoolwin->count() - 1) { + i++; int pi = nums.first(); for (; i < len; i++) { pi--; @@ -842,6 +881,7 @@ void CenterWindow::on_downWinTool() { lstoolwin->insertItem(p + 1, item); wintool.mvItem(p, p + 1); } + sm->setModified(); } void CenterWindow::on_exportSettings() { @@ -905,10 +945,10 @@ void CenterWindow::setoolWinInfo(int index, ToolStructInfo &info) { void CenterWindow::addWinToolInfo(ToolStructInfo &info) { wintoolinfos.append(info); - auto item = new QListWidgetItem( - Utilities::trimIconFromInfo(plgsys->plugin(info.pluginIndex), info), - Utilities::getProgramName(info)); - item->setToolTip(info.process); + auto plg = plgsys->plugin(info.pluginIndex); + auto item = new QListWidgetItem(Utilities::trimIconFromInfo(plg, info), + Utilities::getProgramName(plg, info)); + item->setToolTip(Utilities::getToolTipContent(plg, info)); lstoolwin->addItem(item); wintool.addItem(info); } @@ -935,6 +975,7 @@ void CenterWindow::initGeneralSettings() { sm->sigToolGridSizeChanged(sm->toolGridSize()); connect(sbGridsize, QOverload::of(&DSpinBox::valueChanged), sm, &SettingManager::setToolGridSize); + connect(tabs, &DTabWidget::currentChanged, this, [=] { sm->saveSettings(); }); // WinTool 相关 wintool.setModal(true); @@ -1077,13 +1118,20 @@ void CenterWindow::initAppManger() { } void CenterWindow::getConfig(QDataStream &f) { + QVector plgindices; + // 先保存 Hotkey 的相关信息 f << hotkeys.count(); // 先存一下有几个 for (auto &p : scinfos) { f << p.enabled << p.isPlugin << p.seq; if (p.isPlugin) { - f << p.serviceID << p.provider.toUtf8() << p.params.toUtf8() - << plgsys->pluginHash(p.pluginIndex); //最后存储 MD5 表示一条信息结束了 + f << p.serviceID << p.provider.toUtf8() << p.params.toUtf8(); + auto i = plgindices.indexOf(p.pluginIndex); + if (i >= 0) { + f << true << i; + } else { + f << false << plgsys->pluginHash(p.pluginIndex); + } } else { f << p.process.toUtf8() << p.params.toUtf8(); // 如果是打开文件就没这么多事情了 @@ -1100,9 +1148,13 @@ void CenterWindow::getConfig(QDataStream &f) { if (p.enabled) { f << p.isPlugin; if (p.isPlugin) { - f << p.serviceID << p.provider.toUtf8() << p.params.toUtf8() - << plgsys->pluginHash( - p.pluginIndex); //最后存储 MD5 表示一条信息结束了 + f << p.serviceID << p.provider.toUtf8() << p.params.toUtf8(); + auto i = plgindices.indexOf(p.pluginIndex); + if (i >= 0) { + f << true << i; + } else { + f << false << plgsys->pluginHash(p.pluginIndex); + } } else { f << p.process.toUtf8() << p.params.toUtf8(); // 如果是打开文件就没这么多事情了 @@ -1117,8 +1169,13 @@ void CenterWindow::getConfig(QDataStream &f) { // 只存储相关基础信息就可以了 f << p.isPlugin; if (p.isPlugin) { - f << p.serviceID << p.provider.toUtf8() << p.params.toUtf8() - << plgsys->pluginHash(p.pluginIndex); //最后存储 MD5 表示一条信息结束了 + f << p.serviceID << p.provider.toUtf8() << p.params.toUtf8(); + auto i = plgindices.indexOf(p.pluginIndex); + if (i >= 0) { + f << true << i; + } else { + f << false << plgsys->pluginHash(p.pluginIndex); + } } else { f << p.process.toUtf8() << p.params.toUtf8(); // 如果是打开文件就没这么多事情了 @@ -1128,7 +1185,26 @@ void CenterWindow::getConfig(QDataStream &f) { // 保存完毕,可以返回了 } +void CenterWindow::resetConfig() { + ToolStructInfo toolinfo; + for (auto i = 0; i < 9; i++) { + toolinfos[i] = toolinfo; + QIcon icon; + auto ilbl = lbls[i]; + ilbl->setIcon(icon); + manager->setToolIcon(i, icon); + } + lstoolwin->clear(); + wintoolinfos.clear(); + wintool.rmItem(-1); +} + void CenterWindow::closeEvent(QCloseEvent *event) { event->ignore(); hide(); } + +void CenterWindow::showEvent(QShowEvent *event) { + Q_UNUSED(event); + sm->saveSettings(); +} diff --git a/dialog/centerwindow.h b/dialog/centerwindow.h index ecafe04..baac373 100644 --- a/dialog/centerwindow.h +++ b/dialog/centerwindow.h @@ -72,9 +72,11 @@ public slots: void initPluginSys(); void initAppManger(); void getConfig(QDataStream &f); + void resetConfig(); protected: void closeEvent(QCloseEvent *event) override; + void showEvent(QShowEvent *event) override; private: QList hkcmenu, lscmenu; diff --git a/dialog/toolboxwindow.cpp b/dialog/toolboxwindow.cpp index 1005b2d..e2f357d 100644 --- a/dialog/toolboxwindow.cpp +++ b/dialog/toolboxwindow.cpp @@ -44,7 +44,10 @@ void ToolBoxWindow::addItem(ToolStructInfo &info, int index) { auto plgsys = PluginSystem::instance(); auto plg = plgsys->plugin(info.pluginIndex); auto icon = Utilities::trimIconFromInfo(plg, info); - QString content = tr("Process:") + Utilities::getProgramName(info) + '\n'; + QString content = + tr("Process:") + + (info.isPlugin ? info.process : QFileInfo(info.process).fileName()) + + '\n'; if (info.isPlugin) content += (tr("Service:") + plg->pluginServices()[info.serviceID]); diff --git a/dialog/tooleditdialog.h b/dialog/tooleditdialog.h index 84a92da..a121f07 100644 --- a/dialog/tooleditdialog.h +++ b/dialog/tooleditdialog.h @@ -17,9 +17,10 @@ DWIDGET_USE_NAMESPACE class ToolEditDialog : public DDialog { + Q_OBJECT public: ToolEditDialog(ToolStructInfo res = ToolStructInfo(), - DMainWindow *parent = nullptr); + DMainWindow *parent = nullptr); ToolStructInfo getResult(); // 这里的 enabled 和 seq 保留不使用 private: diff --git a/dialog/toolswapdialog.h b/dialog/toolswapdialog.h index 8ec6f9a..93054fb 100644 --- a/dialog/toolswapdialog.h +++ b/dialog/toolswapdialog.h @@ -9,6 +9,7 @@ DWIDGET_USE_NAMESPACE class ToolSwapDialog : public DDialog { + Q_OBJECT public: ToolSwapDialog(const QVector &icons, int selindex, DDialog *parent = nullptr); diff --git a/images/README.md b/images/README.md new file mode 100644 index 0000000..174f3c0 --- /dev/null +++ b/images/README.md @@ -0,0 +1,13 @@ +## WingTool + +  `WingTool`是一个强大的插件工具箱,中文名`羽云工具箱`,支持热键响应、鼠标跟踪、选词等相关借口。通过开发强大的对应的插件,就可以大大提高生产力。 + +  该软件如果没有任何插件,仅支持添加热键使用默认方式打开任何文件。插件的强大决定着该软件的上限,通过热键可以配置使用热键调用插件借口;默认通过鼠标中键配合`Ctrl`键可以调出工具窗口,选择合适的工具;也可以通过热键调出窗口工具,点击打开所需的文件或者软件,而不必从启动器翻找,避免任务栏图标过多以及桌面文件过多的情况。 + +### 协议 + +  本软件如果是开源版本将遵循`AGPL-3.0`协议,请勿用于该协议之外的用途。如果你想将本软件的代码用于闭源的商业代码,想要解除`GPL`系列的必须开源的限制,请必须亲自咨询我,商讨商业授权相关事宜。 + +## 有关 issue + +  本软件定位是本地生产力基础工具,旨在快速启动和使用高效工具。本人不考虑像 utool 和 quicker 之类提供插件商店。该程序不会进行与网络相关的任何操作,所有的插件安装都是本地的。如果有仅本地的需要,待该软件出 beta 之后,可以尝试该软件,发现 Bug 并递交修复。 diff --git a/lang/zh.qm b/lang/zh.qm new file mode 100644 index 0000000..2ab697c Binary files /dev/null and b/lang/zh.qm differ diff --git a/lang/zh.ts b/lang/zh.ts new file mode 100644 index 0000000..9f38bc6 --- /dev/null +++ b/lang/zh.ts @@ -0,0 +1,677 @@ + + + + + CenterWindow + + + + CenterWindow + 羽云工具箱 + + + + Common + 通用 + + + + EnabledToolWin + 启用工具窗体 + + + + EnabledWinTool + 启用窗体工具 + + + + ToolWinGridSize + 工具窗格大小 + + + + Shortcut + 快捷键 + + + + ToolBox: + 窗口工具调用: + + + + Left + 左键 + + + + Right + 右键 + + + + Middle + 中键 + + + + XButton1 + XButton1 + + + + XButton2 + XButton2 + + + + ToolWin: + 工具窗体: + + + + Config + 配置 + + + + Export + 导出 + + + + Import + 导入 + + + + Save + 保存 + + + + Reset + 重置 + + + + Software + 软件 + + + + %1 , Ver %2 , by WingSummer. + %1,版本:%2,由寂静的羽夏编写。 + + + + General + 常规 + + + + + + + Add + 添加 + + + + + + + Remove + 删除 + + + + + + + + Edit + 编辑 + + + + + + + Clear + 清空 + + + + + Enable + 启用 + + + + HotKey + 热键 + + + + Exec + 执行 + + + + Params + 参数 + + + + Disable + 禁用 + + + + Hotkeys + 热键 + + + + [Plugin] + 【插件】 + + + + Service: + 服务: + + + + + Params: + 参数: + + + + + NoTool + 暂无工具相关信息…… + + + + [File] + 【文件】 + + + + FileName: + 文件名: + + + + Swap + 交换 + + + + Delete + 删除 + + + + + Up + 上移 + + + + + Down + 下移 + + + + TopMost + 置顶 + + + + DownMost + 置底 + + + + ToolBox + 工具箱 + + + + + No selected plugin. + 没有选择插件,故无法显示插件信息。 + + + + Setting + 设置 + + + + Name: + 名称: + + + + RegisteredHotkey: + 注册的热键: + + + + Plugins + 插件 + + + + About + 关于 + + + + ThanksForSponsor + 感谢大家的赞助和支持! + + + + Sponsor + 赞助 + + + + runErr + 执行失败 + + + + err + 错误 + + + + openErr + 打开失败! + + + + + ClearSuccess + 数据清空完毕 + + + + HotkeyRegisterFail + 注册热键失败! + + + + PleaseSelectOne + 请选择一个项目 + + + + + Config (*.wtcfg) + 羽云工具箱配置文件 (*.wtcfg) + + + + ExportSuccess + 导出成功! + + + + ImportSuccess + 倒入成功! + + + + PluginSelDialog + + + PluginSelectingDialog + 插件选择 + + + + No selected plugin. + 请选择一个插件,以显示该插件的信息。 + + + + Name: + 名称: + + + + Select + 选择 + + + + NoSelection + 没有选择插件! + + + + NoPlugin + 无插件 + + + + Cancel + 取消 + + + + PluginSystem + + + ErrLoadPluginSign + 由于插件签名不正确,插件加载失败! + + + + ErrLoadPluginSDKVersion + 由于插件 SDK 版本不匹配,插件加载失败! + + + + ErrLoadPluginNoName + 由于插件没有名称,插件加载失败! + + + + ErLoadPluginProvider + 由于插件没有合法提供者,插件加载失败! + + + + + ErLoadPluginService + 由于插件没有服务,插件加载失败! + + + + ErrLoadInitPlugin + 由于插件初始化失败,插件加载失败! + + + + PluginInitRegister + 插件注册开始 + + + + ErrLoadPluginLoc + 插件加载失败错误位置: + + + + QHotkey + + + Failed to register %1. Error: %2 + 注册失败: %1. ,错误码: %2 + + + + Failed to unregister %1. Error: %2 + 卸载失败: %1. ,错误码: %2 + + + + QObject + + + PluginName: + 插件名: + + + + + + Catagory: + 分类: + + + + + Version: + 版本: + + + + + + Author: + 作者: + + + + + + Comment: + 说明: + + + + + + Provider: + 提供者: + + + + + Services: + 服务: + + + + Version + 版本 + + + + + WingTool + 羽云工具箱 + + + + ShowMain + 显示主窗体 + + + + About + 关于 + + + + Sponsor + 赞助 + + + + + Exit + 退出 + + + + ConfirmExit + 你确认继续关闭该程序吗? + + + + Process:%1 +Service:%2 +Params:%3 + 进程:%1 +服务:%2 +参数:%3 + + + + Process:%1 +Params:%2 + 进程:%1 +参数:%2 + + + + ShortCutEditDialog + + + HotkeyEdit + 编辑热键 + + + + Enabled + 启用 + + + + ShortCut + 快捷键 + + + + Plugin + 插件 + + + + + Service + 服务 + + + + + FilePath + 文件路径 + + + + Param + 参数 + + + + NoHotkeySet + 没有设置热键 + + + + NoProcessSet + 没有设置进程 + + + + ToolBoxWindow + + + PleaseChoose + 请选择 + + + + Process: + 进程: + + + + Service: + 服务:服务: + + + + Params: + 参数: + + + + ToolEditDialog + + + ToolWinEdit + 工具设置 + + + + Plugin + 插件 + + + + + Service + 服务 + + + + + FilePath + 文件路径 + + + + Param + 参数 + + + + NoProcessSet + 没有设置进程 + + + + ToolSwapDialog + + + ToolSwapDialog + 工具交换 + + + + PleaseSelect + 请选择 + + + + NoSelect + 未选择被交换工具对象 + + + + WingApplication + + + + Error + 错误 + + + + + WriteErrorLogError + 写入日志错误! + + + + + Crash + 崩溃 + + + diff --git a/main.cpp b/main.cpp index 5939426..eb4a49e 100644 --- a/main.cpp +++ b/main.cpp @@ -38,15 +38,14 @@ int main(int argc, char *argv[]) { WingApplication a(fakeArgc, fakeArgs.data()); QCoreApplication::setAttribute(Qt::AA_UseOpenGLES); - // auto s = a.applicationDirPath() + "/lang/default.qm"; - // QTranslator translator; - // if (!translator.load(s)) { - // DMessageBox::critical(nullptr, "Error", "Error Loading Translation - // File!", - // DMessageBox::Ok); - // return -1; - // } - // a.installTranslator(&translator); + auto s = a.applicationDirPath() + "/lang/default.qm"; + QTranslator translator; + if (!translator.load(s)) { + DMessageBox::critical(nullptr, "Error", "Error Loading Translation File !", + DMessageBox::Ok); + return -1; + } + a.installTranslator(&translator); a.setOrganizationName("WingCloud"); a.setApplicationName(QObject::tr("WingTool")); @@ -103,6 +102,9 @@ int main(int argc, char *argv[]) { &CenterWindow::addWinToolInfo); QObject::connect(&sm, &SettingManager::sigSaveConfig, &w, &CenterWindow::getConfig); + QObject::connect(&sm, &SettingManager::sigReset, &w, + &CenterWindow::resetConfig); + sm.loadSettings(); QObject::connect(&manager, &AppManager::checkToolShow, @@ -132,9 +134,16 @@ int main(int argc, char *argv[]) { [&w] { w.show(CenterWindow::TabPage::Sponsor); }); sysmenu.addAction(ac); ac = new QAction(QObject::tr("Exit"), menu); - QObject::connect(ac, &QAction::triggered, [] { QApplication::exit(0); }); + QObject::connect(ac, &QAction::triggered, [&w, &sm] { + if (DMessageBox::question(&w, QObject::tr("Exit"), + QObject::tr("ConfirmExit")) == DMessageBox::Yes) { + sm.saveSettings(); + QApplication::exit(0); + } + }); sysmenu.addAction(ac); systray.setContextMenu(menu); + systray.setToolTip(QObject::tr("WingTool")); systray.setIcon(picon); systray.show(); diff --git a/resources.qrc b/resources.qrc index 0df6835..095006a 100644 --- a/resources.qrc +++ b/resources.qrc @@ -12,5 +12,6 @@ images/edit.svg images/up.svg images/swap.svg + images/README.md diff --git a/utilities.h b/utilities.h index d2af620..c4efded 100644 --- a/utilities.h +++ b/utilities.h @@ -123,8 +123,23 @@ public: } } - static QString getProgramName(ToolStructInfo &info) { - return info.isPlugin ? info.process : QFileInfo(info.process).fileName(); + static QString getProgramName(IWingToolPlg *plg, ToolStructInfo &info) { + return info.isPlugin + ? info.process + " | " + plg->pluginServices()[info.serviceID] + : QFileInfo(info.process).fileName(); + } + + static QString getToolTipContent(IWingToolPlg *plg, ToolStructInfo &info) { + if (info.isPlugin) { + return QObject::tr("Process:%1\nService:%2\nParams:%3") + .arg(info.process) + .arg(plg->pluginServices()[info.serviceID]) + .arg(info.params); + } else { + return QObject::tr("Process:%1\nParams:%2") + .arg(info.process) + .arg(info.params); + } } };