diff --git a/src/gui/SkyGui.cpp b/src/gui/SkyGui.cpp index 5095764e3a677..dba2346291618 100644 --- a/src/gui/SkyGui.cpp +++ b/src/gui/SkyGui.cpp @@ -34,8 +34,7 @@ #include #include -InfoPanel::InfoPanel(QGraphicsItem* parent) : QGraphicsTextItem("", parent), - infoPixmap(nullptr) +InfoPanel::InfoPanel(QGraphicsItem* parent) : QGraphicsTextItem("", parent) { QSettings* conf = StelApp::getInstance().getSettings(); Q_ASSERT(conf); @@ -62,8 +61,6 @@ InfoPanel::InfoPanel(QGraphicsItem* parent) : QGraphicsTextItem("", parent), qWarning() << "config.ini option gui/selected_object_info is invalid, using \"default\""; infoTextFilters = StelObject::InfoStringGroup(StelObject::DefaultInfo); } - if (qApp->property("text_texture")==true) // CLI option -t given? - infoPixmap=new QGraphicsPixmapItem(this); QFont font=QGuiApplication::font(); font.setPixelSize(StelApp::getInstance().getScreenFontSize()); @@ -77,7 +74,7 @@ InfoPanel::InfoPanel(QGraphicsItem* parent) : QGraphicsTextItem("", parent), if (conf->value("gui/flag_info_shadow", false).toBool()) { - // Add a drop shadow for better visibility (not on the infopixmap, though) + // Add a drop shadow for better visibility QGraphicsDropShadowEffect *effect = new QGraphicsDropShadowEffect(this); effect->setBlurRadius(6); effect->setColor(QColor(0, 0, 0)); @@ -88,58 +85,6 @@ InfoPanel::InfoPanel(QGraphicsItem* parent) : QGraphicsTextItem("", parent), InfoPanel::~InfoPanel() { - if (infoPixmap) - { - delete infoPixmap; - infoPixmap=nullptr; - } -} - -// A hackish fix for broken OpenGL font situations like RasPi2 VC4 as of 2016-03-26. -// strList is the text-only representation of InfoPanel.toPlainText(), pre-split into a stringlist. -// It is assumed: The h2 element (1-2 lines) has been broken into 1-2 lines and a line "ENDHEAD", rest follows line-by-line. -// The header lines are shown in bold large font, the rest in normal size. -// There is no bold or other font mark-up, but that should be acceptable. -QPixmap getInfoPixmap(const QStringList& strList, QFont font, QColor color) -{ - // Render the text str into a QPixmap. - // search longest string. - int maxLenIdx=0; int maxLen=0; - for (int i = 0; i < strList.size(); ++i) - { - if (strList.at(i).length() > maxLen) - { - maxLen=strList.at(i).length(); - maxLenIdx=i; - } - } - QFont titleFont(font); - titleFont.setBold(true); - titleFont.setPixelSize(font.pixelSize()+7); - - QRect strRect = QFontMetrics(titleFont).boundingRect(strList.at(maxLenIdx)); - int w = strRect.width()+1+static_cast(0.02f*static_cast(strRect.width())); - int h = strRect.height()*strList.count()+8; - - QPixmap strPixmap(w, h); - strPixmap.fill(Qt::transparent); - QPainter painter(&strPixmap); - font.setStyleStrategy(QFont::NoAntialias); // else: font problems on RasPi20160326 - //painter.setRenderHints(QPainter::TextAntialiasing); - painter.setPen(color); - painter.setFont(titleFont); - int txtOffset=0; // to separate heading from rest of text. - for (int i = 0; i < strList.size(); ++i) - { - if (strList.at(i).startsWith( "ENDHEAD")) - { - painter.setFont(font); - txtOffset=8; - } - else - painter.drawText(-strRect.x()+1, -strRect.y()+i*(painter.font().pixelSize()+2)+txtOffset, strList.at(i)); - } - return strPixmap; } void InfoPanel::setTextFromObjects(const QList& selected) @@ -148,8 +93,6 @@ void InfoPanel::setTextFromObjects(const QList& selected) { if (!document()->isEmpty()) document()->clear(); - if (qApp->property("text_texture")==true) // CLI option -t given? - infoPixmap->setVisible(false); } else { @@ -159,31 +102,6 @@ void InfoPanel::setTextFromObjects(const QList& selected) QString s = selected[0]->getInfoString(core, infoTextFilters); selected[0]->removeExtraInfoStrings(StelObject::AllInfo); setHtml(s); - if (qApp->property("text_texture")==true) // CLI option -t given? - { - // Extract color from HTML. - static const QRegularExpression colorRegExp(""); - int colorInt=s.indexOf(colorRegExp); - QString colorStr; - - if (colorInt>-1) - colorStr=colorRegExp.match(s).captured(1); - else - colorStr="#ffffff"; - - QColor infoColor(colorStr); - // inject a marker word in the infostring to mark end of header. - // In case no header exists, put it after the color tag (first closing brace). - int endHead=s.indexOf("")+5; - if (endHead==4) - endHead=s.indexOf(">")+1; - s.insert(endHead, QString("ENDHEAD
")); - setHtml(s); - infoPixmap->setPixmap(getInfoPixmap(getSelectedText().split("\n"), this->font(), infoColor)); - // setting visible=false would hide also the child QGraphicsPixmapItem... - setHtml(""); - infoPixmap->setVisible(true); - } } } diff --git a/src/gui/SkyGui.hpp b/src/gui/SkyGui.hpp index a15dbdf0f128d..f6b88543e066a 100644 --- a/src/gui/SkyGui.hpp +++ b/src/gui/SkyGui.hpp @@ -47,7 +47,6 @@ class InfoPanel : public QGraphicsTextItem private: StelObject::InfoStringGroup infoTextFilters; - QGraphicsPixmapItem *infoPixmap; // Used when text rendering is buggy. Used when CLI option -t given. }; //! The class managing the layout for button bars, selected object info and loading bars.