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(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(GUI "Build GUI elements" OFF) # additional dependencies to QT libraries needed
|
||||
set(WinBuild false)
|
||||
option(GUI "Build GUI elements" ON) # additional dependencies to QT libraries needed
|
||||
set(WinBuild true)
|
||||
|
||||
# helper variables
|
||||
SET(CMAKE_CXX_STANDARD 17)
|
||||
@ -99,6 +99,10 @@ if (${WinBuild})
|
||||
message(STATUS "Using LIBCONFIG++ lib(s): ${LIBCONFIG++_LIBRARIES}")
|
||||
|
||||
include_directories(${LIBCONFIG++_INCLUDE_DIRS} inc)
|
||||
|
||||
if (${GUI})
|
||||
set(CMAKE_PREFIX_PATH "/usr/${TOOLCHAIN_PREFIX}/sys-root/mingw/lib/cmake")
|
||||
endif ()
|
||||
else ()
|
||||
find_package(CURL REQUIRED)
|
||||
if (CURL_INCLUDE_DIRS AND CURL_LIBRARIES)
|
||||
@ -130,6 +134,15 @@ else ()
|
||||
include_directories(${LIBCONFIG_INCLUDE_DIRS})
|
||||
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("")
|
||||
|
||||
#read sample config
|
||||
@ -175,12 +188,6 @@ add_executable(iprefresher src/main.cpp)
|
||||
target_link_libraries(iprefresher dynuiprefresher api ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES})
|
||||
|
||||
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(UI_SOURCES
|
||||
|
@ -1,22 +1,24 @@
|
||||
#include <inc/api/IPAPI.h>
|
||||
#include <inc/IPRefresher.h>
|
||||
#include "MainWindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
#include "inc/Config.h"
|
||||
#include "inc/Logger.h"
|
||||
#include "api/IPAPI.h"
|
||||
#include "IPRefresher.h"
|
||||
#include "Config.h"
|
||||
#include "Logger.h"
|
||||
|
||||
#include <thread>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||
ui->setupUi(this);
|
||||
|
||||
// needs to be defined out of scope -- would be termintated after this constructor.
|
||||
// myThread = std::thread([this](){
|
||||
// IPAPI ipapi;
|
||||
// std::string ip = ipapi.getGlobalIp();
|
||||
// Logger::message("Current global IP: " + ip);
|
||||
// std::string msg = "Your current global IP: "+ip;
|
||||
// ui->labelCurrentIP->setText(msg.c_str());
|
||||
// });
|
||||
new std::thread([this]() {
|
||||
IPAPI ipapi;
|
||||
std::string ip = ipapi.getGlobalIp();
|
||||
Logger::message("Current global IP: " + ip);
|
||||
std::string msg = "Your current global IP: " + ip;
|
||||
this->ui->labelCurrentIP->setText(msg.c_str());
|
||||
});
|
||||
|
||||
|
||||
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(this, SIGNAL(appendLogField(QString)), ui->textLog, SLOT(appendPlainText(QString)));
|
||||
// connect(this, SIGNAL(setProgressBarValue(int)), ui->progressmanual, SLOT(setValue(int)));
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
@ -63,21 +64,6 @@ new std::thread([this](){
|
||||
}
|
||||
|
||||
Logger::message("Finished refreshing Dynu IP.");
|
||||
appendLogField("Finished refreshing Dynu IP.");
|
||||
delete this;
|
||||
this->appendLogField("Finished refreshing Dynu IP.");
|
||||
});
|
||||
// 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
|
||||
|
||||
#include <thread>
|
||||
#include <QtWidgets/QMainWindow>
|
||||
|
||||
namespace Ui {
|
||||
@ -16,17 +15,18 @@ Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = nullptr);
|
||||
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
std::thread myThread;
|
||||
private slots:
|
||||
// void startdownloadBtn();
|
||||
|
||||
void checkConfigBtn();
|
||||
|
||||
void refreshIPBtn();
|
||||
|
||||
signals:
|
||||
|
||||
void appendLogField(QString);
|
||||
// void setInfoLabelText(QString);
|
||||
// void setProgressBarValue(int);
|
||||
};
|
@ -8,6 +8,7 @@
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
std::cout << "gui here!" << std::endl;
|
||||
QCoreApplication::addLibraryPath(".");
|
||||
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
|
Loading…
Reference in New Issue
Block a user