mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-23 10:18:50 +00:00
fix bug 3456 and 3457
http://bugzilla.lyx.org/show_bug.cgi?id=3456 http://bugzilla.lyx.org/show_bug.cgi?id=3457 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17845 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
4fddff272f
commit
3802882900
@ -36,19 +36,19 @@ namespace frontend {
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
char const * const bigleft[] = {"bigl", "Bigl", "biggl", "Biggl", ""};
|
QString const bigleft[] = {"bigl", "Bigl", "biggl", "Biggl", ""};
|
||||||
|
|
||||||
|
|
||||||
char const * const bigright[] = {"bigr", "Bigr", "biggr", "Biggr", ""};
|
QString const bigright[] = {"bigr", "Bigr", "biggr", "Biggr", ""};
|
||||||
|
|
||||||
|
|
||||||
char const * const biggui[] = {N_("big[[delimiter size]]"), N_("Big[[delimiter size]]"),
|
char const * const biggui[] = {N_("big[[delimiter size]]"), N_("Big[[delimiter size]]"),
|
||||||
N_("bigg[[delimiter size]]"), N_("Bigg[[delimiter size]]"), ""};
|
N_("bigg[[delimiter size]]"), N_("Bigg[[delimiter size]]"), ""};
|
||||||
|
|
||||||
|
|
||||||
string fix_name(string const & str, bool big)
|
QString fix_name(QString const & str, bool big)
|
||||||
{
|
{
|
||||||
if (str.empty())
|
if (str.isEmpty())
|
||||||
return ".";
|
return ".";
|
||||||
if (!big || str == "(" || str == ")" || str == "[" || str == "]"
|
if (!big || str == "(" || str == ")" || str == "[" || str == "]"
|
||||||
|| str == "|" || str == "/")
|
|| str == "|" || str == "/")
|
||||||
@ -91,7 +91,6 @@ QDelimiterDialog::QDelimiterDialog(QMathDelimiter * form)
|
|||||||
setupUi(this);
|
setupUi(this);
|
||||||
|
|
||||||
connect(closePB, SIGNAL(clicked()), this, SLOT(accept()));
|
connect(closePB, SIGNAL(clicked()), this, SLOT(accept()));
|
||||||
connect(insertPB, SIGNAL(clicked()), this, SLOT(insertClicked()));
|
|
||||||
|
|
||||||
setWindowTitle(qt_("LyX: Delimiters"));
|
setWindowTitle(qt_("LyX: Delimiters"));
|
||||||
setFocusProxy(leftLW);
|
setFocusProxy(leftLW);
|
||||||
@ -133,41 +132,83 @@ QDelimiterDialog::QDelimiterDialog(QMathDelimiter * form)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QDelimiterDialog::insertClicked()
|
void QDelimiterDialog::updateTeXCode(int size)
|
||||||
{
|
{
|
||||||
string left_str;
|
QString left_str;
|
||||||
string right_str;
|
QString right_str;
|
||||||
if (leftLW->currentRow() < leftLW->count() - 1)
|
QString bigl;
|
||||||
left_str = fromqstr(leftLW->currentItem()->toolTip());
|
QString bigr;
|
||||||
if (rightLW->currentRow() < rightLW->count() - 1)
|
QString code_str;
|
||||||
right_str = fromqstr(rightLW->currentItem()->toolTip());
|
bool bigsize = size != 0;
|
||||||
|
|
||||||
int const size_ = sizeCO->currentIndex();
|
left_str = fix_name(leftLW->currentItem()->toolTip(), bigsize);
|
||||||
if (size_ == 0) {
|
right_str = fix_name(rightLW->currentItem()->toolTip(), bigsize);
|
||||||
form_->controller().dispatchDelim(
|
|
||||||
fix_name(left_str, false) + ' ' +
|
if (!bigsize)
|
||||||
fix_name(right_str, false));
|
tex_code_ = left_str + ' ' + right_str;
|
||||||
} else {
|
else {
|
||||||
std::ostringstream os;
|
tex_code_ = bigleft[size - 1] + ' '
|
||||||
os << '"' << bigleft[size_ - 1] << "\" \""
|
+ left_str + ' '
|
||||||
<< fix_name(left_str, true) << "\" \""
|
+ bigright[size - 1] + ' '
|
||||||
<< bigright[size_ - 1] << "\" \""
|
+ right_str;
|
||||||
<< fix_name(right_str, true) << '"';
|
}
|
||||||
form_->controller().dispatchBigDelim(os.str());
|
|
||||||
|
// generate TeX-code
|
||||||
|
left_str = fix_name(leftLW->currentItem()->toolTip(), true);
|
||||||
|
right_str = fix_name(rightLW->currentItem()->toolTip(), true);
|
||||||
|
if (bigsize == true) {
|
||||||
|
bigl = "\\" + bigleft[size];
|
||||||
|
bigr = "\\" + bigright[size];
|
||||||
}
|
}
|
||||||
|
if (!bigsize)
|
||||||
|
code_str = "TeX-Code: \\left" + left_str + ' ' + "\\right" + right_str;
|
||||||
|
else {
|
||||||
|
// There is nothing in the TeX-code when the delimiter is "None"
|
||||||
|
if (left_str == ".") {
|
||||||
|
left_str = "";
|
||||||
|
bigl = "";
|
||||||
|
}
|
||||||
|
if (right_str == ".") {
|
||||||
|
right_str = "";
|
||||||
|
bigr = "";
|
||||||
|
}
|
||||||
|
code_str = "TeX-Code: " + bigl
|
||||||
|
+ left_str + ' '
|
||||||
|
+ bigr
|
||||||
|
+ right_str;
|
||||||
|
}
|
||||||
|
|
||||||
|
texCodeL->setText(code_str);
|
||||||
|
}
|
||||||
|
|
||||||
|
void QDelimiterDialog::on_insertPB_clicked()
|
||||||
|
{
|
||||||
|
if (sizeCO->currentIndex() == 0)
|
||||||
|
form_->controller().dispatchDelim(fromqstr(tex_code_));
|
||||||
|
else {
|
||||||
|
QString command = '"' + tex_code_ + '"';
|
||||||
|
command.replace(' ', "\" \"");
|
||||||
|
form_->controller().dispatchBigDelim(fromqstr(command));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QDelimiterDialog::on_sizeCO_activated(int index)
|
||||||
|
{
|
||||||
|
updateTeXCode(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QDelimiterDialog::on_leftLW_itemActivated(QListWidgetItem *)
|
void QDelimiterDialog::on_leftLW_itemActivated(QListWidgetItem *)
|
||||||
{
|
{
|
||||||
insertClicked();
|
on_insertPB_clicked();
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QDelimiterDialog::on_rightLW_itemActivated(QListWidgetItem *)
|
void QDelimiterDialog::on_rightLW_itemActivated(QListWidgetItem *)
|
||||||
{
|
{
|
||||||
insertClicked();
|
on_insertPB_clicked();
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,11 +218,7 @@ void QDelimiterDialog::on_leftLW_currentRowChanged(int item)
|
|||||||
if (matchCB->isChecked())
|
if (matchCB->isChecked())
|
||||||
rightLW->setCurrentRow(item);
|
rightLW->setCurrentRow(item);
|
||||||
|
|
||||||
// Display the associated TeX name.
|
updateTeXCode(sizeCO->currentIndex());
|
||||||
if (leftLW->currentRow() == leftLW->count() - 1)
|
|
||||||
texCodeL->clear();
|
|
||||||
else
|
|
||||||
texCodeL->setText("TeX code: \\" + leftLW->currentItem()->toolTip());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -190,11 +227,7 @@ void QDelimiterDialog::on_rightLW_currentRowChanged(int item)
|
|||||||
if (matchCB->isChecked())
|
if (matchCB->isChecked())
|
||||||
leftLW->setCurrentRow(item);
|
leftLW->setCurrentRow(item);
|
||||||
|
|
||||||
// Display the associated TeX name.
|
updateTeXCode(sizeCO->currentIndex());
|
||||||
if (rightLW->currentRow() == leftLW->count() - 1)
|
|
||||||
texCodeL->clear();
|
|
||||||
else
|
|
||||||
texCodeL->setText("TeX code: \\" + rightLW->currentItem()->toolTip());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,12 +33,17 @@ public Q_SLOTS:
|
|||||||
void on_leftLW_currentRowChanged(int);
|
void on_leftLW_currentRowChanged(int);
|
||||||
void on_rightLW_currentRowChanged(int);
|
void on_rightLW_currentRowChanged(int);
|
||||||
void on_matchCB_stateChanged(int);
|
void on_matchCB_stateChanged(int);
|
||||||
void insertClicked();
|
void on_insertPB_clicked();
|
||||||
|
void on_sizeCO_activated(int);
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
char_type doMatch(char_type const symbol) const;
|
char_type doMatch(char_type const symbol) const;
|
||||||
|
///
|
||||||
|
void updateTeXCode(int size);
|
||||||
/// owning form
|
/// owning form
|
||||||
QMathDelimiter * form_;
|
QMathDelimiter * form_;
|
||||||
|
/// TeX code that will be inserted.
|
||||||
|
QString tex_code_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>200</width>
|
<width>286</width>
|
||||||
<height>447</height>
|
<height>537</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy" >
|
<property name="sizePolicy" >
|
||||||
@ -35,13 +35,13 @@
|
|||||||
<property name="sizeGripEnabled" >
|
<property name="sizeGripEnabled" >
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="" >
|
<widget class="QWidget" name="verticalLayout" >
|
||||||
<property name="geometry" >
|
<property name="geometry" >
|
||||||
<rect>
|
<rect>
|
||||||
<x>9</x>
|
<x>10</x>
|
||||||
<y>9</y>
|
<y>10</y>
|
||||||
<width>176</width>
|
<width>261</width>
|
||||||
<height>431</height>
|
<height>511</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" >
|
<layout class="QVBoxLayout" >
|
||||||
@ -144,7 +144,16 @@
|
|||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>TeX Code</string>
|
<string>TeX Code: \Biggl\Updownarrow \Biggr\Updownarrow</string>
|
||||||
|
</property>
|
||||||
|
<property name="textFormat" >
|
||||||
|
<enum>Qt::AutoText</enum>
|
||||||
|
</property>
|
||||||
|
<property name="alignment" >
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap" >
|
||||||
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -190,6 +199,9 @@
|
|||||||
<property name="text" >
|
<property name="text" >
|
||||||
<string>&Size:</string>
|
<string>&Size:</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="alignment" >
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
<property name="buddy" >
|
<property name="buddy" >
|
||||||
<cstring>sizeCO</cstring>
|
<cstring>sizeCO</cstring>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user