[vlmc-devel] [PATCH 2/3] can change directory in project wizard

Sanket Markan sanketmarkan at gmail.com
Sat Mar 12 18:32:40 CET 2016


---
 src/Gui/wizard/GeneralPage.cpp   | 19 +++++++++++++++++--
 src/Gui/wizard/GeneralPage.h     |  3 +++
 src/Gui/wizard/ui/GeneralPage.ui |  7 +++++++
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/src/Gui/wizard/GeneralPage.cpp b/src/Gui/wizard/GeneralPage.cpp
index da986ba..a0de6a2 100644
--- a/src/Gui/wizard/GeneralPage.cpp
+++ b/src/Gui/wizard/GeneralPage.cpp
@@ -37,12 +37,15 @@ GeneralPage::GeneralPage( QWidget *parent ) :
     setTitle( tr( "New project wizard" ) );
     setSubTitle( tr( "Set General options" ) );
 
+    projectDir = VLMC_GET_STRING( "vlmc/WorkspaceLocation" );
+
     // Create palettes
     pValid = pInvalid = palette();
     pInvalid.setColor( QPalette::Text, QColor( 215, 30, 30 ) );
 
     connect( ui.lineEditName, SIGNAL( textChanged(QString) ),
              this, SLOT( updateProjectLocation() ) );
+    connect( ui.lineEditProject, SIGNAL( clicked() ), this, SLOT( buttonPressed() ) );
 
     registerField( "projectName*", ui.lineEditName );
     registerField( "projectPath*", ui.lineEditProjectLocation );
@@ -98,7 +101,7 @@ GeneralPage::validatePage()
 
     //Create the project directory in the workspace dir.
     QString     projectPath = ui.lineEditName->text().replace( ' ', '_' );
-    QDir        workspaceDir( VLMC_GET_STRING( "vlmc/WorkspaceLocation" ) );
+    QDir        workspaceDir( projectDir );
 
     if ( workspaceDir.exists( projectPath ) == false )
         workspaceDir.mkdir( projectPath );
@@ -108,7 +111,7 @@ GeneralPage::validatePage()
 void
 GeneralPage::updateProjectLocation()
 {
-    auto        workspaceLocation = VLMC_GET_STRING( "vlmc/WorkspaceLocation" );
+    auto        workspaceLocation = projectDir;
     QString     pName = ui.lineEditName->text().replace( ' ', '_' );
     QDir        projectDir( QString( "%1/%2" ).arg( workspaceLocation, pName ) );
 
@@ -127,3 +130,15 @@ GeneralPage::setValidity( bool status )
         ui.lineEditProjectLocation->setPalette( pInvalid );
     m_valid = status;
 }
+
+void
+GeneralPage::buttonPressed()
+{
+    QString tempProjectDir = QFileDialog::getExistingDirectory( NULL, tr( "Select a path" ),
+                                                                    projectDir );
+    if ( tempProjectDir.length() > 0 )
+    {
+        projectDir = tempProjectDir;
+        updateProjectLocation();
+    }
+}
diff --git a/src/Gui/wizard/GeneralPage.h b/src/Gui/wizard/GeneralPage.h
index a7bc427..b6d0ae8 100644
--- a/src/Gui/wizard/GeneralPage.h
+++ b/src/Gui/wizard/GeneralPage.h
@@ -28,6 +28,8 @@
 class GeneralPage : public QWizardPage
 {
     Q_OBJECT
+    QString projectDir;
+
 public:
     GeneralPage( QWidget *parent = 0 );
 
@@ -42,6 +44,7 @@ private:
 
 private slots:
     void                updateProjectLocation();
+    void                buttonPressed();
 
 private:
     Ui::GeneralPage     ui;
diff --git a/src/Gui/wizard/ui/GeneralPage.ui b/src/Gui/wizard/ui/GeneralPage.ui
index 69cb399..d261479 100644
--- a/src/Gui/wizard/ui/GeneralPage.ui
+++ b/src/Gui/wizard/ui/GeneralPage.ui
@@ -130,6 +130,13 @@ p, li { white-space: pre-wrap; }
      </property>
     </widget>
    </item>
+   <item row="6" column="1">
+     <widget class="QPushButton" name="lineEditProject">
+       <property name="text">
+        <string>Choose Directory</string>
+       </property>
+     </widget>
+   </item>
   </layout>
  </widget>
  <resources/>
-- 
1.9.1



More information about the Vlmc-devel mailing list