Themes::Themes(FacilityInterface * facilityEngine) : ui(new Ui::interfaceCopy()) { this->facilityEngine=facilityEngine; ui->setupUi(this); ui->TransferList->setModel(&transferModel); transferModel.setFacilityEngine(facilityEngine); currentFile = 0; totalFile = 0; currentSize = 0; totalSize = 0; storeIsInPause = false; modeIsForced = false; haveStarted = false; speedString = facilityEngine->speedToString(0); ui->toolButtonMenu->setMenu(&menu); connect(ui->actionAddFile,&QAction::triggered,this,&Themes::forcedModeAddFile); connect(ui->actionAddFileToCopy,&QAction::triggered,this,&Themes::forcedModeAddFileToCopy); connect(ui->actionAddFileToMove,&QAction::triggered,this,&Themes::forcedModeAddFileToMove); connect(ui->actionAddFolderToCopy,&QAction::triggered,this,&Themes::forcedModeAddFolderToCopy); connect(ui->actionAddFolderToMove,&QAction::triggered,this,&Themes::forcedModeAddFolderToMove); connect(ui->actionAddFolder,&QAction::triggered,this,&Themes::forcedModeAddFolder); #ifdef ULTRACOPIER_PLUGIN_DEBUG connect(&transferModel,&TransferModel::debugInformation,this,&Themes::debugInformation); #endif progressColorWrite=QApplication::palette().color(QPalette::Highlight); progressColorRead=QApplication::palette().color(QPalette::AlternateBase); progressColorRemaining=QApplication::palette().color(QPalette::Base); ui->progressBar_all->setStyleSheet(QStringLiteral("QProgressBar{border:1px solid grey;text-align:center;background-color:%1;}QProgressBar::chunk{background-color:%2;}") .arg(progressColorRemaining.name()) .arg(progressColorWrite.name()) ); ui->progressBar_file->setStyleSheet(QStringLiteral("QProgressBar{border:1px solid grey;text-align:center;background-color:%1;}QProgressBar::chunk{background-color:%2;}") .arg(progressColorRemaining.name()) .arg(progressColorWrite.name()) ); show(); isInPause(false); }
/// \note Can be call without queue because all call will be serialized void copyEngine::errorOnFile(QFileInfo fileInfo,QString errorString,TransferThread * thread,bool isCalledByShowOneNewDialog) { if(stopIt) return; ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"file have error: "+fileInfo.absoluteFilePath()+", error: "+errorString); if(thread==NULL) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"unable to locate the thread"); return; } //load the action tempFileErrorAction=alwaysDoThisActionForFileError; switch(tempFileErrorAction) { case FileError_Skip: thread->skip(); return; case FileError_Retry: thread->retryAfterError(); return; case FileError_PutToEndOfTheList: /// \todo do the read transfer locator and put at the end ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"todo list item not found"); return; default: if(dialogIsOpen) { errorQueueItem newItem; newItem.errorString=errorString; newItem.inode=fileInfo; newItem.mkPath=false; newItem.rmPath=false; newItem.scan=NULL; newItem.transfer=thread; errorQueue << newItem; return; } dialogIsOpen=true; ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"show dialog"); emit error(fileInfo.absoluteFilePath(),fileInfo.size(),fileInfo.lastModified(),errorString); fileErrorDialog dialog(interface,fileInfo,errorString); emit isInPause(true); dialog.exec();/// \bug crash when external close FileErrorAction newAction=dialog.getAction(); emit isInPause(false); ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"close dialog: "+QString::number(newAction)); if(newAction==FileError_Cancel) { emit cancelAll(); return; } if(dialog.getAlways() && newAction!=alwaysDoThisActionForFileError) { alwaysDoThisActionForFileError=newAction; switch(newAction) { default: case FileError_Skip: emit newErrorAction("skip"); break; case FileError_PutToEndOfTheList: emit newErrorAction("putToEndOfTheList"); break; } } switch(newAction) { case FileError_Skip: thread->skip(); break; case FileError_Retry: thread->retryAfterError(); break; case FileError_PutToEndOfTheList: thread->putAtBottom(); /// \todo do the read transfer locator and put at the end ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"todo"); break; default: ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"file error action wrong"); break; } dialogIsOpen=false; if(!isCalledByShowOneNewDialog) emit queryOneNewDialog(); else ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"isCalledByShowOneNewDialog==true then not show other dial"); return; break; } ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"stop"); }
/// \note Can be call without queue because all call will be serialized void copyEngine::fileAlreadyExists(QFileInfo source,QFileInfo destination,bool isSame,TransferThread * thread,bool isCalledByShowOneNewDialog) { if(stopIt) return; if(thread==NULL) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"unable to locate the thread"); return; } //load the action if(isSame) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"file is same: "+source.absoluteFilePath()); tempFileExistsAction=alwaysDoThisActionForFileExists; if(tempFileExistsAction==FileExists_Overwrite || tempFileExistsAction==FileExists_OverwriteIfNewer || tempFileExistsAction==FileExists_OverwriteIfNotSameModificationDate) tempFileExistsAction=FileExists_NotSet; switch(tempFileExistsAction) { case FileExists_Skip: case FileExists_Rename: thread->setFileExistsAction(tempFileExistsAction); break; default: if(dialogIsOpen) { alreadyExistsQueueItem newItem; newItem.source=source; newItem.destination=destination; newItem.isSame=isSame; newItem.transfer=thread; newItem.scan=NULL; alreadyExistsQueue << newItem; return; } dialogIsOpen=true; ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"show dialog"); fileIsSameDialog dialog(interface,source,firstRenamingRule,otherRenamingRule); emit isInPause(true); dialog.exec();/// \bug crash when external close FileExistsAction newAction=dialog.getAction(); emit isInPause(false); ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"close dialog: "+QString::number(newAction)); if(newAction==FileExists_Cancel) { emit cancelAll(); return; } if(dialog.getAlways() && newAction!=alwaysDoThisActionForFileExists) { alwaysDoThisActionForFileExists=newAction; listThread->setAlwaysFileExistsAction(alwaysDoThisActionForFileExists); switch(newAction) { default: case FileExists_Skip: emit newCollisionAction("skip"); break; case FileExists_Rename: emit newCollisionAction("rename"); break; } } if(dialog.getAlways() || newAction!=FileExists_Rename) thread->setFileExistsAction(newAction); else thread->setFileRename(dialog.getNewName()); dialogIsOpen=false; if(!isCalledByShowOneNewDialog) emit queryOneNewDialog(); return; break; } } else { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"file already exists: "+source.absoluteFilePath()+", destination: "+destination.absoluteFilePath()); tempFileExistsAction=alwaysDoThisActionForFileExists; switch(tempFileExistsAction) { case FileExists_Skip: case FileExists_Rename: case FileExists_Overwrite: case FileExists_OverwriteIfNewer: case FileExists_OverwriteIfNotSameModificationDate: ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"always do this action: "+QString::number(tempFileExistsAction)); thread->setFileExistsAction(tempFileExistsAction); break; default: if(dialogIsOpen) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("dialog open, put in queue: %1 %2") .arg(source.absoluteFilePath()) .arg(destination.absoluteFilePath()) ); alreadyExistsQueueItem newItem; newItem.source=source; newItem.destination=destination; newItem.isSame=isSame; newItem.transfer=thread; newItem.scan=NULL; alreadyExistsQueue << newItem; return; } dialogIsOpen=true; ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"show dialog"); fileExistsDialog dialog(interface,source,destination,firstRenamingRule,otherRenamingRule); emit isInPause(true); dialog.exec();/// \bug crash when external close FileExistsAction newAction=dialog.getAction(); emit isInPause(false); ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"close dialog: "+QString::number(newAction)); if(newAction==FileExists_Cancel) { emit cancelAll(); return; } if(dialog.getAlways() && newAction!=alwaysDoThisActionForFileExists) { alwaysDoThisActionForFileExists=newAction; listThread->setAlwaysFileExistsAction(alwaysDoThisActionForFileExists); switch(newAction) { default: case FileExists_Skip: emit newCollisionAction("skip"); break; case FileExists_Rename: emit newCollisionAction("rename"); break; case FileExists_Overwrite: emit newCollisionAction("overwrite"); break; case FileExists_OverwriteIfNewer: emit newCollisionAction("overwriteIfNewer"); break; case FileExists_OverwriteIfNotSameModificationDate: emit newCollisionAction("overwriteIfNotSameModificationDate"); break; } } if(dialog.getAlways() || newAction!=FileExists_Rename) thread->setFileExistsAction(newAction); else thread->setFileRename(dialog.getNewName()); dialogIsOpen=false; if(!isCalledByShowOneNewDialog) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"emit queryOneNewDialog()"); emit queryOneNewDialog(); } return; break; } } ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"stop"); }
Themes::Themes(bool checkBoxShowSpeed,FacilityInterface * facilityEngine,bool moreButtonPushed) : ui(new Ui::interfaceCopy()) { this->facilityEngine=facilityEngine; ui->setupUi(this); ui->TransferList->setModel(&transferModel); transferModel.setFacilityEngine(facilityEngine); ui->tabWidget->setCurrentIndex(0); ui->checkBoxShowSpeed->setChecked(checkBoxShowSpeed); currentFile = 0; totalFile = 0; currentSize = 0; totalSize = 0; haveError = false; this->show(); menu=new QMenu(this); ui->add->setMenu(menu); on_checkBoxShowSpeed_toggled(ui->checkBoxShowSpeed->isChecked()); currentSpeed = 0; storeIsInPause = false; isInPause(false); modeIsForced = false; haveStarted = false; connect(ui->limitSpeed, SIGNAL(valueChanged(int)), this, SLOT(uiUpdateSpeed())); connect(ui->checkBox_limitSpeed,SIGNAL(toggled(bool)), this, SLOT(uiUpdateSpeed())); connect(ui->actionAddFile,SIGNAL(triggered()),this,SLOT(forcedModeAddFile())); connect(ui->actionAddFileToCopy,SIGNAL(triggered()),this,SLOT(forcedModeAddFileToCopy())); connect(ui->actionAddFileToMove,SIGNAL(triggered()),this,SLOT(forcedModeAddFileToMove())); connect(ui->actionAddFolderToCopy,SIGNAL(triggered()),this,SLOT(forcedModeAddFolderToCopy())); connect(ui->actionAddFolderToMove,SIGNAL(triggered()),this,SLOT(forcedModeAddFolderToMove())); connect(ui->actionAddFolder,SIGNAL(triggered()),this,SLOT(forcedModeAddFolder())); //setup the search part closeTheSearchBox(); TimerForSearch = new QTimer(this); TimerForSearch->setInterval(500); TimerForSearch->setSingleShot(true); searchShortcut = new QShortcut(QKeySequence("Ctrl+F"),this); searchShortcut2 = new QShortcut(QKeySequence("F3"),this); searchShortcut3 = new QShortcut(QKeySequence("Escape"),this);//Qt::Key_Escape //connect the search part connect(TimerForSearch, SIGNAL(timeout()), this, SLOT(hilightTheSearch())); connect(searchShortcut, SIGNAL(activated()), this, SLOT(searchBoxShortcut())); connect(searchShortcut2, SIGNAL(activated()), this, SLOT(on_pushButtonSearchNext_clicked())); connect(ui->pushButtonCloseSearch, SIGNAL(clicked()), this, SLOT(closeTheSearchBox())); connect(searchShortcut3, SIGNAL(activated()), this, SLOT(closeTheSearchBox())); //reload directly untranslatable text newLanguageLoaded(); //unpush the more button ui->moreButton->setChecked(moreButtonPushed); on_moreButton_toggled(false); /// \note important for drag and drop, \see dropEvent() setAcceptDrops(true); // try set the OS icon QIcon tempIcon; tempIcon=QIcon::fromTheme("application-exit"); if(!tempIcon.isNull()) { ui->cancelButton->setIcon(tempIcon); ui->pushButtonCloseSearch->setIcon(tempIcon); ui->shutdown->setIcon(tempIcon); } tempIcon=QIcon::fromTheme("edit-delete"); if(!tempIcon.isNull()) ui->del->setIcon(tempIcon); tempIcon=QIcon::fromTheme("media-playback-pause"); if(!tempIcon.isNull()) { player_pause=tempIcon; ui->pauseButton->setIcon(tempIcon); } else player_pause=QIcon(":/resources/player_pause.png"); tempIcon=QIcon::fromTheme("media-playback-play"); if(!tempIcon.isNull()) player_play=tempIcon; else player_play=QIcon(":/resources/player_play.png"); tempIcon=QIcon::fromTheme("media-skip-forward"); if(!tempIcon.isNull()) ui->skipButton->setIcon(tempIcon); tempIcon=QIcon::fromTheme("edit-find"); if(!tempIcon.isNull()) ui->searchButton->setIcon(tempIcon); tempIcon=QIcon::fromTheme("document-open"); if(!tempIcon.isNull()) ui->importTransferList->setIcon(tempIcon); tempIcon=QIcon::fromTheme("document-save"); if(!tempIcon.isNull()) ui->exportTransferList->setIcon(tempIcon); tempIcon=QIcon::fromTheme("list-add"); if(!tempIcon.isNull()) { ui->add->setIcon(tempIcon); ui->actionAddFile->setIcon(tempIcon); ui->actionAddFileToCopy->setIcon(tempIcon); ui->actionAddFileToMove->setIcon(tempIcon); ui->actionAddFolder->setIcon(tempIcon); ui->actionAddFolderToCopy->setIcon(tempIcon); ui->actionAddFolderToMove->setIcon(tempIcon); } shutdown=facilityEngine->haveFunctionality("shutdown"); ui->shutdown->setVisible(shutdown); selectionModel=ui->TransferList->selectionModel(); #ifdef ULTRACOPIER_PLUGIN_DEBUG connect(&transferModel,SIGNAL(debugInformation(DebugLevel,QString,QString,QString,int)),this,SIGNAL(debugInformation(DebugLevel,QString,QString,QString,int))); #endif updateSpeed(); }
Themes::Themes(const bool &alwaysOnTop, const bool &showProgressionInTheTitle, const QColor &progressColorWrite, const QColor &progressColorRead, const QColor &progressColorRemaining, const bool &showDualProgression, const quint8 &comboBox_copyEnd, const bool &speedWithProgressBar, const qint32 ¤tSpeed, const bool &checkBoxShowSpeed, FacilityInterface * facilityEngine, const bool &moreButtonPushed, const bool &minimizeToSystray) : ui(new Ui::interfaceCopy()), uiOptions(new Ui::themesOptions()) { this->facilityEngine=facilityEngine; ui->setupUi(this); uiOptions->setupUi(ui->optionsTab); currentFile = 0; totalFile = 0; currentSize = 0; totalSize = 0; getOldProgression = 200; haveError = false; stat = status_never_started; modeIsForced = false; haveStarted = false; storeIsInPause = false; durationStarted = false; this->progressColorWrite = progressColorWrite; this->progressColorRead = progressColorRead; this->progressColorRemaining= progressColorRemaining; this->currentSpeed = currentSpeed; uiOptions->showProgressionInTheTitle->setChecked(showProgressionInTheTitle); uiOptions->speedWithProgressBar->setChecked(speedWithProgressBar); uiOptions->showDualProgression->setChecked(showDualProgression); uiOptions->alwaysOnTop->setChecked(alwaysOnTop); uiOptions->minimizeToSystray->setChecked(minimizeToSystray); //uiOptions->setupUi(ui->tabWidget->widget(ui->tabWidget->count()-1)); uiOptions->labelStartWithMoreButtonPushed->setVisible(false); uiOptions->checkBoxStartWithMoreButtonPushed->setVisible(false); uiOptions->label_Slider_speed->setVisible(false); uiOptions->SliderSpeed->setVisible(false); uiOptions->label_SpeedMaxValue->setVisible(false); uiOptions->comboBox_copyEnd->setCurrentIndex(comboBox_copyEnd); speedWithProgressBar_toggled(speedWithProgressBar); showDualProgression_toggled(showDualProgression); QPixmap pixmap(75,20); pixmap.fill(progressColorWrite); uiOptions->progressColorWrite->setIcon(pixmap); pixmap.fill(progressColorRead); uiOptions->progressColorRead->setIcon(pixmap); pixmap.fill(progressColorRemaining); uiOptions->progressColorRemaining->setIcon(pixmap); ui->TransferList->setModel(&transferModel); transferModel.setFacilityEngine(facilityEngine); ui->tabWidget->setCurrentIndex(0); uiOptions->toolBox->setCurrentIndex(0); uiOptions->checkBoxShowSpeed->setChecked(checkBoxShowSpeed); menu=new QMenu(this); ui->add->setMenu(menu); //connect the options checkBoxShowSpeed_toggled(uiOptions->checkBoxShowSpeed->isChecked()); connect(uiOptions->checkBoxShowSpeed,&QCheckBox::stateChanged,this,&Themes::checkBoxShowSpeed_toggled); connect(uiOptions->speedWithProgressBar,&QCheckBox::stateChanged,this,&Themes::speedWithProgressBar_toggled); connect(uiOptions->showProgressionInTheTitle,&QCheckBox::stateChanged,this,&Themes::updateTitle); connect(uiOptions->showDualProgression,&QCheckBox::stateChanged,this,&Themes::showDualProgression_toggled); connect(uiOptions->progressColorWrite,&QAbstractButton::clicked,this,&Themes::progressColorWrite_clicked); connect(uiOptions->progressColorRead, &QAbstractButton::clicked,this,&Themes::progressColorRead_clicked); connect(uiOptions->progressColorRemaining,&QAbstractButton::clicked,this,&Themes::progressColorRemaining_clicked); connect(uiOptions->alwaysOnTop,&QAbstractButton::clicked,this,&Themes::alwaysOnTop_clickedSlot); isInPause(false); connect(uiOptions->limitSpeed, static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &Themes::uiUpdateSpeed); connect(uiOptions->checkBox_limitSpeed,&QAbstractButton::toggled, this, &Themes::uiUpdateSpeed); connect(ui->actionAddFile,&QAction::triggered,this,&Themes::forcedModeAddFile); connect(ui->actionAddFileToCopy,&QAction::triggered,this,&Themes::forcedModeAddFileToCopy); connect(ui->actionAddFileToMove,&QAction::triggered,this,&Themes::forcedModeAddFileToMove); connect(ui->actionAddFolderToCopy,&QAction::triggered,this,&Themes::forcedModeAddFolderToCopy); connect(ui->actionAddFolderToMove,&QAction::triggered,this,&Themes::forcedModeAddFolderToMove); connect(ui->actionAddFolder,&QAction::triggered,this,&Themes::forcedModeAddFolder); connect(ui->exportErrorToTransferList,&QToolButton::triggered,this,&Themes::exportErrorIntoTransferList); //setup the search part closeTheSearchBox(); TimerForSearch = new QTimer(this); TimerForSearch->setInterval(500); TimerForSearch->setSingleShot(true); searchShortcut = new QShortcut(QKeySequence(QKeySequence::Find),this); searchShortcut2 = new QShortcut(QKeySequence(QKeySequence::FindNext),this); searchShortcut3 = new QShortcut(QKeySequence(Qt::Key_Escape),this); //connect the search part connect(TimerForSearch, &QTimer::timeout, this, &Themes::hilightTheSearchSlot); connect(searchShortcut, &QShortcut::activated, this, &Themes::searchBoxShortcut); connect(searchShortcut2, &QShortcut::activated, this, &Themes::on_pushButtonSearchNext_clicked); connect(ui->pushButtonCloseSearch, &QPushButton::clicked, this, &Themes::closeTheSearchBox); connect(searchShortcut3, &QShortcut::activated, this, &Themes::closeTheSearchBox); //reload directly untranslatable text newLanguageLoaded(); //unpush the more button ui->moreButton->setChecked(moreButtonPushed); on_moreButton_toggled(moreButtonPushed); /// \note important for drag and drop, \see dropEvent() setAcceptDrops(true); // try set the OS icon if(!iconLoaded) { iconLoaded=true; tempExitIcon=QIcon::fromTheme(QStringLiteral("application-exit")); editDelete=QIcon::fromTheme(QStringLiteral("edit-delete")); player_pause=QIcon::fromTheme(QStringLiteral("media-playback-pause")); if(player_pause.isNull()) player_pause=QIcon(QStringLiteral(":/Themes/Oxygen/resources/player_pause.png")); player_play=QIcon::fromTheme(QStringLiteral("media-playback-play")); if(player_play.isNull()) player_play=QIcon(QStringLiteral(":/Themes/Oxygen/resources/player_play.png")); skinIcon=QIcon::fromTheme(QStringLiteral("media-skip-forward")); editFind=QIcon::fromTheme(QStringLiteral("edit-find")); documentOpen=QIcon::fromTheme(QStringLiteral("document-open")); documentSave=QIcon::fromTheme(QStringLiteral("document-save")); listAdd=QIcon::fromTheme(QStringLiteral("list-add")); } if(!tempExitIcon.isNull()) { ui->cancelButton->setIcon(tempExitIcon); ui->pushButtonCloseSearch->setIcon(tempExitIcon); ui->shutdown->setIcon(tempExitIcon); } if(!editDelete.isNull()) ui->del->setIcon(editDelete); if(!player_pause.isNull()) ui->pauseButton->setIcon(player_pause); if(!skinIcon.isNull()) ui->skipButton->setIcon(skinIcon); if(!editFind.isNull()) ui->searchButton->setIcon(editFind); if(!documentOpen.isNull()) ui->importTransferList->setIcon(documentOpen); if(!documentSave.isNull()) { ui->exportTransferList->setIcon(documentSave); ui->exportErrorToTransferList->setIcon(documentSave); } if(!listAdd.isNull()) { ui->add->setIcon(listAdd); ui->actionAddFile->setIcon(listAdd); ui->actionAddFileToCopy->setIcon(listAdd); ui->actionAddFileToMove->setIcon(listAdd); ui->actionAddFolder->setIcon(listAdd); ui->actionAddFolderToCopy->setIcon(listAdd); ui->actionAddFolderToMove->setIcon(listAdd); } #ifdef Q_OS_WIN32 pixmapTop=QPixmap(QStringLiteral(":/Themes/Oxygen/resources/SystemTrayIcon/systray_Uncaught_Windows.png")); pixmapBottom=QPixmap(QStringLiteral(":/Themes/Oxygen/resources/SystemTrayIcon/systray_Caught_Windows.png")); #else pixmapTop=QPixmap(QStringLiteral(":/Themes/Oxygen/resources/SystemTrayIcon/systray_Uncaught_Unix.png")); pixmapBottom=QPixmap(QStringLiteral(":/Themes/Oxygen/resources/SystemTrayIcon/systray_Caught_Unix.png")); #endif shutdown=facilityEngine->haveFunctionality(QStringLiteral("shutdown")); ui->shutdown->setVisible(shutdown); selectionModel=ui->TransferList->selectionModel(); #ifdef ULTRACOPIER_PLUGIN_DEBUG connect(&transferModel,&TransferModel::debugInformation,this,&Themes::debugInformation); #endif updateSpeed(); alwaysOnTop_clicked(false); /*#ifdef Q_OS_WIN32 uiOptions->labelAlwaysOnTop->hide(); uiOptions->alwaysOnTop->hide(); #endif*/ #ifdef ULTRACOPIER_VERSION_ULTIMATE ui->ad_ultimate->hide(); #else QString ultimateUrl=facilityEngine->ultimateUrl(); if(ultimateUrl.isEmpty()) ui->ad_ultimate->hide(); else ui->ad_ultimate->setText(QStringLiteral("<a href=\"%1\">%2</a>").arg(ultimateUrl).arg(tr("Buy the Ultimate version to fund development"))); #endif show(); sysTrayIcon = new QSystemTrayIcon(this); connect(sysTrayIcon,&QSystemTrayIcon::activated,this,&Themes::catchAction); }
void ReadThread::internalRead() { isInReadLoop=true; tryStartRead=false; if(stopIt) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] stopIt == true, then quit"); internalClose(); return; } #ifdef ULTRACOPIER_PLUGIN_DEBUG stat=InodeOperation; #endif int sizeReaden=0; if(!file.isOpen()) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] is not open!"); return; } QByteArray blockArray; //numberOfBlockCopied = 0; ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+QString::number(id)+"] start the copy"); emit readIsStarted(); #ifdef ULTRACOPIER_PLUGIN_DEBUG stat=Idle; #endif if(stopIt) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] stopIt == true, then quit"); internalClose(); return; } do { //read one block #ifdef ULTRACOPIER_PLUGIN_DEBUG stat=Read; #endif blockArray=file.read(blockSize); #ifdef ULTRACOPIER_PLUGIN_DEBUG stat=Idle; #endif if(file.error()!=QFile::NoError) { errorString_internal=tr("Unable to read the source file: ")+file.errorString()+" ("+QString::number(file.error())+")"; ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] "+QString("file.error()!=QFile::NoError: %1, error: %2").arg(QString::number(file.error())).arg(errorString_internal)); emit error(); isInReadLoop=false; return; } sizeReaden=blockArray.size(); if(sizeReaden>0) { #ifdef ULTRACOPIER_PLUGIN_DEBUG stat=WaitWritePipe; #endif if(!writeThread->write(blockArray)) { if(!stopIt) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] stopped because the write is stopped: "+QString::number(lastGoodPosition)); stopIt=true; } } #ifdef ULTRACOPIER_PLUGIN_DEBUG stat=Idle; #endif if(stopIt) break; lastGoodPosition+=blockArray.size(); //wait for limitation speed if stop not query if(multiForBigSpeed>0) { numberOfBlockCopied++; if(numberOfBlockCopied>=multiForBigSpeed) { numberOfBlockCopied=0; waitNewClockForSpeed.acquire(); if(stopIt) break; } } } /* if(lastGoodPosition>16*1024) { ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] "+QString("Test error in reading: %1 (%2)").arg(file.errorString()).arg(file.error())); errorString_internal=QString("Test error in reading: %1 (%2)").arg(file.errorString()).arg(file.error()); emit error(); isInReadLoop=false; return; } */ } while(sizeReaden>0 && !stopIt); if(lastGoodPosition>file.size()) { errorString_internal=tr("File truncated during the read, possible data change"); ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] "+QString("Source truncated during the read: %1 (%2)").arg(file.errorString()).arg(QString::number(file.error()))); emit error(); isInReadLoop=false; return; } isInReadLoop=false; if(stopIt) { if(putInPause) emit isInPause(); stopIt=false; return; } emit readIsStopped();//will product by signal connection writeThread->endIsDetected(); ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+QString::number(id)+"] stop the read"); }
void ReadThread::checkSum() { QByteArray blockArray; QCryptographicHash hash(QCryptographicHash::Sha1); isInReadLoop=true; lastGoodPosition=0; seek(0); int sizeReaden=0; do { //read one block #ifdef ULTRACOPIER_PLUGIN_DEBUG stat=Read; #endif blockArray=file.read(blockSize); #ifdef ULTRACOPIER_PLUGIN_DEBUG stat=Idle; #endif if(file.error()!=QFile::NoError) { errorString_internal=tr("Unable to read the source file: ")+file.errorString()+" ("+QString::number(file.error())+")"; ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] "+QString("file.error()!=QFile::NoError: %1, error: %2").arg(QString::number(file.error())).arg(errorString_internal)); emit error(); isInReadLoop=false; return; } sizeReaden=blockArray.size(); if(sizeReaden>0) { #ifdef ULTRACOPIER_PLUGIN_DEBUG stat=Checksum; #endif hash.addData(blockArray); #ifdef ULTRACOPIER_PLUGIN_DEBUG stat=Idle; #endif if(stopIt) break; lastGoodPosition+=blockArray.size(); //wait for limitation speed if stop not query if(numberOfBlockCopied>0) { numberOfBlockCopied++; if(numberOfBlockCopied>=multiForBigSpeed) { numberOfBlockCopied=0; waitNewClockForSpeed.acquire(); if(stopIt) break; } } } } while(sizeReaden>0 && !stopIt); if(lastGoodPosition>file.size()) { errorString_internal=tr("File truncated during the read, possible data change"); ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Warning,"["+QString::number(id)+"] "+QString("Source truncated during the read: %1 (%2)").arg(file.errorString()).arg(QString::number(file.error()))); emit error(); isInReadLoop=false; return; } isInReadLoop=false; if(stopIt) { if(putInPause) emit isInPause(); stopIt=false; return; } emit checksumFinish(hash.result()); ULTRACOPIER_DEBUGCONSOLE(Ultracopier::DebugLevel_Notice,"["+QString::number(id)+"] stop the read"); }