# HG changeset patch # User Santeri Piippo # Date 1372966811 -10800 # Node ID 4e05207c76c9dce0cd1dfea92239a162b4d868b1 # Parent 9dd47cc12ab83119d9e339d13192435217de04fb Converted ldraw path prompt diff -r 9dd47cc12ab8 -r 4e05207c76c9 src/dialogs.cpp --- a/src/dialogs.cpp Thu Jul 04 21:09:19 2013 +0300 +++ b/src/dialogs.cpp Thu Jul 04 22:40:11 2013 +0300 @@ -36,6 +36,7 @@ #include "file.h" #include "dialogs.h" #include "ui_overlay.h" +#include "ui_ldrawpath.h" extern_cfg (str, io_ldpath); @@ -144,94 +145,85 @@ } // ================================================================================================= -LDrawPathDialog::LDrawPathDialog (const bool validDefault, QWidget* parent, Qt::WindowFlags f) - : QDialog (parent, f), m_validDefault (validDefault) +LDrawPathDialog::LDrawPathDialog( const bool validDefault, QWidget* parent, Qt::WindowFlags f ) + : QDialog( parent, f ), m_validDefault( validDefault ) { - QLabel* lb_description = null; - lb_resolution = new QLabel ("---"); - - if (validDefault == false) - lb_description = new QLabel ("Please input your LDraw directory"); + ui = new Ui_LDPathUI; + ui->setupUi( this ); + ui->status->setText( "---" ); - QLabel* lb_path = new QLabel ("LDraw path:"); - le_path = new QLineEdit; - btn_findPath = new QPushButton; - btn_findPath->setIcon (getIcon ("folder")); - - btn_cancel = new QPushButton; - - if (validDefault == false) { - btn_cancel->setText ("Exit"); - btn_cancel->setIcon (getIcon ("exit")); - } else { - btn_cancel->setText ("Cancel"); - btn_cancel->setIcon (getIcon ("cancel")); + if( validDefault ) + ui->heading->hide(); + else + { + cancelButton()->setText( "Exit" ); + cancelButton()->setIcon( getIcon( "exit" )); } - dbb_buttons = new QDialogButtonBox (QDialogButtonBox::Ok); - dbb_buttons->addButton (btn_cancel, QDialogButtonBox::RejectRole); - okButton ()->setEnabled (false); + okButton()->setEnabled( false ); - QHBoxLayout* inputLayout = new QHBoxLayout; - inputLayout->addWidget (lb_path); - inputLayout->addWidget (le_path); - inputLayout->addWidget (btn_findPath); + connect( ui->path, SIGNAL( textEdited( QString ) ), this, SLOT( slot_tryConfigure() ) ); + connect( ui->searchButton, SIGNAL( clicked() ), this, SLOT( slot_findPath() ) ); + connect( ui->buttonBox, SIGNAL( rejected() ), this, validDefault ? SLOT( reject() ) : SLOT( slot_exit() )); - QVBoxLayout* mainLayout = new QVBoxLayout; - - if (validDefault == false) - mainLayout->addWidget (lb_description); + setPath( io_ldpath ); - mainLayout->addLayout (inputLayout); - mainLayout->addWidget (lb_resolution); - mainLayout->addWidget (dbb_buttons); - setLayout (mainLayout); - - connect (le_path, SIGNAL (textEdited (QString)), this, SLOT (slot_tryConfigure ())); - connect (btn_findPath, SIGNAL (clicked ()), this, SLOT (slot_findPath ())); - connect (dbb_buttons, SIGNAL (accepted ()), this, SLOT (accept ())); - connect (dbb_buttons, SIGNAL (rejected ()), this, (validDefault) ? SLOT (reject ()) : SLOT (slot_exit ())); - - setPath (io_ldpath); - if (validDefault) - slot_tryConfigure (); + if( validDefault ) + slot_tryConfigure(); +} + +LDrawPathDialog::~LDrawPathDialog() +{ + delete ui; +} + +QPushButton* LDrawPathDialog::okButton() +{ + return ui->buttonBox->button( QDialogButtonBox::Ok ); } -QPushButton* LDrawPathDialog::okButton () { - return dbb_buttons->button (QDialogButtonBox::Ok); +QPushButton* LDrawPathDialog::cancelButton() +{ + return ui->buttonBox->button( QDialogButtonBox::Cancel ); } -void LDrawPathDialog::setPath (str path) { - le_path->setText (path); +void LDrawPathDialog::setPath( str path ) +{ + ui->path->setText( path ); } -str LDrawPathDialog::filename () const { - return le_path->text (); +str LDrawPathDialog::filename() const +{ + return ui->path->text(); } -void LDrawPathDialog::slot_findPath () { - str newpath = QFileDialog::getExistingDirectory (this, "Find LDraw Path"); - - if (newpath.length () > 0 && newpath != filename ()) { - setPath (newpath); - slot_tryConfigure (); +void LDrawPathDialog::slot_findPath() +{ + str newpath = QFileDialog::getExistingDirectory( this, "Find LDraw Path" ); + + if( newpath.length() > 0 && newpath != filename() ) + { + setPath( newpath ); + slot_tryConfigure(); } } -void LDrawPathDialog::slot_exit () { - exit (1); +void LDrawPathDialog::slot_exit() +{ + exit( 1 ); } -void LDrawPathDialog::slot_tryConfigure () { - if (LDPaths::tryConfigure (filename ()) == false) { - lb_resolution->setText (fmt ("%1", - LDPaths::getError())); - okButton ()->setEnabled (false); +void LDrawPathDialog::slot_tryConfigure() +{ + if( LDPaths::tryConfigure( filename() ) == false ) + { + ui->status->setText( fmt( "%1", LDPaths::getError() ) ); + okButton()->setEnabled( false ); return; } - lb_resolution->setText ("OK!"); - okButton ()->setEnabled (true); + ui->status->setText( "OK!" ); + okButton()->setEnabled( true ); } // ============================================================================= diff -r 9dd47cc12ab8 -r 4e05207c76c9 src/dialogs.h --- a/src/dialogs.h Thu Jul 04 21:09:19 2013 +0300 +++ b/src/dialogs.h Thu Jul 04 22:40:11 2013 +0300 @@ -37,6 +37,7 @@ class QLabel; class QAbstractButton; class Ui_OverlayUI; +class Ui_LDPathUI; class OverlayDialog : public QDialog { @@ -65,29 +66,27 @@ }; // ============================================================================= -class LDrawPathDialog : public QDialog { +class LDrawPathDialog : public QDialog +{ Q_OBJECT public: - explicit LDrawPathDialog (const bool validDefault, QWidget* parent = null, Qt::WindowFlags f = 0); - str filename () const; - void setPath (str path); + explicit LDrawPathDialog( const bool validDefault, QWidget* parent = null, Qt::WindowFlags f = 0 ); + virtual ~LDrawPathDialog(); + str filename() const; + void setPath( str path ); private: - Q_DISABLE_COPY (LDrawPathDialog) - - QLabel* lb_resolution; - QLineEdit* le_path; - QPushButton* btn_findPath, *btn_cancel; - QDialogButtonBox* dbb_buttons; + Q_DISABLE_COPY( LDrawPathDialog ) const bool m_validDefault; - - QPushButton* okButton (); + Ui_LDPathUI* ui; + QPushButton* okButton(); + QPushButton* cancelButton(); private slots: - void slot_findPath (); - void slot_tryConfigure (); - void slot_exit (); + void slot_findPath(); + void slot_tryConfigure(); + void slot_exit(); }; // ============================================================================= diff -r 9dd47cc12ab8 -r 4e05207c76c9 src/ui/ldrawpath.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui/ldrawpath.ui Thu Jul 04 22:40:11 2013 +0300 @@ -0,0 +1,92 @@ + + + LDPathUI + + + + 0 + 0 + 344 + 112 + + + + Set LDraw Path + + + + + + Please input your LDraw directory root to proceed: + + + + + + + + + LDraw Path: + + + + + + + + + + + + + + :/icons/folder.png:/icons/folder.png + + + + + + + + + font-weight: bold + + + [[ Information ]] + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + LDPathUI + accept() + + + 248 + 254 + + + 157 + 274 + + + + + diff -r 9dd47cc12ab8 -r 4e05207c76c9 src/ui/overlay.ui --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/ui/overlay.ui Thu Jul 04 22:40:11 2013 +0300 @@ -0,0 +1,278 @@ + + + OverlayUI + + + + 0 + 0 + 276 + 244 + + + + Set Overlay + + + + :/icons/overlay.png:/icons/overlay.png + + + + + + Camera + + + + + + Top + + + + :/icons/camera-top.png:/icons/camera-top.png + + + + + + + Front + + + + :/icons/camera-front.png:/icons/camera-front.png + + + + + + + Left + + + + :/icons/camera-left.png:/icons/camera-left.png + + + + + + + Bottom + + + + :/icons/camera-bottom.png:/icons/camera-bottom.png + + + + + + + Back + + + + :/icons/camera-back.png:/icons/camera-back.png + + + + + + + Right + + + + :/icons/camera-right.png:/icons/camera-right.png + + + + + + + + + + Image + + + + + + QFormLayout::ExpandingFieldsGrow + + + + + File: + + + + + + + + + + + + + + + + :/icons/file-open.png:/icons/file-open.png + + + + + + + + + Origin: + + + + + + + + + + 80 + 0 + + + + px + + + + + + 10000 + + + + + + + + 80 + 0 + + + + px + + + 10000 + + + + + + + + + Dimensions: + + + + + + + + + + 80 + 0 + + + + LDU + + + 10000.000000000000000 + + + + + + + + 80 + 0 + + + + LDU + + + 0.000000000000000 + + + 10000.000000000000000 + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + OverlayUI + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + OverlayUI + reject() + + + 316 + 260 + + + 286 + 274 + + + + +