#8 Dialog

Next Minor Release
open
5
2008-12-08
2008-10-27
No

I think that dialog operation as QFileDialog::getSaveFileName() or QMessageBox::warning must be let in subclass or extern class to let developper decide the user interface and text (open custom dialog, ...)

The function save, by ie. will be : save( Filename, Save | Reset | ... )

Discussion

  • fullmetalcoder
    fullmetalcoder
    2008-10-31

    I'm afraid I do not quite understand the purpose of that request from a user point of view.

    Using QFileDialog static methods is requested by many as it is the only way to use native
    dialogs (which many users want for tighter desktop integration).

    As for QMessageBox I'm not sure it is worth the trouble of reimplementing a special widget
    and substituting calls everywhere in Edyuk. Especially because it will not be possible to
    make such a thing in 3rdparty components (these modules are meant to be independent from
    Edyuk...)

    If you could elaborate your opinion that would be welcome.

    best regards

    fullmetalcoder

     
  • fullmetalcoder
    fullmetalcoder
    2008-10-31

    • milestone: 874753 -->
     
  • For QMessageDlg, i think QEditor or QCodeEdit must send a signal (or return a bool, ...) that give the information to the user interface. And the programmer of the user interface decide to call the good method.

    I think to QDocumentSearch next function. Instead of QMessageBox, the function can return false, or the method send the a signal to the user interface. So, we can change the message, add some options, ...

    Another example, if the user ask to save a file, if the file is of one type, i open a dialog with some information (depending of the projet), and the user can save the file without renaming or choose a new name for the file (and call the QFileDialog).

    For saving, i think the method must only save the file, and the user interface give to the method the file name to use (or blank if the file name don't change)

    By example :
    The method save :

    void QEditor::save( const QString & filename )
    {
    if ( !m_doc )
    return;

    QString oldFileName = fileName();

    if ( ! filename.isEmpty() )
    {
    setFileName(fn);
    }
    m_saveState = Saving;

    if ( oldFileName.count() )
    {
    watcher()->removeWatch(fileName(), this);
    }

    QFile f(fileName());

    if ( !f.open(QFile::WriteOnly) )
    {
    m_saveState = Undefined;
    reconnectWatcher();

    return;
    }

    f.write(m_doc->text(flag(RemoveTrailing), flag(PreserveTrailingIndent)).toLocal8Bit());

    m_doc->setClean();

    emit saved(this, fileName());
    m_saveState = Saved;

    QTimer::singleShot(100, this, SLOT( reconnectWatcher() ));

    update();
    }

    And the user :
    void mySaveAction() {
    if ( editor->fileName().isEmpty() )
    {
    QString fn = QFileDialog::getSaveFileName();

    if ( fn.isEmpty() )
    return;

    setFileName(fn);
    } else if ( isInConflict() ) {
    int ret = QMessageBox::warning(this,
    tr("Conflict!"),
    tr(
    "%1\nhas been modified by another application.\n"
    "Press \"Save\" to overwrite the file on disk\n"
    "Press \"Reset\"to be reload the file from disk.\n"
    "Press \"Discard\" to ignore this warning.\n"
    ).arg(fileName()),
    QMessageBox::Save
    |
    QMessageBox::Reset
    |
    QMessageBox::Discard
    |
    QMessageBox::Cancel
    );
    if ( ret == QMessageBox::Save )
    {
    editor->save(fileName());
    return;
    } else if ( ret == QMessageBox::Reset ) {
    editor->load(fileName());
    return;
    } else if ( ret == QMessageBox::Discard ) {
    return;
    } else {
    return;
    }
    }
    }

    It's only an idea but, if we can have the choice (let QEditor open dialog, or let the user interface)

     
  • fullmetalcoder
    fullmetalcoder
    2008-11-01

    • milestone: --> Next Minor Release
     
  • fullmetalcoder
    fullmetalcoder
    2008-11-01

    So your situation is, if I understood well (correct me if I'm wrong) :

    You are using QCodeEdit in your app and you would like to use custom
    dialogs instead of the ones used by QCodeEdit to keep things consistent
    with the rest of your app?

    I'll add some signals and move the offending code in "default handlers"
    (to keep backward compatiility) as soon as possible.

     
  • Ok, thanks :)

     
  • fullmetalcoder
    fullmetalcoder
    2008-12-08

    • assigned_to: nobody --> fullmetalcoder