VirtualBox

Changeset 11206 in vbox for trunk


Ignore:
Timestamp:
Aug 7, 2008 2:03:27 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
34247
Message:

Fe/Qt4: QILabel context menu rework: copy action now really available for focused QILabel through native copy shortcut without invoking context menu. Old menu creation method cause memory leak - fixed.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox4/include/QILabel_p.h

    r9799 r11206  
    3030/* Qt includes */
    3131#include <QLabel>
     32
     33class QAction;
    3234
    3335class QILabelPrivate: public QLabel
     
    135137    QSize mOwnSizeHint;
    136138    bool mStartDragging;
     139    QAction *mCopyAction;
    137140};
    138141
  • trunk/src/VBox/Frontends/VirtualBox4/src/QILabel.cpp

    r10780 r11206  
    360360    {
    361361        /* Create a context menu for the copy to clipboard action. */
    362         QMenu *menu = new QMenu();
    363         menu->addAction (tr ("&Copy") + "\t" + QString (QKeySequence (QKeySequence::Copy)), this, SLOT (copy()));
    364         menu->exec (aEvent->globalPos());
    365     }else
     362        QMenu menu;
     363        mCopyAction->setText (tr ("&Copy"));
     364        menu.addAction (mCopyAction);
     365        menu.exec (aEvent->globalPos());
     366    } else
    366367        QLabel::contextMenuEvent (aEvent);
    367368}
     
    416417    /* Open links with the QDesktopService */
    417418    setOpenExternalLinks (true);
     419
     420    /* Create invisible copy action */
     421    mCopyAction = new QAction (this);
     422    addAction (mCopyAction);
     423    mCopyAction->setShortcut (QKeySequence (QKeySequence::Copy));
     424    mCopyAction->setShortcutContext (Qt::WidgetShortcut);
     425    connect (mCopyAction, SIGNAL (triggered()), this, SLOT (copy()));
    418426}
    419427
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