Clifford Wolf:

Fixed passing of new file as command line argument
	Some coding style fixes



git-svn-id: http://svn.clifford.at/openscad/trunk@180 b57f626f-c46c-0410-a088-ec61d464b74c
stl_dim
clifford 2009-12-16 09:44:24 +00:00
parent 880c8fcfc0
commit 2ae59b8d65
1 changed files with 16 additions and 9 deletions

View File

@ -294,12 +294,16 @@ MainWindow::~MainWindow()
/*! /*!
Requests to open a file from an external event, e.g. by double-clicking a filename. Requests to open a file from an external event, e.g. by double-clicking a filename.
*/ */
#ifdef ENABLE_MDI
void MainWindow::requestOpenFile(const QString &filename) void MainWindow::requestOpenFile(const QString &filename)
{ {
#ifdef ENABLE_MDI
new MainWindow(filename.toUtf8()); new MainWindow(filename.toUtf8());
#endif
} }
#else
void MainWindow::requestOpenFile(const QString &)
{
}
#endif
void void
MainWindow::openFile(const QString &new_filename) MainWindow::openFile(const QString &new_filename)
@ -325,19 +329,22 @@ MainWindow::setFileName(const QString &filename)
} }
else { else {
QFileInfo fileinfo(filename); QFileInfo fileinfo(filename);
this->fileName = fileinfo.canonicalFilePath(); QString infoFileName = fileinfo.canonicalFilePath();
setWindowTitle("OpenSCAD - " + fileinfo.fileName() + "[*]"); setWindowTitle("OpenSCAD - " + fileinfo.fileName() + "[*]");
// Check that the canonical file path exists - only update recent files // Check that the canonical file path exists - only update recent files
// if it does. Should prevent empty list items on initial open etc. // if it does. Should prevent empty list items on initial open etc.
if (!this->fileName.isEmpty()) { if (!infoFileName.isEmpty()) {
QSettings settings; // already set up properly via main.cpp QSettings settings; // already set up properly via main.cpp
QStringList files = settings.value("recentFileList").toStringList(); QStringList files = settings.value("recentFileList").toStringList();
files.removeAll(this->fileName); files.removeAll(this->fileName);
files.prepend(this->fileName); files.prepend(this->fileName);
while (files.size() > maxRecentFiles) files.removeLast(); while (files.size() > maxRecentFiles)
files.removeLast();
settings.setValue("recentFileList", files); settings.setValue("recentFileList", files);
this->fileName = infoFileName;
} else {
this->fileName = fileinfo.fileName();
} }
QDir::setCurrent(fileinfo.dir().absolutePath()); QDir::setCurrent(fileinfo.dir().absolutePath());