#include "BufferParams.h"
#include "BufferView.h"
#include "Color.h"
+#include "ColorCache.h"
#include "Encoding.h"
#include "FloatPlacement.h"
#include "Format.h"
#include "frontends/alert.h"
#include <QAbstractItemModel>
+#include <QColor>
+#include <QColorDialog>
#include <QCloseEvent>
#include <QFontDatabase>
#include <QScrollBar>
#endif
+// a style sheet for buttons
+// this is for example used for the background color setting button
+static inline QString colorButtonStyleSheet(QColor const & bgColor)
+{
+ if (bgColor.isValid()) {
+ QString rc = QLatin1String("background:");
+ rc += bgColor.name();
+ return rc;
+ }
+ return QLatin1String("");
+}
+
+
using namespace std;
using namespace lyx::support;
namespace lyx {
+RGBColor set_backgroundcolor;
+
namespace {
// used when sorting the textclass list.
class less_textclass_avail_desc
this, SLOT(change_adaptor()));
connect(pageLayoutModule->pagestyleCO, SIGNAL(activated(int)),
this, SLOT(change_adaptor()));
+ connect(pageLayoutModule->backgroundTB, SIGNAL(clicked()),
+ this, SLOT(changeBackgroundColor()));
+ connect(pageLayoutModule->delbackgroundTB, SIGNAL(clicked()),
+ this, SLOT(deleteBackgroundColor()));
pageLayoutModule->pagestyleCO->addItem(qt_("Default"));
pageLayoutModule->pagestyleCO->addItem(qt_("empty"));
marginsModule->columnsepUnit->setEnabled(enableColSep);
}
+void GuiDocument::changeBackgroundColor()
+{
+ QColor const & newColor = QColorDialog::getColor(
+ rgb2qcolor(set_backgroundcolor), qApp->focusWidget());
+ if (!newColor.isValid())
+ return;
+ // set the button color
+ pageLayoutModule->backgroundTB->setStyleSheet(
+ colorButtonStyleSheet(newColor));
+ // save color
+ set_backgroundcolor = rgbFromHexName(fromqstr(newColor.name()));
+ changed();
+}
+
+
+void GuiDocument::deleteBackgroundColor()
+{
+ // set the button color back to white
+ pageLayoutModule->backgroundTB->setStyleSheet(
+ colorButtonStyleSheet(QColor(Qt::white)));
+ // save white as the set color
+ set_backgroundcolor = rgbFromHexName("#ffffff");
+ changed();
+}
+
void GuiDocument::xetexChanged(bool xetex)
{
QString const lang = langModule->languageCO->itemData(
langModule->languageCO->currentIndex()).toString();
- bp_.language = lyx::languages.getLanguage(fromqstr(lang));
+ bp_.language = languages.getLanguage(fromqstr(lang));
// numbering
if (bp_.documentClass().hasTocLevels()) {
else
bp_.orientation = ORIENTATION_PORTRAIT;
+ bp_.backgroundcolor = set_backgroundcolor;
+
// margins
bp_.use_geometry = !marginsModule->marginCB->isChecked()
|| geom_papersize;
pageLayoutModule->facingPagesCB->setChecked(
bp_.sides == TwoSides);
+ pageLayoutModule->backgroundTB->setStyleSheet(
+ colorButtonStyleSheet(rgb2qcolor(bp_.backgroundcolor)));
+ set_backgroundcolor = bp_.backgroundcolor;
lengthToWidgets(pageLayoutModule->paperwidthLE,
pageLayoutModule->paperwidthUnitCO, bp_.paperwidth, defaultUnit);
-
lengthToWidgets(pageLayoutModule->paperheightLE,
pageLayoutModule->paperheightUnitCO, bp_.paperheight, defaultUnit);