/// \brief Create the manager and load the defaults variables LanguagesManager::LanguagesManager() { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start"); //load the overall instance resources=ResourcesManager::getInstance(); options=OptionEngine::getInstance(); plugins=PluginsManager::getInstance(); //load the rest QStringList resourcesPaths=resources->getReadPath(); int index=0; while(index<resourcesPaths.size()) { QString composedTempPath=resourcesPaths.at(index)+"Languages"+QDir::separator(); QDir LanguagesConfiguration(composedTempPath); if(LanguagesConfiguration.exists()) languagePath<<composedTempPath; index++; } //load the plugins plugins->lockPluginListEdition(); qRegisterMetaType<PluginsAvailable>("PluginsAvailable"); connect(this,SIGNAL(previouslyPluginAdded(PluginsAvailable)), this,SLOT(onePluginAdded(PluginsAvailable)),Qt::QueuedConnection); connect(plugins,SIGNAL(onePluginAdded(PluginsAvailable)), this, SLOT(onePluginAdded(PluginsAvailable)),Qt::QueuedConnection); connect(plugins,SIGNAL(onePluginWillBeRemoved(PluginsAvailable)), this, SLOT(onePluginWillBeRemoved(PluginsAvailable)),Qt::DirectConnection); connect(plugins,SIGNAL(pluginListingIsfinish()), this, SLOT(allPluginIsLoaded()),Qt::QueuedConnection); QList<PluginsAvailable> list=plugins->getPluginsByCategory(PluginType_Languages); foreach(PluginsAvailable currentPlugin,list) emit previouslyPluginAdded(currentPlugin); plugins->unlockPluginListEdition(); //load the GUI option QList<QPair<QString, QVariant> > KeysList; KeysList.append(qMakePair(QString("Language"),QVariant("en"))); KeysList.append(qMakePair(QString("Language_autodetect"),QVariant(true))); options->addOptionGroup("Language",KeysList); // connect(this, SIGNAL(newLanguageLoaded(QString)), plugins,SLOT(refreshPluginList(QString))); // connect(this, SIGNAL(newLanguageLoaded(QString)), this,SLOT(retranslateTheUI())); connect(options,SIGNAL(newOptionValue(QString,QString,QVariant)), this, SLOT(newOptionValue(QString)),Qt::QueuedConnection); connect(this, SIGNAL(newLanguageLoaded(QString)), plugins,SIGNAL(newLanguageLoaded()),Qt::QueuedConnection); }
void SessionLoader::onePluginAdded(const PluginsAvailable &plugin) { if(plugin.category!=PluginType_SessionLoader) return; ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start"); QString pluginPath=plugin.path+PluginsManager::getResolvedPluginName("sessionLoader"); ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"try load: "+pluginPath); LocalPlugin newEntry; QPluginLoader *pluginLoader= new QPluginLoader(pluginPath); newEntry.pluginLoader=pluginLoader; QObject *pluginInstance = pluginLoader->instance(); if(pluginInstance) { PluginInterface_SessionLoader *sessionLoader = qobject_cast<PluginInterface_SessionLoader *>(pluginInstance); //check if found int index=0; while(index<pluginList.size()) { if(pluginList.at(index).sessionLoaderInterface==sessionLoader) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,QString("Plugin already found")); pluginLoader->unload(); return; } index++; } if(sessionLoader) { #ifdef ULTRACOPIER_DEBUG connect(sessionLoader,SIGNAL(debugInformation(DebugLevel,QString,QString,QString,int)),this,SLOT(debugInformation(DebugLevel,QString,QString,QString,int))); #endif // ULTRACOPIER_DEBUG newEntry.options=new LocalPluginOptions("SessionLoader-"+plugin.name); newEntry.sessionLoaderInterface=sessionLoader; newEntry.path=plugin.path; newEntry.sessionLoaderInterface->setResources(newEntry.options,plugin.writablePath,plugin.path,ULTRACOPIER_VERSION_PORTABLE_BOOL); newEntry.sessionLoaderInterface->setEnabled(shouldEnabled); optionDialog->addPluginOptionWidget(PluginType_SessionLoader,plugin.name,newEntry.sessionLoaderInterface->options()); connect(languages,SIGNAL(newLanguageLoaded(QString)),newEntry.sessionLoaderInterface,SLOT(newLanguageLoaded())); pluginList << newEntry; } else ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"unable to cast the plugin: "+pluginLoader->errorString()); }
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(); }
/* \brief To set the current language \param newLanguage Should be short name code found into informations.xml of language file */ void LanguagesManager::setCurrentLanguage(const QString &newLanguage) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"start: "+newLanguage); //protection for re-set the same language if(currentLanguage==newLanguage) return; //store the language plugins->setLanguage(newLanguage); //unload the old language if(currentLanguage!="en") { int indexTranslator=0; while(indexTranslator<installedTranslator.size()) { QCoreApplication::removeTranslator(installedTranslator[indexTranslator]); delete installedTranslator[indexTranslator]; indexTranslator++; } installedTranslator.clear(); } if(newLanguage=="en") { currentLanguage="en"; emit newLanguageLoaded(currentLanguage); } else { int index=0; while(index<LanguagesAvailableList.size()) { if(LanguagesAvailableList.at(index).mainShortName==newLanguage) { //load the new language if(newLanguage!="en") { QTranslator *temp; QStringList fileToLoad; //load the language main fileToLoad<<LanguagesAvailableList.at(index).path+"translation.qm"; //load the language plugin QList<PluginsAvailable> listLoadedPlugins=plugins->getPlugins(); int indexPluginIndex=0; while(indexPluginIndex<listLoadedPlugins.size()) { if(listLoadedPlugins.at(indexPluginIndex).category!=PluginType_Languages) { QString tempPath=listLoadedPlugins.at(indexPluginIndex).path+"Languages"+QDir::separator()+LanguagesAvailableList.at(index).mainShortName+QDir::separator()+"translation.qm"; if(QFile::exists(tempPath)) fileToLoad<<tempPath; } indexPluginIndex++; } int indexTranslationFile=0; while(indexTranslationFile<fileToLoad.size()) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"Translation to load: "+fileToLoad.at(indexTranslationFile)); temp=new QTranslator(); if(!temp->load(fileToLoad.at(indexTranslationFile)) || temp->isEmpty()) { delete temp; ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"Unable to load the translation file: "+fileToLoad.at(indexTranslationFile)); } else { QCoreApplication::installTranslator(temp); installedTranslator<<temp; } indexTranslationFile++; } temp=new QTranslator(); if(temp->load(QString("qt_")+newLanguage, QLibraryInfo::location(QLibraryInfo::TranslationsPath)) && !temp->isEmpty()) { QCoreApplication::installTranslator(temp); installedTranslator<<temp; } else { if(!temp->load(LanguagesAvailableList.at(index).path+"qt.qm") || temp->isEmpty()) { ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"Unable to load the translation file: qt.qm, into: "+LanguagesAvailableList.at(index).path); delete temp; } else { QCoreApplication::installTranslator(temp); installedTranslator<<temp; } } } currentLanguage=newLanguage; ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"emit newLanguageLoaded()"); emit newLanguageLoaded(currentLanguage); return; } index++; } ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"unable to found language: "+newLanguage+", LanguagesAvailableList.size(): "+QString::number(LanguagesAvailableList.size())); } }
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); }