first qt gui steps
This commit is contained in:
parent
826386e849
commit
c25996a925
@ -19,6 +19,7 @@ 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" ON) # additional dependencies to QT libraries needed
|
||||
set(WinBuild false)
|
||||
|
||||
# helper variables
|
||||
@ -173,6 +174,34 @@ add_executable(iprefresher src/main.cpp)
|
||||
# LINK generated LIBS #
|
||||
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
|
||||
src/gui/mainwindow.ui
|
||||
)
|
||||
|
||||
#
|
||||
# Generate necessary headers from .ui files. (qmake lets `uic` do this job.)
|
||||
# hint from [Cross-platform Qt5 project using cmake](http://stackoverflow.com/questions/21174586/cross-platform-qt5-project-using-cmake)
|
||||
#
|
||||
qt5_wrap_ui(UI_GENERATED_HEADERS ${UI_SOURCES})
|
||||
|
||||
add_executable(iprefresher-gui
|
||||
src/maingui.cpp
|
||||
src/gui/MainWindow.cpp
|
||||
src/gui/MainWindow.h ${UI_GENERATED_HEADERS})
|
||||
|
||||
# LINK generated LIBS #
|
||||
target_link_libraries(iprefresher-gui dynuiprefresher api ${CURL_LIBRARIES} ${LIBCONFIG++_LIBRARIES} ${QT5_LIBRARIES})
|
||||
endif ()
|
||||
|
||||
# setting install targets
|
||||
IF (NOT ${WinBuild})
|
||||
# INSTALL to Linux SYSTEM #
|
||||
|
38
src/gui/MainWindow.cpp
Normal file
38
src/gui/MainWindow.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
//
|
||||
// Created by lukas on 09.05.20.
|
||||
//
|
||||
|
||||
#include <iostream>
|
||||
#include "MainWindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent), ui(new Ui::MainWindow) {
|
||||
|
||||
ui->setupUi(this);
|
||||
ui->textLog->
|
||||
|
||||
// ui->labelCurrentIP->setText("currently is nothing to do");
|
||||
// ui->labelConfig->setText("blabliblub");
|
||||
// ui->textfieldname->setText("hangover");
|
||||
|
||||
connect(ui->buttonCheckConfig, SIGNAL(clicked()), this, SLOT(checkConfigBtn()));
|
||||
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() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::checkConfigBtn() {
|
||||
std::cout << "btn clicked!" << std::endl;
|
||||
|
||||
appendLogField("btn clicked! \n");
|
||||
}
|
||||
|
||||
void MainWindow::refreshIPBtn() {
|
||||
|
||||
}
|
31
src/gui/MainWindow.h
Normal file
31
src/gui/MainWindow.h
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// Created by lukas on 09.05.20.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <QtWidgets/QMainWindow>
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
class MainWindow : public QMainWindow{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
private slots:
|
||||
// void startdownloadBtn();
|
||||
void checkConfigBtn();
|
||||
void refreshIPBtn();
|
||||
signals:
|
||||
void appendLogField(QString);
|
||||
// void setInfoLabelText(QString);
|
||||
// void setProgressBarValue(int);
|
||||
};
|
103
src/gui/mainwindow.ui
Normal file
103
src/gui/mainwindow.ui
Normal file
@ -0,0 +1,103 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>823</width>
|
||||
<height>618</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<widget class="QPushButton" name="buttonRefreshIP">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>290</x>
|
||||
<y>300</y>
|
||||
<width>91</width>
|
||||
<height>33</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Refresh IP</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelCurrentIP">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>60</y>
|
||||
<width>161</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Your current global IP:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPlainTextEdit" name="textLog">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>410</y>
|
||||
<width>691</width>
|
||||
<height>191</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="cursor" stdset="0">
|
||||
<cursorShape>IBeamCursor</cursorShape>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>40</x>
|
||||
<y>380</y>
|
||||
<width>64</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Log:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="buttonCheckConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>140</y>
|
||||
<width>91</width>
|
||||
<height>33</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Check Config</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="labelConfig">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>270</x>
|
||||
<y>180</y>
|
||||
<width>141</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Config is: undefined</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
17
src/maingui.cpp
Normal file
17
src/maingui.cpp
Normal file
@ -0,0 +1,17 @@
|
||||
//
|
||||
// Created by lukas on 09.05.20.
|
||||
//
|
||||
|
||||
#include <QApplication>
|
||||
#include <iostream>
|
||||
#include "gui/MainWindow.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
std::cout << "gui here!" << std::endl;
|
||||
|
||||
QApplication a(argc, argv);
|
||||
MainWindow w;
|
||||
w.show();
|
||||
|
||||
return QApplication::exec();
|
||||
}
|
Loading…
Reference in New Issue
Block a user