Thu, 04 Jul 2013 22:40:11 +0300
Converted ldraw path prompt
src/dialogs.cpp | file | annotate | diff | comparison | revisions | |
src/dialogs.h | file | annotate | diff | comparison | revisions | |
src/ui/ldrawpath.ui | file | annotate | diff | comparison | revisions | |
src/ui/overlay.ui | file | annotate | diff | comparison | revisions |
--- 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 ("<span style=\"color:red; font-weight: bold;\">%1</span>", - LDPaths::getError())); - okButton ()->setEnabled (false); +void LDrawPathDialog::slot_tryConfigure() +{ + if( LDPaths::tryConfigure( filename() ) == false ) + { + ui->status->setText( fmt( "<span style=\"color:#700; \">%1</span>", LDPaths::getError() ) ); + okButton()->setEnabled( false ); return; } - lb_resolution->setText ("<span style=\"color: #7A0; font-weight: bold;\">OK!</span>"); - okButton ()->setEnabled (true); + ui->status->setText( "<span style=\"color: #270; \">OK!</span>" ); + okButton()->setEnabled( true ); } // =============================================================================
--- 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(); }; // =============================================================================
--- /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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>LDPathUI</class> + <widget class="QDialog" name="LDPathUI"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>344</width> + <height>112</height> + </rect> + </property> + <property name="windowTitle"> + <string>Set LDraw Path</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QLabel" name="heading"> + <property name="text"> + <string>Please input your LDraw directory root to proceed:</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>LDraw Path:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="path"/> + </item> + <item> + <widget class="QPushButton" name="searchButton"> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="../../ldforge.qrc"> + <normaloff>:/icons/folder.png</normaloff>:/icons/folder.png</iconset> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QLabel" name="status"> + <property name="styleSheet"> + <string notr="true">font-weight: bold</string> + </property> + <property name="text"> + <string>[[ Information ]]</string> + </property> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources> + <include location="../../ldforge.qrc"/> + </resources> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>LDPathUI</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>OverlayUI</class> + <widget class="QDialog" name="OverlayUI"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>276</width> + <height>244</height> + </rect> + </property> + <property name="windowTitle"> + <string>Set Overlay</string> + </property> + <property name="windowIcon"> + <iconset resource="../../ldforge.qrc"> + <normaloff>:/icons/overlay.png</normaloff>:/icons/overlay.png</iconset> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="groupBox_2"> + <property name="title"> + <string>Camera</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QRadioButton" name="top"> + <property name="text"> + <string>Top</string> + </property> + <property name="icon"> + <iconset resource="../../ldforge.qrc"> + <normaloff>:/icons/camera-top.png</normaloff>:/icons/camera-top.png</iconset> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QRadioButton" name="front"> + <property name="text"> + <string>Front</string> + </property> + <property name="icon"> + <iconset resource="../../ldforge.qrc"> + <normaloff>:/icons/camera-front.png</normaloff>:/icons/camera-front.png</iconset> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QRadioButton" name="left"> + <property name="text"> + <string>Left</string> + </property> + <property name="icon"> + <iconset resource="../../ldforge.qrc"> + <normaloff>:/icons/camera-left.png</normaloff>:/icons/camera-left.png</iconset> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QRadioButton" name="bottom"> + <property name="text"> + <string>Bottom</string> + </property> + <property name="icon"> + <iconset resource="../../ldforge.qrc"> + <normaloff>:/icons/camera-bottom.png</normaloff>:/icons/camera-bottom.png</iconset> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QRadioButton" name="back"> + <property name="text"> + <string>Back</string> + </property> + <property name="icon"> + <iconset resource="../../ldforge.qrc"> + <normaloff>:/icons/camera-back.png</normaloff>:/icons/camera-back.png</iconset> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QRadioButton" name="right"> + <property name="text"> + <string>Right</string> + </property> + <property name="icon"> + <iconset resource="../../ldforge.qrc"> + <normaloff>:/icons/camera-right.png</normaloff>:/icons/camera-right.png</iconset> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string>Image</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QFormLayout" name="formLayout"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::ExpandingFieldsGrow</enum> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>File:</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QLineEdit" name="filename"/> + </item> + <item> + <widget class="QPushButton" name="fileSearchButton"> + <property name="text"> + <string/> + </property> + <property name="icon"> + <iconset resource="../../ldforge.qrc"> + <normaloff>:/icons/file-open.png</normaloff>:/icons/file-open.png</iconset> + </property> + </widget> + </item> + </layout> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Origin:</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QSpinBox" name="originX"> + <property name="minimumSize"> + <size> + <width>80</width> + <height>0</height> + </size> + </property> + <property name="suffix"> + <string> px</string> + </property> + <property name="prefix"> + <string/> + </property> + <property name="maximum"> + <number>10000</number> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="originY"> + <property name="minimumSize"> + <size> + <width>80</width> + <height>0</height> + </size> + </property> + <property name="suffix"> + <string> px</string> + </property> + <property name="maximum"> + <number>10000</number> + </property> + </widget> + </item> + </layout> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Dimensions:</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QDoubleSpinBox" name="width"> + <property name="minimumSize"> + <size> + <width>80</width> + <height>0</height> + </size> + </property> + <property name="suffix"> + <string> LDU</string> + </property> + <property name="maximum"> + <double>10000.000000000000000</double> + </property> + </widget> + </item> + <item> + <widget class="QDoubleSpinBox" name="height"> + <property name="minimumSize"> + <size> + <width>80</width> + <height>0</height> + </size> + </property> + <property name="suffix"> + <string> LDU</string> + </property> + <property name="minimum"> + <double>0.000000000000000</double> + </property> + <property name="maximum"> + <double>10000.000000000000000</double> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Help|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources> + <include location="../../ldforge.qrc"/> + </resources> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>OverlayUI</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>OverlayUI</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui>