AlbumShaper 1.0a3
helpWindow.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 <qfile.h>
13#include <q3textstream.h>
14#include <qstringlist.h>
15
16#include <qlabel.h>
17#include <qpushbutton.h>
18#include <qlayout.h>
19#include <qsizegrip.h>
20#include <qkeysequence.h>
21//Added by qt3to4:
22#include <QPixmap>
23#include <Q3GridLayout>
24#include <Q3Frame>
25#include <QCloseEvent>
26
27//Projectwide includes
28#include "helpWindow.h"
29#include "contents.h"
30#include "whatsNew.h"
31#include "importing.h"
32#include "annotating.h"
33#include "framing.h"
34#include "enhancing.h"
35#include "proTools.h"
36#include "manipulating.h"
37#include "loadSave.h"
38#include "shortcuts.h"
39
40#include "../ALabel.h"
41#include "../../config.h"
42
43//==============================================
44HelpWindow::HelpWindow( QWidget* parent, const char* name ) : QDialog(parent,name)
45{
46 //determine necessary encoding for reading and writing to html files
47 Q3TextStream::Encoding fileEncoding;
48 QString savingCharSet;
49 QString loadingCharSet;
50
51 //Mac OSX -> Use UTF16
52 #if defined(Q_OS_MACX)
53 fileEncoding = Q3TextStream::Unicode;
54 savingCharSet = "utf16";
55 loadingCharSet = "UTF-16";
56
57 //Other UNIX or Windows with Unicode support -> Use UTF8
58 #elif !defined(Q_WS_WIN) || (defined(Q_WS_WIN) && defined(UNICODE))
59 fileEncoding = Q3TextStream::UnicodeUTF8;
60 savingCharSet = "utf8";
61 loadingCharSet = "UTF-8";
62
63 //Windows without Unicode support (Win95/98/ME) -> Use Latin-1
64 #else
65 fileEncoding = Q3TextStream::Latin1;
66 savingCharSet = "latin-1";
67 loadingCharSet = "latin-1";
68 #endif
69 //-------------------------------------------------------------
70 //generate html pages
71 WhatsNew::generateHTML (fileEncoding, savingCharSet);
72 Importing::generateHTML (fileEncoding, savingCharSet);
73 Annotating::generateHTML (fileEncoding, savingCharSet);
74 Framing::generateHTML (fileEncoding, savingCharSet);
75 Enhancing::generateHTML (fileEncoding, savingCharSet);
76 ProTools::generateHTML (fileEncoding, savingCharSet);
77 Manipulating::generateHTML(fileEncoding, savingCharSet);
78 LoadSave::generateHTML (fileEncoding, savingCharSet);
79 Shortcuts::generateHTML (fileEncoding, savingCharSet);
80
81 resize( 800, 400 );
82 setPaletteBackgroundColor( QColor(255,255,255) );
83
84 //set window title
85 setCaption( tr("Album Shaper Help"));
86 //--
87 //create billboard widget
88 billboard = new ALabel( this, "helpBillboard", NULL,
90 billboard->setPixmap( QPixmap( QString(IMAGE_PATH)+"helpImages/helpBillboard.png") );
92 connect( billboard, SIGNAL(pixmapRemoved()),
93 this, SLOT(showFirstSelection()) );
94
95 //construct special mime source factory for loading html files for the contents and content frames
96 loadingMimeSource = new Q3MimeSourceFactory();
97 loadingMimeSource->setExtensionType("html",QString("text/html;charset=%1").arg(loadingCharSet) );
98
99 //create contents widget
100 Contents* contents = new Contents(fileEncoding, savingCharSet, loadingMimeSource, this);
101 connect( contents, SIGNAL(setPage(HELP_PAGE)),
102 this, SLOT(setPage(HELP_PAGE)) );
103
104 //create widget for holding content
105 content = new Q3TextBrowser( this );
106 content->setHScrollBarMode( Q3ScrollView::Auto );
107 content->setVScrollBarMode( Q3ScrollView::Auto );
108 content->setFrameStyle( Q3Frame::NoFrame );
109 content->setMimeSourceFactory( loadingMimeSource );
110
111 //PLATFORM_SPECIFIC_CODE
112 //mac os x puts in a size grip that can interfere with the updates icon, in order
113 //to avoid this we manually place the size grip ourselves
114 //windows users expect a grip too, but qt doesn't put one in by default. we'll add
115 //it for them too. :-)
116#if defined(Q_OS_MACX) || defined(Q_OS_WIN)
117 content->setCornerWidget( new QSizeGrip(this) );
118#endif
119
120 content->hide();
121 //--
122 //place items in grid layout
123 Q3GridLayout* grid = new Q3GridLayout( this, 4, 3, 0);
124 grid->addMultiCellWidget( billboard, 0,2, 0,0, Qt::AlignHCenter | Qt::AlignTop );
125 grid->addWidget( contents, 1,1 );
126 grid->addMultiCellWidget( content, 0,2, 2,2 );
127
128 grid->setRowSpacing( 0, QMAX(billboard->sizeHint().height() -
129 contents->minimumSizeHint().height(), 0)/2 );
130 grid->setColSpacing( 1, contents->minimumSizeHint().width() );
131 grid->setRowStretch( 1, 1 );
132 grid->setColStretch( 2, 1 );
133 //--
134 //PLATFORM_SPECIFIC_CODE - Close Button
135#if (!defined(Q_OS_WIN) && !defined(Q_OS_MACX))
136 QPushButton* closeButton = new QPushButton( tr("Close"), this );
137 closeButton->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed );
138 closeButton->setDefault(true);
139 connect( closeButton, SIGNAL(clicked()), SLOT(close()) );
140 grid->addMultiCellWidget( closeButton, 3,3, 0,2, Qt::AlignCenter );
141#endif
142 //--
143}
144//==============================================
150//==============================================
151void HelpWindow::closeEvent( QCloseEvent* e)
152{
153 QWidget::closeEvent( e );
154 emit closed();
155}
156//==============================================
158{
159 QDialog::reject();
160 emit closed();
161}
162//==============================================
164{
165 //if billboard stillshown first remove it.
166 if( currentPage == BILLBOARD )
167 {
169 currentPage = page;
170
171 //show page only once billboard has finished sliding away to the left
172 }
173 else
174 {
175 currentPage = page;
177 }
178}
179//==============================================
181{
182 content->show();
184}
185//==============================================
187{
189 content->setSource( Shortcuts::filename() );
190 else if( currentPage == WHATS_NEW )
191 content->setSource( WhatsNew::filename() );
192
194 content->setSource( Importing::filename() );
195 else if( currentPage == ANNOTATING_ALBUMS )
196 content->setSource( Annotating::filename() );
197 else if( currentPage == FRAMING )
198 content->setSource( Framing::filename() );
199 else if( currentPage == ENHANCING )
200 content->setSource( Enhancing::filename() );
201 else if( currentPage == PRO_TOOLS )
202 content->setSource( ProTools::filename() );
203 else if( currentPage == MANIPULATING )
204 content->setSource( Manipulating::filename() );
205 else if( currentPage == SAVING_AND_LOADING )
206 content->setSource( LoadSave::filename() );
207 else
208 content->setText("");
209
210 content->setFocus();
211}
212//==============================================
213
214
#define SLIDE_OUT_LEFT
Definition ALabel.h:21
#define APPEAR_IMMEDIATELY
Definition ALabel.h:18
void setPixmap(const QPixmap &p)
animates setting an image
Definition ALabel.cpp:81
void removePixmap(bool forceImmediate=false)
animates removing an image
Definition ALabel.cpp:136
static void generateHTML(Q3TextStream::Encoding type, QString charSet)
generates the html file
static QString filename()
returns the html filename
QSize minimumSizeHint() const
Definition contents.cpp:61
static void generateHTML(Q3TextStream::Encoding type, QString charSet)
generates the html file
Definition enhancing.cpp:29
static QString filename()
returns the html filename
Definition enhancing.cpp:24
static void generateHTML(Q3TextStream::Encoding type, QString charSet)
generates the html file
Definition framing.cpp:29
static QString filename()
returns the html filename
Definition framing.cpp:24
void setPage(HELP_PAGE page)
void showCurrentPage()
void reject()
void closed()
Q3TextBrowser * content
Definition helpWindow.h:49
ALabel * billboard
Definition helpWindow.h:48
HELP_PAGE currentPage
Definition helpWindow.h:51
Q3MimeSourceFactory * loadingMimeSource
Definition helpWindow.h:53
void closeEvent(QCloseEvent *e)
HelpWindow(QWidget *parent=0, const char *name=0)
void showFirstSelection()
static QString filename()
returns the html filename
Definition importing.cpp:24
static void generateHTML(Q3TextStream::Encoding type, QString charSet)
generates the html file
Definition importing.cpp:29
static QString filename()
returns the html filename
Definition loadSave.cpp:24
static void generateHTML(Q3TextStream::Encoding type, QString charSet)
generates the html file
Definition loadSave.cpp:29
static void generateHTML(Q3TextStream::Encoding type, QString charSet)
generates the html file
static QString filename()
returns the html filename
static void generateHTML(Q3TextStream::Encoding type, QString charSet)
generates the html file
Definition proTools.cpp:29
static QString filename()
returns the html filename
Definition proTools.cpp:24
static void generateHTML(Q3TextStream::Encoding type, QString charSet)
generates the shortcuts html file
static QString filename()
returns the shortcuts html filename
static void generateHTML(Q3TextStream::Encoding type, QString charSet)
generates the html file
Definition whatsNew.cpp:29
static QString filename()
returns the html filename
Definition whatsNew.cpp:24
QString IMAGE_PATH
Definition config.cpp:18
HELP_PAGE
Contents window widget.
Definition contents.h:25
@ WHATS_NEW
Definition contents.h:27
@ MANIPULATING
Definition contents.h:33
@ FRAMING
Definition contents.h:30
@ IMPORTING_AND_ORGANIZING
Definition contents.h:28
@ PRO_TOOLS
Definition contents.h:32
@ SAVING_AND_LOADING
Definition contents.h:34
@ BILLBOARD
Definition contents.h:26
@ ANNOTATING_ALBUMS
Definition contents.h:29
@ KEYBOARD_SHORTCUTS
Definition contents.h:35
@ ENHANCING
Definition contents.h:31