mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-22 23:06:18 +00:00
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 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 );
|
||||
if( !b )
|
||||
|
@ -220,8 +223,41 @@ namespace GUIEditor
|
|||
reset();
|
||||
}
|
||||
|
||||
std::string mg = std::string( "ui:" ) + proj;
|
||||
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()
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "new_gui_dlg.h"
|
||||
#include <QMessageBox>
|
||||
#include <QFileDialog>
|
||||
|
||||
NewGUIDlg::NewGUIDlg( QWidget *parent ) :
|
||||
QDialog( parent )
|
||||
|
@ -26,6 +27,7 @@ QDialog( parent )
|
|||
|
||||
connect( m_ui.okButton, SIGNAL( clicked( bool ) ), this, SLOT( onOKClicked() ) );
|
||||
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();
|
||||
}
|
||||
|
||||
QString NewGUIDlg::getProjectDirectory() const
|
||||
{
|
||||
return m_ui.projectDirEdit->text();
|
||||
}
|
||||
|
||||
void NewGUIDlg::onOKClicked()
|
||||
{
|
||||
if( m_ui.projectEdit->text().isEmpty() )
|
||||
|
@ -61,6 +68,14 @@ void NewGUIDlg::onOKClicked()
|
|||
return;
|
||||
}
|
||||
|
||||
if( m_ui.projectDirEdit->text().isEmpty() )
|
||||
{
|
||||
QMessageBox::information( this,
|
||||
tr( "New project" ),
|
||||
tr( "You must specify a project directory!" ) );
|
||||
return;
|
||||
}
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
|
@ -69,4 +84,15 @@ void NewGUIDlg::onCancelClicked()
|
|||
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 getWindowName() const;
|
||||
QString getProjectDirectory() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void onOKClicked();
|
||||
void onCancelClicked();
|
||||
void onProjectDirTBClicked();
|
||||
|
||||
private:
|
||||
Ui::NewGUIDialog m_ui;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>292</width>
|
||||
<height>95</height>
|
||||
<width>332</width>
|
||||
<height>125</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
|
@ -35,6 +35,23 @@
|
|||
<widget class="QLineEdit" name="windowEdit"/>
|
||||
</item>
|
||||
<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">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
|
@ -47,7 +64,7 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="3" column="1" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QPushButton" name="okButton">
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
|
||||
#include "project_file_parser.h"
|
||||
#include "nel/misc/debug.h"
|
||||
|
||||
namespace GUIEditor
|
||||
{
|
||||
|
@ -208,7 +209,9 @@ namespace GUIEditor
|
|||
reader.readNext();
|
||||
}
|
||||
if( files.mapFiles.empty() )
|
||||
return false;
|
||||
{
|
||||
nlinfo( "No map file(s) specified in project file." );
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue