Skip to content

Commit d054fe1

Browse files
committed
Issue #82: block right click and selection in the GUI when in Monitoring
1 parent 0a78d2b commit d054fe1

File tree

3 files changed

+40
-25
lines changed

3 files changed

+40
-25
lines changed

src/NgPost.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -814,10 +814,10 @@ void NgPost::onPackingDone()
814814
if (_preparePacking)
815815
{
816816
PostingJob *job = static_cast<PostingJob*>(sender());
817-
817+
#ifdef __DEBUG__
818818
qDebug() << "[MB_TRACE][Issue#82][NgPost::onPackingDone] job: " << job
819819
<< ", file: " << job->nzbName();
820-
820+
#endif
821821
if (job == _activeJob)
822822
{
823823
#ifdef __DEBUG__
@@ -858,10 +858,10 @@ void NgPost::_prepareNextPacking()
858858
void NgPost::onPostingJobFinished()
859859
{
860860
PostingJob *job = static_cast<PostingJob*>(sender());
861-
861+
#ifdef __DEBUG__
862862
qDebug() << "[MB_TRACE][Issue#82][NgPost::onPostingJobFinished] job: " << job
863863
<< ", file: " << job->nzbName();
864-
864+
#endif
865865
if (job == _activeJob)
866866
{
867867
if (_hmi && !job->widget())
@@ -2248,8 +2248,10 @@ QString NgPost::parseDefaultConfig()
22482248

22492249
bool NgPost::startPostingJob(PostingJob *job)
22502250
{
2251+
#ifdef __DEBUG__
22512252
qDebug() << "[MB_TRACE][Issue#82][NgPost::startPostingJob] job: " << job
22522253
<< ", file: " << job->nzbName();
2254+
#endif
22532255
if (_hmi)
22542256
{
22552257
connect(job, &PostingJob::articlesNumber, _hmi, &MainWindow::onSetProgressBarRange, Qt::QueuedConnection);

src/PostingJob.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,10 @@ void PostingJob::onImmediateSpeedComputation()
207207
void PostingJob::onStartPosting(bool isActiveJob)
208208
{
209209
_isActiveJob = isActiveJob;
210-
210+
#ifdef __DEBUG__
211211
qDebug() << "[MB_TRACE][Issue#82][PostingJob::onStartPosting] job: " << this
212212
<< ", file: " << nzbName() << " (isActive: " << isActiveJob << ")";
213-
213+
#endif
214214
if (_postWidget)
215215
_log(tr("<h3>Start Post #%1: %2</h3>").arg(_postWidget->jobNumber()).arg(_nzbName));
216216
else

src/hmi/AutoPostWidget.cpp

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,13 @@ void AutoPostWidget::onMonitoringClicked()
259259
_ui->startJobsCB->setEnabled(_isMonitoring);
260260
_ui->postButton->setEnabled(_isMonitoring);
261261

262-
263262
_isMonitoring = !_isMonitoring;
264263
_ui->addMonitoringFolderButton->setEnabled(_isMonitoring);
264+
265+
if (_isMonitoring)
266+
_ui->filesList->setSelectionMode(QAbstractItemView::NoSelection);
267+
else
268+
_ui->filesList->setSelectionMode(QAbstractItemView::ExtendedSelection);
265269
}
266270

267271
void AutoPostWidget::newFileToProcess(const QFileInfo &fileInfo)
@@ -322,14 +326,17 @@ void AutoPostWidget::onMonitorJobStart()
322326

323327
void AutoPostWidget::onSelectFilesClicked()
324328
{
325-
QStringList files = QFileDialog::getOpenFileNames(
326-
this,
327-
tr("Select one or more files"),
328-
_ngPost->_inputDir);
329-
330-
int currentNbFiles = _ui->filesList->count();
331-
for (const QString &file : files)
332-
_ui->filesList->addPathIfNotInList(file, currentNbFiles);
329+
if (!_isMonitoring)
330+
{
331+
QStringList files = QFileDialog::getOpenFileNames(
332+
this,
333+
tr("Select one or more files"),
334+
_ngPost->_inputDir);
335+
336+
int currentNbFiles = _ui->filesList->count();
337+
for (const QString &file : files)
338+
_ui->filesList->addPathIfNotInList(file, currentNbFiles);
339+
}
333340
}
334341

335342
void AutoPostWidget::udatePostingParams()
@@ -432,25 +439,31 @@ void AutoPostWidget::setAutoCompress(bool checked)
432439

433440
void AutoPostWidget::handleKeyEvent(QKeyEvent *keyEvent)
434441
{
435-
qDebug() << "[AutoPostWidget::handleKeyEvent] key event: " << keyEvent->key();
436-
if(keyEvent->key() == Qt::Key_Delete || keyEvent->key() == Qt::Key_Backspace)
442+
if (!_isMonitoring)
437443
{
438-
for (QListWidgetItem *item : _ui->filesList->selectedItems())
444+
qDebug() << "[AutoPostWidget::handleKeyEvent] key event: " << keyEvent->key();
445+
if(keyEvent->key() == Qt::Key_Delete || keyEvent->key() == Qt::Key_Backspace)
439446
{
440-
qDebug() << "[AutoPostWidget::handleKeyEvent] remove item: " << item->text();
441-
_ui->filesList->removeItemWidget2(item);
442-
delete item;
447+
for (QListWidgetItem *item : _ui->filesList->selectedItems())
448+
{
449+
qDebug() << "[AutoPostWidget::handleKeyEvent] remove item: " << item->text();
450+
_ui->filesList->removeItemWidget2(item);
451+
delete item;
452+
}
443453
}
444454
}
445455
}
446456

447457

448458
void AutoPostWidget::handleDropEvent(QDropEvent *e)
449459
{
450-
int currentNbFiles = _ui->filesList->count();
451-
for (const QUrl &url : e->mimeData()->urls())
460+
if (!_isMonitoring)
452461
{
453-
QString fileName = url.toLocalFile();
454-
_ui->filesList->addPathIfNotInList(fileName, currentNbFiles, QFileInfo(fileName).isDir());
462+
int currentNbFiles = _ui->filesList->count();
463+
for (const QUrl &url : e->mimeData()->urls())
464+
{
465+
QString fileName = url.toLocalFile();
466+
_ui->filesList->addPathIfNotInList(fileName, currentNbFiles, QFileInfo(fileName).isDir());
467+
}
455468
}
456469
}

0 commit comments

Comments
 (0)