@@ -30,12 +30,11 @@ MainWindow::MainWindow(QWidget *parent, const char* config_file): QMainWindow(pa
3030{
3131 m_AppVersion.Major = 1 ;
3232 m_AppVersion.Minor = 15 ;
33- m_AppVersion.Bugfix = 0 ;
33+ m_AppVersion.Bugfix = 1 ;
3434
3535 ui->setupUi (this );
3636 m_bUseActiveShield = false ;
3737 m_bOverrideAutoUpdate = false ;
38- LoadConfig (config_file);
3938
4039 // make GUI connections
4140 QObject::connect (ui->actionQuit , SIGNAL (triggered ()), this , SLOT (close ()));
@@ -52,6 +51,33 @@ MainWindow::MainWindow(QWidget *parent, const char* config_file): QMainWindow(pa
5251 QObject::connect (ui->rbDefault , SIGNAL (clicked (bool )), this , SLOT (RadioButtonBehavior (bool )));
5352 QObject::connect (ui->rbMirror , SIGNAL (clicked (bool )), this , SLOT (RadioButtonBehavior (bool )));
5453 SetSamplingRate ();
54+ QString cfgfilepath = find_config_file (config_file);
55+ LoadConfig (cfgfilepath);
56+ }
57+
58+ QString MainWindow::find_config_file (const char * filename) {
59+ if (filename) {
60+ QString qfilename (filename);
61+ if (!QFileInfo::exists (qfilename))
62+ QMessageBox (QMessageBox::Warning, " Config file not found" ,
63+ QStringLiteral (" The file '%1' doesn't exist" ).arg (qfilename), QMessageBox::Ok,
64+ this );
65+ else
66+ return qfilename;
67+ }
68+ QFileInfo exeInfo (QCoreApplication::applicationFilePath ());
69+ QString defaultCfgFilename (exeInfo.completeBaseName () + " .cfg" );
70+ qInfo () << defaultCfgFilename;
71+ QStringList cfgpaths;
72+ cfgpaths << QDir::currentPath ()
73+ << QStandardPaths::standardLocations (QStandardPaths::ConfigLocation) << exeInfo.path ();
74+ for (auto path : cfgpaths) {
75+ QString cfgfilepath = path + QDir::separator () + defaultCfgFilename;
76+ if (QFileInfo::exists (cfgfilepath)) return cfgfilepath;
77+ }
78+ QMessageBox::warning (this , " No config file not found" ,
79+ QStringLiteral (" No default config file could be found" ), " Continue with default config" );
80+ return " " ;
5581}
5682
5783void MainWindow::VersionsDialog ()
0 commit comments