# HG changeset patch
# User insilmaril
# Date 1182340726 0
# Node ID 27cb122a88a62f2bbcd4015b9d798e270856b322
# Parent  0ccc00c05a22b46139f66fe5491a648c065c56be
Added center function

diff -r 0ccc00c05a22 -r 27cb122a88a6 file.cpp
--- a/file.cpp	Wed Jun 20 11:05:39 2007 +0000
+++ b/file.cpp	Wed Jun 20 11:58:46 2007 +0000
@@ -63,6 +63,55 @@
 	return d;
 }
 
+#include <QFileDialog>
+extern QString vymName;
+extern QDir lastFileDir;
+
+QString browseDirectory (QWidget *parent,const QString &caption)
+{
+	QFileDialog fd(parent,caption);
+	fd.setMode (QFileDialog::DirectoryOnly);
+	fd.setCaption(vymName+ " - "+caption);
+	fd.setDir (lastFileDir);
+	fd.show();
+	
+	if ( fd.exec() == QDialog::Accepted )
+		return fd.selectedFile();
+	else
+		return "";
+}
+
+
+
+bool reallyWriteDirectory(const QString &dir)
+{
+	QStringList eList = QDir(dir).entryList();
+	if (eList.first() ==".")  eList.pop_front();	// remove "."
+	if (eList.first() =="..") eList.pop_front();	// remove "."
+	if (!eList.isEmpty())
+	{
+		QMessageBox mb( vymName,
+			QObject::tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
+		QMessageBox::Warning,
+		QMessageBox::Yes ,
+		QMessageBox::Cancel | QMessageBox::Default,
+		QMessageBox::QMessageBox::NoButton );
+
+		mb.setButtonText( QMessageBox::Yes, QObject::tr("Overwrite") );
+		mb.setButtonText( QMessageBox::No, QObject::tr("Cancel"));
+		switch( mb.exec() ) 
+		{
+			case QMessageBox::Yes:
+				// save 
+				return true;
+			case QMessageBox::Cancel:
+				// do nothing
+				return false;
+		}
+	}
+	return true;
+}
+
 QString makeUniqueDir (bool &ok,QString s)
 {
 	// Create unique directory e.g. s="/tmp/vym-XXXXXX"