forked from quickshell/quickshell
		
	core/global: add Quickshell.iconPath
Replaces "image://icon/" in user facing code.
This commit is contained in:
		
							parent
							
								
									24f54f579f
								
							
						
					
					
						commit
						bb33c9a0c4
					
				
					 2 changed files with 10 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -19,6 +19,7 @@
 | 
			
		|||
#include <unistd.h>
 | 
			
		||||
 | 
			
		||||
#include "generation.hpp"
 | 
			
		||||
#include "iconimageprovider.hpp"
 | 
			
		||||
#include "qmlscreen.hpp"
 | 
			
		||||
#include "rootwrapper.hpp"
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -188,6 +189,10 @@ QVariant QuickshellGlobal::env(const QString& variable) { // NOLINT
 | 
			
		|||
	return qEnvironmentVariable(vstr.data());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString QuickshellGlobal::iconPath(const QString& icon) {
 | 
			
		||||
	return IconImageProvider::requestString(icon, "");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QuickshellGlobal* QuickshellGlobal::create(QQmlEngine* engine, QJSEngine* /*unused*/) {
 | 
			
		||||
	auto* qsg = new QuickshellGlobal();
 | 
			
		||||
	auto* generation = EngineGeneration::findEngineGeneration(engine);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -125,6 +125,11 @@ public:
 | 
			
		|||
	/// Returns the string value of an environment variable or null if it is not set.
 | 
			
		||||
	Q_INVOKABLE QVariant env(const QString& variable);
 | 
			
		||||
 | 
			
		||||
	/// Returns a source string usable in an [Image] for a given system icon.
 | 
			
		||||
	///
 | 
			
		||||
	/// [Image]: https://doc.qt.io/qt-6/qml-qtquick-image.html
 | 
			
		||||
	Q_INVOKABLE static QString iconPath(const QString& icon);
 | 
			
		||||
 | 
			
		||||
	[[nodiscard]] QString workingDirectory() const;
 | 
			
		||||
	void setWorkingDirectory(QString workingDirectory);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue