mirror of
https://github.com/x-tools-author/x-tools.git
synced 2025-09-15 15:28:40 +08:00
chore: update files of project
This commit is contained in:
parent
80b6641a3c
commit
e9359d4768
@ -170,6 +170,28 @@ void xToolsApplication::setValidator(QLineEdit *target, int validatorType, int m
|
||||
target->setMaxLength(maxLength);
|
||||
}
|
||||
|
||||
QIcon xToolsApplication::cookedIcon(const QIcon &icon)
|
||||
{
|
||||
QPixmap pixmap = icon.pixmap(QSize(128, 128));
|
||||
QPainter painter(&pixmap);
|
||||
painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||
painter.fillRect(pixmap.rect(), qApp->palette().windowText().color());
|
||||
QIcon colorIcon = QIcon(pixmap);
|
||||
return colorIcon;
|
||||
}
|
||||
|
||||
QMainWindow *xToolsApplication::mainWindow()
|
||||
{
|
||||
for (const auto& it : qobject_cast<QApplication*>(qApp)->topLevelWidgets()) {
|
||||
auto w = qobject_cast<QMainWindow*>(it);
|
||||
if (w) {
|
||||
return w;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void xToolsApplication::setMaximumBlockCount(QVariant doc, int maximum)
|
||||
{
|
||||
auto obj = doc.value<QObject *>();
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include <QApplication>
|
||||
#include <QPixmap>
|
||||
#include <QSplashScreen>
|
||||
#include <QMainWindow>
|
||||
|
||||
class QLineEdit;
|
||||
class xToolsApplication : public QApplication
|
||||
@ -36,6 +37,8 @@ public:
|
||||
|
||||
public:
|
||||
static void setValidator(QLineEdit *target, int validatorType, int maxLength = INT_MAX);
|
||||
static QIcon cookedIcon(const QIcon &icon);
|
||||
static QMainWindow *mainWindow();
|
||||
|
||||
Q_INVOKABLE static void setMaximumBlockCount(QVariant doc, int maximum);
|
||||
Q_INVOKABLE static void setClipboardText(const QString &text);
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
#include "xToolsAssistantFactory.h"
|
||||
#include "xToolsSettings.h"
|
||||
#include "xToolsToolBoxUi.h"
|
||||
#include "xToolsUiInterface.h"
|
||||
#include "xToolsApplication.h"
|
||||
#ifdef X_TOOLS_IMPORT_MODULE_CANBUS_STUDIO
|
||||
#include "xToolsCanBusStudioUi.h"
|
||||
#endif
|
||||
@ -317,7 +317,7 @@ void MainWindow::initNav()
|
||||
xToolsToolBoxUi* toolBoxUi = new xToolsToolBoxUi(this);
|
||||
toolBoxUi->initialize(type);
|
||||
|
||||
auto icon = xToolsUiInterface::cookedIcon(toolBoxUi->windowIcon());
|
||||
auto icon = xToolsApplication::cookedIcon(toolBoxUi->windowIcon());
|
||||
initNav({&btGroup, icon, toolBoxUi->windowTitle(), toolBoxUi, tb});
|
||||
}
|
||||
|
||||
@ -334,13 +334,13 @@ void MainWindow::initNavStudio(QButtonGroup* buttonGroup, QToolBar* toolBar)
|
||||
QString path = ":/Resources/Icons/IconModbus.svg";
|
||||
#ifdef X_TOOLS_IMPORT_MODULE_MODBUS_STUDIO
|
||||
xToolsModbusStudioUi* modbus = new xToolsModbusStudioUi(this);
|
||||
auto icon = xToolsUiInterface::cookedIcon(QIcon(path));
|
||||
auto icon = xToolsApplication::cookedIcon(QIcon(path));
|
||||
initNav({buttonGroup, icon, "Modbus Studio", modbus, toolBar});
|
||||
#endif
|
||||
#ifdef X_TOOLS_IMPORT_MODULE_CANBUS_STUDIO
|
||||
xToolsCanBusStudioUi* canbus = new xToolsCanBusStudioUi(this);
|
||||
path = ":/Resources/Icons/IconCanBus.svg";
|
||||
icon = xToolsUiInterface::cookedIcon(QIcon(path));
|
||||
icon = xToolsApplication::cookedIcon(QIcon(path));
|
||||
initNav({buttonGroup, icon, "CANBus Studio", canbus, toolBar});
|
||||
#endif
|
||||
}
|
||||
@ -390,7 +390,7 @@ void MainWindow::intNavControlButton(QButtonGroup* buttonGroup, QToolBar* toolBa
|
||||
auto style = isTextBesideIcon ? Qt::ToolButtonTextBesideIcon : Qt::ToolButtonIconOnly;
|
||||
QToolButton* tbt = new QToolButton(this);
|
||||
const QString path = ":/Resources/Icons/IconListWithIcon.svg";
|
||||
tbt->setIcon(xToolsUiInterface::cookedIcon(QIcon(path)));
|
||||
tbt->setIcon(xToolsApplication::cookedIcon(QIcon(path)));
|
||||
tbt->setText(" " + tr("Show Icon Only"));
|
||||
tbt->setToolTip(tr("Click to show(hide) nav text"));
|
||||
tbt->setAutoRaise(true);
|
||||
|
||||
@ -36,7 +36,7 @@
|
||||
#include "xToolsToolBoxUiOutputMenu.h"
|
||||
#include "xToolsToolFactory.h"
|
||||
#include "xToolsUdpTransmitterToolUi.h"
|
||||
#include "xToolsUiInterface.h"
|
||||
#include "xToolsApplication.h"
|
||||
#include "xToolsWebSocketTransmitterToolUi.h"
|
||||
|
||||
#ifdef X_TOOLS_IMPORT_MODULE_BLUETOOTH
|
||||
@ -736,7 +736,7 @@ void xToolsToolBoxUi::onComboBoxInputFormatActivated()
|
||||
int format = ui->comboBoxInputFormat->currentData().toInt();
|
||||
auto lineEdit = ui->comboBoxInputText->lineEdit();
|
||||
ui->comboBoxInputText->clear();
|
||||
xToolsUiInterface::setValidator(lineEdit, format);
|
||||
xToolsApplication::setValidator(lineEdit, format);
|
||||
}
|
||||
|
||||
void xToolsToolBoxUi::onComboBoxInputTextActivated()
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
#include "xToolsAnalyzerTool.h"
|
||||
#include "xToolsDataStructure.h"
|
||||
#include "xToolsUiInterface.h"
|
||||
#include "xToolsApplication.h"
|
||||
|
||||
xToolsAnalyzerToolUi::xToolsAnalyzerToolUi(QWidget *parent)
|
||||
: xToolsBaseToolUi{parent}
|
||||
@ -28,7 +28,7 @@ void xToolsAnalyzerToolUi::setToolName(const QString &name)
|
||||
void xToolsAnalyzerToolUi::onBaseToolUiInitialized(xToolsBaseTool *tool, const QString &settingsGroup)
|
||||
{
|
||||
int format = xToolsDataStructure::TextFormatHex;
|
||||
xToolsUiInterface::setValidator(ui->lineEditSeparationMark, format);
|
||||
xToolsApplication::setValidator(ui->lineEditSeparationMark, format);
|
||||
|
||||
ui->checkBoxEnable->setGroupKey(settingsGroup, "analyzerEnable");
|
||||
ui->checkBoxFixedLength->setGroupKey(settingsGroup, "fxiedLength");
|
||||
|
||||
@ -9,12 +9,12 @@
|
||||
#include "xToolsEmitterToolUi.h"
|
||||
|
||||
#include "xToolsTableModelTool.h"
|
||||
#include "xToolsUiInterface.h"
|
||||
#include "xToolsApplication.h"
|
||||
|
||||
xToolsEmitterToolUi::xToolsEmitterToolUi(QWidget *parent)
|
||||
: xToolsTableModelToolUi{"sak.emittertoolui", parent}
|
||||
{
|
||||
mEditor = new xToolsEmitterToolUiEditor(xToolsUiInterface::mainWindow());
|
||||
mEditor = new xToolsEmitterToolUiEditor(xToolsApplication::mainWindow());
|
||||
}
|
||||
|
||||
xToolsEmitterToolUi::~xToolsEmitterToolUi() {}
|
||||
|
||||
@ -18,12 +18,12 @@
|
||||
#include "xToolsMenu.h"
|
||||
#include "xToolsPrestorerTool.h"
|
||||
#include "xToolsPrestorerToolUiEditor.h"
|
||||
#include "xToolsUiInterface.h"
|
||||
#include "xToolsApplication.h"
|
||||
|
||||
xToolsPrestorerToolUi::xToolsPrestorerToolUi(QWidget *parent)
|
||||
: xToolsTableModelToolUi{"SAK.PrestorerToolUi", parent}
|
||||
{
|
||||
mEditor = new xToolsPrestorerToolUiEditor(xToolsUiInterface::mainWindow());
|
||||
mEditor = new xToolsPrestorerToolUiEditor(xToolsApplication::mainWindow());
|
||||
mMenu = new xToolsMenu();
|
||||
}
|
||||
|
||||
|
||||
@ -17,12 +17,12 @@
|
||||
#include <QVariant>
|
||||
|
||||
#include "xToolsTableModelTool.h"
|
||||
#include "xToolsUiInterface.h"
|
||||
#include "xToolsApplication.h"
|
||||
|
||||
xToolsResponserToolUi::xToolsResponserToolUi(QWidget *parent)
|
||||
: xToolsTableModelToolUi{"sak.responsertoolui", parent}
|
||||
{
|
||||
mEditor = new xToolsResponserToolUiEditor(xToolsUiInterface::mainWindow());
|
||||
mEditor = new xToolsResponserToolUiEditor(xToolsApplication::mainWindow());
|
||||
}
|
||||
|
||||
xToolsResponserToolUi::~xToolsResponserToolUi() {}
|
||||
|
||||
@ -8,12 +8,12 @@
|
||||
**************************************************************************************************/
|
||||
#include "xToolsSerialPortTransmitterToolUi.h"
|
||||
|
||||
#include "xToolsUiInterface.h"
|
||||
#include "xToolsApplication.h"
|
||||
|
||||
xToolsSerialPortTransmitterToolUi::xToolsSerialPortTransmitterToolUi(QWidget *parent)
|
||||
: xToolsTransmitterToolUi("SAK.SerialPortTransmitterToolUi", parent)
|
||||
{
|
||||
mEditor = new xToolsSerialPortTransmitterToolUiEditor(xToolsUiInterface::mainWindow());
|
||||
mEditor = new xToolsSerialPortTransmitterToolUiEditor(xToolsApplication::mainWindow());
|
||||
}
|
||||
|
||||
void xToolsSerialPortTransmitterToolUi::onBaseToolUiInitialized(xToolsBaseTool *tool,
|
||||
|
||||
@ -8,12 +8,12 @@
|
||||
**************************************************************************************************/
|
||||
#include "xToolsSocketClientTransmitterToolUi.h"
|
||||
|
||||
#include "xToolsUiInterface.h"
|
||||
#include "xToolsApplication.h"
|
||||
|
||||
xToolsSocketClientTransmitterToolUi::xToolsSocketClientTransmitterToolUi(const char *lg, QWidget *parent)
|
||||
: xToolsTransmitterToolUi(lg, parent)
|
||||
{
|
||||
mEditor = new xToolsSocketClientTransmitterToolUiEditor(xToolsUiInterface::mainWindow());
|
||||
mEditor = new xToolsSocketClientTransmitterToolUiEditor(xToolsApplication::mainWindow());
|
||||
}
|
||||
|
||||
QDialog *xToolsSocketClientTransmitterToolUi::itemEditor()
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
#include "xToolsMenu.h"
|
||||
#include "xToolsSettings.h"
|
||||
#include "xToolsTableModelTool.h"
|
||||
#include "xToolsUiInterface.h"
|
||||
#include "xToolsApplication.h"
|
||||
|
||||
xToolsTableModelToolUi::xToolsTableModelToolUi(const char *lg, QWidget *parent)
|
||||
: xToolsBaseToolUi{parent}
|
||||
@ -284,7 +284,7 @@ QModelIndex xToolsTableModelToolUi::currentIndex()
|
||||
{
|
||||
QModelIndex index = ui->tableView->currentIndex();
|
||||
if (!index.isValid()) {
|
||||
QMessageBox::warning(xToolsUiInterface::mainWindow(),
|
||||
QMessageBox::warning(xToolsApplication::mainWindow(),
|
||||
tr("Please Select an Item"),
|
||||
tr("Please select an tiem first,"
|
||||
" then try again!"));
|
||||
@ -301,7 +301,7 @@ void xToolsTableModelToolUi::writeToSettingsFile()
|
||||
bool xToolsTableModelToolUi::isInitialized()
|
||||
{
|
||||
if (!mTableModelTool) {
|
||||
QMessageBox::warning(xToolsUiInterface::mainWindow(),
|
||||
QMessageBox::warning(xToolsApplication::mainWindow(),
|
||||
tr("Invalid Parameter"),
|
||||
tr("The value of mTableModelTool is nullptr,"
|
||||
" you must called initialize() first!"));
|
||||
@ -330,7 +330,7 @@ void xToolsTableModelToolUi::onPushButtonClearClicked()
|
||||
return;
|
||||
}
|
||||
|
||||
int ret = QMessageBox::warning(xToolsUiInterface::mainWindow(),
|
||||
int ret = QMessageBox::warning(xToolsApplication::mainWindow(),
|
||||
tr("Clear Data"),
|
||||
tr("The data will be empty from settings file, "
|
||||
"please confrim the operation!"),
|
||||
@ -347,7 +347,7 @@ void xToolsTableModelToolUi::onPushButtonDeleteClicked()
|
||||
return;
|
||||
}
|
||||
|
||||
int ret = QMessageBox::warning(xToolsUiInterface::mainWindow(),
|
||||
int ret = QMessageBox::warning(xToolsApplication::mainWindow(),
|
||||
tr("Delete Data"),
|
||||
tr("The data will be delete from settings file, "
|
||||
"please confrim the operation!"),
|
||||
@ -370,7 +370,7 @@ void xToolsTableModelToolUi::onPushButtonImportClicked()
|
||||
return;
|
||||
}
|
||||
|
||||
QString fileName = QFileDialog::getOpenFileName(xToolsUiInterface::mainWindow(),
|
||||
QString fileName = QFileDialog::getOpenFileName(xToolsApplication::mainWindow(),
|
||||
tr("Import data"),
|
||||
".",
|
||||
tr("JSON (*.json);;All (*)"));
|
||||
@ -397,7 +397,7 @@ void xToolsTableModelToolUi::onPushButtonExportClicked()
|
||||
return;
|
||||
}
|
||||
|
||||
QString fileName = QFileDialog::getSaveFileName(xToolsUiInterface::mainWindow(),
|
||||
QString fileName = QFileDialog::getSaveFileName(xToolsApplication::mainWindow(),
|
||||
tr("Import data"),
|
||||
".",
|
||||
tr("JSON (*.json);;All (*); "));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user