mirror of
https://github.com/kiwix/kiwix-desktop.git
synced 2025-09-22 11:37:56 -04:00
Use dialog to select a zim file if no zim as been provide on command line.
It is better than crashing.
This commit is contained in:
parent
a248348452
commit
84e5124ae6
19
main.cpp
19
main.cpp
@ -2,23 +2,34 @@
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <QCommandLineParser>
|
||||
#include <QFileDialog>
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
KiwixApp a(argc, argv);
|
||||
KiwixApp::setApplicationName("kiwix-desktop");
|
||||
|
||||
|
||||
QCommandLineParser parser;
|
||||
parser.addPositionalArgument("zimfile", "The zim file");
|
||||
|
||||
parser.process(a);
|
||||
const QString zimfile = parser.positionalArguments().at(0);
|
||||
|
||||
a.openZimFile(zimfile);
|
||||
QString zimfile;
|
||||
auto positionalArguments = parser.positionalArguments();
|
||||
if (positionalArguments.size() < 1){
|
||||
zimfile = QFileDialog::getOpenFileName(nullptr,
|
||||
"Open Zim",
|
||||
QString(),
|
||||
"ZimFile (*.zim*)");
|
||||
} else {
|
||||
zimfile = parser.positionalArguments().at(0);
|
||||
}
|
||||
std::string f = zimfile.toUtf8().constData();
|
||||
std::cout << f << std::endl;
|
||||
|
||||
MainWindow w;
|
||||
w.show();
|
||||
a.openZimFile(zimfile);
|
||||
|
||||
return a.exec();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user