updated application startup
This commit is contained in:
parent
5a93c6186c
commit
ed65b659de
|
@ -13,6 +13,7 @@
|
||||||
# include <c++utilities/application/fakeqtconfigarguments.h>
|
# include <c++utilities/application/fakeqtconfigarguments.h>
|
||||||
#endif
|
#endif
|
||||||
#include <c++utilities/application/argumentparser.h>
|
#include <c++utilities/application/argumentparser.h>
|
||||||
|
#include <c++utilities/application/commandlineutils.h>
|
||||||
#include <c++utilities/application/failure.h>
|
#include <c++utilities/application/failure.h>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -120,12 +121,14 @@ int main(int argc, char *argv[])
|
||||||
parser.parseArgs(argc, argv);
|
parser.parseArgs(argc, argv);
|
||||||
if(qtConfigArgs.areQtGuiArgsPresent()) {
|
if(qtConfigArgs.areQtGuiArgsPresent()) {
|
||||||
#ifdef GUI_QTWIDGETS
|
#ifdef GUI_QTWIDGETS
|
||||||
return QtGui::runWidgetsGui(argc, argv, fileArg.values().empty() ? QString() : QString::fromLocal8Bit(fileArg.values().front().data()));
|
return QtGui::runWidgetsGui(argc, argv, qtConfigArgs, fileArg.values().empty() ? QString() : QString::fromLocal8Bit(fileArg.values().front().data()));
|
||||||
#else
|
#else
|
||||||
|
CMD_UTILS_START_CONSOLE;
|
||||||
cout << "Application has not been build with Qt widgets GUI support." << endl;
|
cout << "Application has not been build with Qt widgets GUI support." << endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} catch(Failure &ex) {
|
} catch(Failure &ex) {
|
||||||
|
CMD_UTILS_START_CONSOLE;
|
||||||
cout << "Unable to parse arguments. " << ex.what() << "\nSee --help for available commands." << endl;
|
cout << "Unable to parse arguments. " << ex.what() << "\nSee --help for available commands." << endl;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include <c++utilities/application/failure.h>
|
#include <c++utilities/application/failure.h>
|
||||||
#include <c++utilities/application/argumentparser.h>
|
#include <c++utilities/application/argumentparser.h>
|
||||||
|
#include <c++utilities/application/commandlineutils.h>
|
||||||
#include <c++utilities/conversion/stringconversion.h>
|
#include <c++utilities/conversion/stringconversion.h>
|
||||||
#include <c++utilities/conversion/conversionexception.h>
|
#include <c++utilities/conversion/conversionexception.h>
|
||||||
#include <c++utilities/io/ansiescapecodes.h>
|
#include <c++utilities/io/ansiescapecodes.h>
|
||||||
|
@ -122,6 +123,7 @@ void printNotifications(const MediaFileInfo &fileInfo, const char *head = nullpt
|
||||||
|
|
||||||
void printFieldNames(const StringVector ¶meterValues)
|
void printFieldNames(const StringVector ¶meterValues)
|
||||||
{
|
{
|
||||||
|
CMD_UTILS_START_CONSOLE;
|
||||||
VAR_UNUSED(parameterValues)
|
VAR_UNUSED(parameterValues)
|
||||||
cout << "title album artist genre year comment bpm bps lyricist track disk part totalparts encoder\n"
|
cout << "title album artist genre year comment bpm bps lyricist track disk part totalparts encoder\n"
|
||||||
"recorddate performers duration language encodersettings lyrics synchronizedlyrics grouping\n"
|
"recorddate performers duration language encodersettings lyrics synchronizedlyrics grouping\n"
|
||||||
|
@ -130,6 +132,7 @@ void printFieldNames(const StringVector ¶meterValues)
|
||||||
|
|
||||||
void removeBackupFiles(const StringVector ¶meterValues, const Argument &recursiveArg)
|
void removeBackupFiles(const StringVector ¶meterValues, const Argument &recursiveArg)
|
||||||
{
|
{
|
||||||
|
CMD_UTILS_START_CONSOLE;
|
||||||
QDir dir(QString::fromStdString(parameterValues.at(0)));
|
QDir dir(QString::fromStdString(parameterValues.at(0)));
|
||||||
QStringList affectedFiles;
|
QStringList affectedFiles;
|
||||||
int filesFound = Utility::removeBackupFiles(dir, affectedFiles, &cout, recursiveArg.isPresent());
|
int filesFound = Utility::removeBackupFiles(dir, affectedFiles, &cout, recursiveArg.isPresent());
|
||||||
|
@ -367,7 +370,8 @@ unsigned int parseFieldDenotations(const StringVector &fieldDenotations, bool re
|
||||||
|
|
||||||
void generateFileInfo(const StringVector ¶meterValues, const Argument &inputFileArg, const Argument &outputFileArg, const Argument &validateArg)
|
void generateFileInfo(const StringVector ¶meterValues, const Argument &inputFileArg, const Argument &outputFileArg, const Argument &validateArg)
|
||||||
{
|
{
|
||||||
Q_UNUSED(parameterValues)
|
CMD_UTILS_START_CONSOLE;
|
||||||
|
VAR_UNUSED(parameterValues)
|
||||||
try {
|
try {
|
||||||
// parse tags
|
// parse tags
|
||||||
MediaFileInfo inputFileInfo(inputFileArg.values().front());
|
MediaFileInfo inputFileInfo(inputFileArg.values().front());
|
||||||
|
@ -422,6 +426,7 @@ void printProperty(const char *propName, const intType value, const char *suffix
|
||||||
|
|
||||||
void displayFileInfo(const StringVector &, const Argument &filesArg)
|
void displayFileInfo(const StringVector &, const Argument &filesArg)
|
||||||
{
|
{
|
||||||
|
CMD_UTILS_START_CONSOLE;
|
||||||
if(!filesArg.valueCount()) {
|
if(!filesArg.valueCount()) {
|
||||||
cout << "Error: No files have been specified." << endl;
|
cout << "Error: No files have been specified." << endl;
|
||||||
return;
|
return;
|
||||||
|
@ -516,6 +521,7 @@ void displayFileInfo(const StringVector &, const Argument &filesArg)
|
||||||
|
|
||||||
void displayTagInfo(const StringVector ¶meterValues, const Argument &filesArg)
|
void displayTagInfo(const StringVector ¶meterValues, const Argument &filesArg)
|
||||||
{
|
{
|
||||||
|
CMD_UTILS_START_CONSOLE;
|
||||||
if(!filesArg.valueCount()) {
|
if(!filesArg.valueCount()) {
|
||||||
cout << "Error: No files have been specified." << endl;
|
cout << "Error: No files have been specified." << endl;
|
||||||
return;
|
return;
|
||||||
|
@ -594,6 +600,7 @@ void setTagInfo(const StringVector ¶meterValues, const Argument &filesArg, c
|
||||||
const Argument &treatUnknownFilesAsMp3FilesArg, const Argument &id3v1UsageArg, const Argument &id3v2UsageArg,
|
const Argument &treatUnknownFilesAsMp3FilesArg, const Argument &id3v1UsageArg, const Argument &id3v2UsageArg,
|
||||||
const Argument &mergeMultipleSuccessiveTagsArg, const Argument &id3v2VersionArg, const Argument &encodingArg)
|
const Argument &mergeMultipleSuccessiveTagsArg, const Argument &id3v2VersionArg, const Argument &encodingArg)
|
||||||
{
|
{
|
||||||
|
CMD_UTILS_START_CONSOLE;
|
||||||
if(!filesArg.valueCount()) {
|
if(!filesArg.valueCount()) {
|
||||||
cout << "Error: No files have been specified." << endl;
|
cout << "Error: No files have been specified." << endl;
|
||||||
return;
|
return;
|
||||||
|
@ -709,6 +716,7 @@ void setTagInfo(const StringVector ¶meterValues, const Argument &filesArg, c
|
||||||
|
|
||||||
void extractField(const StringVector ¶meterValues, const Argument &inputFileArg, const Argument &outputFileArg)
|
void extractField(const StringVector ¶meterValues, const Argument &inputFileArg, const Argument &outputFileArg)
|
||||||
{
|
{
|
||||||
|
CMD_UTILS_START_CONSOLE;
|
||||||
FieldDenotation fields[knownFieldArraySize];
|
FieldDenotation fields[knownFieldArraySize];
|
||||||
unsigned int validDenotations = parseFieldDenotations(parameterValues, true, fields);
|
unsigned int validDenotations = parseFieldDenotations(parameterValues, true, fields);
|
||||||
if(validDenotations != 1) {
|
if(validDenotations != 1) {
|
||||||
|
|
|
@ -1,21 +1,26 @@
|
||||||
#include "initiate.h"
|
#include "initiate.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
|
||||||
#include "application/settings.h"
|
#include "application/settings.h"
|
||||||
|
|
||||||
|
#include <qtutilities/resources/qtconfigarguments.h>
|
||||||
#include <qtutilities/resources/resources.h>
|
#include <qtutilities/resources/resources.h>
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
|
using namespace ApplicationUtilities;
|
||||||
|
|
||||||
namespace QtGui {
|
namespace QtGui {
|
||||||
|
|
||||||
int runWidgetsGui(int argc, char *argv[], const QString &path)
|
int runWidgetsGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs, const QString &path)
|
||||||
{
|
{
|
||||||
SET_QT_APPLICATION_INFO;
|
SET_QT_APPLICATION_INFO;
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
LOAD_QT_TRANSLATIONS;
|
|
||||||
// load resources needed by classes of qtutilities
|
// load resources needed by classes of qtutilities
|
||||||
QtUtilitiesResources::init();
|
QtUtilitiesResources::init();
|
||||||
Theme::setup();
|
// apply settings specified via command line args
|
||||||
|
qtConfigArgs.applySettings();
|
||||||
|
LOAD_QT_TRANSLATIONS;
|
||||||
Settings::restore();
|
Settings::restore();
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
|
|
|
@ -3,13 +3,15 @@
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_FORWARD_DECLARE_CLASS(QString)
|
||||||
class QString;
|
|
||||||
QT_END_NAMESPACE
|
namespace ApplicationUtilities {
|
||||||
|
class QtConfigArguments;
|
||||||
|
}
|
||||||
|
|
||||||
namespace QtGui {
|
namespace QtGui {
|
||||||
|
|
||||||
int runWidgetsGui(int argc, char *argv[], const QString &path);
|
int runWidgetsGui(int argc, char *argv[], const ApplicationUtilities::QtConfigArguments &qtConfigArgs, const QString &path);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue