AlbumShaper 1.0a3
layoutSettingsWidget.cpp
Go to the documentation of this file.
1//==============================================
2// copyright : (C) 2003-2005 by Will Stokes
3//==============================================
4// This program is free software; you can redistribute it
5// and/or modify it under the terms of the GNU General
6// Public License as published by the Free Software
7// Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//==============================================
10
11//Systemwide includes
12#include <qlayout.h>
13#include <qlabel.h>
14#include <qfont.h>
15#include <qcheckbox.h>
16#include <q3frame.h>
17#include <qslider.h>
18#include <qspinbox.h>
19#include <q3vgroupbox.h>
20#include <qpushbutton.h>
21#include <qcombobox.h>
22#include <qapplication.h>
23#include <qtooltip.h>
24//Added by qt3to4:
25#include <Q3GridLayout>
26#include <QDesktopWidget>
27
28//Projectwide includes
30#include "configuration.h"
31#include "../config.h"
32#include "../gui/window.h"
33#include "../gui/titleWidget.h"
34
35//==============================================
37 QWidget* parent,
38 const char* name ) : QWidget( parent, name)
39{
40 this->config = config;
41
42 categoryLabel = new QLabel( tr("Appearance:"), this);
43 QFont labelFont = categoryLabel->font();
44 labelFont.setWeight(QFont::Bold);
45 categoryLabel->setFont( labelFont );
46
47 horizontalLine = new Q3Frame(this);
48 horizontalLine->setLineWidth(2);
49 horizontalLine->setMidLineWidth(1);
50 horizontalLine->setFrameStyle( Q3Frame::HLine | Q3Frame::Raised );
51 //----------------
52 //General Settings:
53 //-display image animations
54 //-display tooltips
55 generalSettings = new Q3VGroupBox( tr("General"), this);
56 useAnimation = new QCheckBox( tr("Use animation"), generalSettings);
57 showTooltips = new QCheckBox( tr("Show tooltips"), generalSettings);
58 //----------------
59 //Window placement and size Settings:
60 //-restore old placement and size
61 //-preset default size (% of screen size) and placement
62 windowPlacementSize = new Q3VGroupBox( tr("Window Placement and Size"), this);
63 restoreWindowPlacementSize = new QCheckBox( tr("Restore window placement and size"), windowPlacementSize);
64
66 defaultWindowSizeLabel = new QLabel( tr("% of Screen:"), sizeFrame);
67 defaultWindowSizeSlider = new QSlider(Qt::Horizontal, sizeFrame);
68 defaultWindowSizeSlider->setMinValue(1);
69 defaultWindowSizeSlider->setMaxValue(100);
70 defaultWindowSizeValue = new QSpinBox(1,100,1,sizeFrame);
71 defaultWindowSizeValue->setSuffix("%");
72
73 defaultWindowPlacementLabel = new QLabel( tr("Placement:"), sizeFrame);
74 defaultWindowPlacement = new QComboBox( sizeFrame );
75 defaultWindowPlacement->insertItem( tr("Center") );
76 defaultWindowPlacement->insertItem( tr("Top Left") );
77 defaultWindowPlacement->insertItem( tr("Top Right") );
78 defaultWindowPlacement->insertItem( tr("Bottom Left") );
79 defaultWindowPlacement->insertItem( tr("Bottom Right") );
80
81 //update spinbox value when slider moves
82 connect( defaultWindowSizeSlider, SIGNAL(valueChanged(int)),
83 this, SLOT(defaultSizeSliderMoved(int)) );;
84
85 //update slider when spinbox changes
86 connect( defaultWindowSizeValue, SIGNAL(valueChanged(int)),
87 this, SLOT(defaultSizeSpinboxChanged(int)) );;
88
89 //disable manual window size/placement settings when auto save position/location is checked
90 connect( restoreWindowPlacementSize, SIGNAL(toggled(bool)),
91 this, SLOT(toggleDefaultSizeEnabled(bool)) );;
92 //----------------
93 //place window placement/size control in box grid
94 manualPlacementGrid = new Q3GridLayout( sizeFrame, 2, 3, 0);
96
99 manualPlacementGrid->setColStretch(1, 1);
101
103 manualPlacementGrid->addMultiCellWidget(defaultWindowPlacement, 1, 1, 1, 2, Qt::AlignLeft);
104 //----------------
105 //Setup larger boxes in overall grid
106 mainGrid = new Q3GridLayout( this, 5, 1, 0);
107 mainGrid->setSpacing( WIDGET_SPACING );
108
109 mainGrid->addWidget( categoryLabel, 0, 0, Qt::AlignLeft );
110 mainGrid->addWidget( horizontalLine, 1, 0 );
111 mainGrid->addWidget( generalSettings, 2, 0 );
112 mainGrid->addWidget( windowPlacementSize, 3, 0 );
113 mainGrid->setRowStretch( 4, 1 );
114}
115//==============================================
117{
118 //update spinbox
119 defaultWindowSizeValue->setValue( v );
120}
121//==============================================
123{
124 //update slider
125 defaultWindowSizeSlider->setValue( v );
126}
127//==============================================
129{
130 sizeFrame->setDisabled(b);
131}
132//==============================================
134{
135 config->setBool( "layout", "animation", true );
136 config->setBool( "layout", "showTooltips", true );
137 config->setBool( "layout", "restoreWindowPlacementSize", true);
138 //----
139 QDesktopWidget *desktop = QApplication::desktop();
140 int width = (8*desktop->width()) / 10;
141 int height = (8*desktop->height()) / 10;
142 config->setInt( "layout", "windowWidth", width );
143 config->setInt( "layout", "windowHeight", height );
144 config->setInt( "layout", "windowPosX", (desktop->width() - width) / 2 );
145 config->setInt( "layout", "windowPosY", (desktop->height() - height) / 2 );
146 //----
147 config->setInt( "layout", "defaultWindowSize", 80 );
148 config->setString( "layout", "defaultWindowPlacement", 0 );
149}
150//==============================================
152{
153 useAnimation->setChecked( config->getBool( "layout", "animation" ));
154 showTooltips->setChecked( config->getBool( "layout", "showTooltips" ));
155 restoreWindowPlacementSize->setChecked( config->getBool( "layout", "restoreWindowPlacementSize" ));
156 defaultWindowSizeValue->setValue( config->getInt( "layout", "defaultWindowSize" ));
157 defaultWindowPlacement->setCurrentItem( config->getInt( "layout", "defaultWindowPlacement" ) );
158}
159//==============================================
161{
162 //set setting values in config object so they are properly saved to disk
163 config->setBool( "layout", "animation", useAnimation->isChecked() );
164 config->setBool( "layout", "showTooltips", showTooltips->isChecked() );
165 config->setBool( "layout", "restoreWindowPlacementSize", restoreWindowPlacementSize->isChecked());
166 config->setInt( "layout", "defaultWindowSize", defaultWindowSizeValue->value() );
167 config->setInt( "layout", "defaultWindowPlacement", defaultWindowPlacement->currentItem() );
168
169 //apply setting changes to application behavior
170 //QToolTip::setGloballyEnabled( config->getBool( "layout", "showTooltips" ) );
171 ((Window*)qApp->mainWidget())->getTitle()->useAnimation( config->getBool( "layout", "animation" ) );
172}
173//==============================================
int width
Definition blur.cpp:79
int height
Definition blur.cpp:79
Configuration object manages all user-specific application settings.
bool getBool(QString group, QString key)
Fetch bool setting.
void setInt(QString group, QString key, int val)
Set int setting.
void setBool(QString group, QString key, bool val)
Set bool setting.
void setString(QString group, QString key, QString value)
Sets a setting value, if group does not exist it is created, if setting does not exist it is also cre...
int getInt(QString group, QString key)
Fetch int setting.
static void setDefaults(Configuration *config)
Q3GridLayout * manualPlacementGrid
Configuration * config
Backend config object pointer.
LayoutSettingsWidget(Configuration *config, QWidget *parent=0, const char *name=0)
void defaultSizeSpinboxChanged(int val)
QCheckBox * restoreWindowPlacementSize
Q3VGroupBox * windowPlacementSize
Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget.
Definition window.h:40
#define WIDGET_SPACING
Definition config.h:31
long b