void CFileBrowser::saveFileToDevice(void){ //Copy file to the device QFileDialog fileDialog; connect(&fileDialog, SIGNAL(filesSelected(QStringList)), this, SLOT(saveFileToDeviceSelected(QStringList)), Qt::QueuedConnection); fileDialog.setFileMode(QFileDialog::ExistingFiles); fileDialog.exec(); fileDialog.hide(); }
void MainWindow::OpenFileShader(void){ QFileDialog *fd; QString filter; fd = new QFileDialog(); fd->setDirectory(sampleDir); FileName = fd->getOpenFileName(this,tr("Open Shader Files"),sampleDir,"Shader Files ( *.vert | *.frag)", &filter); fd->hide(); if (!FileName.isEmpty()){ glwidget->setShaderFile(FileName); glwidget->loadShader(); } }
// CWFSecondPage CWSecondPage::CWSecondPage(QWidget *parent) : DWizardPage(tr("Configure KToon"), parent) { setPixmap( QPixmap(wizard2_xpm) ); DVHBox *container = new DVHBox(0, Qt::Vertical); container->boxLayout()->setAlignment(Qt::AlignTop); new QLabel(tr("<h3>Step 1<h3>"), container); new QLabel(tr("Choose your KToon installation directory"), container); DVHBox *hbox1 = new DVHBox(container, Qt::Horizontal); m_kthome = new QLineEdit(QString::fromLocal8Bit(::getenv("KTOON_HOME")), hbox1); connect(m_kthome, SIGNAL(textChanged(const QString &)), this, SLOT(verify(const QString &))); m_kthome->setToolTip(tr("Choose the directory where KToon is installed")); QPushButton *button = new QPushButton(tr("Browse..."), hbox1); QFileDialog *fd = new QFileDialog(hbox1); connect(fd, SIGNAL(currentChanged ( const QString & )), m_kthome, SLOT(setText(const QString &))); fd->setFileMode(QFileDialog::Directory); fd->setModal(true); fd->hide(); connect(button, SIGNAL(clicked()), fd, SLOT(show())); new QLabel(tr("Choose a temporal directory"), container); DVHBox *hbox2 = new DVHBox(container, Qt::Horizontal); m_ktrepos = new QLineEdit(QDir::tempPath(),hbox2); connect(m_ktrepos, SIGNAL(textChanged(const QString &)), this, SLOT(verify(const QString &))); m_ktrepos->setToolTip(tr("Choose the directory for temporal files")); QFileDialog *fd2 = new QFileDialog(hbox2); connect(fd2, SIGNAL(currentChanged ( const QString & )), m_ktrepos, SLOT(setText(const QString &))); fd2->hide(); fd2->setFileMode(QFileDialog::Directory); fd2->setModal(true); QPushButton *button2 = new QPushButton(tr("Browse..."), hbox2); connect(button2, SIGNAL(clicked()), fd2, SLOT(show())); setWidget(container); }
/** * @brief Loads a LED-Matrix animation from a .txt File and show it on the LED-Matrix * */ void MainWindow::on_LoadAnimBTN_clicked() { if(m_ui->AnimSequence->text().isEmpty() == true) { QMessageBox::critical(this, "Error", "Please enter the sequence of the animation!", QMessageBox::Ok); return; } else { QFileDialog dia; // = QFileDialog::getOpenFileName(this, tr("Open file"), "/home/pi/LEDMatrix/", tr("Text Files (*.txt)")); QString fileName = dia.getOpenFileName(this, tr("Open file"), "/home/pi/LEDMatrix/", tr("Text Files (*.txt)")); dia.hide(); ifstream file; file.open(fileName.toStdString(), ios_base::in); char c; string line; unsigned char* cArray = new unsigned char[64]; while(getline(file, line)) { int count = 0; for (int i = 0; i < line.length(); i++) { c = line[i]; if(c != ' ') { cArray[count] = static_cast<unsigned char>(c); count++; } } Update(cArray); sleep_for(seconds(m_ui->AnimSequence->text().toInt())); } file.close(); } }