AlbumShaper  1.0a3
Public Member Functions | Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes
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]

List of all members.

Public Member Functions

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

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

Private Attributes

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

Detailed Description

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

Definition at line 32 of file window.h.


Constructor & Destructor Documentation

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 48 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().

                                                  : QWidget(parent,name)
{
  //don't clear pixmap area before painting, prevents flicker
  setWFlags(WRepaintNoErase);

  //load shadow pixmaps
  shadowBL = new QPixmap( QString(IMAGE_PATH)+"miscImages/photoGradientBottomLeft.png" );
  shadowB = new QPixmap( QString(IMAGE_PATH)+"miscImages/photoGradientBottom.png" );
  shadowBR = new QPixmap( QString(IMAGE_PATH)+"miscImages/photoGradientBottomRight.png" );
  shadowR = new QPixmap( QString(IMAGE_PATH)+"miscImages/photoGradientRight.png" );
  shadowTR = new QPixmap( QString(IMAGE_PATH)+"miscImages/photoGradientTopRight.png" );

  //load photo info pixmap
  photoInfo = new QPixmap( QString(IMAGE_PATH)+"buttonIcons/photoInfo.png");

  //------------------------------------------------
  //create configuration object with default settings
  config = new Configuration();
  LoadingSavingWidget::setDefaults(config);
  LayoutSettingsWidget::setDefaults(config);
  AlertsWidget::setDefaults(config);
  MiscSettings::setDefaults(config);
  //------------------------------------------------
  //load user settings
  config->loadSettings();

  //if temorary image directory does not exist create it
  QDir homeDir;
  bool configDirMade = true;
  if(!homeDir.exists( config->getString( "loadSave", "tempImageDirectory")) )
  { configDirMade = homeDir.mkdir( config->getString( "loadSave", "tempImageDirectory")); }
  //if directory could not be made attempt to revert to default directory
  if(!configDirMade)
  {
    AlertDialog alert( "unable to create temp dir", QString("unable to make temporary directory! (" + config->getString( "loadSave", "tempImageDirectory") ),
  "alertIcons/warning.png", this );
  alert.exec();


    config->resetSetting( "loadSave", "tempImageDirectory" );
    configDirMade = true;
    if(!homeDir.exists( config->getString( "loadSave", "tempImageDirectory")) )
    { configDirMade = homeDir.mkdir( config->getString( "loadSave", "tempImageDirectory")); }
  }

  //if we are still unable to create the temporary image directory then immediately abort
  if(!configDirMade)
  {
      AlertDialog alert( "unable to create temp dir", QString("unable to make temporary directory! (" + config->getString( "loadSave", "tempImageDirectory") ),
  "alertIcons/warning.png", this );
  alert.exec();

close();
  }

  //------------------------------------------------
  //create top level widgets
  title  = new TitleWidget (this, "title");
  layout = new LayoutWidget(this, "layout");
  status = new StatusWidget(this, "status");

  connect( layout, SIGNAL(collectionSelected(Subalbum*)),
           title,  SLOT(refreshCollectionAnnotations(Subalbum*)) );

  connect( title,  SIGNAL(subalbumNameChanged()),
           layout, SLOT(refreshSelectedCollectionIconName()) );
  
//  slideshow = new SlideshowWidget(this, "slideshow", WResizeNoErase);
//  slideshow->hide();
//  connect( slideshow, SIGNAL(endSlideshow()), this, SLOT(endSlideshow()) );
    
  //refresh subalbums listing
  layout->refresh();

  //place widgets in main frame
  grid = new QGridLayout( this, 3, 2, 0);                
  grid->addWidget( title,     0, 0 );
  grid->addWidget( layout,    1, 0 );
  grid->setRowStretch( 1, 1 );
  grid->addWidget( status,    2, 0 );
  grid->setRowSpacing( 2, 24 );
//  grid->addMultiCellWidget( slideshow, 0, 2, 1, 1 );
  grid->setColStretch(0, 1 );  
  
  //PLATFORM_SPECIFIC_CODE
  //create and set application icon
  #if( !defined(Q_OS_MACX) && !defined(Q_OS_WIN) )
  setIcon( QPixmap(QString(IMAGE_PATH)+"miscImages/as32.png") );
  #endif

  setCaption( 
#ifdef CVS_CODE
      "(CVS BUILD) " +        
#endif              
              tr("Album Shaper"));
  //------------------------------------------------
  //apply settings
  QToolTip::setGloballyEnabled( config->getBool( "layout", "showTooltips" ) );
  title->useAnimation( config->getBool( "layout", "animation" ) );
  //------------------------------------------------
}
Window::~Window ( )

Save user settings on destruct.

Definition at line 152 of file window.cpp.

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

{
  //flush and reinsert recent albums listing
  config->removeGroup( "recentAlbums" );
  RecentAlbums* recentAlbums = title->getRecentAlbums();
  int num = recentAlbums->numEntries();
  int i;
  QString albumName, albumLocation, albumPhotoCount;
  for(i=0; i<num; i++)
  {
    recentAlbums->getEntry( i, albumName, albumLocation, albumPhotoCount );
    config->setString( "recentAlbums", QString("%1_name").arg(i),     albumName );
    config->setString( "recentAlbums", QString("%1_location").arg(i), albumLocation );    
    config->setString( "recentAlbums", QString("%1_photoCount").arg(i), albumPhotoCount );    
  }  
  
  //store window size and placement in config object
  config->setInt( "layout", "windowPosX", pos().x() );
  config->setInt( "layout", "windowPosY", pos().y() );
  config->setInt( "layout", "windowWidth", size().width() );
  config->setInt( "layout", "windowHeight", size().height() );

  //save user settings
  config->saveSettings();

  //delete non-qt objects
  delete config;
  config = NULL;
}

Member Function Documentation

void Window::closeEvent ( QCloseEvent *  e) [protected]

Definition at line 202 of file window.cpp.

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

{
  //check if unsaved modifications exist, warn user they
  //will lose these if they quit now
  if(title->getAlbum()->albumModified() )
  {
    //if user has chosen to not receive destructive action warnings, or agrees to the action then quit
    bool proceed = (!config->getBool( "alerts", "showDestructiveAlerts" ));
    if(!proceed)
    {
      QuestionDialog sure( tr("Quit without saving?"),
                                       tr("You have unsaved work. Are you sure you want to quit without saving?"),
                                       "alertIcons/warning.png",
                                       this );
      proceed = sure.exec();
    }
    if(proceed)
      e->accept();
    else
      e->ignore();
  }
  else
  {
    e->accept();
  }
}
bool Window::event ( QEvent *  e) [protected]

Definition at line 322 of file window.cpp.

References title, and TitleWidget::windowStateChanged().

{
  //if base class handles event return immediately
  if (QWidget::event( e ) )
    return true;
  
  //handle showMinimized events
  if ( e->type() == QEvent::ShowMinimized )
  {
    //update menu entries as per window state change
    title->windowStateChanged( false );
    return true;
  }
  
  return false;
}
Configuration * Window::getConfig ( )
LayoutWidget * Window::getLayout ( )
StatusWidget * Window::getStatus ( )
TitleWidget * Window::getTitle ( )
void Window::hideEvent ( QHideEvent *  ) [protected]

Definition at line 339 of file window.cpp.

References title, and TitleWidget::windowStateChanged().

{
  //update menu entries as per window state change
  title->windowStateChanged( false );
}
void Window::refresh ( )

refreshes the layout

Definition at line 197 of file window.cpp.

References layout, and LayoutWidget::refresh().

Referenced by TitleWidget::refresh().

{
  layout->refresh();
}
void Window::showEvent ( QShowEvent *  ) [protected]

Definition at line 345 of file window.cpp.

References title, and TitleWidget::windowStateChanged().

{
  //update menu entries as per window state change
  title->windowStateChanged( true );
}
void Window::startSlideshow ( bool  startAtBeginning) [private]

utility function used by above, actually started slideshow


Member Data Documentation

Configuration settings.

Definition at line 100 of file window.h.

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

QGridLayout* Window::grid [private]

Grid objects placed in.

Definition at line 103 of file window.h.

Referenced by Window().

Layout includes subalbums listing and particular subalbum layout.

Definition at line 109 of file window.h.

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

Definition at line 66 of file window.h.

Referenced by Window().

QPixmap * Window::shadowB

Definition at line 63 of file window.h.

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

QPixmap* Window::shadowBL

Definition at line 63 of file window.h.

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

QPixmap * Window::shadowBR

Definition at line 63 of file window.h.

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

QPixmap * Window::shadowR

Definition at line 63 of file window.h.

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

QPixmap * Window::shadowTR

Definition at line 63 of file window.h.

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

Status widget either displays a status message or progress bar.

Definition at line 112 of file window.h.

Referenced by getStatus(), and Window().

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

Definition at line 106 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: