Exemplo n.º 1
0
void KSelectAction_UnitTest::testSetToolTipBeforeRequestingToolButtonWidget()
{
    KSelectAction selectAction("selectAction", 0);
    selectAction.setToolBarMode(KSelectAction::MenuMode);
    selectAction.setToolTip("Test");

    QToolBar toolBar;
    //Don't use requestWidget, as it needs a releaseWidget when used in MenuMode
    //(in ComboBoxMode the widget is released automatically when it is
    //destroyed). When the action is added to the QToolBar, it requests and
    //releases the widget as needed.
    toolBar.addAction(&selectAction);
    QWidget* widget = toolBar.widgetForAction(&selectAction);

    QVERIFY(widget);
    QToolButton* toolButton = qobject_cast<QToolButton*>(widget);
    QVERIFY(toolButton);
    QCOMPARE(toolButton->toolTip(), QString("Test"));
}
Exemplo n.º 2
0
QToolButton* LaunchPad::addDummyButton()
{
  QToolButton* button = ButtonPad::addDummyButton();

  QString tt = cDummyTip;
  tt.append("\n");
  tt.append(button->toolTip());
  button->setToolTip(tt);
  button->setText("Echo");

  QString cmd("echo Dummy button clicked: "
              "SymbolType=[Provider] "
              "Symbol=[Symbol] Market=[Market] "
              "FiId=[FiId] MarketId=[MarketId]");

  mCommands.append(cmd);
  mSymbolTypes.append("");
  mMultis.append(true);

  return button;
}
Exemplo n.º 3
0
bool KateViewSpace::eventFilter(QObject *obj, QEvent *event)
{
    QToolButton *button = qobject_cast<QToolButton *>(obj);

    // quick open button: show tool tip with shortcut
    if (button == m_quickOpen && event->type() == QEvent::ToolTip) {
        QHelpEvent *e = static_cast<QHelpEvent *>(event);
        QAction *quickOpen = m_viewManager->mainWindow()->actionCollection()->action(QStringLiteral("view_quick_open"));
        Q_ASSERT(quickOpen);
        QToolTip::showText(e->globalPos(),
                           button->toolTip() + QStringLiteral(" (%1)").arg(quickOpen->shortcut().toString()), button);
        return true;
    }

    // quick open button: What's This
    if (button == m_quickOpen && event->type() == QEvent::WhatsThis) {
        QHelpEvent *e = static_cast<QHelpEvent *>(event);
        const int hiddenDocs = hiddenDocuments();
        QString helpText = (hiddenDocs == 0)
                         ? i18n("Click here to switch to the Quick Open view.")
                         : i18np("Currently, there is one more document open. To see all open documents, switch to the Quick Open view by clicking here.",
                                 "Currently, there are %1 more documents open. To see all open documents, switch to the Quick Open view by clicking here.",
                                 hiddenDocs);
        QWhatsThis::showText(e->globalPos(), helpText, m_quickOpen);
        return true;
    }

    // on mouse press on view space bar tool buttons: activate this space
    if (button && ! isActiveSpace() && event->type() == QEvent::MouseButtonPress) {
        m_viewManager->setActiveSpace(this);
        if (currentView()) {
            m_viewManager->activateView(currentView()->document());
        }
    }
    return false;
}