261030.6 · a50e122524517e9c4b3e5c8cd09ead7ac0fc6ff4
gui-qt: fixed minor UI inconsistencies
reading declarations
@@ -220,11 +220,16 @@ MainWindow::MainWindow(QWidget *parent) QObject::connect(ui->cbFragment, SIGNAL(clicked()), this, SLOT(plausibility())); QObject::connect(ui->cbLSHover, SIGNAL(clicked()), this, SLOT(plausibility())); QObject::connect(ui->cbLSSemantic, SIGNAL(clicked()), this, SLOT(plausibility()));+ QObject::connect(ui->cbLSHover, SIGNAL(clicked()), this, SLOT(updatePreview()));+ QObject::connect(ui->cbLSSemantic, SIGNAL(clicked()), this, SLOT(updatePreview()));+ QObject::connect(ui->cbLSSyntaxErrors, SIGNAL(clicked()), this, SLOT(updatePreview())); QObject::connect(ui->tabIOSelection, SIGNAL(currentChanged(int)), this, SLOT(plausibility())); QObject::connect(ui->lvInputFiles, SIGNAL(itemSelectionChanged()), this, SLOT(updatePreview())); QObject::connect(ui->lvPluginScripts, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(updatePreview()));+ // must run first: keeps one checked script per type before the preview is updated+ QObject::connect(ui->lvUserScripts, &QListWidget::itemChanged, this, &MainWindow::onUserScriptChanged); QObject::connect(ui->lvUserScripts, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(updatePreview())); QObject::connect(ui->lvUserScripts, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(plausibility())); @@ -238,7 +243,8 @@ MainWindow::MainWindow(QWidget *parent) QObject::connect(ui->cbEncoding, SIGNAL(clicked()), this, SLOT(updatePreview())); QObject::connect(ui->comboEncoding, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePreview())); - QObject::connect(ui->comboFontName, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePreview()));+ // the font combo is editable, so typed names must update the preview too+ QObject::connect(ui->comboFontName, SIGNAL(currentTextChanged(QString)), this, SLOT(updatePreview())); QObject::connect(ui->comboKwCase, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePreview())); QObject::connect(ui->comboReformat, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePreview())); QObject::connect(ui->comboSelectSyntax, SIGNAL(currentIndexChanged(int)), this, SLOT(updatePreview()));@@ -258,6 +264,10 @@ MainWindow::MainWindow(QWidget *parent) QObject::connect(ui->sbLineNoWidth, SIGNAL(valueChanged(int)), this, SLOT(updatePreview())); QObject::connect(ui->sbLineNoStart, SIGNAL(valueChanged(int)), this, SLOT(updatePreview())); QObject::connect(ui->leFontSize, SIGNAL(textChanged(QString)), this, SLOT(updatePreview()));+ QObject::connect(ui->sbTabWidth, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));+ QObject::connect(ui->sbLineLength, SIGNAL(valueChanged(int)), this, SLOT(updatePreview()));+ // the parameter may be a file path, so do not run the plug-ins with each typed character+ QObject::connect(ui->lePluginReadFilePath, SIGNAL(editingFinished()), this, SLOT(updatePreview())); QObject::connect(ui->cbOmitWrappedLineNumbers, SIGNAL(clicked()), this, SLOT(updatePreview())); QObject::connect(&scriptWatcher, SIGNAL(fileChanged(QString)), this, SLOT(updatePreview()));@@ -400,7 +410,8 @@ void MainWindow::addToView(const QStringList& list, QListWidget* listWidget, con void MainWindow::on_pbOutputDest_clicked() {- ui->leOutputDest->setText(QFileDialog::getExistingDirectory(this, tr("Select destination directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks));+ QString dir = QFileDialog::getExistingDirectory(this, tr("Select destination directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);+ if (!dir.isEmpty()) ui->leOutputDest->setText(dir); } @@ -546,17 +557,18 @@ void MainWindow::writeSettings() QStringList inFiles, plugins, userScripts; QVariantList selectedPlugins, selectedUserScripts; - auto collectItems = [&](QListWidget* view, QStringList& list, QVariantList& selected) {+ auto collectItems = [&](QListWidget* view, QStringList& list, QVariantList* selected) { for (int i = 0; i < view->count(); ++i) { list << view->item(i)->data(Qt::UserRole).toString();- if (view->item(i)->checkState() == Qt::Checked)- selected.push_back(QVariant(i));+ if (selected && view->item(i)->checkState() == Qt::Checked)+ selected->push_back(QVariant(i)); } }; - collectItems(ui->lvInputFiles, inFiles, selectedPlugins);- collectItems(ui->lvPluginScripts, plugins, selectedPlugins);- collectItems(ui->lvUserScripts, userScripts, selectedUserScripts);+ // input files are not checkable, so only their paths are saved+ collectItems(ui->lvInputFiles, inFiles, nullptr);+ collectItems(ui->lvPluginScripts, plugins, &selectedPlugins);+ collectItems(ui->lvUserScripts, userScripts, &selectedUserScripts); const char* name = "objectName"; settings.setValue(ui->lvInputFiles->property(name).toString(), inFiles);@@ -1638,11 +1650,10 @@ void MainWindow::plausibility() ui->tbSelectSyntax->setEnabled(getUserScriptPath("lang").isEmpty()); ui->cbHTMLInlineCSS->setEnabled(ui->cbHTMLEmbedStyle->isChecked());- ui->cbHTMLFileNameAnchor->setEnabled(ui->cbHTMLAnchors->isChecked()); ui->leHTMLStyleFile->setEnabled(!ui->cbHTMLEmbedStyle->isChecked()); ui->leHTMLStyleIncFile->setEnabled(!(ui->cbHTMLInlineCSS->isEnabled() && ui->cbHTMLInlineCSS->isChecked())); ui->pbHTMLChooseStyleIncFile->setEnabled(!(ui->cbHTMLInlineCSS->isEnabled() && ui->cbHTMLInlineCSS->isChecked()));- ui->leHTMLCssPrefix->setEnabled(!ui->cbHTMLInlineCSS->isChecked());+ ui->leHTMLCssPrefix->setEnabled(!(ui->cbHTMLInlineCSS->isEnabled() && ui->cbHTMLInlineCSS->isChecked())); ui->leLATEXStyleFile->setEnabled(!ui->cbLATEXEmbedStyle->isChecked()); ui->leTEXStyleFile->setEnabled(!ui->cbTEXEmbedStyle->isChecked()); ui->leSVGStyleFile->setEnabled(!ui->cbSVGEmbedStyle->isChecked());@@ -1654,7 +1665,7 @@ void MainWindow::plausibility() ui->cbHTMLEnclosePreTags->setEnabled(ui->cbFragment->isChecked()); ui->cbKeepInjections->setEnabled(ui->cbFragment->isEnabled() && ui->cbFragment->isChecked()); ui->cbHTMLAnchors->setEnabled(ui->cbIncLineNo->isChecked());- ui->cbHTMLFileNameAnchor->setEnabled(ui->cbIncLineNo->isChecked());+ ui->cbHTMLFileNameAnchor->setEnabled(ui->cbHTMLAnchors->isEnabled() && ui->cbHTMLAnchors->isChecked()); ui->cbHTMLOrderedList->setEnabled(ui->cbIncLineNo->isChecked()); ui->pbCopyToCP->setEnabled(!savedClipboardContent.isEmpty()); ui->pbStartConversion->setEnabled(ui->lvInputFiles->count() > 0);@@ -2008,6 +2019,8 @@ void MainWindow::on_actionVisit_website_triggered() void MainWindow::on_pbPluginReadFilePath_clicked() { selectSingleFile(ui->lePluginReadFilePath, tr("Choose a plug-in input file"), "*");+ // setText() emits no editingFinished signal+ updatePreview(); } void MainWindow::on_pbCopyAndPaste_clicked()@@ -2028,26 +2041,30 @@ void MainWindow::on_lvUserScripts_itemClicked(QListWidgetItem *item) Diluculum::LuaState ls; ls.doFile ( scriptPath.toStdString()); ui->lblScriptDescription->setText(QString::fromStdString(ls["Description"].value().asString()));-- if (item->checkState()==Qt::Checked){- scriptWatcher.addPath(scriptPath);- QString fileExt=QFileInfo(scriptPath).completeSuffix();- QString otherScriptPath;- for (int i = 0; i < ui->lvUserScripts->count(); ++i) {- otherScriptPath = ui->lvUserScripts->item(i)->data(Qt::UserRole).toString();- if (ui->lvUserScripts->item(i)!=item && otherScriptPath.endsWith(fileExt)){- ui->lvUserScripts->item(i)->setCheckState(Qt::Unchecked);- scriptWatcher.removePath(otherScriptPath);- }- }- } else {- scriptWatcher.removePath(scriptPath);- } } catch (Diluculum::LuaError &err) { QMessageBox::warning(this, "User script error", QString::fromStdString( err.what())); } } +void MainWindow::onUserScriptChanged(QListWidgetItem *item)+{+ // handled here instead of in itemClicked, which is not emitted if the check box is toggled by keyboard+ QString scriptPath = item->data(Qt::UserRole).toString();+ if (item->checkState()==Qt::Checked){+ scriptWatcher.addPath(scriptPath);+ QString fileExt = QFileInfo(scriptPath).suffix();+ for (int i = 0; i < ui->lvUserScripts->count(); ++i) {+ QListWidgetItem* otherItem = ui->lvUserScripts->item(i);+ if (otherItem!=item && otherItem->checkState()==Qt::Checked+ && QFileInfo(otherItem->data(Qt::UserRole).toString()).suffix()==fileExt){+ otherItem->setCheckState(Qt::Unchecked);+ }+ }+ } else {+ scriptWatcher.removePath(scriptPath);+ }+}+ QString MainWindow::getUserScriptPath(QString type){ for (int i = 0; i < ui->lvUserScripts->count(); ++i) { QString path=ui->lvUserScripts->item(i)->data(Qt::UserRole).toString();@@ -2168,8 +2185,15 @@ void MainWindow::loadLSProfile() { } plausibility(); - if (ui->comboLSProfiles->currentIndex()==0)+ if (ui->comboLSProfiles->currentIndex()==0) {+ // no server selected: forget the previous one, an empty syntax disables the LSP features+ lsProfile.clear();+ lsSyntax.clear();+ lsOptions.clear();+ lsDelay = 0;+ ui->leLSExec->clear(); // also clears lsExecutable via on_leLSExec_textChanged() return;+ } lsProfile=ui->comboLSProfiles->currentText().toStdString(); @@ -2262,7 +2286,8 @@ void MainWindow::on_leLSExec_textChanged(){ } void MainWindow::on_pbSelWorkspace_clicked(){- ui->leLSWorkspace->setText(QFileDialog::getExistingDirectory(this, tr("Select workspace directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks));+ QString dir = QFileDialog::getExistingDirectory(this, tr("Select workspace directory"), "/home", QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);+ if (!dir.isEmpty()) ui->leLSWorkspace->setText(dir); } void MainWindow::on_pbSelExecutable_clicked(){
@@ -210,6 +210,7 @@ private slots: void on_pbBrowseOutDir_clicked(); void on_lvUserScripts_itemClicked(QListWidgetItem *item);+ void onUserScriptChanged(QListWidgetItem *item); void on_lvPluginScripts_itemClicked(QListWidgetItem *item); void on_browserPreview_selectionChanged();