コード例 #1
0
ファイル: OverlayText.cpp プロジェクト: Breekenz/mumble
void OverlayTextLine::setFont(const QFont& font) {
	qfFont = font;
	qpp = QPainterPath();
	QFontMetrics fm(font);
	fAscent = static_cast<float>(fm.ascent()+1);
	fDescent = static_cast<float>(fm.descent()+1);
	fEdge = qMax(static_cast<float>(font.pointSizeF()) * fEdgeFactor, 1.0f);
}
コード例 #2
0
ファイル: librarycontrol.cpp プロジェクト: daschuer/mixxx
void LibraryControl::slotFontSize(double v) {
    if (v == 0.0) {
        return;
    }
    QFont font = m_pLibrary->getTrackTableFont();
    font.setPointSizeF(font.pointSizeF() + v);
    m_pLibrary->setFont(font);
}
コード例 #3
0
void tst_QFontDialog::task256466_wrongStyle()
{
    QFontDatabase fdb;
    FriendlyFontDialog dialog;
    QListView *familyList = reinterpret_cast<QListView*>(dialog.d_func()->familyList);
    QListView *styleList = reinterpret_cast<QListView*>(dialog.d_func()->styleList);
    QListView *sizeList = reinterpret_cast<QListView*>(dialog.d_func()->sizeList);
    for (int i = 0; i < familyList->model()->rowCount(); ++i) {
        QModelIndex currentFamily = familyList->model()->index(i, 0);
        familyList->setCurrentIndex(currentFamily);
        const QFont current = dialog.currentFont(),
                    expected = fdb.font(currentFamily.data().toString(),
            styleList->currentIndex().data().toString(), sizeList->currentIndex().data().toInt());
        QCOMPARE(current.family(), expected.family());
        QCOMPARE(current.style(), expected.style());
        QCOMPARE(current.pointSizeF(), expected.pointSizeF());
    }
}
コード例 #4
0
ファイル: GuiHelpers.cpp プロジェクト: Foorgol/QTournament
QSizeF GuiHelpers::getFormattedTextSize(QPainter* painter, const QString& s, bool isBold, bool isItalics, QFont fnt, double fntSizeFac)
{
  fnt.setItalic(isItalics);
  fnt.setBold(isBold);
  fnt.setPointSizeF(fnt.pointSizeF() * fntSizeFac);

  QFontMetricsF fm{fnt};
  return fm.boundingRect(s).size();
}
コード例 #5
0
ファイル: qgscomposerutils.cpp プロジェクト: dakcarto/QGIS
QFont QgsComposerUtils::scaledFontPixelSize( const QFont &font )
{
  //upscale using FONT_WORKAROUND_SCALE
  //ref: http://osgeo-org.1560.x6.nabble.com/Multi-line-labels-and-font-bug-td4157152.html
  QFont scaledFont = font;
  double pixelSize = pointsToMM( scaledFont.pointSizeF() ) * FONT_WORKAROUND_SCALE + 0.5;
  scaledFont.setPixelSize( pixelSize );
  return scaledFont;
}
コード例 #6
0
void OutputWindow::setFontZoom(float zoom)
{
    QFont f = font();
    if (f.pointSizeF() == d->m_originalFontSize + zoom)
        return;
    float newZoom = qMax(d->m_originalFontSize + zoom, 4.0f);
    f.setPointSizeF(newZoom);
    setFont(f);
}
コード例 #7
0
void OutputWindow::setBaseFont(const QFont &newFont)
{
    float zoom = fontZoom();
    d->m_originalFontSize = newFont.pointSizeF();
    QFont tmp = newFont;
    float newZoom = qMax(d->m_originalFontSize + zoom, 4.0f);
    tmp.setPointSizeF(newZoom);
    setFont(tmp);
}
コード例 #8
0
//
// Calculates and sets the correct font size in points
// depending on the size multiplier and base font.
//
void QQuickStyledTextPrivate::setFontSize(int size, QTextCharFormat &format)
{
    static const qreal scaling[] = { 0.7, 0.8, 1.0, 1.2, 1.5, 2.0, 2.4 };
    if (baseFont.pointSizeF() != -1)
        format.setFontPointSize(baseFont.pointSize() * scaling[size - 1]);
    else
        format.setFontPointSize(baseFont.pixelSize() * qreal(72.) / qreal(qt_defaultDpi()) * scaling[size - 1]);
    *fontSizeModified = true;
}
コード例 #9
0
//General
void CartesianPlotLegendDock::labelFontChanged(const QFont& font){
	if (m_initializing)
		return;

	QFont labelsFont = font;
	labelsFont.setPixelSize( Worksheet::convertToSceneUnits(font.pointSizeF(), Worksheet::Point) );
	foreach(CartesianPlotLegend* legend, m_legendList)
		legend->setLabelFont(labelsFont);
}
コード例 #10
0
void TargetSettingsPanelWidget::setupUi()
{
    QVBoxLayout *viewLayout = new QVBoxLayout(this);
    viewLayout->setMargin(0);
    viewLayout->setSpacing(0);

    m_selector = new TargetSettingsWidget(this);
    viewLayout->addWidget(m_selector);

    // Setup our container for the contents:
    m_centralWidget = new QStackedWidget(this);
    m_selector->setCentralWidget(m_centralWidget);

    // no target label:
    m_noTargetLabel = new QWidget;
    QVBoxLayout *noTargetLayout = new QVBoxLayout(m_noTargetLabel);
    noTargetLayout->setMargin(0);
    QLabel *label = new QLabel(m_noTargetLabel);
    label->setText(tr("No kit defined in this project."));
    {
        QFont f = label->font();
        f.setPointSizeF(f.pointSizeF() * 1.4);
        f.setBold(true);
        label->setFont(f);
    }
    label->setMargin(10);
    label->setAlignment(Qt::AlignTop);
    noTargetLayout->addWidget(label);
    noTargetLayout->addStretch(10);
    m_centralWidget->addWidget(m_noTargetLabel);

    foreach (Target *t, m_project->targets())
        targetAdded(t);

    // Now set the correct target
    int index = m_targets.indexOf(m_project->activeTarget());
    m_selector->setCurrentIndex(index);
    m_selector->setCurrentSubIndex(0);

    currentTargetChanged(index, 0);

    connect(m_selector, SIGNAL(currentChanged(int,int)),
            this, SLOT(currentTargetChanged(int,int)));
    connect(m_selector, SIGNAL(removeButtonClicked(int)),
            this, SLOT(removeTarget(int)));
    connect(m_selector, SIGNAL(manageButtonClicked()),
            this, SLOT(openTargetPreferences()));
    connect(m_selector, SIGNAL(toolTipRequested(QPoint,int)),
            this, SLOT(showTargetToolTip(QPoint,int)));

    m_selector->setAddButtonMenu(m_addMenu);
    connect(m_addMenu, SIGNAL(triggered(QAction*)),
            this, SLOT(addTarget(QAction*)));

    updateTargetAddAndRemoveButtons();
}
コード例 #11
0
    void paintEvent(QPaintEvent *)
    {
        QSize pageSize = m_pageLayout.fullRectPoints().size();
        QSizeF scaledSize = pageSize.scaled(width() - 10, height() - 10, Qt::KeepAspectRatio);
        QRect pageRect = QRect(QPoint(0,0), scaledSize.toSize());
        pageRect.moveCenter(rect().center());
        qreal width_factor = scaledSize.width() / pageSize.width();
        qreal height_factor = scaledSize.height() / pageSize.height();
        QMarginsF margins = m_pageLayout.margins(QPageLayout::Point);
        int left = qRound(margins.left() * width_factor);
        int top = qRound(margins.top() * height_factor);
        int right = qRound(margins.right() * width_factor);
        int bottom = qRound(margins.bottom() * height_factor);
        QRect marginRect(pageRect.x() + left, pageRect.y() + top,
                         pageRect.width() - (left + right + 1), pageRect.height() - (top + bottom + 1));

        QPainter p(this);
        QColor shadow(palette().mid().color());
        for (int i=1; i<6; ++i) {
            shadow.setAlpha(180-i*30);
            QRect offset(pageRect.adjusted(i, i, i, i));
            p.setPen(shadow);
            p.drawLine(offset.left(), offset.bottom(), offset.right(), offset.bottom());
            p.drawLine(offset.right(), offset.top(), offset.right(), offset.bottom()-1);
        }
        p.fillRect(pageRect, palette().light());

        if (marginRect.isValid()) {
            p.setPen(QPen(palette().color(QPalette::Dark), 0, Qt::DotLine));
            p.drawRect(marginRect);

            marginRect.adjust(2, 2, -1, -1);
            p.setClipRect(marginRect);
            QFont font;
            font.setPointSizeF(font.pointSizeF()*0.25);
            p.setFont(font);
            p.setPen(palette().color(QPalette::Dark));
            QString text(QLatin1String("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi."));
            for (int i=0; i<3; ++i)
                text += text;

            const int spacing = pageRect.width() * 0.1;
            const int textWidth = (marginRect.width() - (spacing * (m_pagePreviewColumns-1))) / m_pagePreviewColumns;
            const int textHeight = (marginRect.height() - (spacing * (m_pagePreviewRows-1))) / m_pagePreviewRows;

            for (int x = 0 ; x < m_pagePreviewColumns; ++x) {
                for (int y = 0 ; y < m_pagePreviewRows; ++y) {
                    QRect textRect(marginRect.left() + x * (textWidth + spacing),
                                   marginRect.top() + y * (textHeight + spacing),
                                   textWidth, textHeight);
                    p.drawText(textRect, Qt::TextWordWrap|Qt::AlignVCenter, text);
                }
            }
        }
    }
コード例 #12
0
float
QMMLPainter::fontSize() const {
    QFont f = p->font();
    float size;
    if (f.pointSize() == -1) {
        size = f.pixelSize()*72/dpi(false);
    } else {
        size = f.pointSizeF();
    }
    return size;
}
コード例 #13
0
ファイル: qgslabelinggui.cpp プロジェクト: CzendaZdenda/qgis
void QgsLabelingGui::updateFont( QFont font )
{
  QString fontSizeUnitString = tr( "pt" );
  if ( mFontSizeUnitComboBox->currentIndex() == 1 )
  {
    fontSizeUnitString = tr( "map units" );
  }
  lblFontName->setText( QString( "%1, %2 %3" ).arg( font.family() ).arg( font.pointSizeF() ).arg( fontSizeUnitString ) );
  lblFontPreview->setFont( font );
  updatePreview();
}
コード例 #14
0
void Configration_Form::resizeEvent(QResizeEvent *)
{
    /*화면크기에 따른 폰트사이즈 조정*/
    QFont font;
    font.setPointSizeF(this->width()/40);
    if(font.pointSizeF()<=12)
    {
        font.setPointSizeF(12);
    }
    ui->label_Title->setFont(font);
}
コード例 #15
0
/** Default constructor. */
ExtendedTabBar::ExtendedTabBar(QWidget *parent)
	: QTabBar(parent)
{
	SettingsPrivate *settings = SettingsPrivate::instance();
	QFont f = settings->font(SettingsPrivate::FF_Library);
	f.setPointSizeF(f.pointSizeF() * 0.8);
	this->setFont(f);
	this->setMouseTracking(true);


	connect(settings, &SettingsPrivate::fontHasChanged, this, [=](SettingsPrivate::FontFamily ff, const QFont &newFont) {
		if (ff == SettingsPrivate::FF_Library) {
			this->setMinimumHeight(fontMetrics().height() * 1.25);
			this->setMaximumHeight(fontMetrics().height() * 1.25);
			QFont font = newFont;
			font.setPointSizeF(font.pointSizeF() * 0.8);
			this->setFont(font);
		}
	});
}
コード例 #16
0
ファイル: GuiHelpers.cpp プロジェクト: Foorgol/QTournament
void GuiHelpers::drawFormattedText(QPainter* painter, int x0, int yBaseline, const QString& s, bool isBold, bool isItalics, QFont fnt, QColor fntColor, double fntSizeFac)
{
  fnt.setItalic(isItalics);
  fnt.setBold(isBold);
  fnt.setPointSizeF(fnt.pointSizeF() * fntSizeFac);

  painter->save();
  painter->setPen(QPen(fntColor));
  painter->setFont(fnt);
  painter->drawText(x0, yBaseline, s);
  painter->restore();
}
コード例 #17
0
/**
 * Update the number of unread messages in the tray icon
 */
void KCheckGmailTray::updateCountImage(QColor color)
{
    kDebug() << k_funcinfo << "Count=" << mMailCount;

    if(mMailCount == 0)
        setPixmapEmpty();
    else {
        // adapted from KMSystemTray::updateCount()

        int oldPixmapWidth = mPixGmail.size().width();

        QString countString = QString::number( mMailCount );
        QFont countFont = KGlobalSettings::generalFont();
        countFont.setBold(true);

        // decrease the size of the font for the number of unread messages if the
        // number doesn't fit into the available space
        float countFontSize = countFont.pointSizeF();
        QFontMetrics qfm( countFont );
        int width = qfm.width( countString );
        if( width > (oldPixmapWidth - 2) )
        {
            countFontSize *= float( oldPixmapWidth - 2 ) / float( width );
            countFont.setPointSizeF( countFontSize );
        }

        // Overlay the light KCheckGmail image with the number image
        QImage iconWithNumberImage = mLightIconImage.copy();
        QPainter p( &iconWithNumberImage );
        p.setFont( countFont );
        KColorScheme scheme( QPalette::Active, KColorScheme::View );

        qfm = QFontMetrics( countFont );
        QRect boundingRect = qfm.tightBoundingRect( countString );
        boundingRect.adjust( 0, 0, 0, 2 );
        boundingRect.setHeight( qMin( boundingRect.height(), oldPixmapWidth ) );
        boundingRect.moveTo( (oldPixmapWidth - boundingRect.width()) / 2,
                             ((oldPixmapWidth - boundingRect.height()) / 2) - 1 );
        p.setOpacity( 0.7 );
        p.setBrush( scheme.background( KColorScheme::LinkBackground ) );
        p.setPen( scheme.background( KColorScheme::LinkBackground ).color() );
        p.drawRoundedRect( boundingRect, 2.0, 2.0 );

        p.setBrush( Qt::NoBrush );
//		p.setPen( scheme.foreground( KColorScheme::LinkText ).color() );
        p.setPen(color);
        p.setOpacity( 1.0 );
        p.drawText( iconWithNumberImage.rect(), Qt::AlignCenter, countString );

        setIcon( QPixmap::fromImage( iconWithNumberImage ) );
    }
}
コード例 #18
0
void TernaryAxis::updatePrerenderedLabels()
{
    TextAttributes attributes = titleTextAttributes();
    double axisLabelAngle = 0.0;
    double fiftyMarkAngle = 0.0;
    QPointF axisLabelPosition;
    QPointF fiftyMarkPosition;
    KDChartEnums::PositionValue fiftyMarkReferencePoint = KDChartEnums::PositionUnknown;

    switch( position().value() ) {
    case KDChartEnums::PositionSouth:
        // this is the axis on the other side of A
        axisLabelAngle = 0.0;
        fiftyMarkAngle = 0.0;
        axisLabelPosition = TriangleTop;
        fiftyMarkPosition = 0.5 * AxisVector_B_C - RelMarkerLength * Norm_B_C;
        fiftyMarkReferencePoint = KDChartEnums::PositionNorth;
        break;
    case KDChartEnums::PositionEast:
        // this is the axis on the other side of B
        axisLabelAngle = 240.0;
        fiftyMarkAngle = 60;
        axisLabelPosition = TriangleBottomLeft;
        fiftyMarkPosition = AxisVector_B_C + 0.5 * AxisVector_C_A - RelMarkerLength * Norm_C_A;
        fiftyMarkReferencePoint = KDChartEnums::PositionSouth;
        break;
    case KDChartEnums::PositionWest:
        // this is the axis on the other side of C
        axisLabelAngle = 120.0;
        fiftyMarkAngle = 300.0;
        axisLabelPosition = TriangleBottomRight;
        fiftyMarkPosition = 0.5 * AxisVector_B_A + RelMarkerLength * Norm_B_A;
        fiftyMarkReferencePoint = KDChartEnums::PositionSouth;
        break;
    case KDChartEnums::PositionUnknown:
        break; // initial value
    default:
        qDebug() << "TernaryAxis::updatePrerenderedLabel: unknown location";
    };

    m_label->setFont( attributes.font() );
    // m_label->setText( titleText() ); // done by setTitleText()
    m_label->setAngle( axisLabelAngle );
    m_label->setPosition( axisLabelPosition );
    m_label->setReferencePoint( KDChartEnums::PositionSouth );
    QFont font = attributes.font();
    font.setPointSizeF( 0.85 * font.pointSizeF() );
    m_fifty->setFont( font );
    m_fifty->setAngle( fiftyMarkAngle );
    m_fifty->setPosition( fiftyMarkPosition );
    m_fifty->setReferencePoint( fiftyMarkReferencePoint );
}
コード例 #19
0
ファイル: OverlayText.cpp プロジェクト: Chasophias/mumble
OverlayTextLine::OverlayTextLine(const QString& s, const QFont& f) :
		fEdgeFactor(0.05f),
		qsText(s),
		qfFont(f),
		iCurWidth(-1),
		iCurHeight(-1),
		fBaseliningThreshold(0.5f),
		bElided(false) {
	QFontMetrics fm(f);
	fAscent = static_cast<float>(fm.ascent());
	fDescent = static_cast<float>(fm.descent());
	fEdge = qMax(static_cast<float>(f.pointSizeF()) * fEdgeFactor, 1.0f);
}
コード例 #20
0
void PlaylistHeaderView::setFont(const QFont &newFont)
{
	QFont font = newFont;
	font.setPointSizeF(font.pointSizeF() * 0.8);
	QHeaderView::setFont(newFont);
	int h = fontMetrics().height() * 1.25;
	if (h >= 30) {
		this->setMinimumHeight(h);
		this->setMaximumHeight(h);
	} else {
		this->setMinimumHeight(30);
		this->setMaximumHeight(30);
	}
}
コード例 #21
0
WelcomeModeLabel::WelcomeModeLabel(QWidget *parent) :
    QLabel(parent), m_unused(0)
{
    // Bold/enlarged font slightly gray. Force color on by stylesheet as it is used
    // as a child of widgets that have stylesheets.
    QFont f = font();
#ifndef Q_OS_WIN
    f.setWeight(QFont::DemiBold);
#endif
    f.setPointSizeF(f.pointSizeF() * 1.2);
    setFont(f);
    setStyleSheet(QLatin1String("color : rgb(85, 85, 85);"));
    setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop);
}
コード例 #22
0
ファイル: systrayicon.cpp プロジェクト: Boris-de/choqok
void SysTrayIcon::updateUnreadCount( int changeOfUnreadPosts )
{
    kDebug();
    unread += changeOfUnreadPosts;

    if ( unread <= 0 ) {
        setIconByName(currentIconName());
        unread = 0;
    } else {
        // adapted from KMSystemTray::updateCount()
        int oldWidth = 22;

        QString countStr = QString::number( unread );
        QFont f = KGlobalSettings::generalFont();
        f.setBold( true );

        float pointSize = f.pointSizeF();
        QFontMetrics fm( f );
        int w = fm.width( countStr );
        if ( w > ( oldWidth - 2 ) ) {
            pointSize *= float( oldWidth - 2 ) / float( w );
            f.setPointSizeF( pointSize );
        }

        // overlay
        QPixmap overlayImg = KIcon(currentIconName()).pixmap(22,22);
        QPainter p( &overlayImg );
        p.setFont( f );
        KColorScheme scheme( QPalette::Active, KColorScheme::View );

        fm = QFontMetrics( f );
        QRect boundingRect = fm.tightBoundingRect( countStr );
        boundingRect.adjust( 0, 0, 0, 2 );
        boundingRect.setHeight( qMin( boundingRect.height(), oldWidth ) );
        boundingRect.moveTo(( oldWidth - boundingRect.width() ) / 2,
                            (( oldWidth - boundingRect.height() ) / 2 ) - 1 );
        p.setOpacity( 0.7 );
        QBrush br(QColor(255, 255, 255), Qt::SolidPattern);
        p.setBrush( br );
        p.setPen( QColor(255, 255, 255) );
        p.drawRoundedRect( boundingRect, 2.0, 2.0 );

        p.setBrush( Qt::NoBrush );
        p.setPen( QColor( 0, 0, 0 ) );
        p.setOpacity( 1.0 );
        p.drawText( overlayImg.rect(), Qt::AlignCenter, countStr );
        setIconByPixmap( overlayImg );
    }
    this->setToolTip( "choqok", i18n("Choqok"), i18np( "1 unread post", "%1 unread posts", unread ) );
}
コード例 #23
0
void ConnectionPOIDelegate::paint(QPainter *iPainter, const QStyleOptionViewItem &iOption, const QModelIndex &iIndex) const
{
    //
    // Fetch data
    //

    QStyledItemDelegate::paint(iPainter, iOption, iIndex);

    if (! iIndex.data(ConnectionPOIRole).type() != QVariant::Invalid)
        return;

    Connection::POI tConnectionPOI = iIndex.data(ConnectionPOIRole).value<Connection::POI>();


    //
    // Configure layout
    //

    // Main drawing rectangle
    QRect rect = iOption.rect;
    rect.adjust(20, 8, -20, -8);

    // Main font
    QFont font = iOption.font;


    //
    // Draw text
    //

    iPainter->save();

    // Station
    QString tStation = stationName(mStations, tConnectionPOI.station);
    iPainter->drawText(rect, Qt::AlignTop | Qt::AlignLeft, tStation);

    // Platform (TODO: might not be available for stops between endpoints)
    QString tPlatform = tr("Platform") % " " % QString::number(tConnectionPOI.platform);
    iPainter->drawText(rect, Qt::AlignTop | Qt::AlignRight, tPlatform);

    // Time
    QString tTime = tConnectionPOI.datetime.toLocalTime().time().toString(Qt::DefaultLocaleShortDate);
    iPainter->setPen(iOption.palette.mid().color());
    font.setPointSizeF(font.pointSizeF() * 0.70);
    iPainter->setFont(font);
    iPainter->drawText(rect, Qt::AlignBottom | Qt::AlignLeft, tTime);

    iPainter->restore();
}
コード例 #24
0
ファイル: Sieve.cpp プロジェクト: evaristeg/turingmachine
    virtual void renderHead(QPainter & painter, TuringMachine const & tm) const
    {
        (void)tm;
        QFont labelFont;
        qreal fontScale = 7. / QFontMetricsF(labelFont).ascent();
        labelFont.setPointSizeF(labelFont.pointSizeF() * fontScale);

        painter.save();
        painter.setFont(labelFont);
        painter.scale(1. / 4., 1. / 4.);
        painter.setPen(QPen(Qt::black, 0., Qt::SolidLine));
        painter.setBrush(Qt::black);
        painter.drawText(-5, 2, 10, 8, Qt::AlignHCenter, label());
        painter.restore();
    }
コード例 #25
0
ファイル: qgslabelinggui.cpp プロジェクト: CzendaZdenda/qgis
void QgsLabelingGui::changeTextFont()
{
  bool ok;
#if defined(Q_WS_MAC) && QT_VERSION >= 0x040500 && defined(QT_MAC_USE_COCOA)
  // Native Mac dialog works only for Qt Carbon
  QFont font = QFontDialog::getFont( &ok, lblFontPreview->font(), this, QString(), QFontDialog::DontUseNativeDialog );
#else
  QFont font = QFontDialog::getFont( &ok, lblFontPreview->font(), this );
#endif
  if ( ok )
  {
    updateFont( font );
  }
  mFontSizeSpinBox->setValue( font.pointSizeF() );
}
nsresult
nsSystemFontsQt::GetSystemFontInfo(const char *aClassName, nsString *aFontName,
                                   gfxFontStyle *aFontStyle) const
{
    QFont qFont = QApplication::font(aClassName);

    aFontStyle->style = FONT_STYLE_NORMAL;
    aFontStyle->systemFont = PR_TRUE;
    NS_NAMED_LITERAL_STRING(quote, "\"");
    nsString family((PRUnichar*)qFont.family().data());
    *aFontName = quote + family + quote;
    aFontStyle->weight = qFont.weight();
    aFontStyle->size = qFont.pointSizeF() * float(gfxQtPlatform::DPI()) / 72.0f;
    return NS_OK;
}
コード例 #27
0
QWidget* PAAlternativeLauncher::createLoginWidget(QWidget *parent)
{
	QWidget *main_widget = new QWidget(parent);
	QVBoxLayout *main_layout = new QVBoxLayout(main_widget);

	main_layout->addStretch();

	QWidget *form_widget = new QWidget(main_widget);
	QPalette palette = form_widget->palette();
	palette.setColor(QPalette::WindowText, Qt::white);
	form_widget->setPalette(palette);
	QFormLayout *form_layout = new QFormLayout(form_widget);
	form_widget->setLayout(form_layout);

	QLabel *login_label = new QLabel(tr("LOGIN"), form_widget);
	QFont font = login_label->font();
	font.setBold(true);
	font.setPointSizeF(3*font.pointSizeF());
	login_label->setFont(font);
	login_label->setAlignment(Qt::AlignCenter);
    login_label->setPalette(palette);
	form_layout->addRow(login_label);

	mUserNameLineEdit = new QLineEdit(form_widget);
	QLabel *user_name_label = new QLabel(tr("Uber ID"), form_widget);
	user_name_label->setPalette(palette);
	form_layout->addRow(user_name_label, mUserNameLineEdit);

	mPasswordLineEdit = new QLineEdit(form_widget);
	mPasswordLineEdit->setEchoMode(QLineEdit::Password);
	QLabel *password_label = new QLabel(tr("Password"), form_widget);
	password_label->setPalette(palette);
	connect(mPasswordLineEdit, SIGNAL(returnPressed()), SLOT(passwordLineEditReturnPressed()));
	form_layout->addRow(password_label, mPasswordLineEdit);

	QPushButton *login_button = new QPushButton(tr("Login"), form_widget);
	form_layout->addRow(login_button);
	connect(login_button, SIGNAL(clicked(bool)), SLOT(loginPushButtonClicked(bool)));

	main_layout->addWidget(form_widget);
	
	main_layout->addStretch();

	QSettings settings;
	mUserNameLineEdit->setText(settings.value("login/username").toString());

	return main_widget;
}
コード例 #28
0
//-----------------------------------------------------------------------------
void XAxisWidget::paintEvent(QPaintEvent*)
{
    pixel_per_sec_ = signal_view_settings_->getPixelsPerSample() * signal_view_settings_->getSampleRate();
    intervall_ = pixel_per_sec_ * MathUtils_::round125 (100.0 / pixel_per_sec_);

    if (intervall_ < 1 )
    {
        return; // invalid intervall
    }
    int32 x_end = x_start_ + width();
    int32 font_height = height() - 5;

    QPainter p (this);

    p.setPen (Qt::black);
    p.translate(-x_start_, 0);
    p.drawLine(x_start_, 0, x_end, 0);
    float64 float_x_start = floor((x_start_ + intervall_ / 2) / intervall_) *
                           intervall_;

    float64 float_x_end = ceil((x_end - intervall_ / 2) / intervall_) *
                          intervall_ + intervall_ / 2;

    for (float32 float_x = float_x_start;
         float_x < float_x_end;
         float_x += intervall_)
    {
        int32 x = (int32)(float_x + 0.5);
        p.drawLine(x, 0, x, 5);
        p.drawText((int32)(x - intervall_ / 2), 5, (int32)intervall_, font_height,
                   Qt::AlignHCenter | Qt::AlignVCenter,
                   QString::number(float_x / pixel_per_sec_));
    }

    if (highlighting_enabled_)
    {
        QFont font;
        font.setPointSizeF (font.pointSizeF() * 1.5);
        font.setBold (true);
        p.setFont (font);
        QRect bounding_rect = p.boundingRect (0, 0, 0, font.pixelSize(), Qt::AlignHCenter | Qt::AlignVCenter, QString::number(time_to_highlight_, 'f', 3));
        bounding_rect.moveTo (time_to_highlight_ * pixel_per_sec_, 5);
        p.fillRect (bounding_rect, Qt::white);
        p.setPen (Qt::black);
        p.drawText (bounding_rect, Qt::AlignLeft | Qt::AlignTop, QString::number(time_to_highlight_, 'f', 2));
        last_highlight_rect_ = bounding_rect;
    }
}
コード例 #29
0
ファイル: tabbar.cpp プロジェクト: VengefulVeggie/Miam-Player
TabBar::TabBar(TabPlaylist *parent) :
	QTabBar(parent), lineEdit(new QLineEdit(this)), tabPlaylist(parent)
{
	this->setAcceptDrops(true);
	this->setDocumentMode(true);
	this->setTabsClosable(true);
	this->setUsesScrollButtons(true);
	this->installEventFilter(this);

	lineEdit->setVisible(false);
	lineEdit->setAlignment(Qt::AlignCenter);
	lineEdit->setFrame(false);
	lineEdit->installEventFilter(this);
	lineEdit->setAttribute(Qt::WA_MacShowFocusRect, false);

	_timer = new QTimer(this);
	_timer->setInterval(300);
	_timer->setSingleShot(true);

	connect(lineEdit, &QLineEdit::returnPressed, this, &TabBar::renameTab);
	// Switch between tabs if the Drag & Drop isn't finished
	connect(_timer, &QTimer::timeout, [=]() {
		this->setCurrentIndex(tabAt(_targetRect.center()));
		_targetRect = tabRect(currentIndex());
	});

	SettingsPrivate *settings = SettingsPrivate::instance();
	auto applyFont = [this, settings] (SettingsPrivate::FontFamily ff, const QFont &newFont)
	{
		if (ff == SettingsPrivate::FF_Playlist) {
			QFont font = newFont;
			font.setPointSizeF(font.pointSizeF() * 0.8);
			this->setFont(font);
			int h = fontMetrics().height() * 1.25;
			if (h >= 30) {
				this->setMinimumHeight(h);
				this->setMaximumHeight(h);
			} else {
				this->setMinimumHeight(30);
				this->setMaximumHeight(30);
			}
		}
	};
	// Init font from settings
	applyFont(SettingsPrivate::FF_Playlist, settings->font(SettingsPrivate::FF_Playlist));
	connect(settings, &SettingsPrivate::fontHasChanged, this, applyFont);
}
コード例 #30
0
void CellEditor::setEditorFont(QFont const & font, bool updateSize, const KoViewConverter *viewConverter)
{
    const qreal scaleY = POINT_TO_INCH(static_cast<qreal>((KoDpi::dpiY())));
    setFont(QFont(font.family(), viewConverter->documentToViewY(font.pointSizeF()) / scaleY));

    if (updateSize) {
        QFontMetrics fontMetrics(this->font());
        int width = fontMetrics.width(toPlainText()) + fontMetrics.averageCharWidth();
        // don't make it smaller: then we would have to repaint the obscured cells
        if (width < this->width())
            width = this->width();
        int height = fontMetrics.height();
        if (height < this->height())
            height = this->height();
        setGeometry(x(), y(), width, height);
    }
}