Commit e13bc441 authored by ElenaSubbotina's avatar ElenaSubbotina

Merge branch 'develop' of https://github.com/ONLYOFFICE/core into develop

parents 56cefcb1 6f860c17
...@@ -348,6 +348,7 @@ public: ...@@ -348,6 +348,7 @@ public:
CConverter* GetNextConverter(); CConverter* GetNextConverter();
void OnConvertFile(CConverter* pConverter, int nCode); void OnConvertFile(CConverter* pConverter, int nCode);
void Start(int nCores); void Start(int nCores);
void Cancel();
}; };
class CConverter : public NSThreads::CBaseThread class CConverter : public NSThreads::CBaseThread
...@@ -371,6 +372,7 @@ public: ...@@ -371,6 +372,7 @@ public:
COfficeFileFormatChecker oChecker; COfficeFileFormatChecker oChecker;
if (!oChecker.isOfficeFile(m_file)) if (!oChecker.isOfficeFile(m_file))
{ {
m_bRunThread = FALSE;
m_pInternal->OnConvertFile(this, -1); m_pInternal->OnConvertFile(this, -1);
return 0; return 0;
} }
...@@ -380,6 +382,7 @@ public: ...@@ -380,6 +382,7 @@ public:
std::map<int, bool>::iterator find = m_pInternal->m_formats.find(nFormat); std::map<int, bool>::iterator find = m_pInternal->m_formats.find(nFormat);
if (find == m_pInternal->m_formats.end()) if (find == m_pInternal->m_formats.end())
{ {
m_bRunThread = FALSE;
m_pInternal->OnConvertFile(this, -1); m_pInternal->OnConvertFile(this, -1);
return 0; return 0;
} }
...@@ -574,7 +577,6 @@ public: ...@@ -574,7 +577,6 @@ public:
CConverter* CInternalWorker::GetNextConverter() CConverter* CInternalWorker::GetNextConverter()
{ {
CTemporaryCS oCS(&m_oCS);
if (m_nCurrent >= m_nCount) if (m_nCurrent >= m_nCount)
return NULL; return NULL;
...@@ -600,6 +602,8 @@ void CInternalWorker::OnConvertFile(CConverter* pConverter, int nCode) ...@@ -600,6 +602,8 @@ void CInternalWorker::OnConvertFile(CConverter* pConverter, int nCode)
void CInternalWorker::Start(int nCores) void CInternalWorker::Start(int nCores)
{ {
CTemporaryCS oCS(&m_oCS);
int nSizeInit = nCores; int nSizeInit = nCores;
if (nSizeInit > m_nCount) if (nSizeInit > m_nCount)
nSizeInit = m_nCount; nSizeInit = m_nCount;
...@@ -608,6 +612,12 @@ void CInternalWorker::Start(int nCores) ...@@ -608,6 +612,12 @@ void CInternalWorker::Start(int nCores)
GetNextConverter(); GetNextConverter();
} }
void CInternalWorker::Cancel()
{
CTemporaryCS oCS(&m_oCS);
m_nCount = m_nCurrent;
}
MainWindow::MainWindow(QWidget *parent) : MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::MainWindow) ui(new Ui::MainWindow)
...@@ -794,6 +804,12 @@ void MainWindow::pushButtonDirectoryClicked() ...@@ -794,6 +804,12 @@ void MainWindow::pushButtonDirectoryClicked()
void MainWindow::pushButtonConvertClicked() void MainWindow::pushButtonConvertClicked()
{ {
if (ui->pushButtonConvert->text() == "CANCEL")
{
m_pWorker->Cancel();
return;
}
std::wstring sProcess = NSFile::GetProcessDirectory(); std::wstring sProcess = NSFile::GetProcessDirectory();
if (!NSDirectory::Exists(sProcess + L"/fonts")) if (!NSDirectory::Exists(sProcess + L"/fonts"))
NSDirectory::CreateDirectory(sProcess + L"/fonts"); NSDirectory::CreateDirectory(sProcess + L"/fonts");
...@@ -810,7 +826,7 @@ void MainWindow::pushButtonConvertClicked() ...@@ -810,7 +826,7 @@ void MainWindow::pushButtonConvertClicked()
m_pWorker->m_pParser->Start(0); m_pWorker->m_pParser->Start(0);
ui->pushButtonConvert->setEnabled(false); ui->pushButtonConvert->setText("CANCEL");
} }
void MainWindow::send_onDirectoryChecked() void MainWindow::send_onDirectoryChecked()
...@@ -829,7 +845,7 @@ void MainWindow::slot_onFileConverted(int nProgress) ...@@ -829,7 +845,7 @@ void MainWindow::slot_onFileConverted(int nProgress)
if (nProgress == m_pWorker->m_nCount) if (nProgress == m_pWorker->m_nCount)
{ {
ui->pushButtonConvert->setEnabled(true); ui->pushButtonConvert->setText("CONVERT");
ui->progressBar->setVisible(false); ui->progressBar->setVisible(false);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment