When creating a new project, save it right away.
This commit is contained in:
parent
479625968d
commit
bc3a6b83e5
5 changed files with 89 additions and 5 deletions
|
@ -210,6 +210,9 @@ namespace GUIEditor
|
||||||
|
|
||||||
std::string proj = d.getProjectName().toUtf8().constData();
|
std::string proj = d.getProjectName().toUtf8().constData();
|
||||||
std::string wnd = d.getWindowName().toUtf8().constData();
|
std::string wnd = d.getWindowName().toUtf8().constData();
|
||||||
|
std::string mg = std::string( "ui:" ) + proj;
|
||||||
|
std::string dir = d.getProjectDirectory().toUtf8().constData();
|
||||||
|
std::string uiFile = "ui_" + proj + ".xml";
|
||||||
|
|
||||||
bool b = GUICtrl->createNewGUI( proj, wnd );
|
bool b = GUICtrl->createNewGUI( proj, wnd );
|
||||||
if( !b )
|
if( !b )
|
||||||
|
@ -220,8 +223,41 @@ namespace GUIEditor
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string mg = std::string( "ui:" ) + proj;
|
|
||||||
hierarchyView->buildHierarchy( mg );
|
hierarchyView->buildHierarchy( mg );
|
||||||
|
|
||||||
|
projectFiles.projectName = proj;
|
||||||
|
projectFiles.masterGroup = mg;
|
||||||
|
projectFiles.activeGroup = std::string( "ui:" ) + proj + ":" + wnd;
|
||||||
|
projectFiles.version = NEW;
|
||||||
|
projectFiles.guiFiles.push_back( uiFile );
|
||||||
|
projectWindow->setupFiles( projectFiles );
|
||||||
|
|
||||||
|
currentProject = proj.c_str();
|
||||||
|
currentProjectFile = std::string( dir + "/" + proj + ".xml" ).c_str();
|
||||||
|
|
||||||
|
|
||||||
|
// Save the project file
|
||||||
|
CProjectFileSerializer serializer;
|
||||||
|
serializer.setFile( currentProjectFile.toUtf8().constData() );
|
||||||
|
if( !serializer.serialize( projectFiles ) )
|
||||||
|
{
|
||||||
|
QMessageBox::critical( this,
|
||||||
|
tr( "Failed to save project" ),
|
||||||
|
tr( "There was an error while trying to save the project." ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the GUI file
|
||||||
|
WidgetSerializer widgetSerializer;
|
||||||
|
widgetSerializer.setFile( dir + "/" + uiFile );
|
||||||
|
widgetSerializer.setActiveGroup( projectFiles.activeGroup );
|
||||||
|
if( !widgetSerializer.serialize( projectFiles.masterGroup ) )
|
||||||
|
{
|
||||||
|
QMessageBox::critical( this,
|
||||||
|
tr( "Failed to save project" ),
|
||||||
|
tr( "There was an error while trying to save the project." ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUIEditorWindow::save()
|
void GUIEditorWindow::save()
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include "new_gui_dlg.h"
|
#include "new_gui_dlg.h"
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
NewGUIDlg::NewGUIDlg( QWidget *parent ) :
|
NewGUIDlg::NewGUIDlg( QWidget *parent ) :
|
||||||
QDialog( parent )
|
QDialog( parent )
|
||||||
|
@ -26,6 +27,7 @@ QDialog( parent )
|
||||||
|
|
||||||
connect( m_ui.okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) );
|
connect( m_ui.okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) );
|
||||||
connect( m_ui.cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) );
|
connect( m_ui.cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) );
|
||||||
|
connect( m_ui.projectDirTB, SIGNAL( clicked( bool ) ), this, SLOT( onProjectDirTBClicked() ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +45,11 @@ QString NewGUIDlg::getWindowName() const
|
||||||
return m_ui.windowEdit->text();
|
return m_ui.windowEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString NewGUIDlg::getProjectDirectory() const
|
||||||
|
{
|
||||||
|
return m_ui.projectDirEdit->text();
|
||||||
|
}
|
||||||
|
|
||||||
void NewGUIDlg::onOKClicked()
|
void NewGUIDlg::onOKClicked()
|
||||||
{
|
{
|
||||||
if( m_ui.projectEdit->text().isEmpty() )
|
if( m_ui.projectEdit->text().isEmpty() )
|
||||||
|
@ -61,6 +68,14 @@ void NewGUIDlg::onOKClicked()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( m_ui.projectDirEdit->text().isEmpty() )
|
||||||
|
{
|
||||||
|
QMessageBox::information( this,
|
||||||
|
tr( "New project" ),
|
||||||
|
tr( "You must specify a project directory!" ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,4 +84,15 @@ void NewGUIDlg::onCancelClicked()
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NewGUIDlg::onProjectDirTBClicked()
|
||||||
|
{
|
||||||
|
QString dir = QFileDialog::getExistingDirectory( this,
|
||||||
|
tr( "Specify project directory" ),
|
||||||
|
"." );
|
||||||
|
if( dir.isEmpty() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_ui.projectDirEdit->setText( dir );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,10 +31,12 @@ public:
|
||||||
|
|
||||||
QString getProjectName() const;
|
QString getProjectName() const;
|
||||||
QString getWindowName() const;
|
QString getWindowName() const;
|
||||||
|
QString getProjectDirectory() const;
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onOKClicked();
|
void onOKClicked();
|
||||||
void onCancelClicked();
|
void onCancelClicked();
|
||||||
|
void onProjectDirTBClicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::NewGUIDialog m_ui;
|
Ui::NewGUIDialog m_ui;
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>292</width>
|
<width>332</width>
|
||||||
<height>95</height>
|
<height>125</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -35,6 +35,23 @@
|
||||||
<widget class="QLineEdit" name="windowEdit"/>
|
<widget class="QLineEdit" name="windowEdit"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Project directory</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="projectDirEdit"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QToolButton" name="projectDirTB">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
@ -47,7 +64,7 @@
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="1" colspan="2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="okButton">
|
<widget class="QPushButton" name="okButton">
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "project_file_parser.h"
|
#include "project_file_parser.h"
|
||||||
|
#include "nel/misc/debug.h"
|
||||||
|
|
||||||
namespace GUIEditor
|
namespace GUIEditor
|
||||||
{
|
{
|
||||||
|
@ -208,7 +209,9 @@ namespace GUIEditor
|
||||||
reader.readNext();
|
reader.readNext();
|
||||||
}
|
}
|
||||||
if( files.mapFiles.empty() )
|
if( files.mapFiles.empty() )
|
||||||
return false;
|
{
|
||||||
|
nlinfo( "No map file(s) specified in project file." );
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue