mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
GuiBox.cpp: fix logic
- if pagebreaks are allowed there cannot be defined a width
This commit is contained in:
parent
53be3321ba
commit
6780a30409
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
#include "GuiBox.h"
|
#include "GuiBox.h"
|
||||||
|
|
||||||
|
#include "GuiApplication.h"
|
||||||
|
#include "ColorCache.h"
|
||||||
#include "LengthCombo.h"
|
#include "LengthCombo.h"
|
||||||
#include "Length.h"
|
#include "Length.h"
|
||||||
#include "qt_helpers.h"
|
#include "qt_helpers.h"
|
||||||
@ -26,6 +28,7 @@
|
|||||||
#include "support/foreach.h"
|
#include "support/foreach.h"
|
||||||
#include "support/lstrings.h"
|
#include "support/lstrings.h"
|
||||||
|
|
||||||
|
#include <QComboBox>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
@ -73,6 +76,60 @@ static QStringList boxGuiSpecialLengthNames()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static QList<ColorPair> colorData()
|
||||||
|
{
|
||||||
|
QList<ColorPair> colors;
|
||||||
|
colors << ColorPair(qt_("none"), Color_none);
|
||||||
|
colors << ColorPair(qt_("black"), Color_black);
|
||||||
|
colors << ColorPair(qt_("white"), Color_white);
|
||||||
|
colors << ColorPair(qt_("blue"), Color_blue);
|
||||||
|
colors << ColorPair(qt_("brown"), Color_brown);
|
||||||
|
colors << ColorPair(qt_("cyan"), Color_cyan);
|
||||||
|
colors << ColorPair(qt_("darkgray"), Color_darkgray);
|
||||||
|
colors << ColorPair(qt_("gray"), Color_gray);
|
||||||
|
colors << ColorPair(qt_("green"), Color_green);
|
||||||
|
colors << ColorPair(qt_("lightgray"), Color_lightgray);
|
||||||
|
colors << ColorPair(qt_("lime"), Color_lime);
|
||||||
|
colors << ColorPair(qt_("magenta"), Color_magenta);
|
||||||
|
colors << ColorPair(qt_("olive"), Color_olive);
|
||||||
|
colors << ColorPair(qt_("orange"), Color_orange);
|
||||||
|
colors << ColorPair(qt_("pink"), Color_pink);
|
||||||
|
colors << ColorPair(qt_("purple"), Color_purple);
|
||||||
|
colors << ColorPair(qt_("red"), Color_red);
|
||||||
|
colors << ColorPair(qt_("teal"), Color_teal);
|
||||||
|
colors << ColorPair(qt_("violet"), Color_violet);
|
||||||
|
colors << ColorPair(qt_("yellow"), Color_yellow);
|
||||||
|
return colors;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void fillComboColor(QComboBox * combo, QList<T> const & list, bool const is_none)
|
||||||
|
{
|
||||||
|
QPixmap coloritem(32, 32);
|
||||||
|
QColor color;
|
||||||
|
// frameColorCO cannot be uncolored
|
||||||
|
if (is_none)
|
||||||
|
combo->addItem("none");
|
||||||
|
typename QList<T>::const_iterator cit = list.begin() + 1;
|
||||||
|
for (; cit != list.end(); ++cit) {
|
||||||
|
color = QColor(guiApp->colorCache().get(cit->second, false));
|
||||||
|
coloritem.fill(color);
|
||||||
|
combo->addItem(QIcon(coloritem), cit->first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class P>
|
||||||
|
static int findPos2nd(QList<P> const & vec, QString val)
|
||||||
|
{
|
||||||
|
for (int i = 0; i != vec.size(); ++i)
|
||||||
|
if (vec[i].first == val)
|
||||||
|
return i;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
|
GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
|
||||||
{
|
{
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
@ -108,6 +165,8 @@ GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
|
|||||||
connect(shadowsizeED, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
|
connect(shadowsizeED, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
|
||||||
connect(shadowsizeUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
connect(shadowsizeUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
||||||
this, SIGNAL(changed()));
|
this, SIGNAL(changed()));
|
||||||
|
connect(frameColorCO, SIGNAL(highlighted(QString)), this, SIGNAL(changed()));
|
||||||
|
connect(backgroundColorCO, SIGNAL(highlighted(QString)), this, SIGNAL(changed()));
|
||||||
|
|
||||||
heightED->setValidator(unsignedLengthValidator(heightED));
|
heightED->setValidator(unsignedLengthValidator(heightED));
|
||||||
widthED->setValidator(unsignedLengthValidator(widthED));
|
widthED->setValidator(unsignedLengthValidator(widthED));
|
||||||
@ -122,6 +181,12 @@ GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
|
|||||||
addCheckedWidget(separationED, separationLA);
|
addCheckedWidget(separationED, separationLA);
|
||||||
addCheckedWidget(shadowsizeED, shadowsizeLA);
|
addCheckedWidget(shadowsizeED, shadowsizeLA);
|
||||||
|
|
||||||
|
// initialize colors
|
||||||
|
color = colorData();
|
||||||
|
// the background can be uncolored while the frame cannot
|
||||||
|
fillComboColor(frameColorCO, color, false);
|
||||||
|
fillComboColor(backgroundColorCO, color, true);
|
||||||
|
|
||||||
initDialog();
|
initDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,6 +250,9 @@ void GuiBox::initDialog()
|
|||||||
// LaTeX's default for \shadowsize is 4 pt
|
// LaTeX's default for \shadowsize is 4 pt
|
||||||
shadowsizeED->setText("4");
|
shadowsizeED->setText("4");
|
||||||
shadowsizeUnitsLC->setCurrentItem(Length::PT);
|
shadowsizeUnitsLC->setCurrentItem(Length::PT);
|
||||||
|
// the default color is black and none
|
||||||
|
frameColorCO->setCurrentIndex(findPos2nd(color, qt_("black")) - 1);
|
||||||
|
backgroundColorCO->setCurrentIndex(findPos2nd(color, qt_("none")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -318,6 +386,9 @@ void GuiBox::paramsToDialog(Inset const * inset)
|
|||||||
shadowsizeUnitsLC->setEnabled(type == "Shadowbox");
|
shadowsizeUnitsLC->setEnabled(type == "Shadowbox");
|
||||||
lengthToWidgets(shadowsizeED, shadowsizeUnitsLC,
|
lengthToWidgets(shadowsizeED, shadowsizeUnitsLC,
|
||||||
(params.shadowsize).asString(), default_unit);
|
(params.shadowsize).asString(), default_unit);
|
||||||
|
// set color
|
||||||
|
frameColorCO->setCurrentIndex(findPos2nd(color, qt_(params.framecolor)) - 1);
|
||||||
|
backgroundColorCO->setCurrentIndex(findPos2nd(color, qt_(params.backgroundcolor)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -443,7 +514,7 @@ bool GuiBox::checkWidgets(bool readonly) const
|
|||||||
// except for Frameless and Boxed, the width cannot be specified if
|
// except for Frameless and Boxed, the width cannot be specified if
|
||||||
// there is no inner box
|
// there is no inner box
|
||||||
bool const width_enabled =
|
bool const width_enabled =
|
||||||
ibox || outer == "Frameless" || outer == "Boxed";
|
ibox || outer == "Frameless" || (outer == "Boxed" && !pagebreakCB->isChecked());
|
||||||
// enable if width_enabled
|
// enable if width_enabled
|
||||||
widthED->setEnabled(width_enabled);
|
widthED->setEnabled(width_enabled);
|
||||||
widthUnitsLC->setEnabled(width_enabled);
|
widthUnitsLC->setEnabled(width_enabled);
|
||||||
|
Loading…
Reference in New Issue
Block a user