Commit 9306b5e9 authored by Olivier Lagrasse's avatar Olivier Lagrasse

Interface - connection des menus - ajout fenetre flottante au premier plan

parent 2d1c507a
......@@ -55,5 +55,5 @@ clean:
wash:
cd ./src && rm *~ *.o *pro Makefile
cd ./tests && rm *~ *.o *pro Makefile
cd ./bin && rm *
# cd ./bin && rm *
cd ./debug && rm *
<ui version="4.0" >
<class>info_window_2</class>
<widget class="QMainWindow" name="info_window_2" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>607</width>
<height>187</height>
</rect>
</property>
<property name="windowTitle" >
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget" >
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="maximumSize" >
<size>
<width>300</width>
<height>16777215</height>
</size>
</property>
<property name="focusPolicy" >
<enum>Qt::StrongFocus</enum>
</property>
<property name="title" >
<string>Trace Resume</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="info_window" >
<property name="title" >
<string>Selection Informations</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>607</width>
<height>26</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar" />
</widget>
<resources/>
<connections/>
</ui>
This diff is collapsed.
<RCC>
<qresource prefix="icon_menu" >
<file>folder_yellow_open.png</file>
<file>no.png</file>
<file>help_index.png</file>
</qresource>
</RCC>
......@@ -8,7 +8,7 @@
#ifndef INTERFACE_H
#define INTERFACE_H
#include "resource.h"
#include "resource.hpp"
/*!
......@@ -22,14 +22,14 @@ class Interface{
\arg string : the string to be displayed.
\brief The function takes a string then displayed it either on the terminal if there is an Interface_console instance, or on a dialof box for the Interface_graphic. Then, it killed the application.
*/
virtual bool error(string) =0;
virtual bool error(const string) const =0;
/*!
\arg string : the string to be displayed.
\brief The function takes a string then displayed it either on the terminal if there is an Interface_console instance, or on a dialof box for the Interface_graphic. Then the program go on.
*/
virtual bool warning(string) =0;
virtual bool warning(const string) const =0;
};
......
......@@ -4,7 +4,7 @@
*/
#include "interface_console.h"
#include "interface_console.hpp"
......@@ -30,7 +30,6 @@ int Interface_console::get_state(int, char**){
void Interface_console::launch_action(int state){
switch(state) {
......@@ -43,6 +42,8 @@ void Interface_console::launch_action(int state){
/* launch the window interface */
_main_window = new Interface_graphic();
break;
default:
......@@ -63,11 +64,11 @@ Interface_console::~Interface_console(){
}
bool Interface_console::error(string s){
bool Interface_console::error(const string s) const{
return true;
}
bool Interface_console::warning(string s){
bool Interface_console::warning(const string s) const{
return true;
}
......@@ -7,8 +7,8 @@
#define INTERFACE_CONSOLE_H
#include "interface.h"
#include "interface_graphic.h"
#include "interface.hpp"
#include "interface_graphic.hpp"
#define STATE_DISPLAY_HELP 0
......@@ -61,14 +61,14 @@ class Interface_console : public Interface{
\arg string : the string to be displayed.
\brief The function takes a string then displayed it into the terminal, then killed the application.
*/
bool error(string);
bool error(const string) const;
/*!
\arg string : the string to be displayed.
\brief The function takes a string then displayed it into the terminal, then the program go on.
*/
bool warning(string);
bool warning(const string) const;
};
......
......@@ -4,56 +4,139 @@
*/
#include "interface_graphic.h"
#include "interface_graphic.hpp"
Interface_graphic::Interface_graphic(){
Interface_graphic::Interface_graphic(QWidget *parent):QWidget(parent){
QUiLoader loader;
QFile file(UI_MAIN_WINDOW_NAME);
QFile file_main(UI_MAIN_WINDOW_NAME);
QFile file_info(UI_INFO_WINDOW_NAME);
file.open(QFile::ReadOnly);
_load_window = loader.load(&file, this);
file_main.open(QFile::ReadOnly);
CKFP(ui_main_window = loader.load(&file_main, this), "Cannot open the .ui file : " << UI_MAIN_WINDOW_NAME);
file_main.close();
if (_load_window==NULL){
/* Error message displays in the terminal */
cerr << "Cannot open the .ui file : " << UI_MAIN_WINDOW_NAME ;//<< " (file " << __FILE << ", l." << __LINE__ <<" )" << endl;
exit(EXIT_FAILURE);
}
file_info.open(QFile::ReadOnly);
CKFP(ui_info_window = loader.load(&file_info, ui_main_window), "Cannot open the .ui file : " << UI_MAIN_WINDOW_NAME);
file_info.close();
file.close();
_render_area = qFindChild<QWidget*>(this, "render_area");
QMetaObject::connectSlotsByName(this);
ui_info_window->setWindowOpacity(0.7);/* Change alpha value of the informative window */
ui_info_window->setWindowFlags(ui_info_window->windowFlags() | Qt::WindowStaysOnTopHint);/* Always display info_window on top */
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(_load_window);
setLayout(layout);
CKFP(ui_render_area = qFindChild<QWidget*>(this, "render_area"), "Cannot find the render_area QWidget in the .ui file");
CKFP(ui_fullscreen_menu = qFindChild<QAction*>(this, "fullscreen"), "Cannot find the fullscreen menu in the .ui file");
_load_window->show();
QMetaObject::connectSlotsByName(this);
ui_main_window->show();/* display the main window */
ui_info_window->show();/* display the info window */
}
Interface_graphic::~Interface_graphic(){
/* Qt desallocates _load_window and _render_area automatically */
/* Qt desallocates ui_main_window and _render_area automatically */
}
bool Interface_graphic::error(string s){
bool Interface_graphic::error(const string s) const{
return true;
}
bool Interface_graphic::warning(string s){
bool Interface_graphic::warning(const string s) const{
return true;
}
/***** SLOTS *****/
void Interface_graphic::on_open_triggered(){
/*
Be careful, here, ui_main_window is used instead this because of this is not a window,
it's an interface class. The real window is ui_main_window.
If this is put, the application closes after the getOpenFilename dialog box closes.
*/
QString filename = QFileDialog::getOpenFileName(ui_main_window);
if (!filename.isEmpty())
/*******************************************************/
/* Not Yet Implemented -> Send file path to the parser */
/*******************************************************/
cerr << "Open file : " << filename.toStdString() << endl;
}
void Interface_graphic::on_close_triggered(){
/*******************************************************************************************/
/* Not Yet Implemented -> Stop the parser and the data structure if they are still implemented */
/*******************************************************************************************/
cerr << "Close file. ";
}
void Interface_graphic::on_quit_triggered(){
close();
}
void Interface_graphic::on_fullscreen_triggered(){
/* Notice that some problems can appears under X system with
the window decoration. Please refer to official documentation of Qt
*/
if (ui_fullscreen_menu->isChecked())/* It is checked before this function is called */
ui_main_window->showFullScreen();
else
ui_main_window->showNormal();
}
void Interface_graphic::on_help_triggered(){
/**************************************************/
/* Not Yet Implemented -> Display the user manual */
/**************************************************/
cerr << "Display help. ";
}
void Interface_graphic::on_about_triggered(){
QMessageBox::about(ui_main_window, tr("About ViTE"),
tr("The <b>Application</b> example demonstrates how to "
"write modern GUI applications using Qt, with a menu bar, "
"toolbars, and a status bar."));
}
......@@ -9,53 +9,72 @@
#define INTERFACE_GRAPHIC_H
#include "interface.h"
#include "interface.hpp"
/*!
*\brief This class is a graphical interface which creates a window, it inherited from the Interface interface.
*/
class Interface_graphic : public Interface, public QWidget{
class Interface_graphic : public QWidget, public Interface{
Q_OBJECT
protected:
/*!
* \brief Used to load the .ui window file.
* \brief Used to load the .ui window files.
*/
QWidget* _load_window;
QWidget* ui_main_window;
QWidget* ui_info_window;
QAction* ui_fullscreen_menu;
QWidget* _render_area;
QWidget* ui_render_area;
public:
public:
/*!
* \brief The default constructor
*/
Interface_graphic();
Interface_graphic(QWidget *parent = 0);
/*!
* \brief The destructor
*/
~Interface_graphic();
virtual ~Interface_graphic();
/*!
* \arg string : the string to be displayed.
*\brief The function takes a string then displayed an info box containing it, then the application will be killed.
*/
bool error(string);
bool error(const string) const;
/*!
*\arg string : the string to be displayed.
*\brief The function takes a string then displayed an info box containing it, then the program go on.
*/
bool warning(string);
bool warning(const string) const;
protected slots:
void on_open_triggered();
void on_close_triggered();
void on_quit_triggered();
void on_fullscreen_triggered();
void on_help_triggered();
void on_about_triggered();
};
......
......@@ -3,15 +3,13 @@
*\brief The main launcher.
*/
#include "interface_console.h"
#include "interface_console.hpp"
int main(int argc, char **argv)
{
QApplication app(argc, argv);
Interface_console console(argc, argv);
return app.exec();
......
This diff is collapsed.
/*!
*\file ressource.h
*\brief This file gives some common header files for the interface classes.
*/
#ifndef RESOURCE_H
#define RESOURCE_H
#include <QApplication>
#include <QtGui>/* for all of the Qt's Widgets */
#include <QtUiTools>/* for the run-time loading .ui file */
#include <QGLWidget>/* for the OpenGL Widget */
#include <iostream>/* to use the C standard library input output functions */
#include <string>
#include <cstdlib> /* for macros EXIT_SUCCESS and EXIT_FAILURE */
using namespace std;
#define UI_MAIN_WINDOW_NAME "main_window.ui"/* name of the main window ui file. This file must be included in the same folder than the compiled program. */
#define UI_INFO_WINDOW_NAME "info_window.ui"/* name of the info window ui file. This file must be included in the same folder than the compiled program. */
/* Now, two checkers are defined (the first for integer return value, the other
for pointer return value). Their body can be empty to enhance program speed.
To pass multi arguments for m, use "<<" between each arguments.
*/
#define CKF(f, m) if((f)==-1) { \
cerr << "File " << __FILE__ <<" - line : " << __LINE__ <<endl; \
cerr << m <<endl; \
exit(EXIT_FAILURE); \
}
#define CKFP(f, m) if((f)==NULL) { \
cerr << "File " << __FILE__ <<" - line : " << __LINE__ <<endl; \
cerr << m <<endl; \
exit(EXIT_FAILURE); \
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment