Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <qt/guiutil.h>

#include <qt/bitcoinaddressvalidator.h>
#include <qt/bitcoingui.h>
#include <qt/bitcoinunits.h>
#include <qt/qvalidatedlineedit.h>
#include <qt/walletmodel.h>
Expand Down Expand Up @@ -1057,14 +1058,49 @@ void loadStyleSheet(QWidget* widget, bool fDebugWidget)
return false;
}

std::string platformName = gArgs.GetArg("-uiplatform", BitcoinGUI::DEFAULT_UIPLATFORM);
stylesheet = std::make_unique<QString>();

for (const auto& file : vecFiles) {
QFile qFile(file);
if (!qFile.open(QFile::ReadOnly)) {
throw std::runtime_error(strprintf("%s: Failed to open file: %s", __func__, file.toStdString()));
}
stylesheet->append(QLatin1String(qFile.readAll()));

QString strStyle = QLatin1String(qFile.readAll());
// Process all <os=...></os> groups in the stylesheet first
QRegularExpressionMatch osStyleMatch;
QRegularExpression osStyleExp(
"^"
"(<os=(?:'|\").+(?:'|\")>)" // group 1
"((?:.|\n)+?)" // group 2
"(</os>?)" // group 3
"$");
osStyleExp.setPatternOptions(QRegularExpression::MultilineOption);
QRegularExpressionMatchIterator it = osStyleExp.globalMatch(strStyle);

// For all <os=...></os> sections
while (it.hasNext() && (osStyleMatch = it.next()).isValid()) {
QStringList listMatches = osStyleMatch.capturedTexts();

// Full match + 3 group matches
if (listMatches.size() % 4) {
throw std::runtime_error(strprintf("%s: Invalid <os=...></os> section in file %s", __func__, file.toStdString()));
}

for (int i = 0; i < listMatches.size(); i += 4) {
if (!listMatches[i + 1].contains(QString::fromStdString(platformName))) {
// If os is not supported for this styles
// just remove the full match
strStyle.replace(listMatches[i], "");
} else {
// If its supported remove the <os=...></os> tags
strStyle.replace(listMatches[i + 1], "");
strStyle.replace(listMatches[i + 3], "");
}
}
}
stylesheet->append(strStyle);
}
return true;
};
Expand Down
35 changes: 35 additions & 0 deletions src/qt/res/css/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -784,3 +784,38 @@ TransactionView
******************************************************/

/***** No dark.css specific coloring here yet *****/


/******************************************************
*******************************************************
STYLING OF OS SPECIFIC UI PARTS

NOTE: GUIUtil::loadStyleSheet treats css code between <os="<os_list>"> and </os>
different. It will only become added for operating systems provided in the list
of the sections start tag.

There may be multiple entries per section. Possible entries:

- macosx
- windows
- other

<os_list> must be a combination of the three options above separated by
comma like in "windows,macosx".

Its ok to have multiple <os="...">...</os> sections in a file with
arbitrary OS combinations. They will all become added to the end of the
file though. Means even putting an <os> section in the top of the file
would become appended to the end of the file during loading which should
be kept in mind when adding sections to avoid unexpected overwriting.
*******************************************************
******************************************************/

<os="macosx, windows, other">

/* Example section to add styles for all operating systems
Remove any to exclude it.
*/

</os>

36 changes: 36 additions & 0 deletions src/qt/res/css/general.css
Original file line number Diff line number Diff line change
Expand Up @@ -1849,3 +1849,39 @@ TransactionView QComboBox {
min-height: 30px;
margin-top: 15px;
}


/******************************************************
*******************************************************
STYLING OF OS SPECIFIC UI PARTS

NOTE: GUIUtil::loadStyleSheet treats css code between <os="<os_list>"> and </os>
different. It will only become added for operating systems provided in the list
of the sections start tag.

There may be multiple entries per section. Possible entries:

- macosx
- windows
- other

<os_list> must be a combination of the three options above separated by
comma like in "windows,macosx".

Its ok to have multiple <os="...">...</os> sections in a file with
arbitrary OS combinations. They will all become added to the end of the
file though. Means even putting an <os> section in the top of the file
would become appended to the end of the file during loading which should
be kept in mind when adding sections to avoid unexpected overwriting.
*******************************************************
******************************************************/


<os="macosx, windows, other">

/* Example section to add styles for all operating systems
Remove any to exclude it.
*/

</os>

36 changes: 36 additions & 0 deletions src/qt/res/css/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -766,3 +766,39 @@ TransactionView
******************************************************/

/***** No light.css specific coloring here yet *****/


/******************************************************
*******************************************************
STYLING OF OS SPECIFIC UI PARTS

NOTE: GUIUtil::loadStyleSheet treats css code between <os="<os_list>"> and </os>
different. It will only become added for operating systems provided in the list
of the sections start tag.

There may be multiple entries per section. Possible entries:

- macosx
- windows
- other

<os_list> must be a combination of the three options above separated by
comma like in "windows,macosx".

Its ok to have multiple <os="...">...</os> sections in a file with
arbitrary OS combinations. They will all become added to the end of the
file though. Means even putting an <os> section in the top of the file
would become appended to the end of the file during loading which should
be kept in mind when adding sections to avoid unexpected overwriting.
*******************************************************
******************************************************/


<os="macosx, windows, other">

/* Example section to add styles for all operating systems
Remove any to exclude it.
*/

</os>