Isis 3 Programmer Reference
QIsisApplication.cpp
1#include "QIsisApplication.h"
2
3#include <locale.h>
4
5#include <QDesktopServices>
6#include <QFileInfo>
7#include <QObject>
8#include <QMessageBox>
9#include <QUrl>
10
11#include "FileName.h"
12#include "Preference.h"
13#include "IException.h"
14#include "IString.h"
15
16namespace Isis {
28 QIsisApplication::QIsisApplication(int &argc, char *argv[]) :
29 QApplication(argc, argv) {
30 // try to use US locale for numbers so we don't end up printing "," instead
31 // of "." where it might count.
32
33 for (int i = 1; i < argc; i++) {
34 QString arg(argv[i]);
35 if (arg.startsWith("-pref")) {
36
37 // So that we can grab the file located after the current '-pref' flag.
38 int nextIndex = i + 1;
39
40 if (nextIndex < argc) {
41 FileName preferenceFile(argv[nextIndex]);
42 QString filePath = preferenceFile.expanded();
43 Preference::Preferences().clear();
44 Preference::Preferences().Load(filePath);
45 }
46 else {
47 QMessageBox::warning(NULL, "Warning", "Preference flag set but no preference file given.");
48 }
49 }
50 }
51 setlocale(LC_NUMERIC, "en_US");
52
53 QDesktopServices::setUrlHandler("http", this, "openUrl");
54 }
55
56
74 bool QIsisApplication::notify(QObject *rec, QEvent *ev) {
75 try {
76 return QApplication::notify(rec, ev);
77 }
78 catch(IException &e) {
79 QMessageBox::critical(NULL, "Error", e.what());
80 }
81 return false;
82 }
83
84
89 QDesktopServices::openUrl(url);
90 }
91}
File name manipulation and expansion.
Definition FileName.h:100
Isis exception class.
Definition IException.h:91
void openUrl(QUrl url)
Open a URL in the browser specified by Isis.
QIsisApplication(int &argc, char *argv[])
Constructor.
virtual bool notify(QObject *rec, QEvent *ev)
notify - this function overrides the QApplication notify as QT event handlers do not handle exception...
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16