update
This commit is contained in:
parent
89b2903f68
commit
b454513cac
|
@ -15,6 +15,7 @@
|
||||||
## WingTool
|
## WingTool
|
||||||
|
|
||||||
  `WingTool`是一个强大的插件工具箱,中文名`羽云工具箱`,支持热键响应、鼠标跟踪、选词等相关借口。通过开发强大的对应的插件,就可以大大提高生产力。
|
  `WingTool`是一个强大的插件工具箱,中文名`羽云工具箱`,支持热键响应、鼠标跟踪、选词等相关借口。通过开发强大的对应的插件,就可以大大提高生产力。
|
||||||
|
|
||||||
  该软件如果没有任何插件,仅支持添加热键使用默认方式打开任何文件。插件的强大决定着该软件的上限,通过热键可以配置使用热键调用插件借口;默认通过鼠标中键配合`Ctrl`键可以调出工具窗口,选择合适的工具;也可以通过热键调出窗口工具,点击打开所需的文件或者软件,而不必从启动器翻找,避免任务栏图标过多以及桌面文件过多的情况。
|
  该软件如果没有任何插件,仅支持添加热键使用默认方式打开任何文件。插件的强大决定着该软件的上限,通过热键可以配置使用热键调用插件借口;默认通过鼠标中键配合`Ctrl`键可以调出工具窗口,选择合适的工具;也可以通过热键调出窗口工具,点击打开所需的文件或者软件,而不必从启动器翻找,避免任务栏图标过多以及桌面文件过多的情况。
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
@ -22,15 +23,14 @@
|
||||||
  现在工具处于开发状态,很多功能并没有完成:
|
  现在工具处于开发状态,很多功能并没有完成:
|
||||||
|
|
||||||
1. 配置相关(已完成 90%)
|
1. 配置相关(已完成 90%)
|
||||||
2. 窗口工具(已完成 40%)
|
2. 语言本地化(已完成 0%)
|
||||||
3. 语言本地化(已完成 0%)
|
|
||||||
4. 软件 UI 相关(已完成 90%)
|
|
||||||
|
|
||||||
  如下是已完成的功能:
|
  如下是已完成的功能:
|
||||||
|
|
||||||
1. 插件系统的设计
|
1. 插件系统的设计
|
||||||
2. 热键调用功能
|
2. 热键调用功能
|
||||||
3. 工具窗口
|
3. 工具窗口
|
||||||
|
4. 窗口工具
|
||||||
|
|
||||||
  待功能基本完成的时候,我会同步到我使用的所有代码托管平台。
|
  待功能基本完成的时候,我会同步到我使用的所有代码托管平台。
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "testplugin.h"
|
#include "testplugin.h"
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
TestPlugin::TestPlugin(QObject *parent) { Q_UNUSED(parent) }
|
TestPlugin::TestPlugin(QObject *parent) { Q_UNUSED(parent) }
|
||||||
|
|
||||||
|
@ -93,6 +94,10 @@ QVariant TestPlugin::pluginServicePipe(int serviceID, QList<QVariant> params) {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestPlugin::onSetting() {
|
||||||
|
QMessageBox::information(nullptr, "Settings", "You Clicked Settings!");
|
||||||
|
}
|
||||||
|
|
||||||
#if QT_VERSION < 0x050000
|
#if QT_VERSION < 0x050000
|
||||||
Q_EXPORT_PLUGIN2(TestPlugin, IWingToolPlg)
|
Q_EXPORT_PLUGIN2(TestPlugin, IWingToolPlg)
|
||||||
#endif // QT_VERSION < 0x050000
|
#endif // QT_VERSION < 0x050000
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QVariant pluginServicePipe(int serviceID, QList<QVariant> params) override;
|
QVariant pluginServicePipe(int serviceID, QList<QVariant> params) override;
|
||||||
|
virtual void onSetting() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QUuid testhotkey;
|
QUuid testhotkey;
|
||||||
|
|
|
@ -26,8 +26,7 @@ SOURCES += \
|
||||||
dialog/pluginseldialog.cpp \
|
dialog/pluginseldialog.cpp \
|
||||||
dialog/tooleditdialog.cpp \
|
dialog/tooleditdialog.cpp \
|
||||||
class/hotkey.cpp \
|
class/hotkey.cpp \
|
||||||
dialog/toolswapdialog.cpp \
|
dialog/toolswapdialog.cpp
|
||||||
control/wintoolitem.cpp
|
|
||||||
RESOURCES += resources.qrc
|
RESOURCES += resources.qrc
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
|
@ -48,5 +47,4 @@ HEADERS += \
|
||||||
utilities.h \
|
utilities.h \
|
||||||
dialog/tooleditdialog.h \
|
dialog/tooleditdialog.h \
|
||||||
class/hotkey.h \
|
class/hotkey.h \
|
||||||
dialog/toolswapdialog.h \
|
dialog/toolswapdialog.h
|
||||||
control/wintoolitem.h
|
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
#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); }
|
|
|
@ -1,28 +0,0 @@
|
||||||
#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
|
|
|
@ -181,7 +181,7 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) {
|
||||||
|
|
||||||
tbhotkeys->setContextMenuPolicy(Qt::CustomContextMenu);
|
tbhotkeys->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(tbhotkeys, &DTabWidget::customContextMenuRequested, this, [=] {
|
connect(tbhotkeys, &DTabWidget::customContextMenuRequested, this, [=] {
|
||||||
auto flag = tbhotkeys->currentRow() >= 0;
|
auto flag = tbhotkeys->selectedItems().count() > 0;
|
||||||
for (auto item : hkcmenu) {
|
for (auto item : hkcmenu) {
|
||||||
item->setEnabled(flag);
|
item->setEnabled(flag);
|
||||||
}
|
}
|
||||||
|
@ -349,61 +349,122 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) {
|
||||||
b->setIconSize(QSize(20, 20));
|
b->setIconSize(QSize(20, 20));
|
||||||
b->setParent(this);
|
b->setParent(this);
|
||||||
b->setToolTip(tr("Add"));
|
b->setToolTip(tr("Add"));
|
||||||
connect(b, &DButtonBoxButton::clicked, this, &CenterWindow::on_addToolWin);
|
connect(b, &DButtonBoxButton::clicked, this, &CenterWindow::on_addWinTool);
|
||||||
blist.append(b);
|
blist.append(b);
|
||||||
b = new DButtonBoxButton(ICONRES2("del"));
|
b = new DButtonBoxButton(ICONRES2("del"));
|
||||||
b->setIconSize(QSize(20, 20));
|
b->setIconSize(QSize(20, 20));
|
||||||
b->setParent(this);
|
b->setParent(this);
|
||||||
b->setToolTip(tr("Remove"));
|
b->setToolTip(tr("Remove"));
|
||||||
connect(b, &DButtonBoxButton::clicked, this, &CenterWindow::on_removeToolWin);
|
connect(b, &DButtonBoxButton::clicked, this, &CenterWindow::on_removeWinTool);
|
||||||
blist.append(b);
|
blist.append(b);
|
||||||
b = new DButtonBoxButton(ICONRES2("edit"));
|
b = new DButtonBoxButton(ICONRES2("edit"));
|
||||||
b->setIconSize(QSize(20, 20));
|
b->setIconSize(QSize(20, 20));
|
||||||
b->setParent(this);
|
b->setParent(this);
|
||||||
b->setToolTip(tr("Edit"));
|
b->setToolTip(tr("Edit"));
|
||||||
connect(b, &DButtonBoxButton::clicked, this, &CenterWindow::on_editToolWin);
|
connect(b, &DButtonBoxButton::clicked, this, &CenterWindow::on_editWinTool);
|
||||||
blist.append(b);
|
blist.append(b);
|
||||||
b = new DButtonBoxButton(ICONRES2("up"));
|
b = new DButtonBoxButton(ICONRES2("up"));
|
||||||
b->setIconSize(QSize(20, 20));
|
b->setIconSize(QSize(20, 20));
|
||||||
b->setParent(this);
|
b->setParent(this);
|
||||||
b->setToolTip(tr("Up"));
|
b->setToolTip(tr("Up"));
|
||||||
connect(b, &DButtonBoxButton::clicked, this, &CenterWindow::on_upToolWin);
|
connect(b, &DButtonBoxButton::clicked, this, &CenterWindow::on_upWinTool);
|
||||||
blist.append(b);
|
blist.append(b);
|
||||||
b = new DButtonBoxButton(ICONRES2("down"));
|
b = new DButtonBoxButton(ICONRES2("down"));
|
||||||
b->setIconSize(QSize(20, 20));
|
b->setIconSize(QSize(20, 20));
|
||||||
b->setParent(this);
|
b->setParent(this);
|
||||||
b->setToolTip(tr("Down"));
|
b->setToolTip(tr("Down"));
|
||||||
connect(b, &DButtonBoxButton::clicked, this, &CenterWindow::on_downToolWin);
|
connect(b, &DButtonBoxButton::clicked, this, &CenterWindow::on_downWinTool);
|
||||||
blist.append(b);
|
blist.append(b);
|
||||||
b = new DButtonBoxButton(ICONRES2("clear"));
|
b = new DButtonBoxButton(ICONRES2("clear"));
|
||||||
b->setIconSize(QSize(20, 20));
|
b->setIconSize(QSize(20, 20));
|
||||||
b->setParent(this);
|
b->setParent(this);
|
||||||
b->setToolTip(tr("Clear"));
|
b->setToolTip(tr("Clear"));
|
||||||
connect(b, &DButtonBoxButton::clicked, this, &CenterWindow::on_clearToolWin);
|
connect(b, &DButtonBoxButton::clicked, this, &CenterWindow::on_clearWinTool);
|
||||||
blist.append(b);
|
blist.append(b);
|
||||||
group->setButtonList(blist, false);
|
group->setButtonList(blist, false);
|
||||||
tvlayout->addWidget(group);
|
tvlayout->addWidget(group);
|
||||||
|
|
||||||
lstoolwin = new DListWidget(w);
|
lstoolwin = new DListWidget(w);
|
||||||
menu = new DMenu(lstoolwin);
|
menu = new DMenu(lstoolwin);
|
||||||
AddMenuAction(tr("Add"), &CenterWindow::on_addToolWin);
|
AddMenuAction(tr("Add"), &CenterWindow::on_addWinTool);
|
||||||
AddMenuAction(tr("Edit"), &CenterWindow::on_editToolWin);
|
AddMenuAction(tr("Edit"), &CenterWindow::on_editWinTool);
|
||||||
AddMenuAction(tr("Remove"), &CenterWindow::on_removeToolWin);
|
lscmenu.append(a);
|
||||||
AddMenuAction(tr("Clear"), &CenterWindow::on_clearToolWin);
|
AddMenuAction(tr("Remove"), &CenterWindow::on_removeWinTool);
|
||||||
|
lscmenu.append(a);
|
||||||
|
AddMenuAction(tr("Clear"), &CenterWindow::on_clearWinTool);
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
AddMenuAction(tr("Up"), &CenterWindow::on_upToolWin);
|
AddMenuAction(tr("Up"), &CenterWindow::on_upWinTool);
|
||||||
AddMenuAction(tr("Down"), &CenterWindow::on_downToolWin);
|
lscmenu.append(a);
|
||||||
|
AddMenuAction(tr("Down"), &CenterWindow::on_downWinTool);
|
||||||
|
lscmenu.append(a);
|
||||||
AddMenuAction(tr("TopMost"), [=] {
|
AddMenuAction(tr("TopMost"), [=] {
|
||||||
|
auto sels = lstoolwin->selectionModel()->selectedRows();
|
||||||
|
QVector<int> nums;
|
||||||
|
for (auto &item : sels) {
|
||||||
|
nums.append(item.row());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(nums.begin(), nums.end());
|
||||||
|
|
||||||
|
// 过滤掉不需移动的选项
|
||||||
|
int i = 0;
|
||||||
|
auto len = nums.count();
|
||||||
|
for (; i < len; i++) {
|
||||||
|
if (nums[i] != i)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下面就开始乾坤大挪移
|
||||||
|
for (auto p = nums.rbegin(); p != nums.rend() - i; p++) {
|
||||||
|
auto pi = *p;
|
||||||
|
wintoolinfos.move(pi, i);
|
||||||
|
auto item = lstoolwin->takeItem(pi);
|
||||||
|
lstoolwin->insertItem(i, item);
|
||||||
|
wintool.mvItem(pi, i);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
lscmenu.append(a);
|
||||||
AddMenuAction(tr("DownMost"), [=] {
|
AddMenuAction(tr("DownMost"), [=] {
|
||||||
|
auto sels = lstoolwin->selectionModel()->selectedRows();
|
||||||
|
QVector<int> nums;
|
||||||
|
for (auto &item : sels) {
|
||||||
|
nums.append(item.row());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(nums.begin(), nums.end(), std::greater<int>());
|
||||||
|
|
||||||
|
// 过滤掉不需移动的选项
|
||||||
|
int i = 0;
|
||||||
|
auto len = nums.count();
|
||||||
|
if (nums.first() == lstoolwin->count() - 1) {
|
||||||
|
int pi = nums.first();
|
||||||
|
for (; i < len; i++) {
|
||||||
|
pi--;
|
||||||
|
if (nums[i] != pi)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下面就开始乾坤大挪移
|
||||||
|
for (auto p = nums.rbegin(); p != nums.rend() - i; p++) {
|
||||||
|
auto pi = *p;
|
||||||
|
wintoolinfos.move(pi, i);
|
||||||
|
auto item = lstoolwin->takeItem(pi);
|
||||||
|
lstoolwin->insertItem(i, item);
|
||||||
|
wintool.mvItem(pi, i);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
lscmenu.append(a);
|
||||||
lstoolwin->setContextMenuPolicy(Qt::CustomContextMenu);
|
lstoolwin->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
lstoolwin->setSelectionMode(QListWidget::SelectionMode::ExtendedSelection);
|
lstoolwin->setSelectionMode(QListWidget::SelectionMode::ExtendedSelection);
|
||||||
lstoolwin->setDragDropMode(QListWidget::DragDropMode::NoDragDrop);
|
lstoolwin->setDragDropMode(QListWidget::DragDropMode::NoDragDrop);
|
||||||
connect(lstoolwin, &DListWidget::customContextMenuRequested, this,
|
connect(lstoolwin, &DListWidget::customContextMenuRequested, this, [=] {
|
||||||
[=] { menu->popup(QCursor::pos()); });
|
auto flag = lstoolwin->selectedItems().count() > 0;
|
||||||
|
for (auto item : lscmenu) {
|
||||||
|
item->setEnabled(flag);
|
||||||
|
}
|
||||||
|
menu->popup(QCursor::pos());
|
||||||
|
});
|
||||||
tvlayout->addWidget(lstoolwin);
|
tvlayout->addWidget(lstoolwin);
|
||||||
|
|
||||||
tlayout->addLayout(tvlayout);
|
tlayout->addLayout(tvlayout);
|
||||||
|
@ -412,15 +473,32 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) {
|
||||||
// Plugins
|
// Plugins
|
||||||
w = new QWidget(this);
|
w = new QWidget(this);
|
||||||
auto playout = new QHBoxLayout(w);
|
auto playout = new QHBoxLayout(w);
|
||||||
|
auto pvlayout = new QVBoxLayout;
|
||||||
lwplgs = new DListWidget(w);
|
lwplgs = new DListWidget(w);
|
||||||
playout->addWidget(lwplgs);
|
playout->addWidget(lwplgs);
|
||||||
|
playout->addLayout(pvlayout);
|
||||||
|
|
||||||
tbplginfo = new DTextBrowser(w);
|
tbplginfo = new DTextBrowser(w);
|
||||||
tbplginfo->setUndoRedoEnabled(false);
|
tbplginfo->setUndoRedoEnabled(false);
|
||||||
tbplginfo->setText(tr("No selected plugin."));
|
tbplginfo->setText(tr("No selected plugin."));
|
||||||
|
|
||||||
|
pvlayout->addWidget(tbplginfo, 1);
|
||||||
|
auto btnplgset = new DPushButton(tr("Setting"), w);
|
||||||
|
connect(btnplgset, &DPushButton::clicked, this, [=] {
|
||||||
|
auto plg = plgsys->plugin(lwplgs->currentRow());
|
||||||
|
plg->onSetting();
|
||||||
|
});
|
||||||
|
btnplgset->setEnabled(false);
|
||||||
|
pvlayout->addWidget(btnplgset);
|
||||||
|
|
||||||
connect(lwplgs, &DListWidget::itemSelectionChanged, this, [=] {
|
connect(lwplgs, &DListWidget::itemSelectionChanged, this, [=] {
|
||||||
|
if (lwplgs->currentRow() < 0) {
|
||||||
|
tbplginfo->setText(tr("No selected plugin."));
|
||||||
|
btnplgset->setEnabled(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
tbplginfo->clear();
|
tbplginfo->clear();
|
||||||
|
btnplgset->setEnabled(true);
|
||||||
auto plg = plgsys->plugin(lwplgs->currentRow());
|
auto plg = plgsys->plugin(lwplgs->currentRow());
|
||||||
tbplginfo->append(tr("Name:") + plg->pluginName());
|
tbplginfo->append(tr("Name:") + plg->pluginName());
|
||||||
|
|
||||||
|
@ -445,7 +523,7 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) {
|
||||||
tbplginfo->append(QString("\t%1").arg(item.toString()));
|
tbplginfo->append(QString("\t%1").arg(item.toString()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
playout->addWidget(tbplginfo);
|
|
||||||
tabs->addTab(w, tr("Plugins"));
|
tabs->addTab(w, tr("Plugins"));
|
||||||
|
|
||||||
// AboutAuthor
|
// AboutAuthor
|
||||||
|
@ -634,7 +712,7 @@ void CenterWindow::enableSelectedHotkeys(bool enable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CenterWindow::on_editToolWin() {
|
void CenterWindow::on_editWinTool() {
|
||||||
auto sels = lstoolwin->selectedItems().count();
|
auto sels = lstoolwin->selectedItems().count();
|
||||||
if (sels != 1) {
|
if (sels != 1) {
|
||||||
DMessageManager::instance()->sendMessage(this, ProgramIcon,
|
DMessageManager::instance()->sendMessage(this, ProgramIcon,
|
||||||
|
@ -654,7 +732,7 @@ void CenterWindow::on_editToolWin() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CenterWindow::on_removeToolWin() {
|
void CenterWindow::on_removeWinTool() {
|
||||||
auto sels = lstoolwin->selectionModel()->selectedRows();
|
auto sels = lstoolwin->selectionModel()->selectedRows();
|
||||||
QVector<int> nums;
|
QVector<int> nums;
|
||||||
for (auto &item : sels) {
|
for (auto &item : sels) {
|
||||||
|
@ -667,17 +745,19 @@ void CenterWindow::on_removeToolWin() {
|
||||||
wintoolinfos.removeAt(index);
|
wintoolinfos.removeAt(index);
|
||||||
auto item = lstoolwin->takeItem(index);
|
auto item = lstoolwin->takeItem(index);
|
||||||
delete item;
|
delete item;
|
||||||
|
wintool.rmItem(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CenterWindow::on_clearToolWin() {
|
void CenterWindow::on_clearWinTool() {
|
||||||
lstoolwin->clear();
|
lstoolwin->clear();
|
||||||
wintoolinfos.clear();
|
wintoolinfos.clear();
|
||||||
|
wintool.rmItem(-1); // 清空数据
|
||||||
DMessageManager::instance()->sendMessage(this, ProgramIcon,
|
DMessageManager::instance()->sendMessage(this, ProgramIcon,
|
||||||
tr("ClearSuccess"));
|
tr("ClearSuccess"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CenterWindow::on_addToolWin() {
|
void CenterWindow::on_addWinTool() {
|
||||||
ToolEditDialog d;
|
ToolEditDialog d;
|
||||||
if (d.exec()) {
|
if (d.exec()) {
|
||||||
auto res = d.getResult();
|
auto res = d.getResult();
|
||||||
|
@ -689,6 +769,7 @@ void CenterWindow::on_addToolWin() {
|
||||||
Utilities::getProgramName(res));
|
Utilities::getProgramName(res));
|
||||||
item->setToolTip(res.process);
|
item->setToolTip(res.process);
|
||||||
lstoolwin->addItem(item);
|
lstoolwin->addItem(item);
|
||||||
|
wintool.addItem(res);
|
||||||
} else {
|
} else {
|
||||||
wintoolinfos.insert(index + 1, res);
|
wintoolinfos.insert(index + 1, res);
|
||||||
|
|
||||||
|
@ -697,13 +778,68 @@ void CenterWindow::on_addToolWin() {
|
||||||
Utilities::getProgramName(res));
|
Utilities::getProgramName(res));
|
||||||
item->setToolTip(res.process);
|
item->setToolTip(res.process);
|
||||||
lstoolwin->insertItem(index + 1, item);
|
lstoolwin->insertItem(index + 1, item);
|
||||||
|
wintool.addItem(res, index + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CenterWindow::on_upToolWin() {}
|
void CenterWindow::on_upWinTool() {
|
||||||
|
auto sels = lstoolwin->selectionModel()->selectedRows();
|
||||||
|
QVector<int> nums;
|
||||||
|
for (auto &item : sels) {
|
||||||
|
nums.append(item.row());
|
||||||
|
}
|
||||||
|
|
||||||
void CenterWindow::on_downToolWin() {}
|
std::sort(nums.begin(), nums.end());
|
||||||
|
|
||||||
|
// 过滤掉不需移动的选项
|
||||||
|
int i = 0;
|
||||||
|
auto len = nums.count();
|
||||||
|
for (; i < len; i++) {
|
||||||
|
if (nums[i] != i)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下面就开始乾坤大挪移
|
||||||
|
for (; i < len; i++) {
|
||||||
|
auto p = nums[i];
|
||||||
|
wintoolinfos.move(p, p - 1);
|
||||||
|
auto item = lstoolwin->takeItem(p);
|
||||||
|
lstoolwin->insertItem(p - 1, item);
|
||||||
|
wintool.mvItem(p, p - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CenterWindow::on_downWinTool() {
|
||||||
|
auto sels = lstoolwin->selectionModel()->selectedRows();
|
||||||
|
QVector<int> nums;
|
||||||
|
for (auto &item : sels) {
|
||||||
|
nums.append(item.row());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(nums.begin(), nums.end(), std::greater<int>());
|
||||||
|
|
||||||
|
// 过滤掉不需移动的选项
|
||||||
|
int i = 0;
|
||||||
|
auto len = nums.count();
|
||||||
|
if (nums.first() == lstoolwin->count() - 1) {
|
||||||
|
int pi = nums.first();
|
||||||
|
for (; i < len; i++) {
|
||||||
|
pi--;
|
||||||
|
if (nums[i] != pi)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 下面就开始乾坤大挪移
|
||||||
|
for (; i < len; i++) {
|
||||||
|
auto p = nums[i];
|
||||||
|
wintoolinfos.move(p, p + 1);
|
||||||
|
auto item = lstoolwin->takeItem(p);
|
||||||
|
lstoolwin->insertItem(p + 1, item);
|
||||||
|
wintool.mvItem(p, p + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CenterWindow::on_exportSettings() {
|
void CenterWindow::on_exportSettings() {
|
||||||
auto path = DFileDialog::getSaveFileName(this, tr(""), QString(),
|
auto path = DFileDialog::getSaveFileName(this, tr(""), QString(),
|
||||||
|
@ -796,6 +932,10 @@ void CenterWindow::initGeneralSettings() {
|
||||||
connect(sbGridsize, QOverload<int>::of(&DSpinBox::valueChanged), sm,
|
connect(sbGridsize, QOverload<int>::of(&DSpinBox::valueChanged), sm,
|
||||||
&SettingManager::setToolGridSize);
|
&SettingManager::setToolGridSize);
|
||||||
|
|
||||||
|
// WinTool 相关
|
||||||
|
wintool.setModal(true);
|
||||||
|
connect(&wintool, &ToolBoxWindow::sigRun, this,
|
||||||
|
[=](int index) { this->runTask(wintoolinfos[index]); });
|
||||||
auto seq = sm->toolBoxHotkey();
|
auto seq = sm->toolBoxHotkey();
|
||||||
kseqTool->setKeySequence(seq);
|
kseqTool->setKeySequence(seq);
|
||||||
hkwintool = manager->registerHotkey(seq, false);
|
hkwintool = manager->registerHotkey(seq, false);
|
||||||
|
|
|
@ -52,12 +52,12 @@ private:
|
||||||
void on_addHotkey();
|
void on_addHotkey();
|
||||||
void enableSelectedHotkeys(bool enable);
|
void enableSelectedHotkeys(bool enable);
|
||||||
|
|
||||||
void on_editToolWin();
|
void on_editWinTool();
|
||||||
void on_removeToolWin();
|
void on_removeWinTool();
|
||||||
void on_clearToolWin();
|
void on_clearWinTool();
|
||||||
void on_addToolWin();
|
void on_addWinTool();
|
||||||
void on_upToolWin();
|
void on_upWinTool();
|
||||||
void on_downToolWin();
|
void on_downWinTool();
|
||||||
|
|
||||||
void on_exportSettings();
|
void on_exportSettings();
|
||||||
void on_importSettings();
|
void on_importSettings();
|
||||||
|
@ -77,7 +77,7 @@ protected:
|
||||||
void closeEvent(QCloseEvent *event) override;
|
void closeEvent(QCloseEvent *event) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QAction *> hkcmenu;
|
QList<QAction *> hkcmenu, lscmenu;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AppManager *manager;
|
AppManager *manager;
|
||||||
|
|
|
@ -61,12 +61,12 @@ PluginSelDialog::PluginSelDialog(DDialog *parent) : DDialog(parent) {
|
||||||
auto b = new DButtonBoxButton(tr("Select"), this);
|
auto b = new DButtonBoxButton(tr("Select"), this);
|
||||||
connect(b, &DButtonBoxButton::clicked, this, [=] {
|
connect(b, &DButtonBoxButton::clicked, this, [=] {
|
||||||
auto item = lsplgs->currentItem();
|
auto item = lsplgs->currentItem();
|
||||||
auto sel = item->data(Qt::UserRole).toInt();
|
if (!item) {
|
||||||
if (sel < 0) {
|
|
||||||
DMessageManager::instance()->sendMessage(this, ProgramIcon,
|
DMessageManager::instance()->sendMessage(this, ProgramIcon,
|
||||||
tr("NoSelection"));
|
tr("NoSelection"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
auto sel = item->data(Qt::UserRole).toInt();
|
||||||
this->done(sel);
|
this->done(sel);
|
||||||
});
|
});
|
||||||
blist.append(b);
|
blist.append(b);
|
||||||
|
|
|
@ -1,19 +1,64 @@
|
||||||
#include "toolboxwindow.h"
|
#include "toolboxwindow.h"
|
||||||
#include "control/wintoolitem.h"
|
#include "plugin/pluginsystem.h"
|
||||||
#include <DLabel>
|
#include <DLabel>
|
||||||
|
#include <DThemeManager>
|
||||||
|
#include <DTitlebar>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
ToolBoxWindow::ToolBoxWindow(DMainWindow *parent) : DDialog(parent) {
|
ToolBoxWindow::ToolBoxWindow(DMainWindow *parent) : DDialog(parent) {
|
||||||
|
setWindowTitle(tr("PleaseChoose"));
|
||||||
|
setWindowFlag(Qt::Tool);
|
||||||
|
setWindowFlag(Qt::WindowStaysOnTopHint);
|
||||||
|
setCloseButtonVisible(false);
|
||||||
lstool = new DListWidget(this);
|
lstool = new DListWidget(this);
|
||||||
|
lstool->setMouseTracking(true);
|
||||||
|
auto pe = lstool->palette();
|
||||||
|
pe.setColor(QPalette::AlternateBase,
|
||||||
|
DGuiApplicationHelper::instance()->themeType() ==
|
||||||
|
DGuiApplicationHelper::LightType
|
||||||
|
? pe.base().color().darker(125)
|
||||||
|
: pe.base().color().lighter(125));
|
||||||
|
lstool->setPalette(pe);
|
||||||
|
lstool->setAlternatingRowColors(true);
|
||||||
|
itemheight = lstool->fontMetrics().lineSpacing() * 4;
|
||||||
|
lstool->setMinimumHeight(itemheight * 5);
|
||||||
addContent(lstool);
|
addContent(lstool);
|
||||||
|
|
||||||
|
connect(DGuiApplicationHelper::instance(),
|
||||||
|
&DGuiApplicationHelper::themeTypeChanged, this,
|
||||||
|
&ToolBoxWindow::setTheme);
|
||||||
|
|
||||||
|
connect(lstool, &DListWidget::clicked, this, [=](const QModelIndex &index) {
|
||||||
|
emit this->sigRun(index.row());
|
||||||
|
lstool->clearSelection();
|
||||||
|
this->hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
connect(lstool, &DListWidget::itemEntered, this,
|
||||||
|
[=](QListWidgetItem *item) { item->setSelected(true); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolBoxWindow::addItem(ToolStructInfo &info, int index) {
|
void ToolBoxWindow::addItem(ToolStructInfo &info, int index) {
|
||||||
auto pitem = new QListWidgetItem;
|
auto plgsys = PluginSystem::instance();
|
||||||
|
auto plg = plgsys->plugin(info.pluginIndex);
|
||||||
|
auto icon = Utilities::trimIconFromInfo(plg, info);
|
||||||
|
QString content = tr("Process:") + Utilities::getProgramName(info) + '\n';
|
||||||
|
|
||||||
auto item = new WinToolItem(this);
|
if (info.isPlugin)
|
||||||
|
content += (tr("Service:") + plg->pluginServices()[info.serviceID]);
|
||||||
|
if (info.params.length())
|
||||||
|
content += ('\n' + tr("Params:") + info.params);
|
||||||
|
|
||||||
|
auto pitem = new QListWidgetItem(icon, content);
|
||||||
|
pitem->setTextAlignment(Qt::AlignCenter);
|
||||||
|
pitem->setSizeHint(QSize(0, itemheight));
|
||||||
|
|
||||||
|
if (index < 0)
|
||||||
|
lstool->addItem(pitem);
|
||||||
|
else
|
||||||
|
lstool->insertItem(index, pitem);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolBoxWindow::rmItem(int index) {
|
void ToolBoxWindow::rmItem(int index) {
|
||||||
|
@ -34,4 +79,25 @@ void ToolBoxWindow::mvItem(int from, int to) {
|
||||||
auto len = lstool->count();
|
auto len = lstool->count();
|
||||||
if (from < 0 || from >= len || to < 0 || to >= len)
|
if (from < 0 || from >= len || to < 0 || to >= len)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
auto item = lstool->takeItem(from);
|
||||||
|
lstool->insertItem(to, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolBoxWindow::setTheme(DGuiApplicationHelper::ColorType theme) {
|
||||||
|
auto pe = lstool->palette();
|
||||||
|
pe.setColor(QPalette::AlternateBase, theme == DGuiApplicationHelper::LightType
|
||||||
|
? pe.base().color().darker(125)
|
||||||
|
: pe.base().color().lighter(125));
|
||||||
|
lstool->setPalette(pe);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolBoxWindow::leaveEvent(QEvent *e) {
|
||||||
|
Q_UNUSED(e);
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ToolBoxWindow::focusOutEvent(QFocusEvent *event) {
|
||||||
|
Q_UNUSED(event);
|
||||||
|
hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
#include <DDialog>
|
#include <DDialog>
|
||||||
|
#include <DGuiApplicationHelper>
|
||||||
#include <DListWidget>
|
#include <DListWidget>
|
||||||
#include <DMainWindow>
|
#include <DMainWindow>
|
||||||
|
|
||||||
|
@ -11,15 +12,26 @@ DWIDGET_USE_NAMESPACE
|
||||||
class ToolBoxWindow : public DDialog {
|
class ToolBoxWindow : public DDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ToolBoxWindow(DMainWindow *parent = nullptr);
|
explicit ToolBoxWindow(DMainWindow *parent = nullptr);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void addItem(ToolStructInfo &info, int index = -1); // -1 表示追加
|
void addItem(ToolStructInfo &info, int index = -1); // -1 表示追加
|
||||||
void rmItem(int index); // -1 表示清空
|
void rmItem(int index); // -1 表示清空
|
||||||
void mvItem(int from, int to);
|
void mvItem(int from, int to);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setTheme(DGuiApplicationHelper::ColorType theme);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void leaveEvent(QEvent *e) override;
|
||||||
|
void focusOutEvent(QFocusEvent *event) override;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void sigRun(int index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DListWidget *lstool;
|
DListWidget *lstool;
|
||||||
|
int itemheight;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TOOLBOXWINDOW_H
|
#endif // TOOLBOXWINDOW_H
|
||||||
|
|
|
@ -124,6 +124,9 @@ public slots:
|
||||||
// 宿主开始回调函数时候使用,第一个参数是函数服务索引,第二个是参数集合
|
// 宿主开始回调函数时候使用,第一个参数是函数服务索引,第二个是参数集合
|
||||||
virtual QVariant pluginServicePipe(int serviceID, QList<QVariant> params) = 0;
|
virtual QVariant pluginServicePipe(int serviceID, QList<QVariant> params) = 0;
|
||||||
|
|
||||||
|
// 当插件窗口选中该插件点击设置按钮时触发,以供插件调用自身设置对话框
|
||||||
|
virtual void onSetting() {}
|
||||||
|
|
||||||
// 当鼠标任何一个键被按下就会触发该函数,如果想处理重载
|
// 当鼠标任何一个键被按下就会触发该函数,如果想处理重载
|
||||||
virtual void buttonPress(Qt::MouseButton btn, int x, int y) {
|
virtual void buttonPress(Qt::MouseButton btn, int x, int y) {
|
||||||
Q_UNUSED(btn);
|
Q_UNUSED(btn);
|
||||||
|
|
Loading…
Reference in New Issue