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