예제 #1
0
LayoutConfigAction::LayoutConfigAction( QWidget * parent )
    : KAction( parent )
{
    KIcon actionIcon( "configure" );    //TEMPORARY ICON
    setIcon( actionIcon );
    m_layoutMenu = new KMenu( parent );
    setMenu( m_layoutMenu );
    setText( i18n( "Playlist layouts" ) );
    m_configAction = new KAction( m_layoutMenu );
    
    m_layoutMenu->addAction( m_configAction );
    m_layoutMenu->addSeparator();
    m_layoutActions = new QActionGroup( m_layoutMenu );
    m_layoutActions->setExclusive( true );

    QStringList layoutsList( LayoutManager::instance()->layouts() );
    foreach( QString iterator, layoutsList )
    {
        m_layoutActions->addAction( iterator )->setCheckable( true );
    }
예제 #2
0
LayoutConfigAction::LayoutConfigAction( QWidget * parent )
    : KAction( parent )
    , m_layoutDialog( 0 )
{
    KIcon actionIcon( QPixmap( KStandardDirs::locate( "data", "amarok/images/playlist-layouts-22.png") ) );    //TEMPORARY ICON
    setIcon( actionIcon );
    m_layoutMenu = new KMenu( parent );
    setMenu( m_layoutMenu );
    setText( i18n( "Playlist Layouts" ) );
    m_configAction = new KAction( m_layoutMenu );
    
    m_layoutMenu->addAction( m_configAction );
    m_layoutMenu->addSeparator();
    m_layoutActions = new QActionGroup( m_layoutMenu );
    m_layoutActions->setExclusive( true );

    QStringList layoutsList( LayoutManager::instance()->layouts() );
    foreach( const QString &iterator, layoutsList )
    {
        m_layoutActions->addAction( iterator )->setCheckable( true );
    }
예제 #3
0
파일: QSidebar.cpp 프로젝트: 4ynyky/CRM
void QSideBar::paintEvent(QPaintEvent *event)
{
    QPainter p(this);

    QFont fontText(p.font());
    fontText.setFamily("Comic Sans MS"); //Helvetica Neue
    p.setFont(fontText);

    QImage texture(":/GUI/SideBarTexture");
    p.fillRect(event->rect(), QBrush(texture));
    p.setPen(Qt::black);
    p.drawLine(event->rect().topRight(), event->rect().bottomRight());

    int action_y = 0;
    int action_x = 0;

    switch (paintMode_) {
        case 0:
            action_y = 0;
            break;
        case 1:
            action_y = event->rect().height()/2-actions_.size()*actionHeight_/2;
            break;
    }

    foreach(QAction *action, actions_)
    {
        QRect actionRect;
        if (style_ == 0) {
            actionRect = QRect(action_x, action_y, event->rect().width(), actionHeight_);
        } else {
            actionRect = QRect(action_x, action_y, event->rect().height(), actionWidth_);
        }


        int curActionResize = 0;
        if (action == clickedAction_) {
            curActionResize = clickedActionSize_;
        }
        QRect actionIconRect(action_x+actionSpace_/2+curActionResize/2, action_y+actionSpace_/2+curActionResize/2, event->rect().width()-actionSpace_-curActionResize, actionHeight_-actionSpace_-curActionResize);
        QIcon  actionIcon(action->icon());
        actionIcon.paint(&p, actionIconRect);

        if((action == actionUnderMouse_) && (action != clickedAction_))
        {
            p.setOpacity(0.3);
            p.fillRect(actionRect, *colorUnderMouseAction_);
            p.setPen(QColor(9, 9, 9));
            p.drawLine(actionRect.topLeft(), actionRect.topRight());
            p.setOpacity(1);
            QToolTip::showText(mapFrom(this, QCursor::pos()), action->toolTip());
        }

        if (action == clickedAction_) {
            p.setOpacity(clickedActionSize_ / 10.0);
            p.fillRect(actionRect, *colorClickedAction_);
            p.setPen(QColor(9, 9, 9));
            p.drawLine(actionRect.topLeft(), actionRect.topRight());
            p.setOpacity(1);
        }

        if(action == actions_.last())
        {
            p.setPen(QColor(15, 15, 15));
            p.drawLine(QPoint(action_x, actionRect.bottomLeft().y()-1), QPoint(actionRect.width(), actionRect.bottomRight().y()-1));
            p.setPen(QColor(55, 55, 55));
            p.drawLine(actionRect.bottomLeft(), actionRect.bottomRight());
        }        

        p.setPen(QColor(15, 15, 15));
        p.drawLine(actionRect.topLeft(), actionRect.topRight());
        p.setPen(QColor(55, 55, 55));
        p.drawLine(QPoint(action_x, actionRect.topLeft().y()+1), QPoint(actionRect.width(), actionRect.topRight().y()+1));

        if (isDrawText_) {
            p.setPen(QColor(217, 217, 217));
            if(action->isChecked())
                p.setPen(QColor(255, 255, 255));
            QRect actionTextRect(action_x, action_y+actionRect.height()-20, event->rect().width(), 15);
            p.drawText(actionTextRect, Qt::AlignCenter, action->text());
        }

        if (style_ == 0) {
            action_y += actionRect.height();
        } else {
            action_x += actionRect.width();
        }
    }