예제 #1
0
void ImageView::setFile(const QString &fileName, const QByteArray &format)
{
    if (format == QByteArrayLiteral("gif")) {
        if (movie) {
            movie->setFileName(fileName);
        } else {
            movie = new QMovie(fileName, format, this);
        }

        connect(movie, &QMovie::frameChanged, this, [this] {
            const QPixmap &current_pixmap = movie->currentPixmap();
            m_sourceSize = current_pixmap.size();

            const QSize &dsize = qApp->desktop()->size();
            qreal device_pixel_ratio = this->devicePixelRatioF();

            QPixmap pixmap = current_pixmap.scaled(QSize(qMin((int)(dsize.width() * 0.7 * device_pixel_ratio), m_sourceSize.width()),
                                                         qMin((int)(dsize.height() * 0.8 * device_pixel_ratio), m_sourceSize.height())),
                                                   Qt::KeepAspectRatio, Qt::SmoothTransformation);

            pixmap.setDevicePixelRatio(device_pixel_ratio);

            setPixmap(pixmap);
        });

        movie->start();

        return;
    } else if (movie) {
        movie->stop();
        movie->deleteLater();
    }

    QImageReader reader(fileName, format);

    m_sourceSize = reader.size();

    const QSize &dsize = qApp->desktop()->size();
    qreal device_pixel_ratio = this->devicePixelRatioF();

    QPixmap pixmap = QPixmap::fromImageReader(&reader).scaled(QSize(qMin((int)(dsize.width() * 0.7 * device_pixel_ratio), m_sourceSize.width()),
                                                                    qMin((int)(dsize.height() * 0.8 * device_pixel_ratio), m_sourceSize.height())),
                                                              Qt::KeepAspectRatio, Qt::SmoothTransformation);

    pixmap.setDevicePixelRatio(device_pixel_ratio);

    setPixmap(pixmap);
}
예제 #2
0
DocsetMetadata::DocsetMetadata(const QJsonObject &jsonObject)
{
    m_name = jsonObject[QStringLiteral("name")].toString();
    m_title = jsonObject[QStringLiteral("title")].toString();

    m_rawIcon = QByteArray::fromBase64(jsonObject[QStringLiteral("icon")].toString().toLocal8Bit());
    m_icon.addPixmap(QPixmap::fromImage(QImage::fromData(m_rawIcon)));

    m_rawIcon2x = QByteArray::fromBase64(jsonObject[QStringLiteral("icon2x")].toString()
            .toLocal8Bit());
    // TODO: Check on a high-resolution screen
    if (qApp->devicePixelRatio() > 1.0) {
        QPixmap pixmap = QPixmap::fromImage(QImage::fromData(m_rawIcon2x));
        pixmap.setDevicePixelRatio(2.0);
        m_icon.addPixmap(pixmap);
    }

    for (const QJsonValue &vv : jsonObject[QStringLiteral("aliases")].toArray())
        m_aliases << vv.toString();

    for (const QJsonValue &vv : jsonObject[QStringLiteral("versions")].toArray())
        m_versions << vv.toString();
    m_revision = jsonObject[QStringLiteral("revision")].toString();

    m_feedUrl = QUrl(jsonObject[QStringLiteral("feed_url")].toString());
    const QJsonArray urlArray = jsonObject[QStringLiteral("urls")].toArray();
    for (const QJsonValue &url : urlArray)
        m_urls.append(QUrl(url.toString()));

    m_extra = jsonObject[QStringLiteral("extra")].toObject();
}
예제 #3
0
void Overview::load(const QImage& image, qreal pixelratio)
{
	// Find minimum scale
	m_min_scale_level = 9;
	int side_max = std::max(image.width(), image.height()) * 0.9;
	int side = 400;
	if (side_max > side) {
		for (int i = 9; i >= 0; --i) {
			int side_test = std::floor(400.0 / ZoomSlider::scaleFactor(i));
			if (side_test > side_max) {
				break;
			}
			m_min_scale_level = i;
			side = side_test;
		}
	} else {
		side = side_max;
	}
	QPixmap pixmap = QPixmap::fromImage(image.scaled(side * pixelratio, side * pixelratio, Qt::KeepAspectRatio, Qt::SmoothTransformation), Qt::AutoColor | Qt::AvoidDither);
	pixmap.setDevicePixelRatio(pixelratio);
	zoom(m_min_scale_level);

	// Resize window
	bool default_size = m_default;
	QSize size = transform().mapRect(QRect(QPoint(0,0), pixmap.size() / pixelratio)).size();
	setMinimumSize(size);
	if (default_size) {
		resize(minimumSize());
	}

	// Show overview
	setPixmap(pixmap);
}
예제 #4
0
// Update the map for the given location.
void LocationDialog::setMapForLocation(const StelLocation& loc)
{
	// Avoids useless processing
	if (lastPlanet==loc.planetName)
		return;

	QPixmap pixmap;
	// Try to set the proper planet map image
	if (loc.planetName=="Earth")
	{
		// Special case for earth, we don't want to see the clouds
		pixmap = QPixmap(":/graphicGui/world.png");
	}
	else
	{
		SolarSystem* ssm = GETSTELMODULE(SolarSystem);
		PlanetP p = ssm->searchByEnglishName(loc.planetName);
		if (p)
		{
			QString path = StelFileMgr::findFile("textures/"+p->getTextMapName());
			if (path.isEmpty())
			{
				qWarning() << "ERROR - could not find planet map for " << loc.planetName;
				return;
			}
			pixmap = QPixmap(path);
		}
	}
	StelCore * core = StelApp::getInstance().getCore();
	pixmap.setDevicePixelRatio(core->getCurrentStelProjectorParams().devicePixelsPerPixel);
	ui->mapLabel->setPixmap(pixmap);
	// For caching
	lastPlanet = loc.planetName;
}
예제 #5
0
/*!
  \return A pixmap that can be used as backing store

  \param widget Widget, for which the backinstore is intended
  \param size Size of the pixmap
 */
QPixmap QwtPainter::backingStore( QWidget *widget, const QSize &size )
{
    QPixmap pm;

#define QWT_HIGH_DPI 1

#if QT_VERSION >= 0x050000 && QWT_HIGH_DPI
    qreal pixelRatio = 1.0;

    if ( widget && widget->windowHandle() )
    {
        pixelRatio = widget->windowHandle()->devicePixelRatio();
    }
    else
    {
        if ( qApp )
            pixelRatio = qApp->devicePixelRatio();
    }

    pm = QPixmap( size * pixelRatio );
    pm.setDevicePixelRatio( pixelRatio );
#else
    Q_UNUSED( widget )
    pm = QPixmap( size );
#endif

#if 0
#ifdef Q_WS_X11
    if ( pm.x11Info().screen() != x11Info().screen() )
         pm.x11SetScreen( x11Info().screen() );
#endif
#endif

    return pm;
}
예제 #6
0
파일: theme.cpp 프로젝트: gottcode/cutemaze
void Theme::cache(const QString& element, QPixmap& pixmap, const QRect& bounds, int angle) const
{
	pixmap = QPixmap(bounds.size() * m_ratio);
	pixmap.setDevicePixelRatio(m_ratio);
	pixmap.fill(QColor(255, 255, 255, 0));
	QPainter painter(&pixmap);
	m_renderer->render(&painter, element, bounds);

	// Handle rotated images
	if (angle) {
		Q_ASSERT(angle == 90 || angle == 180 || angle == 270);
		painter.end();
		pixmap = pixmap.transformed(QTransform().rotate(angle));
		pixmap.setDevicePixelRatio(m_ratio);
	}
}
UpdateNotifier::UpdateNotifier(QWidget *parent)
    : QFrame(parent),
      m_icon(new QLabel),
      m_title(new NormalLabel(tr("Updates"))),
      m_content(new TipsLabel(tr("Updates detected, click to view"))),
      m_closeButton(new DImageButton(this)),
      m_settings(new QSettings("deepin", "dcc-update-notifier")),
      m_updaterInter(new com::deepin::lastore::Updater("com.deepin.lastore",
                                                       "/com/deepin/lastore",
                                                       QDBusConnection::systemBus(), this))
{
    setFixedHeight(80);
    setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed);

    m_content->setWordWrap(true);
    m_content->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);

    const qreal ratio = devicePixelRatioF();
    QIcon icon = QIcon::fromTheme("system-updated", QIcon::fromTheme("application-default-icon"));
    m_icon->setFixedSize(48, 48);

    QPixmap pixmap = icon.pixmap(m_icon->width() * ratio, m_icon->height() * ratio);
    pixmap = pixmap.scaled(m_icon->width() * ratio, m_icon->height() * ratio,
                           Qt::KeepAspectRatioByExpanding,
                           Qt::SmoothTransformation);
    pixmap.setDevicePixelRatio(ratio);

    m_icon->setPixmap(pixmap);

    m_closeButton->setFixedSize(14, 14);

    m_closeButton->setObjectName("NotifyCloseButton");
    m_closeButton->setVisible(false);

    QVBoxLayout *contentLayout = new QVBoxLayout;
    contentLayout->setSpacing(0);
    contentLayout->setMargin(0);

    contentLayout->addStretch();
    contentLayout->addWidget(m_title);
    contentLayout->addSpacing(4);
    contentLayout->addWidget(m_content);
    contentLayout->addStretch();

    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->setSpacing(10);
    mainLayout->setContentsMargins(40, 0, 40, 0);
    mainLayout->addWidget(m_icon);
    mainLayout->addLayout(contentLayout);

    setLayout(mainLayout);

    m_updaterInter->setSync(false);
    updatablePkgsChanged(m_updaterInter->updatablePackages());
    connect(m_updaterInter, &com::deepin::lastore::Updater::UpdatablePackagesChanged,
            this, &UpdateNotifier::updatablePkgsChanged);

    connect(m_closeButton, &DImageButton::clicked, this, &UpdateNotifier::ignoreUpdates);
}
예제 #8
0
void MorePage::initializeWidget()
{
    //导航栏
    QString strTitle = tr("更多...");
    navigationBar = new NavigationBar(this);
    navigationBar->setTitleText(strTitle);

    QHBoxLayout* pHLTop = new QHBoxLayout();
    pHLTop->addWidget(navigationBar);
    pHLTop->setSpacing(0);
    pHLTop->setMargin(0);
    this->setTopbarLayout(pHLTop);


    //个人信息
    QLabel* themeWidget = new QLabel;
    QPixmap pixmap = QPixmap(ImagePath::MOREPAGE_THEME);
    pixmap.setDevicePixelRatio(2);
    themeWidget->setAutoFillBackground(true);
    themeWidget->setFixedHeight(this->screenHeight()*0.25);
    themeWidget->setFixedWidth(this->screenWidth());
    themeWidget->setPixmap(pixmap);
    themeWidget->setScaledContents(true);

    btnPersonalInfo = new QToolButton;
    btnPersonalInfo->setFixedWidth(this->screenWidth());
    btnPersonalInfo->setFixedHeight(this->screenHeight()*0.15);
    btnPersonalInfo->setIconSize(QSize(btnPersonalInfo->height()*0.7, btnPersonalInfo->height()*0.7));
    btnPersonalInfo->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    btnPersonalInfo->setStyleSheet("font:16px; color:white;background-color:rgba(0,0,0,0)");
    connect(btnPersonalInfo, SIGNAL(clicked()), SLOT(on_btnPersonal_clicked()));

    QVBoxLayout* themeLayout = new QVBoxLayout;
    themeLayout->addWidget(btnPersonalInfo);
    themeLayout->setMargin(0);
    themeWidget->setLayout(themeLayout);

    //设置
    btnSetting = new GroupButton;
    btnSetting->setStyleSheet(SheetStyle::GROUPBUTTON_BOTTOMBORDER);
    QPixmap settingPixmap(ImagePath::SETTING);
    this->setGroupButton(btnSetting, settingPixmap, tr("设置"));
    connect(btnSetting, SIGNAL(clicked()), SLOT(on_btnSetting_clicked()));

    QVBoxLayout* vblTotalLayout = new QVBoxLayout;
    vblTotalLayout->addWidget(themeWidget);
    vblTotalLayout->addSpacing(this->screenHeight()*0.026);
    vblTotalLayout->addWidget(btnSetting);
    vblTotalLayout->setAlignment(Qt::AlignTop);
    vblTotalLayout->setMargin(0);
    vblTotalLayout->setSpacing(0);
    this->setBodyPartLayout(vblTotalLayout);

    //屏幕触摸滚动设置
    this->setBodyScreenHeight(this->scrollAreaHasBottomBarHeight());
    this->installScrollViewportArea();
    this->loadLocalData(curAccountID);
}
예제 #9
0
void QuickBeamerDialog::updatePreview(const QString &theme)
{
QPixmap pixmap;
pixmap.load(":/images/beamer/"+theme+".png");
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
if (qApp->devicePixelRatio()>=2) pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
#endif
labelImage->setPixmap(pixmap);
}
예제 #10
0
파일: gutil.cpp 프로젝트: jcome/opentoonz
QPixmap rasterToQPixmap(const TRaster32P &ras, bool premultiplied,
                        bool setDevPixRatio) {
  QPixmap pixmap = QPixmap::fromImage(rasterToQImage(ras, premultiplied));
  if (setDevPixRatio) {
    static int devPixRatio = QApplication::desktop()->devicePixelRatio();
    pixmap.setDevicePixelRatio(devPixRatio);
  }
  return pixmap;
}
예제 #11
0
 //______________________________________________________________________________________
 inline void setDevicePixelRatio( QPixmap& pixmap, qreal value )
 {
     #if QT_VERSION >= 0x050300
     return pixmap.setDevicePixelRatio( value );
     #else
     Q_UNUSED( pixmap );
     Q_UNUSED( value );
     #endif
 }
예제 #12
0
/*!
  \since 5.1

  Returns a pixmap with the requested \a window \a size, \a mode, and \a
  state, generating one if necessary.

  The pixmap can be smaller than the requested size. If \a window is on
  a high-dpi display the pixmap can be larger. In that case it will have
  a devicePixelRatio larger than 1.

  \sa  actualSize(), paint()
*/
QPixmap QIcon::pixmap(QWindow *window, const QSize &size, Mode mode, State state) const
{
    if (!d)
        return QPixmap();

    qreal devicePixelRatio = qt_effective_device_pixel_ratio(window);

    // Handle the simple normal-dpi case:
    if (!(devicePixelRatio > 1.0)) {
        QPixmap pixmap = d->engine->pixmap(size, mode, state);
        pixmap.setDevicePixelRatio(1.0);
        return pixmap;
    }

    // Try get a pixmap that is big enough to be displayed at device pixel resolution.
    QPixmap pixmap = d->engine->pixmap(size * devicePixelRatio, mode, state);
    pixmap.setDevicePixelRatio(d->pixmapDevicePixelRatio(devicePixelRatio, size, pixmap.size()));
    return pixmap;
}
예제 #13
0
파일: utils.cpp 프로젝트: rekols/redict
QPixmap Utils::renderSVG(const QString &path, const QSize &size)
{
    QImageReader reader;
    QPixmap pixmap;
    reader.setFileName(path);

    if (reader.canRead()) {
        const qreal ratio = qApp->devicePixelRatio();
        reader.setScaledSize(size * ratio);
        pixmap = QPixmap::fromImage(reader.read());
        pixmap.setDevicePixelRatio(ratio);
    } else {
        pixmap.load(path);
    }

    return pixmap;
}
예제 #14
0
static void paintSelectedTabBackground(QPainter *painter, const QRect &spanRect)
{
    const int verticalOverlap = 2; // Grows up and down for the overlaps
    const int dpr = painter->device()->devicePixelRatio();
    const QString cacheKey = QLatin1String(Q_FUNC_INFO) + QString::number(spanRect.width())
            + QLatin1Char('x') + QString::number(spanRect.height())
            + QLatin1Char('@') + QString::number(dpr);
    QPixmap selection;
    if (!QPixmapCache::find(cacheKey, &selection)) {
        selection = QPixmap(QSize(spanRect.width(), spanRect.height() + 2 * verticalOverlap) * dpr);
        selection.fill(Qt::transparent);
        selection.setDevicePixelRatio(dpr);
        QPainter p(&selection);
        p.translate(QPoint(0, verticalOverlap));

        const QRect rect(QPoint(), spanRect.size());
        const QRectF borderRect = QRectF(rect).adjusted(0.5, 0.5, -0.5, -0.5);

        //background
        p.save();
        QLinearGradient grad(rect.topLeft(), rect.topRight());
        grad.setColorAt(0, QColor(255, 255, 255, 140));
        grad.setColorAt(1, QColor(255, 255, 255, 210));
        p.fillRect(rect, grad);
        p.restore();

        //shadows
        p.setPen(QColor(0, 0, 0, 110));
        p.drawLine(borderRect.topLeft() + QPointF(1, -1), borderRect.topRight() - QPointF(0, 1));
        p.drawLine(borderRect.bottomLeft(), borderRect.bottomRight());
        p.setPen(QColor(0, 0, 0, 40));
        p.drawLine(borderRect.topLeft(), borderRect.bottomLeft());

        //highlights
        p.setPen(QColor(255, 255, 255, 50));
        p.drawLine(borderRect.topLeft() + QPointF(0, -2), borderRect.topRight() - QPointF(0, 2));
        p.drawLine(borderRect.bottomLeft() + QPointF(0, 1), borderRect.bottomRight() + QPointF(0, 1));
        p.setPen(QColor(255, 255, 255, 40));
        p.drawLine(borderRect.topLeft() + QPointF(0, 0), borderRect.topRight());
        p.drawLine(borderRect.topRight() + QPointF(0, 1), borderRect.bottomRight() - QPointF(0, 1));
        p.drawLine(borderRect.bottomLeft() + QPointF(0, -1), borderRect.bottomRight() - QPointF(0, 1));

        QPixmapCache::insert(cacheKey, selection);
    }
    painter->drawPixmap(spanRect.topLeft() + QPoint(0, -verticalOverlap), selection);
}
예제 #15
0
QPixmap* MainWindow::fromSvgToPixmap(const QSize &ImageSize, const QString &SvgFile)
{
 const qreal PixelRatio = this->devicePixelRatio();
 QSvgRenderer svgRenderer(SvgFile);
 QPixmap *img = new QPixmap(ImageSize*PixelRatio);
 QPainter Painter;

 img->fill(Qt::transparent);

 Painter.begin(img);
 svgRenderer.render(&Painter);
 Painter.end();

 img->setDevicePixelRatio(PixelRatio);

 return img;
}
예제 #16
0
void VpnPage::importVPN()
{
    emit requestFrameKeepAutoHide(false);
    const auto file = QFileDialog::getOpenFileUrl(nullptr);
    emit requestFrameKeepAutoHide(true);
    if (file.isEmpty())
        return;

    const auto args = QStringList { "connection", "import", "type", vpnConfigType(file.path()), "file", file.path() };
    qDebug() << args;

    QProcess p;
    p.start("nmcli", args);
    p.waitForFinished();
    const auto stat = p.exitCode();
    const QString output = p.readAllStandardOutput();
    QString error = p.readAllStandardError();

    qDebug() << stat << output << error;

    if (stat)
    {
        const auto ratio = devicePixelRatioF();
        QPixmap icon = QIcon::fromTheme("dialog-error").pixmap(QSize(48, 48) * ratio);
        icon.setDevicePixelRatio(ratio);

        DDialog dialog;
        dialog.setTitle(tr("Import Error"));
        dialog.setMessage(error.replace(QRegularExpression("[::]\\s+"), ":\n"));
        dialog.addButton(tr("OK"));
        dialog.setIcon(icon);
        dialog.exec();

        return;
    }

    const QRegularExpression regexp("\\(([-\\w]+)\\)");
    const auto match = regexp.match(output);

    if (match.hasMatch())
    {
        m_editingConnUuid = match.captured(1);
        emit requestEditVpn("/", m_editingConnUuid);
    }
}
예제 #17
0
void SurfaceImpl::InitPixMap(int width, int height, Surface *, WindowID wid)
{
    Release();

#if QT_VERSION >= 0x050000
    int dpr = PWindow(wid)->devicePixelRatio();
    QPixmap *pixmap = new QPixmap(width * dpr, height * dpr);
    pixmap->setDevicePixelRatio(dpr);
#else
    QPixmap *pixmap = new QPixmap(width, height);
    Q_UNUSED(wid);
#endif

    pd = pixmap;

    painter = new QPainter(pd);
    my_resources = true;
}
예제 #18
0
        static void createPixmap(Item &item) {
            static qreal dpr = 2.0;
            static QSize iconSize(44, 44);
            QPixmap pixmap(iconSize.width() * Last * dpr, iconSize.height() * dpr);
            pixmap.setDevicePixelRatio(dpr);
            pixmap.fill(QColor(Qt::white));

            {
                const int margin(2);

                QPainter painter(&pixmap);
                QPen pen(item.pen);

                pen.setWidth(pen.width() * 2);

                painter.setPen(pen);
                painter.setBrush(item.brush);

                for (int i = Rect; i < Last; i++) {
                    const QRect rect(QPoint(iconSize.width() * i, 0), iconSize);

                    switch (i) {
                    case Rect: {
                        painter.drawRect(rect.adjusted(margin, margin, -margin, -margin));
                        break;
                    }
                    case Line:{
                        painter.drawLine(QLine(QPoint(rect.left() + margin, rect.center().y() - 2),
                                               QPoint(rect.right() - margin, rect.center().y() - 2)));
                        pen.setStyle(Qt::DotLine);
                        painter.setPen(pen);
                        painter.drawLine(QLine(QPoint(rect.left() + margin, rect.center().y() + 2),
                                               QPoint(rect.right() - margin, rect.center().y() + 2)));
                        break;
                    }
                    }
                }
            }

            item.pixmap = pixmap;
        }
QPixmap loadPixmap(const QString &path)
{
    qreal ratio = 1.0;
    QPixmap pixmap;

    const qreal devicePixelRatio = qApp->devicePixelRatio();

    if (!qFuzzyCompare(ratio, devicePixelRatio)) {
        QImageReader reader;
        reader.setFileName(qt_findAtNxFile(path, devicePixelRatio, &ratio));
        if (reader.canRead()) {
            reader.setScaledSize(reader.size() * (devicePixelRatio / ratio));
            pixmap = QPixmap::fromImage(reader.read());
            pixmap.setDevicePixelRatio(devicePixelRatio);
        }
    } else {
        pixmap.load(path);
    }

    return pixmap;
}
예제 #20
0
QPixmap QScreen::grabWindow(WId window, int x, int y, int width, int height)
{
    const QPlatformScreen *platformScreen = handle();
    if (!platformScreen) {
        qWarning("invoked with handle==0");
        return QPixmap();
    }
    const qreal factor = QHighDpiScaling::factor(this);
    if (qFuzzyCompare(factor, 1))
        return platformScreen->grabWindow(window, x, y, width, height);

    const QPoint nativePos = QHighDpi::toNative(QPoint(x, y), factor);
    QSize nativeSize(width, height);
    if (nativeSize.isValid())
        nativeSize = QHighDpi::toNative(nativeSize, factor);
    QPixmap result =
        platformScreen->grabWindow(window, nativePos.x(), nativePos.y(),
                                   nativeSize.width(), nativeSize.height());
    result.setDevicePixelRatio(factor);
    return result;
}
예제 #21
0
AboutDialog::AboutDialog(QWidget *parent)
    :QDialog( parent)
{
ui.setupUi(this);
QPixmap pixmap;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
if (qApp->devicePixelRatio()==2)
{
pixmap.load(":/images/[email protected]");
pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
}
else pixmap.load(":/images/splash.png");
#else
pixmap.load(":/images/splash.png");
#endif
ui.label->setPixmap(pixmap);
ui.textBrowser1->setOpenExternalLinks(true);
ui.textBrowser2->setOpenExternalLinks(true);
ui.textBrowser3->setOpenExternalLinks(true);
ui.textBrowser4->setOpenExternalLinks(true);
QString head=QString::fromUtf8("<b>Texmaker ")+QLatin1String(TEXMAKERVERSION)+QString::fromUtf8("</b><br>(compiled with Qt ")+QLatin1String(QT_VERSION_STR);
#if !defined(OLDPOPPLER)
head+=QString::fromUtf8(" and Poppler ")+QLatin1String(POPPLER_VERSION);
#endif
ui.textBrowser1->setHtml(head+QString::fromUtf8(")<br><b>Copyright (c) 2003-2014 by Pascal Brachet</b><br><br>Project home site : <a href=\"http://www.xm1math.net/texmaker/\">http://www.xm1math.net/texmaker/</a><br><br><a href=\"https://github.com/gustawho/texmaker-breeze\">GitHub page for this modified version</a>"));
ui.textBrowser2->setHtml(QString::fromUtf8("<b>Copyright (c) 2003-2014 by Pascal Brachet</b><br><br>Texmaker contains code from these programs:<br>Hunspell (GPL)<br>qpdfview ((C) Adam Reichold GPL)<br>QtCreator (Copyright (C) Digia - License: GPL)<br>SyncTeX ( (C) Jerome Laurens - License: GPL)<br>Texworks ((C) Jonathan Kew - License: GPL)<br>AtD ((C) www.afterthedeadline.com - License : LGPL)<br>Tiled (Copyright  Vsevolod Klementjev - License: GPL)<br>jsdifflib ((C) Chas Emerick - license : BSD)<br>Breeze icon theme ((C) KDE Visual Design Group - License: LGPLv3)<br>"));
ui.textBrowser3->setHtml(QString::fromUtf8("<b>Thanks to these contributors :</b><br>Joël Amblard<br>Annette Klepp<br>Nguyen Duy Dien<br>Wouter Franssen<br>Patrick Wieschollek<br>Oriol González Llobet<br>Andriy Bandura<br> Merlin Raschtuttis<br>Sebastián Vanrell<br>Kleanthis Manolopoulos<br>Володимир Боденчук<br>Sandris LACIS<br>Koutheir ATTOUCHI<br>Andreas Pettersson<br>George Boumis<br>Pedro F. Silva<br>Nikolić Miroslav<br>Michele Mastropietro<br>Peter Axt<br>Torbjörn Klatt<br>Tomas Olarte Hernandez<br>Jan Jełowicki<br>Tamas Orosz<br>Adrián Yanes Martínez<br>Koen Wybo<br>Pavel Fric<br>Christian Cenker<br>Seyyed Razi Alavizadeh<br>Frederic Devernay<br>Luis Silvestre<br>Davide Alberelli<br>Ilya Barygin<br>Javier Jardón Cabezas<br>Felipe Bugno<br>Carles Gumí<br>Martin Dreher<br>Andreas Volk<br>Felix Löhr<br>Bernd Warken<br>Wolfgang Dautermann<br>Carlos Eduardo Valencia Urbina<br>Kleanthis Manolopoulos"));
QTextCodec *codec = QTextCodec::codecForName("UTF-8");
QString content;
QFile apropos(":/utilities/license_html.txt");
apropos.open(QIODevice::ReadOnly);
QTextStream in(&apropos);
in.setCodec(codec);
while (!in.atEnd()) 
	{
	content+= in.readLine()+"\n";
	}
apropos.close();
ui.textBrowser4->setHtml(content);
}
예제 #22
0
void UpdateItem::setAppInfo(const AppUpdateInfo &info)
{
    m_info = info;
    QFile file(m_info.m_icon);
    QPixmap pix;
    const qreal ratio = devicePixelRatioF();

    if (file.exists())
        pix = loadPixmap(m_info.m_icon).scaled(m_appIcon->size() * ratio,
                                               Qt::KeepAspectRatioByExpanding,
                                               Qt::SmoothTransformation);
    else {
        pix = QIcon::fromTheme(m_info.m_packageId, QIcon::fromTheme("application-x-desktop"))
                .pixmap(m_appIcon->size() * ratio)
                .scaled(m_appIcon->size() * ratio,
                        Qt::KeepAspectRatioByExpanding,
                        Qt::SmoothTransformation);
        pix.setDevicePixelRatio(ratio);
    }

    m_appIcon->setPixmap(pix);

    m_appName->setText(info.m_name.trimmed());
    m_appVersion->setText(info.m_avilableVersion.trimmed());

    const QString changelog = m_info.m_changelog;
    const QString elidedText = elidedChangelog();

    if (changelog != elidedText)
    {
        m_iconLayout->setContentsMargins(0, 10, 0, 0);
        m_appChangelog->setText(elidedText);
    } else {
        setMinimumHeight(60);
        m_iconLayout->setContentsMargins(0, 0, 0, 0);
        m_appChangelog->setText(changelog);
        m_details->setVisible(false);
    }
}
예제 #23
0
void Core::Internal::ProgressManagerPrivate::doSetApplicationLabel(const QString &text)
{
    if (!pITask)
        return;

    const HWND winId = hwndOfWidget(Core::ICore::mainWindow());
    if (text.isEmpty()) {
        pITask->SetOverlayIcon(winId, NULL, NULL);
    } else {
        QPixmap pix = Core::Icons::ERROR_TASKBAR.pixmap();
        pix.setDevicePixelRatio(1); // We want device-pixel sized font depending on the pix.height
        QPainter p(&pix);
        p.setPen(Qt::white);
        QFont font = p.font();
        font.setPixelSize(pix.height() * 0.5);
        p.setFont(font);
        p.drawText(pix.rect(), Qt::AlignCenter, text);
        const HICON icon = qt_pixmapToWinHICON(pix);
        pITask->SetOverlayIcon(winId, icon, (wchar_t*)text.utf16());
        DestroyIcon(icon);
    }
}
예제 #24
0
static QPixmap getPixmap(QTextDocument *doc, const QTextImageFormat &format, const qreal devicePixelRatio = 1.0)
{
    QPixmap pm;

    QString name = format.name();
    if (name.startsWith(QLatin1String(":/"))) // auto-detect resources and convert them to url
        name.prepend(QLatin1String("qrc"));
    QUrl url = QUrl(name);
    name = resolveFileName(name, &url, devicePixelRatio);
    const QVariant data = doc->resource(QTextDocument::ImageResource, url);
    if (data.type() == QVariant::Pixmap || data.type() == QVariant::Image) {
        pm = qvariant_cast<QPixmap>(data);
    } else if (data.type() == QVariant::ByteArray) {
        pm.loadFromData(data.toByteArray());
    }

    if (pm.isNull()) {
#if 0
        QString context;
        // ### Qt5
        QTextBrowser *browser = qobject_cast<QTextBrowser *>(doc->parent());
        if (browser)
            context = browser->source().toString();
#endif
        // try direct loading
        QImage img;
        if (name.isEmpty() || !img.load(name))
            return QPixmap(QLatin1String(":/qt-project.org/styles/commonstyle/images/file-16.png"));

        pm = QPixmap::fromImage(img);
        doc->addResource(QTextDocument::ImageResource, url, pm);
    }

    if (name.contains(QStringLiteral("@2x")))
        pm.setDevicePixelRatio(2.0);

    return pm;
}
예제 #25
0
AboutDialog::AboutDialog(QWidget *parent)
    :QDialog( parent)
{
ui.setupUi(this);
QPixmap pixmap;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
if (qApp->devicePixelRatio()==2)
{
pixmap.load(":/images/[email protected]");
pixmap.setDevicePixelRatio(qApp->devicePixelRatio());
}
else pixmap.load(":/images/splash.png");
#else
pixmap.load(":/images/splash.png");
#endif
ui.label->setPixmap(pixmap);
ui.textBrowser->setOpenExternalLinks(true);
QString head=QString::fromUtf8("<b>Texmaker ")+QLatin1String(TEXMAKERVERSION)+QString::fromUtf8("</b><br>(compiled with Qt ")+QLatin1String(QT_VERSION_STR);
#if !defined(OLDPOPPLER)
head+=QString::fromUtf8(" and Poppler ")+QLatin1String(POPPLER_VERSION);
#endif
ui.textBrowser->setHtml(head+QString::fromUtf8(")<br><b>Copyright (c) 2003-2014 by Pascal Brachet</b><br><br>Project home site : <a href=\"http://www.xm1math.net/texmaker/\">http://www.xm1math.net/texmaker/</a><br><br>This program is licensed to you under the terms of the GNU General Public License Version 2 as published by the Free Software Foundation.<br><br>Thanks to Joël Amblard, Wouter Franssen, Patrick Wieschollek, Oriol González Llobet, Andriy Bandura, Merlin Raschtuttis, Sebastián Vanrell, Kleanthis Manolopoulos, Володимир Боденчук, Sandris LACIS, Koutheir ATTOUCHI, Andreas Pettersson, George Boumis , Pedro F. Silva, Nikolić Miroslav, Michele Mastropietro, Peter Axt, Torbjörn Klatt , Tomas Olarte Hernandez , Jan Jełowicki, Tamas Orosz, Adrián Yanes Martínez, Koen Wybo, Pavel Fric, Christian Cenker, Seyyed Razi Alavizadeh, Frederic Devernay, Luis Silvestre, Davide Alberelli, Ilya Barygin, Javier Jardón Cabezas, Felipe Bugno, Carles Gumí, Martin Dreher, Andreas Volk, Felix Löhr. <br>Texmaker contains code from the Hunspell (GPL), qpdfview ((C) Adam Reichold GPL), QtCreator (Copyright (C) Nokia - Licence: GPL), SyncTeX ( (C) Jerome Laurens - Licence: GPL), Texworks ((C) Jonathan Kew - Licence: GPL), AtD ((C) www.afterthedeadline.com - Licence : LGPL), Tiled (Copyright  Vsevolod Klementjev - Licence: GPL) programs.<br>Some piece of code has been inspirated by the Ktikz ((C) Florian Hackenberger and Glad Deschrijver - Licence: GPL) and CLedit ((C) 2010 Heinz van Saanen -  Licence: GPL) programs .<br>Texmaker contains icons from the K Desktop Environment ((C) KDE ev - Licence: GPL)."));
}
예제 #26
0
파일: widget.cpp 프로젝트: weinkym/jietu
void Widget::onScreenShotPixmapChanged(const QPixmap &pixmap)
{
    QPixmap tempPixmap = pixmap;
    tempPixmap.setDevicePixelRatio(ui->labelPixmap->devicePixelRatioF());
    ui->labelPixmap->setPixmap(pixmap);
}
예제 #27
0
bool BoardTheme::loadPieces(const QString& pieces, int effect)
{
    QString effectPath;
    if(effect == Outline)
    {
        effectPath = "outline";
    }
    else if(effect == Shadow)
    {
        effectPath = "shadow";
    }

    QString themePath = AppSettings->getThemePath(effectPath, pieces);

    QPixmap big;
    if(!big.load(themePath) || big.width() < 160)
    {
        return false;
    }

    big.setDevicePixelRatio(2.0);

    int realsize = big.height() / 2;
    if(realsize == big.width() / 6)
    {
        /* Cut big theme bitmap into separate pieces */
        m_originalPiece[WhiteRook] = big.copy(0 * realsize, 0, realsize, realsize);
        m_originalPiece[WhiteKnight] = big.copy(1 * realsize, 0, realsize, realsize);
        m_originalPiece[WhiteBishop] = big.copy(2 * realsize, 0, realsize, realsize);
        m_originalPiece[WhiteQueen] = big.copy(3 * realsize, 0, realsize, realsize);
        m_originalPiece[WhiteKing] = big.copy(4 * realsize, 0, realsize, realsize);
        m_originalPiece[WhitePawn] = big.copy(5 * realsize, 0, realsize, realsize);
        m_originalPiece[BlackRook] = big.copy(0 * realsize, realsize, realsize, realsize);
        m_originalPiece[BlackKnight] = big.copy(1 * realsize, realsize, realsize, realsize);
        m_originalPiece[BlackBishop] = big.copy(2 * realsize, realsize, realsize, realsize);
        m_originalPiece[BlackQueen] = big.copy(3 * realsize, realsize, realsize, realsize);
        m_originalPiece[BlackKing] = big.copy(4 * realsize, realsize, realsize, realsize);
        m_originalPiece[BlackPawn] = big.copy(5 * realsize, realsize, realsize, realsize);
    }
    else
    {
        // Test SCID format
        realsize = big.height();
        if(realsize != big.width() / 12)
        {
            return false;
        }
        /* Cut big theme bitmap into separate pieces */
        m_originalPiece[WhitePawn] = big.copy(0 * realsize, 0, realsize, realsize);
        m_originalPiece[WhiteKnight] = big.copy(1 * realsize, 0, realsize, realsize);
        m_originalPiece[WhiteBishop] = big.copy(2 * realsize, 0, realsize, realsize);
        m_originalPiece[WhiteRook] = big.copy(3 * realsize, 0, realsize, realsize);
        m_originalPiece[WhiteQueen] = big.copy(4 * realsize, 0, realsize, realsize);
        m_originalPiece[WhiteKing] = big.copy(5 * realsize, 0, realsize, realsize);
        m_originalPiece[BlackPawn] = big.copy(6 * realsize, 0, realsize, realsize);
        m_originalPiece[BlackKnight] = big.copy(7 * realsize, 0, realsize, realsize);
        m_originalPiece[BlackBishop] = big.copy(8 * realsize, 0, realsize, realsize);
        m_originalPiece[BlackRook] = big.copy(9 * realsize, 0, realsize, realsize);
        m_originalPiece[BlackQueen] = big.copy(10 * realsize, 0, realsize, realsize);
        m_originalPiece[BlackKing] = big.copy(11 * realsize, 0, realsize, realsize);
    }

    m_pieceFilename = themePath;

    if(size().isEmpty())
    {
        setSize(QSize(realsize, realsize));
    }
    else
    {
        setSize(size());
    }
    return true;
}
예제 #28
0
QVariant GameListModel::data(const QModelIndex& index, int role) const
{
  if (!index.isValid())
    return QVariant();

  const UICommon::GameFile& game = *m_games[index.row()];

  switch (index.column())
  {
  case COL_PLATFORM:
    if (role == Qt::DecorationRole)
      return Resources::GetPlatform(game.GetPlatform());
    if (role == Qt::InitialSortOrderRole)
      return static_cast<int>(game.GetPlatform());
    break;
  case COL_COUNTRY:
    if (role == Qt::DecorationRole)
      return Resources::GetCountry(game.GetCountry());
    if (role == Qt::InitialSortOrderRole)
      return static_cast<int>(game.GetCountry());
    break;
  case COL_BANNER:
    if (role == Qt::DecorationRole)
    {
      // GameCube banners are 96x32, but Wii banners are 192x64.
      QPixmap banner = ToQPixmap(game.GetBannerImage());
      if (banner.isNull())
        banner = Resources::GetMisc(Resources::MiscID::BannerMissing);

      banner.setDevicePixelRatio(
          std::max(static_cast<qreal>(banner.width()) / GAMECUBE_BANNER_SIZE.width(),
                   static_cast<qreal>(banner.height()) / GAMECUBE_BANNER_SIZE.height()));

      return banner;
    }
    break;
  case COL_TITLE:
    if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole)
    {
      QString name = QString::fromStdString(game.GetName(m_title_database));
      const int disc_nr = game.GetDiscNumber() + 1;
      if (disc_nr > 1)
      {
        if (!name.contains(QRegExp(QStringLiteral("disc ?%1").arg(disc_nr), Qt::CaseInsensitive)))
        {
          name.append(tr(" (Disc %1)").arg(disc_nr));
        }
      }
      return name;
    }
    break;
  case COL_ID:
    if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole)
      return QString::fromStdString(game.GetGameID());
    break;
  case COL_DESCRIPTION:
    if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole)
      return QString::fromStdString(game.GetDescription());
    break;
  case COL_MAKER:
    if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole)
      return QString::fromStdString(game.GetMaker());
    break;
  case COL_FILE_NAME:
    if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole)
      return QString::fromStdString(game.GetFileName());
    break;
  case COL_SIZE:
    if (role == Qt::DisplayRole)
      return QString::fromStdString(UICommon::FormatSize(game.GetFileSize()));
    if (role == Qt::InitialSortOrderRole)
      return static_cast<quint64>(game.GetFileSize());
    break;
  case COL_TAGS:
    if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole)
    {
      auto tags = GetGameTags(game.GetFilePath());
      tags.sort();

      return tags.join(QStringLiteral(", "));
    }
  }

  return QVariant();
}
예제 #29
0
void LocationManager::onFinished(QNetworkReply *reply) {
	if (!manager) return;
	if (reply->error() != QNetworkReply::NoError) return onFailed(reply);

	QVariant statusCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
	if (statusCode.isValid()) {
		int status = statusCode.toInt();
		if (status == 301 || status == 302) {
			QString loc = reply->header(QNetworkRequest::LocationHeader).toString();
			if (!loc.isEmpty()) {
				QMap<QNetworkReply*, LocationData*>::iterator i = dataLoadings.find(reply);
				if (i != dataLoadings.cend()) {
					LocationData *d = i.value();
					if (serverRedirects.constFind(d) == serverRedirects.cend()) {
						serverRedirects.insert(d, 1);
					} else if (++serverRedirects[d] > MaxHttpRedirects) {
						DEBUG_LOG(("Network Error: Too many HTTP redirects in onFinished() for image link: %1").arg(loc));
						return onFailed(reply);
					}
					dataLoadings.erase(i);
					dataLoadings.insert(manager->get(QNetworkRequest(loc)), d);
					return;
				} else if ((i = imageLoadings.find(reply)) != imageLoadings.cend()) {
					LocationData *d = i.value();
					if (serverRedirects.constFind(d) == serverRedirects.cend()) {
						serverRedirects.insert(d, 1);
					} else if (++serverRedirects[d] > MaxHttpRedirects) {
						DEBUG_LOG(("Network Error: Too many HTTP redirects in onFinished() for image link: %1").arg(loc));
						return onFailed(reply);
					}
					imageLoadings.erase(i);
					imageLoadings.insert(manager->get(QNetworkRequest(loc)), d);
					return;
				}
			}
		}
		if (status != 200) {
			DEBUG_LOG(("Network Error: Bad HTTP status received in onFinished() for image link: %1").arg(status));
			return onFailed(reply);
		}
	}

	LocationData *d = 0;
	QMap<QNetworkReply*, LocationData*>::iterator i = dataLoadings.find(reply);
	if (i != dataLoadings.cend()) {
		d = i.value();
		dataLoadings.erase(i);

		QJsonParseError e;
		QJsonDocument doc = QJsonDocument::fromJson(reply->readAll(), &e);
		if (e.error != QJsonParseError::NoError) {
			DEBUG_LOG(("JSON Error: Bad json received in onFinished() for image link"));
			return onFailed(reply);
		}
		failed(d);

		if (App::main()) App::main()->update();
	} else {
		i = imageLoadings.find(reply);
		if (i != imageLoadings.cend()) {
			d = i.value();
			imageLoadings.erase(i);

			QPixmap thumb;
			QByteArray format;
			QByteArray data(reply->readAll());
			{
				QBuffer buffer(&data);
				QImageReader reader(&buffer);
#ifndef OS_MAC_OLD
				reader.setAutoTransform(true);
#endif // OS_MAC_OLD
				thumb = QPixmap::fromImageReader(&reader, Qt::ColorOnly);
				format = reader.format();
				thumb.setDevicePixelRatio(cRetinaFactor());
				if (format.isEmpty()) format = QByteArray("JPG");
			}
			d->loading = false;
			d->thumb = thumb.isNull() ? (*notLoadedPlaceholder) : ImagePtr(thumb, format);
			serverRedirects.remove(d);
			if (App::main()) App::main()->update();
		}
	}
}
예제 #30
0
QVariant GameListModel::data(const QModelIndex& index, int role) const
{
  if (!index.isValid())
    return QVariant();

  const UICommon::GameFile& game = *m_games[index.row()];

  switch (index.column())
  {
  case COL_PLATFORM:
    if (role == Qt::DecorationRole)
      return Resources::GetPlatform(static_cast<int>(game.GetPlatform()));
    if (role == Qt::InitialSortOrderRole)
      return static_cast<int>(game.GetPlatform());
    break;
  case COL_COUNTRY:
    if (role == Qt::DecorationRole)
      return Resources::GetCountry(static_cast<int>(game.GetCountry()));
    if (role == Qt::InitialSortOrderRole)
      return static_cast<int>(game.GetCountry());
    break;
  case COL_BANNER:
    if (role == Qt::DecorationRole)
    {
      // GameCube banners are 96x32, but Wii banners are 192x64.
      QPixmap banner = ToQPixmap(game.GetBannerImage());
      if (banner.isNull())
        banner = Resources::GetMisc(Resources::BANNER_MISSING);

      banner.setDevicePixelRatio(
          std::max(static_cast<qreal>(banner.width()) / GAMECUBE_BANNER_SIZE.width(),
                   static_cast<qreal>(banner.height()) / GAMECUBE_BANNER_SIZE.height()));

      return banner;
    }
    break;
  case COL_TITLE:
    if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole)
      return QString::fromStdString(game.GetName());
    break;
  case COL_ID:
    if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole)
      return QString::fromStdString(game.GetGameID());
    break;
  case COL_DESCRIPTION:
    if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole)
      return QString::fromStdString(game.GetDescription());
    break;
  case COL_MAKER:
    if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole)
      return QString::fromStdString(game.GetMaker());
    break;
  case COL_FILE_NAME:
    if (role == Qt::DisplayRole || role == Qt::InitialSortOrderRole)
      return QString::fromStdString(game.GetFileName());
    break;
  case COL_SIZE:
    if (role == Qt::DisplayRole)
      return QString::fromStdString(UICommon::FormatSize(game.GetFileSize()));
    if (role == Qt::InitialSortOrderRole)
      return static_cast<quint64>(game.GetFileSize());
    break;
  }

  return QVariant();
}