mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-22 04:11:16 -05:00
Add QDarkStyleSheet to Message Aggregator reference application
This commit is contained in:
parent
74112434f9
commit
d241217737
@ -1087,7 +1087,10 @@ qt5_wrap_ui (wsjt_qt_GENUISRCS ${wsjt_qt_UISRCS})
|
||||
qt5_wrap_ui (wsjtx_GENUISRCS ${wsjtx_UISRCS})
|
||||
|
||||
# Resource generation
|
||||
qt5_add_resources (wsjtx_RESOURCES_RCC ${CMAKE_BINARY_DIR}/wsjtx.qrc)
|
||||
qt5_add_resources (wsjtx_RESOURCES_RCC
|
||||
${CMAKE_BINARY_DIR}/wsjtx.qrc
|
||||
contrib/QDarkStyleSheet/qdarkstyle/style.qrc
|
||||
)
|
||||
|
||||
# AX COM servers
|
||||
if (WIN32)
|
||||
@ -1324,7 +1327,10 @@ target_link_libraries (udp_daemon wsjtx_udp-static)
|
||||
|
||||
add_resources (message_aggregator_RESOURCES /qss ${message_aggregator_STYLESHEETS})
|
||||
configure_file (UDPExamples/message_aggregator.qrc.in message_aggregator.qrc @ONLY)
|
||||
qt5_add_resources (message_aggregator_RESOURCES_RCC ${CMAKE_CURRENT_BINARY_DIR}/message_aggregator.qrc)
|
||||
qt5_add_resources (message_aggregator_RESOURCES_RCC
|
||||
${CMAKE_CURRENT_BINARY_DIR}/message_aggregator.qrc
|
||||
contrib/QDarkStyleSheet/qdarkstyle/style.qrc
|
||||
)
|
||||
add_executable (message_aggregator
|
||||
${message_aggregator_CXXSRCS}
|
||||
${WSJTX_ICON_FILE}
|
||||
|
@ -62,15 +62,30 @@ int main (int argc, char * argv[])
|
||||
|
||||
QObject::connect (&app, SIGNAL (lastWindowClosed ()), &app, SLOT (quit ()));
|
||||
|
||||
{
|
||||
QString ss;
|
||||
auto sf = qApp->styleSheet ();
|
||||
if (sf.size ())
|
||||
{
|
||||
sf.remove ("file:///");
|
||||
QFile file {sf};
|
||||
if (!file.open (QFile::ReadOnly))
|
||||
{
|
||||
throw std::runtime_error {
|
||||
QString {"failed to open \"" + file.fileName () + "\": " + file.errorString ()}.toStdString ()};
|
||||
}
|
||||
ss += file.readAll ();
|
||||
}
|
||||
{
|
||||
QFile file {":/qss/default.qss"};
|
||||
if (!file.open (QFile::ReadOnly))
|
||||
{
|
||||
throw std::runtime_error {
|
||||
QString {"failed to open \"" + file.fileName () + "\": " + file.errorString ()}
|
||||
.toLocal8Bit ().constData ()};
|
||||
QString {"failed to open \"" + file.fileName () + "\": " + file.errorString ()}.toStdString ()};
|
||||
}
|
||||
app.setStyleSheet (file.readAll());
|
||||
ss += file.readAll ();
|
||||
}
|
||||
app.setStyleSheet (ss);
|
||||
}
|
||||
|
||||
MessageAggregatorMainWindow window;
|
||||
|
@ -1236,7 +1236,18 @@ void MainWindow::set_application_font (QFont const& font)
|
||||
qApp->setFont (font);
|
||||
// set font in the application style sheet as well in case it has
|
||||
// been modified in the style sheet which has priority
|
||||
qApp->setStyleSheet (qApp->styleSheet () + "* {" + font_as_stylesheet (font) + '}');
|
||||
QString ss;
|
||||
if (qApp->styleSheet ().size ())
|
||||
{
|
||||
auto sheet = qApp->styleSheet ();
|
||||
sheet.remove ("file:///");
|
||||
QFile sf {sheet};
|
||||
if (sf.open (QFile::ReadOnly | QFile::Text))
|
||||
{
|
||||
ss = sf.readAll () + ss;
|
||||
}
|
||||
}
|
||||
qApp->setStyleSheet (ss + "* {" + font_as_stylesheet (font) + '}');
|
||||
for (auto& widget : qApp->topLevelWidgets ())
|
||||
{
|
||||
widget->updateGeometry ();
|
||||
|
Loading…
Reference in New Issue
Block a user