1 /*************************************************************************
2 Copyright 2009, Matthew Thompson, Lee Hicks
4 This file is part of EconoBoard.
6 EconoBoard 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.
11 EconoBoard is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with EconoBoard. If not, see <http://www.gnu.org/licenses/>.
18 *************************************************************************/
20 #include "application.h"
21 #include "camerathread.h"
22 #include "cameraview.h"
23 #include "setupdialog.h"
25 #include <QSystemTrayIcon>
33 Application::Application(int &argc
, char **argv
)
34 : QApplication(argc
, argv
)
36 setQuitOnLastWindowClosed(false);
38 camThread
= new CameraThread();
44 QCoreApplication::setOrganizationName("EconoSoft");
45 QCoreApplication::setApplicationName("EconoBoard");
51 Application::~Application()
61 void Application::createMenus()
65 trayMenu
= new QMenu();
66 systemTray
->setContextMenu(trayMenu
);
68 trayMenu
->addAction(tr("&Setup"), this, SLOT(setup()));
69 trayMenu
->addAction(tr("&Quit"), this, SLOT(quit()));
72 void Application::createWidgets()
74 systemTray
= new QSystemTrayIcon(QIcon(":tray-img.png"));
76 setupDialog
= new SetupDialog(camThread
);
77 connect(setupDialog
, SIGNAL(settingsChanged(int,int)), this, SLOT(saveSetup(int,int)));
80 void Application::setup()
84 setupDialog
->activateWindow();
87 void Application::saveSetup(int threshold
, int cameraIdx
)
90 settings
.setValue("filter/threshold", threshold
);
91 settings
.setValue("camera/index", cameraIdx
);
93 qDebug("Settings were saved");
96 void Application::restoreSettings()
100 camThread
->setThreshold(settings
.value("filter/threshold").toInt());
101 camThread
->setCamera(settings
.value("camera/index").toInt());