Beispiel #1
0
	QStringList GetPathCandidates (SysPath path, QString suffix)
	{
		if (!suffix.isEmpty () && suffix.at (suffix.size () - 1) != '/')
			suffix += '/';

		QStringList candidates;
		switch (path)
		{
		case SysPath::QML:
#if QT_VERSION < 0x050000
			return GetPathCandidates (SysPath::Share, "qml/" + suffix);
#else
			return GetPathCandidates (SysPath::Share, "qml5/" + suffix);
#endif
		case SysPath::Share:
#ifdef Q_OS_WIN32
			candidates << QApplication::applicationDirPath () + "/share/" + suffix;
#elif defined (Q_OS_MAC) && !defined (USE_UNIX_LAYOUT)
			candidates << QApplication::applicationDirPath () + "/../Resources/share/" + suffix;
#else
	#ifdef INSTALL_PREFIX
			candidates << INSTALL_PREFIX "/share/leechcraft/" + suffix;
	#endif
			candidates << "/usr/local/share/leechcraft/" + suffix
					<< "/usr/share/leechcraft/" + suffix;
#endif
			return candidates;
		}

		qWarning () << Q_FUNC_INFO
				<< "unknown system path"
				<< static_cast<int> (path);
		return QStringList ();
	}
Beispiel #2
0
	QString GetSysPath (SysPath path, const QString& suffix, const QString& filename)
	{
		for (const QString& cand : GetPathCandidates (path, suffix))
			if (QFile::exists (cand + filename))
				return cand + filename;

		qWarning () << Q_FUNC_INFO
				<< "unable to find"
				<< suffix
				<< filename;
		return QString ();
	}
	UnhideListViewBase::UnhideListViewBase (ICoreProxy_ptr proxy, QWidget *parent)
	: QDeclarativeView (parent)
	, Model_ (new UnhideListModel (this))
	{
		new UnhoverDeleteMixin (this);

		const auto& file = GetSysPath (SysPath::QML, "common", "UnhideListView.qml");
		if (file.isEmpty ())
		{
			qWarning () << Q_FUNC_INFO
					<< "file not found";
			deleteLater ();
			return;
		}

		setStyleSheet ("background: transparent");
		setWindowFlags (Qt::ToolTip);
		setAttribute (Qt::WA_TranslucentBackground);

		for (const auto& cand : GetPathCandidates (SysPath::QML, ""))
			engine ()->addImportPath (cand);

		rootContext ()->setContextProperty ("unhideListModel", Model_);
		rootContext ()->setContextProperty ("colorProxy",
				new Util::ColorThemeProxy (proxy->GetColorThemeManager (), this));
		engine ()->addImageProvider ("ThemeIcons", new Util::ThemeImageProvider (proxy));
		setSource (QUrl::fromLocalFile (file));

		connect (rootObject (),
				SIGNAL (closeRequested ()),
				this,
				SLOT (deleteLater ()));
		connect (rootObject (),
				SIGNAL (itemUnhideRequested (QString)),
				this,
				SIGNAL (itemUnhideRequested (QString)));
	}