QSelectFaceWidget::QSelectFaceWidget(const QString &faceIconDir, QWidget *parent) : QWidget(parent), faceIconDir(faceIconDir), iconNumber(0) { this->setWindowFlags(Qt::Popup); QFileInfo iconDir(faceIconDir); if (!iconDir.isDir()) { QDir dir; dir.mkpath(faceIconDir); } QFileInfoList InfoList = QDir(faceIconDir).entryInfoList(); if (InfoList.size()<12) { QList<QString> emotionNameList; Global::InitEmotionNameList(emotionNameList); QString emotionName; foreach(emotionName, emotionNameList) this->DownloadEmotionIcons(emotionName); return ; } this->SetEmotionGridLayout(); qDebug() << "\t" << "Get faces done!"; }
QIconTheme::QIconTheme(const QString &themeName) : m_valid(false) { QFile themeIndex; QList <QIconDirInfo> keyList; QStringList iconDirs = QIcon::themeSearchPaths(); for ( int i = 0 ; i < iconDirs.size() ; ++i) { QDir iconDir(iconDirs[i]); QString themeDir = iconDir.path() + QLatin1Char('/') + themeName; themeIndex.setFileName(themeDir + QLatin1String("/index.theme")); if (themeIndex.exists()) { m_contentDir = themeDir; m_valid = true; QStringList themeSearchPaths = QIcon::themeSearchPaths(); foreach (QString path, themeSearchPaths) { if (!path.startsWith(':') && QFileInfo(path).isDir()) m_contentDirs.append(path + QLatin1Char('/') + themeName); } break; } }
void buddyPicture::saveAvatar(quint16 length) { quint8 uinLength = convertToInt8(buffer->read(1)); length -= 1; QString uin = QString::fromUtf8(buffer->read(uinLength)); length -= uinLength; buffer->read(4); length -= 4; QByteArray hash = buffer->read(16); length -= 16; buffer->read(21); length -= 21; quint16 iconLength = convertToInt16(buffer->read(2)); length -= 2; if ( iconLength ) { QSettings settings(QSettings::NativeFormat, QSettings::UserScope, "qutim/qutim."+m_profile_name+"/ICQ."+m_mine_uin, "contactlist"); settings.beginGroup(uin); settings.setValue("iconhash", hash.toHex()); settings.endGroup(); QString iconPath = settings.fileName().section('/', 0, -3) + "/icqicons"; QDir iconDir(iconPath); if ( !iconDir.exists() ) iconDir.mkpath(iconPath); QFile iconFile(iconPath + "/" + hash.toHex()); if ( iconFile.open(QIODevice::WriteOnly) ) { iconFile.write(buffer->read(iconLength)); } emit updateAvatar(uin, hash); } length -= iconLength; if ( length ) buffer->read(length); }
bool HsBookmarkPublishClient::saveFavicon(const QString Url, const QString iconFileName) { QIcon icon; QDir iconDir(BEDROCK_PROVISIONING::BedrockProvisioning::createBedrockProvisioning()->valueAsString("DataBaseDirectory")); QUrl url(Url); // Retrieve the favicon and check its exsistance icon = QWebSettings::iconForUrl(url); if (icon.isNull()) return false; QString iconPath = iconDir.filePath(iconFileName); QFile iconFile(iconPath); iconFile.open(QIODevice::WriteOnly); QPixmap pixmap = icon.pixmap(30, 30); pixmap.save(&iconFile, "PNG"); iconFile.close(); return true; }
void IconManager::readIconConfigFiles() { QString baseIconDir(ScPaths::instance().iconDir()); QStringList locations; locations<<baseIconDir; QStringList configNames; for ( QStringList::Iterator it = locations.begin(); it != locations.end(); ++it ) { QFileInfo iconDir(*it); if (!iconDir.exists()) continue; QDir id(*it, "*.xml", QDir::Name, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files | QDir::NoSymLinks); if (!id.exists() || (id.count() == 0)) continue; for (uint i = 0; i < id.count(); ++i) { QFileInfo file(*it + id[i]); //qDebug()<<file.absoluteFilePath(); QFile dataFile(file.absoluteFilePath()); if (!dataFile.exists()) continue; dataFile.open(QIODevice::ReadOnly); QTextStream ts(&dataFile); ts.setCodec(QTextCodec::codecForName("UTF-8")); QString errorMsg; int eline; int ecol; QDomDocument xmlData( QString(file.baseName())); QString data(ts.readAll()); dataFile.close(); if ( !xmlData.setContent( data, &errorMsg, &eline, &ecol )) { qDebug()<<data<<errorMsg<<eline<<ecol; if (data.toLower().contains("404 not found")) qDebug()<<"File not found on server"; else qDebug()<<"Could not open file"<<dataFile.fileName(); continue; } QDomElement docElem = xmlData.documentElement(); QDomNode n = docElem.firstChild(); ScIconSetData isd; while( !n.isNull() ) { QDomElement e = n.toElement(); if( !e.isNull() ) { //qDebug()<<e.tagName()<<e.text(); if (e.tagName()=="path") { isd.path=e.text(); } else if (e.tagName()=="author") { isd.author=e.text(); } else if (e.tagName()=="license") { isd.license=e.text(); } else if (e.tagName()=="activeversion") { isd.activeversion=e.text(); } else if (e.tagName()=="nametext") { if (e.hasAttribute("lang")) { isd.nameTranslations.insert(e.attribute("lang"),e.text()); if (e.attribute("lang")=="en_US") isd.baseName=e.text(); } } } n = n.nextSibling(); } //just in case there's no en_US basename if (!isd.baseName.isEmpty()) { m_iconSets.insert(isd.baseName, isd); if(!isd.activeversion.isEmpty()) { int av_major, av_minor, av_patch, curr_major, curr_minor, curr_patch, ver_major, ver_minor, ver_patch; av_major=isd.activeversion.section(".",0,0).toInt(); av_minor=isd.activeversion.section(".",1,1).toInt(); av_patch=isd.activeversion.section(".",2,2).toInt(); curr_major=m_activeSetVersion.section(".",0,0).toInt(); curr_minor=m_activeSetVersion.section(".",1,1).toInt(); curr_patch=m_activeSetVersion.section(".",2,2).toInt(); ver_major=QString(VERSION).section(".",0,0).toInt(); ver_minor=QString(VERSION).section(".",1,1).toInt(); ver_patch=QString(VERSION).section(".",2,2).toInt(); //If iconset version <= app version, and iconset version >= current active iconset version if (av_major<=ver_major && av_minor<=ver_minor && av_patch<=ver_patch && ( av_major>=curr_major || (av_major==curr_major && av_minor>=curr_minor) || (av_major==curr_major && av_minor==curr_minor && av_patch>=curr_patch) ) ) { m_backupSetBasename=m_activeSetBasename; m_backupSetVersion=m_backupSetVersion; m_activeSetBasename=isd.baseName; m_activeSetVersion=isd.activeversion; //qDebug()<<"backupSetBasename"<<m_backupSetBasename<<"activeSetBasename"<<m_activeSetBasename; } } } } } }
QIconTheme::QIconTheme(const QString &themeName) : m_valid(false) { QFile themeIndex; QList <QIconDirInfo> keyList; QStringList iconDirs = QIcon::themeSearchPaths(); for ( int i = 0 ; i < iconDirs.size() ; ++i) { QDir iconDir(iconDirs[i]); QString themeDir = iconDir.path() + QLatin1Char('/') + themeName; themeIndex.setFileName(themeDir + QLatin1String("/index.theme")); if (themeIndex.exists()) { m_contentDir = themeDir; m_valid = true; break; } } #ifndef QT_NO_SETTINGS if (themeIndex.exists()) { const QSettings indexReader(themeIndex.fileName(), QSettings::IniFormat); QStringListIterator keyIterator(indexReader.allKeys()); while (keyIterator.hasNext()) { const QString key = keyIterator.next(); if (key.endsWith(QLatin1String("/Size"))) { // Note the QSettings ini-format does not accept // slashes in key names, hence we have to cheat if (int size = indexReader.value(key).toInt()) { QString directoryKey = key.left(key.size() - 5); QIconDirInfo dirInfo(directoryKey); dirInfo.size = size; QString type = indexReader.value(directoryKey + QLatin1String("/Type") ).toString(); if (type == QLatin1String("Fixed")) dirInfo.type = QIconDirInfo::Fixed; else if (type == QLatin1String("Scalable")) dirInfo.type = QIconDirInfo::Scalable; else dirInfo.type = QIconDirInfo::Threshold; dirInfo.threshold = indexReader.value(directoryKey + QLatin1String("/Threshold"), 2).toInt(); dirInfo.minSize = indexReader.value(directoryKey + QLatin1String("/MinSize"), size).toInt(); dirInfo.maxSize = indexReader.value(directoryKey + QLatin1String("/MaxSize"), size).toInt(); m_keyList.append(dirInfo); } } } // Parent themes provide fallbacks for missing icons m_parents = indexReader.value( QLatin1String("Icon Theme/Inherits")).toStringList(); // Ensure a default platform fallback for all themes if (m_parents.isEmpty()) { const QString fallback = fallbackTheme(); if (!fallback.isEmpty()) m_parents.append(fallback); } // Ensure that all themes fall back to hicolor if (!m_parents.contains(QLatin1String("hicolor"))) m_parents.append(QLatin1String("hicolor")); } #endif //QT_NO_SETTINGS }
// // Step 6 // Extract icon and create .desktop files // bool InstallWindow::Step6CreateShortcuts() { PrintStep(tr("Prepare desktop shortcut")); QDir desktopDir(DESKTOP_ENTRY_PATH), iconDir(ICONS_PATH), dbusDir(DBUS_PATH); if (!desktopDir.exists()) { if (!desktopDir.mkpath(DESKTOP_ENTRY_PATH)) return Failed(tr("Cannot create directory %1") .arg(desktopDir.path())); } if (!iconDir.exists()) { if (!iconDir.mkpath(ICONS_PATH)) return Failed(tr("Cannot create directory %1") .arg(iconDir.path())); } if (!dbusDir.exists()) { if (!dbusDir.mkpath(DBUS_PATH)) return Failed(tr("Cannot create directory %1") .arg(dbusDir.path())); } // Icon path QString fullDataDir(_game->DataPath() + "/usr/palm/applications/" + _game->JsonID() + "/"); QFile iconFile(fullDataDir + _game->JsonIcon()); QString saneName =_game->JsonTitle().toLower(); QString newName(QString(ICONS_PATH) + QString("/") + saneName + ".png"); if (iconFile.exists() && !QFile::exists(newName)) { if (!iconFile.copy(newName)) { return Failed(tr("Cannot copy icon ") + iconFile.fileName() + "to " + ICONS_PATH + "/" + saneName + ".png"); } } QString desktopEntry = "[Desktop Entry]\n" "Encoding=UTF-8\n" "Version=1.0\n" "Type=Application\n" "Name=" + _game->JsonTitle() + "\n" "Exec=" + _game->Exec() + "\n" "X-Osso-Type=application/x-executable\n" "X-Osso-Service=" + _game->DBusName() + "\n" "X-Preenv-Generated=true\n" "X-Preenv-Vendor=" + _game->JsonVendor() + "\n" "X-Maemo-Category=Games\n" "Icon=" + saneName + "\n"; QFile desktopFile(QString(DESKTOP_ENTRY_PATH) + QString("/") + saneName + ".desktop"); if (!desktopFile.open(QFile::WriteOnly | QFile::Text)) return Failed(tr("Cannot create .desktop file ") + desktopFile.fileName()); desktopFile.write(desktopEntry.toLocal8Bit()); desktopFile.close(); QString dbusEntry = "[D-BUS Service]\n" "Name=" + _game->DBusName() + "\n" "Exec=" + _game->Exec() + "\n"; QFile dbusFile(QString(DBUS_PATH) + QString("/") + saneName + ".service"); if (!dbusFile.open(QFile::WriteOnly | QFile::Text)) return Failed(tr("Cannot create DBUS .service file ") + dbusFile.fileName()); dbusFile.write(dbusEntry.toLocal8Bit()); dbusFile.close(); PrintOK(); return Step7PostInstall(); }
DownloadWidget::DownloadWidget(QWidget *parent) : QWidget(parent), m_manager(new QNetworkAccessManager(this)), m_downloadMode(Tiles), m_tabWidget(new QTabWidget(this)), m_dlProgress(new QProgressBar(this)), m_startButton(new QPushButton("&Start download", this)), m_backButton(new QPushButton("&Back", this)), m_startLevel(0), m_dlRect(), m_dlList(), m_currentDownload(0), m_prefix("OSM"), m_up(new QLabel("N 0", this)), m_left(new QLabel("E 0", this)), m_right(new QLabel("E 0", this)), m_bottom(new QLabel("N 0", this)), m_levelSpinBox(new QSpinBox(this)), m_prefixInput(new QLineEdit(this)), m_skipExisting(new QCheckBox("S&kip already downloaded tiles", this)), m_poiTypes(new QListWidget(this)), m_makePOILayer(new QCheckBox("&Load file after download", this)), m_destFilename(new QLineEdit(QDir::homePath()+"/pois.osm", this)), m_packageList(new QListWidget(this)), m_destDir(new QLineEdit(QDir::homePath(), this)) { QGridLayout *layout = new QGridLayout(this); layout->setContentsMargins(0, 0, 0, 0); layout->setRowStretch(0, 1); layout->addWidget(m_tabWidget, 0, 0, 1, 2); m_dlProgress->hide(); layout->addWidget(m_dlProgress, 1, 0, 1, 2); m_startButton->setIcon(QIcon(":ok.png")); connect(m_startButton, SIGNAL(clicked()), this, SLOT(startDownload())); layout->addWidget(m_startButton, 2, 0); m_backButton->setIcon(QIcon(":cancel.png")); connect(m_backButton, SIGNAL(clicked()), this, SIGNAL(back())); layout->addWidget(m_backButton, 2, 1); QWidget *widget = new QWidget(this); layout = new QGridLayout(widget); layout->setContentsMargins(0, 0, 0, 0); layout->setRowStretch(1, 1); m_up->setAlignment(Qt::AlignHCenter); m_left->setAlignment(Qt::AlignLeft | Qt::AlignVCenter); m_right->setAlignment(Qt::AlignRight | Qt::AlignVCenter); m_bottom->setAlignment(Qt::AlignHCenter); layout->addWidget(m_up, 0, 0, 1, 4); layout->addWidget(m_left, 1, 0); layout->addWidget(m_right, 1, 3); layout->addWidget(m_bottom, 2, 0, 1, 4); QLabel *label = new QLabel(this); label->setFrameShape(QLabel::Box); layout->addWidget(label, 1, 1, 1, 2); label = new QLabel("Download up to level:", this); layout->addWidget(label, 3, 0, 1, 2); m_levelSpinBox->setRange(0, 18); layout->addWidget(m_levelSpinBox, 3, 2, 1, 2); label = new QLabel("Download into directory:", this); layout->addWidget(label, 4, 0, 1, 2); m_prefixInput->setText(m_prefix); layout->addWidget(m_prefixInput, 4, 2, 1, 2); m_skipExisting->setChecked(false); layout->addWidget(m_skipExisting, 5, 0, 1, 0); m_tabWidget->addTab(widget, "&Tiles"); widget = new QWidget(this); layout = new QGridLayout(widget); layout->setContentsMargins(0, 0, 0, 0); layout->setRowStretch(0, 1); QSettings set(QDir::homePath()+"/Maps/nanomap.conf", QSettings::NativeFormat); set.beginGroup("poi"); QString iconPath = set.value("iconpath", "/usr/share/NanoMap/icons").toString(); set.endGroup(); QDir iconDir(iconPath); QStringList icons = iconDir.entryList(QStringList() << "*.png"); foreach (const QString &icon, icons) { QString name = icon; name.remove(".png"); QListWidgetItem *item = new QListWidgetItem(QIcon(iconPath+"/"+icon), name); m_poiTypes->addItem(item); }