added better thread management
cross compilation features.
This commit is contained in:
parent
ab772aac55
commit
0eea7095e0
@ -19,8 +19,8 @@ SET(LIB_METHOD STATIC) #SHARED / STATIC
|
|||||||
option(BUILD_DOC "Build documentation" ON) # additional dependency for Doxygen
|
option(BUILD_DOC "Build documentation" ON) # additional dependency for Doxygen
|
||||||
option(PACKAGING "Allow Packaging to <exe>, <deb> or <rpm>" ON) # additional dependencies for RPMbuild,dpkg or NSIS
|
option(PACKAGING "Allow Packaging to <exe>, <deb> or <rpm>" ON) # additional dependencies for RPMbuild,dpkg or NSIS
|
||||||
option(TESTS "Build Tests" ON) # additional dependencies for GTEST - to build tests
|
option(TESTS "Build Tests" ON) # additional dependencies for GTEST - to build tests
|
||||||
option(GUI "Build GUI elements" OFF) # additional dependencies to QT libraries needed
|
option(GUI "Build GUI elements" ON) # additional dependencies to QT libraries needed
|
||||||
set(WinBuild false)
|
set(WinBuild true)
|
||||||
|
|
||||||
# helper variables
|
# helper variables
|
||||||
SET(CMAKE_CXX_STANDARD 17)
|
SET(CMAKE_CXX_STANDARD 17)
|
||||||
@ -99,6 +99,10 @@ if (${WinBuild})
|
|||||||
message(STATUS "Using LIBCONFIG++ lib(s): ${LIBCONFIG++_LIBRARIES}")
|
message(STATUS "Using LIBCONFIG++ lib(s): ${LIBCONFIG++_LIBRARIES}")
|
||||||
|
|
||||||
include_directories(${LIBCONFIG++_INCLUDE_DIRS} inc)
|
include_directories(${LIBCONFIG++_INCLUDE_DIRS} inc)
|
||||||
|
|
||||||
|
if (${GUI})
|
||||||
|
set(CMAKE_PREFIX_PATH "/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/lib/cmake")
|
||||||
|
endif ()
|
||||||
else ()
|
else ()
|
||||||
find_package(CURL REQUIRED)
|
find_package(CURL REQUIRED)
|
||||||
if (CURL_INCLUDE_DIRS AND CURL_LIBRARIES)
|
if (CURL_INCLUDE_DIRS AND CURL_LIBRARIES)
|
||||||
@ -130,6 +134,15 @@ else ()
|
|||||||
include_directories(${LIBCONFIG_INCLUDE_DIRS})
|
include_directories(${LIBCONFIG_INCLUDE_DIRS})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
if (${GUI})
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
|
find_package(Qt5Widgets REQUIRED)
|
||||||
|
find_package(Qt5PrintSupport REQUIRED)
|
||||||
|
find_package(Qt5Sql REQUIRED)
|
||||||
|
endif ()
|
||||||
|
|
||||||
message("")
|
message("")
|
||||||
|
|
||||||
#read sample config
|
#read sample config
|
||||||
@ -175,12 +188,6 @@ add_executable(iprefresher src/main.cpp)
|
|||||||
target_link_libraries(iprefresher dynuiprefresher api ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES})
|
target_link_libraries(iprefresher dynuiprefresher api ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES})
|
||||||
|
|
||||||
if (${GUI})
|
if (${GUI})
|
||||||
set(CMAKE_AUTOMOC ON)
|
|
||||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
||||||
|
|
||||||
find_package(Qt5Widgets REQUIRED)
|
|
||||||
find_package(Qt5PrintSupport REQUIRED)
|
|
||||||
find_package(Qt5Sql REQUIRED)
|
|
||||||
set(QT5_LIBRARIES Qt5::Widgets Qt5::PrintSupport Qt5::Sql)
|
set(QT5_LIBRARIES Qt5::Widgets Qt5::PrintSupport Qt5::Sql)
|
||||||
|
|
||||||
set(UI_SOURCES
|
set(UI_SOURCES
|
||||||
|
@ -1,22 +1,24 @@
|
|||||||
#include <inc/api/IPAPI.h>
|
|
||||||
#include <inc/IPRefresher.h>
|
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
#include "inc/Config.h"
|
#include "api/IPAPI.h"
|
||||||
#include "inc/Logger.h"
|
#include "IPRefresher.h"
|
||||||
|
#include "Config.h"
|
||||||
|
#include "Logger.h"
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
// needs to be defined out of scope -- would be termintated after this constructor.
|
// needs to be defined out of scope -- would be termintated after this constructor.
|
||||||
// myThread = std::thread([this](){
|
new std::thread([this]() {
|
||||||
// IPAPI ipapi;
|
IPAPI ipapi;
|
||||||
// std::string ip = ipapi.getGlobalIp();
|
std::string ip = ipapi.getGlobalIp();
|
||||||
// Logger::message("Current global IP: " + ip);
|
Logger::message("Current global IP: " + ip);
|
||||||
// std::string msg = "Your current global IP: "+ip;
|
std::string msg = "Your current global IP: " + ip;
|
||||||
// ui->labelCurrentIP->setText(msg.c_str());
|
this->ui->labelCurrentIP->setText(msg.c_str());
|
||||||
// });
|
});
|
||||||
|
|
||||||
|
|
||||||
if (Config::validateConfig())
|
if (Config::validateConfig())
|
||||||
@ -28,7 +30,6 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
connect(ui->buttonRefreshIP, SIGNAL(clicked()), this, SLOT(refreshIPBtn()));
|
connect(ui->buttonRefreshIP, SIGNAL(clicked()), this, SLOT(refreshIPBtn()));
|
||||||
|
|
||||||
connect(this, SIGNAL(appendLogField(QString)), ui->textLog, SLOT(appendPlainText(QString)));
|
connect(this, SIGNAL(appendLogField(QString)), ui->textLog, SLOT(appendPlainText(QString)));
|
||||||
// connect(this, SIGNAL(setProgressBarValue(int)), ui->progressmanual, SLOT(setValue(int)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow() {
|
MainWindow::~MainWindow() {
|
||||||
@ -63,21 +64,6 @@ new std::thread([this](){
|
|||||||
}
|
}
|
||||||
|
|
||||||
Logger::message("Finished refreshing Dynu IP.");
|
Logger::message("Finished refreshing Dynu IP.");
|
||||||
appendLogField("Finished refreshing Dynu IP.");
|
this->appendLogField("Finished refreshing Dynu IP.");
|
||||||
delete this;
|
|
||||||
});
|
});
|
||||||
// myThread = std::thread([this](){
|
|
||||||
// IPRefresher ipr;
|
|
||||||
// if (Config::readConfig()) {
|
|
||||||
// ipr.checkIPAdress(false);
|
|
||||||
// } else {
|
|
||||||
// std::cout << "incorrect credentials!" << std::endl;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Logger::message("Finished refreshing Dynu IP.");
|
|
||||||
// appendLogField("Finished refreshing Dynu IP.");
|
|
||||||
// ui->textLog->appendPlainText("Finished refreshing Dynu IP.");
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <thread>
|
|
||||||
#include <QtWidgets/QMainWindow>
|
#include <QtWidgets/QMainWindow>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
@ -16,17 +15,18 @@ Q_OBJECT
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = nullptr);
|
explicit MainWindow(QWidget *parent = nullptr);
|
||||||
|
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
std::thread myThread;
|
|
||||||
private slots:
|
private slots:
|
||||||
// void startdownloadBtn();
|
|
||||||
void checkConfigBtn();
|
void checkConfigBtn();
|
||||||
|
|
||||||
void refreshIPBtn();
|
void refreshIPBtn();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
void appendLogField(QString);
|
void appendLogField(QString);
|
||||||
// void setInfoLabelText(QString);
|
|
||||||
// void setProgressBarValue(int);
|
|
||||||
};
|
};
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
std::cout << "gui here!" << std::endl;
|
std::cout << "gui here!" << std::endl;
|
||||||
|
QCoreApplication::addLibraryPath(".");
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
Loading…
Reference in New Issue
Block a user