main.cpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. This file is part of QTau
  3. Copyright (C) 2013-2018 Tobias "Tomoko" Platen <tplaten@posteo.de>
  4. Copyright (C) 2013 digited <https://github.com/digited>
  5. Copyright (C) 2010-2013 HAL@ShurabaP <https://github.com/haruneko>
  6. QTau is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. SPDX-License-Identifier: GPL-3.0+
  17. */
  18. #include <QApplication>
  19. #include <QIcon>
  20. #include "Controller.h"
  21. #include "Utils.h"
  22. #include <errno.h>
  23. #include <sys/file.h>
  24. #include <unistd.h>
  25. #include <QTranslator>
  26. //GUI erweitern : Oktober 2020 +
  27. // Connichi: feature freeze
  28. #define __devloglevel__ 8
  29. int main(int argc, char *argv[]) {
  30. QApplication app(argc, argv);
  31. QTranslator trans;
  32. if (trans.load(QLocale(), QLatin1String("qtau"), QLatin1String("_"),
  33. QLatin1String(":/tr")))
  34. QCoreApplication::installTranslator(&trans);
  35. else
  36. DEVLOG_ERROR("failed to setup translator");
  37. DEVLOG_DEBUG("trans: " + QLocale::system().name());
  38. app.installTranslator(&trans);
  39. app.setWindowIcon(QIcon(":/images/appicon_ouka_alice.png"));
  40. int pid_file = open("/tmp/qtau.lock", O_CREAT | O_RDWR, 0666);
  41. int rc = flock(pid_file, LOCK_EX | LOCK_NB);
  42. if (rc) {
  43. if (EWOULDBLOCK == errno) {
  44. DEVLOG_ERROR("qtau is running");
  45. return rc;
  46. }
  47. }
  48. qtauController c(app.applicationDirPath());
  49. c.run(); // create UI that can immediately call back, thus requires already
  50. // created & inited controller
  51. rc = app.exec();
  52. unlink("/tmp/qtau.lock");
  53. c.shutdown(rc); // kill all threads
  54. return rc;
  55. }