Exemplo n.º 1
0
const QIcon &QgsLayerItem::iconPolygon()
{
    static QIcon icon;

    if ( icon.isNull() )
        icon = QgsApplication::getThemeIcon( "/mIconPolygonLayer.svg" );

    return icon;
}
Exemplo n.º 2
0
QIcon LWinInfo::icon(bool &noicon){
  if(window==0){ noicon = true; return QIcon();}
  noicon = false;
  QIcon ico = LSession::handle()->XCB->WindowIcon(window);
  //Check for a null icon, and supply one if necessary
  if(ico.isNull()){ ico = LXDG::findIcon( this->Class().toLower(),""); }
  if(ico.isNull()){ico = LXDG::findIcon("preferences-system-windows",""); noicon=true;}
  return ico;
}
Exemplo n.º 3
0
QIcon IconUtils::icon(const QString &name) {
#if defined(APP_MAC) || defined(APP_WIN)
    return fromResources(name);
#else
    QIcon icon = fromTheme(name);
    if (icon.isNull()) icon = fromResources(name);
    return icon;
#endif
}
Exemplo n.º 4
0
QIcon BrowserApplication::icon(const QUrl &url) const
{
    QIcon icon = QWebSettings::iconForUrl(url);
    if (!icon.isNull())
        return icon.pixmap(16, 16);
    if (m_defaultIcon.isNull())
        m_defaultIcon = QIcon(QLatin1String(":defaulticon.png"));
    return m_defaultIcon.pixmap(16, 16);
}
Exemplo n.º 5
0
const QIcon &QgsLayerItem::iconTable()
{
    static QIcon icon;

    if ( icon.isNull() )
        icon = QgsApplication::getThemeIcon( "/mIconTableLayer.png" );

    return icon;
}
Exemplo n.º 6
0
QIcon IconUtils::fromResources(const QString &name) {
    QIcon icon = QIcon(QString(":/images/%1.png").arg(name));
    if (!icon.isNull()) {
        icon.addPixmap(QString(":/images/%1_active.png").arg(name), QIcon::Active);
        icon.addPixmap(QString(":/images/%1_selected.png").arg(name), QIcon::Selected);
        icon.addPixmap(QString(":/images/%1_disabled.png").arg(name), QIcon::Disabled);
    }
    return icon;
}
Exemplo n.º 7
0
const QIcon &QgsDataCollectionItem::iconDataCollection()
{
  static QIcon icon;

  if ( icon.isNull() )
    icon = QgsApplication::getThemeIcon( "/mIconDbSchema.png" );

  return icon;
}
Exemplo n.º 8
0
QIcon LXDG::findMimeIcon(QString extension){
  QIcon ico;
  QString mime = LXDG::findAppMimeForFile(extension);
  if(mime.isEmpty()){ mime = LXDG::findAppMimeForFile(extension.toLower()); }
  mime.replace("/","-"); //translate to icon mime name
  if(!mime.isEmpty()){ ico = LXDG::findIcon(mime, "unknown");} //use the "unknown" mimetype icon as fallback	
  if(ico.isNull()){ ico = LXDG::findIcon("unknown",""); } //just in case
  return ico;
}
Exemplo n.º 9
0
const QIcon &QgsFavouritesItem::iconFavourites()
{
  static QIcon icon;

  if ( icon.isNull() )
    icon = QgsApplication::getThemeIcon( "/mIconFavourites.png" );

  return icon;
}
Exemplo n.º 10
0
const QIcon &QgsLayerItem::iconDefault()
{
  static QIcon icon;

  if ( icon.isNull() )
    icon = QIcon( getThemePixmap( "/mIconLayer.png" ) );

  return icon;
}
Exemplo n.º 11
0
const QIcon &QgsFavouritesItem::iconFavourites()
{
  static QIcon icon;

  if ( icon.isNull() )
    icon = QIcon( getThemePixmap( "/mIconFavourites.png" ) );

  return icon;
}
Exemplo n.º 12
0
const QIcon &QgsDataCollectionItem::iconDataCollection()
{
  static QIcon icon;

  if ( icon.isNull() )
    icon = QIcon( getThemePixmap( "/mIconDbSchema.png" ) );

  return icon;
}
QVariant SpellingMistakesModel::data( const QModelIndex& index, int role ) const
{
  const int column = index.column();
  const int row    = index.row();
  /* The decoration role on the Literal column is a check icon. */
  if( ( role == Qt::DecorationRole )
      && ( column == Constants::MISTAKE_COLUMN_LITERAL ) ) {
    /* Display the icon if the word is a string literal. */
    Word currentWord = d->wordList.at( row );
    if( currentWord.inComment == false ) {
      /* Create and store the icon in a static QIcon variable. It is made
       * static so that there is no need to construct the icon on each
       * call to this code. The downside is that it might need an IDE restart
       * if the theme changes and the resulting icon changed. */
      static const QIcon icon = Utils::Icons::OK.icon();
      Q_ASSERT( icon.isNull() == false );
      return icon;
    } else {
      return QVariant();
    }
  }

  /* The line and column number columns are right aligned */
  if( ( role == Qt::TextAlignmentRole )
      && ( ( column == Constants::MISTAKE_COLUMN_LINE )
           || ( column == Constants::MISTAKE_COLUMN_COLUMN ) ) ) {
    return Qt::AlignRight;
  }

  /* Any other role except the display role is invalid. */
  if( ( index.isValid() == false )
      || ( role != Qt::DisplayRole ) ) {
    return QVariant();
  }

  /* Get the display role. */
  Word currentWord = d->wordList.at( row );
  switch( column ) {
    case Constants::MISTAKE_COLUMN_IDX:
      return row + 1;
    case Constants::MISTAKE_COLUMN_WORD:
      return currentWord.text;
    case Constants::MISTAKE_COLUMN_SUGGESTIONS:
      return currentWord.suggestions.join( QStringLiteral( ", " ) );
    case Constants::MISTAKE_COLUMN_LITERAL:
      /* No text, only the image above. */
      return QVariant();
    case Constants::MISTAKE_COLUMN_LINE:
      return currentWord.lineNumber;
    case Constants::MISTAKE_COLUMN_COLUMN:
      return currentWord.columnNumber;
    default:
      return QVariant();
  }
  return QVariant();
}
Exemplo n.º 14
0
void ListView::setBackgroundImage(const QIcon &icon)
{
    QPalette pal=parentWidget()->palette();
    if (!icon.isNull()) {
        pal.setColor(QPalette::Base, Qt::transparent);
    }
    setPalette(pal);
    viewport()->setPalette(pal);
    bgnd=TreeView::createBgndPixmap(icon);
}
Exemplo n.º 15
0
const QIcon &QgsZipItem::iconZip()
{
  static QIcon icon;

  if ( icon.isNull() )
    icon = QgsApplication::getThemeIcon( QStringLiteral( "/mIconZip.png" ) );
// icon from http://www.softicons.com/free-icons/application-icons/mega-pack-icons-1-by-nikolay-verin/winzip-folder-icon

  return icon;
}
Exemplo n.º 16
0
static inline bool isValidIcon(const QIcon &icon)
{
    if (!icon.isNull()) {
        const QList<QSize> availableSizes = icon.availableSizes();
        if (!availableSizes.empty()) {
            return !availableSizes.front().isEmpty();
        }
    }
    return false;
}
Exemplo n.º 17
0
void Tab::updateIcon(void) {
  QTabWidget* widget = qobject_cast<QTabWidget*>(parentWidget()->parentWidget());
  if(widget) {
    QIcon icon = _webView->icon();
    if(icon.isNull()) {
      icon = QIcon(":/defaultPageIcon.png");
    }
    widget->setTabIcon(widget->indexOf(this), icon);
  }
}
QIcon DrugInteractionResult::icon(const IDrug *drug, const DrugInteractionInformationQuery &query) const
{
    for(int i=0; i < m_Alerts.count(); ++i) {
        // TODO: manage processtime of alerts
        QIcon icon = m_Alerts.at(i)->icon(drug, query);
        if (!icon.isNull())
            return icon;
    }
    return QIcon();
}
Exemplo n.º 19
0
QVariant pOpenedFileModel::data( const QModelIndex& index, int role ) const
{
    if ( !index.isValid() )
    {
        return QVariant();
    }

    pAbstractChild* document = this->document( index );

    if ( !document )
    {
        qWarning() << Q_FUNC_INFO << index << mDocuments;
        Q_ASSERT( document );
        return QVariant();
    }

    switch ( role )
    {
    case Qt::DecorationRole:
    {
        QIcon icon = document->windowIcon();

        if ( !mDocumentsIcons.value( document ).isNull() )
        {
            icon = mDocumentsIcons[ document ];
        }
        else if ( document->isModified() )
        {
            icon = mModifiedIcon;
        }

        if ( icon.isNull() )
        {
            icon = mTransparentIcon;
        }

        return icon;
        break;
    }
    case Qt::DisplayRole:
        return document->fileName();
        break;
    case Qt::ToolTipRole:
    {
        const QString customToolTip = mDocumentsToolTips.value( document );
        const QString toolTip = document->filePath();
        return customToolTip.isEmpty() ? toolTip : customToolTip;
        break;
    }
    default:
        break;
    }

    return QVariant();
}
Exemplo n.º 20
0
// static
HPOINTER QPixmap::toPmHPOINTER(const QIcon &icon, bool isPointer,
                               int hotX, int hotY, bool embedRealAlpha,
                               bool isMini)
{
    if (icon.isNull())
        return NULLHANDLE;

    // get the system icon size
    int w = WinQuerySysValue(HWND_DESKTOP, isPointer ? SV_CXPOINTER : SV_CXICON);
    int h = WinQuerySysValue(HWND_DESKTOP, isPointer ? SV_CYPOINTER : SV_CYICON);
    if (!isPointer && isMini) {
        w = w / 2;
        h = h / 2;
    }

    // obtain the closest (but never larger) icon size we have
    QSize size = icon.actualSize(QSize(w, h));

    QPixmap pm = icon.pixmap(size);
    if (pm.isNull())
        return NULLHANDLE;

    // if we got a smaller pixmap then center it inside the box matching the
    // system size instead of letting WinCreatePointerIndirect() scale (this
    // covers a usual case when we get 32/16 px pixmaps on a 120 DPI system
    // where the icon size is 40/20 px respectively): scaling such small images
    // looks really ugly.
    if (!pm.isNull() && (pm.width() < w || pm.height() < h)) {
        Q_ASSERT(pm.width() <= w && pm.height() <= h);
        QPixmap pmNew(w, h);
        pmNew.fill(Qt::transparent);
        QPainter painter(&pmNew);
        int dx = (w - pm.width()) / 2;
        int dy = (h - pm.height()) / 2;
        painter.drawPixmap(dx, dy, pm);
        pm = pmNew;
        hotX += dx;
        hotY += dy;
    }

    POINTERINFO info;
    info.fPointer = isPointer;
    info.xHotspot = hotX;
    info.yHotspot = pm.height() - hotY - 1;
    info.hbmColor = pm.toPmHBITMAP(&info.hbmPointer, embedRealAlpha);
    info.hbmMiniPointer = NULLHANDLE;
    info.hbmMiniColor = NULLHANDLE;

    HPOINTER hIcon = WinCreatePointerIndirect(HWND_DESKTOP, &info);

    GpiDeleteBitmap(info.hbmPointer);
    GpiDeleteBitmap(info.hbmColor);

    return hIcon;
}
Exemplo n.º 21
0
NMainWindow::NMainWindow(const QString &uiFile, QWidget *parent) : QDialog(parent)
{
#ifdef Q_WS_WIN
    m_framelessShadow = false;
#endif

    setObjectName("mainWindow");

#ifndef _N_NO_SKINS_
    QUiLoader loader;
    QFile formFile(uiFile);
    formFile.open(QIODevice::ReadOnly);
    QWidget *form = loader.load(&formFile);
    formFile.close();

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(form->layout()->itemAt(0)->widget());
    layout->setContentsMargins(0, 0, 0, 0);
    setLayout(layout);
    setStyleSheet(form->styleSheet());
    form->setStyleSheet("");
#else
    Q_UNUSED(uiFile)
    ui.setupUi(this);
#endif

    m_unmaximizedSize = QSize();
    m_unmaximizedPos = QPoint();
    m_isFullScreen = false;
    m_dragActive = false;
    m_resizeActive = false;
    m_resizeSection = Qt::NoSection;

    // enabling dragging window from any point
    QList<QWidget *> widgets = findChildren<QWidget *>();
    foreach (QWidget *widget, widgets)
        widget->installEventFilter(this);

    QIcon icon;
#ifdef Q_WS_X11
    icon = QIcon::fromTheme("nulloy");
#endif
#ifndef Q_WS_MAC
    if (icon.isNull()) {
        QStringList files = QDir(":").entryList(QStringList() << "icon-*", QDir::Files);
        foreach (QString fileName, files)
            icon.addFile(":" + fileName);
    }
#else
    icon.addFile(":icon-16.png");
#endif
    setWindowIcon(icon);

    QMetaObject::connectSlotsByName(this);
}
void QVistaHelper::drawTitleBar(QPainter *painter)
{
    Q_ASSERT(backButton_);
    QPoint origin;
    const bool isWindow = wizard->isWindow();
    const HDC hdc = QVistaHelper::backingStoreDC(wizard, &origin);

    if (vistaState() == VistaAero && isWindow)
        drawBlackRect(QRect(0, 0, wizard->width(),
                            titleBarSize() + topOffset()), hdc);
    const int btnTop = backButton_->mapToParent(QPoint()).y();
    const int btnHeight = backButton_->size().height();
    const int verticalCenter = (btnTop + btnHeight / 2) - 1;

    const QString text = wizard->window()->windowTitle();
    const QFont font = QApplication::font("QMdiSubWindowTitleBar");
    const QFontMetrics fontMetrics(font);
    const QRect brect = fontMetrics.boundingRect(text);
    int textHeight = brect.height();
    int textWidth = brect.width();
    int glowOffset = 0;

    if (vistaState() == VistaAero) {
        textHeight += 2 * glowSize();
        textWidth += 2 * glowSize();
        glowOffset = glowSize();
    }

    const int titleLeft = (wizard->layoutDirection() == Qt::LeftToRight
                           ? titleOffset() - glowOffset
                           : wizard->width() - titleOffset() - textWidth + glowOffset);

    const QRect textRectangle(titleLeft, verticalCenter - textHeight / 2, textWidth, textHeight);
    if (isWindow) {
        drawTitleText(painter, text, textRectangle, hdc);
    } else {
        painter->save();
        painter->setFont(font);
        painter->drawText(textRectangle, Qt::AlignVCenter | Qt::AlignHCenter, text);
        painter->restore();
    }

    const QIcon windowIcon = wizard->windowIcon();
    if (!windowIcon.isNull()) {
        const int iconLeft = (wizard->layoutDirection() == Qt::LeftToRight
                              ? leftMargin()
                              : wizard->width() - leftMargin() - iconSize());

        const QRect rect(origin.x() + iconLeft,
                         origin.y() + verticalCenter - iconSize() / 2, iconSize(), iconSize());
        const HICON hIcon = qt_pixmapToWinHICON(windowIcon.pixmap(iconSize()));
        DrawIconEx(hdc, rect.left(), rect.top(), hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT);
        DestroyIcon(hIcon);
    }
}
Exemplo n.º 23
0
void ToolBoxManager::setup( ToolBarItem* toolBar ) const
{
    if ( !toolBar || !_toolBox )
        return; // empty tool bar

    int ct = _toolBox->count();
    for ( int i=0; i<ct; i++ )
    {
        // get always the first item widget
        QWidget* w = _toolBox->widget(0);
        _toolBox->removeItem(0);
        delete w;
    }

    CommandManager& mgr = Application::Instance->commandManager();
    QList<ToolBarItem*> items = toolBar->getItems();

    for ( QList<ToolBarItem*>::ConstIterator item = items.begin(); item != items.end(); ++item )
    {
        QToolBar* bar = new QToolBar();
        bar->setOrientation(Qt::Vertical);
        bar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
        std::string toolbarName = (*item)->command();
        bar->setObjectName(QString::fromLatin1((*item)->command().c_str()));
        bar->setWindowTitle(QObject::trUtf8(toolbarName.c_str())); // i18n
        _toolBox->addItem( bar, bar->windowTitle() );

        QList<ToolBarItem*> subitems = (*item)->getItems();
        for ( QList<ToolBarItem*>::ConstIterator subitem = subitems.begin(); subitem != subitems.end(); ++subitem )
        {
            if ( (*subitem)->command() == "Separator" ) {
                //bar->addSeparator();
            } else {
                mgr.addTo((*subitem)->command().c_str(), bar);
            }
        }

        // Now set the right size policy for each tool button
        QList<QToolButton*> tool = bar->findChildren<QToolButton*>();
        for (QList<QToolButton*>::Iterator it = tool.begin(); it != tool.end(); ++it) {
            (*it)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
            // When setting the horizontal size policy but no icon is set we use the following trick
            // to make the button text left aligned.
            QIcon icon = (*it)->icon();
            if (icon.isNull())
            {
                // Create an icon filled with the button color
                int size = QApplication::style()->pixelMetric(QStyle::PM_SmallIconSize);
                QPixmap p(size, size);
                p.fill(Qt::transparent);
                (*it)->setIcon(p);
            }
        }
    }
}
void KviTalIconAndRichTextItemDelegate::paint(QPainter * pPainter, const QStyleOptionViewItem & option, const QModelIndex & index) const
{
	pPainter->save();
	QStyleOptionViewItem opt = option;
	initStyleOption(&opt, index);

	if(opt.state & QStyle::State_Selected)
		QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, pPainter);

	QString szText = index.data(Qt::DisplayRole).toString();
	QPixmap pixmap;
	QRect decorationRect;
	QVariant value = index.data(Qt::DecorationRole);

	QIcon ico;

	QPixmap pix;

	if(value.canConvert<QIcon>())
	{
		ico = QIcon(value.value<QIcon>());
		if(!ico.isNull())
			pix = ico.pixmap(m_oIconSize);
		else
			pix = m_oDefaultPix;
	}
	else
	{
		pix = m_oDefaultPix;
	}

	if(!pix.isNull())
	{
		int x = opt.rect.x() + LVI_BORDER;
		int y = opt.rect.y() + LVI_BORDER;
		int w = m_oIconSize.width();

		pPainter->drawPixmap(
		    x + ((w - pix.width()) / 2),
		    y,
		    pix);
	}

	QTextDocument doc;
	doc.setHtml(szText);
	doc.setDefaultFont(opt.font);

	int iIconAndSpace = LVI_BORDER + m_oIconSize.width() + LVI_SPACING;

	pPainter->translate(opt.rect.x() + iIconAndSpace, opt.rect.y() + LVI_BORDER);
	doc.setTextWidth(opt.rect.width() - iIconAndSpace - LVI_BORDER);
	QRect cliprect = QRect(QPoint(0, 0), QSize(opt.rect.width() - iIconAndSpace, opt.rect.height()));
	doc.drawContents(pPainter, cliprect);
	pPainter->restore();
}
Exemplo n.º 25
0
QVariant QgsComposerModel::headerData( int section, Qt::Orientation orientation, int role ) const
{
  static QIcon lockIcon;
  if ( lockIcon.isNull() )
    lockIcon = QgsApplication::getThemeIcon( "/locked.svg" );
  static QIcon showIcon;
  if ( showIcon.isNull() )
    showIcon = QgsApplication::getThemeIcon( "/mActionShowAllLayers.png" );

  switch ( role )
  {
    case Qt::DisplayRole:
    {
      if ( section == ItemId )
      {
        return tr( "Item" );
      }
      return QVariant();
    }

    case Qt::DecorationRole:
    {
      if ( section == Visibility )
      {
        return qVariantFromValue( showIcon );
      }
      else if ( section == LockStatus )
      {
        return qVariantFromValue( lockIcon );
      }

      return QVariant();
    }

    case Qt::TextAlignmentRole:
      return Qt::AlignLeft & Qt::AlignVCenter;

    default:
      return QAbstractItemModel::headerData( section, orientation, role );
  }

}
QSizeF QgsLayerTreeModelLegendNode::drawSymbol( const QgsLegendSettings& settings, ItemContext* ctx, double itemHeight ) const
{
    QIcon symbolIcon = data( Qt::DecorationRole ).value<QIcon>();
    if ( symbolIcon.isNull() )
        return QSizeF();

    if ( ctx )
        symbolIcon.paint( ctx->painter, ctx->point.x(), ctx->point.y() + ( itemHeight - settings.symbolSize().height() ) / 2,
                          settings.symbolSize().width(), settings.symbolSize().height() );
    return settings.symbolSize();
}
QIcon BrowserApplication::icon(const QUrl &url) const
{
#if defined(QWEBENGINESETTINGS)
    QIcon icon = QWebEngineSettings::iconForUrl(url);
    if (!icon.isNull())
        return icon.pixmap(16, 16);
#endif
    if (m_defaultIcon.isNull())
        m_defaultIcon = QIcon(QLatin1String(":defaulticon.png"));
    return m_defaultIcon.pixmap(16, 16);
}
Exemplo n.º 28
0
static inline QIcon designerIcon(const QString &iconName)
{
#if QT_VERSION >= 0x050000
    const QIcon icon = QDesignerFormEditorInterface::createIcon(iconName);
#else
    const QIcon icon = qdesigner_internal::createIconSet(iconName);
#endif
    if (icon.isNull())
        qWarning() << "Unable to locate " << iconName;
    return icon;
}
Exemplo n.º 29
0
void TaskHeader::setIcon(const QIcon &i) {
    m_icon = i;
    if (i.isNull()) {
        m_spacer->changeSize(0,0, QSizePolicy::Fixed, QSizePolicy::Fixed);
    } else {
        m_spacer->changeSize(50,16, QSizePolicy::Fixed, QSizePolicy::Fixed);
    }
    m_spacer->invalidate();
    layout()->invalidate();
    update();
}
Exemplo n.º 30
0
QIcon QtWebKitWebWidget::getIcon() const
{
	if (isPrivate())
	{
		return Utils::getIcon(QLatin1String("tab-private"));
	}

	const QIcon icon = m_webView->icon();

	return (icon.isNull() ? Utils::getIcon(QLatin1String("tab")) : icon);
}