예제 #1
0
QIcon RecaptchaPluginConfig::icon() const {
    const QPixmap icon = ImageCache::instance()->image(iconFilePath());

    if (icon.isNull()) {
        connect(ImageCache::instance(), SIGNAL(imageReady(QString)), this, SLOT(onImageReady(QString)));
        return QPixmap(DEFAULT_ICON);
    }

    return icon;
}
예제 #2
0
QPixmap IconManager::loadPixmap(const QString nam, bool forceUseColor)
{
	if (m_pxCache.contains(nam))
		return *m_pxCache[nam];

	QString iconFilePath(pathForIcon(nam));
	QPixmap *pm = new QPixmap();
	pm->load(iconFilePath);
	if (pm->isNull())
		qWarning("Unable to load icon %s: Got null pixmap", iconFilePath.toLatin1().constData());
//	else
//		qDebug()<<"Successful icon load from"<<iconFilePath;
	if (PrefsManager::instance()->appPrefs.uiPrefs.grayscaleIcons && !forceUseColor)
		iconToGrayscale(pm);
	m_pxCache.insert(nam, pm);
	return *pm;
}
예제 #3
0
파일: util_icon.cpp 프로젝트: JLuc/scribus
QPixmap loadIcon(const QString nam, bool forceUseColor)
{
	static ScPixmapCache<QString> pxCache;
	if (pxCache.contains(nam))
		return *pxCache[nam];

	QString iconFilePath(QString("%1%2").arg(ScPaths::instance().iconDir()).arg(nam));
	QPixmap *pm = new QPixmap();
	
	if (!QFile::exists(iconFilePath))
		qWarning("Unable to load icon %s: File not found", iconFilePath.toLatin1().constData());
	else
	{
		pm->load(iconFilePath);
		if (pm->isNull())
			qWarning("Unable to load icon %s: Got null pixmap", iconFilePath.toLatin1().constData());
		if (PrefsManager::instance()->appPrefs.uiPrefs.grayscaleIcons && !forceUseColor)
			iconToGrayscale(pm);
	}
	pxCache.insert(nam, pm);
	return *pm;
}
예제 #4
0
QPixmap loadIcon(const QString nam, bool forceUseColor)
{
	static ScPixmapCache<QString> pxCache;
	if (pxCache.contains(nam))
		return *pxCache[nam];

	QString iconFilePath(QString("%1%2").arg(ScPaths::instance().iconDir()).arg(nam));
	QPixmap *pm = new QPixmap();
	
	if (!QFile::exists(iconFilePath))
		qWarning("Unable to load icon %s: File not found", iconFilePath.toAscii().constData());
	else
	{
		pm->load(iconFilePath);
		if (pm->isNull())
			qWarning("Unable to load icon %s: Got null pixmap", iconFilePath.toAscii().constData());
		if (PrefsManager::instance()->appPrefs.grayscaleIcons && !forceUseColor)
		{
			QImage qi(pm->toImage());
			int h=qi.height();
			int w=qi.width();
			QRgb c_rgb;
			for (int i=0;i<w;++i)
			{
				for (int j=0;j<h;++j)
				{
					c_rgb=qi.pixel(i,j);
					int k = qMin(qRound(0.3 * qRed(c_rgb) + 0.59 * qGreen(c_rgb) + 0.11 * qBlue(c_rgb)), 255);
					qi.setPixel(i, j, qRgba(k, k, k, qAlpha(c_rgb)));
				}
			}
			*pm=QPixmap::fromImage(qi);
		}
	}
	pxCache.insert(nam, pm);
	return *pm;
}
예제 #5
0
void RecaptchaPluginConfig::onImageReady(const QString &path) {
    if (path == iconFilePath()) {
        emit changed(this);
        disconnect(ImageCache::instance(), SIGNAL(imageReady(QString)), this, SLOT(onImageReady(QString)));
    }
}
예제 #6
0
NS_IMETHODIMP
nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes,
                                       PRBool aForAllUsers)
{
#ifdef DEBUG
  if (aForAllUsers)
    NS_WARNING("Setting the default browser for all users is not yet supported");
#endif

  nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);

  nsCAutoString schemeList;
  nsCAutoString appKeyValue(mAppPath + NS_LITERAL_CSTRING(" \"%s\""));
  unsigned int i;

  for (i = 0; i < NS_ARRAY_LENGTH(appProtocols); ++i) {
    schemeList.Append(nsDependentCString(appProtocols[i].name)
                      + NS_LITERAL_CSTRING(","));

    if (appProtocols[i].essential || aClaimAllTypes) {
      gconf->SetAppForProtocol(nsDependentCString(appProtocols[i].name),
                               appKeyValue);
    }
  }

  if (aClaimAllTypes) {
    nsCOMPtr<nsIGnomeVFSService> vfs =
      do_GetService(NS_GNOMEVFSSERVICE_CONTRACTID);

    nsCOMPtr<nsIStringBundleService> bundleService =
      do_GetService(NS_STRINGBUNDLE_CONTRACTID);
    NS_ENSURE_TRUE(bundleService, NS_ERROR_OUT_OF_MEMORY);

    nsCOMPtr<nsIStringBundle> brandBundle;
    bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle));
    NS_ENSURE_TRUE(brandBundle, NS_ERROR_FAILURE);

    nsXPIDLString brandShortName, brandFullName;
    brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
                                   getter_Copies(brandShortName));
    brandBundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(),
                                   getter_Copies(brandFullName));

    // use brandShortName as the application id.
    NS_ConvertUTF16toUTF8 id(brandShortName);

    vfs->SetAppStringKey(id, nsIGnomeVFSService::APP_KEY_COMMAND, mAppPath);
    vfs->SetAppStringKey(id, nsIGnomeVFSService::APP_KEY_NAME,
                         NS_ConvertUTF16toUTF8(brandFullName));

    // We don't want to be the default handler for "file:", but we do
    // want Nautilus to know that we support file: if the MIME type is
    // one that we can handle.

    schemeList.Append("file");

    vfs->SetAppStringKey(id, nsIGnomeVFSService::APP_KEY_SUPPORTED_URI_SCHEMES,
                         schemeList);

    vfs->SetAppStringKey(id, nsIGnomeVFSService::APP_KEY_EXPECTS_URIS,
                         NS_LITERAL_CSTRING("true"));

    vfs->SetAppBoolKey(id, nsIGnomeVFSService::APP_KEY_CAN_OPEN_MULTIPLE,
                       PR_FALSE);

    vfs->SetAppBoolKey(id, nsIGnomeVFSService::APP_KEY_REQUIRES_TERMINAL,
                       PR_FALSE);

    // Copy icons/document.png to ~/.icons/firefox-document.png
    nsCAutoString iconFilePath(mAppPath);
    PRInt32 lastSlash = iconFilePath.RFindChar(PRUnichar('/'));
    if (lastSlash == -1) {
      NS_ERROR("no slash in executable path?");
    } else {
      iconFilePath.Truncate(lastSlash);
      nsCOMPtr<nsILocalFile> iconFile;
      NS_NewNativeLocalFile(iconFilePath, PR_FALSE, getter_AddRefs(iconFile));
      if (iconFile) {
        iconFile->AppendRelativeNativePath(NS_LITERAL_CSTRING("icons/document.png"));

        nsCOMPtr<nsILocalFile> userIconPath;
        NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), PR_FALSE,
                              getter_AddRefs(userIconPath));
        if (userIconPath) {
          userIconPath->AppendNative(NS_LITERAL_CSTRING(".icons"));
          iconFile->CopyToNative(userIconPath,
                                 nsDependentCString(kDocumentIconPath));
        }
      }
    }

    for (i = 0; i < NS_ARRAY_LENGTH(appTypes); ++i) {
      vfs->AddMimeType(id, nsDependentCString(appTypes[i].mimeType));
      vfs->SetMimeExtensions(nsDependentCString(appTypes[i].mimeType),
                             nsDependentCString(appTypes[i].extensions));
      vfs->SetAppForMimeType(nsDependentCString(appTypes[i].mimeType), id);
      vfs->SetIconForMimeType(nsDependentCString(appTypes[i].mimeType),
                              NS_LITERAL_CSTRING(kDocumentIconPath));
    }

    vfs->SyncAppRegistry();
  }

  return NS_OK;
}