Solarus-Games English Forum

Solarus => Bugs & Feature requests => Topic started by: topdown on May 26, 2015, 12:35:06 AM

Title: Editor Design Consideration- Should loss of focus be required to save a setting?
Post by: topdown on May 26, 2015, 12:35:06 AM
If I change the title bar property in 1.4.2, the editor does not know it unless I tab out, losing the focus, triggering the SIGNAL.  I confess I am not an expert in Qt, C++, or the overall design, though I am getting up to speed. 

I saw this on Github:

settings_dialog.cpp


  connect(&model, SIGNAL(title_bar_changed(QString)),
          this, SLOT(update_title_bar_field()));
  connect(ui.title_bar_field, SIGNAL(editingFinished()),
          this, SLOT(change_title_bar_requested()));



and in plain_text_edit.h,



class PlainTextEdit : public QPlainTextEdit ....

  inline PlainTextEdit(QWidget* parent = nullptr) :
    QPlainTextEdit(parent),
    changed(false),
    show_margin(false) {

    setTabChangesFocus(true);
    setLineWrapMode(LineWrapMode::NoWrap);

    QTextCharFormat char_format = currentCharFormat();
    char_format.setFontFixedPitch(true);
    setCurrentCharFormat(char_format);

    connect(this, SIGNAL(textChanged()), this, SLOT(handle_text_changed()));
  }


Do you think this should be on changing any text in the field or that you have to tab out.  I found that I would change the title bar and run the program.  I saw no change, so I hit save.  I saw no change, and that is when I figured out I had to lose focus.

Interested in feedback.  Thanks.
Title: Re: Editor Design Consideration- Should loss of focus be required to save a setting?
Post by: Christopho on June 19, 2015, 02:40:00 PM
Yes this is a very annoying problem. We fixed the issue in the development version 1.4.3. Thanks for reporting it!
Title: Re: Editor Design Consideration- Should loss of focus be required to save a setting?
Post by: topdown on June 20, 2015, 02:50:12 PM
Would I look at the same point in the code I have above to see the solution?  I like to learn :).
Title: Re: Editor Design Consideration- Should loss of focus be required to save a setting?
Post by: Christopho on June 20, 2015, 05:12:38 PM
We created a new subclass of QPlainTextEdit (and same for QLineEdit) that validates modifications using a QTimer.
https://github.com/christopho/solarus-quest-editor/commit/6e42c0c3737a9d4a2d8ae12d1617644b34499480