1 // Copyright 2010 Jochen Becher
3 // This file is part of MovieSchedule.
5 // MovieSchedule is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // MovieSchedule 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.
15 // You should have received a copy of the GNU General Public License
16 // along with MovieSchedule. If not, see <http://www.gnu.org/licenses/>.
18 #include "movieschedule.h"
20 #include "data/settings.h"
21 #include "data/cinemaschedule.h"
22 #include "control/settingscontroller.h"
23 #include "control/maincontroller.h"
24 #include "control/theatercontroller.h"
25 #include "control/moviecontroller.h"
26 #include "control/locationcontroller.h"
27 #include "control/actioncontroller.h"
28 #include "control/itemmodelsortcontroller.h"
29 #include "ui/mainwindow.h"
30 #include "ui/moviemodel.h"
31 #include "ui/moviewindow.h"
32 #include "ui/theatermodel.h"
33 #include "ui/theaterwindow.h"
34 #include "ui/ratingprovider.h"
35 #include "ui/styleutils.h"
37 #include <QApplication>
38 #include <QTranslator>
44 #include <glib-object.h>
47 #define _STRINGIZE_(x) #x
48 #define _STRINGIZE(x) _STRINGIZE_(x)
50 class ControllerThread : public QThread
65 MovieSchedule::MovieSchedule()
69 int MovieSchedule::exec(int argc, char *argv[])
71 QApplication app(argc, argv);
77 qRegisterMetaType<Location>();
79 StyleUtilsSingleton style_utils_singleton;
80 (void) style_utils_singleton;
84 app_dir = QApplication::applicationDirPath();
86 app_dir = _STRINGIZE(DATADIR) "/movie-schedule";
88 //std::cout << "app_dir = " << qPrintable(app_dir) << std::endl;
90 QString locale = QLocale::system().name();
91 //std::cout << "locale: " << qPrintable(locale) << std::endl;
94 QTranslator translator;
95 translator.load(app_dir + "/translations/movie-schedule_" + locale);
96 app.installTranslator(&translator);
99 RatingSingleton rating_singleton;
100 (void) rating_singleton;
102 CinemaSchedule cinema_schedule;
104 MainWindow main_window(&cinema_schedule);
108 SettingsController settings_controller(&main_window, &settings);
109 settings_controller.Load();
111 ActionController action_controller(&cinema_schedule);
113 ControllerThread sort_worker;
116 ControllerThread search_worker;
117 search_worker.start();
119 ItemModelSortController sort_controller(&cinema_schedule);
120 sort_controller.moveToThread(&sort_worker);
122 TheaterWindow theater_window(&cinema_schedule, &main_window);
123 TheaterController theater_controller(&theater_window, &cinema_schedule, &action_controller,
124 &sort_controller, &search_worker);
126 MovieWindow movie_window(&cinema_schedule, &main_window);
127 MovieController movie_controller(&movie_window, &cinema_schedule, &action_controller,
128 &sort_controller, &search_worker);
130 LocationController location_controller(&main_window, &settings);
132 MainController main_controller(&main_window, &settings, &cinema_schedule, &theater_controller,
133 &movie_controller, &location_controller, &action_controller,
134 &settings_controller, &sort_controller, &search_worker);
136 settings_controller.EmitInitialSettings();
137 main_controller.Run();
142 settings_controller.Save();
145 search_worker.quit();