# HG changeset patch # User Santeri Piippo # Date 1375362331 -10800 # Node ID be1824f53c48080e5724456039a167d235ae06f2 # Parent 6598e3f9c6734fd5ab403af1dd422b6558bbfb60 Added an action for creating a new, blank file, improved multi-file stability diff -r 6598e3f9c673 -r be1824f53c48 src/actions.h --- a/src/actions.h Thu Aug 01 15:35:11 2013 +0300 +++ b/src/actions.h Thu Aug 01 16:05:31 2013 +0300 @@ -1,4 +1,5 @@ act (New) +act (NewFile) act (Open) act (Save) act (SaveAs) diff -r 6598e3f9c673 -r be1824f53c48 src/file.cpp --- a/src/file.cpp Thu Aug 01 15:35:11 2013 +0300 +++ b/src/file.cpp Thu Aug 01 16:05:31 2013 +0300 @@ -940,6 +940,13 @@ return !implicit() && history().pos() != savePos(); } +str LDFile::getShortName() { + if( name().length() > 0 ) + return basename( name() ); + + return tr( "" ); +} + // ============================================================================= LDFile* LDFile::current() { return m_curfile; @@ -948,8 +955,15 @@ void LDFile::setCurrent (LDFile* f) { m_curfile = f; - if (g_win && f) - g_win->updateFileListItem (f); + if( g_win && f ) { + g_win->clearSelection(); + g_win->updateFileListItem( f ); + g_win->buildObjList(); + g_win->R()->setFile( f ); + g_win->R()->update(); + + log( "Changed file to %1", f->getShortName()); + } } // ============================================================================= diff -r 6598e3f9c673 -r be1824f53c48 src/file.h --- a/src/file.h Thu Aug 01 15:35:11 2013 +0300 +++ b/src/file.h Thu Aug 01 16:05:31 2013 +0300 @@ -128,6 +128,7 @@ static LDFile* current(); static void setCurrent (LDFile* f); static void closeInitialFile(); + str getShortName(); private: static LDFile* m_curfile; diff -r 6598e3f9c673 -r be1824f53c48 src/gui.cpp --- a/src/gui.cpp Thu Aug 01 15:35:11 2013 +0300 +++ b/src/gui.cpp Thu Aug 01 16:05:31 2013 +0300 @@ -849,19 +849,13 @@ return; } - str name; - if (f->name() == "") - name = ""; - else - name = basename (f->name()); - if (f == LDFile::current()) ui->fileList->setCurrentItem (f->listItem()); if (f->implicit()) f->listItem()->setForeground (QColor (96, 96, 96)); - f->listItem()->setText (name); + f->listItem()->setText (f->getShortName()); f->listItem()->setIcon (f->hasUnsavedChanges() ? getIcon ("file-save") : QIcon()); } @@ -891,14 +885,7 @@ if (!f || f == LDFile::current()) return; - clearSelection(); LDFile::setCurrent (f); - - log ("Changed file to %1", basename (f->name())); - - R()->setFile (f); - R()->update(); - buildObjList(); } void ForgeWindow::refreshObjectList() { diff -r 6598e3f9c673 -r be1824f53c48 src/gui_actions.cpp --- a/src/gui_actions.cpp Thu Aug 01 15:35:11 2013 +0300 +++ b/src/gui_actions.cpp Thu Aug 01 16:05:31 2013 +0300 @@ -43,7 +43,7 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -DEFINE_ACTION (New, CTRL (N)) { +DEFINE_ACTION (New, CTRL_SHIFT (N)) { QDialog* dlg = new QDialog (g_win); Ui::NewPartUI ui; ui.setupUi (dlg); @@ -80,6 +80,13 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= +DEFINE_ACTION( NewFile, CTRL( N )) { + newFile(); +} + +// ============================================================================= +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * +// ============================================================================= DEFINE_ACTION (Open, CTRL (O)) { str name = QFileDialog::getOpenFileName (g_win, "Open File", "", "LDraw files (*.dat *.ldr)"); diff -r 6598e3f9c673 -r be1824f53c48 src/ui/ldforge.ui --- a/src/ui/ldforge.ui Thu Aug 01 15:35:11 2013 +0300 +++ b/src/ui/ldforge.ui Thu Aug 01 16:05:31 2013 +0300 @@ -70,7 +70,7 @@ 0 0 900 - 23 + 26 @@ -87,6 +87,7 @@ + @@ -269,6 +270,7 @@ false + @@ -405,7 +407,7 @@ :/icons/brick.png:/icons/brick.png - New + New Part Create a new part model. @@ -1246,6 +1248,15 @@ Close All + + + + :/icons/file-new.png:/icons/file-new.png + + + New File + +