forked from hdijkema/QRibbon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqribbontest.cpp
More file actions
130 lines (107 loc) · 3.89 KB
/
qribbontest.cpp
File metadata and controls
130 lines (107 loc) · 3.89 KB
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
#include "qribbonsection.h"
#include "qribbontest.h"
#include "qribbon.h"
#include <QComboBox>
#include <QPlainTextEdit>
#include <QPushButton>
#include <QVBoxLayout>
#include <QApplication>
#include <cstdio>
QRibbonTest::QRibbonTest()
{
QPlainTextEdit *textEdit = new QPlainTextEdit;
textEdit->insertPlainText("Hallo allemaal!\n\nDit is een tekst!");
textEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
boundingWindow = new QWidget();
QVBoxLayout *layout = new QVBoxLayout();
boundingWindow->setLayout(layout);
layout->setContentsMargins(0,0,0,0);
layout->setSpacing(0);
layout->addWidget(this);
QPushButton *b1 = new QPushButton("Hi!", this);
b1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
QPushButton *b2 = new QPushButton("Hallo", this);
connect(b1, SIGNAL(clicked()), this, SLOT(action()));
connect(b2, SIGNAL(clicked()), this, SLOT(action()));
QRibbon *ribbon = new QRibbon(this);
QWidget* tab = ribbon->addRibbonTab("Start", "start");
QRibbonSection *one = new QRibbonSection(tab, "Section One", "one");
one->addWidget(b1, "b1");
one->addWidget(b2, "b2");
one->nextRow();
QAction *a1 = new QAction(QIcon(":/icons/test.svg"), "&Test", one);
one->addAction(a1, "a1");
connect(a1, SIGNAL(triggered()), this, SLOT(action()));
QAction *a2 = new QAction(QIcon(":/icons/test.svg"), "", one);
one->addLargeAction(a2, "a2");
connect(a2, SIGNAL(triggered()), this, SLOT(action()));
QRibbonSection *two = new QRibbonSection(tab, "Section two", "two");
QAction *aa = new QAction(QIcon(":/icons/test.svg"), "", two);
aa->setObjectName("aa");
connect(aa, SIGNAL(triggered()), this, SLOT(action()));
two->addLargeAction(aa, "aa");
QAction *bb = new QAction(QIcon(":/icons/RibbonPoint.svg"), "", two);
bb->setObjectName("bb");
connect(bb, SIGNAL(triggered()), this, SLOT(action()));
two->addLargeAction(bb, "bb");
QAction *det = new QAction(two);
two->setDetailsAction(det);
ribbon->addSection("start", one);
ribbon->addSection("start", two);
QWidget *tab2 = new QWidget();
ribbon->addTab(tab2, "Tab 2", "tab2");
QRibbonSection *three = new QRibbonSection(tab2, "Section 3", "three");
QAction *a3 = new QAction(QIcon(":/icons/QRibbonDetails.svg"), "", three);
connect(a3, SIGNAL(triggered()), this, SLOT(action()));
QComboBox *cbox = new QComboBox();
cbox->addItem("hi");
cbox->addItem("hoi");
cbox->addItem("jae");
three->addWidget(cbox, "cbox", 2);
QAction *a4 = new QAction(QIcon(":/icons/test.svg"), "", three);
connect(a4, SIGNAL(triggered()), this, SLOT(action()));
three->nextRow();
three->addAction(a4, "a4");
three->addWidget(new QLabel("HI"), "");
three->addLargeAction(a3, "a3");
ribbon->addSection("tab2", three);
connect(ribbon,SIGNAL(currentIndexChanged(int)),this,SLOT(indexChanged(int)));
setMenuWidget(ribbon);
setCentralWidget(textEdit);
//boudingWindow->setWindowFlags(Qt::FramelessWindowHint);
}
QRibbonTest::~QRibbonTest()
{
}
QSize QRibbonTest::minimumSizeHint() const
{
QSize s = QMainWindow::minimumSizeHint();
QSize ms = menuWidget()->minimumSizeHint();
s.setWidth(qMax(s.width(), ms.width()));
return s;
}
QSize QRibbonTest::sizeHint() const
{
QSize s = QMainWindow::sizeHint();
QSize ms = menuWidget()->minimumSizeHint();
s.setWidth(qMax(s.width(), ms.width()));
return s;
}
void QRibbonTest::setVisible(bool visible)
{
QMainWindow::setVisible(visible);
boundingWindow->setVisible(visible);
}
void QRibbonTest::indexChanged(int tab) {
printf("current tab = %d\n", tab);
fflush(stdout);
}
void QRibbonTest::action() {
QAction *a = (QAction *) sender();
printf("action = %p\n",a);
if (a->objectName() == "bb") {
printf("JE!\n");
QApplication::closeAllWindows();
}
fflush(stdout);
}