void CFileBrowser::saveFileToDeviceSelected(QStringList filenames){
    CNotify notify;

    if( copyFilesToDevice(link(), filenames, ui->tree->currentItem()->text(1)) == false ){
        notify.execLinkError(link_errno);
    } else {
        notify.updateStatus("File Saved");
        refresh();
    }
}
Beispiel #2
0
/*! \details This is the main window constructor.  It initializes the GUI as
 * as well as the USB Link driver.
 *
 *
 */
Caoslink::Caoslink(QWidget *parent) :
  QMainWindow(parent),
  ui(new Ui::Caoslink)
{
  CNotify notify;
  notify.updateStatus("");
  qDebug("CAOS Init");
  CLink * linkDevice;
  QCoreApplication::setOrganizationName("CoActionOS, Inc");
  QCoreApplication::setOrganizationDomain("coactionos.com");
  QCoreApplication::setApplicationName("CoActionOS Link");
  QCoreApplication::setApplicationVersion(COACTIONOS_LINK_VERSION);

  CFont::init();
  link_set_debug(1);

  ui->setupUi(this);
  linkDevice = ui->connectWidget->clink();
  ui->caosInterface->setLink(linkDevice);
  ui->progressBar->setVisible(false);

  //Connect link thread
  connect(linkDevice, SIGNAL(reconnectSignal(bool)), ui->connectWidget, SLOT(connectRequested(bool)));
  ui->connectWidget->setObjectName("connectWidget");
  ui->statusBar->setObjectName("statusBar");

  QFile file(":/data/CStyle.css");
  if(file.open(QFile::ReadOnly)) {
      QString StyleSheet = QLatin1String(file.readAll());
      file.close();
#ifdef Q_WS_WIN
      file.setFileName(":/data/CStyle-win32.css");
      if( file.open(QFile::ReadOnly)){
          StyleSheet += QLatin1String(file.readAll());
          file.close();
        }
#endif
      qApp->setStyleSheet(StyleSheet);
    }

  CNotify::setUpdateObjects(ui->statusBar, ui->progressBar);
  qDebug("CAOS Init Complete");

}
bool CFileBrowser::copyDirToDevice(CLink * d, QString srcDir, QString targetDir){
    QDir dir(srcDir);
    CNotify notify;
    QStringList files;
    bool ret;
    int i;
    files = dir.entryList(QDir::Files);
    for(i=0; i < files.size(); i++){
        ret = copyFileToDevice(d,
                             dir.path() + "/" + files.at(i),
                             targetDir
                             );
        if( ret < 0 ){
            return false;
        }
        notify.updateStatus("Copied " + files.at(i));
    }
    return true;
}