Changeset - 6862f9405cdb
[Not reviewed]
Mehmet Aslan - 6 years ago 2019-04-04 03:23:29
aaslan-mehmet@hotmail.com
Nonexisting configuration file log changed and handled.
Minor name changes and fixes.
3 files changed with 13 insertions and 11 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -178,7 +178,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} 
 
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVERSION_MINOR=${VERSION_MINOR} ")
 
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVERSION_PATCH=${VERSION_PATCH} ")
 
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVERSION_REVISION=\\\"${VERSION_REVISION}\\\" ")
 
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROGRAM_NAME_STRING=\\\"${PROGRAM_NAME}\\\" ")
 
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DPROGRAM_NAME=\\\"${PROGRAM_NAME}\\\" ")
 

	
 
# add make run target
 
add_custom_target(run
src/main.cpp
Show inline comments
 
@@ -70,7 +70,7 @@ void messageHandler(QtMsgType type, cons
 
int main(int argc, char *argv[])
 
{
 
    QApplication a(argc, argv);
 
    QApplication::setApplicationName(PROGRAM_NAME_STRING);
 
    QApplication::setApplicationName(PROGRAM_NAME);
 
    QApplication::setApplicationVersion(VERSION_STRING);
 

	
 
    qInstallMessageHandler(messageHandler);
src/mainwindow.cpp
Show inline comments
 
@@ -35,6 +35,7 @@
 
#include <limits.h>
 
#include <cmath>
 
#include <iostream>
 
#include <cstdlib>
 

	
 
#include <plot.h>
 
#include <barplot.h>
 
@@ -253,9 +254,11 @@ MainWindow::MainWindow(QWidget *parent) 
 
    onSourceChanged(dataFormatPanel.activeSource());
 

	
 
    // load default settings
 
    QSettings settings(PROGRAM_NAME_STRING, PROGRAM_NAME_STRING);
 
    QSettings settings(PROGRAM_NAME, PROGRAM_NAME);
 
    loadAllSettings(&settings);
 

	
 
    handleCommandLineOptions(*QApplication::instance());
 

	
 
    // ensure command panel has 1 command if none loaded
 
    if (!commandPanel.numOfCommands())
 
    {
 
@@ -270,8 +273,6 @@ MainWindow::MainWindow(QWidget *parent) 
 
                this->ui->tabWidget->setCurrentWidget(&commandPanel);
 
                this->ui->tabWidget->showTabs();
 
            });
 

	
 
    handleCommandLineOptions(*QApplication::instance());
 
}
 

	
 
MainWindow::~MainWindow()
 
@@ -304,7 +305,7 @@ void MainWindow::closeEvent(QCloseEvent 
 
    }
 

	
 
    // save settings
 
    QSettings settings(PROGRAM_NAME_STRING, PROGRAM_NAME_STRING);
 
    QSettings settings(PROGRAM_NAME, PROGRAM_NAME);
 
    saveAllSettings(&settings);
 
    settings.sync();
 

	
 
@@ -601,21 +602,21 @@ void MainWindow::handleCommandLineOption
 
    parser.addHelpOption();
 
    parser.addVersionOption();
 

	
 
    QCommandLineOption loadOpt({"l", "load"}, "Load settings from file.", "filename");
 
    QCommandLineOption configOpt({"c", "config"}, "Load configuration from file.", "filename");
 
    QCommandLineOption portOpt({"p", "port"}, "Set port name.", "port name");
 
    QCommandLineOption baudrateOpt({"b" ,"baudrate"}, "Set port baud rate.", "baud rate");
 
    QCommandLineOption openPortOpt({"o", "open"}, "Open serial port.");
 

	
 
    parser.addOption(loadOpt);
 
    parser.addOption(configOpt);
 
    parser.addOption(portOpt);
 
    parser.addOption(baudrateOpt);
 
    parser.addOption(openPortOpt);
 

	
 
    parser.process(app);
 

	
 
    if (parser.isSet(loadOpt))
 
    if (parser.isSet(configOpt))
 
    {
 
        QString fileName = parser.value(loadOpt);
 
        QString fileName = parser.value(configOpt);
 
        QFileInfo fileInfo(fileName);
 

	
 
        if (fileInfo.exists() && fileInfo.isFile())
 
@@ -625,7 +626,8 @@ void MainWindow::handleCommandLineOption
 
        }
 
        else
 
        {
 
            qWarning() << "Ini file not exist";
 
            qCritical() << "Configuration file not exist. Closing application.";
 
            std::exit(1);
 
        }
 
    }
 

	
0 comments (0 inline, 0 general)