diff --git a/SyntaxHighlighters/frequestjsonhighlighter.cpp b/SyntaxHighlighters/frequestjsonhighlighter.cpp index 7dc3964..3b7ea1c 100644 --- a/SyntaxHighlighters/frequestjsonhighlighter.cpp +++ b/SyntaxHighlighters/frequestjsonhighlighter.cpp @@ -17,6 +17,7 @@ along with this program. If not, see . * */ +#include #include "frequestjsonhighlighter.h" FRequestJSONHighlighter::FRequestJSONHighlighter(QTextDocument *parent) @@ -25,7 +26,7 @@ FRequestJSONHighlighter::FRequestJSONHighlighter(QTextDocument *parent) // Override colors for(HighlightingRule &currRule : this->rules){ - if(currRule.pattern == QRegExp("(true|false|null)(?!\"[^\"]*\")")){ + if(currRule.pattern == QRegularExpression("(true|false|null)(?!\"[^\"]*\")")){ //reserved words currRule.format.setForeground(QColor(0x0066ff)); break; diff --git a/main.cpp b/main.cpp index c1b748c..a2a641b 100755 --- a/main.cpp +++ b/main.cpp @@ -18,11 +18,14 @@ along with this program. If not, see . */ #include "mainwindow.h" +#include "utilglobalvars.h" #include int main(int argc, char *argv[]) { + QCoreApplication::setApplicationName(GlobalVars::AppName); QApplication a(argc, argv); + MainWindow w; w.show(); a.setStyleSheet("QStatusBar::item { border: 0px; }"); //hide borders in status bar //http://qt-project.org/forums/viewthread/18743 diff --git a/mainwindow.cpp b/mainwindow.cpp index 8c8eccd..4f505b8 100755 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -56,7 +56,7 @@ MainWindow::MainWindow(QWidget *parent) : // We use this appender because it is the native way to have \r\n in windows in plog library // example: https://github.com/SergiusTheBest/plog/blob/master/samples/NativeEOL/Main.cpp static plog::RollingFileAppender> fileAppender - (QSTR_TO_TEMPORARY_CSTR(Util::FileSystem::getAppPath() + "/" + GlobalVars::AppLogFileName), 1024*5 /* 5 Mb max log size */, 3); + (QSTR_TO_TEMPORARY_CSTR(UtilFRequest::getAppDataFolder().absoluteFilePath(GlobalVars::AppLogFileName)), 1024*5 /* 5 Mb max log size */, 3); plog::init(plog::info, &fileAppender); this->currentSettings = this->configFileManager.getCurrentSettings(); @@ -195,6 +195,21 @@ void MainWindow::applicationHasLoaded(){ this->applicationIsFullyLoaded = true; this->ignoreAnyChangesToProject.UnsetCondition(); + QStringList args = QCoreApplication::arguments(); + + if(args.size() >= 2){ + QString file = args.at(1); + + if(QFileInfo::exists(file)){ + loadProjectState(file); + + return; + } + else{ + Util::Dialogs::showWarning(QString("The project file \"%1\" does not exist.").arg(file)); + } + } + if(this->currentSettings.recentProjectsPaths.size() > 0){ const QString &lastSavedProject = this->currentSettings.recentProjectsPaths[0]; diff --git a/mainwindow.h b/mainwindow.h index 9fb41cd..b0dacf2 100755 --- a/mainwindow.h +++ b/mainwindow.h @@ -222,7 +222,7 @@ private slots: QList recentProjectsList; QString lastResponseFileName; int lastReplyStatusError = 0; - ConfigFileFRequest configFileManager = ConfigFileFRequest(Util::FileSystem::getAppPath() + "/" + GlobalVars::AppConfigFileName); + ConfigFileFRequest configFileManager = ConfigFileFRequest(UtilFRequest::getAppDataFolder().absoluteFilePath(GlobalVars::AppConfigFileName)); ConfigFileFRequest::Settings currentSettings; const QSize auxMinimumSize = QSize(0,0); const QSize auxMaximumSize = QSize(16777215,16777215); diff --git a/mainwindow.ui b/mainwindow.ui index c2004fd..839e545 100755 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -83,7 +83,7 @@ - + @@ -220,7 +220,7 @@ Qt::Vertical - + diff --git a/utilfrequest.cpp b/utilfrequest.cpp index 66bfbaa..3b0519a 100755 --- a/utilfrequest.cpp +++ b/utilfrequest.cpp @@ -18,9 +18,19 @@ along with this program. If not, see . */ #include "utilfrequest.h" +#include namespace UtilFRequest{ +QDir getAppDataFolder() +{ + QDir appDataFolder = QDir(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)); + + appDataFolder.mkdir("."); + + return appDataFolder; +} + QString getDocumentsFolder(){ QString result = Util::FileSystem::normalizePath(QStandardPaths::locate(QStandardPaths::DocumentsLocation, QString(), QStandardPaths::LocateDirectory)); diff --git a/utilfrequest.h b/utilfrequest.h index 7b1a6bd..9575e1d 100755 --- a/utilfrequest.h +++ b/utilfrequest.h @@ -124,6 +124,7 @@ struct RequestInfo{ static QMimeDatabase mimeDatabase; +QDir getAppDataFolder(); QString getDocumentsFolder(); bool requestTypeMayHaveBody(RequestType currentRequestType); RequestType getRequestTypeByString(const QString ¤tRequestText);