qlopgui.cpp
110 lines
| 2.5 KiB
| text/x-c
|
CppLexer
r15 | /*------------------------------------------------------------------------------ | |||
-- This file is a part of the QLop Software | ||||
-- Copyright (C) 2015, Plasma Physics Laboratory - CNRS | ||||
-- | ||||
-- This program is free software; you can redistribute it and/or modify | ||||
-- it under the terms of the GNU General Public License as published by | ||||
-- the Free Software Foundation; either version 2 of the License, or | ||||
-- (at your option) any later version. | ||||
-- | ||||
-- This program is distributed in the hope that it will be useful, | ||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
-- GNU General Public License for more details. | ||||
-- | ||||
-- You should have received a copy of the GNU General Public License | ||||
-- along with this program; if not, write to the Free Software | ||||
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||
-------------------------------------------------------------------------------*/ | ||||
/*-- Author : Alexis Jeandet | ||||
-- Mail : alexis.jeandet@member.fsf.org | ||||
----------------------------------------------------------------------------*/ | ||||
#include "qlopgui.h" | ||||
QLopGUI* QLopGUI::_self=NULL; | ||||
QDockWidget* QLopGUI::m_gui=NULL; | ||||
QMenuBar* QLopGUI::m_mainMenuBar=NULL; | ||||
QMenu* QLopGUI::m_fileMenu=NULL; | ||||
QMenu* QLopGUI::m_SettingsMenu=NULL; | ||||
#define INIT() \ | ||||
if(Q_UNLIKELY(_self==NULL))\ | ||||
{\ | ||||
init();\ | ||||
} | ||||
QLopGUI::QLopGUI(bool noGUI,QObject *parent) | ||||
{ | ||||
m_serviceName="QLopGUI"; | ||||
m_noGui=noGUI; | ||||
} | ||||
QLopGUI::~QLopGUI() | ||||
{ | ||||
} | ||||
QDockWidget *QLopGUI::getGUI() | ||||
{ | ||||
return m_gui; | ||||
} | ||||
void QLopGUI::init(bool noGUI, QObject *parent) | ||||
{ | ||||
_self=new QLopGUI(noGUI,parent); | ||||
} | ||||
const QString &QLopGUI::serviceName() | ||||
{ | ||||
INIT(); | ||||
return m_serviceName; | ||||
} | ||||
QLopGUI *QLopGUI::self() | ||||
{ | ||||
INIT(); | ||||
return _self; | ||||
} | ||||
void QLopGUI::registerMenuBar(QMenuBar *menuBar) | ||||
{ | ||||
INIT(); | ||||
m_mainMenuBar = menuBar; | ||||
if(m_mainMenuBar) | ||||
{ | ||||
m_fileMenu = m_mainMenuBar->addMenu(tr("File")); | ||||
m_SettingsMenu = m_mainMenuBar->addMenu(tr("Settings")); | ||||
} | ||||
} | ||||
QMenu *QLopGUI::addMenu(const QString &title) | ||||
{ | ||||
INIT(); | ||||
if(m_mainMenuBar) | ||||
{ | ||||
return m_mainMenuBar->addMenu(title); | ||||
} | ||||
return NULL; | ||||
} | ||||
bool QLopGUI::addFileAction(QAction *action) | ||||
{ | ||||
INIT(); | ||||
if(m_fileMenu) | ||||
{ | ||||
m_fileMenu->addAction(action); | ||||
return true; | ||||
} | ||||
return false; | ||||
} | ||||
bool QLopGUI::addSettingsAction(QAction *action) | ||||
{ | ||||
INIT(); | ||||
if(m_SettingsMenu) | ||||
{ | ||||
m_SettingsMenu->addAction(action); | ||||
return true; | ||||
} | ||||
return false; | ||||
} | ||||