forked from Reveares/WayNetConverter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
231 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,62 @@ | ||
cmake_minimum_required (VERSION 3.8) | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
add_executable (WayNetConverter "main.cpp" "Converter.cpp" "Converter.h" "Waypoint.h") | ||
project(WayNetConverter_QT VERSION 0.1 LANGUAGES CXX) | ||
|
||
set(CMAKE_AUTOUIC ON) | ||
set(CMAKE_AUTOMOC ON) | ||
set(CMAKE_AUTORCC ON) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) | ||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets) | ||
|
||
set(PROJECT_SOURCES | ||
main.cpp | ||
Converter.cpp | ||
Converter.h | ||
Waypoint.h | ||
mainwindow.ui | ||
) | ||
|
||
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) | ||
qt_add_executable(WayNetConverter_QT | ||
MANUAL_FINALIZATION | ||
${PROJECT_SOURCES} | ||
) | ||
# Define target properties for Android with Qt 6 as: | ||
# set_property(TARGET WayNetConverter_QT APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR | ||
# ${CMAKE_CURRENT_SOURCE_DIR}/android) | ||
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation | ||
else() | ||
if(ANDROID) | ||
add_library(WayNetConverter_QT SHARED | ||
${PROJECT_SOURCES} | ||
) | ||
# Define properties for Android with Qt 5 after find_package() calls as: | ||
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android") | ||
else() | ||
add_executable(WayNetConverter_QT | ||
${PROJECT_SOURCES} | ||
) | ||
endif() | ||
endif() | ||
|
||
target_link_libraries(WayNetConverter_QT PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) | ||
|
||
set_target_properties(WayNetConverter_QT PROPERTIES | ||
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com | ||
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION} | ||
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR} | ||
MACOSX_BUNDLE TRUE | ||
WIN32_EXECUTABLE TRUE | ||
) | ||
|
||
install(TARGETS WayNetConverter_QT | ||
BUNDLE DESTINATION . | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
|
||
if(QT_VERSION_MAJOR EQUAL 6) | ||
qt_finalize_executable(WayNetConverter_QT) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,98 @@ | ||
#include <iostream> | ||
#include <chrono> | ||
#include "Converter.h" | ||
#include <QtWidgets/QApplication> | ||
#include <QtWidgets/QMainWindow> | ||
#include <QtWidgets/QPushButton> | ||
#include <QtWidgets/QFileDialog> | ||
#include <QtWidgets/QStatusBar> | ||
#include <QtWidgets/QVBoxLayout> | ||
|
||
class MainWindow : public QMainWindow | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
MainWindow(QWidget *parent = nullptr) : QMainWindow(parent) | ||
{ | ||
auto layout = new QVBoxLayout(); | ||
|
||
openZenButton = new QPushButton(tr("Zen öffnen"), this); | ||
layout->addWidget(openZenButton); | ||
|
||
convertButton = new QPushButton(tr("Konvertieren"), this); | ||
convertButton->setEnabled(false); | ||
layout->addWidget(convertButton); | ||
|
||
auto centralWidget = new QWidget(); | ||
centralWidget->setLayout(layout); | ||
setCentralWidget(centralWidget); | ||
|
||
setStatusBar(new QStatusBar()); | ||
statusBar()->showMessage(tr("Bitte wählen Sie eine ZEN-Datei.")); | ||
connect(openZenButton, &QPushButton::clicked, this, &MainWindow::openZen); | ||
connect(convertButton, &QPushButton::clicked, this, &MainWindow::convert); | ||
} | ||
|
||
private slots: | ||
void openZen() | ||
{ | ||
QString fileName = QFileDialog::getOpenFileName(this, tr("Open .zen File"), QDir::homePath(), tr(".zen Files (*.zen)")); | ||
if (!fileName.isEmpty()) { | ||
// call the read function of the Converter class with the selected file name | ||
selectedFile = fileName; | ||
statusBar()->showMessage(selectedFile); | ||
convertButton->setEnabled(true); | ||
} | ||
} | ||
|
||
void convert() | ||
{ | ||
QString outputFile = QFileDialog::getSaveFileName(this, tr("Save Converted File"), QDir::homePath(), tr(".wp Files (*.wp)")); | ||
if (!outputFile.isEmpty()) { | ||
// call the read and write functions of the Converter class with the selected file names | ||
Converter converter; | ||
converter.read(selectedFile.toStdString()); | ||
converter.write(outputFile.toStdString()); | ||
statusBar()->showMessage("Konvertierung abgeschlossen."); | ||
} | ||
} | ||
|
||
|
||
|
||
private: | ||
QPushButton *openZenButton; | ||
QPushButton *convertButton; | ||
QString selectedFile; | ||
}; | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
std::cout << "Reveares' Waypoint Converter" << std::endl << std::endl; | ||
/* | ||
std::cout << "Reveares' Waypoint Converter" << std::endl << std::endl; | ||
if (argc != 3) | ||
{ | ||
std::cerr << "2 Arguments are needed!" << std::endl << "first: path/to/file.zen" << std::endl << "second: filename.wp" << std::endl; | ||
return -1; | ||
} | ||
if (argc != 3) | ||
{ | ||
std::cerr << "2 Arguments are needed!" << std::endl << "first: path/to/file.zen" << std::endl << "second: filename.wp" << std::endl; | ||
return -1; | ||
} | ||
auto start = std::chrono::high_resolution_clock::now(); | ||
auto start = std::chrono::high_resolution_clock::now(); | ||
Converter converter; | ||
converter.read(argv[1]); | ||
converter.write(argv[2]); | ||
Converter converter; | ||
converter.read(argv[1]); | ||
converter.write(argv[2]); | ||
auto end = std::chrono::high_resolution_clock::now(); | ||
std::cout << "Which took " << std::chrono::duration<double>(end - start).count() << " seconds." << std::endl; | ||
auto end = std::chrono::high_resolution_clock::now(); | ||
std::cout << "Which took " << std::chrono::duration<double>(end - start).count() << " seconds." << std::endl; | ||
*/ | ||
|
||
return 0; | ||
QApplication app(argc, argv); | ||
|
||
MainWindow mainWindow; | ||
mainWindow.show(); | ||
|
||
return app.exec(); | ||
} | ||
|
||
#include "main.moc" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?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>560</width> | ||
<height>174</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>MainWindow</string> | ||
</property> | ||
<widget class="QWidget" name="centralwidget"> | ||
<widget class="QPushButton" name="openZenButton"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>200</x> | ||
<y>20</y> | ||
<width>88</width> | ||
<height>34</height> | ||
</rect> | ||
</property> | ||
<property name="mouseTracking"> | ||
<bool>false</bool> | ||
</property> | ||
<property name="toolTip"> | ||
<string>Öffne eine Zen Datei</string> | ||
</property> | ||
<property name="text"> | ||
<string>Zen öffnen</string> | ||
</property> | ||
</widget> | ||
</widget> | ||
<widget class="QMenuBar" name="menubar"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>560</width> | ||
<height>30</height> | ||
</rect> | ||
</property> | ||
<widget class="QMenu" name="menuDatei"> | ||
<property name="title"> | ||
<string>Datei</string> | ||
</property> | ||
</widget> | ||
<addaction name="menuDatei"/> | ||
</widget> | ||
<widget class="QStatusBar" name="statusbar"/> | ||
<action name="actionZen_ffnen"> | ||
<property name="text"> | ||
<string>Zen öffnen</string> | ||
</property> | ||
</action> | ||
<action name="actionBeenden"> | ||
<property name="text"> | ||
<string>Beenden</string> | ||
</property> | ||
</action> | ||
</widget> | ||
<resources/> | ||
<connections> | ||
<connection> | ||
<sender>openZenButton</sender> | ||
<signal>clicked()</signal> | ||
<receiver>openZenButton</receiver> | ||
<slot>click()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>77</x> | ||
<y>267</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>77</x> | ||
<y>267</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
</connections> | ||
</ui> |