forked from czyt1988/SARibbon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainwindow.cpp
1566 lines (1384 loc) · 68.2 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "mainwindow.h"
#if !SARIBBON_USE_3RDPARTY_FRAMELESSHELPER
#include "SAFramelessHelper.h"
#endif
#include "SARibbonApplicationButton.h"
#include "SARibbonBar.h"
#include "SARibbonButtonGroupWidget.h"
#include "SARibbonCategory.h"
#include "SARibbonCheckBox.h"
#include "SARibbonColorToolButton.h"
#include "SARibbonComboBox.h"
#include "SARibbonCustomizeDialog.h"
#include "SARibbonCustomizeWidget.h"
#include "SARibbonGallery.h"
#include "SARibbonLineEdit.h"
#include "SARibbonMenu.h"
#include "SARibbonPannel.h"
#include "SARibbonQuickAccessBar.h"
#include "SARibbonToolButton.h"
#include "colorWidgets/SAColorGridWidget.h"
#include "colorWidgets/SAColorPaletteGridWidget.h"
#include "SARibbonSystemButtonBar.h"
#include <QAbstractButton>
#include <QAction>
#include <QApplication>
#include <QButtonGroup>
#include <QCalendarWidget>
#include <QDebug>
#include <QElapsedTimer>
#include <QFile>
#include <QFileDialog>
#include <QFontComboBox>
#include <QLabel>
#include <QLineEdit>
#include <QMenu>
#include <QMessageBox>
#include <QPushButton>
#include <QRadioButton>
#include <QSpinBox>
#include <QStatusBar>
#include <QTextEdit>
#include <QTextStream>
#include <QXmlStreamWriter>
#include <QMessageBox>
#include <QShortcut>
#include <QLineEdit>
#include <QDialogButtonBox>
#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 << ")"; \
mTextedit->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), mWidgetForCustomize(nullptr), mMenuApplicationBtn(nullptr)
{
PRINT_COST_START();
setWindowTitle(("ribbon mainwindow test"));
mTextedit = new QTextEdit(this);
setCentralWidget(mTextedit);
setStatusBar(new QStatusBar());
SARibbonBar* ribbon = ribbonBar();
//! 通过setContentsMargins设置ribbon四周的间距
ribbon->setContentsMargins(5, 0, 5, 0);
connect(ribbon, &SARibbonBar::actionTriggered, this, [ this ](QAction* action) {
mTextedit->append(QString("action object name=%1 triggered").arg(action->objectName()));
});
//! cn:
//! 这里示例的是如何设置和修改applicationButton,默认情况下SARibbonBar会创建一个SARibbonApplicationButton,
//! SARibbonApplicationButton的父类是QToolButton,用户也可以创建自己的applicationButton,
//! 通过SARibbonBar::setApplicationButton函数设置自己定义的按钮,如果传入一个空指针,将取消掉applicationButton
//! en:
//! Here is an example of how to set and modify the applicationButton. By default,
//! SARibbonBar will create a SARibbonApplicationButton. The parent class of SARibbonApplicationButton is QToolButton.
//! Users can also create their own applicationButton, and set their own buttons through the SARibbonBar::setApplicationButton function.
//! If a null pointer is passed in, the applicationButton will be canceled
createRibbonApplicationButton();
//! cn:
//! 添加主标签页,这里演示通过SARibbonBar::addCategoryPage函数添加一个标签页
//! en:
//! Add the main tab. Here we show how to add a tab through the SARibbonBar::addCategoryPage function
SARibbonCategory* categoryMain = ribbon->addCategoryPage(tr("&Main"));
//! cn: SARibbonBar的Category和Pannel,以及对应的Action都应该设置ObjectName,因为如果要自定义action,这些ObjectName是必不可少的
//! en: The category , pannel and actions of SARibbonBar, should be set with Object Names, as these Object Names are essential for customizing actions
categoryMain->setObjectName(("categoryMain"));
createCategoryMain(categoryMain);
PRINT_COST("new main page");
//! cn:这里演示了另外一种添加标签页的方式,先创建SARibbonCategory指针,并通过SARibbonBar::addCategoryPage函数把SARibbonCategory指针传递给SARibbonBar
//! en:Here is another way to add a tab: first create a SARibbonCategory pointer and pass it to SARibbonBar through the SARibbonBar::addCategoryPage function
SARibbonCategory* categoryOther = new SARibbonCategory();
categoryOther->setCategoryName(tr("Other"));
categoryOther->setObjectName(("categoryOther"));
createCategoryOther(categoryOther);
ribbon->addCategoryPage(categoryOther);
PRINT_COST("add other page");
// 添加删除标签页
SARibbonCategory* categoryDelete = new SARibbonCategory();
categoryDelete->setCategoryName(("Delete"));
categoryDelete->setObjectName(("categoryDelete"));
ribbon->addCategoryPage(categoryDelete);
createCategoryDelete(categoryDelete);
PRINT_COST("add category delete page");
// 添加尺寸标签页
SARibbonCategory* categorySize = new SARibbonCategory();
categorySize->setCategoryName(("Size(example long category)"));
categorySize->setObjectName(("categorySize"));
ribbon->addCategoryPage(categorySize);
createCategorySize(categorySize);
PRINT_COST("add category size page");
// 添加颜色标签页
SARibbonCategory* categoryColor = new SARibbonCategory();
categoryColor->setCategoryName(("Color"));
categoryColor->setObjectName(("categoryColor"));
ribbon->addCategoryPage(categoryColor);
createCategoryColor(categoryColor);
PRINT_COST("add category color page");
createContextCategory1();
PRINT_COST("add context1 category page");
createContextCategory2();
PRINT_COST("add context2 category page");
createQuickAccessBar();
PRINT_COST("add quick access bar");
//! cn:
//! 创建RightButtonGroup,RightButtonGroup类似一个在右上角的工具栏,给用户放置一些快捷图标,例如关于、帮助等图标,
//! RightButtonGroup在SARibbonBar创建时就会构建一个默认的SARibbonButtonGroupWidget,可以通过SARibbonBar::rightButtonGroup函数获取
//! en:
//! Create a RightButtonGroup, which is similar to a toolbar in the upper right corner,
//! providing users with shortcut icons such as About, Help, etc. RightButtonGroup will build a default SARibbonButtonGroupWidget when creating SARibbonBar,
//! which can be obtained through the SARibbonBar::rightButtonGroup function
createRightButtonGroup();
PRINT_COST("add right bar");
//! cn:
//! 这里演示了如何在系统窗口最小化最大化关闭按钮旁边添加其他按钮
createWindowButtonGroupBar();
//! cn:
//! actionManager可以管理所有的action,并给SARibbon的自定义窗口使用,
//! actionManager必须在ribbon的action都创建完成后创建,如果在之前就创建好,后加入ribbon的action需要手动管理到actionManager里,
//! actionManager也可以管理不在ribbonBar里的action
//! en:
//! The ActionManager can manage all actions and be used for SARibbon's custom window.
//! The ActionManager must be created after all the actions in the ribbon are created.
//! If the actions are created before, the actions added to the ribbon need to be manually managed in the ActionManager.
//! The ActionManager can also manage actions not in the ribbon bar
createActionsManager();
setMinimumWidth(500);
showMaximized();
setWindowIcon(QIcon(":/icon/icon/SA.svg"));
#if SA_DEBUG_PRINT_SARIBBONBAR
qDebug() << *ribbon;
#endif
connect(ribbon, &SARibbonBar::currentRibbonTabChanged, this, [ this ](int v) {
mTextedit->append(QString("SARibbonBar::currentRibbonTabChanged(%1)").arg(v));
});
}
void MainWindow::createRibbonApplicationButton()
{
SARibbonBar* ribbon = ribbonBar();
if (!ribbon) {
return;
}
QAbstractButton* btn = ribbon->applicationButton();
if (!btn) {
// cn: SARibbonBar默认就会创建一个SARibbonApplicationButton,因此,在正常情况下,这个位置不会进入
// en: SARibbonBar creates a SARibbonApplicationButton by default. Therefore, under normal circumstances, this location will not enter
btn = new SARibbonApplicationButton(this);
ribbon->setApplicationButton(btn);
}
ribbon->applicationButton()->setText((" &File ")); // 文字两边留有间距,好看一点
// cn: SARibbonMenu和QMenu的操作是一样的
// en: The operations of SARibbonMenu and QMenu are the same
if (!mMenuApplicationBtn) {
mMenuApplicationBtn = new SARibbonMenu(this);
mMenuApplicationBtn->addAction(createAction("test1", ":/icon/icon/action.svg"));
mMenuApplicationBtn->addAction(createAction("test2", ":/icon/icon/action2.svg"));
mMenuApplicationBtn->addAction(createAction("test3", ":/icon/icon/action3.svg"));
mMenuApplicationBtn->addAction(createAction("test4", ":/icon/icon/action4.svg"));
}
SARibbonApplicationButton* appBtn = qobject_cast< SARibbonApplicationButton* >(btn);
if (!appBtn) {
return;
}
appBtn->setMenu(mMenuApplicationBtn);
}
void MainWindow::onShowContextCategory(bool on)
{
if (mContextCategory == nullptr) {
createContextCategory1();
}
if (on) {
this->ribbonBar()->showContextCategory(mContextCategory);
} else {
this->ribbonBar()->hideContextCategory(mContextCategory);
}
}
void MainWindow::onStyleClicked(int id)
{
SARibbonBar::RibbonStyles ribbonStyle = static_cast< SARibbonBar::RibbonStyles >(id);
ribbonBar()->setRibbonStyle(ribbonStyle);
mActionWordWrap->setChecked(SARibbonToolButton::isEnableWordWrap());
switch (ribbonStyle) {
case SARibbonBar::RibbonStyleLooseThreeRow:
// cn:"LooseThreeRow"样式的文字显示是换行的,同时也会显示标题栏,你也可以通过SARibbonBar::setEnableWordWrap来控制按钮是否换行显示,
// 可以通过SARibbonBar::setEnableShowPannelTitle控制标题栏是否显示
mTextedit->append(
tr("\nThe text display of the \"LooseThreeRow\" style is word wrap and also displays the title bar. "
"You can also control whether the button is line breaking through SARibbonBar::setEnableWordWrap,"
"and whether the title bar is displayed through SARibbonBar::setEnableShowPannelTitle"));
mTextedit->append(tr("ribbonBar()->setRibbonStyle(SARibbonBar::RibbonStyleLooseThreeRow);"));
break;
case SARibbonBar::RibbonStyleLooseTwoRow:
// cn:"LooseThreeRow"样式的文字显示是不换行的,同时也会显示标题栏,你也可以通过SARibbonBar::setEnableWordWrap来控制按钮是否换行显示,
// 可以通过SARibbonBar::setEnableShowPannelTitle控制标题栏是否显示
mTextedit->append(
tr("\nThe text display of the \"LooseTwoRow\" style is not word wrap and also displays the title bar. "
"You can also control whether the button is line breaking through SARibbonBar::setEnableWordWrap,"
"and whether the title bar is displayed through SARibbonBar::setEnableShowPannelTitle"));
mTextedit->append(tr("ribbonBar()->setRibbonStyle(SARibbonBar::RibbonStyleLooseTwoRow);"));
break;
case SARibbonBar::RibbonStyleCompactThreeRow:
// cn:"CompactThreeRow"样式的文字显示是换行的,不会显示标题栏,你也可以通过SARibbonBar::setEnableWordWrap来控制按钮是否换行显示,
// 可以通过SARibbonBar::setEnableShowPannelTitle控制标题栏是否显示
mTextedit->append(
tr("\nThe text display of the \"LooseThreeRow\" style is word wrap and not displays the title bar. "
"You can also control whether the button is line breaking through SARibbonBar::setEnableWordWrap,"
"and whether the title bar is displayed through SARibbonBar::setEnableShowPannelTitle"));
mTextedit->append(tr("ribbonBar()->setRibbonStyle(SARibbonBar::RibbonStyleCompactThreeRow);"));
break;
case SARibbonBar::RibbonStyleCompactTwoRow:
// cn:"CompactTwoRow"样式的文字显示是不换行的,不会显示标题栏,你也可以通过SARibbonBar::setEnableWordWrap来控制按钮是否换行显示,
// 可以通过SARibbonBar::setEnableShowPannelTitle控制标题栏是否显示
mTextedit->append(
tr("\nThe text display of the \"CompactTwoRow\" style is not word wrap and not displays the title bar. "
"You can also control whether the button is line breaking through SARibbonBar::setEnableWordWrap,"
"and whether the title bar is displayed through SARibbonBar::setEnableShowPannelTitle"));
mTextedit->append(tr("ribbonBar()->setRibbonStyle(SARibbonBar::RibbonStyleCompactTwoRow);"));
break;
default:
break;
}
}
void MainWindow::onActionCustomizeTriggered(bool b)
{
Q_UNUSED(b);
if (nullptr == mWidgetForCustomize) {
mWidgetForCustomize = new SARibbonCustomizeWidget(this, this, Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::Dialog);
mWidgetForCustomize->setWindowModality(Qt::ApplicationModal); // 设置阻塞类型
mWidgetForCustomize->setAttribute(Qt::WA_ShowModal, true); // 属性设置 true:模态 false:非模态
mWidgetForCustomize->setupActionsManager(mActionsManager);
}
mWidgetForCustomize->show();
mWidgetForCustomize->applys();
}
void MainWindow::onActionCustomizeAndSaveTriggered(bool b)
{
Q_UNUSED(b);
SARibbonCustomizeDialog dlg(this);
dlg.setupActionsManager(mActionsManager);
// 如果启动时未应用上次修改,先应用再读取,保持本地数据和ui一致
if (!mHasApplyCustomizeXmlFile) {
auto res = QMessageBox::question(this, tr("question"), tr("Apply the last modification?\nIf not, local data will be reset"));
if (res == QMessageBox::Yes) {
onActionLoadCustomizeXmlFileTriggered();
return;
} else {
QFile::remove("customize.xml");
dlg.clear();
mHasApplyCustomizeXmlFile = true;
}
}
dlg.fromXml("customize.xml");
if (SARibbonCustomizeDialog::Accepted == dlg.exec()) {
// 先apply
if (dlg.isCached())
dlg.applys();
// 无更改直接退出
if (!dlg.isApplied()) {
mTextedit->append("no change to save");
return;
}
QByteArray str;
QXmlStreamWriter xml(&str);
xml.setAutoFormatting(true);
xml.setAutoFormattingIndent(2);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // QXmlStreamWriter always encodes XML in UTF-8.
xml.setCodec("utf-8");
#endif
xml.writeStartDocument();
bool isok = dlg.toXml(&xml);
xml.writeEndDocument();
if (isok) {
QFile f("customize.xml");
if (f.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) {
QTextStream s(&f);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // QTextStream always encodes XML in UTF-8.
s.setCodec("utf-8");
#endif
s << str;
s.flush();
}
mTextedit->append("write xml:");
mTextedit->append(str);
}
}
}
void MainWindow::onActionCustomizeAndSaveWithApplyTriggered(bool b)
{
// 如果启动时未应用上次修改,先应用再读取,保持本地数据和ui一致
if (!mHasApplyCustomizeXmlFile) {
auto res = QMessageBox::question(this, tr("question"), tr("Apply the last modification?\nIf not, local data will be reset"));
if (res == QMessageBox::Yes) {
onActionLoadCustomizeXmlFileTriggered();
return;
} else {
QFile::remove("customize.xml");
mHasApplyCustomizeXmlFile = true;
}
}
QDialog dlg;
QVBoxLayout* main = new QVBoxLayout;
dlg.setLayout(main);
SARibbonCustomizeWidget* widgetForCustomize = new SARibbonCustomizeWidget(this, &dlg);
widgetForCustomize->setupActionsManager(mActionsManager);
main->addWidget(widgetForCustomize, 1);
QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel | QDialogButtonBox::Apply);
main->addWidget(buttonBox);
connect(buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject);
connect(buttonBox, &QDialogButtonBox::clicked, &dlg, [ = ](QAbstractButton* button) {
auto role = buttonBox->buttonRole(button);
if (role == QDialogButtonBox::ApplyRole) // apply
{
if (widgetForCustomize->isCached()) {
widgetForCustomize->applys();
mTextedit->append("change applied");
} else {
mTextedit->append("no change to apply");
}
}
});
widgetForCustomize->fromXml("customize.xml");
if (QDialog::Accepted == dlg.exec()) {
// 先apply
if (widgetForCustomize->isCached())
widgetForCustomize->applys();
// 无更改直接退出
if (!widgetForCustomize->isApplied()) {
mTextedit->append("no change to save");
return;
}
QByteArray str;
QXmlStreamWriter xml(&str);
xml.setAutoFormatting(true);
xml.setAutoFormattingIndent(2);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // QXmlStreamWriter always encodes XML in UTF-8.
xml.setCodec("utf-8");
#endif
xml.writeStartDocument();
bool isok = widgetForCustomize->toXml(&xml);
xml.writeEndDocument();
if (isok) {
QFile f("customize.xml");
if (f.open(QIODevice::ReadWrite | QIODevice::Text | QIODevice::Truncate)) {
QTextStream s(&f);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) // QTextStream always encodes XML in UTF-8.
s.setCodec("utf-8");
#endif
s << str;
s.flush();
}
mTextedit->append("write xml:");
mTextedit->append(str);
}
} else {
// 清除所有动作
widgetForCustomize->clear();
mTextedit->append("all changes clear, the applied changes will take no effect afer restart");
}
}
void MainWindow::onActionHelpTriggered()
{
QMessageBox::information(this,
tr("infomation"),
tr("\n ==============="
"\n SARibbonBar version:%1"
"\n Author:czy"
"\n Email:[email protected]"
"\n ===============")
.arg(SARibbonBar::versionString()));
}
void MainWindow::onActionRemoveAppBtnTriggered(bool b)
{
if (b) {
ribbonBar()->setApplicationButton(nullptr);
} else {
SARibbonApplicationButton* actionRemoveAppBtn = new SARibbonApplicationButton();
actionRemoveAppBtn->setText(tr(" &File "));
this->ribbonBar()->setApplicationButton(actionRemoveAppBtn);
createRibbonApplicationButton();
}
}
void MainWindow::onActionUseQssTriggered()
{
QFile f("ribbon.qss");
if (!f.exists()) {
QString fdir = QFileDialog::getOpenFileName(this, tr("select qss file"));
if (fdir.isEmpty()) {
return;
}
f.setFileName(fdir);
}
if (!f.open(QIODevice::ReadWrite)) {
return;
}
QString qss(f.readAll());
mTextedit->setText(qss);
this->ribbonBar()->setStyleSheet(qss);
}
void MainWindow::onActionLoadCustomizeXmlFileTriggered()
{
// 只能调用一次
if (!mHasApplyCustomizeXmlFile) {
if (!QFile::exists("customize.xml")) {
mHasApplyCustomizeXmlFile = true;
return;
}
QFile f("customize.xml");
qDebug() << "size of customize.xml : " << f.size();
if (f.size() <= 0) {
mHasApplyCustomizeXmlFile = true;
return;
}
mHasApplyCustomizeXmlFile = sa_apply_customize_from_xml_file("customize.xml", ribbonBar(), mActionsManager);
}
}
void MainWindow::onActionWindowFlagNormalButtonTriggered(bool b)
{
Qt::WindowFlags f = windowFlags();
f.setFlag(Qt::WindowCloseButtonHint, b);
f.setFlag(Qt::WindowMinMaxButtonsHint, b);
setWindowFlags(f);
}
void MainWindow::onFontComWidgetCurrentFontChanged(const QFont& f)
{
qDebug() << "set font:" << f;
ribbonBar()->setFont(f);
update();
}
void MainWindow::onActionFontLargerTriggered()
{
QFont f = font();
f.setPointSize(f.pointSize() + 1);
qDebug() << "before set ribbonBar font:" << ribbonBar()->font();
ribbonBar()->setFont(f);
update();
qDebug() << "set font:" << f;
}
void MainWindow::onActionFontSmallerTriggered()
{
QFont f = font();
f.setPointSize(f.pointSize() - 1);
qDebug() << "before set ribbonBar font:" << ribbonBar()->font();
ribbonBar()->setFont(f);
update();
qDebug() << "set font:" << f;
}
void MainWindow::onActionWordWrapTriggered(bool b)
{
ribbonBar()->setEnableWordWrap(b);
mTextedit->append(tr("By using the SARibbonBar::setEnableWordWrap function, "
"you can set whether text breaks or not.\n"
"By default, the two line mode will not wrap, the three line mode will wrap.\n"
"You can force the two line mode to wrap, or the three line mode to not wrap"));
// cn:通过SARibbonBar::setEnableWordWrap函数可以设置文字是否换行。\n
// 默认情况下,两行模式都不会换行,三行模式下都会换行。\n
// 可以强制设置两行模式也换行,或者三行模式不换行
}
/**
* @brief 测试SARibbonButtonGroupWidget和标题对齐
* @param act
*/
void MainWindow::onButtonGroupActionTriggered(QAction* act)
{
QVariant v = act->property("align");
if (v.isValid()) {
Qt::Alignment al = static_cast< Qt::Alignment >(v.toInt());
if (!ribbonBar()) {
return;
}
ribbonBar()->setWindowTitleAligment(al);
ribbonBar()->repaint();
}
}
/**
* @brief 颜色按钮点击
* @param c
* @param on
*/
void MainWindow::onColorButtonColorClicked(const QColor& c, bool on)
{
Q_UNUSED(on);
mTextedit->append(QString("color click %1").arg(c.name()));
}
/**
* @brief 样式改变
* @param index
*/
void MainWindow::onRibbonThemeComboBoxCurrentIndexChanged(int index)
{
SARibbonTheme t = static_cast< SARibbonTheme >(
mComboboxRibbonTheme->itemData(index).toInt());
setRibbonTheme(t);
}
/**
* @brief 隐藏action
* @param on
*/
void MainWindow::onActionHideActionTriggered(bool on)
{
mActionWordWrap->setVisible(on);
mActionDisable->setVisible(on);
mActionUnlock->setVisible(on);
mActionSetTextTest->setVisible(on);
mActionShowTest->setVisible(on);
mActionHideAction2->setVisible(on);
mActionHideAction4->setVisible(on);
mActionHideShowTextAct2->setVisible(on);
mActionHideShowTextAct3->setVisible(on);
mActionHideShowTextAct4->setVisible(on);
ribbonBar()->updateRibbonGeometry();
}
/**
* @brief 切换所有action是否可见
* @param on
*/
void MainWindow::onActionVisibleAllTriggered(bool on)
{
QList< QAction* > acts = mActionsManager->allActions();
for (QAction* a : acts) {
if (a != mActionVisibleAll) {
a->setVisible(on);
}
}
ribbonBar()->updateRibbonGeometry();
}
/**
@brief 居中对齐checkbox的槽
@param checked
*/
void MainWindow::onCheckBoxAlignmentCenterClicked(bool checked)
{
if (checked) {
ribbonBar()->setRibbonAlignment(SARibbonAlignment::AlignCenter);
} else {
ribbonBar()->setRibbonAlignment(SARibbonAlignment::AlignLeft);
}
}
/**
* @brief 创建其它actions,这些actions并不在SARibbonBar管理
*/
void MainWindow::createOtherActions()
{
mOtherAction1 = new QAction(("text action1"), this);
mOtherAction2 = new QAction(("text action2"), this);
mOtherAction3 = new QAction(("text action3"), this);
mOtherAction4 = new QAction(("text action4"), this);
mOtherAction5 = new QAction(("text action5"), this);
mOtherActionIcon1 = new QAction(QIcon(":/icon/icon/layout.svg"), ("action with icon"), this);
}
void MainWindow::closeEvent(QCloseEvent* e)
{
auto res = QMessageBox::question(this, tr("question"), tr("Confirm whether to exit"));
if (res == QMessageBox::Yes) {
e->accept();
} else {
e->ignore();
}
}
void MainWindow::createCategoryMain(SARibbonCategory* page)
{
//! 1
//! pannel 1 start
//!
// 使用addPannel函数来创建SARibbonPannel,效果和new SARibbonPannel再addPannel一样
SARibbonPannel* pannelStyle = page->addPannel(("ribbon style"));
QAction* actSave = createAction(tr("Save"), ":/icon/icon/save.svg");
// 这样设置快捷键
QShortcut* shortCut = new QShortcut(QKeySequence(QLatin1String("Ctrl+S")), this);
connect(shortCut, &QShortcut::activated, this, [ actSave ]() { actSave->trigger(); });
// 这样设置是无效的
// actSave->setShortcut(QKeySequence(QLatin1String("Ctrl+S")));
connect(actSave, &QAction::triggered, this, [ this ](bool b) {
Q_UNUSED(b);
this->mTextedit->append("actSaveion clicked");
});
pannelStyle->addLargeAction(actSave);
QAction* actHideRibbon = createAction(tr("hide ribbon"), ":/icon/icon/hideRibbon.svg", "actHideRibbon");
actHideRibbon->setCheckable(true);
pannelStyle->addSmallAction(actHideRibbon);
connect(actHideRibbon, &QAction::triggered, this, [ this ](bool b) { this->ribbonBar()->setMinimumMode(b); });
connect(ribbonBar(), &SARibbonBar::ribbonModeChanged, this, [ actHideRibbon ](SARibbonBar::RibbonMode nowNode) {
actHideRibbon->setChecked(nowNode == SARibbonBar::MinimumRibbonMode);
});
QAction* actShowHideButton = createAction(tr("show \nhide button"), ":/icon/icon/showHideButton.svg", "show hide button");
actShowHideButton->setCheckable(true);
pannelStyle->addSmallAction(actShowHideButton); // wrod wrap was not effect in small button
connect(actShowHideButton, &QAction::triggered, this, [ this ](bool b) {
this->ribbonBar()->showMinimumModeButton(b); // 显示ribbon最小化按钮
});
actShowHideButton->trigger();
mActionWordWrap = createAction(tr("word wrap"), ":/icon/icon/wordwrap.svg");
mActionWordWrap->setCheckable(ribbonBar()->isEnableWordWrap());
pannelStyle->addSmallAction(mActionWordWrap);
connect(mActionWordWrap, &QAction::triggered, this, &MainWindow::onActionWordWrapTriggered);
QButtonGroup* g = new QButtonGroup(page);
QRadioButton* r = new QRadioButton();
r->setText(tr("use office style"));
r->setObjectName(("use office style"));
r->setWindowTitle(r->text());
r->setChecked(true);
pannelStyle->addSmallWidget(r);
g->addButton(r, SARibbonBar::RibbonStyleLooseThreeRow);
r = new QRadioButton();
r->setObjectName(("use wps style"));
r->setText(tr("use wps style"));
r->setWindowTitle(r->text());
r->setChecked(false);
pannelStyle->addSmallWidget(r);
g->addButton(r, SARibbonBar::RibbonStyleCompactThreeRow);
r = new QRadioButton();
r->setObjectName(("use office 2row style"));
r->setText(tr("use office 2 row style"));
r->setWindowTitle(r->text());
r->setChecked(false);
pannelStyle->addSmallWidget(r);
g->addButton(r, SARibbonBar::RibbonStyleLooseTwoRow);
r = new QRadioButton();
r->setObjectName(("use wps 2row style"));
r->setText(tr("use wps 2row style"));
r->setWindowTitle(r->text());
r->setChecked(false);
pannelStyle->addSmallWidget(r);
g->addButton(r, SARibbonBar::RibbonStyleCompactTwoRow);
// connect(g, QOverload<int>::of(&QButtonGroup::buttonClicked), this, &MainWindow::onStyleClicked);
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
connect(g, static_cast< void (QButtonGroup::*)(int) >(&QButtonGroup::idClicked), this, &MainWindow::onStyleClicked);
#else
connect(g, static_cast< void (QButtonGroup::*)(int) >(&QButtonGroup::buttonClicked), this, &MainWindow::onStyleClicked);
#endif
mComboboxRibbonTheme = new SARibbonComboBox();
mComboboxRibbonTheme->setWindowTitle(tr("RibbonTheme"));
mComboboxRibbonTheme->setObjectName("RibbonTheme");
mComboboxRibbonTheme->addItem("Theme Win7", static_cast<int>(SARibbonTheme::RibbonThemeWindows7));
mComboboxRibbonTheme->addItem("Theme Office2013", static_cast<int>(SARibbonTheme::RibbonThemeOffice2013));
mComboboxRibbonTheme->addItem("Theme Office2016 Blue", static_cast<int>(SARibbonTheme::RibbonThemeOffice2016Blue));
mComboboxRibbonTheme->addItem("Theme Office2021 Blue", static_cast<int>(SARibbonTheme::RibbonThemeOffice2021Blue));
mComboboxRibbonTheme->addItem("Theme Dark", static_cast<int>(SARibbonTheme::RibbonThemeDark));
mComboboxRibbonTheme->addItem("Theme Dark2", static_cast<int>(SARibbonTheme::RibbonThemeDark2));
mComboboxRibbonTheme->setCurrentIndex(mComboboxRibbonTheme->findData(static_cast< int >(ribbonTheme())));
connect(mComboboxRibbonTheme, QOverload< int >::of(&SARibbonComboBox::currentIndexChanged), this, &MainWindow::onRibbonThemeComboBoxCurrentIndexChanged);
pannelStyle->addSmallWidget(mComboboxRibbonTheme);
SARibbonCheckBox* checkBox = new SARibbonCheckBox(this);
checkBox->setText(tr("Alignment Center"));
checkBox->setObjectName("checkBoxAlignmentCenter");
checkBox->setWindowTitle(checkBox->text());
connect(checkBox, &SARibbonCheckBox::clicked, this, &MainWindow::onCheckBoxAlignmentCenterClicked);
pannelStyle->addSmallWidget(checkBox);
SARibbonPannel* pannelToolButtonStyle = page->addPannel(("sa ribbon toolbutton style"));
SARibbonMenu* menu = new SARibbonMenu(this);
QAction* a = nullptr;
{
QIcon itemicon = QIcon(":/icon/icon/item.svg");
for (int i = 0; i < 5; ++i) {
a = menu->addAction(itemicon, tr("item %1").arg(i + 1));
a->setObjectName(QStringLiteral("item %1").arg(i + 1));
}
}
QAction* act = createAction(tr("test 1"), ":/icon/icon/test1.svg");
QVariant temp("Test");
act->setData(temp);
act->setMenu(menu);
act->setToolTip(tr("use QToolButton::MenuButtonPopup mode"));
pannelToolButtonStyle->addSmallAction(act, QToolButton::MenuButtonPopup);
act = createAction(tr("test 2"), ":/icon/icon/test2.svg");
act->setMenu(menu);
act->setToolTip(tr("use QToolButton::InstantPopup mode"));
pannelToolButtonStyle->addSmallAction(act, QToolButton::InstantPopup);
pannelToolButtonStyle->addSeparator();
act = createAction(tr("Delayed\nPopup"), ":/icon/icon/folder-cog.svg");
act->setMenu(menu);
pannelToolButtonStyle->addLargeAction(act, QToolButton::DelayedPopup);
connect(act, &QAction::triggered, this, &MainWindow::onDelayedPopupCheckabletriggered);
act = createAction(tr("Menu Button Popup"), ":/icon/icon/folder-star.svg");
act->setMenu(menu);
pannelToolButtonStyle->addLargeAction(act, QToolButton::MenuButtonPopup);
connect(act, &QAction::triggered, this, &MainWindow::onMenuButtonPopupCheckabletriggered);
act = createAction(tr("Instant Popup"), ":/icon/icon/folder-stats.svg");
act->setMenu(menu);
pannelToolButtonStyle->addLargeAction(act, QToolButton::InstantPopup);
connect(act, &QAction::triggered, this, &MainWindow::onInstantPopupCheckabletriggered);
act = createAction(tr("Delayed Popup checkable"), ":/icon/icon/folder-table.svg");
act->setCheckable(true);
act->setMenu(menu);
pannelToolButtonStyle->addLargeAction(act, QToolButton::DelayedPopup);
connect(act, &QAction::triggered, this, &MainWindow::onDelayedPopupCheckableTest);
act = createAction(tr("Menu Button Popup checkable"), ":/icon/icon/folder-checkmark.svg");
act->setCheckable(true);
act->setMenu(menu);
pannelToolButtonStyle->addLargeAction(act, QToolButton::MenuButtonPopup);
connect(act, &QAction::triggered, this, &MainWindow::onMenuButtonPopupCheckableTest);
act = createAction(tr("disable action"), ":/icon/icon/disable.svg");
act->setCheckable(true);
act->setMenu(menu);
act->setEnabled(false);
pannelToolButtonStyle->addLargeAction(act);
QAction* optAct = new QAction(this);
connect(optAct, &QAction::triggered, this, [ this ](bool on) {
Q_UNUSED(on);
QMessageBox::information(this, tr("Option Action Triggered"), tr("Option Action Triggered"));
});
pannelToolButtonStyle->setOptionAction(optAct);
//! 2
//! pannel 2 start
//!
SARibbonPannel* pannel2 = page->addPannel(("pannel 2"));
QAction* actShowContext = createAction(tr("show Context"), ":/icon/icon/showContext.svg");
actShowContext->setCheckable(true);
pannel2->addLargeAction(actShowContext);
connect(actShowContext, &QAction::triggered, this, &MainWindow::onShowContextCategory);
QAction* actDeleteContext = createAction(tr("delete Context"), ":/icon/icon/deleteContext.svg");
pannel2->addLargeAction(actDeleteContext);
connect(actDeleteContext, &QAction::triggered, this, [ this, act ](bool on) {
Q_UNUSED(on);
if (this->mContextCategory) {
this->ribbonBar()->destroyContextCategory(this->mContextCategory);
this->mContextCategory = nullptr;
act->setDisabled(true);
}
});
act = createAction(tr("Word\nWrap"), ":/icon/icon/setText.svg");
pannel2->addLargeAction(act);
connect(act, &QAction::triggered, this, [ this ](bool on) {
Q_UNUSED(on);
this->mTextedit->append(tr("Text can be manually wrapped(use \\n), and will appear as 1 line in the case of "
"SARibbonBar::setEnableWordWrap (false)")); // cn:文本中手动换行
});
act = createAction(tr("Word \nWrap"), ":/icon/icon/setText.svg");
act->setMenu(menu);
pannel2->addLargeAction(act);
connect(act, &QAction::triggered, this, [ this ](bool on) {
Q_UNUSED(on);
this->mTextedit->append(tr("Text can be manually wrapped(use \\n), and will appear as 1 line in the case of "
"SARibbonBar::setEnableWordWrap (false)")); // cn:文本中手动换行
});
//! 3
//! pannel 3 start -> widget test
//!
SARibbonPannel* pannelWidgetTest = page->addPannel(tr("widget test"));
pannelWidgetTest->setObjectName(QStringLiteral(u"pannelWidgetTest"));
SARibbonComboBox* com = new SARibbonComboBox(this);
com->setObjectName("SARibbonComboBox test");
com->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
com->setWindowTitle(tr("SARibbonComboBox test"));
for (int i = 0; i < 40; ++i) {
com->addItem(QString("SARibbonComboBox test%1").arg(i + 1));
}
com->setEditable(true);
pannelWidgetTest->addSmallWidget(com);
com = new SARibbonComboBox(this);
com->setObjectName("ComboBox Editable");
com->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
com->setWindowTitle("ComboBox Editable");
for (int i = 0; i < 40; ++i) {
com->addItem(QString("item %1").arg(i + 1));
}
pannelWidgetTest->addSmallWidget(com);
SARibbonLineEdit* lineEdit = new SARibbonLineEdit(this);
lineEdit->setObjectName("Line Edit");
lineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
lineEdit->setWindowTitle("Line Edit");
lineEdit->setText("SARibbonLineEdit");
pannelWidgetTest->addSmallWidget(lineEdit);
QWidget* w = lineEdit->parentWidget();
while (w) {
qDebug() << w->metaObject()->className();
w = w->parentWidget();
}
pannelWidgetTest->addSeparator();
QCalendarWidget* calendarWidget = new QCalendarWidget(this);
calendarWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
calendarWidget->setObjectName(("calendarWidget"));
calendarWidget->setWindowTitle("calendarWidget");
pannelWidgetTest->addLargeWidget(calendarWidget);
optAct = new QAction(this);
connect(optAct, &QAction::triggered, this, [ this ](bool on) {
Q_UNUSED(on);
QMessageBox::information(this, tr("Option Action Triggered"), tr("Option Action Triggered"));
});
pannelWidgetTest->setOptionAction(optAct);
pannelWidgetTest->setVisible(true);
}
void MainWindow::createCategoryOther(SARibbonCategory* page)
{
SARibbonPannel* pannel1 = new SARibbonPannel(tr("pannel one"));
pannel1->setObjectName("CategoryOther-pannel1");
page->addPannel(pannel1);
// 按钮组
SARibbonButtonGroupWidget* btnGroup1 = new SARibbonButtonGroupWidget(pannel1);
btnGroup1->setObjectName("SARibbonButtonGroupWidget1");
btnGroup1->setWindowTitle("SARibbonButtonGroupWidget1");
btnGroup1->addAction(createAction(tr("Decrease Margin"), ":/icon/icon/Decrease-Margin.svg"));
btnGroup1->addAction(createAction(tr("Decrease Indent"), ":/icon/icon/Decrease-Indent.svg"));
btnGroup1->addAction(createAction(tr("Wrap Image Left"), ":/icon/icon/Wrap-Image Left.svg"));
btnGroup1->addAction(createAction(tr("Wrap Image Right"), ":/icon/icon/Wrap-Image Right.svg"));
pannel1->addWidget(btnGroup1, SARibbonPannelItem::Medium);
SARibbonButtonGroupWidget* btnGroup2 = new SARibbonButtonGroupWidget(pannel1);
btnGroup2->setObjectName("SARibbonButtonGroupWidget2");
btnGroup2->setWindowTitle("SARibbonButtonGroupWidget2");
QAction* titleAlgnment = createAction(tr("Align Right"), ":/icon/icon/Align-Right.svg");
titleAlgnment->setProperty("align", (int)Qt::AlignRight | Qt::AlignVCenter);
btnGroup2->addAction(titleAlgnment);
titleAlgnment = createAction(tr("Align Left"), ":/icon/icon/Align-Left.svg");
titleAlgnment->setProperty("align", (int)Qt::AlignLeft | Qt::AlignVCenter);
btnGroup2->addAction(titleAlgnment);
titleAlgnment = createAction(tr("Align Center"), ":/icon/icon/Align-Center.svg");
titleAlgnment->setProperty("align", (int)Qt::AlignCenter);
btnGroup2->addAction(titleAlgnment);
pannel1->addWidget(btnGroup2, SARibbonPannelItem::Medium);
connect(btnGroup2, &SARibbonButtonGroupWidget::actionTriggered, this, &MainWindow::onButtonGroupActionTriggered);
// Gallery
SARibbonGallery* gallery = pannel1->addGallery();
QList< QAction* > galleryActions;
auto lambdaCreateGalleryAction = [ this ](const QString& text, const QString& iconurl) -> QAction* {
QAction* act = this->createAction(text, iconurl);
this->connect(act, &QAction::triggered, this, [ this, text ]() {
if (this->mTextedit) {
this->mTextedit->append(QString("%1 triggered").arg(text));
}
});
return act;
};
galleryActions.append(lambdaCreateGalleryAction("Document File", ":/gallery-icon/icon/gallery/Document-File.svg"));
galleryActions.append(lambdaCreateGalleryAction("Download File", ":/gallery-icon/icon/gallery/Download-File.svg"));
galleryActions.append(lambdaCreateGalleryAction("Drive File Four Word", ":/gallery-icon/icon/gallery/Drive-File.svg"));
galleryActions.append(lambdaCreateGalleryAction("Dropbox File", ":/gallery-icon/icon/gallery/Dropbox-File.svg"));
galleryActions.append(lambdaCreateGalleryAction("Email File", ":/gallery-icon/icon/gallery/Email-File.svg"));
galleryActions.append(lambdaCreateGalleryAction("Encode File", ":/gallery-icon/icon/gallery/Encode-File.svg"));
galleryActions.append(lambdaCreateGalleryAction("Favorit File", ":/gallery-icon/icon/gallery/Favorit-File.svg"));
galleryActions.append(lambdaCreateGalleryAction("File Error", ":/gallery-icon/icon/gallery/File-Error.svg"));
galleryActions.append(lambdaCreateGalleryAction("File Read Only", ":/gallery-icon/icon/gallery/File-Readonly.svg"));
galleryActions.append(lambdaCreateGalleryAction("File Settings", ":/gallery-icon/icon/gallery/File-Settings.svg"));
galleryActions.append(lambdaCreateGalleryAction("Presentation File", ":/gallery-icon/icon/gallery/Presentation-File.svg"));
SARibbonGalleryGroup* group1 = gallery->addCategoryActions(tr("Files"), galleryActions);
group1->setGalleryGroupStyle(SARibbonGalleryGroup::IconWithWordWrapText);
group1->setGridMinimumWidth(80);
galleryActions.clear();
galleryActions.append(lambdaCreateGalleryAction("Photoshop", ":/gallery-icon/icon/gallery/Photoshop.svg"));
galleryActions.append(lambdaCreateGalleryAction("Internet-Explorer", ":/gallery-icon/icon/gallery/Internet-Explorer.svg"));
galleryActions.append(lambdaCreateGalleryAction("Illustrator", ":/gallery-icon/icon/gallery/Illustrator.svg"));
galleryActions.append(lambdaCreateGalleryAction("Google-Maps", ":/gallery-icon/icon/gallery/Google-Maps.svg"));
galleryActions.append(lambdaCreateGalleryAction("Adobe", ":/gallery-icon/icon/gallery/Adobe.svg"));
galleryActions.append(lambdaCreateGalleryAction("Word", ":/gallery-icon/icon/gallery/Word.svg"));
SARibbonGalleryGroup* group2 = gallery->addCategoryActions(tr("Apps"), galleryActions);
group2->setGridMinimumWidth(80);
gallery->setCurrentViewGroup(group1);
QAction* optAct = new QAction(this);
optAct->setObjectName(("debug"));
pannel1->setOptionAction(optAct);
SARibbonPannel* pannel2 = new SARibbonPannel(tr("pannel two"));
pannel2->setObjectName("CategoryOther-pannel2");
page->addPannel(pannel2);
QAction* actionRemoveAppBtn = createAction(tr("remove application button"), ":/icon/icon/remove-app-btn.svg");
actionRemoveAppBtn->setCheckable(true);
connect(actionRemoveAppBtn, &QAction::toggled, this, &MainWindow::onActionRemoveAppBtnTriggered);
pannel2->addLargeAction(actionRemoveAppBtn);
QAction* actionLongText = createAction(tr("show very long text in a button,balabalabala etc"), ":/icon/icon/long-text.svg", "long-text");
pannel2->addLargeAction(actionLongText);
SARibbonPannel* pannelStyle = new SARibbonPannel(tr("style"));
pannelStyle->setObjectName("CategoryOther-pannelStyle");
page->addPannel(pannelStyle);
QAction* actionUseQss = createAction(tr("use qss"), ":/icon/icon/useqss.svg");
connect(actionUseQss, &QAction::triggered, this, &MainWindow::onActionUseQssTriggered);
pannelStyle->addSmallAction(actionUseQss);
QAction* actionLoadCustomizeXmlFile = createAction(tr("load customize from xml file"), ":/icon/icon/useCustomize.svg");
connect(actionLoadCustomizeXmlFile, &QAction::triggered, this, &MainWindow::onActionLoadCustomizeXmlFileTriggered);
pannelStyle->addSmallAction(actionLoadCustomizeXmlFile);
QAction* actionWindowFlagNormalButton = createAction(tr("window normal button"), ":/icon/icon/windowsflag-normal.svg");