void FileDialog::sendFileName() { if (path != "") { emit fileChosen(true); emit fileName(path); this->close(); } }
void MachineWidget::chooseFile() { QString filepath = QFileDialog::getOpenFileName(this, tr("Open File"), "", tr("Files (*.*)")); if (!filepath.isEmpty()) { QImage *image = new QImage(filepath); if (image->isNull()) { QMessageBox::information(this, tr( "Image Viewer"), tr("Cannot load %1.").arg(filepath)); return; } else { emit fileChosen(filepath); } } }
MachineWidget::MachineWidget(QWidget *parent) : QWidget(parent), ui(new Ui::MachineWidget) { ui->setupUi(this); connect(this, SIGNAL(fileChosen(QString)), this, SLOT(createMachine(QString))); program_image = new ProgramImageWidget(); ui->groupBoxSource->layout()->addWidget(program_image); program_image->show(); stream = new std::stringstream(); disableMachineInterface(); std::cout << "machine widget constructed" << std::endl; }
MCWorld::MCWorld() { TravelingPixmap* object; for(int i = 0; i < 3; i++) { object = new TravelingPixmap("images/MCWorld/italian.png"); italians << object; object = new TravelingPixmap("images/MCWorld/maiden.png"); maidens << object; } boat = new TravelingPixmap("images/MCWorld/boat.png"); makeObjectsList(); shore1 = Coordinate(300, 100); shore2 = Coordinate(400, 400); boat1 = Coordinate(150, 250); boat2 = Coordinate(350, 450); setShore1(shore1, boat1); setShore2(shore2, boat2); preferedSpeed = Speed(60, 60, 0).speedModule(); reset(); moving = true; //initialise the rides to make the objects move: for(int i = 0; i < 3; i++) { Ride x; x.nrItalians = i + 1; x.nrMaidens = i + 1; rides << x; rides << x; } //seems like Qt is smart enough to know what to do with the widget: ui.show(); QObject::connect(&ui, SIGNAL(back()), this, SLOT(back())); QObject::connect(&ui, SIGNAL(forward()), this, SLOT(forward())); QObject::connect(&ui, SIGNAL(fileChosen(QString)), this, SLOT(openFile(QString))); QObject::connect(&ui, SIGNAL(speedChanged(double)), this, SLOT(changeSpeed(double))); QObject::connect(&ui, SIGNAL(start()), this, SLOT(toggleStart())); QObject::connect(&ui, SIGNAL(random()), this, SLOT(random())); }
void MaidensUi::openFile() { QString fileName = QFileDialog::getOpenFileName(this, "Select a route file"); if (fileName != "") emit fileChosen(fileName); }