Пример #1
0
RestStateWidget::RestStateWidget( QWidget* parent )
        : WatermarkWidget( parent )
        , m_play_enabled( true )
{
    ui.setupUi( this );

    setFontPixelSize( ui.hello, k_helloFontSize );
    setFontPixelSize( ui.label1, k_standardFontSize );
    setFontPixelSize( ui.label2, k_standardFontSize );

    #ifdef Q_WS_MAC
        QSize s = QPixmap(":/mac/RestStateWidgetCombo.png").size();
        ui.label2->setText( tr("or listen to your music in %1.", "%1 is a media player").arg( "iTunes" ) );

    #elif defined WIN32

        updatePlayerNames();

        // the long line is too wide and makes this->sizeHint huge unless we wordwrap
        ui.label2->setWordWrap( true );

        // Dirty hack to get heights looking the same on Windows
        ui.combo->setFixedHeight( 20 );
        ui.edit->setFixedHeight( 20 );
        ui.play->setFixedHeight( 22 );

    #elif defined LINUX

        ui.label2->hide(); //no plugins on Linux

        QList<QWidget*> widgets; widgets << ui.edit << ui.combo << ui.play;
        int h = 0;
        foreach ( QWidget* w, widgets )
            h = qMax( w->height(), h );
        foreach ( QWidget* w, widgets )
            w->setFixedHeight( h );

    #endif

    connect( ui.edit, SIGNAL( returnPressed() ), ui.play, SLOT( animateClick() ) );
    connect( ui.edit, SIGNAL( textChanged( QString ) ), SLOT( onEditTextChanged( QString ) ) );
    connect( ui.play, SIGNAL( clicked() ), SLOT( onPlayClicked() ) );

    ui.hello->setText( tr("Hello %1,").arg( The::currentUser().username() ) );
    ui.combo->setCurrentIndex( CurrentUserSettings().value( "RestStateWidgetComboIndex", 0 ).toInt() );

    setFocusProxy( ui.edit );

    ui.edit->installEventFilter( this );
}
Пример #2
0
void setFontPixelSizes()
{
    setFontPixelSize((QFont *)&qFontSmallest);
    setFontPixelSize((QFont *)&qFontSmaller);
    setFontPixelSize((QFont *)&qFontSmall);
    setFontPixelSize((QFont *)&qFont);
    setFontPixelSize((QFont *)&qFontLarge);
    setFontPixelSize((QFont *)&qFontLarger);
    setFontPixelSize((QFont *)&qFontSmallerBold);
    setFontPixelSize((QFont *)&qFontSmallBold);
    setFontPixelSize((QFont *)&qFontBold);
    setFontPixelSize((QFont *)&qFontLargeBold);
    setFontPixelSize((QFont *)&qFontLargerBold);
}