further gui developments

This commit is contained in:
lukas 2020-05-10 15:00:51 +02:00
parent c25996a925
commit ab772aac55
4 changed files with 65 additions and 19 deletions

View File

@ -19,7 +19,7 @@ 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" ON) # additional dependencies to QT libraries needed option(GUI "Build GUI elements" OFF) # additional dependencies to QT libraries needed
set(WinBuild false) set(WinBuild false)
# helper variables # helper variables
@ -199,7 +199,7 @@ if (${GUI})
src/gui/MainWindow.h ${UI_GENERATED_HEADERS}) src/gui/MainWindow.h ${UI_GENERATED_HEADERS})
# LINK generated LIBS # # LINK generated LIBS #
target_link_libraries(iprefresher-gui dynuiprefresher api ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES} ${QT5_LIBRARIES}) target_link_libraries(iprefresher-gui -lpthread dynuiprefresher api ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES} ${QT5_LIBRARIES})
endif () endif ()
# setting install targets # setting install targets

View File

@ -1,20 +1,28 @@
// #include <inc/api/IPAPI.h>
// Created by lukas on 09.05.20. #include <inc/IPRefresher.h>
//
#include <iostream>
#include "MainWindow.h" #include "MainWindow.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) : #include "inc/Config.h"
QMainWindow(parent), ui(new Ui::MainWindow) { #include "inc/Logger.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) {
ui->setupUi(this); ui->setupUi(this);
ui->textLog->
// ui->labelCurrentIP->setText("currently is nothing to do"); // needs to be defined out of scope -- would be termintated after this constructor.
// ui->labelConfig->setText("blabliblub"); // myThread = std::thread([this](){
// ui->textfieldname->setText("hangover"); // 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());
// });
if (Config::validateConfig())
ui->labelConfig->setText("Config is: OK");
else
ui->labelConfig->setText("Config is: NOT OK");
connect(ui->buttonCheckConfig, SIGNAL(clicked()), this, SLOT(checkConfigBtn())); connect(ui->buttonCheckConfig, SIGNAL(clicked()), this, SLOT(checkConfigBtn()));
connect(ui->buttonRefreshIP, SIGNAL(clicked()), this, SLOT(refreshIPBtn())); connect(ui->buttonRefreshIP, SIGNAL(clicked()), this, SLOT(refreshIPBtn()));
@ -28,11 +36,48 @@ MainWindow::~MainWindow() {
} }
void MainWindow::checkConfigBtn() { void MainWindow::checkConfigBtn() {
std::cout << "btn clicked!" << std::endl; Logger::message("checking config!");
appendLogField("checking config!");
appendLogField("btn clicked! \n"); if (Config::validateConfig()) {
Logger::message("Config file is OK");
appendLogField("Config file is OK");
ui->labelConfig->setText("Config is: OK");
} else {
Logger::error("There are errors in config file!");
appendLogField("There are errors in config file!");
}
appendLogField("");
} }
void MainWindow::refreshIPBtn() { void MainWindow::refreshIPBtn() {
Logger::message("start refreshing Dynu IP.");
appendLogField("");
appendLogField("start refreshing Dynu IP.");
new 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.");
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.");
// });
} }

View File

@ -4,7 +4,7 @@
#pragma once #pragma once
#include <thread>
#include <QtWidgets/QMainWindow> #include <QtWidgets/QMainWindow>
namespace Ui { namespace Ui {
@ -15,11 +15,12 @@ class MainWindow : public QMainWindow{
Q_OBJECT Q_OBJECT
public: public:
explicit MainWindow(QWidget *parent = 0); 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 startdownloadBtn();
void checkConfigBtn(); void checkConfigBtn();

View File

@ -32,7 +32,7 @@
<rect> <rect>
<x>40</x> <x>40</x>
<y>60</y> <y>60</y>
<width>161</width> <width>301</width>
<height>17</height> <height>17</height>
</rect> </rect>
</property> </property>
@ -42,7 +42,7 @@
</widget> </widget>
<widget class="QPlainTextEdit" name="textLog"> <widget class="QPlainTextEdit" name="textLog">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>false</bool>
</property> </property>
<property name="geometry"> <property name="geometry">
<rect> <rect>