Commit e2af11d1 authored by Dirk Wilden's avatar Dirk Wilden

optionsWidget basically working

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@2782 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 4b98d19d
......@@ -163,6 +163,7 @@ Core::init() {
connect(coreWidget_, SIGNAL(loadIniMenu()) , this, SLOT(slotLoadIniMenu()));
connect(coreWidget_, SIGNAL(saveIniMenu()) , this, SLOT(slotSaveIniMenu()));
connect(coreWidget_, SIGNAL(applyOptions()) , this, SLOT(applyOptions()));
connect(coreWidget_, SIGNAL(saveOptions()) , this, SLOT(saveOptions()));
connect(coreWidget_, SIGNAL(recentOpen(QAction*)) , this, SLOT(slotRecentOpen(QAction*)));
connect(coreWidget_, SIGNAL(exit()) , this, SLOT(slotExit()));
......@@ -598,11 +599,11 @@ Core::writeOnExit() {
if ( ! ini.connect( inifile,true) ) {
emit log(LOGERR,"Can not create user ini file");
} else {
writeImportant(ini);
writeApplicationOptions(ini);
ini.disconnect();
}
} else {
writeImportant(ini);
writeApplicationOptions(ini);
ini.disconnect();
}
......
......@@ -407,6 +407,9 @@ private:
public slots:
/// Save the current options to the standard ini file
void saveOptions();
/// after ini-files have been loaded and core is up or if options have been changed -> apply Options
void applyOptions();
......@@ -433,9 +436,6 @@ private:
*/
void writeObjFile(QString _filename, bool _relativePaths);
/// Write important information like recent files to ini (used e.g. on exit)
void writeImportant(INIFile& _ini);
/// Called if app is closed and writes all information to ini file
void writeOnExit();
......
......@@ -147,6 +147,20 @@ void Core::readApplicationOptions(INIFile& _ini) {
if ( _ini.get_entry( backface_culling, "Options" , "BackfaceCulling") )
OpenFlipper::Options::backfaceCulling(backface_culling);
//============================================================================
// Load the WheelZoomFactor setting
//============================================================================
double wheelZoomFactor = 1.0;
if ( _ini.get_entry( wheelZoomFactor, "Options" , "WheelZoomFactor") )
OpenFlipper::Options::wheelZoomFactor(wheelZoomFactor);
//============================================================================
// Load the WheelZoomFactorShift setting
//============================================================================
double wheelZoomFactorShift = 0.2;
if ( _ini.get_entry( wheelZoomFactorShift, "Options" , "WheelZoomFactorShift") )
OpenFlipper::Options::wheelZoomFactorShift(wheelZoomFactorShift);
//============================================================================
// Load the animation setting
//============================================================================
......@@ -191,10 +205,10 @@ void Core::readApplicationOptions(INIFile& _ini) {
}
}
/** Write the most important options to the given Ini File
/** Write the standard options to the given Ini File
* @param _ini Inifile to use
*/
void Core::writeImportant(INIFile& _ini) {
void Core::writeApplicationOptions(INIFile& _ini) {
// Write maximum recent file count to ini
_ini.add_entry("Options","MaxRecent",OpenFlipper::Options::maxRecent());
......@@ -258,14 +272,8 @@ void Core::writeImportant(INIFile& _ini) {
//write dontLoad Plugins
_ini.add_entry("Plugins","DontLoad", dontLoad);
}
/** Write the standard options to the given Ini File
* @param _ini Inifile to use
*/
void Core::writeApplicationOptions(INIFile& _ini) {
writeImportant(_ini);
if ( !_ini.section_exists("Options") )
_ini.add_section("Options");
......@@ -279,6 +287,9 @@ void Core::writeApplicationOptions(INIFile& _ini) {
_ini.add_entry("Options","BackfaceCulling",coreWidget_->examiner_widget_->backFaceCulling());
_ini.add_entry("Options","Animation",coreWidget_->examiner_widget_->animation());
_ini.add_entry("Options","WheelZoomFactor",coreWidget_->examiner_widget_->wheelZoomFactor());
_ini.add_entry("Options","WheelZoomFactorShift",coreWidget_->examiner_widget_->wheelZoomFactorShift());
//============================================================================
// Save the current draw modes
//============================================================================
......
......@@ -62,10 +62,10 @@ void Core::applyOptions(){
if (OpenFlipper::Options::defaultToolboxMode() != "")
coreWidget_->slotChangeView(OpenFlipper::Options::defaultToolboxMode(), QStringList());
//Set Fullscreen
if ( OpenFlipper::Options::fullScreen() ) {
coreWidget_->setWindowFlags( coreWidget_->windowFlags () | Qt::FramelessWindowHint) ;
coreWidget_->resize(QApplication::desktop()->size());
}
if ( OpenFlipper::Options::fullScreen() )
coreWidget_->setWindowState(Qt::WindowFullScreen);
else
coreWidget_->setWindowState(!Qt::WindowFullScreen);
//Hide Logger
if (OpenFlipper::Options::hideLogger()) {
......@@ -81,6 +81,10 @@ void Core::applyOptions(){
//Backface Culling
coreWidget_->examiner_widget_->backFaceCulling(OpenFlipper::Options::backfaceCulling());
//wheel zoom factor
coreWidget_->examiner_widget_->setWheelZoomFactor(OpenFlipper::Options::wheelZoomFactor());
coreWidget_->examiner_widget_->setWheelZoomFactorShift(OpenFlipper::Options::wheelZoomFactorShift());
//hideToolbox
if (OpenFlipper::Options::hideToolbox()) {
......@@ -99,6 +103,26 @@ void Core::applyOptions(){
}
void Core::saveOptions(){
QString inifile = QDir::home().absolutePath() + OpenFlipper::Options::dirSeparator() + ".OpenFlipper" +
OpenFlipper::Options::dirSeparator() + "OpenFlipper.ini";
INIFile ini;
if ( ! ini.connect( inifile ,false) ) {
emit log(LOGERR,"Failed to connect to users ini file");
if ( ! ini.connect( inifile,true) ) {
emit log(LOGERR,"Can not create user ini file");
} else {
writeApplicationOptions(ini);
ini.disconnect();
}
} else {
writeApplicationOptions(ini);
ini.disconnect();
}
}
void Core::setupOptions() {
// Get the Main config dir in the home directory and possibly create it
......
......@@ -86,6 +86,12 @@ static bool animation_ = false;
/// Store the backfaceCulling mode
static bool backfaceCulling_ = false;
/// Store the wheelZoomFactor mode
static double wheelZoomFactor_ = 1.0;
/// Store the wheelZoomFactorShift mode
static double wheelZoomFactorShift_ = 0.2;
/// Store the toolbox gui Mode mode
static bool hideToolbox_ = false;
......@@ -311,6 +317,26 @@ bool backfaceCulling( ) {
return backfaceCulling_;
}
/// Store wheelZoomFactor setting
void wheelZoomFactor( double _factor ) {
wheelZoomFactor_ = _factor;
}
/// get wheelZoomFactor setting
double wheelZoomFactor( ) {
return wheelZoomFactor_;
}
/// Store wheelZoomFactorShift setting
void wheelZoomFactorShift( double _factor ) {
wheelZoomFactorShift_ = _factor;
}
/// get wheelZoomFactorShift setting
double wheelZoomFactorShift( ) {
return wheelZoomFactorShift_;
}
/// Set if we start the logging widget closed
void hideLogger( bool _hide) {
hideLogger_ = _hide;
......
......@@ -293,6 +293,22 @@ bool iconDir(QString _dir);
DLLEXPORT
bool backfaceCulling( );
/// Store wheelZoomFactor setting
DLLEXPORT
void wheelZoomFactor( double _factor );
/// get wheelZoomFactor setting
DLLEXPORT
double wheelZoomFactor( );
/// Store wheelZoomFactorShift setting
DLLEXPORT
void wheelZoomFactorShift( double _factor );
/// get wheelZoomFactorShift setting
DLLEXPORT
double wheelZoomFactorShift( );
/** @} */
//===========================================================================
......
......@@ -436,8 +436,16 @@ void CoreWidget::showOptionsWidget() {
if ( optionsWidget_ == 0 ) {
optionsWidget_ = new OptionsWidget(0);
connect(optionsWidget_,SIGNAL(applyOptions()),this,SIGNAL(applyOptions()));
connect(optionsWidget_,SIGNAL(saveOptions()),this,SIGNAL(saveOptions()));
}
//show the optionsWidget centered
QPoint center;
center.setX( x() + width() / 2 );
center.setY( y() + height() / 2 );
optionsWidget_->setGeometry(center.x() - optionsWidget_->width() / 2, center.y() - optionsWidget_->height() / 2, optionsWidget_->width(), optionsWidget_->height());
optionsWidget_->show();
}
......
......@@ -438,6 +438,7 @@ public:
signals:
void applyOptions();
void saveOptions();
private:
......
......@@ -45,12 +45,35 @@ OptionsWidget::OptionsWidget( QWidget *parent)
}
void OptionsWidget::showEvent ( QShowEvent * event ) {
std::cerr << "Todo : Set Options in Widget" << std::endl;
//general
fullscreen->setChecked( OpenFlipper::Options::fullScreen() );
splash->setChecked( OpenFlipper::Options::splash() );
toolbox->setChecked( !OpenFlipper::Options::hideToolbox() );
logger->setChecked( !OpenFlipper::Options::hideLogger() );
//viewer
backfaceCulling->setChecked( OpenFlipper::Options::backfaceCulling() );
wZoomFactor->setText( QString::number(OpenFlipper::Options::wheelZoomFactor(), 'f') );
wZoomFactorShift->setText( QString::number(OpenFlipper::Options::wheelZoomFactorShift(), 'f') );
}
void OptionsWidget::slotApply() {
std::cerr << "Todo : Get Options from Widget and set them in the core" << std::endl;
//general
OpenFlipper::Options::fullScreen( fullscreen->isChecked() );
OpenFlipper::Options::splash( splash->isChecked() );
OpenFlipper::Options::hideToolbox( !toolbox->isChecked() );
OpenFlipper::Options::hideLogger( !logger->isChecked() );
//viewer
OpenFlipper::Options::backfaceCulling( backfaceCulling->isChecked() );
OpenFlipper::Options::wheelZoomFactor( wZoomFactor->text().toDouble() );
OpenFlipper::Options::wheelZoomFactorShift( wZoomFactorShift->text().toDouble() );
emit applyOptions();
emit saveOptions();
hide();
}
......
......@@ -48,6 +48,7 @@ class OptionsWidget : public QWidget, public Ui::OptionsWidget
signals:
void applyOptions();
void saveOptions();
private slots:
/// Hide widget, Update Options and tell others about changed Options
......
......@@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>290</width>
<height>404</height>
<width>567</width>
<height>487</height>
</rect>
</property>
<property name="windowTitle" >
......@@ -14,14 +14,196 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QLabel" name="label" >
<property name="text" >
<string>TODO</string>
<widget class="QTabWidget" name="tabWidget" >
<property name="toolTip" >
<string/>
</property>
<property name="statusTip" >
<string/>
</property>
<property name="currentIndex" >
<number>1</number>
</property>
<property name="usesScrollButtons" >
<bool>true</bool>
</property>
<widget class="QWidget" name="general" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>545</width>
<height>409</height>
</rect>
</property>
<attribute name="title" >
<string>General</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<widget class="QCheckBox" name="fullscreen" >
<property name="toolTip" >
<string>Display OpenFlipper in fullscreen mode</string>
</property>
<property name="statusTip" >
<string>Display OpenFlipper in fullscreen mode</string>
</property>
<property name="text" >
<string>Show Fullscreen</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="splash" >
<property name="toolTip" >
<string>Show splash screen on startup</string>
</property>
<property name="statusTip" >
<string>Show splash screen on startup</string>
</property>
<property name="text" >
<string>Show Splash-Screen</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="toolbox" >
<property name="toolTip" >
<string>Show the toolbox for plugin widgets</string>
</property>
<property name="statusTip" >
<string>Show the toolbox for plugin widgets</string>
</property>
<property name="text" >
<string>Show Toolbox (CTRL+T)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="logger" >
<property name="toolTip" >
<string>Show the Logger window at the bottom</string>
</property>
<property name="statusTip" >
<string>Show the Logger window at the bottom</string>
</property>
<property name="text" >
<string>Show Logger (CTRL+L)</string>
</property>
</widget>
</item>
<item>
<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>
</layout>
</widget>
<widget class="QWidget" name="viewer" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>545</width>
<height>409</height>
</rect>
</property>
<attribute name="title" >
<string>Viewer</string>
</attribute>
<layout class="QFormLayout" name="formLayout" >
<item row="0" column="1" >
<widget class="QCheckBox" name="backfaceCulling" >
<property name="toolTip" >
<string>Enable backface culling</string>
</property>
<property name="statusTip" >
<string>Enable backface culling</string>
</property>
<property name="text" >
<string>Backface culling</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>MouseWheel Zoomfactor:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="wZoomFactor" >
<property name="maximumSize" >
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip" >
<string>Set the factor to control the zooming with the mouse-wheel</string>
</property>
<property name="statusTip" >
<string>Set the factor to control the zooming with the mouse-wheel</string>
</property>
<property name="inputMask" >
<string>9.99; </string>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>MouseWheel Zoomfactor (shift):</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="wZoomFactorShift" >
<property name="maximumSize" >
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip" >
<string>Set the factor to control the zooming with the mouse-wheel while the shift key is pressed</string>
</property>
<property name="statusTip" >
<string>Set the factor to control the zooming with the mouse-wheel while the shift key is pressed</string>
</property>
<property name="inputMask" >
<string>9.99; </string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<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>
<widget class="QPushButton" name="applyButton" >
<property name="text" >
......
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