summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/firstuse.cpp24
-rw-r--r--core/launcher/firstuse.h1
-rw-r--r--core/launcher/main.cpp3
3 files changed, 16 insertions, 12 deletions
diff --git a/core/launcher/firstuse.cpp b/core/launcher/firstuse.cpp
index 2dc6a72..3f769ae 100644
--- a/core/launcher/firstuse.cpp
+++ b/core/launcher/firstuse.cpp
@@ -9,51 +9,50 @@
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
// I need access to some things you don't normally get access to.
#ifndef _MSC_VER
//### revise to allow removal of translators under MSVC
#define private public
#define protected public
#endif
#include "firstuse.h"
#include "inputmethods.h"
#include "applauncher.h"
#include "serverapp.h"
#include <qtopia/custom.h>
-#if defined(QPE_NEED_CALIBRATION)
+
#include "calibrate.h"
-#endif
#include "documentlist.h"
#include <qtopia/resource.h>
#include <qtopia/qcopenvelope_qws.h>
#include <qtopia/qpeapplication.h>
#include <qtopia/config.h>
#include <qtopia/applnk.h>
#include <qtopia/mimetype.h>
#include <qtopia/fontmanager.h>
#include <qapplication.h>
#include <qfile.h>
#include <qpainter.h>
#include <qcstring.h>
#include <qsimplerichtext.h>
#include <qcolor.h>
#include <qpushbutton.h>
#include <qhbox.h>
#include <qlabel.h>
#include <qtimer.h>
#if defined( Q_WS_QWS )
#include <qwsdisplay_qws.h>
#include <qgfx_qws.h>
@@ -147,54 +146,58 @@ FirstUse::FirstUse(QWidget* parent, const char * name, WFlags wf) :
// need to set the geom to lower corner
QSize sz = inputMethods->sizeHint();
int buttonWidth = (width() - sz.width()) / 2;
int x = 0;
controlHeight = back->sizeHint().height();
inputMethods->setGeometry(0,0, sz.width(), controlHeight );
x += sz.width();
back->setGeometry(x, 0, buttonWidth, controlHeight);
x += buttonWidth;
next->setGeometry(x, 0, buttonWidth, controlHeight);
taskBar->setGeometry( 0, height() - controlHeight, desk.width(), controlHeight);
taskBar->hide();
#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
qDebug("Setting up QCop to QPE/System");
QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
connect(sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
this, SLOT(message(const QCString &, const QByteArray &)) );
#endif
calcMaxWindowRect();
-#if defined(QPE_NEED_CALIBRATION)
- if ( !QFile::exists("/etc/pointercal") ) {
- needCalibrate = TRUE;
- grabMouse();
+
+ m_calHandler = ( QWSServer::mouseHandler() && QWSServer::mouseHandler()->inherits("QCalibratedMouseHandler") ) ? true : false;
+
+ if ( m_calHandler) {
+ if ( !QFile::exists("/etc/pointercal") ) {
+ needCalibrate = TRUE;
+ grabMouse();
+ }
}
-#endif
+
Config config("locale");
config.setGroup( "Language");
lang = config.readEntry( "Language", "en");
defaultFont = font();
//###language/font hack; should look it up somewhere
#ifdef Q_WS_QWS
if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
QFont fn = FontManager::unicodeFont( FontManager::Proportional );
qApp->setFont( fn, TRUE );
}
#endif
}
FirstUse::~FirstUse()
{
delete appLauncher;
delete docList;
delete taskBar;
ServerApplication::allowRestart = TRUE;
}
void FirstUse::calcMaxWindowRect()
@@ -209,49 +212,49 @@ void FirstUse::calcMaxWindowRect()
wr.setCoords( 0, 0, displayWidth-1,
qApp->desktop()->height() - controlHeight-1);
}
#if QT_VERSION < 0x030000
QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,
QSize(qt_screen->width(),qt_screen->height()))
);
#else
QWSServer::setMaxWindowRect( wr );
#endif
#endif
}
/* cancel current dialog, and bring up next */
void FirstUse::nextDialog()
{
int prevApp = currApp;
do {
currApp++;
qDebug( "currApp = %d", currApp );
if ( settingsTable[currApp].app == 0 ) {
if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) {
// The last application is still running.
- // Tell it to stop, and when its done we'll come back
+ // Tell it to stop, and when its done we'll come back
// to nextDialog and exit.
qDebug( "Waiting for %s to exit", settingsTable[prevApp].app );
QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app,
settingsTable[prevApp].stop );
currApp = prevApp;
} else {
qDebug( "Done!" );
Config config( "qpe" );
config.setGroup( "Startup" );
config.writeEntry( "FirstUse", FALSE );
QPixmap pix = Resource::loadPixmap("bigwait");
QLabel *lblWait = new QLabel(0, "wait hack!", // No tr
QWidget::WStyle_Customize | QWidget::WDestructiveClose |
QWidget::WStyle_NoBorder | QWidget::WStyle_Tool |
QWidget::WStyle_StaysOnTop);
lblWait->setPixmap( pix );
lblWait->setAlignment( QWidget::AlignCenter );
lblWait->setGeometry( qApp->desktop()->geometry() );
lblWait->show();
qApp->processEvents();
QTimer::singleShot( 1000, lblWait, SLOT(close()) );
repaint();
close();
ServerApplication::allowRestart = TRUE;
@@ -470,48 +473,47 @@ void FirstUse::drawText(QPainter &p, const QString &text)
if (rt.height() < height() / 2)
h += ((height() / 2) - rt.height()) / 2;
rt.draw(&p, 10, h, QRegion(0,0, width()-20, height()), palette());
}
void FirstUse::updateButtons()
{
if ( currApp >= 0 ) {
taskBar->show();
}
int i = currApp-1;
while ( i >= 0 && !settingsTable[i].enabled )
i--;
back->setText(tr("<< Back"));
back->setEnabled( i >= 0 && !waitingForLaunch );
i = currApp+1;
while ( settingsTable[i].app && !settingsTable[i].enabled )
i++;
if ( !settingsTable[i].app )
next->setText(tr("Finish"));
else
next->setText(tr("Next >>"));
+
next->setEnabled( !waitingForLaunch );
}
void FirstUse::keyPressEvent( QKeyEvent *e )
{
// Allow cancelling at first dialog, in case display is broken.
if ( e->key() == Key_Escape && currApp < 0 )
QDialog::keyPressEvent(e);
}
void FirstUse::mouseReleaseEvent( QMouseEvent * )
{
if ( currApp < 0 ) {
-#if defined(QPE_NEED_CALIBRATION)
- if ( needCalibrate ) {
+ if ( m_calHandler && needCalibrate ) {
releaseMouse();
Calibrate *cal = new Calibrate;
cal->exec();
delete cal;
}
-#endif
nextDialog();
}
}
diff --git a/core/launcher/firstuse.h b/core/launcher/firstuse.h
index 44a95a8..98858f8 100644
--- a/core/launcher/firstuse.h
+++ b/core/launcher/firstuse.h
@@ -58,27 +58,28 @@ private:
void updateButtons();
private:
QPixmap splash;
QPixmap buttons;
InputMethods *inputMethods;
QPushButton *back;
QPushButton *next;
int controlHeight;
QString lang;
QTranslator *transApp;
QTranslator *transLib;
bool needCalibrate;
DocumentList *docList;
AppLauncher *appLauncher;
QWidget *taskBar;
int currApp;
int waitForExit;
bool waitingForLaunch;
bool needRestart;
+ bool m_calHandler : 1;
QFont defaultFont;
};
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index 075985d..ad40536 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -177,49 +177,50 @@ void initEnvironment()
setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1);
QPEApplication::defaultRotation ( ); /* to ensure deforient matches reality */
}
}
static void initKeyboard()
{
Config config("qpe");
config.setGroup( "Keyboard" );
int ard = config.readNumEntry( "RepeatDelay" );
int arp = config.readNumEntry( "RepeatPeriod" );
if ( ard > 0 && arp > 0 )
qwsSetKeyboardAutoRepeat( ard, arp );
QString layout = config.readEntry( "Layout", "us101" );
Server::setKeyboardLayout( layout );
}
static bool firstUse()
{
bool needFirstUse = FALSE;
- if ( QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) {
+ if ( QWSServer::mouseHandler() &&
+ QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) {
if ( !QFile::exists( "/etc/pointercal" ) )
needFirstUse = TRUE;
}
{
Config config( "qpe" );
config.setGroup( "Startup" );
needFirstUse |= config.readBoolEntry( "FirstUse", TRUE );
}
if ( !needFirstUse )
return FALSE;
FirstUse *fu = new FirstUse();
fu->exec();
bool rs = fu->restartNeeded();
delete fu;
return rs;
}
int initApplication( int argc, char ** argv )
{
cleanup();