defuze.me
Client
|
00001 /************************************************************************** 00002 ** defuze.me Epitech Innovative Project 00003 ** 00004 ** Copyright 2010 00005 ** Athena Calmettes - Jocelyn De La Rosa - Francois Gaillard 00006 ** Adrien Jarthon - Alexandre Moore - Luc Peres - Arnaud Sellier 00007 ** 00008 ** All rights reserved. 00009 **************************************************************************/ 00010 00011 #include "guicore.hpp" 00012 #include "parametersmodule.hpp" 00013 #include "exception.hpp" 00014 00015 using namespace Gui; 00016 00017 GuiCore::GuiCore(QStringList __attribute__((unused)) &arguments) 00018 { 00019 mainWindow = NULL; 00020 readyToAddModules = false; 00021 uiConfiguration = new UiConfiguration(); 00022 ModuleFactory::initModuleFactory(this); 00023 } 00024 00025 GuiCore::~GuiCore() 00026 { 00027 if (mainWindow) 00028 delete mainWindow; 00029 } 00030 00031 void GuiCore::init(Cores *c) 00032 { 00033 cores = c; 00034 setParamsName("gui"); 00035 setParamsBackEnd(Parameterizable::NONE); 00036 registerToParamsCore(cores->params()); 00037 mainWindow = new MainWindow(this); 00038 addTab(tr("Broadcast"), ":/icons/note", true); 00039 addTab(tr("Scheduling"), ":/icons/calendar"); 00040 addTab(tr("Social"), ":/icons/social"); 00041 aboutDialog = new About; 00042 //parametersModule = new ParametersModule(this, mainWindow); 00043 readyToAddModules = true; 00044 addPendingModules(); 00045 } 00046 00047 void GuiCore::aboutToQuit() 00048 { 00049 } 00050 00051 MainWindow* GuiCore::getMainWindow() 00052 { 00053 return mainWindow; 00054 } 00055 00056 ParametersModule *GuiCore::getParametersModule() const 00057 { 00058 return parametersModule; 00059 } 00060 00061 void GuiCore::defineParams() 00062 { 00063 setParameter("maximized", true); 00064 setParameter("windowed", true); 00065 setParameter("aero", true); 00066 setParameter("window_title", "Defuze.me"); 00067 } 00068 00069 void GuiCore::popup(QWidget* window) 00070 { 00071 window->setParent(mainWindow); 00072 window->setWindowFlags(Qt::Tool); 00073 if (mainWindow->isVisible()) 00074 window->show(); 00075 else 00076 connect(this, SIGNAL(showPopups()), window, SLOT(show())); 00077 } 00078 00079 void GuiCore::addTab(const QString &title, const QString &icon, bool active) 00080 { 00081 mainWindow->addTab(new Tab(title), icon, active); 00082 } 00083 00084 Tab* GuiCore::currentTab() const 00085 { 00086 return mainWindow->currentTab(); 00087 } 00088 00089 Tab* GuiCore::getTab(TAB_INDEX tabIndex) const 00090 { 00091 if (mainWindow->getTabs().size() >= tabIndex + 1) 00092 return mainWindow->getTabs().at(tabIndex); 00093 else 00094 return 0; 00095 } 00096 00097 void GuiCore::addModule(Module *module) 00098 { 00099 if (readyToAddModules) 00100 { 00101 Tab *tab; 00102 if ((tab = getTab((TAB_INDEX)module->getTabIndex()))) 00103 tab->addModule(module); 00104 else 00105 throw_exception(0x01, "Cannot add module to unknown tab"); 00106 } 00107 else 00108 { 00109 pendingModules << module; 00110 emit module->displayPending(); 00111 } 00112 } 00113 00114 void GuiCore::addPendingModules() 00115 { 00116 if (!readyToAddModules) 00117 return; 00118 while (pendingModules.size()) 00119 addModule(pendingModules.takeFirst()); 00120 } 00121 00122 void GuiCore::toogleParametersModule() 00123 { 00124 if (parametersModule->isHidden()) 00125 parametersModule->show(); 00126 else 00127 parametersModule->hide(); 00128 } 00129 00130 void GuiCore::showAll() 00131 { 00132 mainWindow->show(); 00133 if (getPublicParameter("maximized").toBool()) 00134 mainWindow->showMaximized(); 00135 emit showPopups(); 00136 } 00137 00138 About* GuiCore::getAboutDialog() const 00139 { 00140 return aboutDialog; 00141 }