Пример #1
0
QIcon IconList::getIcon(QString key)
{
	int icon_index = getIconIndex(key);

	if (icon_index != -1)
		return icons[icon_index].icon();

	// Fallback for icons that don't exist.
	icon_index = getIconIndex("infinity");

	if (icon_index != -1)
		return icons[icon_index].icon();
	return QIcon();
}
Пример #2
0
// called by CWList::populateListCtrl
//  This default implementation just adds one row for the entry
int CWListEntry::addYourRowsToListCtrl(CListCtrl &clc,  int iStartingRow)
{
	LV_ITEM lvi;
	lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE | LVIF_IMAGE;
	lvi.state = 0;
	lvi.stateMask = 0;
	lvi.pszText = LPSTR_TEXTCALLBACK;   // app. maintains text
	lvi.iImage = getIconIndex();

	lvi.iSubItem = 0;
	lvi.iItem = iStartingRow;
	lvi.lParam = (LPARAM) this;
	if(!m_bEnabled)
	{
		lvi.state =  INDEXTOOVERLAYMASK(1); // draw the 'not' icon over it
		lvi.stateMask = LVIS_OVERLAYMASK;
	}
	else
	{
		lvi.state = 0;
		lvi.stateMask =  NULL;
	}
	ASSERTX(-1 != clc.InsertItem(&lvi));
	return 1+ iStartingRow;	// the next row that will be inserted
}
Пример #3
0
void ObjectMan::drawLeaderObjectName(Thing thing) {
	Common::String objectName;
	int16 iconIndex = getIconIndex(thing);
	if (iconIndex == kDMIconIndiceJunkChampionBones) {
		Junk *junk = (Junk*)_vm->_dungeonMan->getThingData(thing);
		Common::String champBonesName;

		switch (_vm->getGameLanguage()) { // localized
		case Common::FR_FRA:
			// Fix original bug: strcpy was coming after strcat
			champBonesName = Common::String(_objectNames[iconIndex]);
			champBonesName += Common::String(_vm->_championMan->_champions[junk->getChargeCount()]._name);
			break;
		default: // English and German version are the same
			champBonesName = Common::String(_vm->_championMan->_champions[junk->getChargeCount()]._name);
			champBonesName += Common::String(_objectNames[iconIndex]);
			break;
		}

		objectName = champBonesName;
	} else
		objectName = Common::String(_objectNames[iconIndex]);

	_vm->_textMan->printWithTrailingSpaces(_vm->_displayMan->_bitmapScreen, k160_byteWidthScreen, 233, 37, kDMColorCyan, kDMColorBlack, objectName.c_str(), k14_ObjectNameMaximumLength, k200_heightScreen);
}
Пример #4
0
QIcon IconList::getBigIcon(QString key)
{
	int icon_index = getIconIndex(key);

	if (icon_index == -1)
		key = "infinity";

	// Fallback for icons that don't exist.
	icon_index = getIconIndex(key);

	if (icon_index == -1)
		return QIcon();

	QPixmap bigone = icons[icon_index].icon().pixmap(256,256).scaled(256,256);
	return QIcon(bigone);
}
Пример #5
0
bool IconList::deleteIcon(QString key)
{
	int iconIdx = getIconIndex(key);
	if (iconIdx == -1)
		return false;
	auto &iconEntry = icons[iconIdx];
	if (iconEntry.has(MMCIcon::FileBased))
	{
		return QFile::remove(iconEntry.m_images[MMCIcon::FileBased].filename);
	}
	return false;
}
Пример #6
0
int IconPickerDialog::exec ( QString selection )
{
	auto list = MMC->icons();
	auto contentsWidget = ui->iconView;
	selectedIconKey = selection;
	
	
	int index_nr = list->getIconIndex(selection);
	auto model_index = list->index(index_nr);
	contentsWidget->selectionModel()->select(model_index, QItemSelectionModel::Current | QItemSelectionModel::Select);
	
	QMetaObject::invokeMethod(this, "delayed_scroll", Qt::QueuedConnection, Q_ARG(QModelIndex,model_index));
	return QDialog::exec();
}
Пример #7
0
void IconList::fileChanged(const QString &path)
{
	QLOG_INFO() << "Checking " << path;
	QFileInfo checkfile(path);
	if (!checkfile.exists())
		return;
	QString key = checkfile.baseName();
	int idx = getIconIndex(key);
	if (idx == -1)
		return;
	QIcon icon(path);
	if (!icon.availableSizes().size())
		return;

	icons[idx].m_images[MMCIcon::FileBased].icon = icon;
	dataChanged(index(idx), index(idx));
	emit iconUpdated(key);
}
void NotificationManager::notify(const char *tag, int id, const char *title, const char *text)
{
    std::shared_ptr<AttachedJENV> jenv(new AttachedJENV());
    if (!jenv->attached())
    {
        LOG(ANDROID_LOG_ERROR, "Unable to get VM");
        return;
    }

    if (!initializeStatics(jenv))
    {
        LOG(ANDROID_LOG_ERROR, "Unable to init internal objects");
        return;
    }

    std::shared_ptr<JavaObject> nb = jenv->createJO(notificationBuilder_->get(),
                                                     &JavaObjects::NotificationBuilder_Desc);
    nb->call("setAutoCancel", (jboolean)JNI_TRUE);
    nb->call("setContentTitle", jenv->env()->NewStringUTF(title));
    nb->call("setContentText", jenv->env()->NewStringUTF(text));
    nb->call("setSmallIcon", getIconIndex(jenv));
    jvalue notification = nb->call("getNotification");
    if (notification.l)
    {
        std::shared_ptr<JavaLocalRef<jobject> > notif(jenv->createRef(notification.l));
        std::shared_ptr<JavaObject> nm = jenv->createJO(notificationManager_->get(),
                                                         &JavaObjects::NotificationManager_Desc);
        nm->call("notify_0", jenv->env()->NewStringUTF(tag), id, notif->get());

        LOG(ANDROID_LOG_INFO, "Notification created succesfully");
    }
    else
    {
        LOG(ANDROID_LOG_ERROR, "Unable to create Notification object");
    }
}
// called by CWList::populateListCtrl
//  We will enter one row for each change, plus extra rows for extra environments
int CWEnvironConstrainedRule::addYourRowsToListCtrl(CListCtrl &clc, int iStartingRow)
{
//	m_startingRow = iStartingRow;

	LV_ITEM lvi;
	lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE |LVIF_IMAGE;
	lvi.pszText = LPSTR_TEXTCALLBACK;   // app. maintains text
	lvi.iImage = getIconIndex();                     // image list index

	lvi.iSubItem = 0;
	lvi.iItem = iStartingRow;
	lvi.lParam = (LPARAM) this;    // change
	//lvi.state = INDEXTOSTATEIMAGEMASK(m_bEnabled?1:2);
	//lvi.stateMask = LVIF_STATE;
	if(!m_bEnabled)
	{
		lvi.state =  INDEXTOOVERLAYMASK(1); // draw the 'not' icon over it
		lvi.stateMask = LVIS_OVERLAYMASK;
	}
	else
	{
		lvi.state = 0;
		lvi.stateMask =  NULL;
	}

	ASSERTX(-1 != clc.InsertItem(&lvi));


	// first environment goes on first row (with the rule)
	// unless the rule has a comment, in which case the comment
	// goes on the first row with it
	int e;
	if(m_lcComments.GetLength())
	{
		e = 0;
		++iStartingRow;
	}
	else
		e = 1;	// don't give the first environment its own row

	// show one of two icons for string or morpheme environment types
 /*   if(this->m_pOwningList->getEnvironmentType() ==kMorphEnv)
		lvi.iImage = 1;
	else
		lvi.iImage = 2;
*/
	lvi.iImage = 99;	// empty
	//lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;

	for(e; e < m_environments.GetSize(); e++)
	{
		lvi.iItem = e +  iStartingRow;
		lvi.lParam = (LPARAM) m_environments[e];    // environment
		CStringEnvironment *pEnv = m_environments[e];
		if(!pEnv->m_bEnabled)
		{
			lvi.state =  INDEXTOOVERLAYMASK(1); // draw the 'not' icon over it
			lvi.stateMask = LVIS_OVERLAYMASK;
		}
		else
		{
			lvi.state = 0;
			lvi.stateMask =  NULL;
		}
		ASSERTX(-1 != clc.InsertItem(&lvi));

		// now set the icon for the env sub item, so that the icon shows up in the right column
/*		LV_ITEM lsub;
		lsub.mask = LVIF_IMAGE;
		if(this->m_pOwningList->getEnvironmentType() ==kMorphEnv)
			lsub.iImage = 1;
		else
			lsub.iImage = 2;
		lsub.iSubItem = m_iColumnForEnv;
		ListView_SetItem(clc.m_hWnd, &lsub);
*/	}

/*		if(m_lcComments.GetLength())	comment now go on first row
	{
		lvi.iItem = e + iStartingRow;
		lvi.lParam = (LPARAM) &m_lcComments;    // comment line
		ASSERTX(-1 != clc.InsertItem(&lvi));
		++e;
	}
*/
	return e + iStartingRow;	// the next row that will be inserted
}
Пример #10
0
void IconList::directoryChanged(const QString &path)
{
	QDir new_dir (path);
	if(m_dir.absolutePath() != new_dir.absolutePath())
	{
		m_dir.setPath(path);
		m_dir.refresh();
		if(is_watching)
			stopWatching();
		startWatching();
	}
	if(!m_dir.exists())
		if(!ensureFolderPathExists(m_dir.absolutePath()))
			return;
	m_dir.refresh();
	auto new_list = m_dir.entryList(QDir::Files, QDir::Name);
	for (auto it = new_list.begin(); it != new_list.end(); it++)
	{
		QString &foo = (*it);
		foo = m_dir.filePath(foo);
	}
	auto new_set = new_list.toSet();
	QList<QString> current_list;
	for (auto &it : icons)
	{
		if (!it.has(MMCIcon::FileBased))
			continue;
		current_list.push_back(it.m_images[MMCIcon::FileBased].filename);
	}
	QSet<QString> current_set = current_list.toSet();

	QSet<QString> to_remove = current_set;
	to_remove -= new_set;

	QSet<QString> to_add = new_set;
	to_add -= current_set;

	for (auto remove : to_remove)
	{
		QLOG_INFO() << "Removing " << remove;
		QFileInfo rmfile(remove);
		QString key = rmfile.baseName();
		int idx = getIconIndex(key);
		if (idx == -1)
			continue;
		icons[idx].remove(MMCIcon::FileBased);
		if (icons[idx].type() == MMCIcon::ToBeDeleted)
		{
			beginRemoveRows(QModelIndex(), idx, idx);
			icons.remove(idx);
			reindex();
			endRemoveRows();
		}
		else
		{
			dataChanged(index(idx), index(idx));
		}
		m_watcher->removePath(remove);
		emit iconUpdated(key);
	}

	for (auto add : to_add)
	{
		QLOG_INFO() << "Adding " << add;
		QFileInfo addfile(add);
		QString key = addfile.baseName();
		if (addIcon(key, QString(), addfile.filePath(), MMCIcon::FileBased))
		{
			m_watcher->addPath(add);
			emit iconUpdated(key);
		}
	}
}