Index: trunk/src/main.cpp
===================================================================
--- trunk/src/main.cpp	(revision 79)
+++ trunk/src/main.cpp	(revision 80)
@@ -53,4 +53,8 @@
 	qsrand(QDateTime::currentDateTime().toTime_t() ^ QCursor::pos().x() ^ QCursor::pos().y());
 
+QTranslator en;
+	if (en.load("en", PATH_I18N))
+		app.installTranslator(&en);
+
 MainWindow mainwindow;
 	mainwindow.show();
Index: trunk/src/mainwindow.cpp
===================================================================
--- trunk/src/mainwindow.cpp	(revision 79)
+++ trunk/src/mainwindow.cpp	(revision 80)
@@ -34,29 +34,14 @@
 	: QMainWindow(parent)
 {
-	settings = new QSettings(QSettings::IniFormat,QSettings::UserScope,"TSPSG","tspsg");
+	settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "TSPSG", "tspsg", this);
 	loadLanguage();
-	setupUi(this);
-#ifndef Q_OS_WINCE
-QStatusBar *statusbar = new QStatusBar(this);
-	statusbar->setObjectName("statusbar");
-	setStatusBar(statusbar);
-#endif // Q_OS_WINCE
+	setupUi();
+
 	initDocStyleSheet();
-	solutionText->document()->setDefaultFont(settings->value("Output/Font",QFont(DEF_FONT_FAMILY,DEF_FONT_SIZE)).value<QFont>());
-	solutionText->setTextColor(settings->value("Output/Color",DEF_FONT_COLOR).value<QColor>());
-	solutionText->setWordWrapMode(QTextOption::WordWrap);
-#ifdef Q_OS_WINCE
-	// A little hack for toolbar icons to have a sane size.
-	toolBar->setIconSize(QSize(logicalDpiX() / 4, logicalDpiY() / 4));
-#endif
+
 #ifndef QT_NO_PRINTER
 	printer = new QPrinter(QPrinter::HighResolution);
 #endif // QT_NO_PRINTER
-	groupSettingsLanguageList = new QActionGroup(this);
-	actionSettingsLanguageEnglish->setData("en");
-	actionSettingsLanguageEnglish->setActionGroup(groupSettingsLanguageList);
-	loadLangList();
-	spinCities->setMaximum(MAX_NUM_CITIES);
-	actionSettingsLanguageAutodetect->setChecked(settings->value("Language","").toString().isEmpty());
+
 	connect(actionFileNew,SIGNAL(triggered()),this,SLOT(actionFileNewTriggered()));
 	connect(actionFileOpen,SIGNAL(triggered()),this,SLOT(actionFileOpenTriggered()));
@@ -64,4 +49,8 @@
 	connect(actionFileSaveAsTask,SIGNAL(triggered()),this,SLOT(actionFileSaveAsTaskTriggered()));
 	connect(actionFileSaveAsSolution,SIGNAL(triggered()),this,SLOT(actionFileSaveAsSolutionTriggered()));
+#ifndef QT_NO_PRINTER
+	connect(actionFilePrintPreview,SIGNAL(triggered()),this,SLOT(actionFilePrintPreviewTriggered()));
+	connect(actionFilePrint,SIGNAL(triggered()),this,SLOT(actionFilePrintTriggered()));
+#endif // QT_NO_PRINTER
 	connect(actionSettingsPreferences,SIGNAL(triggered()),this,SLOT(actionSettingsPreferencesTriggered()));
 	connect(actionSettingsLanguageAutodetect,SIGNAL(triggered(bool)),this,SLOT(actionSettingsLanguageAutodetectTriggered(bool)));
@@ -69,17 +58,9 @@
 	connect(actionHelpAboutQt,SIGNAL(triggered()),qApp,SLOT(aboutQt()));
 	connect(actionHelpAbout,SIGNAL(triggered()),this,SLOT(actionHelpAboutTriggered()));
-#ifndef QT_NO_PRINTER
-	menuFile->insertAction(actionFileExit,actionFilePrintPreview);
-	menuFile->insertAction(actionFileExit,actionFilePrint);
-	menuFile->insertSeparator(actionFileExit);
-	toolBar->insertAction(actionSettingsPreferences,actionFilePrint);
-	connect(actionFilePrintPreview,SIGNAL(triggered()),this,SLOT(actionFilePrintPreviewTriggered()));
-	connect(actionFilePrint,SIGNAL(triggered()),this,SLOT(actionFilePrintTriggered()));
-#endif // QT_NO_PRINTER
+
 	connect(buttonSolve,SIGNAL(clicked()),this,SLOT(buttonSolveClicked()));
 	connect(buttonRandom,SIGNAL(clicked()),this,SLOT(buttonRandomClicked()));
 	connect(buttonBackToTask,SIGNAL(clicked()),this,SLOT(buttonBackToTaskClicked()));
 	connect(spinCities,SIGNAL(valueChanged(int)),this,SLOT(spinCitiesValueChanged(int)));
-	setCentralWidget(tabWidget);
 
 	if (settings->value("SavePos", false).toBool()) {
@@ -100,5 +81,4 @@
 	}
 
-	qsrand(QDateTime().currentDateTime().toTime_t());
 	tspmodel = new CTSPModel(this);
 	taskView->setModel(tspmodel);
@@ -116,4 +96,11 @@
 }
 
+MainWindow::~MainWindow()
+{
+#ifndef QT_NO_PRINTER
+	delete printer;
+#endif
+}
+
 /* Privates **********************************************************/
 
@@ -142,5 +129,9 @@
 	filters.append(trUtf8("All Files") + " (*)");
 
+#ifdef Q_OS_WINCE
+	QString file = QFileDialog::getOpenFileName(this, trUtf8("Task Load"), QString(), filters.join(";;"), NULL, QFileDialog::DontUseNativeDialog);
+#else
 QString file = QFileDialog::getOpenFileName(this, trUtf8("Task Load"), QString(), filters.join(";;"));
+#endif // Q_OS_WINCE
 	if (file.isEmpty() || !QFileInfo(file).isFile())
 		return;
@@ -197,5 +188,9 @@
 	filters.append(trUtf8("All Files") + " (*)");
 
+#ifdef Q_OS_WINCE
+QString file = QFileDialog::getSaveFileName(this, QString(), selectedFile, filters.join(";;"), NULL, QFileDialog::DontUseNativeDialog);
+#else
 QString file = QFileDialog::getSaveFileName(this, QString(), selectedFile, filters.join(";;"));
+#endif
 	if (file.isEmpty())
 		return;
@@ -292,8 +287,10 @@
 bool untitled = (fileName == trUtf8("Untitled") + ".tspt");
 	if (loadLanguage(action->data().toString())) {
+		QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 		settings->setValue("Language",action->data().toString());
-		retranslateUi(this);
+		retranslateUi();
 		if (untitled)
 			setFileName();
+		QApplication::restoreOverrideCursor();
 	}
 }
@@ -348,4 +345,5 @@
 	lblIcon->setPixmap(QPixmap(":/images/tspsg.png").scaledToWidth(logicalDpiX() * 2 / 3, Qt::SmoothTransformation));
 	lblIcon->setAlignment(Qt::AlignTop);
+	lblTitle->setOpenExternalLinks(true);
 	lblTitle->setText(title);
 
@@ -452,5 +450,5 @@
 		output.append("<p>" + trUtf8("Resulting path:") + "</p>");
 	output.append("<p>&nbsp;&nbsp;" + solver.getSortedPath() + "</p>");
-	output.append("<p>" + trUtf8("The price is <b>%1</b> units.").arg(step->price) + "</p>");
+	output.append("<p>" + trUtf8("The price is <b>%n</b> unit(s).", "", step->price) + "</p>");
 	if (!solver.isOptimal()) {
 		output.append("<p>&nbsp;</p>");
@@ -502,4 +500,5 @@
 void MainWindow::spinCitiesValueChanged(int n)
 {
+	QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
 int count = tspmodel->numCities();
 	tspmodel->setNumCities(n);
@@ -509,4 +508,5 @@
 			taskView->resizeRowToContents(k);
 		}
+	QApplication::restoreOverrideCursor();
 }
 
@@ -596,23 +596,27 @@
 		qApp->removeTranslator(translator);
 		delete translator;
-	}
-	translator = new QTranslator();
-	if ((lng.compare("en") != 0) && !lng.startsWith("en_")) {
-		// Trying to load system Qt library translation...
-		qtTranslator = new QTranslator();
-		if (qtTranslator->load("qt_" + lng,QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
+		translator = NULL;
+	}
+
+	if (lng == "en")
+		return true;
+
+	// Trying to load system Qt library translation...
+	qtTranslator = new QTranslator(this);
+	if (qtTranslator->load("qt_" + lng,QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
+		qApp->installTranslator(qtTranslator);
+	else {
+		// No luck. Let's try to load a bundled one.
+		if (qtTranslator->load("qt_" + lng,PATH_I18N))
 			qApp->installTranslator(qtTranslator);
 		else {
-			// No luck. Let's try to load a bundled one.
-			if (qtTranslator->load("qt_" + lng,PATH_I18N))
-				qApp->installTranslator(qtTranslator);
-			else {
-				// Qt library translation unavailable
-				delete qtTranslator;
-				qtTranslator = NULL;
-			}
+			// Qt library translation unavailable
+			delete qtTranslator;
+			qtTranslator = NULL;
 		}
 	}
+
 	// Now let's load application translation.
+	translator = new QTranslator(this);
 	if (translator->load(lng,PATH_I18N))
 		qApp->installTranslator(translator);
@@ -620,9 +624,7 @@
 		delete translator;
 		translator = NULL;
-		if ((lng.compare("en") != 0) && !lng.startsWith("en_")) {
-			if (!ad)
-				QMessageBox(QMessageBox::Warning,trUtf8("Language Change"),trUtf8("Unable to load translation language."),QMessageBox::Ok,this).exec();
-			return false;
-		}
+		if (!ad)
+			QMessageBox(QMessageBox::Warning,trUtf8("Language Change"),trUtf8("Unable to load translation language."),QMessageBox::Ok,this).exec();
+		return false;
 	}
 	return true;
@@ -689,4 +691,29 @@
 }
 
+void MainWindow::retranslateUi(bool all)
+{
+	if (all)
+		Ui::MainWindow::retranslateUi(this);
+
+#ifndef QT_NO_PRINTER
+	actionFilePrintPreview->setText(QApplication::translate("MainWindow", "P&rint Preview...", 0, QApplication::UnicodeUTF8));
+#ifndef QT_NO_TOOLTIP
+	actionFilePrintPreview->setToolTip(QApplication::translate("MainWindow", "Preview solution results", 0, QApplication::UnicodeUTF8));
+#endif // QT_NO_TOOLTIP
+#ifndef QT_NO_STATUSTIP
+	actionFilePrintPreview->setStatusTip(QApplication::translate("MainWindow", "Preview current solution results before printing", 0, QApplication::UnicodeUTF8));
+#endif // QT_NO_STATUSTIP
+
+	actionFilePrint->setText(QApplication::translate("MainWindow", "&Print...", 0, QApplication::UnicodeUTF8));
+#ifndef QT_NO_TOOLTIP
+	actionFilePrint->setToolTip(QApplication::translate("MainWindow", "Print solution", 0, QApplication::UnicodeUTF8));
+#endif // QT_NO_TOOLTIP
+#ifndef QT_NO_STATUSTIP
+	actionFilePrint->setStatusTip(QApplication::translate("MainWindow", "Print current solution results", 0, QApplication::UnicodeUTF8));
+#endif // QT_NO_STATUSTIP
+	actionFilePrint->setShortcut(QApplication::translate("MainWindow", "Ctrl+P", 0, QApplication::UnicodeUTF8));
+#endif // QT_NO_PRINTER
+}
+
 bool MainWindow::saveTask() {
 QStringList filters(trUtf8("%1 Task File").arg("TSPSG") + " (*.tspt)");
@@ -698,5 +725,10 @@
 		file = QFileInfo(fileName).canonicalPath() + "/" + QFileInfo(fileName).completeBaseName() + ".tspt";
 
+#ifdef Q_OS_WINCE
+	file = QFileDialog::getSaveFileName(this, trUtf8("Task Save"), file, filters.join(";;"), NULL, QFileDialog::DontUseNativeDialog);
+#else
 	file = QFileDialog::getSaveFileName(this, trUtf8("Task Save"), file, filters.join(";;"));
+#endif // Q_OS_WINCE
+
 	if (file.isEmpty())
 		return false;
@@ -715,4 +747,58 @@
 }
 
+void MainWindow::setupUi()
+{
+	Ui::MainWindow::setupUi(this);
+
+#if QT_VERSION >= 0x040600
+	setToolButtonStyle(Qt::ToolButtonFollowStyle);
+#endif
+
+#ifndef Q_OS_WINCE
+QStatusBar *statusbar = new QStatusBar(this);
+	statusbar->setObjectName("statusbar");
+	setStatusBar(statusbar);
+#endif // Q_OS_WINCE
+
+#ifdef Q_OS_WINCE
+	//! \hack HACK: A little hack for toolbar icons to have a sane size.
+	toolBar->setIconSize(QSize(logicalDpiX() / 4, logicalDpiY() / 4));
+#endif
+
+	solutionText->document()->setDefaultFont(settings->value("Output/Font",QFont(DEF_FONT_FAMILY,DEF_FONT_SIZE)).value<QFont>());
+	solutionText->setTextColor(settings->value("Output/Color",DEF_FONT_COLOR).value<QColor>());
+	solutionText->setWordWrapMode(QTextOption::WordWrap);
+
+#ifndef QT_NO_PRINTER
+	actionFilePrintPreview = new QAction(this);
+	actionFilePrintPreview->setObjectName("actionFilePrintPreview");
+	actionFilePrintPreview->setEnabled(false);
+	actionFilePrintPreview->setIcon(QIcon(":/images/icons/document_preview.png"));
+
+	actionFilePrint = new QAction(this);
+	actionFilePrint->setObjectName("actionFilePrint");
+	actionFilePrint->setEnabled(false);
+	actionFilePrint->setIcon(QIcon(":/images/icons/fileprint.png"));
+
+	menuFile->insertAction(actionFileExit,actionFilePrintPreview);
+	menuFile->insertAction(actionFileExit,actionFilePrint);
+	menuFile->insertSeparator(actionFileExit);
+
+	toolBar->insertAction(actionSettingsPreferences,actionFilePrint);
+#endif // QT_NO_PRINTER
+
+	groupSettingsLanguageList = new QActionGroup(this);
+	actionSettingsLanguageEnglish->setData("en");
+	actionSettingsLanguageEnglish->setActionGroup(groupSettingsLanguageList);
+	loadLangList();
+	actionSettingsLanguageAutodetect->setChecked(settings->value("Language","").toString().isEmpty());
+
+	spinCities->setMaximum(MAX_NUM_CITIES);
+
+	retranslateUi(false);
+
+	setCentralWidget(tabWidget);
+}
+
 void MainWindow::toggleSolutionActions(bool enable)
 {
Index: trunk/src/mainwindow.h
===================================================================
--- trunk/src/mainwindow.h	(revision 79)
+++ trunk/src/mainwindow.h	(revision 80)
@@ -47,4 +47,5 @@
 public:
 	MainWindow(QWidget *parent = 0);
+	~MainWindow();
 
 private slots:
@@ -82,4 +83,6 @@
 #ifndef QT_NO_PRINTER
 	QPrinter *printer;
+	QAction *actionFilePrintPreview;
+	QAction *actionFilePrint;
 #endif // QT_NO_PRINTER
 	QSettings *settings;
@@ -93,6 +96,8 @@
 	void outputMatrix(const TMatrix &matrix, QStringList &output);
 	void outputMatrix(const SStep &step, QStringList &output);
+	void retranslateUi(bool all = true);
 	bool saveTask();
 	void setFileName(const QString &fileName = trUtf8("Untitled") + ".tspt");
+	void setupUi();
 	void toggleSolutionActions(bool enable = true);
 };
Index: trunk/src/settingsdialog.cpp
===================================================================
--- trunk/src/settingsdialog.cpp	(revision 79)
+++ trunk/src/settingsdialog.cpp	(revision 80)
@@ -181,5 +181,7 @@
 	labelHint->setText(labelHint->statusTip());
 #endif // Q_OS_WINCE
-	settings = new QSettings(QSettings::IniFormat,QSettings::UserScope,"TSPSG","tspsg");
+
+	settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "TSPSG", "tspsg", this);
+
 	spinRandMin->setMaximum(MAX_RAND_VALUE);
 	spinRandMin->setValue(settings->value("MinCost",DEF_RAND_MIN).toInt());
Index: trunk/src/tspmodel.cpp
===================================================================
--- trunk/src/tspmodel.cpp	(revision 79)
+++ trunk/src/tspmodel.cpp	(revision 80)
@@ -31,5 +31,5 @@
 	: QAbstractTableModel(parent), nCities(0)
 {
-	settings = new QSettings(QSettings::IniFormat,QSettings::UserScope,"TSPSG","tspsg");
+	settings = new QSettings(QSettings::IniFormat, QSettings::UserScope, "TSPSG", "tspsg", this);
 }
 
@@ -468,4 +468,4 @@
 inline int CTSPModel::rand(int min, int max) const
 {
-	return min + (int)(((float)qrand() / RAND_MAX) * (max - min));
-}
+	return min + (int)floor(((double)qrand() / RAND_MAX) * (max + 1 - min));
+}
