53 this->force_C_locale_decimalseparator();
55 QFile stylesheet(
":/cxStyleSheet.ss");
56 stylesheet.open(QIODevice::ReadOnly);
57 this->setStyleSheet(stylesheet.readAll());
60 void Application::reportException(QString text)
62 QThread*
main = this->thread();
63 QThread* current = QThread::currentThread();
64 QString threadName = current->objectName();
65 if (threadName.isEmpty())
70 threadName =
"SECONDARY";
73 reportError(QString(
"Exception caught: [%1]\nin thread [%2]").arg(text).arg(threadName));
80 return QApplication::notify(rec, ev);
82 catch(std::exception& e)
84 this->reportException(e.what());
89 this->reportException(
"Unknown");
96 void Application::force_C_locale_decimalseparator()
99 QString radixChar = nl_langinfo(RADIXCHAR);
100 QString C_radixChar =
".";
102 if (radixChar != C_radixChar)
104 QLocale::setDefault(QLocale::c());
105 setlocale(LC_NUMERIC,
"C");
107 std::cout << QString(
"Detected non-standard decimal separator [%1], changing to standard [%2].")
112 QString number = QString(
"%1").arg(0.5);
113 if (!number.contains(C_radixChar))
114 std::cout <<
"Failed to set decimal separator." << std::endl;
121 if (!window->isVisible())
124 #ifdef __APPLE__ // needed on mac for bringing to front: does the opposite on linux
125 window->activateWindow();
132 QWidget *mainwindow = Q_NULLPTR;
133 foreach(mainwindow, QApplication::topLevelWidgets()) {
134 if(mainwindow->objectName() ==
"MainWindow")
137 QAction* action = mainwindow->findChild<QAction*>(actionName);
int main(int argc, char *argv[])
void reportError(QString msg)
Application(int &argc, char **argv)
void bringWindowToFront(QWidget *window)
void triggerMainWindowActionWithObjectName(QString actionName)
virtual bool notify(QObject *rec, QEvent *ev)