Index: src/settingsdialog.cpp
===================================================================
--- src/settingsdialog.cpp	(revision e0fcac5f2c6ab0bd37fa7a8c63ea43347c13fb7c)
+++ src/settingsdialog.cpp	(revision 1fbf016a095b6f072d0f2640e55791f938a8d843)
@@ -35,9 +35,23 @@
 	setupUi(this);
 	// Laying out elements
+	layoutCitiesLimit = new QHBoxLayout();
+	layoutCitiesLimit->setMargin(0);
+	layoutCitiesLimit->setSpacing(0);
+	layoutCitiesLimit->addSpacing(10);
+	layoutCitiesLimit->addWidget(cbCitiesLimit);
+	layoutCitiesLimit->addWidget(spinCitiesLimit);
+	layoutCitiesLimit->addStretch();
+
+	buttonBox->button(QDialogButtonBox::Save)->setIcon(QIcon(":/images/icons/button_ok.png"));
+	buttonBox->button(QDialogButtonBox::Save)->setStatusTip(trUtf8("Save new preferences"));
+	buttonBox->button(QDialogButtonBox::Save)->setCursor(QCursor(Qt::PointingHandCursor));
+	buttonBox->button(QDialogButtonBox::Cancel)->setIcon(QIcon(":/images/icons/button_cancel.png"));
+	buttonBox->button(QDialogButtonBox::Cancel)->setStatusTip(trUtf8("Close without saving preferences"));
+	buttonBox->button(QDialogButtonBox::Cancel)->setCursor(QCursor(Qt::PointingHandCursor));
+
 #ifdef Q_OS_WINCE
 	// Layout helper elements
 QVBoxLayout *vbox1, *vbox2;
 QHBoxLayout *hbox1, *hbox2;
-QSpacerItem *spacer;
 
 	labelRandMin->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);
@@ -48,6 +62,7 @@
 	vbox2->addWidget(groupRandomSettings);
 	vbox2->addWidget(groupOutputSettings);
-	spacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding);
-	vbox2->addItem(spacer);
+	vbox2->addStretch();
+	vbox2->addWidget(cbShowMatrix);
+	vbox2->addLayout(layoutCitiesLimit);
 	vbox2->addWidget(cbAutosize);
 
@@ -62,8 +77,6 @@
 	hbox2->setSpacing(6);
 	hbox2->addWidget(buttonHelp);
-	spacer = new QSpacerItem(0,0,QSizePolicy::Expanding);
-	hbox2->addItem(spacer);
-	hbox2->addWidget(buttonOK);
-	hbox2->addWidget(buttonCancel);
+	hbox2->addStretch();
+	hbox2->addWidget(buttonBox);
 
 	// Central layout
@@ -78,5 +91,4 @@
 QVBoxLayout *vbox1, *vbox2, *vbox3;
 QHBoxLayout *hbox1, *hbox2, *hbox3;
-QSpacerItem *spacer;
 
 	cbSaveState = new QCheckBox(bgWhite);
@@ -93,7 +105,8 @@
 	imgIcon->setFrameShape(QFrame::Panel);
 	imgIcon->setLineWidth(0);
-	imgIcon->setPixmap(QPixmap(QString::fromUtf8(":/images/icons/preferences_system.png")));
+	imgIcon->setPixmap(QPixmap(":/images/icons/preferences_system.png"));
 	imgIcon->setStyleSheet("background-color: #0080C0;");
 	imgIcon->setAlignment(Qt::AlignCenter);
+	imgIcon->setMinimumWidth(150);
 
 	labelHint = new QLabel(bgGrey);
@@ -131,16 +144,15 @@
 	hbox2->addWidget(groupRandomSettings);
 	hbox2->addWidget(groupOutputSettings);
-	spacer = new QSpacerItem(0,0,QSizePolicy::Expanding);
-	hbox2->addItem(spacer);
+	hbox2->addStretch();
 
 	// Top right part (with white bg)
 	vbox2 = new QVBoxLayout(bgWhite);
-	spacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding);
-	vbox2->addItem(spacer);
+	vbox2->addStretch();
 	vbox2->addLayout(hbox2);
+	vbox2->addWidget(cbShowMatrix);
+	vbox2->addLayout(layoutCitiesLimit);
 	vbox2->addWidget(cbAutosize);
 	vbox2->addWidget(cbSaveState);
-	spacer = new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding);
-	vbox2->addItem(spacer);
+	vbox2->addStretch();
 
 	// Bottom part (with grey bg)
@@ -150,6 +162,5 @@
 	hbox3->addWidget(buttonHelp);
 	hbox3->addWidget(labelHint);
-	hbox3->addWidget(buttonOK);
-	hbox3->addWidget(buttonCancel);
+	hbox3->addWidget(buttonBox);
 
 	// Central layout
@@ -161,6 +172,4 @@
 	vbox1->addWidget(bgGrey);
 #endif // Q_OS_WINCE
-	connect(buttonOK,SIGNAL(clicked()),this,SLOT(accept()));
-	connect(buttonCancel,SIGNAL(clicked()),this,SLOT(reject()));
 	connect(spinRandMin,SIGNAL(valueChanged(int)),this,SLOT(spinRandMinValueChanged(int)));
 	connect(buttonFont,SIGNAL(clicked()),this,SLOT(buttonFontClicked()));
@@ -169,6 +178,5 @@
 	setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
 #ifndef Q_OS_WINCE
-	// Setting initial text of dialog hint label to own status tip
-	// text.
+	// Setting initial text of dialog hint label to own status tip text.
 	labelHint->setText(labelHint->statusTip());
 #endif // Q_OS_WINCE
@@ -182,8 +190,18 @@
 	cbSaveState->setChecked(settings->value("SavePos",false).toBool());
 #endif // Q_OS_WINCE
+
 	settings->beginGroup("Output");
+	cbShowMatrix->setChecked(settings->value("ShowMatrix", DEF_SHOW_MATRIX).toBool());
+	cbCitiesLimit->setEnabled(cbShowMatrix->isChecked());
+	cbCitiesLimit->setChecked(settings->value("UseShowMatrixLimit", DEF_USE_SHOW_MATRIX_LIMIT && cbShowMatrix->isChecked()).toBool());
+	spinCitiesLimit->setEnabled(cbShowMatrix->isChecked());
+	spinCitiesLimit->setValue(settings->value("ShowMatrixCitiesLimit", DEF_SHOW_MATRIX_CITY_LIMIT).toInt());
+	spinCitiesLimit->setMaximum(MAX_NUM_CITIES);
+
 	font = settings->value("Font",QFont(DEF_FONT_FAMILY,DEF_FONT_SIZE)).value<QFont>();
 	color = settings->value("Color",DEF_FONT_COLOR).value<QColor>();
 	settings->endGroup();
+
+	adjustSize();
 }
 
@@ -211,14 +229,19 @@
 {
 #ifndef Q_OS_WINCE
-	settings->setValue("SavePos",cbSaveState->isChecked());
-#endif // Q_OS_WINCE
-	settings->setValue("Autosize",cbAutosize->isChecked());
-	settings->setValue("MinCost",spinRandMin->value());
-	settings->setValue("MaxCost",spinRandMax->value());
+	settings->setValue("SavePos", cbSaveState->isChecked());
+#endif // Q_OS_WINCE
+	settings->setValue("Autosize", cbAutosize->isChecked());
+	settings->setValue("MinCost", spinRandMin->value());
+	settings->setValue("MaxCost", spinRandMax->value());
+
 	settings->beginGroup("Output");
+	settings->setValue("ShowMatrix", cbShowMatrix->isChecked());
+	settings->setValue("UseShowMatrixLimit", cbShowMatrix->isChecked() && cbCitiesLimit->isChecked());
+	if (cbCitiesLimit->isChecked())
+		settings->setValue("ShowMatrixCitiesLimit", spinCitiesLimit->value());
 	if (newFont)
-		settings->setValue("Font",font);
+		settings->setValue("Font", font);
 	if (newColor)
-		settings->setValue("Color",color);
+		settings->setValue("Color", color);
 	settings->endGroup();
 	QDialog::accept();
@@ -261,10 +284,4 @@
 			labelHint->setText(labelHint->statusTip());
 		return true;
-	// Making imgIcon square.
-	} else if (ev->type() == QEvent::Show) {
-bool result = QDialog::event(ev);
-		if (result)
-			imgIcon->setMinimumWidth(imgIcon->height());
-		return result;
 	} else
 		return QDialog::event(ev);
