VTQ_PATH variable implementation

Forums

Hi Rui:
QSS stylesheets require absolute paths for images.
I have decided to add the VTQ_PATH variable to the VTQ format.

This allows you to include image backgrounds. Also extra icons for QT elements such as the arrows of the QAbstractSpinBox, QCombox, etc.

Example:
qtractorPluginListView {
background: url(VTQ_PATH/Tecnico_Images/shelves.png);
}

This greatly expands the possibilities of customizing Qtractor.
For example, currently the fader handles in my theme are made with gradients. With this implementation it is possible to create a perfectly detailed graph, with shadows, perspectives, etc.

I have implemented it and it works:

...qtractor.cpp linea 577
	// Custom style sheet (QSS)...
	if (!options.sCustomStyleSheet.isEmpty()) {
		QFile file(options.sCustomStyleSheet);
		if (file.open(QFile::ReadOnly)) {
			QFileInfo fileInfo(options.sCustomStyleSheet);
			QString vtqPath = fileInfo.path();
			QString qssContent = QString::fromUtf8(file.readAll());
			qssContent.replace("VTQ_PATH", vtqPath);
			app.setStyleSheet(qssContent);
			file.close();
		}
	}

I have a question, and it is if it would still work with accents and characters in paths from other languages.

How would you feel about adding it officially to Qtractor?

Permalink

hi, I think having it as a special named variable or symbol is not the right thing: it would make it locked down to your VTQ offering :/

what about making all the url paths relative to the .qss file location (ie. fileInfo.absolutePath() in above code) ? and then on load, replace all url( rpath ) occurrences to final url( + fileInfo.absolutePath() + '/' + _ rpath_ ) ?

get the idea?

Yes, it is a cleaner solution.
In fact, it would work just as expected (as it does in CSS where the reference path is always the CSS file, and not the application or "index").
That also saves me from having to document it.
It just didn't occur to me that there was already a recognizable pattern for making the changes: url(

This works:

	// Custom style sheet (QSS)...
	if (!options.sCustomStyleSheet.isEmpty()) {
		QFile file(options.sCustomStyleSheet);
		if (file.open(QFile::ReadOnly)) {
			QFileInfo fileInfo(options.sCustomStyleSheet);
			QString qssPath = fileInfo.path();
			QString qssContent = QString::fromUtf8(file.readAll());
			qssContent.replace("url(", "url("+qssPath+"/");
			app.setStyleSheet(qssContent);
			file.close();
		}
	}

Example QSS:
qtractorPluginListView {
background: url(Tecnico_Images/shelves.png);
}

Permalink

hi,

as proposed, the url( relative/path ) to url( /absolute/path ) substitution is now in effect (using a regular expressions):
qtractor >= 1.5.2.2git.dfd7ac

please test && tell
cheers

Add new comment

The content of this field is kept private and will not be shown publicly.

Markdown

  • Parses markdown and converts it to HTML.
  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type='1 A I'> <li> <dl> <dt> <dd> <h2 id='jump-*'> <h3 id> <h4 id> <h5 id> <h6 id> <img src alt height width> <strike> <pre> <p> <br>
  • Lines and paragraphs break automatically.

Filtered HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <b> <i> <pre> <img src alt height width> <strike>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
File attachments
Unlimited number of files can be uploaded to this field.
2 MB limit.
Allowed types: jpg jpeg gif png txt doc docx xls xlsx pdf ppt pps odt ods odp zip gz bz2 xz patch diff wav ogg flac ogv mp4 qtz.
CAPTCHA
Enter the characters shown in the image.