@@ -309,7 +309,7 @@ MainWindow::MainWindow(QWidget *parent)
309309 break ;
310310 }
311311 case 2 : { // receiving raw file bytes
312- const qint64 MAX_CHUNK = 1024 ;
312+ const qint64 MAX_CHUNK = CHUNK_SIZE ;
313313 while (socket->bytesAvailable () > 0 && current_file_size < current_total_file_size) {
314314 qint64 remaining = current_total_file_size - current_file_size;
315315 qint64 toRead = qMin (MAX_CHUNK, remaining);
@@ -326,7 +326,7 @@ MainWindow::MainWindow(QWidget *parent)
326326 }
327327 // flush occasionally
328328 flushIndex++;
329- if (flushIndex >= 25 ) {
329+ if (flushIndex >= 125 ) {
330330 current_file->flush ();
331331 flushIndex = 0 ;
332332 }
@@ -579,9 +579,14 @@ void MainWindow::sendFile()
579579 }
580580 else
581581 {
582+ ui->sendButton ->setEnabled (false );
583+ ui->pairButton ->setEnabled (false );
584+ ui->MessageInput ->setEnabled (false );
585+ scrollToBottom ();
586+
582587 while (!current_file->atEnd ())
583588 {
584- QByteArray bytes = current_file->read (1024 );
589+ QByteArray bytes = current_file->read (CHUNK_SIZE );
585590 current_file_size += bytes.size ();
586591 bytesReceivedThisSecond += bytes.size ();
587592 qint64 written = socket->write (bytes);
@@ -622,14 +627,18 @@ void MainWindow::sendFile()
622627 currentFileMessage->setStatus (" File Transferred" );
623628 currentFileMessage->setProgress (100 );
624629
630+ ui->sendButton ->setEnabled (true );
631+ ui->pairButton ->setEnabled (true );
632+ ui->MessageInput ->setEnabled (true );
633+
625634 }
626635}
627636
628637void MainWindow::sendFileChunk ()
629638{
630639 if (!sendingFile || !current_file) return ;
631640
632- const int chunkSize = 1024 ;
641+ const int chunkSize = CHUNK_SIZE ;
633642 QByteArray bytes = current_file->read (chunkSize);
634643
635644 if (bytes.isEmpty ()) {
0 commit comments