Commit 4e8d7a7e authored by Clement CHAVANCE's avatar Clement CHAVANCE

added Abstract class PreferenceWidget and a ProjectPreferences widget

parent 0a48a346
/*****************************************************************************
* PreferenceWidget.cpp: Abstract class that will be used to save load / preferences
* values.
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Clement CHAVANCE <kinder@vlmc.org>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QWidget>
#include "PreferenceWidget.h"
PreferenceWidget::PreferenceWidget( QWidget* widget )
: m_widget(widget)
{
}
QWidget* PreferenceWidget::widget() const
{
return ( m_widget );
}
/*****************************************************************************
* PreferenceWidget.h: Abstract class that will be used to save load / preferences
* values.
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Clement CHAVANCE <kinder@vlmc.org>
*
* 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef PREFERENCEWIDGET_H
#define PREFERENCEWIDGET_H
#include <QWidget>
class PreferenceWidget
{
public:
PreferenceWidget( QWidget* widget );
virtual ~PreferenceWidget() {}
virtual bool load() = 0;
virtual bool save() = 0;
QWidget* widget() const;
private:
QWidget* m_widget;
};
#endif
#include "ui_ProjectPreferences.h"
#include "ProjectPreferences.h"
ProjectPreferences::ProjectPreferences()
{
m_ui.setupUi( this );
}
ProjectPreferences::~ProjectPreferences() { }
#ifndef PROJECTPREFERENCES_H
#define PROJECTPREFERENCES_H
#include "ui_ProjectPreferences.h"
class ProjectPreferences : public PreferenceWidget
{
//Q_OBJECT
public:
ProjectPreferences( QWidget* parent = 0 );
~ProjectPreferences();
bool load();
bool save();
private:
Ui::ProjectPreferences m_ui;
};
#endif
......@@ -29,6 +29,7 @@
#include <QLabel>
#include "PreferenceWidget.h"
#include "SimplePreferences.h"
#include "Panel.h"
......@@ -59,19 +60,21 @@ SimplePreferences::~SimplePreferences()
//TODO : see if the widget MUST have a fixed size, or if the window can dynamicaly
//adjust to the size of the biggest Widget.
void SimplePreferences::addWidget( const QString& name,
QWidget* widget,
PreferenceWidget* pWidget,
const QString& icon,
const QString& label)
{
m_stackedWidgets->addWidget( widget );
widget->setParent( this );
m_stackedWidgets->addWidget( pWidget->widget() );
int idx = m_stackedWidgets->indexOf( widget );
int idx = m_stackedWidgets->indexOf( pWidget->widget() );
m_widgets.insert( idx, name );
m_panel->addButton( label, icon, idx );
if (m_currentWidget == 0)
{
m_currentWidget = widget;
m_currentWidget = pWidget->widget();
}
m_pWidgets.append( pWidget );
}
void SimplePreferences::build()
......@@ -115,6 +118,11 @@ QVBoxLayout* SimplePreferences::buildRightHLayout()
return ( layout );
}
void SimplePreferences::save( void )
{
}
void SimplePreferences::switchWidget( int widget )
{
//TODO : Change the title of the preferences shown
......
......@@ -30,8 +30,10 @@
#include <QVBoxLayout>
#include <QButtonGroup>
#include <QStackedWidget>
#include <QVector>
#include "Panel.h"
#include "PreferenceWidget.h"
class SimplePreferences : public QWidget
{
......@@ -42,24 +44,29 @@ class SimplePreferences : public QWidget
SimplePreferences( QWidget* parent = 0 );
~SimplePreferences();
void addWidget( const QString& name,
QWidget* widget,
PreferenceWidget* pWidget,
const QString& icon,
const QString& label );
void build();
private:
QVBoxLayout* buildRightHLayout();
void save( void );
private:
QHash<int, QString> m_widgets;
QWidget* m_currentWidget;
Panel* m_panel;
QLabel* m_title;
QStackedWidget* m_stackedWidgets;
QHash<int, QString> m_widgets;
QVector<PreferenceWidget*> m_pWidgets;
QWidget* m_currentWidget;
Panel* m_panel;
QLabel* m_title;
QStackedWidget* m_stackedWidgets;
bool m_saved;
public slots:
void switchWidget( int widget );
private slots:
signals:
void widgetSwitched( int widget );
};
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ProjectPreferences</class>
<widget class="QWidget" name="ProjectPreferences">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>425</width>
<height>302</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="tracks_label">
<property name="text">
<string>Number of tracks</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="tracksNb">
<property name="text">
<string>64</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0">
<widget class="QLabel" name="output_FPS_label">
<property name="text">
<string>Output fps</string>
</property>
</widget>
</item>
<item row="3" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="outputFPS">
<property name="text">
<string>25</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="previewFPS">
<property name="text">
<string>25</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="preview_FPS_label">
<property name="text">
<string>preview FPS</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
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