VirtualBox

Changeset 5193 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Oct 9, 2007 11:00:07 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
25120
Message:

FE/Qt: Added VBoxGlobal::setTextLabel(), a proper reimpl of QToolButton::setTextLabel() that assigns a correct accel if it is present in the text string.

Location:
trunk/src/VBox/Frontends/VirtualBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxGlobal.h

    r5160 r5193  
    4141class QAction;
    4242class QLabel;
     43class QToolButton;
    4344
    4445// Auxiliary types
     
    431432                               const char *aDisabled = 0, const char *aSmallDisabled = 0,
    432433                               const char *aActive = 0, const char *aSmallActive = 0);
     434
     435    static void setTextLabel (QToolButton *aToolButton, const QString &aTextLabel);
    433436
    434437    static QRect normalizeGeometry (const QRect &aRect, const QRect &aBoundRect,
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxGlobal.cpp

    r5160 r5193  
    3737#include <qimage.h>
    3838#include <qlabel.h>
     39#include <qtoolbutton.h>
    3940
    4041#ifdef Q_WS_X11
     
    24042405}
    24052406
     2407/**
     2408 *  Replacement for QToolButton::setTextLabel() that handles the shortcut
     2409 *  letter (if it is present in the argument string) as if it were a setText()
     2410 *  call: the shortcut letter is used to automatically assign an "Alt+<letter>"
     2411 *  accelerator key sequence to the given tool button.
     2412 *
     2413 *  @note This method preserves the icon set if it was assigned before. Only
     2414 *  the text label and the accelerator are changed.
     2415 *
     2416 *  @param aToolButton  Tool button to set the text label on.
     2417 *  @param aTextLabel   Text label to set.
     2418 */
     2419/* static */
     2420void VBoxGlobal::setTextLabel (QToolButton *aToolButton,
     2421                               const QString &aTextLabel)
     2422{
     2423    AssertReturnVoid (aToolButton != NULL);
     2424
     2425    /* remember the icon set as setText() will kill it */
     2426    QIconSet iset = aToolButton->iconSet();
     2427    /* re-use the setText() method to detect and set the accelerator */
     2428    aToolButton->setText (aTextLabel);
     2429    QKeySequence accel = aToolButton->accel();
     2430    aToolButton->setTextLabel (aTextLabel);
     2431    aToolButton->setIconSet (iset);
     2432    /* set the accel last as setIconSet() would kill it */
     2433    aToolButton->setAccel (accel);
     2434}
     2435
    24062436/**
    24072437 *  Ensures that the given rectangle \a aRect is fully contained within the
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette