From 7992d6f870b2edc92a20c0c40ac629dd32da96d6 Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Thu, 29 Jul 2021 10:53:57 +0200 Subject: [PATCH 1/6] added /usr/local to search path for the stylesheet --- wfmain.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index a5b9f08..d73de2f 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -2225,11 +2225,11 @@ void wfmain::setAppTheme(bool isCustom) QFile f(":"+prefs.stylesheetPath); // built-in resource #else QFile f("/usr/share/wfview/stylesheets/" + prefs.stylesheetPath); + QFile g("/usr/local/share/wfview/stylesheets/" + prefs.stylesheetPath); #endif if (!f.exists()) { - printf("Unable to set stylesheet, file not found\n"); - printf("Tried to load: [%s]\n", QString( QString("/usr/share/wfview/stylesheets/") + prefs.stylesheetPath).toStdString().c_str() ); + printf("Unable to set stylesheet, file not found or permission issue [%s]\n", QString( QString("/usr/share/wfview/stylesheets/") + prefs.stylesheetPath).toStdString().c_str() ); } else { @@ -2237,6 +2237,18 @@ void wfmain::setAppTheme(bool isCustom) QTextStream ts(&f); qApp->setStyleSheet(ts.readAll()); } + + if (!g.exists()) + { + printf("Unable to set stylesheet, file not found or permisson issue [%s]\n", QString( QString("/usr/local/share/wfview/stylesheets/") + prefs.stylesheetPath).toStdString().c_str() ); + } + else + { + g.open(QFile::ReadOnly | QFile::Text); + QTextStream ts(&g); + qApp->setStyleSheet(ts.readAll()); + } + } else { qApp->setStyleSheet(""); } From 2ac1b8c0acb6a6c6a3f4374f050aa828f07fa7a5 Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Thu, 29 Jul 2021 11:28:45 +0200 Subject: [PATCH 2/6] fix: set the style once --- wfmain.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index d73de2f..cb69885 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -2224,32 +2224,38 @@ void wfmain::setAppTheme(bool isCustom) #ifndef Q_OS_LINUX QFile f(":"+prefs.stylesheetPath); // built-in resource #else - QFile f("/usr/share/wfview/stylesheets/" + prefs.stylesheetPath); - QFile g("/usr/local/share/wfview/stylesheets/" + prefs.stylesheetPath); +// two paths are possible - fu = /usr; fl = /usr/local + QFile fu("/usr/share/wfview/stylesheets/" + prefs.stylesheetPath); + QFile fl("/usr/local/share/wfview/stylesheets/" + prefs.stylesheetPath); #endif - if (!f.exists()) + +// check if the filepath is in /usr and if so -- set the style and return + if (!fu.exists()) { printf("Unable to set stylesheet, file not found or permission issue [%s]\n", QString( QString("/usr/share/wfview/stylesheets/") + prefs.stylesheetPath).toStdString().c_str() ); } else { - f.open(QFile::ReadOnly | QFile::Text); - QTextStream ts(&f); + fu.open(QFile::ReadOnly | QFile::Text); + QTextStream ts(&fu); qApp->setStyleSheet(ts.readAll()); + return; } - if (!g.exists()) +// if above fails, check if filepath is in /usr/local and if so -- set the style from there and return + if (!fl.exists()) { printf("Unable to set stylesheet, file not found or permisson issue [%s]\n", QString( QString("/usr/local/share/wfview/stylesheets/") + prefs.stylesheetPath).toStdString().c_str() ); } else { - g.open(QFile::ReadOnly | QFile::Text); - QTextStream ts(&g); + fl.open(QFile::ReadOnly | QFile::Text); + QTextStream ts(&fl); qApp->setStyleSheet(ts.readAll()); + return; } - } else { +// if both fail, we revert to no style sheet set qApp->setStyleSheet(""); } } From 4e63a72106d6da3eb87e28f263415d54fc722947 Mon Sep 17 00:00:00 2001 From: Elliott Liggett Date: Fri, 30 Jul 2021 17:30:34 -0700 Subject: [PATCH 3/6] Added a little extra logic, also some cross-platform help, to the custom stylesheet loader. --- wfmain.cpp | 54 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index cb69885..4d0c196 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -2222,40 +2222,52 @@ void wfmain::setAppTheme(bool isCustom) if(isCustom) { #ifndef Q_OS_LINUX - QFile f(":"+prefs.stylesheetPath); // built-in resource -#else -// two paths are possible - fu = /usr; fl = /usr/local - QFile fu("/usr/share/wfview/stylesheets/" + prefs.stylesheetPath); - QFile fl("/usr/local/share/wfview/stylesheets/" + prefs.stylesheetPath); -#endif - -// check if the filepath is in /usr and if so -- set the style and return - if (!fu.exists()) + QFile fresource(":"+prefs.stylesheetPath); // built-in resource + if (!fresource.exists()) { - printf("Unable to set stylesheet, file not found or permission issue [%s]\n", QString( QString("/usr/share/wfview/stylesheets/") + prefs.stylesheetPath).toStdString().c_str() ); + // This would be quite unusual... + qApp->setStyleSheet(""); + return; } else { - fu.open(QFile::ReadOnly | QFile::Text); - QTextStream ts(&fu); + fresource.open(QFile::ReadOnly | QFile::Text); + QTextStream ts(&fresource); qApp->setStyleSheet(ts.readAll()); return; } +#else +// two paths are possible - fusr = /usr; flocal = /usr/local + QFile fusr("/usr/share/wfview/stylesheets/" + prefs.stylesheetPath); + QFile flocal("/usr/local/share/wfview/stylesheets/" + prefs.stylesheetPath); + +// check if the filepath is in /usr and if so -- set the style and return + if (fusr.exists()) + { + fusr.open(QFile::ReadOnly | QFile::Text); + QTextStream ts(&fusr); + qApp->setStyleSheet(ts.readAll()); + return; + } + // if above fails, check if filepath is in /usr/local and if so -- set the style from there and return - if (!fl.exists()) + if (flocal.exists()) { - printf("Unable to set stylesheet, file not found or permisson issue [%s]\n", QString( QString("/usr/local/share/wfview/stylesheets/") + prefs.stylesheetPath).toStdString().c_str() ); - } - else - { - fl.open(QFile::ReadOnly | QFile::Text); - QTextStream ts(&fl); + flocal.open(QFile::ReadOnly | QFile::Text); + QTextStream ts(&flocal); qApp->setStyleSheet(ts.readAll()); - return; + return; } + + // Still here? Then we could not find a file: + printf("Unable to set stylesheet, file not found or permisson issue. Tried loading [%s] and ", QString( QString("/usr/local/share/wfview/stylesheets/") + prefs.stylesheetPath).toStdString().c_str() ); + printf(" [%s]\n", QString( QString("/usr/share/wfview/stylesheets/") + prefs.stylesheetPath).toStdString().c_str() ); + printf("Unsetting stylesheet."); + qApp->setStyleSheet(""); +#endif } else { -// if both fail, we revert to no style sheet set + // Not custom, proceed without: qApp->setStyleSheet(""); } } From 472709357805cdfdf6de24888397e0d768c25cce Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Sun, 1 Aug 2021 13:55:44 +0200 Subject: [PATCH 4/6] added derSuessmann additions to have a linux install prefix --- INSTALL.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 6df4ada..11df8c7 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -40,15 +40,16 @@ git clone https://gitlab.com/eliggett/wfview.git ~~~ ### 3. Create a build directory, compile, and install: +If you want to change the default install path from `/usr/local` to a different prefix (e.g. `/opt`), you must call `qmake ../wfview/wfview.pro PREFIX=/opt` + ~~~ mkdir build cd build qmake ../wfview/wfview.pro make -j -sudo ./install.sh +sudo make install ~~~ - ### 4. You can now launch wfview, either from the terminal or from your desktop environment. If you encounter issues using the serial port, run the following command: ~~~ @@ -65,7 +66,7 @@ sudo usermod -aG dialout $USER ~~~ -### opensuse/sles/tumbleweed install ### +### opensuse/sles/tumbleweed install --- install wfview on suse 15.x sles 15.x or tumbleweed; this was done on a clean install/updated OS. From 680262b4d2ef00b49fa3e98e0f41c0ab4d6a816f Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Sun, 1 Aug 2021 13:58:47 +0200 Subject: [PATCH 5/6] added derSuessmann additions to have a linux install prefix --- wfview.pro | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/wfview.pro b/wfview.pro index 86d16a4..9c56e55 100644 --- a/wfview.pro +++ b/wfview.pro @@ -38,6 +38,12 @@ equals(QT_ARCH, arm): DEFINES += USE_NEON DEFINES += OUTSIDE_SPEEX DEFINES += RANDOM_PREFIX=wf +isEmpty(PREFIX) { + PREFIX = /usr/local +} + +DEFINES += PREFIX=\\\"$$PREFIX\\\" + # Choose audio system, uses QTMultimedia if both are commented out. # DEFINES += RTAUDIO # DEFINES += PORTAUDIO @@ -74,18 +80,25 @@ win32:DEFINES += UNAME=\\\"build\\\" RESOURCES += qdarkstyle/style.qrc \ resources/resources.qrc +unix:target.path = $$PREFIX/bin +INSTALLS += target + # Why doesn't this seem to do anything? DISTFILES += resources/wfview.png \ resources/install.sh DISTFILES += resources/wfview.desktop -linux:QMAKE_POST_LINK += cp ../wfview/resources/wfview.png .; -linux:QMAKE_POST_LINK += cp ../wfview/resources/wfview.desktop .; -linux:QMAKE_POST_LINK += cp ../wfview/resources/install.sh .; -linux:QMAKE_POST_LINK += cp -r ../wfview/qdarkstyle .; -linux:QMAKE_POST_LINK += chmod 755 install.sh; -linux:QMAKE_POST_LINK += echo; echo; echo "Run install.sh as root from the build directory to install."; echo; echo; +unix:applications.files = resources/wfview.desktop +unix:applications.path = $$PREFIX/share/applications +INSTALLS += applications +unix:pixmaps.files = resources/wfview.png +unix:pixmaps.path = $$PREFIX/share/pixmaps +INSTALLS += pixmaps + +unix:stylesheets.files = qdarkstyle +unix:stylesheets.path = $$PREFIX/share/wfview +INSTALLS += stylesheets # Do not do this, it will hang on start: # CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG_OUTPUT From bee4f03edb6edf534c2cfe71c5219a5b2a7cb382 Mon Sep 17 00:00:00 2001 From: Roeland Jansen Date: Mon, 2 Aug 2021 08:06:19 +0200 Subject: [PATCH 6/6] added derSuessman prefix code --- wfmain.cpp | 51 +++++++++------------------------------------------ 1 file changed, 9 insertions(+), 42 deletions(-) diff --git a/wfmain.cpp b/wfmain.cpp index 4d0c196..b5d1497 100644 --- a/wfmain.cpp +++ b/wfmain.cpp @@ -2222,52 +2222,22 @@ void wfmain::setAppTheme(bool isCustom) if(isCustom) { #ifndef Q_OS_LINUX - QFile fresource(":"+prefs.stylesheetPath); // built-in resource - if (!fresource.exists()) + QFile f(":"+prefs.stylesheetPath); // built-in resource +#else + QFile f(PREFIX "/share/wfview/" + prefs.stylesheetPath); +#endif + if (!f.exists()) { - // This would be quite unusual... - qApp->setStyleSheet(""); - return; + printf("Unable to set stylesheet, file not found\n"); + printf("Tried to load: [%s]\n", f.fileName().toStdString().c_str() ); } else { - fresource.open(QFile::ReadOnly | QFile::Text); - QTextStream ts(&fresource); + f.open(QFile::ReadOnly | QFile::Text); + QTextStream ts(&f); qApp->setStyleSheet(ts.readAll()); - return; } - -#else -// two paths are possible - fusr = /usr; flocal = /usr/local - QFile fusr("/usr/share/wfview/stylesheets/" + prefs.stylesheetPath); - QFile flocal("/usr/local/share/wfview/stylesheets/" + prefs.stylesheetPath); - -// check if the filepath is in /usr and if so -- set the style and return - if (fusr.exists()) - { - fusr.open(QFile::ReadOnly | QFile::Text); - QTextStream ts(&fusr); - qApp->setStyleSheet(ts.readAll()); - return; - } - -// if above fails, check if filepath is in /usr/local and if so -- set the style from there and return - if (flocal.exists()) - { - flocal.open(QFile::ReadOnly | QFile::Text); - QTextStream ts(&flocal); - qApp->setStyleSheet(ts.readAll()); - return; - } - - // Still here? Then we could not find a file: - printf("Unable to set stylesheet, file not found or permisson issue. Tried loading [%s] and ", QString( QString("/usr/local/share/wfview/stylesheets/") + prefs.stylesheetPath).toStdString().c_str() ); - printf(" [%s]\n", QString( QString("/usr/share/wfview/stylesheets/") + prefs.stylesheetPath).toStdString().c_str() ); - printf("Unsetting stylesheet."); - qApp->setStyleSheet(""); -#endif } else { - // Not custom, proceed without: qApp->setStyleSheet(""); } } @@ -3955,9 +3925,6 @@ void wfmain::on_bandGenbtn_clicked() void wfmain::on_aboutBtn_clicked() { abtBox->show(); - - - } void wfmain::on_fStoBtn_clicked()