コード例 #1
0
void 
UnicornVolumeSlider::installFilters()
{
    QToolButton* muteButton = findChild<QToolButton*>();
    if( muteButton )
        muteButton->installEventFilter( this );
    
    QSlider* volumeSlider = findChild<QSlider*>();
    if( volumeSlider )
    {
        volumeSlider->setOrientation( Qt::Vertical );
        volumeSlider->installEventFilter( this );
        connect( volumeSlider, SIGNAL(valueChanged(int)), SLOT(onVolumeValueChanged(int)));
    }
    
    setFixedWidth( 30 );
    layout()->setContentsMargins( 0, 10, 0, 10);
    setAutoFillBackground( false );
}
コード例 #2
0
ファイル: kmenu.cpp プロジェクト: vasi/kdelibs
QAction* KMenu::addTitle(const QIcon &icon, const QString &text, QAction* before)
{
    QAction *buttonAction = new QAction(this);
    QFont font = buttonAction->font();
    font.setBold(true);
    buttonAction->setFont(font);
    buttonAction->setText(text);
    buttonAction->setIcon(icon);

    QWidgetAction *action = new QWidgetAction(this);
    action->setObjectName(KMENU_TITLE);
    QToolButton *titleButton = new QToolButton(this);
    titleButton->installEventFilter(d); // prevent clicks on the title of the menu
    titleButton->setDefaultAction(buttonAction);
    titleButton->setDown(true); // prevent hover style changes in some styles
    titleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    action->setDefaultWidget(titleButton);

    insertAction(before, action);
    return action;
}
コード例 #3
0
ファイル: toolbar.cpp プロジェクト: leewood/kadu
QToolButton * ToolBar::createPushButton(QAction *before, ToolBarAction &action)
{
	if (!Actions::instance()->contains(action.actionName))
		return nullptr;

	MainWindow *kaduMainWindow = qobject_cast<MainWindow *>(parentWidget());
	if (!kaduMainWindow)
		return nullptr;

	auto actionByName = Actions::instance()->value(action.actionName);
	if (!actionByName)
		return nullptr;

	if (!kaduMainWindow->supportsActionType(actionByName->type()))
		return nullptr;

	action.action = Actions::instance()->createAction(action.actionName, kaduMainWindow->actionContext(), kaduMainWindow);
	insertAction(before, action.action);

	QToolButton *button = qobject_cast<QToolButton *>(widgetForAction(action.action));

	action.widget = button;
	if (button)
	{
		connect(button, SIGNAL(pressed()), this, SLOT(widgetPressed()));
		button->installEventFilter(watcher);
		button->setToolButtonStyle(action.style);

		if (action.action->menu() && Actions::instance()->contains(action.actionName))
		{
			ActionDescription *actionDescription = Actions::instance()->value(action.actionName);
			if (actionDescription)
				button->setPopupMode(actionDescription->buttonPopupMode());
		}
	}

	return button;
}