mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-24 21:55:29 +00:00
fix crash when adding new format (bug 1692), improve qt converters ui (bug 1488)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9204 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
246b54496e
commit
248968e24c
@ -1,3 +1,12 @@
|
|||||||
|
2004-11-08 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
|
||||||
|
|
||||||
|
* QPrefsDialog.C (new_format(), remove_format()): fix crash when
|
||||||
|
adding new formats (add missing converters().update() call) [bug 1692]
|
||||||
|
|
||||||
|
* QPrefsDialog.[Ch]:
|
||||||
|
* ui/QPrefConvertersModule.C: improve ui for converter changes
|
||||||
|
[bug 1488].
|
||||||
|
|
||||||
2004-11-06 Lars Gullik Bjonnes <larsbj@gullik.net>
|
2004-11-06 Lars Gullik Bjonnes <larsbj@gullik.net>
|
||||||
|
|
||||||
* QLImage.C (loadableFormats): use bind, equal_to instead of
|
* QLImage.C (loadableFormats): use bind, equal_to instead of
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#include <qlineedit.h>
|
#include <qlineedit.h>
|
||||||
#include <qpushbutton.h>
|
#include <qpushbutton.h>
|
||||||
#include <qspinbox.h>
|
#include <qspinbox.h>
|
||||||
|
#include <qstring.h>
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
@ -173,6 +174,10 @@ QPrefsDialog::QPrefsDialog(QPrefs * form)
|
|||||||
connect(convertersModule->converterRemovePB, SIGNAL(clicked()), this, SLOT(remove_converter()));
|
connect(convertersModule->converterRemovePB, SIGNAL(clicked()), this, SLOT(remove_converter()));
|
||||||
connect(convertersModule->converterModifyPB, SIGNAL(clicked()), this, SLOT(modify_converter()));
|
connect(convertersModule->converterModifyPB, SIGNAL(clicked()), this, SLOT(modify_converter()));
|
||||||
connect(convertersModule->convertersLB, SIGNAL(highlighted(int)), this, SLOT(switch_converter(int)));
|
connect(convertersModule->convertersLB, SIGNAL(highlighted(int)), this, SLOT(switch_converter(int)));
|
||||||
|
connect(convertersModule->converterFromCO, SIGNAL(activated(const QString&)), this, SLOT(converter_changed()));
|
||||||
|
connect(convertersModule->converterToCO, SIGNAL(activated(const QString&)), this, SLOT(converter_changed()));
|
||||||
|
connect(convertersModule->converterED, SIGNAL(textChanged(const QString&)), this, SLOT(converter_changed()));
|
||||||
|
connect(convertersModule->converterFlagED, SIGNAL(textChanged(const QString&)), this, SLOT(converter_changed()));
|
||||||
|
|
||||||
// Qt really sucks. This is as ugly as it looks, but the alternative
|
// Qt really sucks. This is as ugly as it looks, but the alternative
|
||||||
// means having to derive every module == bloat
|
// means having to derive every module == bloat
|
||||||
@ -311,13 +316,15 @@ void QPrefsDialog::updateConverters()
|
|||||||
Converters::const_iterator ccit = form_->converters().begin();
|
Converters::const_iterator ccit = form_->converters().begin();
|
||||||
Converters::const_iterator cend = form_->converters().end();
|
Converters::const_iterator cend = form_->converters().end();
|
||||||
for (; ccit != cend; ++ccit) {
|
for (; ccit != cend; ++ccit) {
|
||||||
string const name(ccit->From->prettyname() + " -> " +
|
std::string const name = ccit->From->prettyname() + " -> "
|
||||||
ccit->To->prettyname());
|
+ ccit->To->prettyname();
|
||||||
convertmod->convertersLB->insertItem(toqstr(name));
|
convertmod->convertersLB->insertItem(toqstr(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (convertmod->convertersLB->currentItem() == -1)
|
if (convertmod->convertersLB->currentItem() == -1)
|
||||||
convertmod->convertersLB->setCurrentItem(0);
|
convertmod->convertersLB->setCurrentItem(0);
|
||||||
|
|
||||||
|
updateConverterButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -328,6 +335,40 @@ void QPrefsDialog::switch_converter(int nr)
|
|||||||
convertersModule->converterToCO->setCurrentItem(form_->formats().getNumber(c.to));
|
convertersModule->converterToCO->setCurrentItem(form_->formats().getNumber(c.to));
|
||||||
convertersModule->converterED->setText(toqstr(c.command));
|
convertersModule->converterED->setText(toqstr(c.command));
|
||||||
convertersModule->converterFlagED->setText(toqstr(c.flags));
|
convertersModule->converterFlagED->setText(toqstr(c.flags));
|
||||||
|
|
||||||
|
updateConverterButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QPrefsDialog::converter_changed()
|
||||||
|
{
|
||||||
|
updateConverterButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QPrefsDialog::updateConverterButtons()
|
||||||
|
{
|
||||||
|
Format const & from(form_->formats().get(
|
||||||
|
convertersModule->converterFromCO->currentItem()));
|
||||||
|
Format const & to(form_->formats().get(
|
||||||
|
convertersModule->converterToCO->currentItem()));
|
||||||
|
int const sel = form_->converters().getNumber(from.name(), to.name());
|
||||||
|
bool const known = !(sel < 0);
|
||||||
|
bool const valid = !(convertersModule->converterED->text().isEmpty()
|
||||||
|
|| from.name() == to.name());
|
||||||
|
|
||||||
|
Converter const & c(form_->converters().get(
|
||||||
|
convertersModule->convertersLB->currentItem()));
|
||||||
|
string const old_command = c.command;
|
||||||
|
string const old_flag = c.flags;
|
||||||
|
string const new_command(fromqstr(convertersModule->converterED->text()));
|
||||||
|
string const new_flag(fromqstr(convertersModule->converterFlagED->text()));
|
||||||
|
|
||||||
|
bool modified = ((old_command != new_command) || (old_flag != new_flag));
|
||||||
|
|
||||||
|
convertersModule->converterModifyPB->setEnabled(valid && known && modified);
|
||||||
|
convertersModule->converterNewPB->setEnabled(valid && !known);
|
||||||
|
convertersModule->converterRemovePB->setEnabled(known);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -337,9 +378,11 @@ void QPrefsDialog::new_converter()
|
|||||||
{
|
{
|
||||||
Format const & from(form_->formats().get(convertersModule->converterFromCO->currentItem()));
|
Format const & from(form_->formats().get(convertersModule->converterFromCO->currentItem()));
|
||||||
Format const & to(form_->formats().get(convertersModule->converterToCO->currentItem()));
|
Format const & to(form_->formats().get(convertersModule->converterToCO->currentItem()));
|
||||||
|
string const command(fromqstr(convertersModule->converterED->text()));
|
||||||
|
string const flags(fromqstr(convertersModule->converterFlagED->text()));
|
||||||
|
|
||||||
Converter const * old = form_->converters().getConverter(from.name(), to.name());
|
Converter const * old = form_->converters().getConverter(from.name(), to.name());
|
||||||
form_->converters().add(from.name(), to.name(), "", "");
|
form_->converters().add(from.name(), to.name(), command, flags);
|
||||||
if (!old) {
|
if (!old) {
|
||||||
form_->converters().updateLast(form_->formats());
|
form_->converters().updateLast(form_->formats());
|
||||||
}
|
}
|
||||||
@ -589,6 +632,7 @@ void QPrefsDialog::new_format()
|
|||||||
form_->formats().sort();
|
form_->formats().sort();
|
||||||
updateFormats();
|
updateFormats();
|
||||||
fileformatsModule->formatsLB->setCurrentItem(form_->formats().getNumber(_("New")));
|
fileformatsModule->formatsLB->setCurrentItem(form_->formats().getNumber(_("New")));
|
||||||
|
form_->converters().update(form_->formats());
|
||||||
updateConverters();
|
updateConverters();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,6 +669,7 @@ void QPrefsDialog::remove_format()
|
|||||||
return;
|
return;
|
||||||
form_->formats().erase(form_->formats().get(nr).name());
|
form_->formats().erase(form_->formats().get(nr).name());
|
||||||
updateFormats();
|
updateFormats();
|
||||||
|
form_->converters().update(form_->formats());
|
||||||
updateConverters();
|
updateConverters();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ public:
|
|||||||
~QPrefsDialog();
|
~QPrefsDialog();
|
||||||
|
|
||||||
void updateConverters();
|
void updateConverters();
|
||||||
|
void updateConverterButtons();
|
||||||
void updateCopiers();
|
void updateCopiers();
|
||||||
void updateFormats();
|
void updateFormats();
|
||||||
|
|
||||||
@ -61,6 +62,7 @@ public slots:
|
|||||||
void remove_format();
|
void remove_format();
|
||||||
|
|
||||||
void switch_converter(int);
|
void switch_converter(int);
|
||||||
|
void converter_changed();
|
||||||
void new_converter();
|
void new_converter();
|
||||||
void modify_converter();
|
void modify_converter();
|
||||||
void remove_converter();
|
void remove_converter();
|
||||||
|
@ -13,15 +13,15 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>384</width>
|
<width>466</width>
|
||||||
<height>261</height>
|
<height>265</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property stdset="1">
|
<property stdset="1">
|
||||||
<name>caption</name>
|
<name>caption</name>
|
||||||
<string>File Conversion</string>
|
<string>File Conversion</string>
|
||||||
</property>
|
</property>
|
||||||
<hbox>
|
<grid>
|
||||||
<property stdset="1">
|
<property stdset="1">
|
||||||
<name>margin</name>
|
<name>margin</name>
|
||||||
<number>11</number>
|
<number>11</number>
|
||||||
@ -30,13 +30,13 @@
|
|||||||
<name>spacing</name>
|
<name>spacing</name>
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<widget>
|
<widget row="0" column="0" >
|
||||||
<class>QLayoutWidget</class>
|
<class>QLayoutWidget</class>
|
||||||
<property stdset="1">
|
<property stdset="1">
|
||||||
<name>name</name>
|
<name>name</name>
|
||||||
<cstring>Layout4</cstring>
|
<cstring>Layout7</cstring>
|
||||||
</property>
|
</property>
|
||||||
<vbox>
|
<grid>
|
||||||
<property stdset="1">
|
<property stdset="1">
|
||||||
<name>margin</name>
|
<name>margin</name>
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
@ -45,7 +45,7 @@
|
|||||||
<name>spacing</name>
|
<name>spacing</name>
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<widget>
|
<widget row="0" column="0" rowspan="1" colspan="2" >
|
||||||
<class>QLabel</class>
|
<class>QLabel</class>
|
||||||
<property stdset="1">
|
<property stdset="1">
|
||||||
<name>name</name>
|
<name>name</name>
|
||||||
@ -60,82 +60,75 @@
|
|||||||
<cstring>convertersLB</cstring>
|
<cstring>convertersLB</cstring>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
<widget>
|
<spacer row="2" column="1" >
|
||||||
<class>QLayoutWidget</class>
|
<property>
|
||||||
|
<name>name</name>
|
||||||
|
<cstring>Spacer8</cstring>
|
||||||
|
</property>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>orientation</name>
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>sizeType</name>
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>sizeHint</name>
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
<widget row="2" column="0" >
|
||||||
|
<class>QPushButton</class>
|
||||||
<property stdset="1">
|
<property stdset="1">
|
||||||
<name>name</name>
|
<name>name</name>
|
||||||
<cstring>Layout1</cstring>
|
<cstring>converterRemovePB</cstring>
|
||||||
|
</property>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>text</name>
|
||||||
|
<string>&Remove</string>
|
||||||
</property>
|
</property>
|
||||||
<grid>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>margin</name>
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>spacing</name>
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<widget row="0" column="0" rowspan="1" colspan="2" >
|
|
||||||
<class>QListBox</class>
|
|
||||||
<item>
|
|
||||||
<property>
|
|
||||||
<name>text</name>
|
|
||||||
<string>New Item</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>name</name>
|
|
||||||
<cstring>convertersLB</cstring>
|
|
||||||
</property>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>sizePolicy</name>
|
|
||||||
<sizepolicy>
|
|
||||||
<hsizetype>3</hsizetype>
|
|
||||||
<vsizetype>7</vsizetype>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>vScrollBarMode</name>
|
|
||||||
<enum>AlwaysOn</enum>
|
|
||||||
</property>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>hScrollBarMode</name>
|
|
||||||
<enum>AlwaysOff</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget row="1" column="0" >
|
|
||||||
<class>QPushButton</class>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>name</name>
|
|
||||||
<cstring>converterNewPB</cstring>
|
|
||||||
</property>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>text</name>
|
|
||||||
<string>&New</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<widget row="1" column="1" >
|
|
||||||
<class>QPushButton</class>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>name</name>
|
|
||||||
<cstring>converterRemovePB</cstring>
|
|
||||||
</property>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>text</name>
|
|
||||||
<string>&Remove</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</grid>
|
|
||||||
</widget>
|
</widget>
|
||||||
</vbox>
|
<widget row="1" column="0" rowspan="1" colspan="2" >
|
||||||
|
<class>QListBox</class>
|
||||||
|
<item>
|
||||||
|
<property>
|
||||||
|
<name>text</name>
|
||||||
|
<string>New Item</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>name</name>
|
||||||
|
<cstring>convertersLB</cstring>
|
||||||
|
</property>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>sizePolicy</name>
|
||||||
|
<sizepolicy>
|
||||||
|
<hsizetype>3</hsizetype>
|
||||||
|
<vsizetype>7</vsizetype>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>vScrollBarMode</name>
|
||||||
|
<enum>AlwaysOn</enum>
|
||||||
|
</property>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>hScrollBarMode</name>
|
||||||
|
<enum>AlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
</widget>
|
</widget>
|
||||||
<widget>
|
<widget row="0" column="1" >
|
||||||
<class>QLayoutWidget</class>
|
<class>QLayoutWidget</class>
|
||||||
<property stdset="1">
|
<property stdset="1">
|
||||||
<name>name</name>
|
<name>name</name>
|
||||||
<cstring>Layout6</cstring>
|
<cstring>Layout16</cstring>
|
||||||
</property>
|
</property>
|
||||||
<vbox>
|
<grid>
|
||||||
<property stdset="1">
|
<property stdset="1">
|
||||||
<name>margin</name>
|
<name>margin</name>
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
@ -144,7 +137,7 @@
|
|||||||
<name>spacing</name>
|
<name>spacing</name>
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<widget>
|
<widget row="0" column="0" >
|
||||||
<class>QLayoutWidget</class>
|
<class>QLayoutWidget</class>
|
||||||
<property stdset="1">
|
<property stdset="1">
|
||||||
<name>name</name>
|
<name>name</name>
|
||||||
@ -263,56 +256,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</grid>
|
</grid>
|
||||||
</widget>
|
</widget>
|
||||||
<widget>
|
<spacer row="2" column="0" >
|
||||||
<class>QLayoutWidget</class>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>name</name>
|
|
||||||
<cstring>Layout5</cstring>
|
|
||||||
</property>
|
|
||||||
<hbox>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>margin</name>
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>spacing</name>
|
|
||||||
<number>6</number>
|
|
||||||
</property>
|
|
||||||
<widget>
|
|
||||||
<class>QPushButton</class>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>name</name>
|
|
||||||
<cstring>converterModifyPB</cstring>
|
|
||||||
</property>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>text</name>
|
|
||||||
<string>&Modify</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<spacer>
|
|
||||||
<property>
|
|
||||||
<name>name</name>
|
|
||||||
<cstring>Spacer2</cstring>
|
|
||||||
</property>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>orientation</name>
|
|
||||||
<enum>Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property stdset="1">
|
|
||||||
<name>sizeType</name>
|
|
||||||
<enum>Expanding</enum>
|
|
||||||
</property>
|
|
||||||
<property>
|
|
||||||
<name>sizeHint</name>
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</hbox>
|
|
||||||
</widget>
|
|
||||||
<spacer>
|
|
||||||
<property>
|
<property>
|
||||||
<name>name</name>
|
<name>name</name>
|
||||||
<cstring>Spacer28</cstring>
|
<cstring>Spacer28</cstring>
|
||||||
@ -333,9 +277,69 @@
|
|||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</vbox>
|
<widget row="1" column="0" >
|
||||||
|
<class>QLayoutWidget</class>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>name</name>
|
||||||
|
<cstring>Layout14</cstring>
|
||||||
|
</property>
|
||||||
|
<hbox>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>margin</name>
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>spacing</name>
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<widget>
|
||||||
|
<class>QPushButton</class>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>name</name>
|
||||||
|
<cstring>converterNewPB</cstring>
|
||||||
|
</property>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>text</name>
|
||||||
|
<string>A&dd</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget>
|
||||||
|
<class>QPushButton</class>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>name</name>
|
||||||
|
<cstring>converterModifyPB</cstring>
|
||||||
|
</property>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>text</name>
|
||||||
|
<string>&Modify</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<spacer>
|
||||||
|
<property>
|
||||||
|
<name>name</name>
|
||||||
|
<cstring>Spacer3</cstring>
|
||||||
|
</property>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>orientation</name>
|
||||||
|
<enum>Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property stdset="1">
|
||||||
|
<name>sizeType</name>
|
||||||
|
<enum>Expanding</enum>
|
||||||
|
</property>
|
||||||
|
<property>
|
||||||
|
<name>sizeHint</name>
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</hbox>
|
||||||
|
</widget>
|
||||||
|
</grid>
|
||||||
</widget>
|
</widget>
|
||||||
</hbox>
|
</grid>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>convertersLB</tabstop>
|
<tabstop>convertersLB</tabstop>
|
||||||
|
Loading…
Reference in New Issue
Block a user