Example #1
0
void KuickShow::slotHighlighted( const KFileItem *fi )
{
    KFileItem *item = const_cast<KFileItem *>( fi );
    statusBar()->changeItem( item->getStatusBarInfo(), URL_ITEM );
    bool image = FileWidget::isImage( fi );

    QString meta;
    if ( image )
    {
        KFileMetaInfo info = item->metaInfo();
        if ( info.isValid() )
        {
            meta = info.item( KFileMimeTypeInfo::Size ).string();
            KFileMetaInfoGroup group = info.group( "Technical" );
            if ( group.isValid() )
            {
                QString bpp = group.item( "BitDepth" ).string();
                if ( !bpp.isEmpty() )
                    meta.append( ", " ).append( bpp );
            }
        }
    }
    statusBar()->changeItem( meta, META_ITEM );

    fileWidget->actionCollection()->action("kuick_print")->setEnabled( image );
    fileWidget->actionCollection()->action("kuick_showInSameWindow")->setEnabled( image );
    fileWidget->actionCollection()->action("kuick_showInOtherWindow")->setEnabled( image );
    fileWidget->actionCollection()->action("kuick_showFullscreen")->setEnabled( image );
}
Example #2
0
void CelSplashScreen::setPixmap( const QString &filename )
{
    QPixmap _pixmap(filename);
    resize( _pixmap.size() );

    //  Set default values for status and version fields
    status.getRect().setX(20);
    status.getRect().setY(height() - 40);
    status.getRect().setWidth(width() - 200);
    status.getRect().setHeight(20);
    status.setFlags(Qt::AlignLeft | Qt::AlignTop);

    version.getRect().setX(width() - 180);
    version.getRect().setY(height() - 40);
    version.getRect().setWidth(150);
    version.getRect().setHeight(20);
    version.setFlags(Qt::AlignRight | Qt::AlignTop);
    version.setContent(VERSION);

    KFileMetaInfo info(filename);
    KFileMetaInfoGroup comments = info.group("Comment");

    if (comments.isValid()) {
        status.set("status", comments);
        version.set("version", comments);
        int i = 0;
        char extraName[10];
        sprintf(extraName, "extra%02d", i);
        while (i< 100 && comments.item(QString(extraName) + "_insert_before").isValid()) {
            TextItem extra;
            extra.set(extraName, comments);
            extraText.push_back(extra);
            i++;
            sprintf(extraName, "extra%02d", i);
        }
    }

    QRect desk = KGlobalSettings::splashScreenDesktopGeometry();
    setGeometry( ( desk.width() / 2 ) - ( width() / 2 ) + desk.left(),
       ( desk.height() / 2 ) - ( height() / 2 ) + desk.top(),
         width(), height() );
    if (_pixmap.hasAlphaChannel()) {
        QPixmap bg = QPixmap::grabWindow( qt_xrootwin(), x(), y(), width(), height() );
        QPainter painter(&bg);
        painter.drawPixmap(0, 0, _pixmap);
        pixmap = bg;
    } else {
        pixmap = _pixmap;
    }
    
    QPainter painter( &pixmap, this );
    version.draw(&painter);
    for(std::vector<TextItem>::const_iterator i = extraText.begin(); i != extraText.end();  ++i)
        (*i).draw(&painter);

    repaint();
}
Example #3
0
TQStringList FileProps::availableKeys( const TQString& group ) const
{
    KFileMetaInfoGroup g = m_info->group( group );
    TQStringList allKeys = g.keys();
    TQStringList ret;
    TQStringList::ConstIterator it = allKeys.begin();
    for ( ; it != allKeys.end(); ++it )
    {
        if ( g.item( *it ).isValid() )
            ret.append( *it );
    }

    return ret;
}
Example #4
0
// static helper:
// creates strings like
// "group:       translatedKey:               value"
TQString FileProps::createKeyValue( const KFileMetaInfoGroup& g,
                                   const TQString& key )
{
    static const int MAX_SPACE = 25;
    KFileMetaInfoItem item = g.item( key );

    TQString result("%1");
    result = result.arg( (item.isValid() ? item.translatedKey() : key) + ":",
                         -MAX_SPACE );
    result.append( beatifyValue( item.string() ) );

    TQString group("%1");
    group = group.arg( g.translatedName() + ":", -MAX_SPACE );
    result.prepend( group );

    return result;
}
Example #5
0
bool FileProps::setValue( const TQString& group,
                          const TQString& key, const TQString &value )
{
    KFileMetaInfoGroup g = m_info->group( group );
    bool wasAdded = false;
    if ( !g.isValid() )
    {
        if ( m_info->addGroup( group ) )
        {
            wasAdded = true;
            g = m_info->group( group );
        }
        else
            return false;
    }

    bool ok = g[key].setValue( value );

    if ( !ok && wasAdded ) // remove the created group again
        (void) m_info->removeGroup( group );
        
    m_dirty |= ok;
    return ok;
}
Example #6
0
TQStringList FileProps::supportedKeys( const TQString& group ) const
{
    KFileMetaInfoGroup g = m_info->group( group );
    return g.supportedKeys();
}
Example #7
0
TQStringList FileProps::preferredValues( const TQString& group ) const
{
    KFileMetaInfoGroup g = m_info->group( group );
    return FileProps::createKeyValueList( g, g.preferredKeys() );
}
Example #8
0
TQStringList FileProps::preferredKeys( const TQString& group ) const
{
    KFileMetaInfoGroup g = m_info->group( group );
    return g.preferredKeys();
}
Example #9
0
void TextItem::set(const QString& prefix, const KFileMetaInfoGroup& comments) {
    bool ok;
    int intVal;
    intVal = comments.value(prefix + "_disable").toInt(&ok);
    if (ok) disable = intVal;
    intVal = comments.value(prefix + "_x").toInt(&ok);
    if (ok) rect.setX(intVal);
    intVal = comments.value(prefix + "_y").toInt(&ok);
    if (ok) rect.setY(intVal);
    intVal = comments.value(prefix + "_width").toInt(&ok);
    if (ok) rect.setWidth(intVal);
    intVal = comments.value(prefix+ "_height").toInt(&ok);
    if (ok) rect.setHeight(intVal);
    QString sVal = comments.value(prefix + "_halign").toString();
    int _flags = -1;
    if (sVal == "left") {
        _flags = Qt::AlignLeft;
    } else if (sVal == "center") {
        _flags = Qt::AlignHCenter;
    } else if (sVal == "right") {
        _flags = Qt::AlignRight;
    }
    sVal = comments.value(prefix + "_valign").toString();
    if (sVal == "top") {
        if (_flags < 0) _flags = Qt::AlignTop;
        else _flags |= Qt::AlignTop;
    } else if (sVal == "center") {
        if (_flags < 0) _flags = Qt::AlignVCenter;
        else _flags |= Qt::AlignVCenter;
    } else if (sVal == "bottom") {
        if (_flags < 0) _flags = Qt::AlignBottom;
        else _flags |= Qt::AlignBottom;
    }
    if (_flags >= 0) flags = _flags;
    sVal = comments.value(prefix + "_font_family").toString();
    if (sVal != "") font.setFamily(sVal);
    intVal = comments.value(prefix + "_font_size").toInt(&ok);
    if (ok) font.setPixelSize(intVal);
    intVal = comments.value(prefix + "_font_is_bold").toInt(&ok);
    if (ok) font.setBold(intVal);
    sVal = comments.value(prefix + "_color").toString();
    if (sVal != "") setColor(sVal);
    intVal = comments.value(prefix + "_show_box").toInt(&ok);
    if (ok) showBox = intVal;
    sVal = comments.value(prefix + "_insert_before").toString();
    if (sVal != "") insertBefore = sVal;
}