UEFITool/UEFITool/uefitool_main.cpp

63 lines
1.6 KiB
C++
Raw Normal View History

/* uefitool_main.cpp
Copyright (c) 2022, Nikolaj Schlej. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
*/
#include <QApplication>
#include <QString>
#include "uefitool.h"
2019-08-18 10:02:30 +08:00
class UEFIToolApplication : public QApplication
{
UEFITool* tool;
2019-08-18 10:02:30 +08:00
public:
UEFIToolApplication(int &argc, char **argv)
: QApplication(argc, argv)
2019-08-18 10:02:30 +08:00
{
setOrganizationName("CodeRush");
setOrganizationDomain("coderush.me");
setApplicationName("UEFITool");
tool = new UEFITool();
2019-08-18 10:02:30 +08:00
}
virtual ~UEFIToolApplication() {
delete tool;
2019-08-18 10:02:30 +08:00
}
virtual bool event(QEvent *event)
2019-08-18 10:02:30 +08:00
{
if (event->type() == QEvent::FileOpen) {
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(event);
tool->openImageFile(openEvent->file());
2019-08-18 10:02:30 +08:00
}
2019-08-18 10:02:30 +08:00
return QApplication::event(event);
}
int startup()
{
tool->setProgramPath(arguments().at(0));
if (arguments().length() > 1)
tool->openImageFile(arguments().at(1));
tool->show();
return exec();
}
2019-08-18 10:02:30 +08:00
};
int main(int argc, char *argv[])
{
2019-08-18 10:02:30 +08:00
UEFIToolApplication a(argc, argv);
return a.startup();
}