mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2026-04-27 05:18:10 +00:00
Updated main() to allow --version and --help options. Added cmdline processing function.
This commit is contained in:
1 parent
4017192546
commit
6301ec587d
2 files changed
+59
-23
No files matched your search
+5
-6
@@ -19,11 +19,11 @@ This file contains project-specific information to help AI assistants work effec
|
||||
|
||||
## Application Type & Testing
|
||||
|
||||
### GUI Application - NO Command Line Interface
|
||||
### GUI Application - Few Command Line Interface Arguments
|
||||
- **Application type**: Qt6 GUI application
|
||||
- **Cannot test with**: `--help`, `--version`, or any CLI flags
|
||||
- **It can be tested with**: `--help` or `--version`, both of which should exit
|
||||
- **Test method**: Launch GUI (`build/AppleSAWS`) or run specific tests
|
||||
- **Entry point**: `main.cpp` launches Qt GUI
|
||||
- **Entry point**: `main.cxx` launches Qt GUI
|
||||
|
||||
## Development Standards & Preferences
|
||||
|
||||
@@ -94,10 +94,9 @@ This file contains project-specific information to help AI assistants work effec
|
||||
- ✅ Always use `./build.sh` or CMake commands
|
||||
|
||||
### Application Testing
|
||||
- ❌ Don't try `build/AppleSAWS --help` (GUI app, no CLI)
|
||||
- ❌ Don't expect command-line output for testing
|
||||
- ✅ Use `--help` or `--version` for quick smoke tests (both exit without launching the GUI)
|
||||
- ✅ Build success indicates code correctness
|
||||
- ✅ Can launch GUI for functional testing (`build/AppleSAWS`)
|
||||
- ✅ Launch the GUI for functional testing (`build/AppleSAWS`)
|
||||
|
||||
### Code Style
|
||||
- ❌ Don't use old-style Qt SIGNAL/SLOT macros
|
||||
|
||||
+54
-17
@@ -1,28 +1,65 @@
|
||||
#include <QApplication>
|
||||
#include <QSettings>
|
||||
#include <QString>
|
||||
#include <QFontDatabase>
|
||||
#include <QDebug>
|
||||
|
||||
#include "StartupDialog.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QCommandLineParser>
|
||||
#include <QDebug>
|
||||
#include <QFontDatabase>
|
||||
#include <QString>
|
||||
#include <QStringView>
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr auto OrganizationName = QStringView{u"LydianScaleSoftware"};
|
||||
constexpr auto OrganizationDomain = QStringView{u"lydianscale.com"};
|
||||
constexpr auto ApplicationName = QStringView{u"AppleSAWS"};
|
||||
constexpr auto ApplicationVersion = QStringView{u"development"};
|
||||
constexpr auto ApplicationDescription = QStringView{u"Apple II disk image and file exploration toolkit."};
|
||||
|
||||
void processArguments(QCoreApplication& app)
|
||||
{
|
||||
QCommandLineParser parser;
|
||||
parser.setApplicationDescription(QString{ApplicationDescription});
|
||||
const QCommandLineOption helpOption = parser.addHelpOption();
|
||||
const QCommandLineOption versionOption = parser.addVersionOption();
|
||||
|
||||
parser.process(app);
|
||||
|
||||
if (parser.isSet(helpOption))
|
||||
{
|
||||
parser.showHelp();
|
||||
}
|
||||
|
||||
if (parser.isSet(versionOption))
|
||||
{
|
||||
parser.showVersion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
QCoreApplication::setOrganizationName("LydianScaleSoftware");
|
||||
QCoreApplication::setOrganizationDomain("lydianscale.com");
|
||||
QCoreApplication::setApplicationName("AppleSAWS");
|
||||
QApplication app(argc, argv);
|
||||
QCoreApplication::setOrganizationName(QString{OrganizationName});
|
||||
QCoreApplication::setOrganizationDomain(QString{OrganizationDomain});
|
||||
QCoreApplication::setApplicationName(QString{ApplicationName});
|
||||
QCoreApplication::setApplicationVersion(QString{ApplicationVersion});
|
||||
|
||||
auto x = QFontDatabase::addApplicationFont(":/fonts/Print_Char_21.ttf");
|
||||
auto y = QFontDatabase::addApplicationFont(":/fonts/PR_Number_3.ttf");
|
||||
processArguments(app);
|
||||
|
||||
if (x < 0) { qWarning("Could not load Print_Char_21.ttf font."); }
|
||||
if (y < 0) { qWarning("Could not load PR_Number_3.ttf font."); }
|
||||
const auto loadFont = [](const QString& resourcePath, QStringView friendlyName) {
|
||||
if (QFontDatabase::addApplicationFont(resourcePath) < 0)
|
||||
{
|
||||
qWarning().noquote() << QStringLiteral("Could not load %1 font.").arg(friendlyName);
|
||||
}
|
||||
};
|
||||
|
||||
StartupDialog w;
|
||||
w.show();
|
||||
loadFont(QStringLiteral(":/fonts/Print_Char_21.ttf"), QStringLiteral("Print_Char_21.ttf"));
|
||||
loadFont(QStringLiteral(":/fonts/PR_Number_3.ttf"), QStringLiteral("PR_Number_3.ttf"));
|
||||
|
||||
return a.exec();
|
||||
StartupDialog startupDialog;
|
||||
startupDialog.show();
|
||||
|
||||
return app.exec();
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user