123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- #include "mainwindow.h"
- #include <QApplication>
- #include <QFile>
- #include <QTextEdit>
- #include <QAbstractButton>
- #include <QFileDialog>
- #include "SARibbonBar.h"
- #include "SARibbonCategory.h"
- #include <QPushButton>
- #include <QMessageBox>
- #include "SARibbonPannel.h"
- #include "SARibbonToolButton.h"
- #include <QAction>
- #include <QMenu>
- #include <QStatusBar>
- #include <QDebug>
- #include <QElapsedTimer>
- #include <QRadioButton>
- #include <QButtonGroup>
- #include <QSpinBox>
- #include <QSplitter>
- #include <QLineEdit>
- #include <QCalendarWidget>
- #include <QXmlStreamWriter>
- #include <QTextStream>
- #include <QFontComboBox>
- #include <QLabel>
- #include "SARibbonMenu.h"
- #include "SARibbonComboBox.h"
- #include "SARibbonLineEdit.h"
- #include "SARibbonGallery.h"
- #include "SARibbonCheckBox.h"
- #include "SARibbonQuickAccessBar.h"
- #include "SARibbonButtonGroupWidget.h"
- #include "SARibbonApplicationButton.h"
- #include "SARibbonCustomizeWidget.h"
- #include "SARibbonElementManager.h"
- #include "SARibbonCustomizeDialog.h"
- #include "SARibbonColorToolButton.h"
- #include "SAFramelessHelper.h"
- #include "colorWidgets/SAColorPaletteGridWidget.h"
- #include "colorWidgets/SAColorGridWidget.h"
- #include <QDockWidget>
- #define PRINT_COST_START() \
- QElapsedTimer __TMP_COST; \
- __TMP_COST.start(); \
- int __TMP_LASTTIMES = 0
- #define PRINT_COST(STR) \
- do { \
- int ___TMP_INT = __TMP_COST.elapsed(); \
- qDebug() << STR << " cost " << ___TMP_INT - __TMP_LASTTIMES << " ms (" << ___TMP_INT << ")"; \
- m_edit->append(QString("%1 cost %2 ms(%3)").arg(STR).arg(___TMP_INT - __TMP_LASTTIMES).arg(___TMP_INT)); \
- __TMP_LASTTIMES = ___TMP_INT; \
- } while (0)
- MainWindow::MainWindow(QWidget* par) : SARibbonMainWindow(par), m_customizeWidget(nullptr)
- {
- PRINT_COST_START();
- mTreeList = new QDockWidget("菜单",this);
- mTreeList->setFeatures(QDockWidget::NoDockWidgetFeatures);
- addDockWidget(Qt::LeftDockWidgetArea,mTreeList);
- addTreeList(mTreeList);
- mConsole = new QDockWidget("控制台",this);
- addDockWidget(Qt::BottomDockWidgetArea,mConsole);
- mConsole->setAllowedAreas(Qt::BottomDockWidgetArea);
- mCent = new QDockWidget("主界面",this);
- addDockWidget(Qt::RightDockWidgetArea,mCent);
- mCent->setFeatures(QDockWidget::NoDockWidgetFeatures);
- setCorner(Qt::BottomLeftCorner,Qt::LeftDockWidgetArea);
- setCentralWidget(mCent);
- SAFramelessHelper* helper = framelessHelper();
- helper->setRubberBandOnResize(false);
- //setWindowTitle(("ribbon mainwindow test"));
- m_edit = new QTextEdit(this);
- mConsole->setWidget(m_edit);
- setStatusBar(new QStatusBar());
- SARibbonBar* ribbon = ribbonBar();
- //通过setContentsMargins设置ribbon四周的间距
- ribbon->setContentsMargins(5, 0, 5, 0);
- //设置applicationButton
- PRINT_COST("setCentralWidget & setWindowTitle");
- ribbon->applicationButton()->setText(("File"));
- ribbon->applicationButton()->hide();
- //添加主标签页 - 通过addCategoryPage工厂函数添加
- SARibbonCategory* categoryFile = ribbon->addCategoryPage(tr("文件(F)"));
- categoryFile->setObjectName(("categoryFile"));
- createCategoryFile(categoryFile);
- PRINT_COST("new main page");
- //添加显示标签页 - 直接new SARibbonCategory添加
- SARibbonCategory* categoryDisplay = new SARibbonCategory();
- categoryDisplay->setCategoryName(tr("显示(S)"));
- categoryDisplay->setObjectName(("categoryDisplay"));
- createCategoryDisplay(categoryDisplay);
- ribbon->addCategoryPage(categoryDisplay);
- PRINT_COST("add categoryDisplay page");
- //添加数据标签页
- SARibbonCategory* categoryData = new SARibbonCategory();
- categoryData->setCategoryName(("数据(D)"));
- categoryData->setObjectName(("categoryDelete"));
- ribbon->addCategoryPage(categoryData);
- createCategoryData(categoryData);
- PRINT_COST("add category categoryData page");
- //添加导入标签页
- SARibbonCategory* categoryGrid = new SARibbonCategory();
- categoryGrid->setCategoryName(("网格(G)"));
- categoryGrid->setObjectName(("categoryGrid"));
- ribbon->addCategoryPage(categoryGrid);
- createCategoryGrid(categoryGrid);
- PRINT_COST("add category categoryGrid page");
- //添加帮助标签页
- SARibbonCategory* categoryHelp = new SARibbonCategory();
- categoryHelp->setCategoryName(("帮助(H)"));
- categoryHelp->setObjectName(("categoryHelp"));
- ribbon->addCategoryPage(categoryHelp);
- createCategoryHelp(categoryHelp);
- PRINT_COST("add category help page");
- SARibbonQuickAccessBar* quickAccessBar = ribbon->quickAccessBar();
- createQuickAccessBar(quickAccessBar);
- PRINT_COST("add quick access bar");
- SARibbonButtonGroupWidget* rightBar = ribbon->rightButtonGroup();
- createRightButtonGroup(rightBar);
- PRINT_COST("add right bar");
- setMinimumWidth(1000);
- showMaximized();
- ribbonBar()->setRibbonStyle(SARibbonBar::WpsLiteStyleTwoRow);
- }
- void MainWindow::addTreeList(QDockWidget* widget)
- {
- QTreeWidget *tree = new QTreeWidget();
- tree->setHeaderHidden(true);
- QTreeWidgetItem* modelItem = new QTreeWidgetItem(tree);
- modelItem->setText(0,"模型");
- tree->addTopLevelItem(modelItem);
- QTreeWidgetItem* gridItem = new QTreeWidgetItem(tree);
- gridItem->setText(0,"网格");
- tree->addTopLevelItem(gridItem);
- QTreeWidgetItem* CfdItem = new QTreeWidgetItem(tree);
- CfdItem->setText(0,"CFD计算");
- tree->addTopLevelItem(CfdItem);
- QTreeWidgetItem* CfdSetItem = new QTreeWidgetItem(CfdItem);
- CfdSetItem->setText(0,"设置");
- QTreeWidgetItem* CfdCalcItem = new QTreeWidgetItem(CfdItem);
- CfdCalcItem->setText(0,"计算");
- QTreeWidgetItem* CfdResultItem = new QTreeWidgetItem(CfdItem);
- CfdResultItem->setText(0,"结果");
- QTreeWidgetItem* IrItem = new QTreeWidgetItem(tree);
- IrItem->setText(0,"IR计算");
- tree->addTopLevelItem(IrItem);
- QTreeWidgetItem* IrSetItem = new QTreeWidgetItem(IrItem);
- IrSetItem->setText(0,"设置");
- QTreeWidgetItem* IrCalcItem = new QTreeWidgetItem(IrItem);
- IrCalcItem->setText(0,"计算");
- QTreeWidgetItem* IrResultItem = new QTreeWidgetItem(IrItem);
- IrResultItem->setText(0,"结果");
- QTreeWidgetItem* ResultItem = new QTreeWidgetItem(tree);
- ResultItem->setText(0,"结果展示");
- tree->addTopLevelItem(ResultItem);
- widget->setWidget(tree);
- }
- void MainWindow::createCategoryFile(SARibbonCategory* page)
- {
- }
- void MainWindow::createCategoryDisplay(SARibbonCategory* page)
- {
- }
- void MainWindow::createCategoryData(SARibbonCategory* page)
- {
- }
- void MainWindow::createCategoryGrid(SARibbonCategory* page)
- {
- }
- void MainWindow::createCategoryHelp(SARibbonCategory* page)
- {
- }
- void MainWindow::createQuickAccessBar(SARibbonQuickAccessBar* quickAccessBar)
- {
- }
- void MainWindow::createRightButtonGroup(SARibbonButtonGroupWidget* rightBar)
- {
- }
|