Ribbon add shortcuts to tooltip
This commit is contained in:
@@ -79,6 +79,17 @@ void Ribbon::_setIconsSize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Ribbon::_setButtonText(QToolButton * b, QAction * a) {
|
||||||
|
b->setText(a->text());
|
||||||
|
QString sc;
|
||||||
|
for (const auto & s: a->shortcuts()) {
|
||||||
|
sc += "\n" + s.toString(QKeySequence::NativeText);
|
||||||
|
}
|
||||||
|
b->setToolTip(a->text() + sc);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Ribbon::setVisible(bool yes) {
|
void Ribbon::setVisible(bool yes) {
|
||||||
QToolBar::setVisible(yes);
|
QToolBar::setVisible(yes);
|
||||||
if (parent == 0) return;
|
if (parent == 0) return;
|
||||||
@@ -109,7 +120,7 @@ void Ribbon::init() {
|
|||||||
QBoxLayout * l, * tl;
|
QBoxLayout * l, * tl;
|
||||||
QToolButton * b;
|
QToolButton * b;
|
||||||
//tab->setIconSize(QSize(32, 32));
|
//tab->setIconSize(QSize(32, 32));
|
||||||
foreach (QAction * i, lm) {
|
for (QAction * i: lm) {
|
||||||
if (!i->menu()) continue;
|
if (!i->menu()) continue;
|
||||||
//if (!i->menu()->isVisible()) continue;
|
//if (!i->menu()->isVisible()) continue;
|
||||||
la = i->menu()->actions();
|
la = i->menu()->actions();
|
||||||
@@ -146,7 +157,7 @@ void Ribbon::init() {
|
|||||||
g->setLayout(l);
|
g->setLayout(l);
|
||||||
l->setSpacing(2);
|
l->setSpacing(2);
|
||||||
l->setContentsMargins(2, 2, 2, 2);
|
l->setContentsMargins(2, 2, 2, 2);
|
||||||
foreach (QAction * j, la) {
|
for (QAction * j: la) {
|
||||||
if (j->isSeparator()) {
|
if (j->isSeparator()) {
|
||||||
if (l->isEmpty()) continue;
|
if (l->isEmpty()) continue;
|
||||||
tl->addWidget(g);
|
tl->addWidget(g);
|
||||||
@@ -184,8 +195,7 @@ void Ribbon::init() {
|
|||||||
}
|
}
|
||||||
//b->setIconSize(QSize(16, 16));
|
//b->setIconSize(QSize(16, 16));
|
||||||
b->setIcon(j->icon());
|
b->setIcon(j->icon());
|
||||||
b->setText(j->text());
|
_setButtonText(b, j);
|
||||||
b->setToolTip(j->text());
|
|
||||||
//b->addAction(j);
|
//b->addAction(j);
|
||||||
//b->setShortcut(j->shortcut());
|
//b->setShortcut(j->shortcut());
|
||||||
b->setAutoRaise(true);
|
b->setAutoRaise(true);
|
||||||
@@ -220,11 +230,10 @@ void Ribbon::init() {
|
|||||||
|
|
||||||
void Ribbon::retranslate() {
|
void Ribbon::retranslate() {
|
||||||
QAction * a;
|
QAction * a;
|
||||||
foreach (QToolButton * i, buttons) {
|
for (QToolButton * i: buttons) {
|
||||||
a = (QAction * )(i->property("ribbonAction").toLongLong());
|
a = (QAction * )(i->property("ribbonAction").toLongLong());
|
||||||
if (a == 0) continue;
|
if (a == 0) continue;
|
||||||
i->setText(a->text());
|
_setButtonText(i, a);
|
||||||
i->setToolTip(a->toolTip());
|
|
||||||
//i->setShortcut(a->shortcut());
|
//i->setShortcut(a->shortcut());
|
||||||
}
|
}
|
||||||
for (int i = 0; i < tab->count(); ++i) {
|
for (int i = 0; i < tab->count(); ++i) {
|
||||||
@@ -237,7 +246,7 @@ void Ribbon::retranslate() {
|
|||||||
|
|
||||||
|
|
||||||
void Ribbon::setIconSize(const QSize & size) {
|
void Ribbon::setIconSize(const QSize & size) {
|
||||||
foreach (QToolButton * i, buttons)
|
for (QToolButton * i: buttons)
|
||||||
i->setIconSize(size);
|
i->setIconSize(size);
|
||||||
_resize();
|
_resize();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ private:
|
|||||||
void changeEvent(QEvent *e);
|
void changeEvent(QEvent *e);
|
||||||
void _resize();
|
void _resize();
|
||||||
void _setIconsSize();
|
void _setIconsSize();
|
||||||
|
void _setButtonText(QToolButton * b, QAction * a);
|
||||||
|
|
||||||
int hovered, delay;
|
int hovered, delay;
|
||||||
bool delay_e;
|
bool delay_e;
|
||||||
|
|||||||
Reference in New Issue
Block a user