AlbumShaper 1.0a3
loadingSavingWidget.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 <q3frame.h>
16#include <qcheckbox.h>
17#include <q3vgroupbox.h>
18#include <qlineedit.h>
19#include <qpushbutton.h>
20#include <qtooltip.h>
21#include <qcombobox.h>
22#include <qstringlist.h>
23#include <qdir.h>
24#include <q3filedialog.h>
25#include <qslider.h>
26#include <qvalidator.h>
27//Added by qt3to4:
28#include <QPixmap>
29#include <Q3GridLayout>
30
31//Projectwide includes
32#include "loadingSavingWidget.h"
33#include "configuration.h"
34#include "../config.h"
35
36//PLATFORM_SPECIFIC_CODE
37#if defined(Q_OS_WIN)
38#include <stdlib.h>
39#endif
40
41//==============================================
43 QWidget* parent,
44 const char* name ) : QWidget( parent, name)
45{
46 this->config = config;
47
48 categoryLabel = new QLabel( tr("Loading + Saving:"), this);
49 QFont labelFont = categoryLabel->font();
50 labelFont.setWeight(QFont::Bold);
51 categoryLabel->setFont( labelFont );
52
53 horizontalLine = new Q3Frame(this);
54 horizontalLine->setLineWidth(2);
55 horizontalLine->setMidLineWidth(1);
56 horizontalLine->setFrameStyle( Q3Frame::HLine | Q3Frame::Raised );
57 //----------------
58 //Default new album theme
59 defaultToThisThemeFrame = new Q3Frame( this );
60 defaultToThisThemeOnNew = new QLabel( tr("Default new album theme:"), defaultToThisThemeFrame);
62
63 defaultToThisTheme->insertItem( tr("Last Used") );
64 QDir localDir( THEMES_PATH );
65 QStringList list = localDir.entryList( QDir::Dirs );
66 QStringList::Iterator file;
67 for ( file = list.begin(); file != list.end(); ++file )
68 {
69 if(localDir.exists( QString(*file) + "/theme.xsl" ))
70 defaultToThisTheme->insertItem( *file );
71 }
72
73 defaultToThisThemeGrid = new Q3GridLayout(defaultToThisThemeFrame, 1, 4, 0);
75 defaultToThisThemeGrid->setColSpacing(1, 8);
77 defaultToThisThemeGrid->setColSpacing(3, 8);
78 defaultToThisThemeGrid->setColStretch(3, 1);
79 //----------------
80 //Temp directory
81 tempImageDirectoryFrame = new Q3Frame( this );
82 tempImageDirectory = new QLabel( tr("Temporary image directory:"), tempImageDirectoryFrame);
84 tempImageDirectoryVal->setText( "/home" );
85 browseButton = new QPushButton( tempImageDirectoryFrame );
86 browseButton->setPixmap( QPixmap(QString(IMAGE_PATH)+"buttonIcons/browse.png") );
87 browseButton->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Maximum );
88 QToolTip::add( browseButton, tr("Browse to temporary image directory") );
89 connect( browseButton, SIGNAL(clicked()), SLOT(browse()) );
90
91 tempImageDirectoryGrid = new Q3GridLayout(tempImageDirectoryFrame, 1, 5, 0);
93 tempImageDirectoryGrid->setColSpacing(1, 8);
95 tempImageDirectoryGrid->setColStretch(2, 1);
96 tempImageDirectoryGrid->setColSpacing(3, 8);
97 tempImageDirectoryGrid->addWidget(browseButton, 0, 4);
98 //----------------
99 //Check photo mods since last load?
100 checkPhotoMods = new QCheckBox( tr("Check for photo modifications"), this );
101 //----------------
102 //Setup larger boxes in overall grid
103 mainGrid = new Q3GridLayout( this, 6, 1, 0);
104 mainGrid->setSpacing( WIDGET_SPACING );
105
106 mainGrid->addWidget( categoryLabel, 0, 0, Qt::AlignLeft );
107 mainGrid->addWidget( horizontalLine, 1, 0 );
108 mainGrid->addWidget( defaultToThisThemeFrame, 2, 0 );
109 mainGrid->addWidget( tempImageDirectoryFrame, 3, 0 );
110 mainGrid->addWidget( checkPhotoMods, 4, 0 );
111 mainGrid->setRowStretch( 5, 1 );
112 //----------------
113}
114//==============================================
116{
117 QString dirName = Q3FileDialog::getExistingDirectory( tempImageDirectoryVal->text(),
118 this, NULL, "Temporary Image Directory");
119 if(!dirName.isNull())
120 tempImageDirectoryVal->setText( dirName );
121}
122//==============================================
124{
125 config->setBool( "loadSave", "disableCheckPhotoMods", true );
126 config->setString( "loadSave", "defaultTheme", "Last Used" );
127 config->setString( "loadSave", "lastUsedTheme", "Slick" );
128 //-------
129 //set default loading/saving albums, add photo, and temp image directories
130 config->setString( "loadSave", "tempImageDirectory", TEMP_DIR );
131
132 //PLATFORM_SPECIFIC_CODE
133
134 //Mac OS X
135 #if defined(Q_OS_MACX)
136 config->setString( "loadSave", "loadSaveDir", QDir::homeDirPath() + QString("/Pictures") );
137
138 //Windows
139 #elif defined(Q_OS_WIN)
140 config->setString( "loadSave", "loadSaveDir",
141 QDir::convertSeparators( getenv("USERPROFILE") +
142 QString("/My Documents/My Pictures") ));
143
144 //Unix/Linux/BSD
145 #else
146 config->setString( "loadSave", "loadSaveDir", QDir::homeDirPath() );
147 #endif
148
149 config->setString( "loadSave", "addPhotoDir", config->getString( "loadSave", "loadSaveDir") );
150 //-------
151 config->setBool( "loadSave", "useDefaultImageSizes", true );
152 config->setInt( "loadSave", "thumbWidth", 200 );
153 config->setInt( "loadSave", "thumbHeight", 150 );
154 config->setInt( "loadSave", "slideshowWidth", 600 );
155 config->setInt( "loadSave", "slideshowHeight", 400 );
156 config->setInt( "loadSave", "albumWidth", 500 );
157 config->setInt( "loadSave", "albumHeight", 320 );
158 config->setInt( "loadSave", "subalbumWidth", 200 );
159 config->setInt( "loadSave", "subalbumHeight", 150 );
160}
161//==============================================
163{
164 checkPhotoMods->setChecked( ! config->getBool( "loadSave", "disableCheckPhotoMods" ));
165 tempImageDirectoryVal->setText( config->getString( "loadSave", "tempImageDirectory" ) );
166 tempImageDirectoryVal->setCursorPosition(0);
167
168 int i;
169 bool defaultTFound = false;
170 QString defaultT = config->getString( "loadSave", "defaultTheme" );
171 for(i=1; i<defaultToThisTheme->count(); i++)
172 {
173 defaultToThisTheme->setCurrentItem(i);
174 if(defaultToThisTheme->currentText().compare( defaultT ) == 0)
175 {
176 defaultTFound = true;
177 break;
178 }
179 }
180
181 if(!defaultTFound)
182 defaultToThisTheme->setCurrentItem(0);
183}
184//==============================================
186{
187 config->setBool( "loadSave", "disableCheckPhotoMods", !checkPhotoMods->isChecked() );
188 config->setString( "loadSave", "tempImageDirectory",
189 QDir::convertSeparators( QDir::cleanDirPath( tempImageDirectoryVal->text() ) ) );
190 config->setString( "loadSave", "defaultTheme", defaultToThisTheme->currentText() );
191}
192//==============================================
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...
QString getString(QString group, QString key)
Fetch string setting.
QCheckBox * checkPhotoMods
Check for photo modifications on load.
Q3Frame * tempImageDirectoryFrame
Temporary Image directory.
Q3GridLayout * tempImageDirectoryGrid
Q3GridLayout * defaultToThisThemeGrid
QLineEdit * tempImageDirectoryVal
LoadingSavingWidget(Configuration *config, QWidget *parent=0, const char *name=0)
static void setDefaults(Configuration *config)
Configuration * config
Backend config object pointer.
QString IMAGE_PATH
Definition config.cpp:18
QString TEMP_DIR
Definition config.cpp:23
QString THEMES_PATH
Definition config.cpp:21
#define WIDGET_SPACING
Definition config.h:31