Пример #1
0
void ActionThread::run()
{
    d->running = true;

    while (d->running)
    {
        ActionThreadPriv::Task* t = 0;
        {
            QMutexLocker lock(&d->mutex);

            if (!d->todo.isEmpty())
            {
                t = d->todo.takeFirst();
            }
            else
            {
                d->condVar.wait(&d->mutex);
            }
        }

        if (t)
        {
            ActionData ad1;
            ad1.fileUrl = t->item.m_itemUrl;
            ad1.status  = ActionData::BatchStarted;
            emit starting(ad1);

            // Loop with all batch tools operations to apply on item.

            d->cancel          = false;
            int        index   = 0;
            bool       success = false;
            KUrl       outUrl  = t->item.m_itemUrl;
            KUrl       inUrl;
            KUrl::List tmp2del;
            DImg       tmpImage;
            QString    errMsg;

            for (BatchToolMap::const_iterator it = t->item.m_toolsMap.constBegin();
                 !d->cancel && (it != t->item.m_toolsMap.constEnd()) ; ++it)
            {
                index                      = it.key();
                BatchToolSet set           = it.value();
                d->tool                    = set.tool;
                BatchToolSettings settings = set.settings;
                inUrl                      = outUrl;

                kDebug() << "Tool Index: " << index;

                ActionData ad2;
                ad2.fileUrl = t->item.m_itemUrl;
                ad2.status  = ActionData::TaskStarted;
                ad2.index   = index;
                emit finished(ad2);

                d->tool->setImageData(tmpImage);
                d->tool->setWorkingUrl(d->workingUrl);
                d->tool->setRawDecodingSettings(d->rawDecodingSettings);
                d->tool->setResetExifOrientationAllowed(d->exifSetOrientation);
                d->tool->setLastChainedTool(index == t->item.m_toolsMap.count());
                d->tool->setInputUrl(inUrl);
                d->tool->setSettings(settings);
                d->tool->setInputUrl(inUrl);
                d->tool->setOutputUrlFromInputUrl();

                outUrl   = d->tool->outputUrl();
                success  = d->tool->apply();
                tmpImage = d->tool->imageData();
                errMsg   = d->tool->errorDescription();
                tmp2del.append(outUrl);
                d->tool  = 0;

                if (success && !d->cancel)
                {
                    ActionData ad3;
                    ad3.fileUrl = t->item.m_itemUrl;
                    ad3.status  = ActionData::TaskDone;
                    ad3.index   = index;
                    emit finished(ad3);
                }
                else if (d->cancel)
                {
                    ActionData ad4;
                    ad4.fileUrl = t->item.m_itemUrl;
                    ad4.status  = ActionData::TaskCanceled;
                    ad4.index   = index;
                    emit finished(ad4);

                    ActionData ad5;
                    ad5.fileUrl = t->item.m_itemUrl;
                    ad5.status  = ActionData::BatchCanceled;
                    emit finished(ad5);

                    break;
                }
                else
                {
                    ActionData ad4;
                    ad4.fileUrl = t->item.m_itemUrl;
                    ad4.status  = ActionData::TaskFailed;
                    ad4.index   = index;
                    emit finished(ad4);

                    ActionData ad5;
                    ad5.fileUrl = t->item.m_itemUrl;
                    ad5.status  = ActionData::BatchFailed;

                    if (!errMsg.isEmpty())
                    {
                        ad5.message = errMsg;
                    }

                    emit finished(ad5);

                    break;
                }
            }

            if (success && !d->cancel)
            {
                // if success, we don't remove last output tmp url.
                tmp2del.removeAll(outUrl);

                ActionData ad6;
                ad6.fileUrl = t->item.m_itemUrl;
                ad6.destUrl = outUrl;
                ad6.status  = ActionData::BatchDone;
                emit finished(ad6);
            }

            // Clean up all tmp url.

            for (KUrl::List::const_iterator it = tmp2del.constBegin(); it != tmp2del.constEnd() ; ++it)
            {
                unlink(QFile::encodeName((*it).toLocalFile()));
            }
        }

        delete t;
    }
}
Пример #2
0
/*
 * This Event method is called whenever the user presses a key
 */
void MainWindow::keyPressEvent(QKeyEvent* ke)
{
  if (ke->key() == Qt::Key_Return || ke->key() == Qt::Key_Enter)
  {
    //We are searching for AUR foreign packages...
    if (isRemoteSearchSelected() && m_leFilterPackage->hasFocus() && m_cic == NULL)
    {
      if (m_leFilterPackage->text().size() < 2)
      {
        QMessageBox::information(this, StrConstants::getWarning(), StrConstants::getSearchStringIsShort(), QMessageBox::Ok);
        return;
      }

      //ui->twGroups->setEnabled(false);

      QFuture<QList<PackageListData> *> f;
      disconnect(&g_fwRemote, SIGNAL(finished()), this, SLOT(preBuildRemotePackageList()));
      m_cic = new CPUIntensiveComputing();
      f = QtConcurrent::run(searchRemotePackages, m_leFilterPackage->text());
      g_fwRemote.setFuture(f);
      connect(&g_fwRemote, SIGNAL(finished()), this, SLOT(preBuildRemotePackageList()));
    }
    //We are searching for packages that own some file typed by user...
    else if (isSearchByFileSelected() && m_leFilterPackage->hasFocus() && m_cic == NULL)
    {
      //ui->twGroups->setEnabled(false);

      QFuture<QString> f;
      disconnect(&g_fwPackageOwnsFile, SIGNAL(finished()), this, SLOT(positionInPkgListSearchByFile()));
      m_cic = new CPUIntensiveComputing();
      f = QtConcurrent::run(searchPacmanPackagesByFile, m_leFilterPackage->text());
      g_fwPackageOwnsFile.setFuture(f);
      connect(&g_fwPackageOwnsFile, SIGNAL(finished()), this, SLOT(positionInPkgListSearchByFile()));
    }
    //We are probably inside 'Files' tab...
    else
    {
      QTreeView *tvPkgFileList =
          ui->twProperties->widget(ctn_TABINDEX_FILES)->findChild<QTreeView*>("tvPkgFileList");

      if(tvPkgFileList)
      {
        if(tvPkgFileList->hasFocus())
        {
          openFile();
        }
      }
    }
  }
  else if(ke->key() == Qt::Key_Escape)
  {
    if(m_leFilterPackage->hasFocus())
    {
      m_leFilterPackage->clear();
    }
  }
  else if(ke->key() == Qt::Key_Delete)
  {
    onPressDelete();
  }    
  else if(ke->key() == Qt::Key_1 && ke->modifiers() == Qt::AltModifier)
  {
    changeTabWidgetPropertiesIndex(ctn_TABINDEX_INFORMATION);
  }
  else if(ke->key() == Qt::Key_2 && ke->modifiers() == Qt::AltModifier)
  {
    ui->twProperties->setCurrentIndex(ctn_TABINDEX_FILES);
    refreshTabFiles(false, true);
  }
  else if(ke->key() == Qt::Key_3 && ke->modifiers() == Qt::AltModifier)
  {
    changeTabWidgetPropertiesIndex(ctn_TABINDEX_TRANSACTION);
  }
  else if(ke->key() == Qt::Key_4 && ke->modifiers() == Qt::AltModifier)
  {
    changeTabWidgetPropertiesIndex(ctn_TABINDEX_OUTPUT);
  }
  else if(ke->key() == Qt::Key_5 && ke->modifiers() == Qt::AltModifier)
  {
    changeTabWidgetPropertiesIndex(ctn_TABINDEX_NEWS);
  }
  else if(ke->key() == Qt::Key_6 && ke->modifiers() == Qt::AltModifier)
  {
    changeTabWidgetPropertiesIndex(ctn_TABINDEX_HELPUSAGE);
  }
  else if(ke->key() == Qt::Key_F4)
  {
    openTerminal();
  }
  /*else if(ke->key() == Qt::Key_F5)
  {
    metaBuildPackageList();
  }*/
  else if(ke->key() == Qt::Key_F6)
  {
    openDirectory();
  }
  else if (ke->key() == Qt::Key_F10)
  {
    maximizePackagesTreeView(false);
  }
  else if (ke->key() == Qt::Key_F12)
  {
    maximizePropertiesTabWidget(false);
  }
  else if(ke->key() == Qt::Key_C && ke->modifiers() == Qt::ControlModifier)
  {
    copyFullPathToClipboard();
  }
  else if(ke->key() == Qt::Key_L && ke->modifiers() == Qt::ControlModifier)
  {
    m_leFilterPackage->setFocus();
    m_leFilterPackage->selectAll();
  }
  else if(ke->key() == Qt::Key_F && ke->modifiers() == Qt::ControlModifier)
  {
    if (m_commandExecuting != ectn_NONE) return;

    if (isPropertiesTabWidgetVisible() &&
        (ui->twProperties->currentIndex() == ctn_TABINDEX_INFORMATION ||
         ui->twProperties->currentIndex() == ctn_TABINDEX_OUTPUT ||
         ui->twProperties->currentIndex() == ctn_TABINDEX_NEWS ||
         ui->twProperties->currentIndex() == ctn_TABINDEX_HELPUSAGE))
    {
      QTextBrowser *tb = ui->twProperties->currentWidget()->findChild<QTextBrowser*>("textBrowser");
      SearchBar *searchBar = ui->twProperties->currentWidget()->findChild<SearchBar*>("searchbar");

      if (tb && tb->toPlainText().size() > 0 && searchBar)
      {
        if (searchBar) searchBar->show();
      }
    }
    else if (isPropertiesTabWidgetVisible() && ui->twProperties->currentIndex() == ctn_TABINDEX_FILES)
    {
      QTreeView *tb = ui->twProperties->currentWidget()->findChild<QTreeView*>("tvPkgFileList");
      SearchBar *searchBar = ui->twProperties->currentWidget()->findChild<SearchBar*>("searchbar");

      if (tb && tb->model()->rowCount() > 0 && searchBar)
      {
        if (searchBar) searchBar->show();
      }
    }
  }
  else if(ke->key() == Qt::Key_D && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier))
  {
    //The user wants to know which packages have no description!
    showPackagesWithNoDescription();
  }
  else if(ke->key() == Qt::Key_G && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier))
  {
    //The user wants to go to "Display All groups"
    if (!isAllCategoriesSelected())
    {
      ui->twGroups->setCurrentItem(m_AllGroupsItem);
    }
  }
  else if(ke->key() == Qt::Key_C && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier))
  {
    if (m_commandExecuting == ectn_NONE)
    {
      doCleanCache(); //If we are not executing any command, let's clean the cache
    }
  }
  else if(ke->key() == Qt::Key_R && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier))
  {
    if (m_commandExecuting == ectn_NONE)
    {
      doRemovePacmanLockFile(); //If we are not executing any command, let's remove Pacman's lock file
    }
  } 
  else if(ke->key() == Qt::Key_T && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier)
          && m_initializationCompleted)
  {   
    if (m_commandExecuting != ectn_NONE) return;

    QStringList terminals = Terminal::getListOfAvailableTerminals();

    if (terminals.count() > 2)
    {
      int index = terminals.indexOf(SettingsManager::getTerminal());
      int newIndex = selectTerminal(index);

      if (index != newIndex)
      {
        SettingsManager::setTerminal(terminals.at(newIndex));
      }
    }
  }

  /*else if(ke->key() == Qt::Key_Z && ke->modifiers() == (Qt::ShiftModifier|Qt::ControlModifier))
  {
    parseXBPSProcessOutput("Updating configuration file `/etc/skel/.bashrc");
  }*/

  else ke->ignore();
}
Пример #3
0
void UserContextMenu::showContextMenu(const QPoint &pos, const QString &userName, UserLevelFlags userLevel, int playerId)
{
    aUserName->setText(userName);
    
    QMenu *menu = new QMenu(static_cast<QWidget *>(parent()));
    menu->addAction(aUserName);
    menu->addSeparator();
    menu->addAction(aDetails);
    menu->addAction(aShowGames);
    menu->addAction(aChat);
    if (userLevel.testFlag(ServerInfo_User::IsRegistered) && (tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsRegistered)) {
        menu->addSeparator();
        if (tabSupervisor->getUserListsTab()->getBuddyList()->getUsers().contains(userName))
            menu->addAction(aRemoveFromBuddyList);
        else
            menu->addAction(aAddToBuddyList);
        if (tabSupervisor->getUserListsTab()->getIgnoreList()->getUsers().contains(userName))
            menu->addAction(aRemoveFromIgnoreList);
        else
            menu->addAction(aAddToIgnoreList);
    }
    if (game && (game->isHost() || !tabSupervisor->getAdminLocked())) {
        menu->addSeparator();
        menu->addAction(aKick);
    }
    if (!tabSupervisor->getAdminLocked()) {
        menu->addSeparator();
        menu->addAction(aBan);
    }
    bool anotherUser = userName != QString::fromStdString(tabSupervisor->getUserInfo()->name());
    aChat->setEnabled(anotherUser);
    aShowGames->setEnabled(anotherUser);
    aAddToBuddyList->setEnabled(anotherUser);
    aRemoveFromBuddyList->setEnabled(anotherUser);
    aAddToIgnoreList->setEnabled(anotherUser);
    aRemoveFromIgnoreList->setEnabled(anotherUser);
    aKick->setEnabled(anotherUser);
    aBan->setEnabled(anotherUser);
    
    QAction *actionClicked = menu->exec(pos);
    if (actionClicked == aDetails) {
        UserInfoBox *infoWidget = new UserInfoBox(client, true, static_cast<QWidget *>(parent()), Qt::Dialog | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
        infoWidget->setAttribute(Qt::WA_DeleteOnClose);
        infoWidget->updateInfo(userName);
    } else if (actionClicked == aChat)
        emit openMessageDialog(userName, true);
    else if (actionClicked == aShowGames) {
        Command_GetGamesOfUser cmd;
        cmd.set_user_name(userName.toStdString());
        
        PendingCommand *pend = client->prepareSessionCommand(cmd);
        connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(gamesOfUserReceived(Response, CommandContainer)));
        
        client->sendCommand(pend);
    } else if (actionClicked == aAddToBuddyList) {
        Command_AddToList cmd;
        cmd.set_list("buddy");
        cmd.set_user_name(userName.toStdString());
        
        client->sendCommand(client->prepareSessionCommand(cmd));
    } else if (actionClicked == aRemoveFromBuddyList) {
        Command_RemoveFromList cmd;
        cmd.set_list("buddy");
        cmd.set_user_name(userName.toStdString());
        
        client->sendCommand(client->prepareSessionCommand(cmd));
    } else if (actionClicked == aAddToIgnoreList) {
        Command_AddToList cmd;
        cmd.set_list("ignore");
        cmd.set_user_name(userName.toStdString());
        
        client->sendCommand(client->prepareSessionCommand(cmd));
    } else if (actionClicked == aRemoveFromIgnoreList) {
        Command_RemoveFromList cmd;
        cmd.set_list("ignore");
        cmd.set_user_name(userName.toStdString());
        
        client->sendCommand(client->prepareSessionCommand(cmd));
    } else if (actionClicked == aKick) {
        Command_KickFromGame cmd;
        cmd.set_player_id(playerId);
        game->sendGameCommand(cmd);
    } else if (actionClicked == aBan) {
        Command_GetUserInfo cmd;
        cmd.set_user_name(userName.toStdString());
        
        PendingCommand *pend = client->prepareSessionCommand(cmd);
        connect(pend, SIGNAL(finished(Response, CommandContainer, QVariant)), this, SLOT(banUser_processUserInfoResponse(Response)));
        
        client->sendCommand(pend);
    }
    
    delete menu;
}
Пример #4
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    mSettings(new QSettings(this)),
    mSavePath(""),
    mProgressBar(new QProgressBar(this)),
    mStatusBar(new QStatusBar(this)),
    mToolBar(new QToolBar(this)),
    mMenuBar(new QMenuBar(this)),
    mTabWidget(new QTabWidget(this)),

    // Menus
    mFileMenu(new QMenu(tr("File"), this)),
    mEditMenu(new QMenu(tr("Edit"), this)),
    mToolsMenu(new QMenu(tr("Tools"), this)),
    mHelpMenu(new QMenu(tr("Help"), this)),

    //Actions
    mActionExit(new QAction(QP_ICON("application-exit"), tr("Exit"), this)),
    mActionOpen(new QAction(QP_ICON("document-open"),tr("Open"), this)),
    mActionSave(new QAction(QP_ICON("document-save"),tr("Save"), this)),
    mActionSaveAs(new QAction(QP_ICON("document-save-as"),tr("Save As"), this)),
    mActionPrint(new QAction(QP_ICON("document-print"),tr("Print"), this)),

    mActionClear(new QAction(QP_ICON("edit-clear"), tr("Clear"), this)),
    mActionUndo(new QAction(QP_ICON("edit-undo"),tr("Undo"), this)),
    mActionRedo(new QAction(QP_ICON("edit-redo"),tr("Redo"), this)),
    mActionSwap(new QAction(QP_ICON("system-switch-user"), tr("Swap"), this)),
    mActionOptions(new QAction(QP_ICON("configure"), tr("Options"), this)),

    mActionAbout(new QAction(QIcon::fromTheme("help-about"), tr("About"), this)),
    mActionAboutQt(new QAction(tr("About Qt"), this)),

    mTranslationWidget(new QPTranslationWidget(this)),
    mDictionaryWidget(new DictionaryWidget(this)),
    mSettingsDialog(new Config(this)),

    mPluginsConfig(new PluginsConfig),
    mTranslatorsConfig(new QPTranslatorsConfig(this)),
    mLanguageConfig(new LanguageConfig(this)),
    mDictionaryConfig(new DictionaryConfig(this)),
    mCommonConfig(new CommonConfig(this))
{
    setWindowTitle(qApp->applicationName());

    mActionOpen->setShortcut(QKeySequence("Ctrl+O"));
    mActionSave->setShortcut(QKeySequence("Ctrl+S"));
    mActionSaveAs->setShortcut(QKeySequence("Ctrl+Shift+S"));
    mActionPrint->setShortcut(QKeySequence("Ctrl+P"));
    mActionExit->setShortcut(QKeySequence("Ctrl+Q"));

    mActionUndo->setShortcut(QKeySequence("Ctrl+U"));
    mActionRedo->setShortcut(QKeySequence("Ctrl+R"));
    mActionSwap->setShortcut(QKeySequence("Ctrl+Alt+S"));

    mFileMenu->addAction(mActionOpen);
    mFileMenu->addSeparator();
    mFileMenu->addAction(mActionSave);
    mFileMenu->addAction(mActionSaveAs);
    mFileMenu->addAction(mActionPrint);
    mFileMenu->addSeparator();
    mFileMenu->addAction(mActionExit);

    mEditMenu->addAction(mActionClear);
    mEditMenu->addSeparator();
    mEditMenu->addAction(mActionUndo);
    mEditMenu->addAction(mActionRedo);
    mEditMenu->addAction(mActionSwap);
    mEditMenu->addSeparator();
    mEditMenu->addAction(mActionOptions);

    mHelpMenu->addAction(mActionAbout);
    mHelpMenu->addAction(mActionAboutQt);

    mMenuBar->addMenu(mFileMenu);
    mMenuBar->addMenu(mEditMenu);
    mMenuBar->addMenu(mHelpMenu);

    mToolBar->addAction(mActionOpen);
    mToolBar->addAction(mActionSave);
    mToolBar->addAction(mActionSaveAs);
    mToolBar->addSeparator();
    mToolBar->addAction(mActionClear);
    mToolBar->addAction(mActionUndo);
    mToolBar->addAction(mActionRedo);
    mToolBar->setMovable(false);

    mTabWidget->setTabPosition(QTabWidget::West);

    this->setCentralWidget(mTabWidget);
    this->setStatusBar(mStatusBar);
    this->setMenuBar(mMenuBar);

    mProgressBar->setMaximum(0);
    mProgressBar->setMinimum(0);
    mProgressBar->setValue(0);
    mStatusBar->addPermanentWidget(mProgressBar);

    mProgressBar->setFormat("");
    mProgressBar->setFixedWidth(200);
    stopProgressBar();

    this->addToolBar(mToolBar);
    this->addToolBar(mDictionaryWidget->getToolBar());
    this->addToolBar(mTranslationWidget->mainToolBar());

    mTabWidget->insertTab(mTabWidget->count(), mTranslationWidget, QP_ICON("translator"), tr("Translator"));
    mTabWidget->insertTab(mTabWidget->count(), mDictionaryWidget, QP_ICON("dictionary"), tr("Dictionary"));

    if(mTabWidget->count() > 1)
        mTabWidget->setCurrentIndex(0);

    // Configuring settings pages
    mSettingsDialog->addPage(mTranslatorsConfig, "Translators");
    mSettingsDialog->addPage(mDictionaryConfig, "Dictionaries");
    mSettingsDialog->addPage(mLanguageConfig, "Languages");
    mSettingsDialog->addPage(mPluginsConfig, "Plugins");
    mSettingsDialog->addPage(mCommonConfig, "Generic");

    connect(mActionOpen, SIGNAL(triggered()), this, SLOT(open()));
    connect(mActionPrint, SIGNAL(triggered()), this, SLOT(print()));
    connect(mActionSave, SIGNAL(triggered()), this, SLOT(save()));
    connect(mActionSaveAs, SIGNAL(triggered()), this, SLOT(saveAs()));

    connect(mActionExit, SIGNAL(triggered()), this, SLOT(exit()));
    connect(mActionClear, SIGNAL(triggered()), this, SLOT(clear()));
    connect(mActionUndo, SIGNAL(triggered()), this, SLOT(undo()));
    connect(mActionRedo, SIGNAL(triggered()), this, SLOT(redo()));
    connect(mActionSwap, SIGNAL(triggered()), mTranslationWidget, SLOT(swap()));
    connect(mActionOptions, SIGNAL(triggered()), mSettingsDialog, SLOT(show()));
    connect(mActionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
    connect(mActionAbout, SIGNAL(triggered()), this, SLOT(about()));

    // Widgets , Dialogs, etc
    connect(mSettingsDialog, SIGNAL(accepted()), this, SLOT(onConfigAccept()));
    connect(mTabWidget, SIGNAL(currentChanged(int)), this, SLOT(onIndexChange(int)));

    connect(mTranslatorsConfig, SIGNAL(translatorIndexChanged(int)), mTranslationWidget, SLOT(setTranslatorIndex(int)));
    connect(mTranslationWidget, SIGNAL(translatorIndexChanged(int)), mTranslatorsConfig, SLOT(setTranslatorIndex(int)));
    connect(mTranslationWidget, SIGNAL(translatorIndexChanged(int)), this, SLOT(updateTranslatorConfig()));

    connect(mTranslationWidget, SIGNAL(message(QString)), this, SLOT(setStatusBarMessage(QString)));
    connect(mDictionaryWidget, SIGNAL(message(QString)), this, SLOT(setStatusBarMessage(QString)));

    connect(mTranslationWidget, SIGNAL(started()), this, SLOT(startProgressBar()));
    connect(mDictionaryWidget, SIGNAL(started()), this, SLOT(startProgressBar()));

    connect(mTranslationWidget, SIGNAL(finished()), this, SLOT(stopProgressBar()));
    connect(mDictionaryWidget, SIGNAL(finished()), this, SLOT(stopProgressBar()));

    mSettings->beginGroup(QP_MAINWINDOW_CONFIG_GROUP);

    // Read configs
    updateTranslatorConfig();
    onConfigAccept();

    mTranslationWidget->setTranslatorsNames(mTranslatorsConfig->getTranslatorsNames());

    mTranslatorsConfig->read();

    readCfg();

}
void StdIOClientInterface::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
    if (exitStatus == QProcess::CrashExit)
        emit error(tr("Crashed with exit code %1: %2").arg(exitCode, m_process.error()));
    emit finished();
}
Пример #6
0
ImageView::ImageView(const ThumbList &itemList,
                     int *pos, int slideShow, int sortorder)
    : m_pos(*pos),
      m_savedPos(pos),

      // Common slideshow variables
      m_slideshow_sequencing(slideShow),

      m_listener(this),
      m_slideshow_sequence(ComposeSlideshowSequence(slideShow))
{

    int xbase, ybase, screenwidth, screenheight;
    GetMythUI()->GetScreenSettings(xbase, screenwidth,  m_wmult,
                                ybase, screenheight, m_hmult);
    m_screenSize = QSize(screenwidth, screenheight);

    // --------------------------------------------------------------------

    bool recurse = gCoreContext->GetBoolSetting("GalleryRecursiveSlideshow", false);

    ThumbItem *origItem = nullptr;
    if (m_pos < itemList.size())
        origItem = itemList.at(m_pos);

    ThumbList fileList, dirList;
    LoadAlbumRunnable::filterDirectories(itemList, fileList, dirList);
    ImageView::AddItems(fileList);

    if (recurse)
    {
        // Load pictures from all directories on a different thread.
        m_loaderRunnable = new LoadAlbumRunnable(this, dirList, sortorder,
                                                 m_slideshow_sequencing);
        m_loaderThread = new MThread("LoadAlbum", m_loaderRunnable);
        QObject::connect(m_loaderThread->qthread(), SIGNAL(finished()),
                &m_listener, SLOT(FinishLoading()));
        m_loaderThread->start();

        // Wait for at least one image to be loaded.
        {
            QMutexLocker guard(&m_itemListLock);
            while (m_itemList.empty() && !m_finishedLoading)
            {
                m_imagesLoaded.wait(&m_itemListLock);
            }
        }
    }

    // --------------------------------------------------------------------

    // since we remove dirs item position might have changed
    if (origItem)
        m_pos = m_itemList.indexOf(origItem);

    m_pos = (!origItem || (m_pos == -1)) ? 0 : m_pos;
    m_slideshow_sequence->set(m_pos);

    // --------------------------------------------------------------------

    m_slideshow_frame_delay = gCoreContext->GetNumSetting("SlideshowDelay", 0);
    m_slideshow_frame_delay = (!m_slideshow_frame_delay) ?
        2 : m_slideshow_frame_delay;
    m_slideshow_frame_delay_state = m_slideshow_frame_delay * 1000;

    // --------------------------------------------------------------------

    if (slideShow == 2)
    {
        m_slideshow_mode = QT_TR_NOOP("Random Slideshow");
    }
    else if (slideShow == 3)
    {
        m_slideshow_mode = QT_TR_NOOP("Seasonal Slideshow");
    }
    else
    {
        m_slideshow_mode = QT_TR_NOOP("Slideshow");
    }
}
Пример #7
0
void SheerCloudLink::Download(QString file, QByteArray & out){
  m_reply = get( QNetworkRequest( QUrl( m_location + "/download?login="******"&password="******"&file=" + file ) ));
  m_out = &out;
  connect(m_reply, SIGNAL(finished()), SLOT(download_completed()));
  connect(m_reply, SIGNAL(downloadProgress ( qint64 , qint64 ) ), SIGNAL(progress ( qint64 , qint64 ) ));
};
Пример #8
0
	void CompressFileJob::start()
	{
		compress_thread = new CompressThread(file);
		connect(compress_thread,SIGNAL(finished()),this,SLOT(compressThreadFinished()),Qt::QueuedConnection);
		compress_thread->start();
	}
Пример #9
0
void DecompressFileJob::start()
{
    decompress_thread = new DecompressThread(file,dest);
    connect(decompress_thread,SIGNAL(finished()),this,SLOT(decompressThreadFinished()),Qt::QueuedConnection);
    decompress_thread->start();
}
Пример #10
0
	void deflate_writer::finish() {
		AIO_PRE_CONDITION(valid() && !finished());
		m_imp->finish();
	}
Пример #11
0
void    Profilmplayer::on_finish(int po)
{
	Q_UNUSED(po);
    emit finished();
}
Пример #12
0
	bool deflate_writer::writable() const{
		AIO_PRE_CONDITION(valid() && !finished());
		return true;
	}
Пример #13
0
	range<const byte*> deflate_writer::write(const range<const byte*>& buf){
		AIO_PRE_CONDITION(valid() && !finished());
		return m_imp->write(buf);
	}
Пример #14
0
	deflate_writer::~deflate_writer(){
		if (!finished())
			finish();
	}
Пример #15
0
void MainWindow::initialize() {
    // Get the news information
    QNetworkRequest request;
    request.setUrl(QUrl(NewsURL));
    
    _newsReply = _networkManager.get(request);
    QObject::connect(_newsReply, SIGNAL(finished()),
            this, SLOT(newsReadyRead())
    );
    QObject::connect(_newsReply, SIGNAL(error(QNetworkReply::NetworkError)),
            this, SLOT(newsNetworkError())
    );

    _shortcutWidget = new ShortcutWidget(this, Qt::Popup | Qt::Dialog);
    _shortcutWidget->setWindowModality(Qt::WindowModal);
    _shortcutWidget->hide();

    _syncWidget = new SyncWidget(this, Qt::Popup | Qt::Dialog);
    _syncWidget->setWindowModality(Qt::WindowModal);
    _syncWidget->hide();

    ghoul::logging::LogManager::initialize(ghoul::logging::LogManager::LogLevel::Debug);
    LogMgr.addLog( std::make_unique< ghoul::logging::ConsoleLog >() );
    // TODO: This can crash the system in cases where the logfile can't be created ---abock
    LogMgr.addLog( std::make_unique< ghoul::logging::HTMLLog >("LauncherLog.html", ghoul::logging::HTMLLog::Append::No) );
    LogMgr.addLog( std::make_unique< QLog >() );

    std::string configurationFile = _configurationFile;
    
    _configuration = new openspace::ConfigurationManager;
    configurationFile = _configuration->findConfiguration( configurationFile );
    _configuration->loadFromFile(configurationFile);

    // Load all available scenes
    QString modulesDirectory = QString::fromStdString(absPath("${SCENE}"));
    QDir d(modulesDirectory);
    d.setFilter(QDir::Files);
    QFileInfoList list = d.entryInfoList();
    _scenes->addItem("Use Default");
    for (const QFileInfo& i : list) {
        QString file = i.fileName();
        file = file.replace(".scene", "");
        _sceneFiles.insert(file, i.absoluteFilePath());
        _scenes->addItem(file);
    }
    _scenes->setCurrentText("Use Default");
    _syncWidget->setSceneFiles(_sceneFiles);

    // Load all available configuration files
    QString configurationDirectory = QString::fromStdString(absPath("${SGCT}"));
    d = QDir(configurationDirectory);
    d.setFilter(QDir::Files);
    list = d.entryInfoList();
    _configurations->addItem("Use Default");
    for (const QFileInfo& i : list) {
        QString file = i.fileName();
        file = file.replace(".xml", "");
        _configurationFiles.insert(file, i.absoluteFilePath());
        _configurations->addItem(file);
    }
    _configurations->setCurrentText("Use Default");
}
Пример #16
0
int Sprint::handleGameOverInput()
{
	pauseMusic();
	
	recordBestScore();
	
	if(Game::gameOver())
	{
		setBackground(SPRINT_GAMEOVER_IMG);
		
		sf::String lines, time;
		
		lines.SetFont(vador);
		lines.SetText(toString(getLinesCompleted()) + " / 40");
		
		time.SetFont(vador);
		time.SetText(timer.format());
		
		lines.SetSize(30.0);
		time.SetSize(30.0);
		
		lines.SetPosition(300.0, 187.0);
		time.SetPosition(300.0, 222.0);
		
		renderArea->Draw(lines);
		renderArea->Draw(time);
	}
	
	if(finished())
	{
		setBackground(SPRINT_FINISHED_IMG);
		
		sf::String time;
		
		time.SetText(timer.format());
		time.SetFont(vador);
		time.SetSize(48.0);
		
		time.SetPosition(245.0, 205.0);
		
		renderArea->Draw(time);
	}
	
	sf::Event event;
	
	while(renderArea->GetEvent(event))
	{
		if(event.Type == sf::Event::Closed)
			renderArea->Close();
		
		if(event.Type == sf::Event::KeyPressed)
		{
			if(event.Key.Code == sf::Key::R)
				restart();
			
			if(event.Key.Code == sf::Key::M)
				return RETURN_MAIN;
		}
	}
	
	return CONTINUE;
}
Пример #17
0
bool HttpServerResponse::end(const QByteArray &chunk)
{
    switch (priv->formattingState) {
    case Priv::STATUS_LINE:
    case Priv::END:
        return false;
    case Priv::HEADERS:
    {
        if (priv->options.testFlag(HttpServerResponse::HTTP_1_1)) {
            {
                static const char key[] = "Connection";
                if (priv->options.testFlag(HttpServerResponse::KEEP_ALIVE)) {
                    static const char value[] = "keep-alive";
                    priv->headers
                            .replace(QByteArray::fromRawData(key,
                                                             sizeof(key) - 1),
                                     QByteArray::fromRawData(value,
                                                             sizeof(value)
                                                             - 1));
                } else {
                    static const char value[] = "close";
                    priv->headers
                            .replace(QByteArray::fromRawData(key,
                                                             sizeof(key) - 1),
                                     QByteArray::fromRawData(value,
                                                             sizeof(value)
                                                             - 1));
                }
            }
            {
                static const char key[] = "Transfer-Encoding",
                        value[] = "chunked";
                priv->headers.insert(QByteArray::fromRawData(key,
                                                             sizeof(key) - 1),
                                     QByteArray::fromRawData(value,
                                                             sizeof(value)
                                                             - 1));
            }
        } else {
            static const char key[] = "Content-Length";
            priv->headers.replace(QByteArray::fromRawData(key,
                                                          sizeof(key) - 1),
                                  QByteArray::number(priv->http10Buffer.size()
                                                     + chunk.size()));
        }

        for (Headers::iterator i = priv->headers.begin()
             ;i != priv->headers.end();++i) {
            priv->device.write(i.key());
            priv->device.write(": ", 2);
            priv->device.write(i.value());
            priv->device.write(CRLF);
        }
        priv->device.write(CRLF);

        priv->formattingState = Priv::MESSAGE_BODY;
    }
    case Priv::MESSAGE_BODY:
    {
        if (chunk.size()) {
            if (priv->options.testFlag(HttpServerResponse::HTTP_1_1)) {
                priv->device.write(QByteArray::number(chunk.size(), 16));
                priv->device.write(CRLF);
            } else if (priv->http10Buffer.size()) {
                priv->device.write(priv->http10Buffer);
                priv->http10Buffer.clear();
            }
            priv->device.write(chunk);
            if (priv->options.testFlag(HttpServerResponse::HTTP_1_1))
                priv->device.write(CRLF);
        } else if (priv->http10Buffer.size()) {
            priv->device.write(priv->http10Buffer);
            priv->http10Buffer.clear();
        }
        if (priv->options.testFlag(HttpServerResponse::HTTP_1_1)) {
            priv->device.write(LAST_CHUNK);
            priv->formattingState = Priv::TRAILERS;
        } else {
            priv->device.close();
            priv->formattingState = Priv::END;
            emit finished();
            break;
        }
    }
    case Priv::TRAILERS:
    {
        priv->device.write(CRLF);
        if (!priv->options.testFlag(HttpServerResponse::KEEP_ALIVE))
            priv->device.close();

        priv->formattingState = Priv::END;
        emit finished();
    }
    } // switch (priv->formattingState)
    return true;
}
Пример #18
0
void cSSAOWorker::doWork()
{
	int quality = threadData->quality;
	int startLine = threadData->startLine;
	int width = image->GetWidth();
	int height = image->GetHeight();

	double *cosine = new double[quality];
	double *sine = new double[quality];
	for (int i = 0; i < quality; i++)
	{
		sine[i] = sin((double) i / quality * 2.0 * M_PI);
		cosine[i] = cos((double) i / quality * 2.0 * M_PI);
	}

	double scale_factor = (double) width / (quality * quality) / 2.0;
	double aspectRatio = (double) width / height;

	params::enumPerspectiveType perspectiveType = params->perspectiveType;
	double fov = params->fov;

	double intensity = params->ambientOcclusion;

	int listIndex = 0;

	int step = threadData->progressive;
	if(step == 0) step = 1;

	for (int y = startLine; y < height; y += threadData->noOfThreads)
	{
		if (threadData->list)
		{
			if (listIndex >= threadData->list->size())
			{
				continue;
			}
			if (y < threadData->list->at(listIndex))
			{
				continue;
			}
			else
			{
				listIndex++;
			}
		}
		for (int x = 0; x < width; x+=step)
		{
			double z = image->GetPixelZBuffer(x, y);
			unsigned short opacity16 = image->GetPixelOpacity(x, y);
			double opacity = opacity16 / 65535.0;
			double total_ambient = 0;

			if (z < 1e19)
			{
				//printf("SSAO point on object\n");
				double x2, y2;
				if (perspectiveType == params::perspFishEye)
				{
					x2 = M_PI * ((double) x / width - 0.5) * aspectRatio;
					y2 = M_PI * ((double) y / height - 0.5);
					double r = sqrt(x2 * x2 + y2 * y2);
					if (r != 0.0)
					{
						x2 = x2 / r * sin(r * fov) * z;
						y2 = y2 / r * sin(r * fov) * z;
					}
				}
				else if (perspectiveType == params::perspEquirectangular)
				{
					x2 = M_PI * ((double) x / width - 0.5) * aspectRatio;
					y2 = M_PI * ((double) y / height - 0.5);
					x2 = sin(fov * x2) * cos(fov * y2) * z;
					y2 = sin(fov * y2) * z;
				}
				else
				{
					x2 = ((double) x / width - 0.5) * aspectRatio;
					y2 = ((double) y / height - 0.5);
					x2 = x2 * z * fov;
					y2 = y2 * z * fov;
				}

				double ambient = 0;

				for (int angle = 0; angle < quality; angle++)
				{
					double ca, sa;
					if(params->SSAO_random_mode)
					{
						double angle = Random(62831) / 10000.0;
						ca = cos(angle);
						sa = sin(angle);
					}
					else
					{
						ca = cosine[angle];
						sa = sine[angle];
					}

					double max_diff = -1e50;

					for (double r = 1.0; r < quality; r += 1.0)
					{
						double rr = r * r * scale_factor;
						double xx = x + rr * ca;
						double yy = y + rr * sa;

						if ((int) xx == (int) x && (int) yy == (int) y) continue;
						if (xx < 0 || xx > width - 1 || yy < 0 || yy > height - 1) continue;
						double z2 = image->GetPixelZBuffer(xx, yy);

						double xx2, yy2;
						if (perspectiveType == params::perspFishEye)
						{
							xx2 = M_PI * ((double) xx / width - 0.5) * aspectRatio;
							yy2 = M_PI * ((double) yy / height - 0.5);
							double r2 = sqrt(xx2 * xx2 + yy2 * yy2);
							if (r != 0.0)
							{
								xx2 = xx2 / r2 * sin(r2 * fov) * z2;
								yy2 = yy2 / r2 * sin(r2 * fov) * z2;
							}
						}
						else if (perspectiveType == params::perspEquirectangular)
						{
							xx2 = M_PI * (xx / width - 0.5) * aspectRatio;
							yy2 = M_PI * (yy / height - 0.5);
							xx2 = sin(fov * xx2) * cos(fov * yy2) * z2;
							yy2 = sin(fov * yy2) * z2;
						}
						else
						{
							xx2 = (xx / width - 0.5) * aspectRatio;
							yy2 = (yy / height - 0.5);
							xx2 = xx2 * (z2 * fov);
							yy2 = yy2 * (z2 * fov);
						}

						double dx = xx2 - x2;
						double dy = yy2 - y2;
						double dz = z2 - z;
						double dr = sqrt(dx * dx + dy * dy);
						double diff = -dz / dr;

						if (diff > max_diff) max_diff = diff;

					}
					double max_angle = atan(max_diff);

					ambient += -max_angle / M_PI + 0.5;

				}

				total_ambient = ambient / quality;
				if (total_ambient < 0) total_ambient = 0;

			}


			for (int xx = 0; xx < step; xx++)
			{
				if (xx >= width - 1) break;
				sRGB8 colour = image->GetPixelColor(x + xx, y);
				sRGB16 pixel = image->GetPixelImage16(x + xx, y);
				double R = pixel.R + 65535.0 * colour.R / 256.0 * total_ambient * intensity * (1.0 - opacity);
				double G = pixel.G + 65535.0 * colour.G / 256.0 * total_ambient * intensity * (1.0 - opacity);
				double B = pixel.B + 65535.0 * colour.B / 256.0 * total_ambient * intensity * (1.0 - opacity);
				if (R > 65535) R = 65535;
				if (G > 65535) G = 65535;
				if (B > 65535) B = 65535;

				pixel.R = R;
				pixel.G = G;
				pixel.B = B;
				image->PutPixelImage16(x + xx, y, pixel);
			}

}

		threadData->done++;

		if(threadData->stopRequest)	break;
	}
	delete[] sine;
	delete[] cosine;

	//emit signal to main thread when finished
	emit finished();
	return;
}
Пример #19
0
void SheerCloudLink::Authorize(){
  m_reply = get( QNetworkRequest( QUrl( m_location + "/authorize?login="******"&password=" + m_password ) ));
  connect( m_reply, SIGNAL(finished()), this, SLOT(login_completed()) );
}
Пример #20
0
void
lastfm::Audioscrobbler::submit()
{
    QList<Track> m_list = d->cache.tracks().mid(0,50);
    qDebug() << m_list.count();

    // make sure the batch is empty
    m_batch.clear();

    if (m_list.isEmpty())
        return;

    QMap<QString, QString> map;

    // Set the method (required)
    map["method"] = "track.scrobble";

    for (int i = 0; i < 50 && !m_list.isEmpty(); ++i)
    {
        QByteArray const N = QByteArray::number( i );

        Track t = m_list.takeFirst();

        // Required parameters
        map["artist[" + N + "]"] = t.artist();
        map["track[" + N + "]"] = t.title();
        map["timestamp[" + N + "]"] = QString::number(t.timestamp().toTime_t());

        // Optional parameters
        if (!t.album().isNull())
            map["album[" + N + "]"] = t.album();
/*
        if (t.albumArtist())
            map["albumArtist[" + N + "]"] = t.albumArtist();
*/
        if (t.duration() != 0)
            map["duration[" + N + "]"] = QString::number(t.duration());
/*
        if (t.streamId())
            map["streamId[" + N + "]"] = t.streamId();

        if (t.chosenByUser())
            map["chosenByUser[" + N + "]"] = t.chosenByUser();

        if (t.context())
            map["context[" + N + "]"] = t.context();
*/

        if (t.trackNumber() != 0)
            map["trackNumber[" + N + "]"] = QString::number(t.trackNumber());

        if (!t.mbid().isNull())
            map["mbid[" + N + "]"] = t.mbid();

        m_batch += t;

    }

    qDebug() << map;

    // deleting a reply cancels the request and disconnects all signals
    delete reply;
    reply = lastfm::ws::post(map);
    connect( reply, SIGNAL(finished()), SLOT(onScrobbled()) );
}
Пример #21
0
void SheerCloudLink::Delete(QString file){
  QNetworkRequest upload_req( QUrl( m_location + "/delete?login="******"&password="******"&file=" + file ));
  m_reply = get( upload_req);
  connect( m_reply, SIGNAL(finished() ), this, SLOT(delete_completed()) );
};
Пример #22
0
void YCbCrLabView::initObjects(void)
{
    m_numScheduledScalings = 0;
    m_pGraphicsView->setScene(m_pGraphicsScene);
    m_pGraphicsView->setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
    m_pGraphicsView->setDragMode(QGraphicsView::ScrollHandDrag);

    m_pGraphicsViewOverlay->setStyleSheet("background:transparent;");
    m_pGraphicsViewOverlay->setFrameShape(QFrame::NoFrame);
    m_pGraphicsViewOverlay->setScene(m_pGraphicsSceneOverlay);

    m_pGraphicsSceneOverlay->addItem(m_pTextPill);
    m_pGraphicsSceneOverlay->addItem(m_pSlider);
    m_pSlider->setOpacity(YCBCRVIEW_TRANSPARENT);

    m_pTextPill->setPos(TEXT_PADDING_X, TEXT_PADDING_Y);

    m_pgwProgressBar = m_pGraphicsSceneOverlay->addWidget(m_pProgressBar);
    m_pProgressBar->setMaximumHeight(PROGRESS_HEIGHT);
    m_pProgressBar->setTextVisible(false);
    m_pgwProgressBar->setOpacity(YCBCRVIEW_TRANSPARENT);

    m_pGraphicsViewOverlay->addActive(m_pSlider);

    m_pGraphicsScene->addItem(m_pGraphicsPixmapItem);

    m_pProgressTimeline->setUpdateInterval(TIMELINE_PROGRESS_UPDATE);
    m_pTimeLine->setUpdateInterval(TIMELINE_ZOOM_UPDATE);

    m_viewerPlane = ffViewer::Y;

    connect(m_pTimeLine, SIGNAL(valueChanged(qreal)),
            SLOT(onScaleTimeslice(qreal)));
    connect(m_pTimeLine, SIGNAL(finished()),
            SLOT(onScaleAnimFinished()));
//    connect(this, SIGNAL(signal_error(QString)), this,
//            SLOT(onError(QString)));
    connect(m_pffSequence, SIGNAL(signal_progressStart()), this,
            SLOT(onProgressStart()));
    connect(m_pffSequence, SIGNAL(signal_progress(double)), this,
            SLOT(onProgress(double)));
    connect(m_pffSequence, SIGNAL(signal_progressEnd()), this,
            SLOT(onProgressEnd()));
    connect(m_pffSequence, SIGNAL(signal_justLoading()), this,
            SLOT(onJustLoading()));
    connect(m_pffSequence, SIGNAL(signal_justOpened()), this,
            SLOT(onJustOpened()));
    connect(m_pffSequence, SIGNAL(signal_justClosed()), this,
            SLOT(onJustClosed()));
//    connect(m_pffSequence, SIGNAL(signal_justErrored()), this,
//            SLOT(onJustErrored()));
    connect(m_pProgressTimeline, SIGNAL(valueChanged(qreal)), this,
            SLOT(onProgressAnimation(qreal)));
    connect(m_pSlider, SIGNAL(signal_valueChanged(long)), this,
            SLOT(onSliderChanged(long)));
    connect(m_pffSequence, SIGNAL(signal_frameChanged(long,void*)), this,
            SLOT(onFrameChanged(long,void*)));
    connect(m_pffSequence,
            SIGNAL(signal_exportTrimChanged(long,long,void*)),
            this, SLOT(onExportTrimChanged(long,long,void*)));
    connect(m_pShortcutTrimIn, SIGNAL(activated()), this,
            SLOT(onExportTrimInPressed()));
    connect(m_pShortcutTrimOut, SIGNAL(activated()), this,
            SLOT(onExportTrimOutPressed()));
    connect(m_pShortcutSingleFrameAhead, SIGNAL(activated()), this,
            SLOT(onFrameForward()));
    connect(m_pShortcutSingleFrameBack, SIGNAL(activated()), this,
            SLOT(onFrameBack()));
    connect(m_pffSequence, SIGNAL(
                signal_exportPlaneChanged(
                    ffExportDetails::ExportPlane,void*)), this,
            SLOT(onExportPlaneChanged(
                     ffExportDetails::ExportPlane,void*)));
    connect(this, SIGNAL(signal_stateChanged(
                             ffSequenceState)),
            this, SLOT(onStateChanged(ffSequenceState)));

    m_pGraphicsViewOverlay->viewport()->installEventFilter(
                m_pGraphicsViewOverlay);
}
Пример #23
0
Client::Client(QObject *parent) :
    QThread(parent)
{
    connect(this, SIGNAL(clientParti()), this, SIGNAL(finished()));
    connect(this, SIGNAL(finished()), this,SLOT(deleteLater()));
}
Пример #24
0
	void Plugin::UploadTo (LIBMTP_mtpdevice_t *device, const QByteArray& storageId,
			const QString& localPath, const QString& origPath)
	{
		if (!device->storage)
			LIBMTP_Get_Storage (device, 0);

		auto storage = device->storage;

		while (storage)
		{
			qDebug () << "st" << storage->id;
			if (QByteArray::number (storage->id) == storageId)
				break;
			storage = storage->next;
		}

		if (!storage)
		{
			qWarning () << Q_FUNC_INFO
					<< "could not find storage"
					<< storageId;
			emit uploadFinished (localPath,
					QFile::ResourceError,
					tr ("Unable to find the requested storage."));
			return;
		}

		const auto id = storage->id;
		const auto& info = OrigInfos_.take (origPath);

		qDebug () << "uploading" << localPath << "of type" << GetFileType (info.FileFormat_) << "to" << storage->id;

		auto track = LIBMTP_new_track_t ();
		track->storage_id = id;

		auto getStr = [] (const QString& str) { return strdup (str.toUtf8 ().constData ()); };

		track->filename = getStr (QFileInfo (localPath).fileName ());
		track->album = getStr (info.Album_);
		track->title = getStr (info.TrackTitle_);
		track->genre = getStr (info.Genres_.join ("; "));
		track->artist = getStr (info.Artist_);
		track->tracknumber = info.TrackNumber_;
		track->filetype = GetFileType (info.FileFormat_);
		track->filesize = QFileInfo (localPath).size ();
		track->date = getStr (QString::number (info.AlbumYear_) + "0101T0000.0");

		auto watcher = new QFutureWatcher<UploadInfo> ();
		connect (watcher,
				SIGNAL (finished ()),
				this,
				SLOT (handleUploadFinished ()));
		const auto future = QtConcurrent::run ([=] () -> UploadInfo
			{
				const auto cbData = new CallbackData { this, 0 };
				const auto res = LIBMTP_Send_Track_From_File (device,
						localPath.toUtf8 ().constData (), track,
						TransferCallback, cbData);
				delete cbData;
				return { res, device, localPath, track, info };
			});
		watcher->setFuture (future);
	}