Skip to content

Commit

Permalink
Fix AboutDlg compilation on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
schorsch1976 committed Jun 21, 2019
1 parent 3aaaac4 commit 9197be4
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 913 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,25 +119,27 @@ ENDIF (WIN32)
######################################################################
# Version
######################################################################
find_package(Git REQUIRED)

# branch
EXECUTE_PROCESS(
COMMAND git rev-parse --abbrev-ref HEAD
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# commit hash
EXECUTE_PROCESS(
COMMAND git log -1 --format=%h
COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# description
EXECUTE_PROCESS(
COMMAND git describe --tags
COMMAND ${GIT_EXECUTABLE} describe --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DESCRIPTION
OUTPUT_STRIP_TRAILING_WHITESPACE
Expand Down
10 changes: 8 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,11 @@ SET(LIBS
Qt5::Core
)

ADD_EXECUTABLE(AsciiFlowQT ${SRCS})
TARGET_LINK_LIBRARIES(AsciiFlowQT ${LIBS})
IF(WIN32)
SET(SUBSYSTEM "WIN32")
ELSE(WIN32)
SET(SUBSYSTEM)
ENDIF(WIN32)

ADD_EXECUTABLE(AsciiFlowQT ${SUBSYSTEM} ${SRCS})
TARGET_LINK_LIBRARIES(AsciiFlowQT ${LIBS})
41 changes: 25 additions & 16 deletions src/about.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <QDebug>
#include <QDesktopServices>
#include <QRegularExpression>
#include <QUrl>

#define STRINGIFY(string) LOCALSTRING(string)
#define LOCALSTRING(string) #string
Expand All @@ -13,34 +15,41 @@ About::About(QWidget *parent) : QDialog(parent), ui(new Ui::About)

connect(ui->btnOk, &QPushButton::clicked, [this]() { this->close(); });

auto open_link = [](QString link) {
QRegularExpression ex("&");
link.remove(ex);
bool res = QDesktopServices::openUrl(QUrl(link));
if (!res)
{
qDebug() << "Failed to open url: " << link;
}
};

// Ascii flow
ui->labelAsciiFlowVersion->setText(STRINGIFY(GIT_COMMIT_HASH));
ui->labelAsciiFlowBranch->setText(STRINGIFY(GIT_BRANCH));
ui->labelAsciiFlowDescription->setText(STRINGIFY(GIT_DESCRIPTION));

connect(ui->commandLinkButtonHomeAsciiFlow, &QCommandLinkButton::pressed,
[this]() {
QString link = ui->commandLinkButtonHomeAsciiFlow->text();
link.remove(0, 1);
bool res = QDesktopServices::openUrl(QUrl(link));
if (!res)
{
qDebug() << "Failed to open url: " << link;
}
[this, open_link]() {
open_link(ui->commandLinkButtonHomeAsciiFlow->text());
});
connect(ui->commandLinkButtonAsciiFlowLicence, &QCommandLinkButton::pressed,
[this, open_link]() {
open_link(ui->commandLinkButtonAsciiFlowLicence->text());
});

// QT
ui->labelRunningQTVersion->setText(qVersion());
ui->labelCompiledQTVersion->setText(QT_VERSION_STR);

connect(ui->commandLinkButtonHomeQT, &QCommandLinkButton::pressed,
[this]() {
QString link = ui->commandLinkButtonHomeQT->text();
link.remove(0, 1);
bool res = QDesktopServices::openUrl(QUrl(link));
if (!res)
{
qDebug() << "Failed to open url: " << link;
}
[this, open_link]() {
open_link(ui->commandLinkButtonHomeQT->text());
});
connect(ui->commandLinkButtonQTLicence, &QCommandLinkButton::pressed,
[this, open_link]() {
open_link(ui->commandLinkButtonQTLicence->text());
});
}

Expand Down
Loading

0 comments on commit 9197be4

Please sign in to comment.