src/dialogs.cpp

changeset 248
4431371f3ffe
parent 226
3dd9e63698cd
child 249
6b2cc2d82ba6
equal deleted inserted replaced
247:1a2ca515f683 248:4431371f3ffe
23 #include <QFileDialog> 23 #include <QFileDialog>
24 #include <QLabel> 24 #include <QLabel>
25 #include <QPushButton> 25 #include <QPushButton>
26 #include <QBoxLayout> 26 #include <QBoxLayout>
27 #include <QGridLayout> 27 #include <QGridLayout>
28 #include <qprogressbar.h>
28 29
29 #include "dialogs.h" 30 #include "dialogs.h"
30 #include "widgets.h" 31 #include "widgets.h"
31 #include "gui.h" 32 #include "gui.h"
32 #include "gldraw.h" 33 #include "gldraw.h"
421 objs.push_back (new LDEmpty); 422 objs.push_back (new LDEmpty);
422 423
423 g_win->fullRefresh (); 424 g_win->fullRefresh ();
424 } 425 }
425 426
427 // =============================================================================
428 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
429 // =============================================================================
426 RotationPointDialog::RotationPointDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) { 430 RotationPointDialog::RotationPointDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) {
427 rb_rotpoint = new RadioBox ("Rotation Point", { "Object center", "Custom" }, 0, Qt::Vertical, this); 431 rb_rotpoint = new RadioBox ("Rotation Point", { "Object center", "Custom" }, 0, Qt::Vertical, this);
428 connect (rb_rotpoint, SIGNAL (valueChanged (int)), this, SLOT (radioBoxChanged ())); 432 connect (rb_rotpoint, SIGNAL (valueChanged (int)), this, SLOT (radioBoxChanged ()));
429 433
430 gb_customPos = new QGroupBox ("Custom point", this); 434 gb_customPos = new QGroupBox ("Custom point", this);
470 } 474 }
471 475
472 void RotationPointDialog::radioBoxChanged () { 476 void RotationPointDialog::radioBoxChanged () {
473 setCustom (rb_rotpoint->value ()); 477 setCustom (rb_rotpoint->value ());
474 } 478 }
479
480 // =============================================================================
481 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
482 // =============================================================================
483 OpenFileDialog::OpenFileDialog (QWidget* parent, Qt::WindowFlags f) : QDialog (parent, f) {
484 progressBar = new QProgressBar;
485 progressText = new QLabel;
486 setNumLines (0);
487 m_progress = 0;
488
489 QDialogButtonBox* dbb_buttons = new QDialogButtonBox;
490 dbb_buttons->addButton (QDialogButtonBox::Cancel);
491 connect (dbb_buttons, SIGNAL (rejected ()), this, SLOT (reject ()));
492
493 QVBoxLayout* layout = new QVBoxLayout (this);
494 layout->addWidget (progressText);
495 layout->addWidget (progressBar);
496 layout->addWidget (dbb_buttons);
497 }
498
499 void OpenFileDialog::callback_setNumLines () {
500 progressBar->setRange (0, numLines ());
501 updateValues ();
502 }
503
504 void OpenFileDialog::updateValues () {
505 progressBar->setValue (progress ());
506 progressText->setText (fmt ("%s: %lu/%lu lines parsed", fileName ().c (), progress (), numLines ()));
507 }
508
509 void OpenFileDialog::updateProgress (int progress) {
510 m_progress = progress;
511 updateValues ();
512 }

mercurial