Example #1
0
    QPixmap GlobalImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
    {
        QPixmap image(id);
        QPixmap result;

        if (requestedSize.isValid()) {
            result = image.scaled(requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        }
        else {
            result = image;
        }

        *size = result.size();
        return result;
    }
QPixmap ItemLibraryImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
{
    QPixmap pixmap(id);
    if (size) {
        size->setWidth(pixmap.width());
        size->setHeight(pixmap.height());
    }

    if (pixmap.isNull())
        return pixmap;

    if (requestedSize.isValid())
        return pixmap.scaled(requestedSize);
    return pixmap;
}
/******************************************************************************
* Return the maximum minimum size for any instance.
*/
QSize StackedScrollGroup::maxMinimumSizeHint() const
{
    QSize sz;
    for (int i = 0, count = mWidgets.count();  i < count;  ++i)
    {
        QWidget* w = static_cast<StackedScrollWidget*>(mWidgets[i])->widget();
        if (!w)
            return QSize();
        QSize s = w->minimumSizeHint();
        if (!s.isValid())
            return QSize();
        sz = sz.expandedTo(s);
    }
    return sz;
}
Example #4
0
void KNHelper::restoreWindowSize(const QString &name, QWidget *d, const QSize &defaultSize)
{
    KConfig *c = knGlobals.config();
    c->setGroup("WINDOW_SIZES");

    QSize s = c->readSizeEntry(name, &defaultSize);

    if(s.isValid())
    {
        QRect max = KGlobalSettings::desktopGeometry(QCursor::pos());
        if(s.width() > max.width()) s.setWidth(max.width() - 5);
        if(s.height() > max.height()) s.setHeight(max.height() - 5);
        d->resize(s);
    }
}
Example #5
0
bool ConverterWizard::validatePage()
{
	QImageReader reader(m_heightMap->text());
	if ( !reader.canRead() )
		QMessageBox::warning(this, tr("Error"), tr("Can not read heightmap %1 !\n%2").arg(m_heightMap->text()).arg(reader.errorString()));
	else
	{
		QSize size = reader.size();
		if (size.isValid() && ( size.width() != size.height() || ( ( size.width() & ( size.width() - 1 ) ) != 0 ) ) )
			QMessageBox::warning(this, tr("Error"), tr("The heightmap must have equal width and height and the side length must be a power of two! e.g. 1024x1024"));
		else
			return true;
	}
	return false;
}
static inline QSize qwtScreenResolution()
{
    static QSize screenResolution;
    if ( !screenResolution.isValid() )
    {
        QDesktopWidget *desktop = QApplication::desktop();
        if ( desktop )
        {
            screenResolution.setWidth( desktop->logicalDpiX() );
            screenResolution.setHeight( desktop->logicalDpiY() );
        }
    }

    return screenResolution;
}
Example #7
0
QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& contents, const QSize& size) const
{
#ifdef QTWEBKIT
    QWebView webView;
    QPalette pal = webView.palette();
    pal.setColor(QPalette::Background, Qt::transparent);
    webView.setPalette(pal);
    webView.setContent(contents, QString::fromAscii("image/svg+xml"));
    QString node = QString::fromAscii("document.rootElement.nodeName");
    QString root = webView.page()->mainFrame()->evaluateJavaScript(node).toString();
    if (root.isEmpty() || root.compare(QLatin1String("svg"), Qt::CaseInsensitive)) {
        return QPixmap();
    }

    QString w = QString::fromAscii("document.rootElement.width.baseVal.value");
    QString h = QString::fromAscii("document.rootElement.height.baseVal.value");
    double ww = webView.page()->mainFrame()->evaluateJavaScript(w).toDouble();
    double hh = webView.page()->mainFrame()->evaluateJavaScript(h).toDouble();
    if (ww == 0.0 || hh == 0.0)
        return QPixmap();
#endif

    QImage image(size, QImage::Format_ARGB32_Premultiplied);
    image.fill(0x00000000);

    QPainter p(&image);
#ifdef QTWEBKIT
    qreal xs = size.isValid() ? size.width() / ww : 1.0;
    qreal ys = size.isValid() ? size.height() / hh : 1.0;
    p.scale(xs, ys);

    // the best quality
    p.setRenderHint(QPainter::Antialiasing);
    p.setRenderHint(QPainter::TextAntialiasing);
    p.setRenderHint(QPainter::SmoothPixmapTransform);
    p.setOpacity(0); // important to keep transparent background
    webView.page()->mainFrame()->render(&p);
#else
    // tmp. disable the report window to suppress some bothering warnings
    Base::Console().SetEnabledMsgType("ReportOutput", ConsoleMsgType::MsgType_Wrn, false);
    QSvgRenderer svg(contents);
    Base::Console().SetEnabledMsgType("ReportOutput", ConsoleMsgType::MsgType_Wrn, true);
    svg.render(&p);
#endif
    p.end();

    return QPixmap::fromImage(image);
}
/*!
  Render the SVG data

  \param painter Painter
  \param viewBox View Box, see QSvgRenderer::viewBox
  \param rect Traget rectangle on the paint device
*/
void QwtPlotSvgItem::render(QPainter *painter,
        const QRect &viewBox, const QRect &rect) const
{
    if ( !viewBox.isValid() )
        return;

#if QT_VERSION >= 0x040100
    const QSize paintSize(painter->window().width(),
        painter->window().height());
    if ( !paintSize.isValid() )
        return;

    const double xRatio =
        double(paintSize.width()) / viewBox.width();
    const double yRatio =
        double(paintSize.height()) / viewBox.height();

    const double dx = rect.left() / xRatio + 1.0;
    const double dy = rect.top() / yRatio + 1.0;

    const double mx = double(rect.width()) / paintSize.width();
    const double my = double(rect.height()) / paintSize.height();

    painter->save();

    painter->translate(dx, dy);
    painter->scale(mx, my);

    d_data->renderer.setViewBox(viewBox);
    d_data->renderer.render(painter);

    painter->restore();
#else
    const double mx = double(rect.width()) / viewBox.width();
    const double my = double(rect.height()) / viewBox.height();
    const double dx = rect.x() - mx * viewBox.x();
    const double dy = rect.y() - my * viewBox.y();

    painter->save();

    painter->translate(dx, dy);
    painter->scale(mx, my);
    
    d_data->picture.play(painter);

    painter->restore();
#endif
}
Example #9
0
void XMainWindow::showEvent(QShowEvent *event)
{
  if(!_private->_shown)
  {
    _private->_shown = true;
//qDebug("isModal() %s", isModal()?"true":"false");

    QRect availableGeometry = QApplication::desktop()->availableGeometry();
    if(!omfgThis->showTopLevel() && !isModal())
      availableGeometry = omfgThis->workspace()->geometry();

    QString objName = objectName();
    QPoint pos = xtsettingsValue(objName + "/geometry/pos").toPoint();
    QSize lsize = xtsettingsValue(objName + "/geometry/size").toSize();

    if(lsize.isValid() && xtsettingsValue(objName + "/geometry/rememberSize", true).toBool() && (metaObject()->className() != QString("xTupleDesigner")))
      resize(lsize);

    setAttribute(Qt::WA_DeleteOnClose);
    if(omfgThis->showTopLevel() || isModal())
    {
      omfgThis->_windowList.append(this);
      statusBar()->show();
      QRect r(pos, size());
      if(!pos.isNull() && availableGeometry.contains(r) && xtsettingsValue(objName + "/geometry/rememberPos", true).toBool())
        move(pos);
    }
    else
    {
      QWidget * fw = focusWidget();
      omfgThis->workspace()->addWindow(this);
      QRect r(pos, size());
      if(!pos.isNull() && availableGeometry.contains(r) && xtsettingsValue(objName + "/geometry/rememberPos", true).toBool())
        move(pos);
      // This originally had to be after the show? Will it work here?
      if(fw)
        fw->setFocus();
    }

    loadScriptEngine();
  }

  bool blocked = _private->_action->blockSignals(true);
  _private->_action->setChecked(true);
  _private->_action->blockSignals(blocked);

  QMainWindow::showEvent(event);
}
Example #10
0
void QuickEdit::Show(BrowserNode * node)
{
    //first, we need to determine the type of currently selected item
    // if we cannot open window for such node type - do nothing
    rootInterface->removeChildren(0, rootInterface->childCount());
    localNodeHolder.clear();
    if(!node)
        return;
    UmlCode nodeType = node->get_type();
    if(!validTypes.contains(nodeType))
        return;
    //next we need to recursively create items for node
    if(!itemCreators.contains(nodeType))
        return;
    itemCreators[nodeType](rootInterface, node);
    // we then assign items and all is ok
    treeModel->InsertRootItem(rootInterface);

    std::function<bool(TreeItemInterface*)> check = [&](TreeItemInterface* )
    {
       return true;
    };

    TreeFunctions::ExpandAllSatisfying<TreeItemInterface>(check, ui->tvEditor, treeModel, QModelIndex());
    QSettings settings(QSettings::IniFormat, QSettings::UserScope, "DoUML", "settings");
    settings.setIniCodec(QTextCodec::codecForName("UTF-8"));
    QByteArray arr = settings.value("headers/quickedit", QByteArray()).toByteArray();
    if(!arr.isNull())
        ui->tvEditor->header()->restoreState(arr);

    ui->chkCpp->setChecked(settings.value("quickedit_checkboxes/cpp",true).toBool());
    ui->chkJava->setChecked(settings.value("quickedit_checkboxes/java", true).toBool());
    ui->chkPhp->setChecked(settings.value("quickedit_checkboxes/php",true).toBool());
    ui->chkPython->setChecked(settings.value("quickedit_checkboxes/python", true).toBool());
    ui->chkIdl->setChecked(settings.value("quickedit_checkboxes/idl", true).toBool());
    QSize size = settings.value("window/size", QSize()).toSize();

    CheckColumnVisibility();
    if(!size.isValid())
        this->showMaximized();
    else
    {
        this->resize(size);
        this->show();
    }


}
Example #11
0
void QCamFrameCommon::setSize(QSize s) {
   assert(nbRef_<=1);
   if (!s.isValid()) {
      return;
   }
   /* need multiple of 4 */
   int x=s.width();
   int y=s.height();
   if (x%4) {x+=(4-x%4);}
   if (y%4) {y+=(4-y%4);}
   s=QSize(x,y);
   if (size_ != s) {
      size_=s;
      allocBuff();
   }
}
Example #12
0
QImage QtImageProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize)
{
	if (size != nullptr)
	{
		*size = requestedSize;
	}

	auto key = id.toLongLong();
	auto it = imageCache_.find(key);
	if (it == imageCache_.end())
	{
		return QImage(requestedSize.width(), requestedSize.height(), QImage::Format_ARGB32);
	}

	return requestedSize.isValid() ? it.value().scaled(requestedSize) : it.value();
}
    QSize PagerPrivate::clampedBoundingBox(bool ignoreScrollBars)
    {
        QSize requestedSize = pager->boundingBox();
        int maxHeight = pager->height() - marginTop - marginBottom - (drawLabels ? 12 : 0);
        if (!ignoreScrollBars && orientation == Qt::Horizontal && scrollBar->isVisible()) { maxHeight -= scrollBar->height(); }
        int maxWidth = pager->width() - marginLeft - marginRight;
        if (!ignoreScrollBars && orientation == Qt::Vertical && scrollBar->isVisible()) { maxWidth -= scrollBar->width(); }

        if (!requestedSize.isValid())
        {
            requestedSize = QSize(1, 1);
        }

        requestedSize.scale(maxWidth, maxHeight, Qt::KeepAspectRatio);
        return requestedSize;
    }
Example #14
0
// really generate the background pixmap according to current settings and apply it.
void DesktopWindow::updateWallpaper() {
    if(wallpaperMode_ != WallpaperNone) {  // use wallpaper
        QPixmap pixmap;
        QImage image;
        if(wallpaperMode_ == WallpaperTile) { // use the original size
            image = QImage(wallpaperFile_);
            // Note: We can't use the QPainter::drawTiledPixmap(), because it doesn't tile
            // correctly for background pixmaps bigger than the current screen size.
            const QSize s = size();
            pixmap = QPixmap{s};
            QPainter painter{&pixmap};
            for (int x = 0; x < s.width(); x += image.width()) {
                for (int y = 0; y < s.height(); y += image.height()) {
                    painter.drawImage(x, y, image);
                }
            }
        }
        else if(wallpaperMode_ == WallpaperStretch) {
            image = loadWallpaperFile(size());
            pixmap = QPixmap::fromImage(image);
        }
        else { // WallpaperCenter || WallpaperFit
            if(wallpaperMode_ == WallpaperCenter) {
                image = QImage(wallpaperFile_); // load original image
            }
            else if(wallpaperMode_ == WallpaperFit || wallpaperMode_ == WallpaperZoom) {
                // calculate the desired size
                QSize origSize = QImageReader(wallpaperFile_).size(); // get the size of the original file
                if(origSize.isValid()) {
                    QSize desiredSize = origSize;
                    Qt::AspectRatioMode mode = (wallpaperMode_ == WallpaperFit ? Qt::KeepAspectRatio : Qt::KeepAspectRatioByExpanding);
                    desiredSize.scale(width(), height(), mode);
                    image = loadWallpaperFile(desiredSize); // load the scaled image
                }
            }
            if(!image.isNull()) {
                pixmap = QPixmap(size());
                QPainter painter(&pixmap);
                pixmap.fill(bgColor_);
                int x = (width() - image.width()) / 2;
                int y = (height() - image.height()) / 2;
                painter.drawImage(x, y, image);
            }
        }
        wallpaperPixmap_ = pixmap;
    }
}
QImage WindowImageProvider::requestImage(const QString &id,
                                              QSize *size,
                                              const QSize &requestedSize)
{
    /* Throw away the part of the id after the @ (if any) since it's just a timestamp
       added to force the QML image cache to request to this image provider
       a new image instead of re-using the old. See SpreadWindow.qml for more
       details on the problem. */
    int atPos = id.indexOf('@');
    QString windowIds = (atPos == -1) ? id : id.left(atPos);

    /* After doing this, split the rest of the id on the character "|". The first
       part is the window ID of the decorations, the latter of the actual content. */
    atPos = windowIds.indexOf('|');
    Window frameId = ((atPos == -1) ? windowIds : windowIds.left(atPos)).toULong();
    Window contentId = ((atPos == -1) ? windowIds : windowIds.mid(atPos + 1)).toULong();

    /* Use form image://window/root to specify you want an image of the root window */
    if (atPos == -1 && windowIds == "root") {
        frameId = QX11Info::appRootWindow();
    }

    QImage image;
    QPixmap pixmap = getWindowPixmap(frameId, contentId);
    if (!pixmap.isNull()) {
        image = convertWindowPixmap(pixmap, frameId);
        if (image.isNull()) {
            /* This means that the window got unmapped while we were converting it to
               an image. Try again so that we will pick up the pixmap captured by
               metacity instead. */
            pixmap = getWindowPixmap(frameId, contentId);
            if (!pixmap.isNull()) {
                image = convertWindowPixmap(pixmap, frameId);
            }
        }
    }

    if (!image.isNull()) {
        if (requestedSize.isValid()) {
            image = image.scaled(requestedSize);
        }
        size->setWidth(image.width());
        size->setHeight(image.height());
    }

    return image;
}
Example #16
0
void XWidget::showEvent(QShowEvent *event)
{
  if(!_private->_shown)
  {
    _private->_shown = true;
    if (windowFlags() & (Qt::Window | Qt::Dialog))
    {
      QRect availableGeometry = QApplication::desktop()->availableGeometry();
      if(!omfgThis->showTopLevel() && !isModal())
        availableGeometry = QRect(QPoint(0, 0), omfgThis->workspace()->size());

      QString objName = objectName();
      QPoint pos = xtsettingsValue(objName + "/geometry/pos").toPoint();
      QSize lsize = xtsettingsValue(objName + "/geometry/size").toSize();

      if(lsize.isValid() && xtsettingsValue(objName + "/geometry/rememberSize", true).toBool())
        resize(lsize);

      setAttribute(Qt::WA_DeleteOnClose);
      if(omfgThis->showTopLevel() || isModal())
      {
        omfgThis->_windowList.append(this);
        QRect r(pos, size());
        if(!pos.isNull() && availableGeometry.contains(r) && xtsettingsValue(objName + "/geometry/rememberPos", true).toBool())
          move(pos);
      }
      else
      {
        QWidget * fw = focusWidget();
        omfgThis->workspace()->addWindow(this);
        QRect r(pos, size());
        if(!pos.isNull() && availableGeometry.contains(r) && xtsettingsValue(objName + "/geometry/rememberPos", true).toBool() && parentWidget())
          parentWidget()->move(pos);
        // This originally had to be after the show? Will it work here?
        if(fw)
          fw->setFocus();
      }
    }

    loadScriptEngine();

    QList<XCheckBox*> allxcb = findChildren<XCheckBox*>();
    for (int i = 0; i < allxcb.size(); ++i)
      allxcb.at(i)->init();
  }
  QWidget::showEvent(event);
}
Example #17
0
void QWaylandEglWindow::newSurfaceCreated()
{
    if (mWaylandEglWindow) {
        wl_egl_window_destroy(mWaylandEglWindow);
    }
    wl_visual *visual = QWaylandScreen::waylandScreenFromWidget(widget())->visual();
    QSize size = geometry().size();
    if (!size.isValid())
        size = QSize(0,0);

    mWaylandEglWindow = wl_egl_window_create(mSurface,size.width(),size.height(),visual);
    if (mGLContext) {
        EGLNativeWindowType window(reinterpret_cast<EGLNativeWindowType>(mWaylandEglWindow));
        EGLSurface surface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mGLContext->eglConfig(),window,NULL);
        mGLContext->setEglSurface(surface);
    }
}
Example #18
0
QSize WidgetStack::minimumSizeHint() const
      {
      if (top == -1)
            return (QSize(0, 0));

      QSize s(0,0);
      for (unsigned int i = 0; i < stack.size(); ++i) {
            if (stack[i]) {
                  QSize ss = stack[i]->minimumSizeHint();
                  if (!ss.isValid())
                        ss = stack[i]->minimumSize();
                  s = s.expandedTo(ss);
                  }
            }

      return s;
      }
Example #19
0
void LayerWidget::setRectSize(QSize size)
{
    _rect = QRect(QPoint(0, 0), size);
    if(!size.isValid())
    {
        _scene->removeItem(_rectItem);
        _rectItem = NULL;
        return;
    }
    if(!_rectItem)
    {
        _rectItem = _scene->addRect(0, 0, size.width(), size.height(), QPen(Qt::red, 0)); // pen with 0 penWidth to ignore penWidth transorm
        _rectItem->setZValue(-1);
    }
    else
        _rectItem->setRect(0, 0, size.width(), size.height());
}
Example #20
0
    QImage GlobalImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
    {
        QImage image(id);
        QImage result;

        if (requestedSize.isValid()) {
            result = image.scaled(requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        }
        else {
            result = image;
        }

        const QSize &originalSize = image.size();
        m_OriginalSizes.insert(id, QSize(originalSize.width(), originalSize.height()));

        *size = result.size();
        return result;
    }
Example #21
0
 // This is run in a low priority thread.
 QImage request(const QString &id, QSize *size, const QSize &req_size)
 {
     if (size) *size = QSize(100,50);
     QImage image(
             req_size.width() > 0 ? req_size.width() : 100,
             req_size.height() > 0 ? req_size.height() : 50,
             QImage::Format_RGB32);
     image.fill(QColor(id).rgba());
     QPainter p(&image);
     QFont f = p.font();
     f.setPixelSize(30);
     p.setFont(f);
     p.setPen(Qt::black);
     if (req_size.isValid())
         p.scale(req_size.width()/100.0, req_size.height()/50.0);
     p.drawText(QRectF(0,0,100,50),Qt::AlignCenter,id);
     return image;
 }
void ItemViewImageDelegate::drawAspectRatio(QPainter* p, const QRect& dimsRect, const QSize& dims) const
{
    Q_D(const ItemViewImageDelegate);

    p->setFont(d->fontXtra);
    QString resolution;

    if (dims.isValid())
    {
        ImagePropertiesTab::aspectRatioToString(dims.width(), dims.height(), resolution);
    }
    else
    {
        resolution = i18nc("unknown image resolution", "Unknown");
    }

    p->drawText(dimsRect, Qt::AlignCenter, resolution); //squeezedTextCached(p, dimsRect.width(), resolution));
}
Example #23
0
/*!
    \reimp
*/
QSize QSplitter::sizeHint() const
{
    Q_D(const QSplitter);
    ensurePolished();
    int l = 0;
    int t = 0;
    for (int i = 0; i < d->list.size(); ++i) {
        QWidget *w = d->list.at(i)->widget;
        if (w->isHidden())
            continue;
        QSize s = w->sizeHint();
        if (s.isValid()) {
            l += d->pick(s);
            t = qMax(t, d->trans(s));
        }
    }
    return orientation() == Qt::Horizontal ? QSize(l, t) : QSize(t, l);
}
Example #24
0
int QSplitterLayoutStruct::getWidgetSize(Qt::Orientation orient)
{
    if (sizer == -1) {
        QSize s = widget->sizeHint();
        const int presizer = pick(s, orient);
        const int realsize = pick(widget->size(), orient);
        if (!s.isValid() || (widget->testAttribute(Qt::WA_Resized) && (realsize > presizer))) {
            sizer = pick(widget->size(), orient);
        } else {
            sizer = presizer;
        }
        QSizePolicy p = widget->sizePolicy();
        int sf = (orient == Qt::Horizontal) ? p.horizontalStretch() : p.verticalStretch();
        if (sf > 1)
            sizer *= sf;
    }
    return sizer;
}
Example #25
0
void ConverterWizard::setHeightMap()
{
	QString filter = tr("Image files (");
	QList<QByteArray> formats = QImageReader::supportedImageFormats();
	foreach(QByteArray format, formats)
		filter += "*." + QString(format)+" ";
	filter+= ")";	
	filter+= tr(";;All files (*.*)");
	QString fileName = QFileDialog::getOpenFileName(this, tr("Select heightmap"), QDir::currentPath(), filter);
	if (fileName.isEmpty())
		return;
	QImageReader reader(fileName);
	QSize size = reader.size();
	if (size.isValid() && ( size.width() != size.height() || ( ( size.width() & ( size.width() - 1 ) ) != 0 ) ) )
		QMessageBox::warning(this, tr("Error"), tr("The heightmap must have equal width and height and the side length must be a power of two! e.g. 1024x1024"));
	else
		m_heightMap->setText(fileName);
}
Example #26
0
bool FormStreamingImp::initialize(const QSize &max_size)
{
   int w=640;
   int h=480;

   if( current_webcam->open_device() < 0 )
     return false;
   if( max_size.isValid() )
     {
	w = max_size.width();
	h = max_size.height();
     }
   qDebug("Inititating with %dx%d\n",w,h);
   if( current_webcam->init_device(w,h) == false )
     return false;

   return true;
}
Example #27
0
void QPixmapIconEngine::addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state)
{
    if (fileName.isEmpty())
        return;
    const QString abs = fileName.startsWith(QLatin1Char(':')) ? fileName : QFileInfo(fileName).absoluteFilePath();
    const bool ignoreSize = !size.isValid();
    ImageReader imageReader(abs);
    const QByteArray format = imageReader.format();
    if (format.isEmpty()) // Device failed to open or unsupported format.
        return;
    QImage image;
    if (format != "ico") {
        if (ignoreSize) { // No size specified: Add all images.
            while (imageReader.read(&image))
                pixmaps += QPixmapIconEngineEntry(abs, image, mode, state);
        } else {
            // Try to match size. If that fails, add a placeholder with the filename and empty pixmap for the size.
            while (imageReader.read(&image) && image.size() != size) {}
            pixmaps += image.size() == size ?
                QPixmapIconEngineEntry(abs, image, mode, state) : QPixmapIconEngineEntry(abs, size, mode, state);
        }
        return;
    }
    // Special case for reading Windows ".ico" files. Historically (QTBUG-39287),
    // these files may contain low-resolution images. As this information is lost,
    // ICOReader sets the original format as an image text key value. Read all matching
    // images into a list trying to find the highest quality per size.
    QList<QImage> icoImages;
    while (imageReader.read(&image)) {
        if (ignoreSize || image.size() == size) {
            const int position = findBySize(icoImages, image.size());
            if (position >= 0) { // Higher quality available? -> replace.
                if (origIcoDepth(image) > origIcoDepth(icoImages.at(position)))
                    icoImages[position] = image;
            } else {
                icoImages.append(image);
            }
        }
    }
    foreach (const QImage &i, icoImages)
        pixmaps += QPixmapIconEngineEntry(abs, i, mode, state);
    if (icoImages.isEmpty() && !ignoreSize) // Add placeholder with the filename and empty pixmap for the size.
        pixmaps += QPixmapIconEngineEntry(abs, size, mode, state);
}
Example #28
0
    QSize sizeHint() const {
        int f = 2 * frameWidth();
        QSize sz(f, f);
        int h = fontMetrics().height();

        if (widget()) {
             if (!widgetSize.isValid())
                 widgetSize = widgetResizable() ? widget()->sizeHint() : widget()->size();
             sz += widgetSize;
         } else {
             sz += QSize(12 * h, 8 * h);
         }
         if (verticalScrollBarPolicy() == Qt::ScrollBarAlwaysOn)
             sz.setWidth(sz.width() + verticalScrollBar()->sizeHint().width());
         if (horizontalScrollBarPolicy() == Qt::ScrollBarAlwaysOn)
             sz.setHeight(sz.height() + horizontalScrollBar()->sizeHint().height());

         return sz; // .boundedTo(QSize(36 * h, 24 * h));
    }
Example #29
0
void CGifItem::init(const QString& fileName,const QSize& size,bool bClip )
{
	m_oImageList.clear();
	m_nCurrFrame = 0;
	m_nTimerID = 0;
	m_fileName = fileName;
	QSize tmp(0,0);
	m_fileSize = tmp;
	m_bClip = bClip;

	if (size.isValid())
	{
		m_fileSize = size;
	}

	setFlags(ItemIsSelectable | ItemIsFocusable);
	LoadPixmap();

}
/*!
  Creates a \<a\> link tag of the given \a text using a given URL
  \a url in a popup window  with the name \a windowName.
*/
QString TViewHelper::linkToPopup(const QString &text, const QUrl &url, const QString &windowName,
                                 const QSize &size, const QPoint &topLeft, const QString &windowStyle,
                                 const QString &jsCondition, const THtmlAttribute &attributes) const
{
    QString string("<a href=\"");
    string.append(url.toString()).append("\"");

    string += " onclick=\"";
    if (!jsCondition.isEmpty()) {
        string.append("if (").append(jsCondition).append(") { ");
    }

    string += "window.open(this.href";
    if (!windowName.isEmpty()) {
        string.append(", '").append(windowName).append("'");
    }

    string += ", '";
    if (size.isValid()) {
        string.append("width=").append(QString::number(size.width())).append(",height=").append(QString::number(size.height()));
    }

    if (!topLeft.isNull()) {
        if (string.right(1) != "'")
            string += ",";
        string.append("top=").append(QString::number(topLeft.x())).append(",left=").append(QString::number(topLeft.y()));
    }

    if (!windowStyle.isEmpty()) {
        if (string.right(1) != "'")
            string += ",";
        string += windowStyle;
    }
    string += "');";

    if (!jsCondition.isEmpty()) {
        string += " }";
    }
    string += " return false;\"";

    string.append(attributes.toString()).append(">").append(text).append("</a>");
    return string;
}