AlbumShaper 1.0a3
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:
Collaboration diagram for Window:

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.
 
Q3GridLayout * 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 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.

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
106close();
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:37
static void setDefaults(Configuration *config)
Configuration object manages all user-specific application settings.
bool getBool(QString group, QString key)
Fetch bool setting.
bool loadSettings()
Loads settings.
void resetSetting(QString group, QString key)
Resets a setting to it's default value.
QString getString(QString group, QString key)
Fetch string setting.
static void setDefaults(Configuration *config)
Displays list of subalbums and a particular subalbum layout.
void refresh()
Refreshes layout.
static void setDefaults(Configuration *config)
static void setDefaults(Configuration *config)
A subalbum contains photos.
Definition subalbum.h:49
Widget which displays album name, description, representative image, and album shaper logo.
Definition titleWidget.h:57
void useAnimation(bool val)
Use animation for rep images?
TitleWidget * title
Title widget cont ains menu's, album information and Album Shaper icon.
Definition window.h:113
QPixmap * shadowTR
Definition window.h:70
QPixmap * shadowB
Definition window.h:70
StatusWidget * status
Status widget either displays a status message or progress bar.
Definition window.h:119
QPixmap * photoInfo
Definition window.h:73
QPixmap * shadowR
Definition window.h:70
LayoutWidget * layout
Layout includes subalbums listing and particular subalbum layout.
Definition window.h:116
Q3GridLayout * grid
Grid objects placed in.
Definition window.h:110
QPixmap * shadowBR
Definition window.h:70
QPixmap * shadowBL
Definition window.h:70
Configuration * config
Configuration settings.
Definition window.h:107
QString IMAGE_PATH
Definition config.cpp:18

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

◆ ~Window()

Window::~Window ( )

Save user settings on destruct.

Definition at line 158 of file window.cpp.

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
182
183 //delete non-qt objects
184 delete config;
185 config = NULL;
186}
int width
Definition blur.cpp:79
int height
Definition blur.cpp:79
void removeGroup(QString group)
Removes an entire group of settings.
void setInt(QString group, QString key, int val)
Set int setting.
bool saveSettings()
Saves settings.
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...
This class maintains and handles saving and loading a list of recently viewed albums.
void getEntry(int index, QString &name, QString &location, QString &photoCount)
RecentAlbums * getRecentAlbums()
returns handle to recent albums object

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

Member Function Documentation

◆ closeEvent()

void Window::closeEvent ( QCloseEvent * e)
protected

Definition at line 208 of file window.cpp.

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
A configurable question dialog that returns true/false.
Album * getAlbum()
Returns a pointer to the album object.

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

◆ event()

bool Window::event ( QEvent * e)
protected

Definition at line 328 of file window.cpp.

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}
void windowStateChanged(bool state)
Enables/disables "minimize" window menu entry depending on window state.

References title, and TitleWidget::windowStateChanged().

◆ getConfig()

◆ getLayout()

◆ getStatus()

◆ getTitle()

◆ hideEvent()

void Window::hideEvent ( QHideEvent * )
protected

Definition at line 345 of file window.cpp.

346{
347 //update menu entries as per window state change
348 title->windowStateChanged( false );
349}

References title, and TitleWidget::windowStateChanged().

◆ refresh()

void Window::refresh ( )

refreshes the layout

Definition at line 203 of file window.cpp.

204{
205 layout->refresh();
206}

References layout, and LayoutWidget::refresh().

Referenced by TitleWidget::refresh().

◆ showEvent()

void Window::showEvent ( QShowEvent * )
protected

Definition at line 351 of file window.cpp.

352{
353 //update menu entries as per window state change
354 title->windowStateChanged( true );
355}

References title, and TitleWidget::windowStateChanged().

◆ 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: