Esempio n. 1
0
StatusProperty::StatusProperty( const QString& name, const QString& text, Level level, Property* parent )
  : Property( name, text, text, parent )
  , level_( level )
{
  setShouldBeSaved( false );
  status_icons_[0] = loadPixmap( "package://rviz/icons/ok.png" );
  status_icons_[1] = loadPixmap( "package://rviz/icons/warning.png" );
  status_icons_[2] = loadPixmap( "package://rviz/icons/error.png" );
}
Esempio n. 2
0
void QgsPhotoWidget::initWidget( QWidget* editor )
{
  QWidget* container;

  mLineEdit = qobject_cast<QLineEdit*>( editor );

  if ( mLineEdit )
    container = qobject_cast<QWidget*>( mLineEdit->parent() );
  else
  {
    container = editor;
    mLineEdit = container->findChild<QLineEdit*>();
  }

  mButton = container->findChild<QPushButton*>( "FileChooserButton" );
  if ( !mButton )
    mButton = container->findChild<QPushButton*>();

  mPhotoLabel = container->findChild<QLabel*>( "PhotoLabel" );
  if ( !mPhotoLabel )
    mPhotoLabel = container->findChild<QLabel*>();

  if ( mButton )
    connect( mButton, SIGNAL( clicked() ), this, SLOT( selectFileName() ) );

  if ( mLineEdit )
  {
    connect( mLineEdit, SIGNAL( textChanged( QString ) ), this, SLOT( valueChanged( QString ) ) );
    connect( mLineEdit, SIGNAL( textChanged( QString ) ), this, SLOT( loadPixmap( QString ) ) );
  }
}
void DisplayItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    painter->setRenderHints(QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
    painter->setPen(QColor::fromRgbF(1, 1, 1, 0.1));

    if (!index.data(DisplayControlModel::ItemIsLastRole).toBool())
        painter->drawLine(QPoint(60, option.rect.bottom()), QPoint(option.rect.right() - 30, option.rect.bottom()));

    const int icon_x = 15;
    const int icon_y = option.rect.top() + (option.rect.height() - 36) / 2;
    painter->drawPixmap(icon_x, icon_y, index.data(DisplayControlModel::ItemIconRole).value<QPixmap>());

    if (index.data(DisplayControlModel::ItemSelectedRole).toBool())
    {
        const int x = option.rect.right() - 24;
        const int y = option.rect.top() + (option.rect.height() - 16) / 2;

        painter->drawPixmap(x, y, loadPixmap(":/frame/themes/dark/icons/select.svg"));
    }

    const int name_x = 65;
    const int name_y = option.rect.top() + 20;
    painter->setPen(Qt::white);
    painter->drawText(name_x, name_y, index.data(DisplayControlModel::ItemTitleRole).toString());

    QRect descRect = option.rect;
    descRect.setTopLeft(QPoint(name_x, name_y + 5));
    descRect.setRight(option.rect.right() - 30);
    painter->setPen(QColor(255, 255, 255, .6 * 255));
    painter->drawText(descRect, Qt::AlignLeft | Qt::TextWordWrap, index.data(DisplayControlModel::ItemDescriptionRole).toString());
}
Esempio n. 4
0
bool Deck::importDana(QString fileName)
{
    QFileInfo fi(fileName);
    QString baseName = fi.baseName().toLower();

    QString tempFolder = utils::combinePaths(tempPath(), baseName);
    QString deckPath = utils::combinePaths(tempFolder, "deck.xml"); 
    QString iconPath = utils::combinePaths(tempFolder, "icon.png"); 
    
    utils::createDirectory(tempFolder);
    
    Compressor c;
    if(!c.decompressFolder(fileName, tempFolder)) {
        return false;
    }

    /// 
    importFromXml(deckPath);

    utils::removeFile(deckPath);
    utils::copyDirectory(getDeckPath(), tempFolder);

    /// load icon pixmap
    loadPixmap( iconPath );

    return true;
}
Esempio n. 5
0
QIcon
IconLoader::load(QString name)
{
    QPixmap pmap(loadPixmap(name));
    if (pmap.isNull()) return QIcon();
    else return QIcon(pmap);
}
Esempio n. 6
0
void CardInfo::updatePixmapCache()
{
    qDebug() << "Updating pixmap cache for" << name;
    clearPixmapCache();
    loadPixmap();

    emit pixmapUpdated();
}
Esempio n. 7
0
KdmPixmap::KdmPixmap(KdmItem *parent, const QDomNode &node, const char *name) : KdmItem(parent, node, name)
{
    itemType = "pixmap";

    // Set default values for pixmap (note: strings are already Null)
    pixmap.normal.tint.setRgb(0xFFFFFF);
    pixmap.normal.alpha = 1.0;
    pixmap.active.present = false;
    pixmap.prelight.present = false;

    // Read PIXMAP ID
    // it rarely happens that a pixmap can be a button too!
    QDomNode n = node;
    QDomElement elPix = n.toElement();

    // Read PIXMAP TAGS
    QDomNodeList childList = node.childNodes();
    for(uint nod = 0; nod < childList.count(); nod++)
    {
        QDomNode child = childList.item(nod);
        QDomElement el = child.toElement();
        QString tagName = el.tagName();

        if(tagName == "normal")
        {
            loadPixmap(el.attribute("file", ""), pixmap.normal.pixmap, pixmap.normal.fullpath);
            parseColor(el.attribute("tint", "#ffffff"), pixmap.normal.tint);
            pixmap.normal.alpha = el.attribute("alpha", "1.0").toFloat();
        }
        else if(tagName == "active")
        {
            pixmap.active.present = true;
            loadPixmap(el.attribute("file", ""), pixmap.active.pixmap, pixmap.active.fullpath);
            parseColor(el.attribute("tint", "#ffffff"), pixmap.active.tint);
            pixmap.active.alpha = el.attribute("alpha", "1.0").toFloat();
        }
        else if(tagName == "prelight")
        {
            pixmap.prelight.present = true;
            loadPixmap(el.attribute("file", ""), pixmap.prelight.pixmap, pixmap.prelight.fullpath);
            parseColor(el.attribute("tint", "#ffffff"), pixmap.prelight.tint);
            pixmap.prelight.alpha = el.attribute("alpha", "1.0").toFloat();
        }
    }
}
Esempio n. 8
0
void CardInfoPicture::paintEvent(QPaintEvent *)
{
    if (width() == 0 || height() == 0)
        return;

    if (pixmapDirty)
        loadPixmap();

    QPainter painter(this);
    style()->drawItemPixmap(&painter, rect(), Qt::AlignHCenter, resizedPixmap);
}
void TitledSliderItem::setRightIcon(const QString &rightIcon)
{
    if (rightIcon != m_rightIcon) {
        m_rightIcon = rightIcon;

        QPixmap pix = loadPixmap(m_rightIcon);
        m_rightIconLabel->setPixmap(pix);
        m_rightIconLabel->setVisible(!pix.isNull());

        emit rightIconChanged();
    }
}
Esempio n. 10
0
OpenGlTexture::OpenGlTexture(QObject *parent, const QPixmap &_pixmap, qreal _blurKernelSize) :
    QObject(parent) {
    mirrorX = mirrorY = false;
    video          = 0;
    webView        = 0;
    texture        = 0;
    init           = false;
    timerCamera    = -1;
    openCvProcess  = 0;
    loadPixmap(_pixmap, _blurKernelSize);
    textures.append(this);
}
Esempio n. 11
0
void
Button::changePixmap( const QString& name )
{
	QString path = locate( "data", "xkmenu/" + name );
	if( path.isNull() )
	{
		kdWarning() << k_funcinfo << "Pixmap could not be found [ "
				  << name << " ]" << endl;
		return;
	}
	loadPixmap( path  );
}
Esempio n. 12
0
void mrcGraphicsItem::run()
{
    pixmapLoaded = true;
    mutex.lock();
    (*threadCount)++;
    mutex.unlock();

    loadPixmap();

    mutex.lock();
    (*threadCount)--;
    mutex.unlock();
}
Esempio n. 13
0
QPixmap KGrTheme::background (unsigned int width, unsigned int height, 
                              unsigned int variant)
{
    QTime t;
    t.restart();
    QPixmap pixmap;
    if ((width != 0) && (height != 0)) {
        if (numBackgrounds <= 0) {	// No variants, maybe not even a b/g.
            loadPixmap (QSize (width, height),
                        QString ("background"), pixmap, Set);
            dbe1 "loadPixmap: \"background\" %dx%d\n", width, height);
        }
        else {
Esempio n. 14
0
void QgsPhotoWidgetWrapper::initWidget( QWidget* editor )
{
  QWidget* container;

  mLineEdit = qobject_cast<QLineEdit*>( editor );
#ifdef WITH_QTWEBKIT
  mWebView = qobject_cast<QWebView*>( editor );
#endif

  if ( mLineEdit )
  {
    container = mLineEdit->parentWidget();
  }
#ifdef WITH_QTWEBKIT
  else if ( mWebView )
  {
    container = mWebView->parentWidget();
    mLineEdit = container->findChild<QLineEdit*>();
  }
#endif
  else
  {
    container = editor;
    mLineEdit = container->findChild<QLineEdit*>();
  }

  mButton = container->findChild<QPushButton*>( "FileChooserButton" );
  if ( !mButton )
    mButton = container->findChild<QPushButton*>();

  mPhotoLabel = container->findChild<QLabel*>( "PhotoLabel" );
  if ( !mPhotoLabel )
    mPhotoLabel = container->findChild<QLabel*>();

  mPhotoPixmapLabel = qobject_cast<QgsPixmapLabel*>( mPhotoLabel );
  if ( mButton )
    connect( mButton, SIGNAL( clicked() ), this, SLOT( selectFileName() ) );

  if ( mLineEdit )
  {

    QgsFilterLineEdit *fle = qobject_cast<QgsFilterLineEdit*>( mLineEdit );
    if ( fle )
    {
      fle->setNullValue( QSettings().value( "qgis/nullValue", "NULL" ).toString() );
    }

    connect( mLineEdit, SIGNAL( textChanged( QString ) ), this, SLOT( valueChanged( QString ) ) );
    connect( mLineEdit, SIGNAL( textChanged( QString ) ), this, SLOT( loadPixmap( QString ) ) );
  }
}
Esempio n. 15
0
void ImageViewer::loadImage(const QUrl& image)
{
    m_reloadRequestTimer->stop();

    m_image = image;

    if (image.path().endsWith(".svg") || image.path().endsWith(".svgz")) {
        loadSvg(image);
    } else {
        ImageLoader *loader = new ImageLoader(image, size(), this);
        connect(loader, SIGNAL(loadImage(QUrl,QSize,QImage)), this, SLOT(loadPixmap(QUrl,QSize,QImage)));
        QThreadPool::globalInstance()->start(loader);
    }
}
Esempio n. 16
0
void QgsPhotoWidgetWrapper::setValue( const QVariant& value )
{
  if ( mLineEdit )
  {
    if ( value.isNull() )
      mLineEdit->setText( QSettings().value( "qgis/nullValue", "NULL" ).toString() );
    else
      mLineEdit->setText( value.toString() );
  }
  else
  {
    loadPixmap( value.toString() );
  }
}
Esempio n. 17
0
QPixmap
IconLoader::loadPixmap(QString name)
{
    if (m_cache.find(name) != m_cache.end()) return m_cache[name];
    QPixmap pixmap = loadPixmap(":pixmaps/toolbar", name);
    if (pixmap.isNull()) pixmap = loadPixmap(":pixmaps/transport", name);
    if (pixmap.isNull()) pixmap = loadPixmap(":pixmaps/misc", name);
    if (pixmap.isNull()) pixmap = loadPixmap(":pixmaps/stock", name);
    if (pixmap.isNull()) pixmap = loadPixmap(":pixmaps/icons", name);
    if (pixmap.isNull()) pixmap = loadPixmap(":pixmaps/style", name);
    if (pixmap.isNull()) pixmap = loadPixmap(":pixmaps", name);
    m_cache[name] = pixmap;
    return pixmap;
}
Esempio n. 18
0
void CameraPub::onInitialize()
{
  Display::onInitialize();

  video_publisher_ = new video_export::VideoPublisher();

  std::stringstream ss;
  static int count = 0;
  ss << "RvizCameraPubCamera" << count++;
  camera_ = context_->getSceneManager()->createCamera(ss.str());

  // render to texture
  rtt_texture_ = Ogre::TextureManager::getSingleton().createManual(
      "RttTex",
      Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
      Ogre::TEX_TYPE_2D,
      640, 480,
      0,
      Ogre::PF_R8G8B8,
      Ogre::TU_RENDERTARGET);
  render_texture_ = rtt_texture_->getBuffer()->getRenderTarget();
  render_texture_->addViewport(camera_);
  render_texture_->getViewport(0)->setClearEveryFrame(true);
  render_texture_->getViewport(0)->setBackgroundColour(Ogre::ColourValue::Black);
  render_texture_->getViewport(0)->setOverlaysEnabled(false);
  render_texture_->setAutoUpdated(false);
  render_texture_->setActive(false);
  render_texture_->addListener(this);

  camera_->setNearClipDistance(0.01f);
  camera_->setPosition(0, 10, 15);
  camera_->lookAt(0, 0, 0);

  // Thought this was optional but the plugin crashes without it
  vis_bit_ = context_->visibilityBits()->allocBit();
  render_texture_->getViewport(0)->setVisibilityMask(vis_bit_);

  visibility_property_ = new DisplayGroupVisibilityProperty(
    vis_bit_, context_->getRootDisplayGroup(), this, "Visibility", true,
    "Changes the visibility of other Displays in the camera view.");

  visibility_property_->setIcon(loadPixmap("package://rviz/icons/visibility.svg", true));

  this->addChild(visibility_property_, 0);
  updateDisplayNamespace();
}
void DisplayTypeTree::fillTree( Factory *factory )
{
    QIcon default_package_icon = loadPixmap( "package://rviz/icons/default_package_icon.png" );

    QStringList classes = factory->getDeclaredClassIds();
    classes.sort();

    // Map from package names to the corresponding top-level tree widget items.
    std::map<QString, QTreeWidgetItem*> package_items;

    for( int i = 0; i < classes.size(); i++ )
    {
      QString lookup_name = classes[ i ];
      QString package = factory->getClassPackage( lookup_name );
      QString description = factory->getClassDescription( lookup_name );
      QString name = factory->getClassName( lookup_name );

      QTreeWidgetItem* package_item;

      std::map<QString, QTreeWidgetItem*>::iterator mi;
      mi = package_items.find( package );
      if( mi == package_items.end() )
      {
        package_item = new QTreeWidgetItem( this );
        package_item->setText( 0, package );
        package_item->setIcon( 0, default_package_icon );

        package_item->setExpanded( true );
        package_items[ package ] = package_item;
      }
      else
      {
        package_item = (*mi).second;
      }
      QTreeWidgetItem* class_item = new QTreeWidgetItem( package_item );

      class_item->setIcon( 0, factory->getIcon( lookup_name ) );

      class_item->setText( 0, name );
      class_item->setWhatsThis( 0, description );
      // Store the lookup name for each class in the UserRole of the item.
      class_item->setData( 0, Qt::UserRole, lookup_name );
    }
}
Esempio n. 20
0
void Widget::loadDefaults()
{
    // "content" << "icon" << "title" << "layout" << "size" << "pos" << "fn" << "fs" << "duration" < "sc" << "bg" << "fg";
    Message& m = m_messageQueue.front();
    Settings* s = &m_settings;
    if (m.data["layout"]) {
        QString name = m.data["layout"]->toString();
        name.remove(".conf");
        s = new Settings(name);
        s->fillWith(m_settings);
        qDebug() << "Layout loaded : " << name;
        qDebug() << s->get("gui/foreground_color");
    }
    if (!m.data["bg"])
        m.data["bg"] = boost::optional<QVariant>(s->get("gui/background_color"));
    if (!m.data["fg"])
        m.data["fg"] = boost::optional<QVariant>(s->get("gui/foreground_color"));
    if (!m.data["sc"])
        m.data["sc"] = boost::optional<QVariant>(s->get("main/sound_command"));
    if (!m.data["duration"])
        m.data["duration"] = boost::optional<QVariant>(s->get("main/duration"));
    if (!m.data["fs"])
        m.data["fs"] = boost::optional<QVariant>(s->get("gui/font_size"));
    if (!m.data["fn"])
        m.data["fn"] = boost::optional<QVariant>(s->get("gui/font"));
    if (!m.data["fv"])
        m.data["fv"] = boost::optional<QVariant>(s->get("gui/font_variant"));
    if (!m.data["pos"])
        m.data["pos"] = boost::optional<QVariant>(s->get("gui/position"));
    if (!m.data["size"])
        m.data["size"] = boost::optional<QVariant>(s->get("gui/height"));
    if (!m.data["icon"])
        m.data["icon"] = loadPixmap(s->has("gui/icon") ? s->get("gui/icon").toString() : "");
    if (!m.data["aot"])
        m.data["aot"] = boost::optional<QVariant>(s->get("gui/always_on_top"));
    if (!m.data["ac"])
        m.data["ac"] = boost::optional<QVariant>(s->get("main/activate_command"));
    if (!m.data["bounce"])
        m.data["bounce"] = boost::optional<QVariant>(s->get("gui/bounce"));
    if (s != &m_settings)
        delete s;
}
SettingsOptionItem::SettingsOptionItem(QWidget *parent)
    : QFrame(parent),

      m_title(new QLabel),
      m_icon(new QLabel)
{
    m_icon->setPixmap(loadPixmap(":/display/themes/common/icon/list_select.png"));
    m_icon->setVisible(false);

    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addWidget(m_title);
    mainLayout->addStretch();
    mainLayout->addWidget(m_icon);
    mainLayout->setSpacing(0);

    mainLayout->setContentsMargins(15, 0, 10, 0);

    setFixedHeight(36);

    setLayout(mainLayout);
}
Esempio n. 22
0
QPixmap *CardInfo::getPixmap(QSize size)
{
    QPixmap *cachedPixmap = scaledPixmapCache.value(size.width());
    if (cachedPixmap)
        return cachedPixmap;
    QPixmap *bigPixmap = loadPixmap();
    QPixmap *result;
    if (bigPixmap->isNull()) {
        if (!getName().isEmpty())
            return 0;
        else {
            result = new QPixmap(size);
            result->fill(Qt::transparent);
            QSvgRenderer svg(QString(":/back.svg"));
            QPainter painter(result);
            svg.render(&painter, QRectF(0, 0, size.width(), size.height()));
        }
    } else
        result = new QPixmap(bigPixmap->scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
    scaledPixmapCache.insert(size.width(), result);
    return result;
}
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);
    }
}
Esempio n. 24
0
void Widget::setupIcon()
{
    Message& m = m_messageQueue.front();
    bool done = true;
    if (m.data["icon"]) {
        QPixmap pix = qvariant_cast<QPixmap>(*m.data["icon"]);
        if (pix.isNull())
            pix = loadPixmap(m.data["icon"]->toString());
        if (!pix.isNull())
            m.data["icon"].reset(pix);
        else if (pix.isNull())
            done = false;
        if (pix.height() > m.data["size"]->toInt())
            pix = pix.scaled(m.data["size"]->toInt()-2, m.data["size"]->toInt()-2, Qt::KeepAspectRatio);
        m.data["icon"].reset(pix);
        m_contentView["icon"]->setPixmap(pix);
        m_contentView["icon"]->setMaximumWidth(9999);
    }
    if (!done) {
        m_contentView["icon"]->setPixmap(QPixmap());
        m_contentView["icon"]->setFixedWidth(2);
    }
}
Esempio n. 25
0
void CardInfo::getPixmap(QSize size, QPixmap &pixmap)
{
    QString key = QLatin1String("card_") + name + QLatin1Char('_') + QString::number(size.width());
    if(QPixmapCache::find(key, &pixmap))
        return;

    QPixmap bigPixmap;
    loadPixmap(bigPixmap);
    if (bigPixmap.isNull()) {
        if (!getName().isEmpty()) {
            pixmap = QPixmap(); // null
            return;
        } else {
            pixmap = QPixmap(size);
            pixmap.fill(Qt::transparent);
            QSvgRenderer svg(QString(":/back.svg"));
            QPainter painter(&pixmap);
            svg.render(&painter, QRectF(0, 0, size.width(), size.height()));
        }
    } else {
        pixmap = bigPixmap.scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    }
    QPixmapCache::insert(key, pixmap);
}
void BasicListDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
    const bool isHover = index.data(BasicListModel::ItemHoverRole).toBool();

    painter->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
    painter->setBrush(Qt::red);
    painter->setPen(Qt::black);

    if (isHover) {
        QPainterPath path;
        path.addRoundedRect(option.rect.marginsRemoved(QMargins(15, 0, 5, 0)), 6, 6);
        painter->fillPath(path, QColor(0, 0, 0, 0.05 * 255));
    }

    painter->drawText(option.rect.marginsRemoved(QMargins(30, 0, 0, 0)), Qt::AlignVCenter | Qt::AlignLeft, index.data(Qt::DisplayRole).toString());

    if (index.data(BasicListModel::ItemSelectedRole).toBool())
    {
        const int x = option.rect.right() - 16 - 14;
        const int y = option.rect.top() + (option.rect.height() - 16) / 2;

        painter->drawPixmap(x, y, loadPixmap(":/widgets/themes/dark/icons/list_select.png"));
    }
}
Esempio n. 27
0
IconItem::IconItem( const QString& name, const QString& icon )
{
    _name = name;
    _pixmap = loadPixmap( icon );
}
QPixmap QuickSwitchButton::normalPixmap() const
{
    QString checkedStr = m_checked ? "_on" : "_off";
    return loadPixmap(QString(":/frame/themes/%1/icons/%2%3.png").arg(m_themeName).arg(m_iconName).arg(checkedStr));
}
Esempio n. 29
0
FailedDisplay::FailedDisplay( const QString& desired_class_id, const QString& error_message )
  : error_message_( error_message )
{
  setClassId( desired_class_id );
  setIcon( loadPixmap( "package://rviz/icons/failed_display.png" ) );
}
Esempio n. 30
0
QIcon IconManager::loadIcon(const QString nam, bool forceUseColor)
{
	return QIcon(loadPixmap(nam, forceUseColor));
}