From: Jürgen Spitzmüller Date: Fri, 15 Apr 2005 08:56:46 +0000 (+0000) Subject: fix qprefs ui (bug 1829) X-Git-Tag: 1.6.10~14396 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=e54f1bea17e53511d37b0f4ab11c8d009f752f4a;p=features.git fix qprefs ui (bug 1829) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9816 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index ce01731360..6c563eacc2 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,10 @@ +2005-04-15 Jürgen Spitzmüller + + * ui/QPrefsConvertersModule.ui: + * ui/QPrefsCopiersModule.ui: + * ui/QPrefsFileformatsModule.ui: + * QPrefsDialog.[Ch]: more intuitive ui (cf. bug 1829) + 2005-04-14 Jürgen Spitzmüller * ui/NumberingModuleBase.ui: Remove numbering items ... diff --git a/src/frontends/qt2/QPrefsDialog.C b/src/frontends/qt2/QPrefsDialog.C index f2c364b118..050c93b044 100644 --- a/src/frontends/qt2/QPrefsDialog.C +++ b/src/frontends/qt2/QPrefsDialog.C @@ -179,6 +179,12 @@ QPrefsDialog::QPrefsDialog(QPrefs * form) connect(fileformatsModule->formatRemovePB, SIGNAL(clicked()), this, SLOT(remove_format())); connect(fileformatsModule->formatModifyPB, SIGNAL(clicked()), this, SLOT(modify_format())); connect(fileformatsModule->formatsLB, SIGNAL(highlighted(int)), this, SLOT(switch_format(int))); + connect(fileformatsModule->formatED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed())); + connect(fileformatsModule->guiNameED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed())); + connect(fileformatsModule->shortcutED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed())); + connect(fileformatsModule->extensionED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed())); + connect(fileformatsModule->viewerED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed())); + connect(fileformatsModule->editorED, SIGNAL(textChanged(const QString&)), this, SLOT(fileformat_changed())); connect(convertersModule->converterNewPB, SIGNAL(clicked()), this, SLOT(new_converter())); connect(convertersModule->converterRemovePB, SIGNAL(clicked()), this, SLOT(remove_converter())); @@ -204,6 +210,8 @@ QPrefsDialog::QPrefsDialog(QPrefs * form) connect(copiersModule->copierNewPB, SIGNAL(clicked()), this, SLOT(change_adaptor())); connect(copiersModule->copierRemovePB, SIGNAL(clicked()), this, SLOT(change_adaptor())); connect(copiersModule->copierModifyPB, SIGNAL(clicked()), this, SLOT(change_adaptor())); + connect(copiersModule->copierFormatCO, SIGNAL(activated(const QString&)), this, SLOT(copiers_changed())); + connect(copiersModule->copierED, SIGNAL(textChanged(const QString&)), this, SLOT(copiers_changed())); connect(fileformatsModule->formatNewPB, SIGNAL(clicked()), this, SLOT(change_adaptor())); connect(fileformatsModule->formatRemovePB, SIGNAL(clicked()), this, SLOT(change_adaptor())); @@ -337,6 +345,10 @@ void QPrefsDialog::updateConverters() { QPrefConvertersModule * convertmod(convertersModule); + // save current selection + QString current = convertmod->converterFromCO->currentText() + + " -> " + convertmod->converterToCO->currentText(); + convertmod->converterFromCO->clear(); convertmod->converterToCO->clear(); @@ -357,6 +369,12 @@ void QPrefsDialog::updateConverters() convertmod->convertersLB->insertItem(toqstr(name)); } + // restore selection + if (!current.isEmpty()) { + QListBoxItem * item = convertmod->convertersLB->findItem(current); + convertmod->convertersLB->setCurrentItem(item); + } + // select first element if restoring failed if (convertmod->convertersLB->currentItem() == -1) convertmod->convertersLB->setCurrentItem(0); @@ -455,6 +473,8 @@ void QPrefsDialog::remove_converter() void QPrefsDialog::updateCopiers() { // The choice widget + // save current selection + QString current = copiersModule->copierFormatCO->currentText(); copiersModule->copierFormatCO->clear(); for (Formats::const_iterator it = form_->formats().begin(), @@ -478,6 +498,12 @@ void QPrefsDialog::updateCopiers() copiersModule->AllCopiersLB->insertItem(toqstr(pretty)); } + // restore selection + if (!current.isEmpty()) { + QListBoxItem * item = copiersModule->AllCopiersLB->findItem(current); + copiersModule->AllCopiersLB->setCurrentItem(item); + } + // select first element if restoring failed if (copiersModule->AllCopiersLB->currentItem() == -1) copiersModule->AllCopiersLB->setCurrentItem(0); } @@ -540,6 +566,7 @@ void QPrefsDialog::switch_copierLB(int nr) break; } } + updateCopierButtons(); } @@ -582,6 +609,36 @@ void QPrefsDialog::switch_copierCO(int nr) } +void QPrefsDialog::copiers_changed() +{ + updateCopierButtons(); +} + + +void QPrefsDialog::updateCopierButtons() +{ + QString selected = copiersModule->copierFormatCO->currentText(); + + bool known = false; + for (unsigned int i = 0; i != copiersModule->AllCopiersLB->count(); i++) { + if (copiersModule->AllCopiersLB->text(i) == selected) + known = true; + } + + bool const valid = !copiersModule->copierED->text().isEmpty(); + + Format const * fmt = getFormat(fromqstr(selected)); + string const old_command = form_->movers().command(fmt->name()); + string const new_command(fromqstr(copiersModule->copierED->text())); + + bool modified = (old_command != new_command); + + copiersModule->copierModifyPB->setEnabled(valid && known && modified); + copiersModule->copierNewPB->setEnabled(valid && !known); + copiersModule->copierRemovePB->setEnabled(known); +} + + void QPrefsDialog::new_copier() { std::string const combo_text = @@ -599,6 +656,8 @@ void QPrefsDialog::new_copier() updateCopiers(); int const last = copiersModule->AllCopiersLB->count() - 1; copiersModule->AllCopiersLB->setCurrentItem(last); + + updateCopierButtons(); } @@ -614,6 +673,7 @@ void QPrefsDialog::modify_copier() form_->movers().set(fmt->name(), command); updateCopiers(); + updateCopierButtons(); } @@ -629,6 +689,7 @@ void QPrefsDialog::remove_copier() form_->movers().set(fmt_name, string()); updateCopiers(); + updateCopierButtons(); } @@ -636,6 +697,9 @@ void QPrefsDialog::updateFormats() { QPrefFileformatsModule * formatmod(fileformatsModule); + // save current selection + QString current = formatmod->guiNameED->text(); + formatmod->formatsLB->clear(); Formats::const_iterator cit = form_->formats().begin(); @@ -644,6 +708,12 @@ void QPrefsDialog::updateFormats() formatmod->formatsLB->insertItem(toqstr(cit->prettyname())); } + // restore selection + if (!current.isEmpty()) { + QListBoxItem * item = formatmod->formatsLB->findItem(current); + formatmod->formatsLB->setCurrentItem(item); + } + // select first element if restoring failed if (formatmod->formatsLB->currentItem() == -1) formatmod->formatsLB->setCurrentItem(0); } @@ -660,17 +730,80 @@ void QPrefsDialog::switch_format(int nr) fileformatsModule->editorED->setText(toqstr(f.editor())); fileformatsModule->formatRemovePB->setEnabled( !form_->converters().formatIsUsed(f.name())); + + updateFormatsButtons(); +} + + +void QPrefsDialog::fileformat_changed() +{ + updateFormatsButtons(); +} + + +void QPrefsDialog::updateFormatsButtons() +{ + QString const format = fileformatsModule->formatED->text(); + QString const gui_name = fileformatsModule->guiNameED->text(); + int const sel = form_->formats().getNumber(fromqstr(format)); + bool gui_name_known = false; + int where = sel; + for (unsigned int i = 0; i != fileformatsModule->formatsLB->count(); i++) { + if (fileformatsModule->formatsLB->text(i) == gui_name) { + gui_name_known = true; + where = i; + } + } + + // assure that a gui name cannot be chosen twice + bool const known_otherwise = gui_name_known && (where != sel); + + bool const known = !(sel < 0); + bool const valid = (!fileformatsModule->formatED->text().isEmpty() + && !fileformatsModule->guiNameED->text().isEmpty()); + + Format const & f(form_->formats().get( + fileformatsModule->formatsLB->currentItem())); + string const old_pretty(f.prettyname()); + string const old_shortcut(f.shortcut()); + string const old_extension(f.extension()); + string const old_viewer(f.viewer()); + string const old_editor(f.editor()); + + string const new_pretty(fromqstr(gui_name)); + string const new_shortcut(fromqstr(fileformatsModule->shortcutED->text())); + string const new_extension(fromqstr(fileformatsModule->extensionED->text())); + string const new_viewer(fromqstr(fileformatsModule->viewerED->text())); + string const new_editor(fromqstr(fileformatsModule->editorED->text())); + + bool modified = ((old_pretty != new_pretty) || (old_shortcut != new_shortcut) + || (old_extension != new_extension) || (old_viewer != new_viewer) + || (old_editor != new_editor)); + + fileformatsModule->formatModifyPB->setEnabled( + valid && known && modified && !known_otherwise); + fileformatsModule->formatNewPB->setEnabled(valid && !known && !gui_name_known); + fileformatsModule->formatRemovePB->setEnabled(known); } void QPrefsDialog::new_format() { - form_->formats().add(_("New")); + string const name = fromqstr(fileformatsModule->formatED->text()); + string const prettyname = fromqstr(fileformatsModule->guiNameED->text()); + string const extension = fromqstr(fileformatsModule->extensionED->text()); + string const shortcut = fromqstr(fileformatsModule->shortcutED->text()); + string const viewer = fromqstr(fileformatsModule->viewerED->text()); + string const editor = fromqstr(fileformatsModule->editorED->text()); + + form_->formats().add(name, extension, prettyname, shortcut, viewer, editor); form_->formats().sort(); updateFormats(); - fileformatsModule->formatsLB->setCurrentItem(form_->formats().getNumber(_("New"))); + fileformatsModule->formatsLB->setCurrentItem(form_->formats().getNumber(name)); form_->converters().update(form_->formats()); + updateConverters(); + updateFormatsButtons(); } @@ -696,6 +829,7 @@ void QPrefsDialog::modify_format() fileformatsModule->formatsLB->update(); updateConverters(); + updateFormatsButtons(); } @@ -707,7 +841,9 @@ void QPrefsDialog::remove_format() form_->formats().erase(form_->formats().get(nr).name()); updateFormats(); form_->converters().update(form_->formats()); + updateConverters(); + updateFormatsButtons(); } diff --git a/src/frontends/qt2/QPrefsDialog.h b/src/frontends/qt2/QPrefsDialog.h index 9e1a223d34..facac1fd62 100644 --- a/src/frontends/qt2/QPrefsDialog.h +++ b/src/frontends/qt2/QPrefsDialog.h @@ -54,12 +54,15 @@ public: void updateConverters(); void updateConverterButtons(); void updateCopiers(); + void updateCopierButtons(); void updateFormats(); + void updateFormatsButtons(); public slots: void change_adaptor(); void switch_format(int); + void fileformat_changed(); void new_format(); void modify_format(); void remove_format(); @@ -72,6 +75,7 @@ public slots: void switch_copierLB(int nr); void switch_copierCO(int nr); + void copiers_changed(); void new_copier(); void modify_copier(); void remove_copier(); diff --git a/src/frontends/qt2/ui/QPrefConvertersModule.ui b/src/frontends/qt2/ui/QPrefConvertersModule.ui index 0665bf07bf..6fb38ad860 100644 --- a/src/frontends/qt2/ui/QPrefConvertersModule.ui +++ b/src/frontends/qt2/ui/QPrefConvertersModule.ui @@ -13,7 +13,7 @@ 0 0 - 466 + 458 265 @@ -30,98 +30,6 @@ spacing 6 - - QLayoutWidget - - name - Layout7 - - - - margin - 0 - - - spacing - 6 - - - QLabel - - name - formatsLA_2 - - - text - &Converters - - - buddy - convertersLB - - - - - name - Spacer8 - - - orientation - Horizontal - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - QPushButton - - name - converterRemovePB - - - text - &Remove - - - - QListBox - - - text - New Item - - - - name - convertersLB - - - sizePolicy - - 3 - 7 - - - - vScrollBarMode - AlwaysOn - - - hScrollBarMode - AlwaysOff - - - - QLayoutWidget @@ -339,6 +247,115 @@ + + QLayoutWidget + + name + Layout6 + + + + margin + 0 + + + spacing + 6 + + + QLabel + + name + formatsLA_2 + + + text + &Converters + + + buddy + convertersLB + + + + QLayoutWidget + + name + Layout5 + + + + margin + 0 + + + spacing + 6 + + + + name + Spacer8 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + QPushButton + + name + converterRemovePB + + + text + &Remove + + + + + + QListBox + + + text + New Item + + + + name + convertersLB + + + sizePolicy + + 5 + 7 + + + + vScrollBarMode + AlwaysOn + + + hScrollBarMode + AlwaysOff + + + + diff --git a/src/frontends/qt2/ui/QPrefCopiersModule.ui b/src/frontends/qt2/ui/QPrefCopiersModule.ui index e446ec5d0b..d2455e4f70 100644 --- a/src/frontends/qt2/ui/QPrefCopiersModule.ui +++ b/src/frontends/qt2/ui/QPrefCopiersModule.ui @@ -13,7 +13,7 @@ 0 0 - 547 + 428 261 @@ -21,7 +21,7 @@ caption File Conversion - + margin 11 @@ -30,13 +30,13 @@ spacing 6 - + QLayoutWidget name - Layout4 + Layout7 - + margin 0 @@ -45,28 +45,41 @@ spacing 6 - - QLabel + + QListBox + + + text + New Item + + name - AllCopiersLA + AllCopiersLB - text - C&opiers + sizePolicy + + 5 + 7 + - - buddy - AllCopiersLB + + vScrollBarMode + Auto + + + hScrollBarMode + AlwaysOff - + QLayoutWidget name - Layout1 + Layout6 - + margin 0 @@ -75,46 +88,28 @@ spacing 6 - - QListBox - - - text - New Item - - - + + name - AllCopiersLB + Spacer3 - sizePolicy - - 3 - 7 - - - - vScrollBarMode - AlwaysOn - - - hScrollBarMode - AlwaysOff + orientation + Horizontal - - - QPushButton - name - copierNewPB + sizeType + Preferred - - text - &New + + sizeHint + + 20 + 20 + - - + + QPushButton name @@ -125,17 +120,32 @@ &Remove - + - + + QLabel + + name + AllCopiersLA + + + text + C&opiers + + + buddy + AllCopiersLB + + + - + QLayoutWidget name - Layout6 + Layout9 - + margin 0 @@ -144,7 +154,67 @@ spacing 6 - + + QLayoutWidget + + name + Layout8 + + + + margin + 0 + + + spacing + 6 + + + QPushButton + + name + copierNewPB + + + text + &Add + + + + QPushButton + + name + copierModifyPB + + + text + &Modify + + + + + name + Spacer2 + + + orientation + Horizontal + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + + + QLayoutWidget name @@ -212,56 +282,7 @@ - - QLayoutWidget - - name - Layout5 - - - - margin - 0 - - - spacing - 6 - - - QPushButton - - name - copierModifyPB - - - text - &Modify - - - - - name - Spacer2 - - - orientation - Horizontal - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - - - + name Spacer28 @@ -282,9 +303,9 @@ - + - + AllCopiersLB diff --git a/src/frontends/qt2/ui/QPrefFileformatsModule.ui b/src/frontends/qt2/ui/QPrefFileformatsModule.ui index 173ec52600..c8d86b7de6 100644 --- a/src/frontends/qt2/ui/QPrefFileformatsModule.ui +++ b/src/frontends/qt2/ui/QPrefFileformatsModule.ui @@ -13,7 +13,7 @@ 0 0 - 356 + 419 261 @@ -21,7 +21,7 @@ caption File Formats - + margin 11 @@ -30,13 +30,13 @@ spacing 6 - + QLayoutWidget name - Layout3 + Layout4 - + margin 0 @@ -45,88 +45,226 @@ spacing 6 - + + QLineEdit + + name + viewerED + + + + QLineEdit + + name + editorED + + + + QLineEdit + + name + shortcutED + + + QLabel name - formatsLA + guiNameLA text - &File formats + &GUI name: buddy - formatsLB + guiNameED + + QLabel + + name + formatLA + + + text + F&ormat: + + + buddy + formatED + + + + QLineEdit + + name + guiNameED + + + + QLabel + + name + viewerLA + + + text + &Viewer: + + + buddy + viewerED + + + + QLabel + + name + editorLA + + + text + Ed&itor: + + + buddy + editorED + + + + QLineEdit + + name + formatED + + + + QLabel + + name + shortcutLA + + + text + S&hortcut: + + + buddy + shortcutED + + + + QLabel + + name + extensionLA + + + text + E&xtension: + + + buddy + extensionED + + + + QLineEdit + + name + extensionED + + + + + + QLayoutWidget + + name + Layout5 + + + + margin + 0 + + + spacing + 6 + - QLayoutWidget + QPushButton name - Layout1 + formatNewPB + + + text + &Add - - - margin - 0 - - - spacing - 6 - - - QPushButton - - name - formatNewPB - - - text - &New - - - - QListBox - - - text - New Item - - - - name - formatsLB - - - vScrollBarMode - AlwaysOn - - - hScrollBarMode - AlwaysOff - - - - QPushButton - - name - formatRemovePB - - - text - &Remove - - - - + + QPushButton + + name + formatModifyPB + + + text + &Modify + + + + + name + Spacer3_2 + + + orientation + Horizontal + + + sizeType + MinimumExpanding + + + sizeHint + + 20 + 20 + + + + - + + + name + Spacer26 + + + orientation + Vertical + + + sizeType + Expanding + + + sizeHint + + 20 + 20 + + + + QLayoutWidget name - Layout6 + Layout10 @@ -138,159 +276,53 @@ 6 - QLayoutWidget + QLabel name - Layout4 + formatsLA - - - margin - 0 - - - spacing - 6 + + text + &File formats + + + buddy + formatsLB + + + + QListBox + + + text + New Item - - QLineEdit - - name - viewerED - - - - QLineEdit - - name - editorED - - - - QLineEdit - - name - shortcutED - - - - QLabel - - name - guiNameLA - - - text - &GUI name: - - - buddy - guiNameED - - - - QLabel - - name - formatLA - - - text - F&ormat: - - - buddy - formatED - - - - QLineEdit - - name - guiNameED - - - - QLabel - - name - viewerLA - - - text - &Viewer: - - - buddy - viewerED - - - - QLabel - - name - editorLA - - - text - Ed&itor: - - - buddy - editorED - - - - QLineEdit - - name - formatED - - - - QLabel - - name - shortcutLA - - - text - S&hortcut: - - - buddy - shortcutED - - - - QLabel - - name - extensionLA - - - text - E&xtension: - - - buddy - extensionED - - - - QLineEdit - - name - extensionED - - - + + + name + formatsLB + + + sizePolicy + + 5 + 7 + + + + vScrollBarMode + AlwaysOn + + + hScrollBarMode + AlwaysOff + QLayoutWidget name - Layout5 + Layout7 @@ -301,21 +333,10 @@ spacing 6 - - QPushButton - - name - formatModifyPB - - - text - &Modify - - name - Spacer2 + Spacer3 orientation @@ -323,7 +344,7 @@ sizeType - Expanding + Preferred sizeHint @@ -333,32 +354,43 @@ + + QPushButton + + name + formatRemovePB + + + text + &Remove + + - - - name - Spacer26 - - - orientation - Vertical - - - sizeType - Expanding - - - sizeHint - - 20 - 20 - - - - + + + name + Spacer4 + + + orientation + Horizontal + + + sizeType + Minimum + + + sizeHint + + 20 + 20 + + + + formatsLB