コード例 #1
0
ファイル: statusicons.cpp プロジェクト: ZerGabriel/vacuum-im
void StatusIcons::loadStorages()
{
	clearStorages();
	QList<QString> storages = FileStorage::availSubStorages(RSR_STORAGE_STATUSICONS) << FILE_STORAGE_SHARED_DIR;
	foreach(const QString &substorage, storages)
	{
		LOG_DEBUG(QString("Status icon storage added, storage=%1").arg(substorage));

		IconStorage *storage = new IconStorage(RSR_STORAGE_STATUSICONS,substorage,this);
		FStorages.insert(substorage,storage);

		QString pattern = storage->storageProperty(STATUSICONS_STORAGE_PATTERN);
		if (!pattern.isEmpty())
		{
			insertRule(pattern,substorage,IStatusIcons::DefaultRule);
			FStatusRules += pattern;
		}

		Action *action = new Action(FCustomIconMenu);
		action->setCheckable(true);
		action->setIcon(storage->getIcon(SIK_ONLINE));
		action->setText(storage->storageProperty(FILE_STORAGE_NAME,substorage));
		action->setData(ADR_SUBSTORAGE,substorage);
		connect(action,SIGNAL(triggered(bool)),SLOT(onSetCustomIconsetByAction(bool)));
		
		FCustomIconActions.insert(substorage,action);
		FCustomIconMenu->addAction(action,AG_DEFAULT,true);
	}
コード例 #2
0
ファイル: statusicons.cpp プロジェクト: ZerGabriel/vacuum-im
QIcon StatusIcons::iconByJidStatus(const Jid &AContactJid, int AShow, const QString &ASubscription, bool AAsk) const
{
	QString substorage = iconsetByJid(AContactJid);
	QString iconKey = iconKeyByStatus(AShow,ASubscription,AAsk);
	IconStorage *storage = FStorages.value(substorage,FDefaultStorage);
	return storage!=NULL ? storage->getIcon(iconKey) : QIcon();
}
コード例 #3
0
ファイル: statusicons.cpp プロジェクト: ZerGabriel/vacuum-im
QIcon StatusIcons::iconByJid(const Jid &AStreamJid, const Jid &AContactJid) const
{
	QString substorage = iconsetByJid(AContactJid);
	QString iconKey = iconKeyByJid(AStreamJid, AContactJid);
	IconStorage *storage = FStorages.value(substorage,FDefaultStorage);
	return storage!=NULL ? storage->getIcon(iconKey) : QIcon();
}
コード例 #4
0
ファイル: iconstorage.cpp プロジェクト: ChALkeR/vacuum-im
void IconStorage::insertAutoIcon(QObject *AObject, const QString &AKey, int AIndex, int AAnimate, const QString &AProperty)
{
	IconStorage *oldStorage = FObjectStorage.value(AObject);
	if (oldStorage!=NULL && oldStorage!=this)
		oldStorage->removeAutoIcon(AObject);

	if (AObject!=NULL && !AKey.isEmpty())
	{
		IconUpdateParams *params;
		if (oldStorage!=this)
		{
			params = new IconUpdateParams;
			FObjectStorage.insert(AObject,this);
			FUpdateParams.insert(AObject,params);
		}
		else
		{
			params = FUpdateParams.value(AObject);
		}
		params->key = AKey;
		params->index = AIndex;
		params->prop = AProperty;
		params->animate = AAnimate;
		initAnimation(AObject,params);
		updateObject(AObject);
		connect(AObject,SIGNAL(destroyed(QObject *)),SLOT(onObjectDestroyed(QObject *)));
	}
	else if (AObject!=NULL)
	{
		removeAutoIcon(AObject);
	}
}
コード例 #5
0
EmoticonsOptions::EmoticonsOptions(IEmoticons *AEmoticons, QWidget *AParent) : QWidget(AParent)
{
	ui.setupUi(this);
	IconStorage *storage = IconStorage::staticStorage(RSR_STORAGE_MENUICONS);
	storage->insertAutoIcon(ui.tbtUp,MNI_EMOTICONS_ARROW_UP);
	storage->insertAutoIcon(ui.tbtDown,MNI_EMOTICONS_ARROW_DOWN);

	FEmoticons = AEmoticons;
	ui.lwtEmoticons->setItemDelegate(new IconsetDelegate(ui.lwtEmoticons));
	connect(ui.lwtEmoticons,SIGNAL(itemChanged(QListWidgetItem *)),SIGNAL(modified()));

	connect(ui.tbtUp,SIGNAL(clicked()),SLOT(onUpButtonClicked()));
	connect(ui.tbtDown,SIGNAL(clicked()),SLOT(onDownButtonClicked()));

	reset();
}
コード例 #6
0
QSize IconsetDelegate::sizeHint(const QStyleOptionViewItem &AOption, const QModelIndex &AIndex) const
{
	QString name = AIndex.data(IDR_STORAGE).toString();
	QString subdir = AIndex.data(IDR_SUBSTORAGE).toString();
	
	IconStorage *storage = FStorages.value(name).value(subdir,NULL);
	if (storage==NULL && !name.isEmpty() && !subdir.isEmpty())
	{
		storage = new IconStorage(name,subdir);
		FStorages[name].insert(subdir,storage);
	}

	if (storage != NULL)
	{
		int space = 2;
		QSize size(0,0);

		QStyleOptionViewItemV4 indexOption = indexStyleOption(AOption,AIndex);

		if (!AIndex.data(IDR_HIDE_STORAGE_NAME).toBool())
		{
			QSize checkSize = checkButtonRect(indexOption,indexOption.rect,AIndex.data(Qt::CheckStateRole)).size();
			QString displayText = storage->storageProperty(FILE_STORAGE_NAME,name+"/"+subdir);
			QSize textSize = indexOption.fontMetrics.size(Qt::TextSingleLine,displayText);
			size.setHeight(qMax(checkSize.height(),textSize.height()));
			size.setWidth(checkSize.width()+textSize.width()+space);
		}

		int rows = AIndex.data(IDR_ICON_ROW_COUNT).isValid() ? AIndex.data(IDR_ICON_ROW_COUNT).toInt() : DEFAULT_ICON_ROW_COUNT;
		int iconWidth = qMin(indexOption.rect.width(),storage->fileFirstKeys().count()*(indexOption.decorationSize.width()+space));
		int iconHeight = (indexOption.decorationSize.height()+space)*rows;

		return QSize(qMax(size.width(),iconWidth)+space,size.height()+iconHeight+space);
	}
	else
	{
		return QStyledItemDelegate::sizeHint(AOption,AIndex);
	}
}
コード例 #7
0
void IconsetDelegate::paint(QPainter *APainter, const QStyleOptionViewItem &AOption, const QModelIndex &AIndex) const
{
	QString name = AIndex.data(IDR_STORAGE).toString();
	QString subdir = AIndex.data(IDR_SUBSTORAGE).toString();

	IconStorage *storage = FStorages.value(name).value(subdir);
	if (storage==NULL && !name.isEmpty() && !subdir.isEmpty())
	{
		storage = new IconStorage(name,subdir);
		FStorages[name].insert(subdir,storage);
	}

	if (storage != NULL)
	{
		QStyleOptionViewItemV4 indexOption = indexStyleOption(AOption,AIndex);

#if defined(Q_WS_WIN) && !defined(QT_NO_STYLE_WINDOWSVISTA)
		QStyle *style = indexOption.widget ? indexOption.widget->style() : QApplication::style();
		if (qobject_cast<QWindowsVistaStyle *>(style))
		{
			indexOption.palette.setColor(QPalette::All, QPalette::HighlightedText, indexOption.palette.color(QPalette::Active, QPalette::Text));
			indexOption.palette.setColor(QPalette::All, QPalette::Highlight, indexOption.palette.base().color().darker(108));
		}
#endif

		APainter->save();
		APainter->setClipping(true);
		APainter->setClipRect(indexOption.rect);

		drawBackground(APainter,indexOption);

		int space = 2;
		QRect drawRect = indexOption.rect.adjusted(space,space,-space,-space);

		if (!AIndex.data(IDR_HIDE_STORAGE_NAME).toBool())
		{
			QRect ceckRect(drawRect.topLeft(),checkButtonRect(indexOption,drawRect,AIndex.data(Qt::CheckStateRole)).size());
			drawCheckButton(APainter,indexOption,ceckRect,static_cast<Qt::CheckState>(AIndex.data(Qt::CheckStateRole).toInt()));
			drawRect.setLeft(ceckRect.right()+space);

			QString displayText = storage->storageProperty(FILE_STORAGE_NAME,name+"/"+subdir);
			QRect textRect(drawRect.topLeft(),indexOption.fontMetrics.size(Qt::TextSingleLine,displayText));

			QPalette::ColorGroup cg = indexOption.state & QStyle::State_Enabled ? QPalette::Normal : QPalette::Disabled;
			if (cg == QPalette::Normal && !(indexOption.state & QStyle::State_Active))
				cg = QPalette::Inactive;
			if (indexOption.state & QStyle::State_Selected)
				APainter->setPen(indexOption.palette.color(cg, QPalette::HighlightedText));
			else
				APainter->setPen(indexOption.palette.color(cg, QPalette::Text));
			APainter->drawText(textRect,indexOption.displayAlignment,displayText);

			drawRect.setTop(textRect.bottom() + space);
			drawRect.setLeft(indexOption.rect.left() + space);
		}

		int maxRows = AIndex.data(IDR_ICON_ROW_COUNT).isValid() ? AIndex.data(IDR_ICON_ROW_COUNT).toInt() : DEFAULT_ICON_ROW_COUNT;

		int row = 0;
		int column = 0;
		int iconIndex = 0;
		int left = drawRect.left();
		int top = drawRect.top();
		QList<QString> iconKeys = storage->fileFirstKeys();
		while (drawRect.bottom()>top && drawRect.right()>left && iconIndex<iconKeys.count() && row<maxRows)
		{
// *** <<< eyeCU <<< ***
			bool filtered=false;
			for (QStringList::ConstIterator it=FFilter.constBegin(); it!=FFilter.constEnd(); ++it)
				if (iconKeys.at(iconIndex).endsWith(*it))
				{
					filtered=true;
					break;
				}
			if (!filtered)
			{
// *** >>> eyeCU >>> ***
			QIcon icon = storage->getIcon(iconKeys.at(iconIndex));
			if (!icon.isNull())
			{
				QPixmap pixmap = icon.pixmap(indexOption.decorationSize,QIcon::Normal,QIcon::On);
				APainter->drawPixmap(left,top,pixmap);
				left += indexOption.decorationSize.width()+space;
			}
			// *** <<< eyeCU >>> ***
			column++;

			if (left >= drawRect.right()-indexOption.decorationSize.width())
			{
				column = 0;
				left = drawRect.left();
				top += indexOption.decorationSize.height()+space;
			}
// *** <<< eyeCU <<< ***
			}
			iconIndex++;
// *** >>> eyeCU >>> ***
		}

		drawFocusRect(APainter,indexOption,indexOption.rect);

		APainter->restore();
	}
	else
	{
		QStyledItemDelegate::paint(APainter,AOption,AIndex);
	}
}
コード例 #8
0
ファイル: statusicons.cpp プロジェクト: ZerGabriel/vacuum-im
QString StatusIcons::iconFileName(const QString &ASubStorage, const QString &AIconKey) const
{
	IconStorage *storage = FStorages.value(ASubStorage,FDefaultStorage);
	return storage!=NULL ? storage->fileFullName(AIconKey) : QString::null;
}