Thu, 01 Aug 2013 16:05:31 +0300
Added an action for creating a new, blank file, improved multi-file stability
src/actions.h | file | annotate | diff | comparison | revisions | |
src/file.cpp | file | annotate | diff | comparison | revisions | |
src/file.h | file | annotate | diff | comparison | revisions | |
src/gui.cpp | file | annotate | diff | comparison | revisions | |
src/gui_actions.cpp | file | annotate | diff | comparison | revisions | |
src/ui/ldforge.ui | file | annotate | diff | comparison | revisions |
--- 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)
--- 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( "<anonymous>" ); +} + // ============================================================================= 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()); + } } // =============================================================================
--- 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;
--- 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 = "<anonymous>"; - 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() {
--- 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)");
--- 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 @@ <x>0</x> <y>0</y> <width>900</width> - <height>23</height> + <height>26</height> </rect> </property> <widget class="QMenu" name="menuFile"> @@ -87,6 +87,7 @@ </property> </widget> <addaction name="actionNew"/> + <addaction name="actionNewFile"/> <addaction name="actionOpen"/> <addaction name="menuOpenRecent"/> <addaction name="actionSave"/> @@ -269,6 +270,7 @@ <bool>false</bool> </attribute> <addaction name="actionNew"/> + <addaction name="actionNewFile"/> <addaction name="actionOpen"/> <addaction name="actionSave"/> <addaction name="actionSaveAs"/> @@ -405,7 +407,7 @@ <normaloff>:/icons/brick.png</normaloff>:/icons/brick.png</iconset> </property> <property name="text"> - <string>New</string> + <string>New Part</string> </property> <property name="statusTip"> <string>Create a new part model.</string> @@ -1246,6 +1248,15 @@ <string>Close All</string> </property> </action> + <action name="actionNewFile"> + <property name="icon"> + <iconset resource="../../ldforge.qrc"> + <normaloff>:/icons/file-new.png</normaloff>:/icons/file-new.png</iconset> + </property> + <property name="text"> + <string>New File</string> + </property> + </action> </widget> <resources> <include location="../../ldforge.qrc"/>