WSL/SLF GitLab Repository

Commit 56a81534 authored by Michael Reisecker's avatar Michael Reisecker
Browse files

Integration improvement for validity markers

No more "invisible" link, added tooltips
parent 51b3c724
......@@ -16,6 +16,9 @@
<parameter key="TEXT3" type="text" optional="false" default="${env:USeR}">
<help>Styling of invalid expression</help>
</parameter>
<parameter key="TEXT4" type="text" optional="false" validate="^(\w+)(\d+)$" default="STATION1">
<help>Validation for text + number</help>
</parameter>
<parameter key="CHECK" type="checkbox" caption="check me" optional="false" default="true">
<help>Old styling for special cases without label</help>
......
......@@ -288,7 +288,7 @@ void MainWindow::openIni()
const QString path( QFileDialog::getOpenFileName(this, tr("Open INI file"), start_path,
"INI files (*.ini);;All files (*)", nullptr,
QFileDialog::DontUseNativeDialog | QFileDialog::DontConfirmOverwrite) );
QFileDialog::DontUseNativeDialog | QFileDialog::DontConfirmOverwrite) );
if (path.isNull()) //cancelled
return;
openIni(path);
......
......@@ -55,7 +55,6 @@ Textfield::Textfield(const QString &section, const QString &key, const QDomNode
sz_label.setWidth(static_cast<int>(fontMetrics().boundingRect(Cst::u_globe).width()) * 1.2);
sz_label.setHeight(static_cast<int>(fontMetrics().boundingRect(Cst::u_globe).height()));
nav_button_->setFixedSize(sz_label);
nav_button_->setCursor(Qt::PointingHandCursor);
connect(nav_button_, &QToolButton::clicked, this, &Textfield::navButtonClicked);
/* layout of textbox plus button and the main layout */
......@@ -128,24 +127,33 @@ void Textfield::checkValue(const QString &text)
setDefaultPanelStyles(text);
if (coord_match.captured(idx_full) == text && !text.isEmpty()) {
nav_button_->setText(Cst::u_globe);
nav_button_->setCursor(Qt::PointingHandCursor);
nav_button_->setToolTip(tr("Show online map"));
} else {
if (!validation_regex_.isNull()) { //check against regex specified in XML
const QRegularExpression rex_xml(validation_regex_);
const QRegularExpressionMatch xml_match(rex_xml.match(text));
const bool is_invalid = xml_match.captured(idx_full) != text && !text.isEmpty();
setInvalidStyle(is_invalid);
nav_button_->setText(is_invalid? Cst::u_warning : Cst::u_valid);
nav_button_->setProperty("invalid", is_invalid? "true" : "false"); //set "invalid" style on label-button also
nav_button_->setText(is_invalid? Cst::u_warning : (text.isEmpty()? "" : Cst::u_valid));
nav_button_->setCursor(text.isEmpty()? Qt::ArrowCursor : Qt::PointingHandCursor); //mark as link
nav_button_->setToolTip(text.isEmpty()? "" :
(is_invalid? tr("Entered expression has wrong format") : tr("Valid expression")));
//set "invalid" style on navigation button also:
nav_button_->setProperty("invalid", is_invalid? "true" : "false");
nav_button_->style()->unpolish(nav_button_);
nav_button_->style()->polish(nav_button_);
} else { //check for (arithmetic) expressions
bool evaluation_success;
const bool is_expression = expr::checkExpression(text, evaluation_success,
substitutions_, needs_prefix_for_evaluation_);
const bool is_invalid = (is_expression && !evaluation_success) && !text.isEmpty();
const bool is_invalid = is_expression && !evaluation_success;
setInvalidStyle(is_invalid);
nav_button_->setProperty("invalid", is_invalid? "true" : "false");
nav_button_->setText(is_invalid? Cst::u_warning : (is_expression? Cst::u_valid : ""));
nav_button_->setCursor(is_expression? Qt::PointingHandCursor : Qt::ArrowCursor);
nav_button_->setToolTip(is_expression?
(is_invalid? tr("Entered expression has wrong format") : tr("Valid expression")) : "");
nav_button_->setProperty("invalid", is_invalid? "true" : "false");
nav_button_->style()->unpolish(nav_button_);
nav_button_->style()->polish(nav_button_);
}
......@@ -160,6 +168,8 @@ void Textfield::checkValue(const QString &text)
*/
void Textfield::navButtonClicked() //for now this button only pops up for coordinates
{
if (nav_button_->text().isEmpty())
return;
if (nav_button_->text() != Cst::u_globe) { //"valid" resp. "invalid" icons
getMainWindow()->loadHelp("Input panels 1", "help-textfield");
return;
......
Supports Markdown
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