zz_ldrawPathDialog.cpp

changeset 180
16306e69a895
parent 179
f98391b179ab
equal deleted inserted replaced
179:f98391b179ab 180:16306e69a895
22 #include <QFileDialog> 22 #include <QFileDialog>
23 #include "zz_ldrawPathDialog.h" 23 #include "zz_ldrawPathDialog.h"
24 #include "gui.h" 24 #include "gui.h"
25 #include "file.h" 25 #include "file.h"
26 26
27 extern_cfg (str, io_ldpath);
27 28
28 // ======================================================================================================================================== 29 // ========================================================================================================================================
29 LDrawPathDialog::LDrawPathDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { 30 LDrawPathDialog::LDrawPathDialog (const bool validDefault, QWidget* parent, Qt::WindowFlags f)
31 : QDialog (parent, f), m_validDefault (validDefault)
32 {
33 QLabel* lb_description;
30 lb_resolution = new QLabel ("---"); 34 lb_resolution = new QLabel ("---");
31 QLabel* lb_description = new QLabel ("Please input your LDraw directory"); 35
36 if (validDefault == false)
37 lb_description = new QLabel ("Please input your LDraw directory");
38
32 QLabel* lb_path = new QLabel ("LDraw path:"); 39 QLabel* lb_path = new QLabel ("LDraw path:");
33 le_path = new QLineEdit; 40 le_path = new QLineEdit;
34 btn_findPath = new QPushButton; 41 btn_findPath = new QPushButton;
35 btn_findPath->setIcon (getIcon ("folder")); 42 btn_findPath->setIcon (getIcon ("folder"));
36 43
37 btn_tryConfigure = new QPushButton ("Configure"); 44 btn_tryConfigure = new QPushButton ("Configure");
38 btn_tryConfigure->setIcon (getIcon ("settings")); 45 btn_tryConfigure->setIcon (getIcon ("settings"));
39 46
40 btn_exit = new QPushButton ("Exit"); 47 btn_cancel = new QPushButton;
41 btn_exit->setIcon (getIcon ("exit")); 48
49 if (validDefault == false) {
50 btn_cancel->setText ("Exit");
51 btn_cancel->setIcon (getIcon ("exit"));
52 } else {
53 btn_cancel->setText ("Cancel");
54 btn_cancel->setIcon (getIcon ("cancel"));
55 }
42 56
43 dbb_buttons = new QDialogButtonBox (QDialogButtonBox::Ok); 57 dbb_buttons = new QDialogButtonBox (QDialogButtonBox::Ok);
44 dbb_buttons->addButton (btn_tryConfigure, QDialogButtonBox::ApplyRole); 58 dbb_buttons->addButton (btn_tryConfigure, QDialogButtonBox::ActionRole);
45 dbb_buttons->addButton (btn_exit, QDialogButtonBox::RejectRole); 59 dbb_buttons->addButton (btn_cancel, QDialogButtonBox::RejectRole);
46 okButton ()->setEnabled (false); 60 okButton ()->setEnabled (false);
47 61
48 QHBoxLayout* inputLayout = new QHBoxLayout; 62 QHBoxLayout* inputLayout = new QHBoxLayout;
49 inputLayout->addWidget (lb_path); 63 inputLayout->addWidget (lb_path);
50 inputLayout->addWidget (le_path); 64 inputLayout->addWidget (le_path);
51 inputLayout->addWidget (btn_findPath); 65 inputLayout->addWidget (btn_findPath);
52 66
53 QVBoxLayout* mainLayout = new QVBoxLayout; 67 QVBoxLayout* mainLayout = new QVBoxLayout;
54 mainLayout->addWidget (lb_description); 68
69 if (validDefault == false)
70 mainLayout->addWidget (lb_description);
71
55 mainLayout->addLayout (inputLayout); 72 mainLayout->addLayout (inputLayout);
56 mainLayout->addWidget (lb_resolution); 73 mainLayout->addWidget (lb_resolution);
57 mainLayout->addWidget (dbb_buttons); 74 mainLayout->addWidget (dbb_buttons);
58 setLayout (mainLayout); 75 setLayout (mainLayout);
59 76
77 connect (le_path, SIGNAL (textEdited ()), this, SLOT (slot_tryConfigure ()));
60 connect (btn_findPath, SIGNAL (clicked ()), this, SLOT (slot_findPath ())); 78 connect (btn_findPath, SIGNAL (clicked ()), this, SLOT (slot_findPath ()));
61 connect (btn_tryConfigure, SIGNAL (clicked ()), this, SLOT (slot_tryConfigure ())); 79 connect (btn_tryConfigure, SIGNAL (clicked ()), this, SLOT (slot_tryConfigure ()));
62 connect (dbb_buttons, SIGNAL (accepted ()), this, SLOT (accept ())); 80 connect (dbb_buttons, SIGNAL (accepted ()), this, SLOT (accept ()));
63 connect (dbb_buttons, SIGNAL (rejected ()), this, SLOT (slot_exit ())); 81 connect (dbb_buttons, SIGNAL (rejected ()), this, (validDefault) ? SLOT (reject ()) : SLOT (slot_exit ()));
82
83 setPath (io_ldpath);
84 if (validDefault)
85 slot_tryConfigure ();
64 } 86 }
65
66 87
67 // ======================================================================================================================================== 88 // ========================================================================================================================================
68 QPushButton* LDrawPathDialog::okButton () { 89 QPushButton* LDrawPathDialog::okButton () {
69 return dbb_buttons->button (QDialogButtonBox::Ok); 90 return dbb_buttons->button (QDialogButtonBox::Ok);
70 } 91 }
71
72 92
73 // ======================================================================================================================================== 93 // ========================================================================================================================================
74 void LDrawPathDialog::setPath (str path) { 94 void LDrawPathDialog::setPath (str path) {
75 le_path->setText (path); 95 le_path->setText (path);
76 } 96 }

mercurial