AlbumShaper  1.0a3
Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
Window Class Reference

Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget. More...

#include <window.h>

Inheritance diagram for Window:
Inheritance graph
[legend]
Collaboration diagram for Window:
Collaboration graph
[legend]

Public Member Functions

 Window (QWidget *parent=0, const char *name=0)
 Creates title area, layout, and tool bar and places them in grid. More...
 
 ~Window ()
 Save user settings on destruct. More...
 
TitleWidgetgetTitle ()
 returns a pointer to the title widget More...
 
LayoutWidgetgetLayout ()
 returns a pointer to the layout object More...
 
StatusWidgetgetStatus ()
 returns a pointer to the status widget More...
 
void refresh ()
 refreshes the layout More...
 
ConfigurationgetConfig ()
 get setting object More...
 

Public Attributes

QPixmap * shadowBL
 
QPixmap * shadowB
 
QPixmap * shadowBR
 
QPixmap * shadowR
 
QPixmap * shadowTR
 
QPixmap * photoInfo
 

Protected Member Functions

bool event (QEvent *)
 
void hideEvent (QHideEvent *)
 
void showEvent (QShowEvent *)
 
void closeEvent (QCloseEvent *e)
 

Private Member Functions

void startSlideshow (bool startAtBeginning)
 utility function used by above, actually started slideshow More...
 

Private Attributes

Configurationconfig
 Configuration settings. More...
 
Q3GridLayout * grid
 Grid objects placed in. More...
 
TitleWidgettitle
 Title widget cont ains menu's, album information and Album Shaper icon. More...
 
LayoutWidgetlayout
 Layout includes subalbums listing and particular subalbum layout. More...
 
StatusWidgetstatus
 Status widget either displays a status message or progress bar. More...
 

Detailed Description

Top level widget, encapsulates the title widget, the layout widget, and the toolbar widget.

Definition at line 39 of file window.h.

Constructor & Destructor Documentation

§ Window()

Window::Window ( QWidget parent = 0,
const char *  name = 0 
)

Creates title area, layout, and tool bar and places them in grid.

refresh title annotations when collections are selected

refresh collection icons when collection names are edited

Definition at line 54 of file window.cpp.

References config, Configuration::getBool(), Configuration::getString(), grid, IMAGE_PATH, layout, Configuration::loadSettings(), photoInfo, LayoutWidget::refresh(), Configuration::resetSetting(), MiscSettings::setDefaults(), AlertsWidget::setDefaults(), LoadingSavingWidget::setDefaults(), LayoutSettingsWidget::setDefaults(), shadowB, shadowBL, shadowBR, shadowR, shadowTR, status, title, and TitleWidget::useAnimation().

54  : QWidget(parent,name)
55 {
56  //don't clear pixmap area before painting, prevents flicker
57  setWindowFlags(Qt::WNoAutoErase);
58 
59  //load shadow pixmaps
60  shadowBL = new QPixmap( QString(IMAGE_PATH)+"miscImages/photoGradientBottomLeft.png" );
61  shadowB = new QPixmap( QString(IMAGE_PATH)+"miscImages/photoGradientBottom.png" );
62  shadowBR = new QPixmap( QString(IMAGE_PATH)+"miscImages/photoGradientBottomRight.png" );
63  shadowR = new QPixmap( QString(IMAGE_PATH)+"miscImages/photoGradientRight.png" );
64  shadowTR = new QPixmap( QString(IMAGE_PATH)+"miscImages/photoGradientTopRight.png" );
65 
66  //load photo info pixmap
67  photoInfo = new QPixmap( QString(IMAGE_PATH)+"buttonIcons/photoInfo.png");
68 
69  //------------------------------------------------
70  //create configuration object with default settings
71  config = new Configuration();
76  //------------------------------------------------
77  //load user settings
79 
80  //if temorary image directory does not exist create it
81  QDir homeDir;
82  bool configDirMade = true;
83  if(!homeDir.exists( config->getString( "loadSave", "tempImageDirectory")) )
84  { configDirMade = homeDir.mkdir( config->getString( "loadSave", "tempImageDirectory")); }
85  //if directory could not be made attempt to revert to default directory
86  if(!configDirMade)
87  {
88  AlertDialog alert( "unable to create temp dir", QString("unable to make temporary directory! (" + config->getString( "loadSave", "tempImageDirectory") ),
89  "alertIcons/warning.png", this );
90  alert.exec();
91 
92 
93  config->resetSetting( "loadSave", "tempImageDirectory" );
94  configDirMade = true;
95  if(!homeDir.exists( config->getString( "loadSave", "tempImageDirectory")) )
96  { configDirMade = homeDir.mkdir( config->getString( "loadSave", "tempImageDirectory")); }
97  }
98 
99  //if we are still unable to create the temporary image directory then immediately abort
100  if(!configDirMade)
101  {
102  AlertDialog alert( "unable to create temp dir", QString("unable to make temporary directory! (" + config->getString( "loadSave", "tempImageDirectory") ),
103  "alertIcons/warning.png", this );
104  alert.exec();
105 
106 close();
107  }
108 
109  //------------------------------------------------
110  //create top level widgets
111  title = new TitleWidget (this, "title");
112  layout = new LayoutWidget(this, "layout");
113  status = new StatusWidget(this, "status");
114 
116  connect( layout, SIGNAL(collectionSelected(Subalbum*)),
117  title, SLOT(refreshCollectionAnnotations(Subalbum*)) );
118 
120  connect( title, SIGNAL(subalbumNameChanged()),
121  layout, SLOT(refreshSelectedCollectionIconName()) );
122 
123 // slideshow = new SlideshowWidget(this, "slideshow", WResizeNoErase);
124 // slideshow->hide();
125 // connect( slideshow, SIGNAL(endSlideshow()), this, SLOT(endSlideshow()) );
126 
127  //refresh subalbums listing
128  layout->refresh();
129 
130  //place widgets in main frame
131  grid = new Q3GridLayout( this, 3, 2, 0);
132  grid->addWidget( title, 0, 0 );
133  grid->addWidget( layout, 1, 0 );
134  grid->setRowStretch( 1, 1 );
135  grid->addWidget( status, 2, 0 );
136  grid->setRowSpacing( 2, 24 );
137 // grid->addMultiCellWidget( slideshow, 0, 2, 1, 1 );
138  grid->setColStretch(0, 1 );
139 
140  //PLATFORM_SPECIFIC_CODE
141  //create and set application icon
142  #if( !defined(Q_OS_MACX) && !defined(Q_OS_WIN) )
143  setIcon( QPixmap(QString(IMAGE_PATH)+"miscImages/as32.png") );
144  #endif
145 
146  setCaption(
147 #ifdef CVS_CODE
148  "(CVS BUILD) " +
149 #endif
150  tr("Album Shaper"));
151  //------------------------------------------------
152  //apply settings
153  //QToolTip::setGloballyEnabled( config->getBool( "layout", "showTooltips" ) );
154  title->useAnimation( config->getBool( "layout", "animation" ) );
155  //------------------------------------------------
156 }
A configurable alert dialog that displays an alert/error message.
Definition: alertDialog.h:36
Q3GridLayout * grid
Grid objects placed in.
Definition: window.h:110
QPixmap * shadowBL
Definition: window.h:70
static void setDefaults(Configuration *config)
QPixmap * shadowR
Definition: window.h:70
QString getString(QString group, QString key)
Fetch string setting.
bool getBool(QString group, QString key)
Fetch bool setting.
void resetSetting(QString group, QString key)
Resets a setting to it&#39;s default value.
void refresh()
Refreshes layout.
bool loadSettings()
Loads settings.
static void setDefaults(Configuration *config)
static void setDefaults(Configuration *config)
Displays list of subalbums and a particular subalbum layout.
Definition: layoutWidget.h:39
QString IMAGE_PATH
Definition: config.cpp:18
A subalbum contains photos.
Definition: subalbum.h:48
void useAnimation(bool val)
Use animation for rep images?
StatusWidget * status
Status widget either displays a status message or progress bar.
Definition: window.h:119
LayoutWidget * layout
Layout includes subalbums listing and particular subalbum layout.
Definition: window.h:116
TitleWidget * title
Title widget cont ains menu&#39;s, album information and Album Shaper icon.
Definition: window.h:113
Configuration object manages all user-specific application settings.
Definition: configuration.h:24
QPixmap * shadowTR
Definition: window.h:70
Widget which displays album name, description, representative image, and album shaper logo...
Definition: titleWidget.h:56
QPixmap * shadowB
Definition: window.h:70
static void setDefaults(Configuration *config)
QPixmap * shadowBR
Definition: window.h:70
Configuration * config
Configuration settings.
Definition: window.h:107
QPixmap * photoInfo
Definition: window.h:73

§ ~Window()

Window::~Window ( )

Save user settings on destruct.

Definition at line 158 of file window.cpp.

References config, RecentAlbums::getEntry(), TitleWidget::getRecentAlbums(), height, RecentAlbums::numEntries(), Configuration::removeGroup(), Configuration::saveSettings(), Configuration::setInt(), Configuration::setString(), title, and width.

159 {
160  //flush and reinsert recent albums listing
161  config->removeGroup( "recentAlbums" );
162  RecentAlbums* recentAlbums = title->getRecentAlbums();
163  int num = recentAlbums->numEntries();
164  int i;
165  QString albumName, albumLocation, albumPhotoCount;
166  for(i=0; i<num; i++)
167  {
168  recentAlbums->getEntry( i, albumName, albumLocation, albumPhotoCount );
169  config->setString( "recentAlbums", QString("%1_name").arg(i), albumName );
170  config->setString( "recentAlbums", QString("%1_location").arg(i), albumLocation );
171  config->setString( "recentAlbums", QString("%1_photoCount").arg(i), albumPhotoCount );
172  }
173 
174  //store window size and placement in config object
175  config->setInt( "layout", "windowPosX", pos().x() );
176  config->setInt( "layout", "windowPosY", pos().y() );
177  config->setInt( "layout", "windowWidth", size().width() );
178  config->setInt( "layout", "windowHeight", size().height() );
179 
180  //save user settings
181  config->saveSettings();
182 
183  //delete non-qt objects
184  delete config;
185  config = NULL;
186 }
void removeGroup(QString group)
Removes an entire group of settings.
void setInt(QString group, QString key, int val)
Set int 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 width
Definition: blur.cpp:79
bool saveSettings()
Saves settings.
This class maintains and handles saving and loading a list of recently viewed albums.
Definition: recentAlbums.h:26
TitleWidget * title
Title widget cont ains menu&#39;s, album information and Album Shaper icon.
Definition: window.h:113
void getEntry(int index, QString &name, QString &location, QString &photoCount)
RecentAlbums * getRecentAlbums()
returns handle to recent albums object
Configuration * config
Configuration settings.
Definition: window.h:107
int height
Definition: blur.cpp:79

Member Function Documentation

§ closeEvent()

void Window::closeEvent ( QCloseEvent *  e)
protected

Definition at line 208 of file window.cpp.

References Album::albumModified(), config, TitleWidget::getAlbum(), Configuration::getBool(), and title.

209 {
210  //check if unsaved modifications exist, warn user they
211  //will lose these if they quit now
212  if(title->getAlbum()->albumModified() )
213  {
214  //if user has chosen to not receive destructive action warnings, or agrees to the action then quit
215  bool proceed = (!config->getBool( "alerts", "showDestructiveAlerts" ));
216  if(!proceed)
217  {
218  QuestionDialog sure( tr("Quit without saving?"),
219  tr("You have unsaved work. Are you sure you want to quit without saving?"),
220  "alertIcons/warning.png",
221  this );
222  proceed = sure.exec();
223  }
224  if(proceed)
225  e->accept();
226  else
227  e->ignore();
228  }
229  else
230  {
231  e->accept();
232  }
233 }
bool albumModified()
Returns true if album has been modified since the last save operation.
Definition: album.cpp:139
bool getBool(QString group, QString key)
Fetch bool setting.
TitleWidget * title
Title widget cont ains menu&#39;s, album information and Album Shaper icon.
Definition: window.h:113
Album * getAlbum()
Returns a pointer to the album object.
A configurable question dialog that returns true/false.
Configuration * config
Configuration settings.
Definition: window.h:107

§ event()

bool Window::event ( QEvent *  e)
protected

Definition at line 328 of file window.cpp.

References title, and TitleWidget::windowStateChanged().

329 {
330  //if base class handles event return immediately
331  if (QWidget::event( e ) )
332  return true;
333 
334  //handle showMinimized events
335  if ( e->type() == QEvent::WindowStateChange && windowState() == Qt::WindowMinimized )
336  {
337  //update menu entries as per window state change
338  title->windowStateChanged( false );
339  return true;
340  }
341 
342  return false;
343 }
TitleWidget * title
Title widget cont ains menu&#39;s, album information and Album Shaper icon.
Definition: window.h:113
void windowStateChanged(bool state)
Enables/disables "minimize" window menu entry depending on window state.

§ getConfig()

Configuration * Window::getConfig ( )

§ getLayout()

LayoutWidget * Window::getLayout ( )

§ getStatus()

StatusWidget * Window::getStatus ( )

§ getTitle()

TitleWidget * Window::getTitle ( )

§ hideEvent()

void Window::hideEvent ( QHideEvent *  )
protected

Definition at line 345 of file window.cpp.

References title, and TitleWidget::windowStateChanged().

346 {
347  //update menu entries as per window state change
348  title->windowStateChanged( false );
349 }
TitleWidget * title
Title widget cont ains menu&#39;s, album information and Album Shaper icon.
Definition: window.h:113
void windowStateChanged(bool state)
Enables/disables "minimize" window menu entry depending on window state.

§ refresh()

void Window::refresh ( )

refreshes the layout

Definition at line 203 of file window.cpp.

References layout, and LayoutWidget::refresh().

Referenced by TitleWidget::refresh().

204 {
205  layout->refresh();
206 }
void refresh()
Refreshes layout.
LayoutWidget * layout
Layout includes subalbums listing and particular subalbum layout.
Definition: window.h:116

§ showEvent()

void Window::showEvent ( QShowEvent *  )
protected

Definition at line 351 of file window.cpp.

References title, and TitleWidget::windowStateChanged().

352 {
353  //update menu entries as per window state change
354  title->windowStateChanged( true );
355 }
TitleWidget * title
Title widget cont ains menu&#39;s, album information and Album Shaper icon.
Definition: window.h:113
void windowStateChanged(bool state)
Enables/disables "minimize" window menu entry depending on window state.

§ startSlideshow()

void Window::startSlideshow ( bool  startAtBeginning)
private

utility function used by above, actually started slideshow

Member Data Documentation

§ config

Configuration* Window::config
private

Configuration settings.

Definition at line 107 of file window.h.

Referenced by closeEvent(), getConfig(), Window(), and ~Window().

§ grid

Q3GridLayout* Window::grid
private

Grid objects placed in.

Definition at line 110 of file window.h.

Referenced by Window().

§ layout

LayoutWidget* Window::layout
private

Layout includes subalbums listing and particular subalbum layout.

Definition at line 116 of file window.h.

Referenced by getLayout(), refresh(), and Window().

§ photoInfo

QPixmap* Window::photoInfo

Definition at line 73 of file window.h.

Referenced by Window().

§ shadowB

QPixmap * Window::shadowB

Definition at line 70 of file window.h.

Referenced by PhotoPreviewWidget::paintItem(), and Window().

§ shadowBL

QPixmap* Window::shadowBL

Definition at line 70 of file window.h.

Referenced by PhotoPreviewWidget::paintItem(), and Window().

§ shadowBR

QPixmap * Window::shadowBR

Definition at line 70 of file window.h.

Referenced by PhotoPreviewWidget::paintItem(), and Window().

§ shadowR

QPixmap * Window::shadowR

Definition at line 70 of file window.h.

Referenced by PhotoPreviewWidget::paintItem(), and Window().

§ shadowTR

QPixmap * Window::shadowTR

Definition at line 70 of file window.h.

Referenced by PhotoPreviewWidget::paintItem(), and Window().

§ status

StatusWidget* Window::status
private

Status widget either displays a status message or progress bar.

Definition at line 119 of file window.h.

Referenced by getStatus(), and Window().

§ title

TitleWidget* Window::title
private

Title widget cont ains menu's, album information and Album Shaper icon.

Definition at line 113 of file window.h.

Referenced by closeEvent(), event(), getTitle(), hideEvent(), showEvent(), Window(), and ~Window().


The documentation for this class was generated from the following files: