src/dialogs/ldrawpathdialog.cpp

changeset 1217
314e12e23c3a
parent 999
213a7c7a3ce4
child 1222
34def2630300
equal deleted inserted replaced
1216:12f9ea615cbc 1217:314e12e23c3a
21 #include <QLabel> 21 #include <QLabel>
22 #include "ldrawpathdialog.h" 22 #include "ldrawpathdialog.h"
23 #include "ui_ldrawpathdialog.h" 23 #include "ui_ldrawpathdialog.h"
24 #include "../mainwindow.h" 24 #include "../mainwindow.h"
25 25
26 LDrawPathDialog::LDrawPathDialog (const QString& defaultPath, bool validDefault, QWidget* parent, Qt::WindowFlags f) : 26 LDrawPathDialog::LDrawPathDialog(const QString& defaultPath, bool validDefault, QWidget* parent, Qt::WindowFlags f) :
27 QDialog (parent, f), 27 QDialog(parent, f),
28 m_hasValidDefault (validDefault), 28 m_hasValidDefault(validDefault),
29 ui (*new Ui_LDrawPathDialog) 29 ui(*new Ui_LDrawPathDialog)
30 { 30 {
31 ui.setupUi (this); 31 ui.setupUi(this);
32 ui.status->setText ("---"); 32 ui.status->setText("---");
33 33
34 if (validDefault) 34 if (validDefault)
35 ui.heading->hide(); 35 ui.heading->hide();
36 else 36 else
37 { 37 {
38 cancelButton()->setText ("Exit"); 38 cancelButton()->setText("Exit");
39 cancelButton()->setIcon (GetIcon ("exit")); 39 cancelButton()->setIcon(GetIcon("exit"));
40 } 40 }
41 41
42 okButton()->setEnabled (false); 42 okButton()->setEnabled(false);
43 43
44 connect (ui.path, SIGNAL (textChanged (QString)), this, SIGNAL (pathChanged (QString))); 44 connect(ui.path, SIGNAL(textChanged(QString)), this, SIGNAL(pathChanged(QString)));
45 connect (ui.searchButton, SIGNAL (clicked()), this, SLOT (searchButtonClicked())); 45 connect(ui.searchButton, SIGNAL(clicked()), this, SLOT(searchButtonClicked()));
46 connect (ui.buttonBox, SIGNAL (rejected()), this, SLOT (reject())); 46 connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
47 connect (ui.buttonBox, SIGNAL (accepted()), this, SLOT (accept())); 47 connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
48 setPath (defaultPath); 48 setPath(defaultPath);
49 } 49 }
50 50
51 LDrawPathDialog::~LDrawPathDialog() 51 LDrawPathDialog::~LDrawPathDialog()
52 { 52 {
53 delete &ui; 53 delete &ui;
54 } 54 }
55 55
56 QPushButton* LDrawPathDialog::okButton() 56 QPushButton* LDrawPathDialog::okButton()
57 { 57 {
58 return ui.buttonBox->button (QDialogButtonBox::Ok); 58 return ui.buttonBox->button(QDialogButtonBox::Ok);
59 } 59 }
60 60
61 QPushButton* LDrawPathDialog::cancelButton() 61 QPushButton* LDrawPathDialog::cancelButton()
62 { 62 {
63 return ui.buttonBox->button (QDialogButtonBox::Cancel); 63 return ui.buttonBox->button(QDialogButtonBox::Cancel);
64 } 64 }
65 65
66 void LDrawPathDialog::setPath (QString path) 66 void LDrawPathDialog::setPath(QString path)
67 { 67 {
68 ui.path->setText (path); 68 ui.path->setText(path);
69 } 69 }
70 70
71 QString LDrawPathDialog::path() const 71 QString LDrawPathDialog::path() const
72 { 72 {
73 return ui.path->text(); 73 return ui.path->text();
74 } 74 }
75 75
76 void LDrawPathDialog::searchButtonClicked() 76 void LDrawPathDialog::searchButtonClicked()
77 { 77 {
78 QString newpath = QFileDialog::getExistingDirectory (this, "Find LDraw Path"); 78 QString newpath = QFileDialog::getExistingDirectory(this, "Find LDraw Path");
79 79
80 if (not newpath.isEmpty()) 80 if (not newpath.isEmpty())
81 setPath (newpath); 81 setPath(newpath);
82 } 82 }
83 83
84 void LDrawPathDialog::setStatusText (const QString& statusText, bool ok) 84 void LDrawPathDialog::setStatusText(const QString& statusText, bool ok)
85 { 85 {
86 okButton()->setEnabled (ok); 86 okButton()->setEnabled(ok);
87 87
88 if (statusText.isEmpty() && ok == false) 88 if (statusText.isEmpty() && ok == false)
89 ui.status->setText ("---"); 89 ui.status->setText("---");
90 else 90 else
91 { 91 {
92 ui.status->setText (QString ("<span style=\"color: %1\">%2</span>") 92 ui.status->setText(QString("<span style=\"color: %1\">%2</span>")
93 .arg (ok ? "#270" : "#700") 93 .arg(ok ? "#270" : "#700")
94 .arg (statusText)); 94 .arg(statusText));
95 } 95 }
96 } 96 }

mercurial