Skip to content

Commit a27ff3e

Browse files
committed
HelpPlugin: reduce warning build on Windows
The warings code from using the environment variable in a way MSVC does not like. This is used to write the desktop file - which is not needed on windows. So make this function a stub, and reduce includes on Windows.
1 parent d09cfef commit a27ff3e

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

src/plugins/help/help_plg.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
*/
88

99
#include <cstdlib>
10-
#include <filesystem>
11-
#include <fstream>
1210
#include <iostream>
1311
#include <string>
1412

@@ -47,6 +45,9 @@
4745
#include <windows.h>
4846
#else
4947
#include <unistd.h>
48+
// Needed for saving the desktop file
49+
#include <filesystem>
50+
#include <fstream>
5051
#endif
5152

5253
#if defined(__linux__)
@@ -101,8 +102,9 @@ You can also load projects, build and execute them:
101102
)";
102103

103104
auto static createDesktopMenuItem(const std::string &programName, const std::string &version,
104-
const std::string &execPath, const std::string &svgIconContent)
105-
-> std::string {
105+
const std::string &execPath,
106+
const std::string &svgIconContent) -> std::string {
107+
#if !defined(_WIN32)
106108
const char *homeDir = std::getenv("HOME");
107109
if (!homeDir) {
108110
std::cerr << "Unable to get HOME directory" << std::endl;
@@ -145,6 +147,14 @@ auto static createDesktopMenuItem(const std::string &programName, const std::str
145147
<< "Terminal=false\n";
146148
file.close();
147149
return desktopFile.string();
150+
#else
151+
// all this does not make sence on Windows
152+
Q_UNUSED(programName)
153+
Q_UNUSED(version)
154+
Q_UNUSED(execPath)
155+
Q_UNUSED(svgIconContent)
156+
return {};
157+
#endif
148158
}
149159

150160
auto static getExecutablePath() -> std::string {
@@ -540,10 +550,9 @@ void HelpPlugin::actionAbout_triggered() {
540550

541551
auto contentWidget = new QWidget;
542552
auto contentLayout = new QVBoxLayout(contentWidget);
543-
auto textLabel = new QLabel(aboutText.arg(appName)
544-
.arg(version)
545-
.arg("https://github.com/codepointerapp/codepointer")
546-
.arg("https://gitlab.com/codepointer/codepointer"));
553+
auto textLabel =
554+
new QLabel(aboutText.arg(appName, version, "https://github.com/codepointerapp/codepointer",
555+
"https://gitlab.com/codepointer/codepointer"));
547556
textLabel->setWordWrap(true);
548557
textLabel->setOpenExternalLinks(true);
549558
textLabel->setTextFormat(Qt::RichText);

0 commit comments

Comments
 (0)