示例#1
0
QString SystemTray::currentAttentionIconName() const
{
    if (state() == State::NeedsAttention && _attentionBehavior == AttentionBehavior::Blink && !_blinkState) {
        return iconName(State::Active);
    }
    return iconName(State::NeedsAttention);
}
示例#2
0
QString SystemTray::currentIconName() const
{
    if (state() == State::NeedsAttention) {
        if (_attentionBehavior == AttentionBehavior::ChangeColor) {
            return iconName(State::NeedsAttention);
        }
        if (_attentionBehavior == AttentionBehavior::Blink && _blinkState) {
            return iconName(State::NeedsAttention);
        }
        return iconName(State::Active);
    }
    else {
        return iconName(state());
    }
}
KMyMoneyBriefSchedule::KMyMoneyBriefSchedule(QWidget *parent)
    : kScheduleBriefWidget(parent/*,name, Qt::WStyle_Customize | Qt::WStyle_NoBorder*/)
{
    m_nextButton->setIcon(KIcon(QString::fromLatin1("arrow-right")));
    m_prevButton->setIcon(KIcon(QString::fromLatin1("arrow-left")));

    connect(m_prevButton, SIGNAL(clicked()), this, SLOT(slotPrevClicked()));
    connect(m_nextButton, SIGNAL(clicked()), this, SLOT(slotNextClicked()));
    connect(m_closeButton, SIGNAL(clicked()), this, SLOT(hide()));
    connect(m_skipButton, SIGNAL(clicked()), this, SLOT(slotSkipClicked()));
    connect(m_buttonEnter, SIGNAL(clicked()), this, SLOT(slotEnterClicked()));

    KGuiItem skipGuiItem(i18n("&Skip"),
                         KIcon("media-seek-forward"),
                         i18n("Skip this transaction"),
                         i18n("Use this button to skip this transaction"));
    m_skipButton->setGuiItem(skipGuiItem);

    // as of KDE 4.8 the icon we use here move to a different location
    QString iconName("go-jump-locationbar");;
    if (KDE::version() >= 0x040800) {
        iconName = QLatin1String("key-enter");
    }

    KGuiItem enterGuiItem(i18n("&Enter"),
                          KIcon(iconName),
                          i18n("Record this transaction into the register"),
                          i18n("Use this button to record this transaction"));
    m_buttonEnter->setGuiItem(enterGuiItem);
}
示例#4
0
文件: kfileitem.cpp 项目: KDE/kio
QMimeType KFileItem::determineMimeType() const
{
    if (!d) {
        return QMimeType();
    }

    if (!d->m_mimeType.isValid() || !d->m_bMimeTypeKnown) {
        QMimeDatabase db;
        if (isDir()) {
            d->m_mimeType = db.mimeTypeForName(QStringLiteral("inode/directory"));
        } else {
            bool isLocalUrl;
            const QUrl url = mostLocalUrl(&isLocalUrl);
            d->m_mimeType = db.mimeTypeForUrl(url);
            // was:  d->m_mimeType = KMimeType::findByUrl( url, d->m_fileMode, isLocalUrl );
            // => we are no longer using d->m_fileMode for remote URLs.
            Q_ASSERT(d->m_mimeType.isValid());
            //qDebug() << d << "finding final mimetype for" << url << ":" << d->m_mimeType.name();
        }
        d->m_bMimeTypeKnown = true;
    }

    if (d->m_delayedMimeTypes) { // if we delayed getting the iconName up till now, this is the right point in time to do so
        d->m_delayedMimeTypes = false;
        d->m_useIconNameCache = false;
        (void)iconName();
    }

    return d->m_mimeType;
}
void LxQtNetworkMonitor::timerEvent(QTimerEvent *event)
{
    bool matched = false;

#ifdef STATGRAB_NEWER_THAN_0_90
    size_t num_network_stats;
#else
    int num_network_stats;
#endif
    sg_network_io_stats *network_stats = sg_get_network_io_stats_diff(&num_network_stats);

    for (int x = 0; x < num_network_stats; x++)
    {
        if (m_interface == QString::fromLocal8Bit(network_stats->interface_name))
        {
            if (network_stats->rx != 0 && network_stats->tx != 0)
            {
                m_pic.load(iconName("transmit-receive"));
            }
            else if (network_stats->rx != 0 && network_stats->tx == 0)
            {
                m_pic.load(iconName("receive"));
            }
            else if (network_stats->rx == 0 && network_stats->tx != 0)
            {
                m_pic.load(iconName("transmit"));
            }
            else
            {
                m_pic.load(iconName("idle"));
            }

            matched = true;

            break;
        }

        network_stats++;
    }

    if (!matched)
    {
        m_pic.load(iconName("error"));
    }

    update();
}
示例#6
0
void FileSystem::setConfiguration(QDomDocument* config, const QString& mainDataDir, const QString& userDataDir)
{
    Q_UNUSED(mainDataDir);
    Q_UNUSED(userDataDir);

    QString rootPath;
    QIcon folderIcon;
    QIcon defaultFileIcon;
    QHash<QString, QIcon> icons;
    if (config != NULL) {
        QDomElement elt = config->documentElement();
        if (!elt.isNull() && elt.tagName() == "FileSystem") {
            for (QDomNode n = elt.firstChild(); !n.isNull(); n = n.nextSibling()) {
                if (n.isElement()) {
                    QDomElement e = n.toElement();
                    if (e.tagName() == "RootPath") {
                        QString p(e.attribute("value"));
                        if (QFile::exists(p)) {
                            rootPath = p;
                        }
                    }
                    if (e.tagName() == "Icons") {
                        for (QDomNode n2 = e.firstChild(); !n2.isNull(); n2 = n2.nextSibling()) {
                            if (n2.isElement()) {
                                QDomElement e2 = n2.toElement();
                                QString iconName(e2.attribute("icon"));
                                QString iconPath(userDataDir + "/" + iconName);
                                if (!QFile::exists(iconPath)) {
                                    iconPath = mainDataDir + "/" + iconName;
                                    if (!QFile::exists(iconPath)) {
                                        iconPath = QString::null;
                                    }
                                }
                                if (e2.tagName() == "Folder") {
                                    folderIcon = QIcon(iconPath);
                                } else if (e2.tagName() == "DefaultFile") {
                                    defaultFileIcon = QIcon(iconPath);
                                } else if (e2.tagName() == "File") {
                                    icons[e2.attribute("type")] = QIcon(iconPath);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (rootPath.isEmpty()) {
        rootPath = QDir::rootPath();
    }
    MediaIconProvider* iconProvider = new MediaIconProvider();
    iconProvider->setFolderIcon(folderIcon);
    iconProvider->setDefaultFileIcon(defaultFileIcon);
    iconProvider->setFileTypeIcons(icons);
    m_model->setIconProvider(iconProvider);
    m_model->setRootPath(rootPath);
}
示例#7
0
/*
void AdjustNames::resizeEvent( QResizeEvent * event )
{
    int w = event->size().width();
    int h = event->size().height();
    BackFrame->resize(event->size());
    if( w > 300 && h > 150 )
    {
        Cancel->setGeometry(w-85,h-36,77,26);
        Next->setGeometry(w-168,h-36,77,26);
        line->setGeometry(14,h-53,w-21,16);
        title->setGeometry(220,21,w-299,18);
        instructions->setGeometry(220,h-79,w-229,18);
        tableWidget->setGeometry(220, 45, w-229, h-130);
    }
}
*/
void AdjustNames::show()
{
    QDialog::show();

    scenarioName->setText(QString(     "Scenario Name:       ") + extractor->setup->scenarioName->text());
    scenarioDirectory->setText(QString("Scenario Directory:  ") + extractor->setup->scenarioDirectory->text());

    tableWidget->clearContents();
    tableWidget->setRowCount(0);

    tableWidget->horizontalHeaderItem(0)->setToolTip("This is the node id used by the EXata/QualNet simulator and GUI");
    tableWidget->horizontalHeaderItem(1)->setToolTip("This is the name used by the HLA federate that published the entity");
    tableWidget->horizontalHeaderItem(2)->setToolTip("Enter text to change the name that will be used by the EXata/QualNet simulator and GUI");
    tableWidget->horizontalHeaderItem(3)->setToolTip("Enter an icon file name or browse to change the icon used by the EXata/QualNet simulator and GUI");

    QAbstractItemModel* model = tableWidget->model();
    SNT_HLA::NodeSet::iterator it = extractor->ns->begin();
    //QFontMetrics fontMetrics = tableWidget->fontMetrics();
    //int iconWidth = 0;
    while( it != extractor->ns->end() )
    {
        QApplication::processEvents();
        if( extractor == 0 )
            break;
        if( (*it)->entity )
        {
            QString name((*it)->getNodeName());
            int id = (*it)->NodeId;
            QString iconName((*it)->getIconName().c_str());
            QIcon icon(iconName);
            QFileInfo iconInfo(iconName);
            int row = tableWidget->rowCount();
            tableWidget->insertRow(row);
            QModelIndex index = model->index(row, 1, QModelIndex());
            model->setData(index, name);
            index = model->index(row, 2, QModelIndex());
            model->setData(index, name);
            index = model->index(row, 0, QModelIndex());
            model->setData(index, id);
            tableWidget->item(row, 0)->setFlags(0);
            tableWidget->item(row, 1)->setFlags(0);
            FileNameWidget* wid = new FileNameWidget("Open Icon File", extractor->exeHome+"/gui/icons", getImageFilter(),tableWidget);
            wid->setText(iconName);
            wid->setToolTip("Enter an icon file name or browse to change the icon used by the EXata/QualNet simulator and GUI");
            tableWidget->setCellWidget(row, 3, wid);
            tableWidget->item(row,0)->setToolTip("This is the node id used by the EXata/QualNet simulator and GUI");
            tableWidget->item(row,1)->setToolTip("This is the name used by the HLA federate that published the entity");
            tableWidget->item(row,2)->setToolTip("Enter text to change the name that will be used by the EXata/QualNet simulator and GUI");
            tableWidget->resizeColumnToContents(0);
            tableWidget->resizeColumnToContents(1);
            tableWidget->resizeColumnToContents(2);
        }
        //tableWidget->setColumnWidth(3, iconWidth);
        it++;
    }
}
示例#8
0
QIcon SystemEntry::icon() const
{
    const QString &name = iconName();

    if (!name.isEmpty()) {
        return QIcon::fromTheme(name, QIcon::fromTheme("unknown"));
    }

    return QIcon::fromTheme("unknown");
}
示例#9
0
QColor IconColors::dominantColor() const
{
    const QImage img = m_icon.pixmap({32, 32}).toImage();
    if(img.isNull()) {
        qWarning() << "wrong icon" << m_icon << m_icon.name();
        return QColor(Qt::black);
    }
    const int tolerance = 10;
    QVector<uint> hue(360/tolerance, 0);

#ifdef OUTPUT_PIXMAP_DEBUG
    QImage thing(img.size()+QSize(0,1), QImage::Format_ARGB32);
    thing.fill(Qt::white);
#endif

    for (int w=0, cw=img.width(); w<cw; ++w) {
        for (int h=0, ch=img.height(); h<ch; ++h) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
            const QColor c = img.pixelColor(w, h).toHsv();
#else
            const QColor c(img.pixel(w, h));
#endif

            if (c.value()>150 && c.saturation()>20 && c.hue()>=0 && c.alpha()>200) {
                hue[c.hue()/tolerance]++;

#ifdef OUTPUT_PIXMAP_DEBUG
//                 qDebug() << "adopting" << w << "x" << h << c.name() << c.hue();
//                 thing.setPixelColor(w, h, c);
                thing.setPixelColor(w, h, QColor::fromHsv(tolerance*(c.hue()/tolerance), 220, 220));
#endif
            }
        }
    }

    uint dominantHue = 0, biggestAmount = 0;
    for(int i=0; i<hue.size(); ++i) {
        if (hue[i]>biggestAmount) {
            biggestAmount = hue[i];
            dominantHue = i;
        }
    }

    QColor ret = QColor::fromHsv((dominantHue*tolerance + tolerance/2) % 360, 255, 255);

#ifdef OUTPUT_PIXMAP_DEBUG
    qDebug() << "dominant" << dominantHue << hue[dominantHue] << "~=" << ((100*hue[dominantHue])/(img.width()*img.height())) << "% " << iconName();
    thing.setPixelColor(0, img.height(), ret);
    thing.save("/tmp/"+iconName()+".png");
#endif

    return ret;
}
void FolderSelectionWidget::setFolders(QStringList includeDirs, QStringList exclude)
{
    m_listWidget->clear();
    m_mountPoints.clear();

    QList<Solid::Device> devices
        = Solid::Device::listFromType(Solid::DeviceInterface::StorageAccess);

    Q_FOREACH (const Solid::Device& dev, devices) {
        const Solid::StorageAccess* sa = dev.as<Solid::StorageAccess>();
        if (!sa->isAccessible())
            continue;

        QString mountPath = sa->filePath();
        if (!shouldShowMountPoint(mountPath))
            continue;

        m_mountPoints << mountPath;
    }
    m_mountPoints << QDir::homePath();

    m_mountPoints = addTrailingSlashes(m_mountPoints);
    includeDirs = addTrailingSlashes(includeDirs);
    exclude = addTrailingSlashes(exclude);

    QStringList excludeList = exclude;
    Q_FOREACH (const QString& mountPath, m_mountPoints) {
        if (includeDirs.contains(mountPath))
            continue;

        if (exclude.contains(mountPath))
            continue;

        excludeList << mountPath;
    }

    Q_FOREACH (QString url, excludeList) {
        QListWidgetItem* item = new QListWidgetItem(m_listWidget);
        QString display = getFolderDisplayName(url);

        item->setData(Qt::DisplayRole, display);
        item->setData(Qt::WhatsThisRole, url);
        item->setData(UrlRole, url);
        item->setData(Qt::DecorationRole, QIcon::fromTheme(iconName(url)));
        item->setToolTip(makeHomePretty(url));

        m_listWidget->addItem(item);
    }
void LxQtNetworkMonitor::settingsChanged()
{
    m_iconIndex = mPlugin->settings()->value("icon", 1).toInt();
    m_interface = mPlugin->settings()->value("interface").toString();
    if (m_interface.isEmpty())
    {
#ifdef STATGRAB_NEWER_THAN_0_90
        size_t count;
#else
        int count;
#endif
        sg_network_iface_stats* stats = sg_get_network_iface_stats(&count);
        if (count > 0)
            m_interface = QString(stats[0].interface_name);
    }

    m_pic.load(iconName("error"));
}
示例#12
0
// private
void kpTool::createAction ()
{
#if DEBUG_KP_TOOL && 0
    kdDebug () << "kpTool(" << name () << "::createAction()" << endl;
#endif

    if (!m_mainWindow)
    {
        kdError () << "kpTool::createAction() without mw" << endl;
        return;
    }

    KActionCollection *ac = m_mainWindow->actionCollection ();
    if (!ac)
    {
        kdError () << "kpTool::createAction() without ac" << endl;
        return;
    }


    if (m_action)
    {
        // TODO: I don't think this will ever be executed as we are not called
        //       outside of the constructor.
    #if DEBUG_KP_TOOL
        kdDebug () << "\tdeleting existing" << endl;
    #endif
        ac->remove (m_action);
        m_action = 0;
    }


    m_action = new kpToolAction (text (), iconName (), shortcutForKey (m_key),
                                 this, SLOT (slotActionActivated ()),
                                 m_mainWindow->actionCollection (), name ());
    m_action->setExclusiveGroup (QString::fromLatin1 ("Tool Box Actions"));
    m_action->setWhatsThis (description ());

    connect (m_action, SIGNAL (toolTipChanged (const QString &)),
             this, SLOT (slotActionToolTipChanged (const QString &)));
}
示例#13
0
MenuDiskItem::MenuDiskItem(UdisksInfo *info, QWidget *parent)
    : QWidget(parent),
      m_info(info)
{
    setupUi(this);
    
    eject->setIcon(XdgIcon::fromTheme("media-eject"));
    QString iconName(info->iconName());
    
    connect(info, SIGNAL(error(QString)),
            this, SIGNAL(error(QString)));

    if (!iconName.isEmpty())
        diskButton->setIcon(XdgIcon::fromTheme(iconName));
    else
        diskButton->setIcon(XdgIcon::fromTheme("drive-removable-media-usb"));

    setLabel(info->displayName() + " (" + info->fileSystem() + ")");

    setMountStatus(info->isMounted());
}
示例#14
0
/*!
   USBIndicator::indicatorData
   returns the data and icon that needs to be displayed in the universal pop up and indicator menu 
*/
QVariant USBIndicator::indicatorData(int role) const
{
    myDebug() << ">>> USBIndicator::indicatorData, role is " << role;
    switch(role) {
    	case PrimaryTextRole: 
        {
        	QString text = QString(hbTrId("txt_usb_dblist_usb_connected"));
        	return text;
        }
    	case SecondaryTextRole:
        {
        	return mSecDisplayName;
        }
   	 	case DecorationNameRole:
        {
        	QString iconName(KUsbIconFile);
        	return iconName;
        }
    	default: 
        	return QVariant();      
    }
}
// ----------------------------------------------------------------------------
// SisxSilentInstallIndicator::indicatorData
// @see sisxsilentinstallindicator.h
// ----------------------------------------------------------------------------
QVariant SisxSilentInstallIndicator::indicatorData(int role) const
{       
switch(role)
    {
    case PrimaryTextRole: 
        {
        // Set text to first line of indicator.
        QString text("");
        // Check which mode is on.
        if ( mIsInstallProcess  )
            { 
            text.append(QString("Installing"));            
            }       
        else
            {
            text.append(QString("Finalizing installations"));            
            }     
        return text;        
        }
    case SecondaryTextRole:
        {
        // Set text to second line of indicator.
        QString text("");        
        text.append(QString("%1 %").arg(mUpdateValue));      
        return text; 
        }    
    case DecorationNameRole:
    case MonoDecorationNameRole:
        {
        // Get icon for the indicator.
        QString iconName(KSifUiDefaultApplicationIcon);
        return iconName;
        }
    default: 
        return QVariant();      
    }
}
示例#16
0
QString KCupsPrinter::iconName() const
{
    return iconName(type());
}
示例#17
0
QIcon XdgMimeType::icon() const
{
    return XdgIcon::fromTheme((iconName()));
}
示例#18
0
文件: status.cpp 项目: xujb/qutim
QIcon Status::createIcon(Type type, const QString &protocol)
{
	return Icon(iconName(type,protocol));
}
示例#19
0
QIcon KCupsPrinter::icon(cups_ptype_e type)
{
    return QIcon::fromTheme(iconName(type));
}
示例#20
0
QVariant ProfileModel::data(const QModelIndex &index, int role) const {

  if (!index.isValid()) {
    return QVariant();
  }

  if ((index.row() < 0) || (index.row() >= p_cache.count())) {
    return QVariant();
  }

  if (role == Qt::TextAlignmentRole) {
    return int(Qt::AlignLeft | Qt::AlignVCenter);
  }

  if ((role == Qt::DisplayRole) || (role == Qt::EditRole)) {
    switch (index.column()) {

      case PROFILE_MODEL_COLUMN_PROFILEINDEX_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_PROFILEINDEX_KEY];
      case PROFILE_MODEL_COLUMN_NAME_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_NAME_KEY];
      case PROFILE_MODEL_COLUMN_ICON_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_ICON_KEY];

      case PROFILE_MODEL_COLUMN_ENCODER_SELECTED_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_ENCODER_SELECTED_KEY];

      case PROFILE_MODEL_COLUMN_PATTERN_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_PATTERN_KEY];
      case PROFILE_MODEL_COLUMN_FAT32COMPATIBLE_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_FAT32COMPATIBLE_KEY];
      case PROFILE_MODEL_COLUMN_UNDERSCORE_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_UNDERSCORE_KEY];
      case PROFILE_MODEL_COLUMN_2DIGITSTRACKNUM_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_2DIGITSTRACKNUM_KEY];
      case PROFILE_MODEL_COLUMN_SC_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_SC_KEY];
      case PROFILE_MODEL_COLUMN_SC_SCALE_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_SC_SCALE_KEY];
      case PROFILE_MODEL_COLUMN_SC_SIZE_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_SC_SIZE_KEY];
      case PROFILE_MODEL_COLUMN_SC_FORMAT_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_SC_FORMAT_KEY];
      case PROFILE_MODEL_COLUMN_SC_NAME_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_SC_NAME_KEY];
      case PROFILE_MODEL_COLUMN_PL_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_PL_KEY];
      case PROFILE_MODEL_COLUMN_PL_FORMAT_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_PL_FORMAT_KEY];
      case PROFILE_MODEL_COLUMN_PL_NAME_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_PL_NAME_KEY];
      case PROFILE_MODEL_COLUMN_PL_ABS_FILE_PATH_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_PL_ABS_FILE_PATH_KEY];
      case PROFILE_MODEL_COLUMN_PL_UTF8_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_PL_UTF8_KEY];
      case PROFILE_MODEL_COLUMN_INF_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_INF_KEY];
      case PROFILE_MODEL_COLUMN_INF_TEXT_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_INF_TEXT_KEY];
      case PROFILE_MODEL_COLUMN_INF_NAME_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_INF_NAME_KEY];
      case PROFILE_MODEL_COLUMN_INF_SUFFIX_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_INF_SUFFIX_KEY];
      case PROFILE_MODEL_COLUMN_HL_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_HL_KEY];
      case PROFILE_MODEL_COLUMN_HL_FORMAT_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_HL_FORMAT_KEY];
      case PROFILE_MODEL_COLUMN_HL_NAME_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_HL_NAME_KEY];
      case PROFILE_MODEL_COLUMN_CUE_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_CUE_KEY];
      case PROFILE_MODEL_COLUMN_CUE_NAME_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_CUE_NAME_KEY];
      case PROFILE_MODEL_COLUMN_SF_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_SF_KEY];
      case PROFILE_MODEL_COLUMN_SF_NAME_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_SF_NAME_KEY];
      case PROFILE_MODEL_COLUMN_RG_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_RG_KEY];
      case PROFILE_MODEL_COLUMN_ENCODER_LAME_PARAMETERS_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_COLUMN_ENCODER_LAME_PARAMETERS_KEY];
      case PROFILE_MODEL_COLUMN_ENCODER_OGGENC_PARAMETERS_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_COLUMN_ENCODER_OGGENC_PARAMETERS_KEY];
      case PROFILE_MODEL_COLUMN_ENCODER_FLAC_PARAMETERS_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_COLUMN_ENCODER_FLAC_PARAMETERS_KEY];
      case PROFILE_MODEL_COLUMN_ENCODER_FAAC_PARAMETERS_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_COLUMN_ENCODER_FAAC_PARAMETERS_KEY];
      case PROFILE_MODEL_COLUMN_ENCODER_WAVE_PARAMETERS_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_COLUMN_ENCODER_WAVE_PARAMETERS_KEY];
      case PROFILE_MODEL_COLUMN_ENCODER_CUSTOM_PARAMETERS_INDEX : return p_cache.at(index.row())[PROFILE_MODEL_COLUMN_ENCODER_CUSTOM_PARAMETERS_KEY];

    }
  }

  if (role == Qt::DecorationRole) {
    QString iconName(p_cache.at(index.row())[PROFILE_MODEL_ICON_KEY].toString());

    if(!iconName.isEmpty()) {
      KIcon icon(iconName);
      if(!icon.isNull()) {
        return icon;
      }
    }

    return KIcon(DEFAULT_ICON);
  }

  return QVariant();

}
Playlist::PlaylistLayoutEditDialog::PlaylistLayoutEditDialog( QWidget *parent )
    : QDialog( parent )
{
    setupUi( this );

    // -- add tokens to the token pool
    Column tokenValues[] = {
        Album,
        AlbumArtist,
        Artist,
        Bitrate,
        Bpm,
        Comment,
        Composer,
        Directory,
        DiscNumber,
        Divider,
        Filename,
        Filesize,
        Genre,
        GroupLength,
        GroupTracks,
        LastPlayed,
        Labels,
        Length,
        Moodbar,
        PlaceHolder,
        PlayCount,
        Rating,
        SampleRate,
        Score,
        Source,
        Title,
        TitleWithTrackNum,
        TrackNumber,
        Type,
        Year };

    for( uint i = 0; i < sizeof( tokenValues ) / sizeof( tokenValues[0] ); i++ )
        tokenPool->addToken( new Token( columnName( tokenValues[i] ),
                                        iconName( tokenValues[i] ),
                                        static_cast<qint64>(tokenValues[i]) ) );

    m_firstActiveLayout = LayoutManager::instance()->activeLayoutName();

    //add an editor to each tab
    for( int part = 0; part < PlaylistLayout::NumParts; part++ )
        m_partsEdit[part] = new Playlist::LayoutEditWidget( this );
    m_layoutsMap = new QMap<QString, PlaylistLayout>();

    elementTabs->addTab( m_partsEdit[PlaylistLayout::Head], i18n( "Head" ) );
    elementTabs->addTab( m_partsEdit[PlaylistLayout::StandardBody], i18n( "Body" ) );
    elementTabs->addTab( m_partsEdit[PlaylistLayout::VariousArtistsBody], i18n( "Body (Various artists)" ) );
    elementTabs->addTab( m_partsEdit[PlaylistLayout::Single], i18n( "Single" ) );

    QStringList layoutNames = LayoutManager::instance()->layouts();
    foreach( const QString &layoutName, layoutNames )
    {
        PlaylistLayout layout = LayoutManager::instance()->layout( layoutName );
        layout.setDirty( false );
        m_layoutsMap->insert( layoutName, layout );
    }
示例#22
0
void MacBundler::showSettingsDialogFor(ProjectPtr project)
{
    // project->GetSettings()->GetGlobalSettings();
    // project->GetSettings()->GetBuildConfiguration(name);

    ProjectSettingsCookie cookie;

    ProjectSettingsPtr settings = project->GetSettings();
    if(not settings) {
        wxMessageBox(_("Cannot continue, impossible to access project settings."));
        return;
    }

    std::map<wxString, BuildConfigPtr> configs;
    wxArrayString choices;

    // TODO: allow putting the rules in the config root and not in every target
    BuildConfigPtr buildConfig = settings->GetFirstBuildConfiguration(cookie);
    while(buildConfig) {

        configs[buildConfig->GetName()] = buildConfig;
        choices.Add(buildConfig->GetName());

        buildConfig = settings->GetNextBuildConfiguration(cookie);
    }

    bool accepted = false;
    bool generateInfoPlistFile = false;
    bool generateIcon = false;

    wxArrayString targetsToSet;

    wxString iconName(wxT("icon.icns"));

    {
        BundleConfigDialog configDlg(project, m_mgr->GetTheApp()->GetTopWindow(), choices, m_mgr);
        configDlg.ShowModal();
        accepted = configDlg.getResults(targetsToSet, &generateInfoPlistFile, &generateIcon);
        iconName = configDlg.getIconDestName();

        if(accepted and generateInfoPlistFile) {
            wxFileName projPath = project->GetFileName();
            projPath.SetFullName(wxT(""));
            const wxString projectDirName = projPath.GetFullPath();
            const wxString infoPlistFile = projectDirName + wxT("/Info.plist");

            if(wxFileExists(infoPlistFile)) {
                int out = wxMessageBox(wxString::Format(_("The following file:\n%s\nalready exists, overwrite it?\n"),
                                                        infoPlistFile.c_str()),
                                       _("Warning"),
                                       wxYES_NO);
                if(out == wxYES) {
                    wxTextFile file;
                    file.Open(infoPlistFile);
                    file.Clear();
                    configDlg.writeInfoPlistFile(file);
                    file.Close();
                }
            } else {
                wxTextFile file;
                if(not file.Create(infoPlistFile)) {
                    wxMessageBox(_("Could not create Info.plist file\n") + infoPlistFile);
                } else {
                    configDlg.writeInfoPlistFile(file);
                    file.Close();
                }
            }

            if(wxFileExists(infoPlistFile)) {
                // FIXME: if the file was already present, it will be added again and appear twice in the file tree
                wxArrayString paths;
                paths.Add(infoPlistFile);
                m_mgr->CreateVirtualDirectory(project->GetName(), wxT("osx"));
                m_mgr->AddFilesToVirtualFolder(project->GetName() + wxT(":osx"), paths);
            }
        } // nend if create info.plist

        if(accepted and generateIcon) {
            wxString iconSourcePath = configDlg.getIconSource();
            if(not iconSourcePath.IsEmpty()) {
                // sips doesn't like double slashes in path names
                iconSourcePath.Replace(wxT("//"), wxT("/"));

                wxFileName projPath = project->GetFileName();
                projPath.SetFullName(wxT(""));
                const wxString projectDirName = projPath.GetFullPath();
                wxString iconFileDest = projectDirName + wxT("/") + configDlg.getIconDestName();

                // sips doesn't like double slashes in path names
                iconFileDest.Replace(wxT("//"), wxT("/"));

                std::cout << "Copying icon '" << iconSourcePath.mb_str() << "' to project\n";

                if(iconSourcePath.EndsWith(wxT(".icns"))) {
                    if(not wxCopyFile(iconSourcePath, iconFileDest)) {
                        wxMessageBox(_("Sorry, could not copy icon"));
                    }
                } else {
                    wxString cmd =
                        wxT("sips -s format icns '") + iconSourcePath + wxT("' --out '") + iconFileDest + wxT("'");
                    std::cout << cmd.mb_str() << std::endl;
                    wxExecute(cmd, wxEXEC_SYNC);
                    if(not wxFileExists(iconFileDest)) {
                        wxMessageBox(_("Sorry, could not convert selected icon to icns format"));
                    }
                }

                // FIXME: if the file was already present, it will be added again and appear twice in the file tree
                if(wxFileExists(iconFileDest)) {
                    wxArrayString paths;
                    paths.Add(iconFileDest);
                    m_mgr->CreateVirtualDirectory(project->GetName(), wxT("osx"));
                    m_mgr->AddFilesToVirtualFolder(project->GetName() + wxT(":osx"), paths);
                }
            } // end if icon not null
        }     // end if generate icon
    }
    if(!accepted) return;

    for(int n = 0; n < targetsToSet.GetCount(); n++) {
        BuildConfigPtr buildConfig = configs[targetsToSet[n]];

        wxString outputFileName = buildConfig->GetOutputFileName();
        wxString output = wxT("$(ProjectName).app/Contents/MacOS/$(ProjectName)");
        buildConfig->SetOutputFileName(wxT("$(IntermediateDirectory)/") + output);
        buildConfig->SetCommand(wxT("./") + output);

        if(generateInfoPlistFile or generateIcon) {
            // get existing custom makefile targets, if any
            wxString customPreBuild = buildConfig->GetPreBuildCustom();

            wxString deps, rules;
            deps = customPreBuild.BeforeFirst(wxT('\n'));
            rules = customPreBuild.AfterFirst(wxT('\n'));

            rules = rules.Trim();
            rules = rules.Trim(false);

            deps = deps.Trim();
            deps = deps.Trim(false);

            if(generateInfoPlistFile) {
                // augment existing rules with new rules to manage Info.plist file
                deps.Append(wxT(" $(IntermediateDirectory)/$(ProjectName).app/Contents/Info.plist"));
                rules.Append(wxString(wxT("\n## rule to copy the Info.plist file into the bundle\n")) +
                             wxT("$(IntermediateDirectory)/$(ProjectName).app/Contents/Info.plist: Info.plist\n") +
                             wxT("\tmkdir -p '$(IntermediateDirectory)/$(ProjectName).app/Contents' && cp -f "
                                 "Info.plist '$(IntermediateDirectory)/$(ProjectName).app/Contents/Info.plist'"));
            }
            if(generateIcon) {
                // augment existing rules with new rules to manage Info.plist file
                deps.Append(wxT(" $(IntermediateDirectory)/$(ProjectName).app/Contents/Resources/") + iconName);
                rules.Append(
                    wxT("\n## rule to copy the icon file into the "
                        "bundle\n$(IntermediateDirectory)/$(ProjectName).app/Contents/Resources/") +
                    iconName + wxT(": ") + iconName +
                    wxT("\n\tmkdir -p '$(IntermediateDirectory)/$(ProjectName).app/Contents/Resources/' && cp -f ") +
                    iconName + wxT(" '$(IntermediateDirectory)/$(ProjectName).app/Contents/Resources/") + iconName +
                    wxT("'"));
            }

            // set the new rules
            rules = rules.Trim();
            rules = rules.Trim(false);
            deps = deps.Trim();
            deps = deps.Trim(false);

            wxString prebuilstep;
            prebuilstep << deps << wxT("\n");
            prebuilstep << rules;
            prebuilstep << wxT("\n");

            // Set the content only if there is real content to add
            wxString tmpPreBuildStep(prebuilstep);
            tmpPreBuildStep.Trim().Trim(false);
            buildConfig->SetPreBuildCustom(prebuilstep);
        } // end if

        settings->SetBuildConfiguration(buildConfig);

    } // end for

    project->SetSettings(settings);
}
示例#23
0
PassRefPtr<Image> Image::loadPlatformResource(const char *name)
{
#if PLATFORM(BLACKBERRY)
    return ResourceBlackBerry::loadPlatformImageResource(name);
#else
    //FIXME: Either load a "proper" icon instead of drawing one, or get this
    //       upstream as cross-platform default implementation (or both).
    OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(IntSize(16, 16));
    if (!imageBuffer)
        return 0;

    String iconName(name); // a.k.a. "enable string comparisons with =="

    if (iconName == "missingImage") {
        // Draw a fancy red x-shaped icon.
        GraphicsContext* context = imageBuffer->context();
        context->save();

        context->fillRect(FloatRect(0, 0, 16, 16), Color::white, DeviceColorSpace);

        context->setStrokeStyle(SolidStroke);
        context->setStrokeThickness(1.7);
        context->setStrokeColor(Color(48, 48, 48), DeviceColorSpace);
        context->setFillColor(Color(200, 30, 0), DeviceColorSpace);

        context->translate(8, 8);

        context->rotate(piDouble / 4.0);
        context->strokeRect(FloatRect(-1.5, -7, 3, 14));

        context->rotate(-piDouble / 2.0);
        context->strokeRect(FloatRect(-1.5, -7, 3, 14));
        context->fillRect(FloatRect(-1.5, -7, 3, 14));

        context->rotate(piDouble / 2.0);
        context->fillRect(FloatRect(-1.5, -7, 3, 14));

        context->restore();
    } else if (iconName == "searchCancel" || iconName == "searchCancelPressed") {
        // Draw a more subtle, gray x-shaped icon.
        GraphicsContext* context = imageBuffer->context();
        context->save();

        context->fillRect(FloatRect(0, 0, 16, 16), Color::white, DeviceColorSpace);

        if (iconName.length() == sizeof("searchCancel") - 1)
            context->setFillColor(Color(128, 128, 128), DeviceColorSpace);
        else
            context->setFillColor(Color(64, 64, 64), DeviceColorSpace);

        context->translate(8, 8);

        context->rotate(piDouble / 4.0);
        context->fillRect(FloatRect(-1, -7, 2, 14));

        context->rotate(-piDouble / 2.0);
        context->fillRect(FloatRect(-1, -7, 2, 14));

        context->restore();
    }

    return imageBuffer->copyImage();
#endif
}
示例#24
0
QIcon XdgMimeInfo::icon() const
{
    return XdgIcon::fromTheme(iconName());
}