Beispiel #1
0
void MapWidget::drawMarker(const MapMarker &marker, QPainter &painter, const QPointF &markerPosition, const QPointF &rectPosition)
{
    QRectF markerRect = getMarkerRect(marker, rectPosition);

    QColor bgColor = getMarkerTextBackgroundColor();
    painter.setBrush(QBrush(bgColor));

    // drawing the line connector
    painter.setPen(bgColor);
    painter.setClipping(true);
    painter.setClipRegion(QRegion(rect()).subtracted(markerRect.toRect()));
    painter.drawLine(markerRect.center(), markerPosition);

    // drawing the transparent background
    painter.setClipping(false);
    painter.setPen(Qt::NoPen);
    painter.drawRect(markerRect);

    // drawing the player marker
    const static qreal markerSize = 1.6;
    painter.setBrush(getMarkerColor());
    painter.drawEllipse(markerPosition, markerSize, markerSize);

    qreal hOffset = rectPosition.x() + TEXT_MARGIM; // left margin

    // draw the player name text
    QString playerName = marker.getPlayerName();
    painter.setFont(userFont);

    QFontMetrics metrics = painter.fontMetrics();
    qreal playerNameWidth = metrics.width(playerName);
    painter.setPen(getMarkerTextColor());
    qreal textY = rectPosition.y() + TEXT_MARGIM + metrics.descent()/2.0;
    painter.drawText(hOffset, textY, playerName);
    hOffset += playerNameWidth + TEXT_MARGIM * 3;

    // draw the player country name
    painter.setFont(countryFont);
    metrics = painter.fontMetrics();

    QColor countryNameColor(getMarkerTextColor());
    countryNameColor.setAlpha(180); // country name is drawed using some alpha
    painter.setPen(countryNameColor);
    QString countryName = marker.getCountryName();
    painter.drawText(hOffset, textY, countryName);

    hOffset += metrics.width(countryName);

    painter.setFont(userFont); //restore the normal font
    metrics = painter.fontMetrics();

    // draw the player country flag
    const QImage &image = marker.getFlag();
    qreal imageX = hOffset + TEXT_MARGIM;
    qreal imageY = rectPosition.y() - image.height()/2.0;
    painter.drawImage(QPointF(imageX, imageY), image);
}
Beispiel #2
0
void Pulsars::saveSettingsToConfig(void)
{
	conf->beginGroup("Pulsars");

	conf->setValue("url", updateUrl);
	conf->setValue("update_frequency_days", updateFrequencyDays);
	conf->setValue("updates_enabled", updatesEnabled);
	conf->setValue("distribution_enabled", getDisplayMode());
	conf->setValue("use_separate_colors", getGlitchFlag());
	conf->setValue("filter_enabled", getFilteredMode());
	conf->setValue("filter_value", QString::number(getFilterValue(), 'f', 2));
	conf->setValue("enable_at_startup", enableAtStartup);
	conf->setValue("flag_show_pulsars_button", flagShowPulsarsButton);
	conf->setValue("marker_color", StelUtils::vec3fToStr(getMarkerColor()));
	conf->setValue("glitch_color", StelUtils::vec3fToStr(getGlitchColor()));

	conf->endGroup();
}