return QString();
}
+
+bool getPixmap(QPixmap & pixmap, QString const & path)
+{
+ if (pixmap.load(path)) {
+ if (path.endsWith(".svgz") || path.endsWith(".svg") ) {
+ GuiApplication const * guiApp = theGuiApp();
+ if (guiApp != 0) {
+ pixmap.setDevicePixelRatio(guiApp->pixelRatio());
+ }
+ }
+ return true;
+ }
+ return false;
+}
+
+
QPixmap getPixmap(QString const & path, QString const & name, QString const & ext)
{
- QPixmap pixmap;
QString imagedir = path;
FileName fname = imageLibFileSearch(imagedir, name, ext, theGuiApp()->imageSearchMode());
QString fpath = toqstr(fname.absFileName());
+ QPixmap pixmap = QPixmap();
- if (pixmap.load(fpath)) {
+ if (getPixmap(pixmap, fpath)) {
return pixmap;
- } else {
- QStringList exts = ext.split(",");
- fpath = ":/" + path + name + ".";
- for (int i = 0; i < exts.size(); ++i) {
- if (pixmap.load(fpath + exts.at(i)))
+ }
+
+ QStringList exts = ext.split(",");
+ fpath = ":/" + path + name + ".";
+ for (int i = 0; i < exts.size(); ++i) {
+ if (getPixmap(pixmap, fpath + exts.at(i))) {
return pixmap;
- }
+ }
}
bool const list = ext.contains(",");
return QPixmap();
}
+
QIcon getIcon(FuncRequest const & f, bool unknown)
{
#if (QT_VERSION >= 0x040600)
return QIcon();
//LYXERR(Debug::GUI, "Found icon: " << icon);
- QPixmap pm;
- if (!pm.load(icon)) {
+ QPixmap pixmap = QPixmap();
+ if (!getPixmap(pixmap,icon)) {
LYXERR0("Cannot load icon " << icon << " please verify resource system!");
return QIcon();
}
- return QIcon(pm);
+ return QIcon(pixmap);
}
#ifdef Q_OS_MAC
#if QT_VERSION > 0x040600
setAttribute(Qt::AA_MacDontSwapCtrlAndMeta,lyxrc.mac_dontswap_ctrl_meta);
+#endif
+#if QT_VERSION > 0x050100
+ setAttribute(Qt::AA_UseHighDpiPixmaps,true);
#endif
// Create the global default menubar which is shown for the dialogs
// and if no GuiView is visible.
#include "TocModel.h"
#include "qt_helpers.h"
+#include "support/filetools.h"
#include "frontends/alert.h"
#include "frontends/KeySymbol.h"
#include <QSplitter>
#include <QStackedWidget>
#include <QStatusBar>
+#include <QSvgRenderer>
#include <QtConcurrentRun>
#include <QTime>
#include <QTimer>
class BackgroundWidget : public QWidget
{
public:
- BackgroundWidget()
+ BackgroundWidget(int width, int height)
+ : width_(width), height_(height)
{
LYXERR(Debug::GUI, "show banner: " << lyxrc.show_banner);
if (!lyxrc.show_banner)
/// The text to be written on top of the pixmap
QString const text = lyx_version ?
qt_("version ") + lyx_version : qt_("unknown version");
- splash_ = getPixmap("images/", "banner", "svgz,png");
+ QString imagedir = "images/";
+ FileName fname = imageLibFileSearch(imagedir, "banner", "svgz");
+ QSvgRenderer svgRenderer(toqstr(fname.absFileName()));
+ if (svgRenderer.isValid()) {
+ splash_ = QPixmap(splashSize());
+ QPainter painter(&splash_);
+ svgRenderer.render(&painter);
+ splash_.setDevicePixelRatio(pixelRatio());
+ } else {
+ splash_ = getPixmap("images/", "banner", "png");
+ }
QPainter pain(&splash_);
pain.setPen(QColor(0, 0, 0));
- double const multiplier = splashPixelRatio() / pixelRatio();
- int const size = static_cast<int>(toqstr(lyxrc.font_sizes[FONT_SIZE_LARGE]).toDouble() * multiplier);
- int const x = static_cast<int>(190 * multiplier);
- int const y = static_cast<int>(225 * multiplier);
+ qreal const fsize = fontSize();
+ QPointF const position = textPosition();
LYXERR(Debug::GUI,
"widget pixel ratio: " << pixelRatio() <<
" splash pixel ratio: " << splashPixelRatio() <<
- " version text size,position: " << size << "@" << x << "+" << y);
+ " version text size,position: " << fsize << "@" << position.x() << "+" << position.y());
QFont font;
// The font used to display the version info
font.setStyleHint(QFont::SansSerif);
font.setWeight(QFont::Bold);
- font.setPointSize(size);
+ font.setPointSizeF(fsize);
pain.setFont(font);
- pain.drawText(x, y, text);
+ pain.drawText(position, text);
setFocusPolicy(Qt::StrongFocus);
}
void paintEvent(QPaintEvent *)
{
- int const w = static_cast<int>(splash_.width() / splashPixelRatio());
- int const h = static_cast<int>(splash_.height() / splashPixelRatio());
+ int const w = width_;
+ int const h = height_;
int const x = (width() - w) / 2;
int const y = (height() - h) / 2;
LYXERR(Debug::GUI,
private:
QPixmap splash_;
+ int const width_;
+ int const height_;
/// Current ratio between physical pixels and device-independent pixels
double pixelRatio() const {
#endif
}
+ qreal fontSize() {
+ return toqstr(lyxrc.font_sizes[FONT_SIZE_LARGE]).toDouble();
+ }
+
+ QPointF textPosition() {
+ return QPointF(splashWidth()/2 - 16, splashHeigth() - 40);
+ }
+
+ QSize splashSize() {
+ return QSize(width_ * pixelRatio(),height_ * pixelRatio());
+ }
+
+ double splashWidth() {
+ return splash_.width()/splashPixelRatio();
+ }
+
+ double splashHeigth() {
+ return splash_.height()/splashPixelRatio();
+ }
+
/// Ratio between physical pixels and device-independent pixels of splash image
double splashPixelRatio() const {
#if QT_VERSION >= 0x050000
}
splitter_ = new QSplitter;
- bg_widget_ = new BackgroundWidget;
+ bg_widget_ = new BackgroundWidget(400, 250);
stack_widget_ = new QStackedWidget;
stack_widget_->addWidget(bg_widget_);
stack_widget_->addWidget(splitter_);