feat: Show Git SHA in Windows daemon version number
This commit is contained in:
committed by
Chris Rizzitello
parent
5d310be807
commit
f6ccd2a25b
@ -25,6 +25,7 @@ if(WIN32)
|
||||
net
|
||||
platform
|
||||
app
|
||||
common
|
||||
${libs}
|
||||
Qt6::Core)
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "arch/Arch.h"
|
||||
#include "base/Log.h"
|
||||
#include "common/constants.h"
|
||||
#include "common/version.h"
|
||||
#include "deskflow/DaemonApp.h"
|
||||
#include "deskflow/ipc/DaemonIpcServer.h"
|
||||
|
||||
@ -61,7 +62,7 @@ int main(int argc, char **argv)
|
||||
// which is not useful for troubleshooting Windows services.
|
||||
// It's important to write the version number to the log file so we can be certain the old daemon
|
||||
// was uninstalled, since sometimes Windows services can get stuck and fail to be removed.
|
||||
LOG_PRINT("%s Daemon (v%s)", kAppName, kVersion);
|
||||
LOG_PRINT("%s Daemon v%s", kAppName, displayVersion().toStdString().c_str());
|
||||
|
||||
switch (initResult) {
|
||||
using enum DaemonApp::InitResult;
|
||||
|
||||
@ -107,6 +107,7 @@ add_executable(${target} WIN32 MACOSX_BUNDLE
|
||||
target_link_libraries(
|
||||
${target}
|
||||
gui
|
||||
common
|
||||
Qt6::Core
|
||||
Qt6::Widgets
|
||||
Qt6::Network)
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
#include "ui_AboutDialog.h"
|
||||
|
||||
#include "common/constants.h"
|
||||
#include "gui/style_utils.h"
|
||||
#include "common/version.h"
|
||||
|
||||
#include <QClipboard>
|
||||
#include <QDateTime>
|
||||
@ -32,15 +32,7 @@ AboutDialog::AboutDialog(QWidget *parent) : QDialog(parent), ui{std::make_unique
|
||||
ui->btnCopyVersion->setIcon(QIcon::fromTheme(QIcon::ThemeIcon::EditCopy));
|
||||
connect(ui->btnCopyVersion, &QPushButton::clicked, this, &AboutDialog::copyVersionText);
|
||||
|
||||
// Set up the displayed version number
|
||||
auto versionString = QString(kVersion);
|
||||
if (versionString.endsWith(QStringLiteral(".0"))) {
|
||||
versionString.chop(2);
|
||||
} else {
|
||||
versionString.append(QStringLiteral(" (%1)").arg(kVersionGitSha));
|
||||
}
|
||||
|
||||
ui->lblVersion->setText(versionString);
|
||||
ui->lblVersion->setText(displayVersion());
|
||||
|
||||
ui->lblDescription->setText(kAppDescription);
|
||||
ui->lblCopyright->setText(kCopyright);
|
||||
|
||||
@ -7,6 +7,7 @@ configure_file(constants.h.in constants.h @ONLY)
|
||||
|
||||
add_library(common INTERFACE
|
||||
common.h
|
||||
version.h
|
||||
IInterface.h
|
||||
stdbitset.h
|
||||
stddeque.h
|
||||
@ -24,7 +25,9 @@ add_library(common INTERFACE
|
||||
${CMAKE_CURRENT_BINARY_DIR}/constants.h
|
||||
)
|
||||
|
||||
find_package(Qt6 COMPONENTS Core)
|
||||
target_link_libraries(common INTERFACE Qt6::Core)
|
||||
|
||||
if(APPLE)
|
||||
target_sources(common INTERFACE MacOSXPrecomp.h)
|
||||
endif()
|
||||
|
||||
|
||||
@ -41,11 +41,12 @@ enum
|
||||
kExitArgs = 3, // bad arguments
|
||||
kExitConfig = 4, // cannot read configuration
|
||||
};
|
||||
namespace deskflow::common {
|
||||
|
||||
#if WINAPI_MSWINDOWS
|
||||
namespace deskflow::common {
|
||||
|
||||
const auto kCloseEventName = "Global\\DeskflowClose";
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace deskflow::common
|
||||
|
||||
28
src/lib/common/version.h
Normal file
28
src/lib/common/version.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Deskflow -- mouse and keyboard sharing utility
|
||||
* SPDX-FileCopyrightText: (C) 2025 Symless Ltd.
|
||||
* SPDX-License-Identifier: GPL-2.0-only WITH LicenseRef-OpenSSL-Exception
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "common/constants.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
/**
|
||||
* @brief Get the version number string for display.
|
||||
*
|
||||
* If the version number ends with ".0", the ".0" is removed.
|
||||
* If the version number does not end with ".0", the git SHA is appended in parentheses.
|
||||
*/
|
||||
inline QString displayVersion()
|
||||
{
|
||||
auto versionString = QString(kVersion);
|
||||
if (versionString.endsWith(QStringLiteral(".0"))) {
|
||||
versionString.chop(2);
|
||||
} else {
|
||||
versionString.append(QStringLiteral(" (%1)").arg(kVersionGitSha));
|
||||
}
|
||||
return versionString;
|
||||
}
|
||||
Reference in New Issue
Block a user