00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
#include <qframe.h>
00013
#include <qlayout.h>
00014
#include <qpixmap.h>
00015
#include <qtooltip.h>
00016
#include <qdir.h>
00017
#include <qapplication.h>
00018
#include <qiconview.h>
00019
00020
00021
#if defined(Q_OS_MACX)
00022
#include "/Developer/Headers/FlatCarbon/Carbon.h"
00023
#endif
00024
00025
00026
#include "window.h"
00027
#include "titleWidget.h"
00028
#include "layoutWidget.h"
00029
#include "statusWidget.h"
00030
#include "subalbumsWidget.h"
00031
#include "subalbumWidget.h"
00032
#include "dialogs/questionDialog.h"
00033
#include "dialogs/alertDialog.h"
00034
00035
00036
#include "../config.h"
00037
#include "../backend/album.h"
00038
#include "../backend/subalbum.h"
00039
#include "../backend/photo.h"
00040
#include "../backend/recentAlbums.h"
00041
#include "../configuration/configuration.h"
00042
#include "../configuration/loadingSavingWidget.h"
00043
#include "../configuration/layoutSettingsWidget.h"
00044
#include "../configuration/alertsWidget.h"
00045
#include "../configuration/miscSettings.h"
00046
00047
00048 Window::Window(
QWidget* parent,
const char* name ) :
QWidget(parent,name)
00049 {
00050
00051 setWFlags(WRepaintNoErase);
00052
00053
00054
shadowBL =
new QPixmap( QString(
IMAGE_PATH)+
"miscImages/photoGradientBottomLeft.png" );
00055
shadowB =
new QPixmap( QString(
IMAGE_PATH)+
"miscImages/photoGradientBottom.png" );
00056
shadowBR =
new QPixmap( QString(
IMAGE_PATH)+
"miscImages/photoGradientBottomRight.png" );
00057
shadowR =
new QPixmap( QString(
IMAGE_PATH)+
"miscImages/photoGradientRight.png" );
00058
shadowTR =
new QPixmap( QString(
IMAGE_PATH)+
"miscImages/photoGradientTopRight.png" );
00059
00060
00061
photoInfo =
new QPixmap( QString(
IMAGE_PATH)+
"buttonIcons/photoInfo.png");
00062
00063
00064
00065
config =
new Configuration();
00066 LoadingSavingWidget::setDefaults(
config);
00067 LayoutSettingsWidget::setDefaults(
config);
00068 AlertsWidget::setDefaults(
config);
00069 MiscSettings::setDefaults(
config);
00070
00071
00072
config->
loadSettings();
00073
00074
00075 QDir homeDir;
00076
bool configDirMade =
true;
00077
if(!homeDir.exists(
config->
getString(
"loadSave",
"tempImageDirectory")) )
00078 { configDirMade = homeDir.mkdir(
config->
getString(
"loadSave",
"tempImageDirectory")); }
00079
00080
if(!configDirMade)
00081 {
00082
AlertDialog alert(
"unable to create temp dir", QString(
"unable to make temporary directory! (" +
config->
getString(
"loadSave",
"tempImageDirectory") ),
00083
"alertIcons/warning.png",
this );
00084 alert.exec();
00085
00086
00087
config->
resetSetting(
"loadSave",
"tempImageDirectory" );
00088 configDirMade =
true;
00089
if(!homeDir.exists(
config->
getString(
"loadSave",
"tempImageDirectory")) )
00090 { configDirMade = homeDir.mkdir(
config->
getString(
"loadSave",
"tempImageDirectory")); }
00091 }
00092
00093
00094
if(!configDirMade)
00095 {
00096
AlertDialog alert(
"unable to create temp dir", QString(
"unable to make temporary directory! (" +
config->
getString(
"loadSave",
"tempImageDirectory") ),
00097
"alertIcons/warning.png",
this );
00098 alert.exec();
00099
00100 close();
00101 }
00102
00103
00104
00105
title =
new TitleWidget (
this,
"title");
00106
layout =
new LayoutWidget(
this,
"layout");
00107
status =
new StatusWidget(
this,
"status");
00108
00110 connect(
layout, SIGNAL(collectionSelected(
Subalbum*)),
00111
title, SLOT(refreshCollectionAnnotations(
Subalbum*)) );
00112
00114 connect(
title, SIGNAL(subalbumNameChanged()),
00115
layout, SLOT(refreshSelectedCollectionIconName()) );
00116
00117
00118
00119
00120
00121
00122
layout->
refresh();
00123
00124
00125
grid =
new QGridLayout(
this, 3, 2, 0);
00126
grid->addWidget(
title, 0, 0 );
00127
grid->addWidget(
layout, 1, 0 );
00128
grid->setRowStretch( 1, 1 );
00129
grid->addWidget(
status, 2, 0 );
00130
grid->setRowSpacing( 2, 24 );
00131
00132
grid->setColStretch(0, 1 );
00133
00134
00135
00136
#if( !defined(Q_OS_MACX) && !defined(Q_OS_WIN) )
00137
setIcon( QPixmap(QString(
IMAGE_PATH)+
"miscImages/as32.png") );
00138
#endif
00139
00140 setCaption(
00141 #ifdef CVS_CODE
00142
"(CVS BUILD) " +
00143 #endif
00144 tr(
"Album Shaper"));
00145
00146
00147 QToolTip::setGloballyEnabled(
config->
getBool(
"layout",
"showTooltips" ) );
00148
title->
useAnimation(
config->
getBool(
"layout",
"animation" ) );
00149
00150 }
00151
00152 Window::~Window()
00153 {
00154
00155
config->
removeGroup(
"recentAlbums" );
00156
RecentAlbums* recentAlbums =
title->
getRecentAlbums();
00157
int num = recentAlbums->
numEntries();
00158
int i;
00159 QString albumName, albumLocation, albumPhotoCount;
00160
for(i=0; i<num; i++)
00161 {
00162 recentAlbums->
getEntry( i, albumName, albumLocation, albumPhotoCount );
00163
config->
setString(
"recentAlbums", QString(
"%1_name").arg(i), albumName );
00164
config->
setString(
"recentAlbums", QString(
"%1_location").arg(i), albumLocation );
00165
config->
setString(
"recentAlbums", QString(
"%1_photoCount").arg(i), albumPhotoCount );
00166 }
00167
00168
00169
config->
setInt(
"layout",
"windowPosX", pos().x() );
00170
config->
setInt(
"layout",
"windowPosY", pos().y() );
00171
config->
setInt(
"layout",
"windowWidth", size().
width() );
00172
config->
setInt(
"layout",
"windowHeight", size().
height() );
00173
00174
00175
config->
saveSettings();
00176
00177
00178
delete config;
00179
config = NULL;
00180 }
00181
00182 TitleWidget*
Window::getTitle()
00183 {
00184
return title;
00185 }
00186
00187 LayoutWidget*
Window::getLayout()
00188 {
00189
return layout;
00190 }
00191
00192 StatusWidget*
Window::getStatus()
00193 {
00194
return status;
00195 }
00196
00197 void Window::refresh()
00198 {
00199
layout->
refresh();
00200 }
00201
00202 void Window::closeEvent( QCloseEvent* e)
00203 {
00204
00205
00206
if(
title->
getAlbum()->
albumModified() )
00207 {
00208
00209
bool proceed = (!
config->
getBool(
"alerts",
"showDestructiveAlerts" ));
00210
if(!proceed)
00211 {
00212
QuestionDialog sure( tr(
"Quit without saving?"),
00213 tr(
"You have unsaved work. Are you sure you want to quit without saving?"),
00214
"alertIcons/warning.png",
00215
this );
00216 proceed = sure.exec();
00217 }
00218
if(proceed)
00219 e->accept();
00220
else
00221 e->ignore();
00222 }
00223
else
00224 {
00225 e->accept();
00226 }
00227 }
00228
00229 Configuration*
Window::getConfig()
00230 {
00231
return config;
00232 }
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322 bool Window::event( QEvent *e )
00323 {
00324
00325
if (QWidget::event( e ) )
00326
return true;
00327
00328
00329
if ( e->type() == QEvent::ShowMinimized )
00330 {
00331
00332
title->
windowStateChanged(
false );
00333
return true;
00334 }
00335
00336
return false;
00337 }
00338
00339 void Window::hideEvent( QHideEvent *)
00340 {
00341
00342
title->
windowStateChanged(
false );
00343 }
00344
00345 void Window::showEvent ( QShowEvent * )
00346 {
00347
00348
title->
windowStateChanged(
true );
00349 }
00350