update
This commit is contained in:
parent
03dc3b332e
commit
89b2903f68
|
@ -21,8 +21,8 @@
|
|||
|
||||
  现在工具处于开发状态,很多功能并没有完成:
|
||||
|
||||
1. 配置相关(已完成 80%)
|
||||
2. 窗口工具(已完成 10%)
|
||||
1. 配置相关(已完成 90%)
|
||||
2. 窗口工具(已完成 40%)
|
||||
3. 语言本地化(已完成 0%)
|
||||
4. 软件 UI 相关(已完成 90%)
|
||||
|
||||
|
|
|
@ -25,7 +25,9 @@ SOURCES += \
|
|||
control/pluginselector.cpp \
|
||||
dialog/pluginseldialog.cpp \
|
||||
dialog/tooleditdialog.cpp \
|
||||
class/hotkey.cpp
|
||||
class/hotkey.cpp \
|
||||
dialog/toolswapdialog.cpp \
|
||||
control/wintoolitem.cpp
|
||||
RESOURCES += resources.qrc
|
||||
|
||||
HEADERS += \
|
||||
|
@ -45,4 +47,6 @@ HEADERS += \
|
|||
dialog/pluginseldialog.h \
|
||||
utilities.h \
|
||||
dialog/tooleditdialog.h \
|
||||
class/hotkey.h
|
||||
class/hotkey.h \
|
||||
dialog/toolswapdialog.h \
|
||||
control/wintoolitem.h
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "class/eventmonitor.h"
|
||||
#include "class/hotkey.h"
|
||||
#include "dialog/toolboxwindow.h"
|
||||
#include "dialog/toolwindow.h"
|
||||
#include "utilities.h"
|
||||
#include <QList>
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
SettingManager *SettingManager::m_instance = nullptr;
|
||||
|
||||
SettingManager::SettingManager(QObject *parent)
|
||||
: QObject(parent), m_toolGridSize(TOOLGRIDSIZE),
|
||||
: QObject(parent), m_toolwin(true), m_wintool(true),
|
||||
m_toolGridSize(TOOLGRIDSIZE),
|
||||
m_toolBox(
|
||||
QKeySequence(Qt::KeyboardModifier::ShiftModifier | Qt::Key_Space)),
|
||||
m_toolwinMod(Qt::KeyboardModifier::ControlModifier),
|
||||
|
@ -17,12 +18,15 @@ SettingManager::SettingManager(QObject *parent)
|
|||
|
||||
SettingManager *SettingManager::instance() { return m_instance; }
|
||||
|
||||
bool SettingManager::loadSettings() {
|
||||
QString strConfigPath =
|
||||
QString("%1/%2/%3/config.conf")
|
||||
.arg(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation))
|
||||
.arg(qApp->organizationName())
|
||||
.arg(qApp->applicationName());
|
||||
bool SettingManager::loadSettings(QString filename) {
|
||||
|
||||
QString strConfigPath = filename.isEmpty()
|
||||
? QString("%1/%2/%3/config.conf")
|
||||
.arg(QStandardPaths::writableLocation(
|
||||
QStandardPaths::ConfigLocation))
|
||||
.arg(qApp->organizationName())
|
||||
.arg(qApp->applicationName())
|
||||
: filename;
|
||||
|
||||
QFile f(strConfigPath);
|
||||
QDataStream stream(&f);
|
||||
|
@ -39,7 +43,8 @@ bool SettingManager::loadSettings() {
|
|||
auto plgsys = PluginSystem::instance();
|
||||
|
||||
// General
|
||||
stream >> m_toolGridSize >> m_toolBox >> m_toolwinMod >> m_toolMouse;
|
||||
stream >> m_toolwin >> m_wintool >> m_toolGridSize >> m_toolBox >>
|
||||
m_toolwinMod >> m_toolMouse;
|
||||
|
||||
// 读取结束,提示可以加载基础配置内容了
|
||||
emit loadedGeneral();
|
||||
|
@ -175,7 +180,8 @@ bool SettingManager::exportSettings(QString filename) {
|
|||
static char header[] = "WINGTOOL";
|
||||
stream.writeRawData(header, 8);
|
||||
// General
|
||||
stream << m_toolGridSize << m_toolBox << m_toolwinMod << m_toolMouse;
|
||||
stream << m_toolwin << m_wintool << m_toolGridSize << m_toolBox
|
||||
<< m_toolwinMod << m_toolMouse;
|
||||
// 有些配置直接保存到 CenterWindow 里面了,为了减少内存占用
|
||||
emit sigSaveConfig(stream);
|
||||
// 至此,保存完毕
|
||||
|
@ -185,6 +191,8 @@ bool SettingManager::exportSettings(QString filename) {
|
|||
return false;
|
||||
}
|
||||
|
||||
void SettingManager::resetSettings() {}
|
||||
|
||||
int SettingManager::toolGridSize() const { return m_toolGridSize; }
|
||||
|
||||
void SettingManager::setToolGridSize(const int v) {
|
||||
|
@ -205,10 +213,26 @@ Qt::KeyboardModifier SettingManager::toolwinMod() const { return m_toolwinMod; }
|
|||
|
||||
void SettingManager::setToolwinMod(const Qt::KeyboardModifier &toolwinMod) {
|
||||
m_toolwinMod = toolwinMod;
|
||||
emit sigToolwinModChanged(toolwinMod);
|
||||
}
|
||||
|
||||
Qt::MouseButton SettingManager::toolwinMouseBtn() const { return m_toolMouse; }
|
||||
|
||||
void SettingManager::setToolMouseBtn(const Qt::MouseButton &toolMouse) {
|
||||
m_toolMouse = toolMouse;
|
||||
emit sigToolwinMouseBtnChanged(toolMouse);
|
||||
}
|
||||
|
||||
bool SettingManager::toolwinEnabled() const { return m_toolwin; }
|
||||
|
||||
void SettingManager::setToolwinEnabled(bool toolwin) {
|
||||
m_toolwin = toolwin;
|
||||
emit sigToolwinEnabledChanged(toolwin);
|
||||
}
|
||||
|
||||
bool SettingManager::wintoolEnabled() const { return m_wintool; }
|
||||
|
||||
void SettingManager::setWintoolEnabled(bool wintool) {
|
||||
m_wintool = wintool;
|
||||
emit sigWintoolEnabledChanged(wintool);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ public:
|
|||
static SettingManager *instance();
|
||||
|
||||
public:
|
||||
bool loadSettings();
|
||||
bool loadSettings(QString filename = QString());
|
||||
bool saveSettings();
|
||||
bool exportSettings(QString filename);
|
||||
void resetSettings();
|
||||
|
@ -34,13 +34,20 @@ public:
|
|||
Qt::MouseButton toolwinMouseBtn() const;
|
||||
void setToolMouseBtn(const Qt::MouseButton &toolwinMouseBtn);
|
||||
|
||||
bool toolwinEnabled() const;
|
||||
void setToolwinEnabled(bool toolwinEnabled);
|
||||
|
||||
bool wintoolEnabled() const;
|
||||
void setWintoolEnabled(bool wintoolEnabled);
|
||||
|
||||
signals:
|
||||
void sigToolwinEnabledChanged(bool b);
|
||||
void sigWintoolEnabledChanged(bool b);
|
||||
void sigToolGridSizeChanged(int v);
|
||||
void loadedGeneral();
|
||||
void sigToolBoxHotkeyChanged(const QKeySequence seq);
|
||||
void sigToolWinShortCutChanged(const Qt::KeyboardModifier mod,
|
||||
const Qt::MouseButton btn);
|
||||
|
||||
void sigToolwinModChanged(const Qt::KeyboardModifier mod);
|
||||
void sigToolwinMouseBtnChanged(const Qt::MouseButton btn);
|
||||
void sigSaveConfig(QDataStream &stream);
|
||||
|
||||
// 配置添加信号
|
||||
|
@ -51,6 +58,7 @@ signals:
|
|||
private:
|
||||
static SettingManager *m_instance;
|
||||
|
||||
bool m_toolwin, m_wintool;
|
||||
int m_toolGridSize;
|
||||
|
||||
QKeySequence m_toolBox;
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
#include "wintoolitem.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
WinToolItem::WinToolItem(QWidget *parent) : QWidget(parent) {
|
||||
setFixedHeight(30);
|
||||
auto layout = new QHBoxLayout(this);
|
||||
lbl = new DLabel(this);
|
||||
lbl->setFixedSize(25, 25);
|
||||
lbl->setScaledContents(true);
|
||||
layout->addWidget(lbl);
|
||||
auto ilayout = new QVBoxLayout(this);
|
||||
layout->addLayout(ilayout, 1);
|
||||
m_name = new DLabel(this);
|
||||
ilayout->addWidget(m_name);
|
||||
m_srv = new DLabel(this);
|
||||
ilayout->addWidget(m_srv);
|
||||
m_param = new DLabel(this);
|
||||
ilayout->addWidget(m_param);
|
||||
}
|
||||
|
||||
WinToolItem::WinToolItem(const QPixmap pix, const QString &name,
|
||||
const QString &srv, const QString ¶ms,
|
||||
QWidget *parent)
|
||||
: QWidget(parent) {
|
||||
setFixedHeight(30);
|
||||
auto layout = new QHBoxLayout(this);
|
||||
lbl = new DLabel(this);
|
||||
lbl->setPixmap(pix);
|
||||
lbl->setFixedSize(25, 25);
|
||||
lbl->setScaledContents(true);
|
||||
layout->addWidget(lbl);
|
||||
auto ilayout = new QVBoxLayout(this);
|
||||
layout->addLayout(ilayout, 1);
|
||||
m_name = new DLabel(name, this);
|
||||
ilayout->addWidget(m_name);
|
||||
m_srv = new DLabel(srv, this);
|
||||
ilayout->addWidget(m_srv);
|
||||
m_param = new DLabel(params, this);
|
||||
ilayout->addWidget(m_param);
|
||||
}
|
||||
|
||||
void WinToolItem::setIcon(QPixmap pix) { lbl->setPixmap(pix); }
|
||||
|
||||
void WinToolItem::setName(const QString &name) { m_name->setText(name); }
|
||||
|
||||
void WinToolItem::setSrvName(const QString &srv) { m_srv->setText(srv); }
|
||||
|
||||
void WinToolItem::setParams(const QString ¶ms) { m_param->setText(params); }
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef WINTOOLITEM_H
|
||||
#define WINTOOLITEM_H
|
||||
|
||||
#include <DLabel>
|
||||
#include <QPixmap>
|
||||
#include <QWidget>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
class WinToolItem : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit WinToolItem(QWidget *parent = nullptr);
|
||||
explicit WinToolItem(const QPixmap pix, const QString &name,
|
||||
const QString &srv, const QString ¶ms,
|
||||
QWidget *parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void setIcon(const QPixmap pix);
|
||||
void setName(const QString &name);
|
||||
void setSrvName(const QString &srv);
|
||||
void setParams(const QString ¶ms);
|
||||
|
||||
private:
|
||||
DLabel *lbl, *m_name, *m_srv, *m_param;
|
||||
};
|
||||
|
||||
#endif // WINTOOLITEM_H
|
|
@ -1,12 +1,15 @@
|
|||
#include "centerwindow.h"
|
||||
#include "shortcuteditdialog.h"
|
||||
#include "tooleditdialog.h"
|
||||
#include "toolswapdialog.h"
|
||||
#include <DButtonBox>
|
||||
#include <DFileDialog>
|
||||
#include <DLabel>
|
||||
#include <DMessageBox>
|
||||
#include <DMessageManager>
|
||||
#include <DTextBrowser>
|
||||
#include <DTitlebar>
|
||||
#include <DWidgetUtil>
|
||||
#include <QButtonGroup>
|
||||
#include <QCloseEvent>
|
||||
#include <QDesktopServices>
|
||||
|
@ -53,14 +56,8 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) {
|
|||
auto hlayout = new QHBoxLayout(gw);
|
||||
vlayout->addLayout(hlayout);
|
||||
cbToolWin = new DCheckBox(tr("EnabledToolWin"), this);
|
||||
connect(cbToolWin, &DCheckBox::toggled, this, [=](bool v) {
|
||||
|
||||
});
|
||||
hlayout->addWidget(cbToolWin);
|
||||
cbWinTool = new DCheckBox(tr("EnabledWinTool"), this);
|
||||
connect(cbWinTool, &DCheckBox::toggled, this, [=](bool v) {
|
||||
|
||||
});
|
||||
hlayout->addWidget(cbWinTool);
|
||||
gw = new QWidget(w);
|
||||
vlayout->addWidget(gw);
|
||||
|
@ -70,10 +67,6 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) {
|
|||
sbGridsize = new DSpinBox(w);
|
||||
sbGridsize->setRange(30, 60);
|
||||
sbGridsize->setValue(40); // 默认 40 先
|
||||
connect(sbGridsize, QOverload<int>::of(&DSpinBox::valueChanged), this,
|
||||
[=](int v) {
|
||||
|
||||
});
|
||||
hlayout->addWidget(sbGridsize, 1);
|
||||
|
||||
vlayout->addSpacing(10);
|
||||
|
@ -85,10 +78,6 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) {
|
|||
vlayout->addWidget(gw);
|
||||
auto flayout = new QFormLayout(gw);
|
||||
kseqTool = new DKeySequenceEdit(gw);
|
||||
connect(kseqTool, &DKeySequenceEdit::editingFinished, this,
|
||||
[=](const QKeySequence &keySequence) {
|
||||
|
||||
});
|
||||
flayout->addRow(tr("ToolBox:"), kseqTool);
|
||||
hlayout = new QHBoxLayout(gw);
|
||||
cbMod = new DComboBox(gw);
|
||||
|
@ -110,19 +99,16 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) {
|
|||
auto group = new DButtonBox(this);
|
||||
QList<DButtonBoxButton *> blist;
|
||||
auto b = new DButtonBoxButton(tr("Export"), this);
|
||||
connect(b, &DButtonBoxButton::clicked, this, [=] {
|
||||
|
||||
});
|
||||
connect(b, &DButtonBoxButton::clicked, this,
|
||||
[=] { this->on_exportSettings(); });
|
||||
blist.append(b);
|
||||
b = new DButtonBoxButton(tr("Import"), this);
|
||||
connect(b, &DButtonBoxButton::clicked, this, [=] {
|
||||
|
||||
});
|
||||
connect(b, &DButtonBoxButton::clicked, this,
|
||||
[=] { this->on_importSettings(); });
|
||||
blist.append(b);
|
||||
b = new DButtonBoxButton(tr("Reset"), this);
|
||||
connect(b, &DButtonBoxButton::clicked, this, [=] {
|
||||
|
||||
});
|
||||
connect(b, &DButtonBoxButton::clicked, this,
|
||||
[=] { this->on_resetSettings(); });
|
||||
blist.append(b);
|
||||
group->setButtonList(blist, false);
|
||||
vlayout->addWidget(group);
|
||||
|
@ -232,7 +218,6 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) {
|
|||
mlayout->setSpacing(1);
|
||||
auto btngs = new QButtonGroup(w);
|
||||
btngs->setExclusive(true); // 设置按钮选中互斥
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
auto lbl = new DIconButton(this);
|
||||
lbl->setFixedSize(gridsize - 2, gridsize - 2);
|
||||
|
@ -254,7 +239,6 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) {
|
|||
auto e = QMetaEnum::fromType<IWingToolPlg::Catagorys>();
|
||||
|
||||
tbtoolinfo->setText(tr("[Plugin]"));
|
||||
tbtoolinfo->append("");
|
||||
tbtoolinfo->append(QObject::tr("PluginName:") + plg->pluginName());
|
||||
tbtoolinfo->append(tr("Service:") +
|
||||
plg->pluginServices()[info.serviceID]);
|
||||
|
@ -276,7 +260,6 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) {
|
|||
} else {
|
||||
if (info.enabled) {
|
||||
tbtoolinfo->setText(tr("[File]"));
|
||||
tbtoolinfo->append("");
|
||||
tbtoolinfo->append(tr("FileName:") + info.process);
|
||||
tbtoolinfo->append(tr("Params:") + info.params);
|
||||
} else {
|
||||
|
@ -299,22 +282,51 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) {
|
|||
|
||||
group = new DButtonBox(this);
|
||||
blist.clear(); // 重新征用
|
||||
b = new DButtonBoxButton(tr("Edit"), this);
|
||||
b = new DButtonBoxButton(ICONRES2("edit"));
|
||||
b->setParent(this);
|
||||
b->setIconSize(QSize(20, 20));
|
||||
b->setToolTip(tr("Edit"));
|
||||
connect(b, &DButtonBoxButton::clicked, this, [=] {
|
||||
ToolEditDialog d(toolinfos[sellbl]);
|
||||
if (d.exec()) {
|
||||
auto res = d.getResult();
|
||||
toolinfos[sellbl] = res;
|
||||
auto icon =
|
||||
Utilities::trimIconFromInfo(plgsys->plugin(res.pluginIndex), res);
|
||||
auto ilbl = lbls[sellbl];
|
||||
ilbl->setIcon(icon);
|
||||
manager->setToolIcon(sellbl, icon);
|
||||
emit ilbl->toggled(true);
|
||||
this->setoolWinInfo(sellbl, res);
|
||||
emit lbls[sellbl]->toggled(true);
|
||||
}
|
||||
});
|
||||
blist.append(b);
|
||||
b = new DButtonBoxButton(tr("Delete"), this);
|
||||
b = new DButtonBoxButton(ICONRES2("swap"));
|
||||
b->setParent(this);
|
||||
b->setIconSize(QSize(20, 20));
|
||||
b->setToolTip(tr("Swap"));
|
||||
connect(b, &DButtonBoxButton::clicked, this, [=] {
|
||||
QVector<QIcon> icons;
|
||||
for (auto i = 0; i < 9; i++) {
|
||||
icons.append(lbls[i]->icon());
|
||||
}
|
||||
|
||||
ToolSwapDialog d(icons, this->sellbl);
|
||||
auto res = d.exec();
|
||||
if (res >= 0) {
|
||||
auto tmp = toolinfos[sellbl];
|
||||
toolinfos[sellbl] = toolinfos[res];
|
||||
toolinfos[res] = tmp;
|
||||
|
||||
auto icon1 = lbls[sellbl]->icon();
|
||||
auto icon2 = lbls[res]->icon();
|
||||
lbls[sellbl]->setIcon(icon2);
|
||||
lbls[res]->setIcon(icon1);
|
||||
|
||||
manager->setToolIcon(sellbl, icon2);
|
||||
manager->setToolIcon(res, icon1);
|
||||
lbls[res]->setChecked(true);
|
||||
}
|
||||
});
|
||||
blist.append(b);
|
||||
b = new DButtonBoxButton(ICONRES2("del"));
|
||||
b->setParent(this);
|
||||
b->setIconSize(QSize(20, 20));
|
||||
b->setToolTip(tr("Delete"));
|
||||
connect(b, &DButtonBoxButton::clicked, this, [=] {
|
||||
toolinfos[sellbl].enabled = false;
|
||||
auto ilbl = lbls[sellbl];
|
||||
|
@ -637,8 +649,7 @@ void CenterWindow::on_editToolWin() {
|
|||
auto item = lstoolwin->item(index);
|
||||
item->setIcon(
|
||||
Utilities::trimIconFromInfo(plgsys->plugin(res.pluginIndex), res));
|
||||
item->setText(res.isPlugin ? res.process
|
||||
: QFileInfo(res.process).fileName());
|
||||
item->setText(Utilities::getProgramName(res));
|
||||
item->setToolTip(res.process);
|
||||
}
|
||||
}
|
||||
|
@ -675,7 +686,7 @@ void CenterWindow::on_addToolWin() {
|
|||
wintoolinfos.append(res);
|
||||
auto item = new QListWidgetItem(
|
||||
Utilities::trimIconFromInfo(plgsys->plugin(res.pluginIndex), res),
|
||||
res.isPlugin ? res.process : QFileInfo(res.process).fileName());
|
||||
Utilities::getProgramName(res));
|
||||
item->setToolTip(res.process);
|
||||
lstoolwin->addItem(item);
|
||||
} else {
|
||||
|
@ -683,7 +694,7 @@ void CenterWindow::on_addToolWin() {
|
|||
|
||||
auto item = new QListWidgetItem(
|
||||
Utilities::trimIconFromInfo(plgsys->plugin(res.pluginIndex), res),
|
||||
res.isPlugin ? res.process : QFileInfo(res.process).fileName());
|
||||
Utilities::getProgramName(res));
|
||||
item->setToolTip(res.process);
|
||||
lstoolwin->insertItem(index + 1, item);
|
||||
}
|
||||
|
@ -694,6 +705,32 @@ void CenterWindow::on_upToolWin() {}
|
|||
|
||||
void CenterWindow::on_downToolWin() {}
|
||||
|
||||
void CenterWindow::on_exportSettings() {
|
||||
auto path = DFileDialog::getSaveFileName(this, tr(""), QString(),
|
||||
tr("Config (*.wtcfg)"));
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
|
||||
if (sm->exportSettings(path)) {
|
||||
DMessageManager::instance()->sendMessage(this, ProgramIcon,
|
||||
tr("ExportSuccess"));
|
||||
}
|
||||
}
|
||||
|
||||
void CenterWindow::on_importSettings() {
|
||||
auto path = DFileDialog::getOpenFileName(this, tr(""), QString(),
|
||||
tr("Config (*.wtcfg)"));
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
|
||||
if (sm->loadSettings(path)) {
|
||||
DMessageManager::instance()->sendMessage(this, ProgramIcon,
|
||||
tr("ImportSuccess"));
|
||||
}
|
||||
}
|
||||
|
||||
void CenterWindow::on_resetSettings() { sm->resetSettings(); }
|
||||
|
||||
void CenterWindow::addHotKeyInfo(ToolStructInfo &info) {
|
||||
// 添加 UI 项目
|
||||
auto index = tbhotkeys->rowCount();
|
||||
|
@ -719,68 +756,149 @@ void CenterWindow::addHotKeyInfo(ToolStructInfo &info) {
|
|||
}
|
||||
|
||||
void CenterWindow::setoolWinInfo(int index, ToolStructInfo &info) {
|
||||
if (index >= 4)
|
||||
index++;
|
||||
toolinfos[index] = info;
|
||||
|
||||
// 更新 UI
|
||||
// TODO
|
||||
auto icon =
|
||||
Utilities::trimIconFromInfo(plgsys->plugin(info.pluginIndex), info);
|
||||
auto ilbl = lbls[sellbl];
|
||||
ilbl->setIcon(icon);
|
||||
manager->setToolIcon(sellbl, icon);
|
||||
}
|
||||
|
||||
void CenterWindow::addWinToolInfo(ToolStructInfo &info) {
|
||||
wintoolinfos << info;
|
||||
auto item = new QListWidgetItem(
|
||||
Utilities::trimIconFromInfo(plgsys->plugin(info.pluginIndex), info),
|
||||
info.isPlugin ? info.process : QFileInfo(info.process).fileName());
|
||||
Utilities::getProgramName(info));
|
||||
item->setToolTip(info.process);
|
||||
lstoolwin->addItem(item);
|
||||
}
|
||||
|
||||
void CenterWindow::initGeneralSettings() {
|
||||
sm = SettingManager::instance();
|
||||
auto gridsize = sm->toolGridSize();
|
||||
for (auto i = 0; i < 9; i++) {
|
||||
lbls[i]->setFixedSize(QSize(gridsize, gridsize));
|
||||
}
|
||||
|
||||
Qt::KeyboardModifier mod = sm->toolwinMod();
|
||||
Qt::MouseButton btn = sm->toolwinMouseBtn();
|
||||
switch (mod) {
|
||||
case Qt::KeyboardModifier::AltModifier:
|
||||
cbMod->setCurrentIndex(2);
|
||||
break;
|
||||
case Qt::KeyboardModifier::MetaModifier:
|
||||
cbMod->setCurrentIndex(3);
|
||||
break;
|
||||
case Qt::KeyboardModifier::ShiftModifier:
|
||||
cbMod->setCurrentIndex(1);
|
||||
break;
|
||||
default:
|
||||
cbMod->setCurrentIndex(0);
|
||||
break;
|
||||
}
|
||||
// 注册有关设置更改相关信号
|
||||
cbWinTool->setChecked(sm->wintoolEnabled());
|
||||
cbToolWin->setChecked(sm->toolwinEnabled());
|
||||
|
||||
switch (btn) {
|
||||
case Qt::MouseButton::RightButton:
|
||||
cbMouseBtn->setCurrentIndex(1);
|
||||
break;
|
||||
case Qt::MouseButton::MidButton:
|
||||
cbMouseBtn->setCurrentIndex(2);
|
||||
break;
|
||||
case Qt::MouseButton::XButton1:
|
||||
cbMouseBtn->setCurrentIndex(3);
|
||||
break;
|
||||
case Qt::MouseButton::XButton2:
|
||||
cbMouseBtn->setCurrentIndex(4);
|
||||
break;
|
||||
default:
|
||||
cbMouseBtn->setCurrentIndex(0);
|
||||
break;
|
||||
}
|
||||
connect(cbToolWin, &DCheckBox::toggled, this,
|
||||
[=](bool v) { sm->setToolwinEnabled(v); });
|
||||
connect(cbWinTool, &DCheckBox::toggled, this, [=](bool v) {
|
||||
sm->setWintoolEnabled(v);
|
||||
hkwintool->setRegistered(v);
|
||||
});
|
||||
|
||||
connect(sm, &SettingManager::sigToolGridSizeChanged, this, [=](int v) {
|
||||
for (auto i = 0; i < 9; i++) {
|
||||
lbls[i]->setFixedSize(QSize(v, v));
|
||||
}
|
||||
});
|
||||
sm->sigToolGridSizeChanged(sm->toolGridSize());
|
||||
connect(sbGridsize, QOverload<int>::of(&DSpinBox::valueChanged), sm,
|
||||
&SettingManager::setToolGridSize);
|
||||
|
||||
auto seq = sm->toolBoxHotkey();
|
||||
kseqTool->setKeySequence(seq);
|
||||
manager->registerHotkey(seq, false);
|
||||
hkwintool = manager->registerHotkey(seq, false);
|
||||
hkwintool->disconnect(); // 断开所有自带连接,不能让它走默认处理
|
||||
connect(hkwintool, &Hotkey::activated, this, [&] {
|
||||
Dtk::Widget::moveToCenter(&wintool);
|
||||
wintool.show();
|
||||
Utilities::activeWindowFromDock(wintool.winId());
|
||||
});
|
||||
connect(kseqTool, &DKeySequenceEdit::editingFinished, this,
|
||||
[=](const QKeySequence &keySequence) {
|
||||
sm->setToolBoxHotkey(keySequence);
|
||||
});
|
||||
connect(sm, &SettingManager::sigToolBoxHotkeyChanged, this,
|
||||
[=](const QKeySequence seq) { hkwintool->setShortcut(seq, true); });
|
||||
|
||||
connect(sm, &SettingManager::sigToolwinEnabledChanged, this,
|
||||
[=](bool b) { cbToolWin->setChecked(b); });
|
||||
connect(sm, &SettingManager::sigWintoolEnabledChanged, this,
|
||||
[=](bool b) { cbWinTool->setChecked(b); });
|
||||
|
||||
connect(sm, &SettingManager::sigToolwinModChanged, this,
|
||||
[=](const Qt::KeyboardModifier mod) {
|
||||
switch (mod) {
|
||||
case Qt::KeyboardModifier::AltModifier:
|
||||
cbMod->setCurrentIndex(2);
|
||||
break;
|
||||
case Qt::KeyboardModifier::MetaModifier:
|
||||
cbMod->setCurrentIndex(3);
|
||||
break;
|
||||
case Qt::KeyboardModifier::ShiftModifier:
|
||||
cbMod->setCurrentIndex(1);
|
||||
break;
|
||||
default:
|
||||
cbMod->setCurrentIndex(0);
|
||||
break;
|
||||
}
|
||||
});
|
||||
sm->sigToolwinModChanged(sm->toolwinMod());
|
||||
|
||||
connect(sm, &SettingManager::sigToolwinMouseBtnChanged, this,
|
||||
[=](const Qt::MouseButton btn) {
|
||||
switch (btn) {
|
||||
case Qt::MouseButton::RightButton:
|
||||
cbMouseBtn->setCurrentIndex(1);
|
||||
break;
|
||||
case Qt::MouseButton::MidButton:
|
||||
cbMouseBtn->setCurrentIndex(2);
|
||||
break;
|
||||
case Qt::MouseButton::XButton1:
|
||||
cbMouseBtn->setCurrentIndex(3);
|
||||
break;
|
||||
case Qt::MouseButton::XButton2:
|
||||
cbMouseBtn->setCurrentIndex(4);
|
||||
break;
|
||||
default:
|
||||
cbMouseBtn->setCurrentIndex(0);
|
||||
break;
|
||||
}
|
||||
});
|
||||
sm->sigToolwinMouseBtnChanged(sm->toolwinMouseBtn());
|
||||
|
||||
connect(cbMod, QOverload<int>::of(&DComboBox::currentIndexChanged), this,
|
||||
[=](int index) {
|
||||
Qt::KeyboardModifier mod = Qt::KeyboardModifier::NoModifier;
|
||||
switch (index) {
|
||||
case 0:
|
||||
mod = Qt::KeyboardModifier::ControlModifier;
|
||||
break;
|
||||
case 1:
|
||||
mod = Qt::KeyboardModifier::ShiftModifier;
|
||||
break;
|
||||
case 2:
|
||||
mod = Qt::KeyboardModifier::AltModifier;
|
||||
break;
|
||||
case 3:
|
||||
mod = Qt::KeyboardModifier::MetaModifier;
|
||||
break;
|
||||
}
|
||||
sm->setToolwinMod(mod);
|
||||
});
|
||||
connect(cbMouseBtn, QOverload<int>::of(&DComboBox::currentIndexChanged), this,
|
||||
[=](int index) {
|
||||
Qt::MouseButton btn = Qt::MouseButton::NoButton;
|
||||
switch (index) {
|
||||
case 0:
|
||||
btn = Qt::MouseButton::LeftButton;
|
||||
break;
|
||||
case 1:
|
||||
btn = Qt::MouseButton::RightButton;
|
||||
break;
|
||||
case 2:
|
||||
btn = Qt::MouseButton::MidButton;
|
||||
break;
|
||||
case 3:
|
||||
btn = Qt::MouseButton::XButton1;
|
||||
break;
|
||||
case 4:
|
||||
btn = Qt::MouseButton::XButton2;
|
||||
break;
|
||||
}
|
||||
sm->setToolMouseBtn(btn);
|
||||
});
|
||||
}
|
||||
|
||||
void CenterWindow::initPluginSys() {
|
||||
|
@ -802,9 +920,7 @@ void CenterWindow::initAppManger() {
|
|||
this->runTask(task);
|
||||
}
|
||||
});
|
||||
connect(manager, &AppManager::hotkeyReleased, this, [=](const Hotkey *) {
|
||||
|
||||
});
|
||||
connect(manager, &AppManager::hotkeyReleased, this, [=](const Hotkey *) {});
|
||||
connect(manager, &AppManager::hotkeyEnableChanged, this,
|
||||
[=](bool value, const Hotkey *hotkey) {
|
||||
if (hotkey->isHostHotkey()) {
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "class/appmanager.h"
|
||||
#include "class/settingmanager.h"
|
||||
#include "plugin/pluginsystem.h"
|
||||
#include "toolboxwindow.h"
|
||||
#include "utilities.h"
|
||||
#include <DCheckBox>
|
||||
#include <DComboBox>
|
||||
|
@ -58,6 +59,10 @@ private:
|
|||
void on_upToolWin();
|
||||
void on_downToolWin();
|
||||
|
||||
void on_exportSettings();
|
||||
void on_importSettings();
|
||||
void on_resetSettings();
|
||||
|
||||
public slots:
|
||||
void addHotKeyInfo(ToolStructInfo &info);
|
||||
void setoolWinInfo(int index, ToolStructInfo &info);
|
||||
|
@ -99,6 +104,9 @@ private:
|
|||
|
||||
DSpinBox *sbGridsize;
|
||||
|
||||
Hotkey *hkwintool;
|
||||
ToolBoxWindow wintool;
|
||||
|
||||
private:
|
||||
QMap<Hotkey *, ToolStructInfo> scinfos; // 用于 Hotkeys
|
||||
QList<Hotkey *> hotkeys; // Hotkeys 方便进行检索
|
||||
|
|
|
@ -1,3 +1,37 @@
|
|||
#include "toolboxwindow.h"
|
||||
#include "control/wintoolitem.h"
|
||||
#include <DLabel>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
|
||||
ToolBoxWindow::ToolBoxWindow(DMainWindow *parent) : DDialog(parent) {}
|
||||
ToolBoxWindow::ToolBoxWindow(DMainWindow *parent) : DDialog(parent) {
|
||||
lstool = new DListWidget(this);
|
||||
addContent(lstool);
|
||||
}
|
||||
|
||||
void ToolBoxWindow::addItem(ToolStructInfo &info, int index) {
|
||||
auto pitem = new QListWidgetItem;
|
||||
|
||||
auto item = new WinToolItem(this);
|
||||
}
|
||||
|
||||
void ToolBoxWindow::rmItem(int index) {
|
||||
if (index < 0) {
|
||||
lstool->clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (index >= lstool->count()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto k = lstool->takeItem(index);
|
||||
delete k;
|
||||
}
|
||||
|
||||
void ToolBoxWindow::mvItem(int from, int to) {
|
||||
auto len = lstool->count();
|
||||
if (from < 0 || from >= len || to < 0 || to >= len)
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef TOOLBOXWINDOW_H
|
||||
#define TOOLBOXWINDOW_H
|
||||
|
||||
#include "utilities.h"
|
||||
#include <DDialog>
|
||||
#include <DListWidget>
|
||||
#include <DMainWindow>
|
||||
|
@ -12,9 +13,9 @@ class ToolBoxWindow : public DDialog {
|
|||
public:
|
||||
ToolBoxWindow(DMainWindow *parent = nullptr);
|
||||
|
||||
signals:
|
||||
void addItem(QListWidgetItem *item, int index = -1); // -1 表示追加
|
||||
void rmItem(int index); // -1 表示清空
|
||||
public:
|
||||
void addItem(ToolStructInfo &info, int index = -1); // -1 表示追加
|
||||
void rmItem(int index); // -1 表示清空
|
||||
void mvItem(int from, int to);
|
||||
|
||||
private:
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
#include "toolswapdialog.h"
|
||||
#include "class/settingmanager.h"
|
||||
#include <DDialogButtonBox>
|
||||
#include <DLabel>
|
||||
#include <DMessageManager>
|
||||
#include <QButtonGroup>
|
||||
#include <QShortcut>
|
||||
|
||||
ToolSwapDialog::ToolSwapDialog(const QVector<QIcon> &icons, int selindex,
|
||||
DDialog *parent)
|
||||
: DDialog(parent) {
|
||||
setWindowTitle(tr("ToolSwapDialog"));
|
||||
|
||||
addContent(new DLabel(tr("PleaseSelect"), this), Qt::AlignCenter);
|
||||
addSpacing(10);
|
||||
auto gridsize = SettingManager::instance()->toolGridSize();
|
||||
auto gw = new QWidget(this);
|
||||
gw->setFixedSize(gridsize * 3, gridsize * 3);
|
||||
delete gw->layout();
|
||||
auto mlayout = new QGridLayout;
|
||||
gw->setLayout(mlayout);
|
||||
mlayout->setMargin(1);
|
||||
auto btngs = new QButtonGroup(this);
|
||||
btngs->setExclusive(true); // 设置按钮选中互斥
|
||||
for (int i = 0; i < 9; i++) {
|
||||
auto lbl = new DIconButton(this);
|
||||
lbl->setFixedSize(gridsize - 2, gridsize - 2);
|
||||
lbl->setIconSize(QSize(gridsize / 2, gridsize / 2));
|
||||
lbl->setIcon(icons[i]);
|
||||
lbl->setCheckable(true);
|
||||
auto in = std::div(i, 3);
|
||||
mlayout->addWidget(lbl, in.quot, in.rem, Qt::AlignCenter);
|
||||
lbls[i] = lbl;
|
||||
btngs->addButton(lbl);
|
||||
connect(lbl, &DIconButton::toggled, this, [=](bool b) {
|
||||
if (b)
|
||||
cur = i;
|
||||
});
|
||||
}
|
||||
auto lbl4 = lbls[4];
|
||||
lbl4->setIcon(ICONRES("close"));
|
||||
lbl4->setEnabled(false);
|
||||
lbls[selindex]->setEnabled(false);
|
||||
addContent(gw, Qt::AlignCenter);
|
||||
addSpacing(20);
|
||||
auto dbbox = new DDialogButtonBox(
|
||||
DDialogButtonBox::Ok | DDialogButtonBox::Cancel, this);
|
||||
connect(dbbox, &DDialogButtonBox::accepted, this, &ToolSwapDialog::on_accept);
|
||||
connect(dbbox, &DDialogButtonBox::rejected, this, &ToolSwapDialog::on_reject);
|
||||
auto key = QKeySequence(Qt::Key_Return);
|
||||
auto s = new QShortcut(key, this);
|
||||
connect(s, &QShortcut::activated, this, &ToolSwapDialog::on_accept);
|
||||
addContent(dbbox);
|
||||
}
|
||||
|
||||
void ToolSwapDialog::on_accept() {
|
||||
if (cur == -1) {
|
||||
DMessageManager::instance()->sendMessage(this, ProgramIcon, tr("NoSelect"));
|
||||
return;
|
||||
}
|
||||
done(cur);
|
||||
}
|
||||
|
||||
void ToolSwapDialog::on_reject() { done(-1); }
|
||||
|
||||
void ToolSwapDialog::closeEvent(QCloseEvent *event) {
|
||||
Q_UNUSED(event);
|
||||
done(-1);
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
#ifndef TOOLSWAPDIALOG_H
|
||||
#define TOOLSWAPDIALOG_H
|
||||
|
||||
#include "utilities.h"
|
||||
#include <DDialog>
|
||||
#include <DIconButton>
|
||||
#include <QGridLayout>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
class ToolSwapDialog : public DDialog {
|
||||
public:
|
||||
ToolSwapDialog(const QVector<QIcon> &icons, int selindex,
|
||||
DDialog *parent = nullptr);
|
||||
|
||||
private:
|
||||
void on_accept();
|
||||
void on_reject();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *event) override;
|
||||
|
||||
private:
|
||||
QGridLayout *mlayout;
|
||||
DIconButton *lbls[9] = {nullptr};
|
||||
|
||||
int cur = -1;
|
||||
};
|
||||
|
||||
#endif // TOOLSWAPDIALOG_H
|
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1664602805289" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3975" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M514 65.5c-246.5 0-446.3 199.8-446.3 446.3S267.5 958.1 514 958.1s446.3-199.8 446.3-446.3S760.5 65.5 514 65.5zM407.3 752l-26.1 79.8-152.6-170.3 223.7-47-23 70.3c3.8 1.4 7.6 2.8 11.5 4 132.2 43.3 272.5-6.2 350.5-112.6-62.7 147.7-228.7 225.5-384 175.8z m169.4-334.7l16.7-71.8c-3.9-1.1-7.8-2.1-11.8-3-135.5-31.5-270.9 30.1-339.2 143 49.5-152.5 208-244.6 367-208.8l19.1-82 166.9 156.1-218.7 66.5z" fill="#29ABE2" p-id="3976"></path></svg>
|
After Width: | Height: | Size: 766 B |
4
main.cpp
4
main.cpp
|
@ -82,8 +82,6 @@ int main(int argc, char *argv[]) {
|
|||
/*== 以下在主函数初始化确保单例 ==*/
|
||||
/* 之后不得使用构造函数的方式使用 */
|
||||
|
||||
qRegisterMetaType<Qt::MouseButton>();
|
||||
|
||||
// 初始化程序基础驱动
|
||||
AppManager manager;
|
||||
w.initAppManger();
|
||||
|
@ -110,7 +108,7 @@ int main(int argc, char *argv[]) {
|
|||
QObject::connect(&manager, &AppManager::checkToolShow,
|
||||
[&sm, &manager](Qt::MouseButton btn) {
|
||||
auto mod = manager.getKeyModifier();
|
||||
return mod == sm.toolwinMod() &&
|
||||
return sm.toolwinEnabled() && mod == sm.toolwinMod() &&
|
||||
sm.toolwinMouseBtn() == btn;
|
||||
});
|
||||
|
||||
|
|
|
@ -11,5 +11,6 @@
|
|||
<file>images/down.svg</file>
|
||||
<file>images/edit.svg</file>
|
||||
<file>images/up.svg</file>
|
||||
<file>images/swap.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -112,6 +112,10 @@ public:
|
|||
return QIcon::fromTheme(t.iconName(), QIcon(t.iconName()));
|
||||
}
|
||||
}
|
||||
|
||||
static QString getProgramName(ToolStructInfo &info) {
|
||||
return info.isPlugin ? info.process : QFileInfo(info.process).fileName();
|
||||
}
|
||||
};
|
||||
|
||||
#endif // UTILIES_H
|
||||
|
|
Loading…
Reference in New Issue