Wed, 08 May 2013 04:10:31 +0300
Moved LDraw path setting out of the configuration dialog to the LDraw path dialog, it does the job better.
file.cpp | file | annotate | diff | comparison | revisions | |
gui.cpp | file | annotate | diff | comparison | revisions | |
gui_actions.cpp | file | annotate | diff | comparison | revisions | |
zz_configDialog.cpp | file | annotate | diff | comparison | revisions | |
zz_configDialog.h | file | annotate | diff | comparison | revisions | |
zz_ldrawPathDialog.cpp | file | annotate | diff | comparison | revisions | |
zz_ldrawPathDialog.h | file | annotate | diff | comparison | revisions |
--- a/file.cpp Wed May 08 03:53:45 2013 +0300 +++ b/file.cpp Wed May 08 04:10:31 2013 +0300 @@ -43,7 +43,7 @@ void initPaths () { if (!tryConfigure (io_ldpath)) { - LDrawPathDialog dlg; + LDrawPathDialog dlg (false); if (!dlg.exec ()) exit (0);
--- a/gui.cpp Wed May 08 03:53:45 2013 +0300 +++ b/gui.cpp Wed May 08 04:10:31 2013 +0300 @@ -145,6 +145,7 @@ addMenuAction ("saveAs"); // Save As menu->addSeparator (); // ------- addMenuAction ("settings"); // Settings + addMenuAction ("setLDrawPath"); // Set LDraw Path menu->addSeparator (); // ------- addMenuAction ("exit"); // Exit
--- a/gui_actions.cpp Wed May 08 03:53:45 2013 +0300 +++ b/gui_actions.cpp Wed May 08 04:10:31 2013 +0300 @@ -26,6 +26,7 @@ #include "zz_addObjectDialog.h" #include "zz_aboutDialog.h" #include "misc.h" +#include "zz_ldrawPathDialog.h" // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * @@ -108,6 +109,11 @@ ConfigDialog::staticDialog (); } +MAKE_ACTION (setLDrawPath, "Set LDraw Path", "settings", "Change the LDraw directory path.", (0)) { + LDrawPathDialog dlg (true); + dlg.exec (); +} + // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // =============================================================================
--- a/zz_configDialog.cpp Wed May 08 03:53:45 2013 +0300 +++ b/zz_configDialog.cpp Wed May 08 04:10:31 2013 +0300 @@ -30,7 +30,6 @@ #include <qevent.h> #include <qgroupbox.h> -extern_cfg (str, io_ldpath); extern_cfg (str, gl_bgcolor); extern_cfg (str, gl_maincolor); extern_cfg (bool, lv_colorize); @@ -82,22 +81,6 @@ mainTab = new QWidget; // ========================================================================= - // LDraw path - lb_LDrawPath = new QLabel ("LDraw path:"); - - le_LDrawPath = new QLineEdit; - le_LDrawPath->setText (io_ldpath.value.chars()); - - pb_findLDrawPath = new QPushButton; - pb_findLDrawPath->setIcon (getIcon ("folder")); - connect (pb_findLDrawPath, SIGNAL (clicked ()), - this, SLOT (slot_findLDrawPath ())); - - QHBoxLayout* qLDrawPathLayout = new QHBoxLayout; - qLDrawPathLayout->addWidget (le_LDrawPath); - qLDrawPathLayout->addWidget (pb_findLDrawPath); - - // ========================================================================= // Background and foreground colors lb_viewBg = new QLabel ("Background color:"); pb_viewBg = new QPushButton; @@ -160,27 +143,24 @@ cb_colorBFC->setEnabled (false); QGridLayout* layout = new QGridLayout; - layout->addWidget (lb_LDrawPath, 0, 0); - layout->addLayout (qLDrawPathLayout, 0, 1, 1, 3); - - layout->addWidget (lb_viewBg, 1, 0); - layout->addWidget (pb_viewBg, 1, 1); - layout->addWidget (lb_viewFg, 1, 2); - layout->addWidget (pb_viewFg, 1, 3); + layout->addWidget (lb_viewBg, 0, 0); + layout->addWidget (pb_viewBg, 0, 1); + layout->addWidget (lb_viewFg, 0, 2); + layout->addWidget (pb_viewFg, 0, 3); - layout->addWidget (lb_lineThickness, 2, 0); - layout->addWidget (sl_lineThickness, 2, 1); - layout->addWidget (lb_viewFgAlpha, 2, 2); - layout->addWidget (sl_viewFgAlpha, 2, 3); + layout->addWidget (lb_lineThickness, 1, 0); + layout->addWidget (sl_lineThickness, 1, 1); + layout->addWidget (lb_viewFgAlpha, 1, 2); + layout->addWidget (sl_viewFgAlpha, 1, 3); - layout->addWidget (lb_iconSize, 3, 0); - layout->addWidget (sl_iconSize, 3, 1); + layout->addWidget (lb_iconSize, 2, 0); + layout->addWidget (sl_iconSize, 2, 1); - layout->addWidget (cb_colorize, 4, 0, 1, 4); - layout->addWidget (cb_colorBFC, 5, 0, 1, 4); - layout->addWidget (cb_selFlash, 6, 0, 1, 4); - layout->addWidget (cb_blackEdges, 7, 0, 1, 4); - layout->addWidget (cb_schemanticInline, 8, 0, 1, 4); + layout->addWidget (cb_colorize, 3, 0, 1, 4); + layout->addWidget (cb_colorBFC, 4, 0, 1, 4); + layout->addWidget (cb_selFlash, 5, 0, 1, 4); + layout->addWidget (cb_blackEdges, 6, 0, 1, 4); + layout->addWidget (cb_schemanticInline, 7, 0, 1, 4); mainTab->setLayout (layout); // Add the tab to the manager @@ -541,17 +521,6 @@ // ============================================================================= // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= -void ConfigDialog::slot_findLDrawPath () { - str dir = QFileDialog::getExistingDirectory (this, "Choose LDraw directory", - le_LDrawPath->text()); - - if (~dir) - le_LDrawPath->setText (dir.chars()); -} - -// ============================================================================= -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -// ============================================================================= void ConfigDialog::pickColor (strconfig& cfg, QPushButton* qButton) { QColorDialog dlg (QColor (cfg.value.chars())); dlg.setWindowIcon (getIcon ("colorselect")); @@ -718,8 +687,6 @@ ConfigDialog dlg (g_win); if (dlg.exec ()) { - io_ldpath = dlg.le_LDrawPath->text(); - lv_colorize = dlg.cb_colorize->isChecked (); gl_colorbfc = dlg.cb_colorBFC->isChecked (); gl_selflash = dlg.cb_selFlash->isChecked ();
--- a/zz_configDialog.h Wed May 08 03:53:45 2013 +0300 +++ b/zz_configDialog.h Wed May 08 04:10:31 2013 +0300 @@ -52,11 +52,8 @@ // ========================================================================= // Main tab widgets - QLabel* lb_LDrawPath; QLabel* lb_viewBg, *lb_viewFg, *lb_viewFgAlpha; QLabel* lb_lineThickness, *lb_iconSize; - QLineEdit* le_LDrawPath; - QPushButton* pb_findLDrawPath; QPushButton* pb_viewBg, *pb_viewFg; QCheckBox* cb_colorize, *cb_colorBFC, *cb_selFlash, *cb_schemanticInline, *cb_blackEdges; @@ -106,7 +103,6 @@ QList<ShortcutListItem*> getShortcutSelection (); private slots: - void slot_findLDrawPath (); void slot_setGLBackground (); void slot_setGLForeground ();
--- a/zz_ldrawPathDialog.cpp Wed May 08 03:53:45 2013 +0300 +++ b/zz_ldrawPathDialog.cpp Wed May 08 04:10:31 2013 +0300 @@ -24,11 +24,18 @@ #include "gui.h" #include "file.h" +extern_cfg (str, io_ldpath); // ======================================================================================================================================== -LDrawPathDialog::LDrawPathDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { +LDrawPathDialog::LDrawPathDialog (const bool validDefault, QWidget* parent, Qt::WindowFlags f) + : QDialog (parent, f), m_validDefault (validDefault) +{ + QLabel* lb_description; lb_resolution = new QLabel ("---"); - QLabel* lb_description = new QLabel ("Please input your LDraw directory"); + + if (validDefault == false) + lb_description = new QLabel ("Please input your LDraw directory"); + QLabel* lb_path = new QLabel ("LDraw path:"); le_path = new QLineEdit; btn_findPath = new QPushButton; @@ -37,12 +44,19 @@ btn_tryConfigure = new QPushButton ("Configure"); btn_tryConfigure->setIcon (getIcon ("settings")); - btn_exit = new QPushButton ("Exit"); - btn_exit->setIcon (getIcon ("exit")); + 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")); + } dbb_buttons = new QDialogButtonBox (QDialogButtonBox::Ok); - dbb_buttons->addButton (btn_tryConfigure, QDialogButtonBox::ApplyRole); - dbb_buttons->addButton (btn_exit, QDialogButtonBox::RejectRole); + dbb_buttons->addButton (btn_tryConfigure, QDialogButtonBox::ActionRole); + dbb_buttons->addButton (btn_cancel, QDialogButtonBox::RejectRole); okButton ()->setEnabled (false); QHBoxLayout* inputLayout = new QHBoxLayout; @@ -51,25 +65,31 @@ inputLayout->addWidget (btn_findPath); QVBoxLayout* mainLayout = new QVBoxLayout; - mainLayout->addWidget (lb_description); + + if (validDefault == false) + mainLayout->addWidget (lb_description); + mainLayout->addLayout (inputLayout); mainLayout->addWidget (lb_resolution); mainLayout->addWidget (dbb_buttons); setLayout (mainLayout); + connect (le_path, SIGNAL (textEdited ()), this, SLOT (slot_tryConfigure ())); connect (btn_findPath, SIGNAL (clicked ()), this, SLOT (slot_findPath ())); connect (btn_tryConfigure, SIGNAL (clicked ()), this, SLOT (slot_tryConfigure ())); connect (dbb_buttons, SIGNAL (accepted ()), this, SLOT (accept ())); - connect (dbb_buttons, SIGNAL (rejected ()), this, SLOT (slot_exit ())); + connect (dbb_buttons, SIGNAL (rejected ()), this, (validDefault) ? SLOT (reject ()) : SLOT (slot_exit ())); + + setPath (io_ldpath); + if (validDefault) + slot_tryConfigure (); } - // ======================================================================================================================================== QPushButton* LDrawPathDialog::okButton () { return dbb_buttons->button (QDialogButtonBox::Ok); } - // ======================================================================================================================================== void LDrawPathDialog::setPath (str path) { le_path->setText (path);
--- a/zz_ldrawPathDialog.h Wed May 08 03:53:45 2013 +0300 +++ b/zz_ldrawPathDialog.h Wed May 08 04:10:31 2013 +0300 @@ -30,7 +30,7 @@ Q_OBJECT public: - explicit LDrawPathDialog (QWidget* parent = null, Qt::WindowFlags f = 0); + explicit LDrawPathDialog (const bool validDefault, QWidget* parent = null, Qt::WindowFlags f = 0); str path () const; void setPath (str path); void (*callback ()) () const { return m_callback; } @@ -41,9 +41,10 @@ QLabel* lb_resolution; QLineEdit* le_path; - QPushButton* btn_findPath, *btn_tryConfigure, *btn_exit; + QPushButton* btn_findPath, *btn_tryConfigure, *btn_cancel; QDialogButtonBox* dbb_buttons; void (*m_callback) (); + const bool m_validDefault; QPushButton* okButton ();