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
e2d4a0b885
commit
a02e283699
@ -7,7 +7,6 @@
|
|||||||
* code directory.
|
* code directory.
|
||||||
**************************************************************************************************/
|
**************************************************************************************************/
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "ui_MainWindow.h"
|
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QActionGroup>
|
#include <QActionGroup>
|
||||||
@ -34,6 +33,8 @@
|
|||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
#include <QMenuBar>
|
||||||
|
#include <QStatusBar>
|
||||||
|
|
||||||
#include "xToolsDataStructure.h"
|
#include "xToolsDataStructure.h"
|
||||||
#include "xToolsInterface.h"
|
#include "xToolsInterface.h"
|
||||||
@ -64,10 +65,10 @@ QString palettePath()
|
|||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget* parent)
|
MainWindow::MainWindow(QWidget* parent)
|
||||||
: QMainWindow(parent)
|
: xToolsMainWindow(parent)
|
||||||
, ui(new Ui::MainWindow)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
QStackedWidget *stackedWidget = new QStackedWidget();
|
||||||
|
setCentralWidget(stackedWidget);
|
||||||
|
|
||||||
QDir dir;
|
QDir dir;
|
||||||
if (dir.exists(palettePath())) {
|
if (dir.exists(palettePath())) {
|
||||||
@ -112,7 +113,7 @@ MainWindow::MainWindow(QWidget* parent)
|
|||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
delete ui;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::initMenuBar()
|
void MainWindow::initMenuBar()
|
||||||
@ -121,8 +122,8 @@ void MainWindow::initMenuBar()
|
|||||||
|
|
||||||
initFileMenu();
|
initFileMenu();
|
||||||
initToolMenu();
|
initToolMenu();
|
||||||
initOptionMenu();
|
//initOptionMenu();
|
||||||
initLanguageMenu();
|
//initLanguageMenu();
|
||||||
initLinksMenu();
|
initLinksMenu();
|
||||||
initHelpMenu();
|
initHelpMenu();
|
||||||
}
|
}
|
||||||
@ -141,11 +142,9 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
|||||||
|
|
||||||
void MainWindow::initFileMenu()
|
void MainWindow::initFileMenu()
|
||||||
{
|
{
|
||||||
QMenu* fileMenu = new QMenu(tr("&File"), this);
|
|
||||||
menuBar()->addMenu(fileMenu);
|
|
||||||
// Tool box
|
// Tool box
|
||||||
QMenu* windowMenu = new QMenu(tr("New Window"), this);
|
QMenu* windowMenu = new QMenu(tr("New Window"), this);
|
||||||
fileMenu->addMenu(windowMenu);
|
m_fileMenu->addMenu(windowMenu);
|
||||||
QList<int> toolTypeList = xToolsToolBoxUi::supportedCommunicationTools();
|
QList<int> toolTypeList = xToolsToolBoxUi::supportedCommunicationTools();
|
||||||
for (auto& toolType : toolTypeList) {
|
for (auto& toolType : toolTypeList) {
|
||||||
const QString name = xToolsToolBoxUi::communicationToolName(toolType);
|
const QString name = xToolsToolBoxUi::communicationToolName(toolType);
|
||||||
@ -186,25 +185,25 @@ void MainWindow::initFileMenu()
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fileMenu->addSeparator();
|
m_fileMenu->addSeparator();
|
||||||
QAction* importAction = new QAction(tr("Import Palette"), fileMenu);
|
QAction* importAction = new QAction(tr("Import Palette"), m_fileMenu);
|
||||||
fileMenu->addAction(importAction);
|
m_fileMenu->addAction(importAction);
|
||||||
connect(importAction, &QAction::triggered, this, &MainWindow::onImportActionTriggered);
|
connect(importAction, &QAction::triggered, this, &MainWindow::onImportActionTriggered);
|
||||||
|
|
||||||
QAction* exportAction = new QAction(tr("Export Palette"), fileMenu);
|
QAction* exportAction = new QAction(tr("Export Palette"), m_fileMenu);
|
||||||
fileMenu->addAction(exportAction);
|
m_fileMenu->addAction(exportAction);
|
||||||
connect(exportAction, &QAction::triggered, this, &MainWindow::onExportActionTriggered);
|
connect(exportAction, &QAction::triggered, this, &MainWindow::onExportActionTriggered);
|
||||||
|
|
||||||
fileMenu->addSeparator();
|
m_fileMenu->addSeparator();
|
||||||
QAction* exitAction = new QAction(tr("Exit"), this);
|
QAction* exitAction = new QAction(tr("Exit"), this);
|
||||||
fileMenu->addAction(exitAction);
|
m_fileMenu->addAction(exitAction);
|
||||||
connect(exitAction, SIGNAL(triggered(bool)), this, SLOT(close()));
|
connect(exitAction, SIGNAL(triggered(bool)), this, SLOT(close()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::initToolMenu()
|
void MainWindow::initToolMenu()
|
||||||
{
|
{
|
||||||
QMenu* toolMenu = new QMenu(tr("&Tools"));
|
QMenu* toolMenu = new QMenu(tr("&Tools"));
|
||||||
menuBar()->addMenu(toolMenu);
|
menuBar()->insertMenu(m_languageMenu->menuAction(), toolMenu);
|
||||||
|
|
||||||
for (auto& t : SAKAssistantsFactory::instance()->supportedAssistants()) {
|
for (auto& t : SAKAssistantsFactory::instance()->supportedAssistants()) {
|
||||||
QString name = SAKAssistantsFactory::instance()->assistantName(t);
|
QString name = SAKAssistantsFactory::instance()->assistantName(t);
|
||||||
@ -525,29 +524,27 @@ void MainWindow::initLanguageMenu()
|
|||||||
|
|
||||||
void MainWindow::initHelpMenu()
|
void MainWindow::initHelpMenu()
|
||||||
{
|
{
|
||||||
QMenu* helpMenu = new QMenu(tr("&Help"), this);
|
|
||||||
menuBar()->addMenu(helpMenu);
|
|
||||||
QAction* aboutQtAction = new QAction(tr("About Qt"), this);
|
QAction* aboutQtAction = new QAction(tr("About Qt"), this);
|
||||||
helpMenu->addAction(aboutQtAction);
|
m_helpMenu->addAction(aboutQtAction);
|
||||||
connect(aboutQtAction, &QAction::triggered, this, [=]() {
|
connect(aboutQtAction, &QAction::triggered, this, [=]() {
|
||||||
QMessageBox::aboutQt(this, tr("About Qt"));
|
QMessageBox::aboutQt(this, tr("About Qt"));
|
||||||
});
|
});
|
||||||
|
|
||||||
QAction* aboutAction = new QAction(tr("About xTools"), this);
|
QAction* aboutAction = new QAction(tr("About xTools"), this);
|
||||||
helpMenu->addAction(aboutAction);
|
m_helpMenu->addAction(aboutAction);
|
||||||
connect(aboutAction, &QAction::triggered, this, &MainWindow::aboutSoftware);
|
connect(aboutAction, &QAction::triggered, this, &MainWindow::aboutSoftware);
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QString tips = tr("Buy from Microsoft App Store");
|
QString tips = tr("Buy from Microsoft App Store");
|
||||||
QIcon buy(":/Resources/Icons/IconBuy.svg");
|
QIcon buy(":/Resources/Icons/IconBuy.svg");
|
||||||
QAction* microsoft = new QAction(buy, tips);
|
QAction* microsoft = new QAction(buy, tips);
|
||||||
helpMenu->addAction(microsoft);
|
m_helpMenu->addAction(microsoft);
|
||||||
connect(microsoft, &QAction::triggered, this, []() {
|
connect(microsoft, &QAction::triggered, this, []() {
|
||||||
QUrl url("https://www.microsoft.com/store/apps/9P29H1NDNKBB");
|
QUrl url("https://www.microsoft.com/store/apps/9P29H1NDNKBB");
|
||||||
QDesktopServices::openUrl(url);
|
QDesktopServices::openUrl(url);
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
QMenu* srcMenu = new QMenu(tr("Get Source"), this);
|
QMenu* srcMenu = new QMenu(tr("Get Source"), this);
|
||||||
helpMenu->addMenu(srcMenu);
|
m_helpMenu->addMenu(srcMenu);
|
||||||
QAction* visitGitHubAction = new QAction(QIcon(":/resources/images/GitHub.png"),
|
QAction* visitGitHubAction = new QAction(QIcon(":/resources/images/GitHub.png"),
|
||||||
tr("GitHub"),
|
tr("GitHub"),
|
||||||
this);
|
this);
|
||||||
@ -566,22 +563,22 @@ void MainWindow::initHelpMenu()
|
|||||||
srcMenu->addAction(visitGiteeAction);
|
srcMenu->addAction(visitGiteeAction);
|
||||||
|
|
||||||
QAction* releaseHistoryAction = new QAction(tr("Release History"), this);
|
QAction* releaseHistoryAction = new QAction(tr("Release History"), this);
|
||||||
helpMenu->addAction(releaseHistoryAction);
|
m_helpMenu->addAction(releaseHistoryAction);
|
||||||
connect(releaseHistoryAction, &QAction::triggered, this, &MainWindow::showHistory);
|
connect(releaseHistoryAction, &QAction::triggered, this, &MainWindow::showHistory);
|
||||||
|
|
||||||
helpMenu->addSeparator();
|
m_helpMenu->addSeparator();
|
||||||
QAction* qrCodeAction = new QAction(tr("QR Code"), this);
|
QAction* qrCodeAction = new QAction(tr("QR Code"), this);
|
||||||
helpMenu->addAction(qrCodeAction);
|
m_helpMenu->addAction(qrCodeAction);
|
||||||
connect(qrCodeAction, &QAction::triggered, this, &MainWindow::showQrCode);
|
connect(qrCodeAction, &QAction::triggered, this, &MainWindow::showQrCode);
|
||||||
#ifndef X_TOOLS_IMPORT_MODULE_PRIVATE
|
#ifndef X_TOOLS_IMPORT_MODULE_PRIVATE
|
||||||
helpMenu->addAction(tr("Donate"), this, &MainWindow::showDonation);
|
m_helpMenu->addAction(tr("Donate"), this, &MainWindow::showDonation);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::initLinksMenu()
|
void MainWindow::initLinksMenu()
|
||||||
{
|
{
|
||||||
QMenu* linksMenu = new QMenu(tr("&Links"), this);
|
QMenu* linksMenu = new QMenu(tr("&Links"), this);
|
||||||
menuBar()->addMenu(linksMenu);
|
menuBar()->insertMenu(m_helpMenu->menuAction(), linksMenu);
|
||||||
|
|
||||||
struct Link
|
struct Link
|
||||||
{
|
{
|
||||||
@ -728,24 +725,24 @@ void MainWindow::initNav(const NavContext& ctx)
|
|||||||
if (ctx.page->layout()) {
|
if (ctx.page->layout()) {
|
||||||
ctx.page->layout()->setContentsMargins(0, 0, 0, 0);
|
ctx.page->layout()->setContentsMargins(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
ui->stackedWidget->addWidget(ctx.page);
|
auto stackedWidget = qobject_cast<QStackedWidget*>(centralWidget());
|
||||||
|
stackedWidget->addWidget(ctx.page);
|
||||||
|
|
||||||
int pageCount = ctx.bg->buttons().count();
|
int pageCount = ctx.bg->buttons().count();
|
||||||
QObject::connect(bt, &QToolButton::clicked, bt, [=]() {
|
QObject::connect(bt, &QToolButton::clicked, bt, [=]() {
|
||||||
ui->stackedWidget->setCurrentIndex(pageCount - 1);
|
stackedWidget->setCurrentIndex(pageCount - 1);
|
||||||
xToolsSettings::instance()->setPageIndex(pageCount - 1);
|
xToolsSettings::instance()->setPageIndex(pageCount - 1);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (xToolsSettings::instance()->pageIndex() == (pageCount - 1)) {
|
if (xToolsSettings::instance()->pageIndex() == (pageCount - 1)) {
|
||||||
bt->setChecked(true);
|
bt->setChecked(true);
|
||||||
ui->stackedWidget->setCurrentIndex(pageCount - 1);
|
stackedWidget->setCurrentIndex(pageCount - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::initStatusBar()
|
void MainWindow::initStatusBar()
|
||||||
{
|
{
|
||||||
ui->statusbar->showMessage("Hello world", 10 * 1000);
|
statusBar()->showMessage("Hello world", 10 * 1000);
|
||||||
ui->statusbar->hide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::aboutSoftware()
|
void MainWindow::aboutSoftware()
|
||||||
|
|||||||
@ -13,7 +13,6 @@
|
|||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLoggingCategory>
|
#include <QLoggingCategory>
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMetaEnum>
|
#include <QMetaEnum>
|
||||||
@ -22,11 +21,9 @@
|
|||||||
#include <QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
|
||||||
namespace Ui {
|
#include "xToolsMainWindow.h"
|
||||||
class MainWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public xToolsMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -54,7 +51,6 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const QLoggingCategory mLoggingCategory{"sak.mainwindow"};
|
const QLoggingCategory mLoggingCategory{"sak.mainwindow"};
|
||||||
Ui::MainWindow* ui;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initMenuBar();
|
void initMenuBar();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user