USGS

Isis 3.0 Object Programmers' Reference

Home

QIsisApplication.cpp
1 #include "QIsisApplication.h"
2 
3 #include <locale.h>
4 
5 #include <QDesktopServices>
6 #include <QObject>
7 #include <QMessageBox>
8 #include <QUrl>
9 #include <QWebView>
10 
11 #include "FileName.h"
12 #include "IException.h"
13 #include "IString.h"
14 
15 namespace Isis {
22  QIsisApplication::QIsisApplication(int &argc, char *argv[]) :
23  QApplication(argc, argv) {
24  // try to use US locale for numbers so we don't end up printing "," instead
25  // of "." where it might count.
26  setlocale(LC_NUMERIC, "en_US");
27 
28  QDesktopServices::setUrlHandler("http", this, "openUrl");
29  }
30 
31 
49  bool QIsisApplication::notify(QObject *rec, QEvent *ev) {
50  try {
51  return QApplication::notify(rec, ev);
52  }
53  catch(IException &e) {
54  QMessageBox::critical(NULL, "Error", e.what());
55  }
56  return false;
57  }
58 
59 
63  void QIsisApplication::openUrl(QUrl url) {
64  QWebView *view = new QWebView(NULL);
65  view->setAttribute(Qt::WA_DeleteOnClose);
66  view->load(url);
67  view->show();
68  }
69 }