update
This commit is contained in:
parent
2dfd84f4d2
commit
dc16cb71b8
|
@ -37,7 +37,6 @@ HEADERS += \
|
||||||
dialog/centerwindow.h \
|
dialog/centerwindow.h \
|
||||||
dialog/toolwindow.h \
|
dialog/toolwindow.h \
|
||||||
dialog/toolboxwindow.h \
|
dialog/toolboxwindow.h \
|
||||||
class/settings.h \
|
|
||||||
plugin/pluginsystem.h \
|
plugin/pluginsystem.h \
|
||||||
plugin/iwingtoolplg.h \
|
plugin/iwingtoolplg.h \
|
||||||
class/settingmanager.h \
|
class/settingmanager.h \
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
#include "settings.h"
|
|
||||||
|
|
||||||
Settings::Settings()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
#ifndef SETTINGS_H
|
|
||||||
#define SETTINGS_H
|
|
||||||
|
|
||||||
|
|
||||||
class Settings
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Settings();
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // SETTINGS_H
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QFormLayout>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QMimeDatabase>
|
#include <QMimeDatabase>
|
||||||
|
@ -37,7 +38,7 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) {
|
||||||
auto scview = new QScrollArea;
|
auto scview = new QScrollArea;
|
||||||
scview->setWidget(w);
|
scview->setWidget(w);
|
||||||
auto vlayout = new QVBoxLayout(w);
|
auto vlayout = new QVBoxLayout(w);
|
||||||
|
vlayout->setMargin(20);
|
||||||
auto l = new DLabel(tr("Common"), this);
|
auto l = new DLabel(tr("Common"), this);
|
||||||
auto font = this->font();
|
auto font = this->font();
|
||||||
font.setUnderline(true);
|
font.setUnderline(true);
|
||||||
|
@ -48,18 +49,82 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) {
|
||||||
vlayout->addWidget(l);
|
vlayout->addWidget(l);
|
||||||
vlayout->addSpacing(5);
|
vlayout->addSpacing(5);
|
||||||
cbauto = new DCheckBox(tr("AutoStart"), this);
|
cbauto = new DCheckBox(tr("AutoStart"), this);
|
||||||
vlayout->setMargin(20);
|
connect(cbauto, &DCheckBox::toggled, this, [=](bool v) {
|
||||||
|
|
||||||
|
});
|
||||||
vlayout->addWidget(cbauto, Qt::AlignTop);
|
vlayout->addWidget(cbauto, Qt::AlignTop);
|
||||||
|
|
||||||
|
vlayout->addSpacing(10);
|
||||||
|
l = new DLabel(tr("Shortcut"), this);
|
||||||
|
l->setFont(font);
|
||||||
|
vlayout->addWidget(l);
|
||||||
|
vlayout->addSpacing(5);
|
||||||
|
auto gw = new QWidget(w);
|
||||||
|
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);
|
||||||
|
auto hlayout = new QHBoxLayout(gw);
|
||||||
|
cbMod = new DComboBox(gw);
|
||||||
|
cbMod->addItems({"Ctrl", "Shift", "Alt", "Super"});
|
||||||
|
cbMod->setCurrentIndex(0);
|
||||||
|
hlayout->addWidget(cbMod);
|
||||||
|
cbMouseBtn = new DComboBox(gw);
|
||||||
|
cbMouseBtn->addItems(
|
||||||
|
{tr("Left"), tr("Right"), tr("Middle"), tr("XButton1"), tr("XButton2")});
|
||||||
|
cbMouseBtn->setCurrentIndex(2);
|
||||||
|
hlayout->addWidget(cbMouseBtn);
|
||||||
|
flayout->addRow(tr("ToolWin:"), hlayout);
|
||||||
|
|
||||||
|
vlayout->addSpacing(10);
|
||||||
|
l = new DLabel(tr("Config"), this);
|
||||||
|
l->setFont(font);
|
||||||
|
vlayout->addWidget(l);
|
||||||
|
vlayout->addSpacing(5);
|
||||||
|
auto group = new DButtonBox(this);
|
||||||
|
QList<DButtonBoxButton *> blist;
|
||||||
|
auto b = new DButtonBoxButton(tr("Export"), this);
|
||||||
|
connect(b, &DButtonBoxButton::clicked, this, [=] {
|
||||||
|
|
||||||
|
});
|
||||||
|
blist.append(b);
|
||||||
|
b = new DButtonBoxButton(tr("Import"), this);
|
||||||
|
connect(b, &DButtonBoxButton::clicked, this, [=] {
|
||||||
|
|
||||||
|
});
|
||||||
|
blist.append(b);
|
||||||
|
b = new DButtonBoxButton(tr("Reset"), this);
|
||||||
|
connect(b, &DButtonBoxButton::clicked, this, [=] {
|
||||||
|
|
||||||
|
});
|
||||||
|
blist.append(b);
|
||||||
|
group->setButtonList(blist, false);
|
||||||
|
vlayout->addWidget(group);
|
||||||
|
|
||||||
|
vlayout->addSpacing(10);
|
||||||
|
l = new DLabel(tr("Software"), this);
|
||||||
|
l->setFont(font);
|
||||||
|
vlayout->addWidget(l);
|
||||||
|
vlayout->addSpacing(5);
|
||||||
|
|
||||||
|
vlayout->addWidget(new DLabel(QString(tr("%1 , Ver %2 , by WingSummer."))
|
||||||
|
.arg(qApp->applicationName())
|
||||||
|
.arg(qApp->applicationVersion())));
|
||||||
|
|
||||||
vlayout->addStretch();
|
vlayout->addStretch();
|
||||||
tabs->addTab(w, tr("General"));
|
tabs->addTab(w, tr("General"));
|
||||||
|
|
||||||
// Hotkeys
|
// Hotkeys
|
||||||
w = new QWidget(this);
|
w = new QWidget(this);
|
||||||
vlayout = new QVBoxLayout(w);
|
vlayout = new QVBoxLayout(w);
|
||||||
auto group = new DButtonBox(this);
|
group = new DButtonBox(this);
|
||||||
vlayout->setMargin(20);
|
vlayout->setMargin(20);
|
||||||
QList<DButtonBoxButton *> blist;
|
blist.clear(); // 征用
|
||||||
auto b = new DButtonBoxButton(tr("Add"), this);
|
b = new DButtonBoxButton(tr("Add"), this);
|
||||||
connect(b, &DButtonBoxButton::clicked, this, &CenterWindow::on_addHotkey);
|
connect(b, &DButtonBoxButton::clicked, this, &CenterWindow::on_addHotkey);
|
||||||
blist.append(b);
|
blist.append(b);
|
||||||
b = new DButtonBoxButton(tr("Remove"), this);
|
b = new DButtonBoxButton(tr("Remove"), this);
|
||||||
|
@ -137,7 +202,7 @@ CenterWindow::CenterWindow(DMainWindow *parent) : DMainWindow(parent) {
|
||||||
auto tvlayout = new QVBoxLayout;
|
auto tvlayout = new QVBoxLayout;
|
||||||
|
|
||||||
auto gridsize = 40; // 默认 40 先
|
auto gridsize = 40; // 默认 40 先
|
||||||
auto gw = new QWidget(w);
|
gw = new QWidget(w);
|
||||||
gw->setFixedSize(gridsize * 3, gridsize * 3);
|
gw->setFixedSize(gridsize * 3, gridsize * 3);
|
||||||
auto mlayout = new QGridLayout(gw);
|
auto mlayout = new QGridLayout(gw);
|
||||||
mlayout->setMargin(1);
|
mlayout->setMargin(1);
|
||||||
|
@ -513,9 +578,42 @@ void CenterWindow::enableSelectedHotkeys(bool enable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CenterWindow::on_editToolWin() {}
|
void CenterWindow::on_editToolWin() {
|
||||||
|
auto sels = lstoolwin->selectedItems().count();
|
||||||
|
if (sels != 1) {
|
||||||
|
DMessageManager::instance()->sendMessage(this, ProgramIcon,
|
||||||
|
tr("PleaseSelectOne"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto index = lstoolwin->currentRow();
|
||||||
|
ToolEditDialog d(wintoolinfos[index]);
|
||||||
|
if (d.exec()) {
|
||||||
|
auto res = d.getResult();
|
||||||
|
wintoolinfos[index] = res;
|
||||||
|
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->setToolTip(res.process);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CenterWindow::on_removeToolWin() {}
|
void CenterWindow::on_removeToolWin() {
|
||||||
|
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>());
|
||||||
|
|
||||||
|
for (auto index : nums) {
|
||||||
|
wintoolinfos.removeAt(index);
|
||||||
|
auto item = lstoolwin->takeItem(index);
|
||||||
|
delete item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CenterWindow::on_clearToolWin() {
|
void CenterWindow::on_clearToolWin() {
|
||||||
lstoolwin->clear();
|
lstoolwin->clear();
|
||||||
|
@ -531,8 +629,19 @@ void CenterWindow::on_addToolWin() {
|
||||||
auto index = lstoolwin->currentRow();
|
auto index = lstoolwin->currentRow();
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
wintoolinfos.append(res);
|
wintoolinfos.append(res);
|
||||||
|
auto item = new QListWidgetItem(
|
||||||
|
Utilities::trimIconFromInfo(plgsys->plugin(res.pluginIndex), res),
|
||||||
|
res.isPlugin ? res.process : QFileInfo(res.process).fileName());
|
||||||
|
item->setToolTip(res.process);
|
||||||
|
lstoolwin->addItem(item);
|
||||||
} else {
|
} else {
|
||||||
|
wintoolinfos.insert(index + 1, res);
|
||||||
|
|
||||||
|
auto item = new QListWidgetItem(
|
||||||
|
Utilities::trimIconFromInfo(plgsys->plugin(res.pluginIndex), res),
|
||||||
|
res.isPlugin ? res.process : QFileInfo(res.process).fileName());
|
||||||
|
item->setToolTip(res.process);
|
||||||
|
lstoolwin->insertItem(index + 1, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,9 @@
|
||||||
#include "plugin/pluginsystem.h"
|
#include "plugin/pluginsystem.h"
|
||||||
#include "utilities.h"
|
#include "utilities.h"
|
||||||
#include <DCheckBox>
|
#include <DCheckBox>
|
||||||
|
#include <DComboBox>
|
||||||
#include <DDialog>
|
#include <DDialog>
|
||||||
|
#include <DKeySequenceEdit>
|
||||||
#include <DListWidget>
|
#include <DListWidget>
|
||||||
#include <DMainWindow>
|
#include <DMainWindow>
|
||||||
#include <DMenu>
|
#include <DMenu>
|
||||||
|
@ -91,6 +93,9 @@ private:
|
||||||
|
|
||||||
DIconButton *lbls[9] = {nullptr};
|
DIconButton *lbls[9] = {nullptr};
|
||||||
|
|
||||||
|
DKeySequenceEdit *kseqTool;
|
||||||
|
DComboBox *cbMod, *cbMouseBtn;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMap<Hotkey *, ToolStructInfo> scinfos; // 用于 Hotkeys
|
QMap<Hotkey *, ToolStructInfo> scinfos; // 用于 Hotkeys
|
||||||
QList<Hotkey *> hotkeys; // Hotkeys 方便进行检索
|
QList<Hotkey *> hotkeys; // Hotkeys 方便进行检索
|
||||||
|
|
|
@ -109,12 +109,12 @@ void ShortCutEditDialog::on_accept() {
|
||||||
res.provider = sel->provider();
|
res.provider = sel->provider();
|
||||||
res.pluginIndex = ps->getSelectedIndex();
|
res.pluginIndex = ps->getSelectedIndex();
|
||||||
} else {
|
} else {
|
||||||
|
res.process = fcedit->text();
|
||||||
if (res.process.isEmpty()) {
|
if (res.process.isEmpty()) {
|
||||||
DMessageManager::instance()->sendMessage(this, ProgramIcon,
|
DMessageManager::instance()->sendMessage(this, ProgramIcon,
|
||||||
tr("NoProcessSet"));
|
tr("NoProcessSet"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res.process = fcedit->text();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res.params = dledit->text();
|
res.params = dledit->text();
|
||||||
|
|
|
@ -12,6 +12,11 @@ class ToolBoxWindow : public DDialog {
|
||||||
public:
|
public:
|
||||||
ToolBoxWindow(DMainWindow *parent = nullptr);
|
ToolBoxWindow(DMainWindow *parent = nullptr);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void addItem(QListWidgetItem *item, int index = -1); // -1 表示追加
|
||||||
|
void rmItem(int index); // -1 表示清空
|
||||||
|
void mvItem(int from, int to);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DListWidget *lstool;
|
DListWidget *lstool;
|
||||||
};
|
};
|
||||||
|
|
|
@ -81,12 +81,12 @@ void ToolEditDialog::on_accept() {
|
||||||
res.provider = sel->provider();
|
res.provider = sel->provider();
|
||||||
res.pluginIndex = ps->getSelectedIndex();
|
res.pluginIndex = ps->getSelectedIndex();
|
||||||
} else {
|
} else {
|
||||||
|
res.process = fcedit->text();
|
||||||
if (res.process.isEmpty()) {
|
if (res.process.isEmpty()) {
|
||||||
DMessageManager::instance()->sendMessage(this, ProgramIcon,
|
DMessageManager::instance()->sendMessage(this, ProgramIcon,
|
||||||
tr("NoProcessSet"));
|
tr("NoProcessSet"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res.process = fcedit->text();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res.params = dledit->text();
|
res.params = dledit->text();
|
||||||
|
|
5
main.cpp
5
main.cpp
|
@ -49,6 +49,7 @@ int main(int argc, char *argv[]) {
|
||||||
a.setOrganizationName("WingCloud");
|
a.setOrganizationName("WingCloud");
|
||||||
a.setApplicationName(QObject::tr("WingTool"));
|
a.setApplicationName(QObject::tr("WingTool"));
|
||||||
a.setApplicationVersion("1.0.0");
|
a.setApplicationVersion("1.0.0");
|
||||||
|
a.setApplicationLicense("AGPL-3.0");
|
||||||
|
|
||||||
QIcon picon = ProgramIcon;
|
QIcon picon = ProgramIcon;
|
||||||
a.setProductIcon(picon);
|
a.setProductIcon(picon);
|
||||||
|
@ -128,8 +129,10 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
QObject::connect(&systray, &QSystemTrayIcon::activated,
|
QObject::connect(&systray, &QSystemTrayIcon::activated,
|
||||||
[&w](QSystemTrayIcon::ActivationReason reason) {
|
[&w](QSystemTrayIcon::ActivationReason reason) {
|
||||||
if (reason == QSystemTrayIcon::ActivationReason::Trigger)
|
if (reason == QSystemTrayIcon::ActivationReason::Trigger) {
|
||||||
w.show(CenterWindow::TabPage::General);
|
w.show(CenterWindow::TabPage::General);
|
||||||
|
Utilities::activeWindowFromDock(w.winId());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Dtk::Widget::moveToCenter(&w);
|
Dtk::Widget::moveToCenter(&w);
|
||||||
|
|
30
utilities.h
30
utilities.h
|
@ -4,7 +4,9 @@
|
||||||
#include "plugin/iwingtoolplg.h"
|
#include "plugin/iwingtoolplg.h"
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
|
#include <QMimeDatabase>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QtDBus>
|
||||||
|
|
||||||
#define ProgramIcon QIcon(":/images/logo.svg")
|
#define ProgramIcon QIcon(":/images/logo.svg")
|
||||||
#define ICONRES(name) QIcon(":/images/" name ".png")
|
#define ICONRES(name) QIcon(":/images/" name ".png")
|
||||||
|
@ -28,14 +30,42 @@ struct ToolStructInfo {
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(ToolStructInfo)
|
Q_DECLARE_METATYPE(ToolStructInfo)
|
||||||
|
|
||||||
|
class PluginSystem;
|
||||||
|
|
||||||
class Utilities {
|
class Utilities {
|
||||||
public:
|
public:
|
||||||
|
static bool activeWindowFromDock(quintptr winId) {
|
||||||
|
bool bRet = true;
|
||||||
|
// new interface use application as id
|
||||||
|
QDBusInterface dockDbusInterface("com.deepin.dde.daemon.Dock",
|
||||||
|
"/com/deepin/dde/daemon/Dock",
|
||||||
|
"com.deepin.dde.daemon.Dock");
|
||||||
|
QDBusReply<void> reply = dockDbusInterface.call("ActivateWindow", winId);
|
||||||
|
if (!reply.isValid()) {
|
||||||
|
qDebug() << "call com.deepin.dde.daemon.Dock failed" << reply.error();
|
||||||
|
bRet = false;
|
||||||
|
}
|
||||||
|
return bRet;
|
||||||
|
}
|
||||||
|
|
||||||
static QIcon processPluginIcon(IWingToolPlg *plg) {
|
static QIcon processPluginIcon(IWingToolPlg *plg) {
|
||||||
if (plg->pluginIcon().isNull()) {
|
if (plg->pluginIcon().isNull()) {
|
||||||
return ICONRES("plugin");
|
return ICONRES("plugin");
|
||||||
}
|
}
|
||||||
return plg->pluginIcon();
|
return plg->pluginIcon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static QIcon trimIconFromInfo(IWingToolPlg *plg, ToolStructInfo &info) {
|
||||||
|
if (info.isPlugin) {
|
||||||
|
if (plg == nullptr)
|
||||||
|
return QIcon();
|
||||||
|
return plg->pluginIcon();
|
||||||
|
} else {
|
||||||
|
QMimeDatabase db;
|
||||||
|
auto t = db.mimeTypeForFile(info.process);
|
||||||
|
return QIcon::fromTheme(t.iconName(), QIcon(t.iconName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UTILIES_H
|
#endif // UTILIES_H
|
||||||
|
|
Loading…
Reference in New Issue