r14390 by cbradney - Enable text preview in new item tool prefs widget
scribus-commit
scribus-commit at lists.scribus.net
Thu Dec 10 00:40:26 CET 2009
Revision: 14390
Author: cbradney
Date: 2009-12-09T12:55:55.692674Z
Commit message: Enable text preview in new item tool prefs widget
Changeset:
M /trunk/Scribus/scribus/ui/prefs_itemtools.cpp
M /trunk/Scribus/scribus/ui/preferencesdialog.cpp
M /trunk/Scribus/scribus/ui/prefs_itemtools.h
M /trunk/Scribus/scribus/ui/prefs_itemtoolsbase.ui
M /trunk/Scribus/scribus/ui/tabtools.cpp
Diffs:
Index: scribus/ui/prefs_itemtools.cpp
===================================================================
--- scribus/ui/prefs_itemtools.cpp (revision 14389)
+++ scribus/ui/prefs_itemtools.cpp (revision 14390)
@@ -13,10 +13,12 @@
#include "units.h"
#include "commonstrings.h"
#include "prefsmanager.h"
+#include "sampleitem.h"
Prefs_ItemTools::Prefs_ItemTools(QWidget* parent)
: Prefs_Pane(parent),
- m_doc(NULL)
+ m_doc(NULL),
+ showFontPreview(false)
{
setupUi(this);
lineEndArrowComboBox->setStartDirection(false);
@@ -41,6 +43,7 @@
void Prefs_ItemTools::languageChange()
{
+ textPreviewWidget->setText( tr( "Woven silk pyjamas exchanged for blue quartz" ));
}
void Prefs_ItemTools::unitChange(int newIndex)
@@ -57,24 +60,17 @@
unitChange(docUnitIndex);
PrefsManager* prefsManager=PrefsManager::instance();
- ColorList::Iterator itc, endOfColorList;
- //TODO ColorList* colorList = (docu != 0) ? (&docu->PageColors) : prefsManager->colorSetPtr();
- ColorList* colorList = prefsManager->colorSetPtr();
+ ColorList* colorList = (m_doc != NULL) ? (&m_doc->PageColors) : prefsManager->colorSetPtr();
-
//Text Tool
-
-//TODO textPreviewWidget
-
- for (int fc=0; fc<textFontComboBox->count(); ++fc)
+ for (int i=0; i<textFontComboBox->count(); ++i)
{
- if (textFontComboBox->itemText(fc) == prefsData->itemToolPrefs.textFont)
+ if (textFontComboBox->itemText(i) == prefsData->itemToolPrefs.textFont)
{
- textFontComboBox->setCurrentIndex(fc);
+ textFontComboBox->setCurrentIndex(i);
break;
}
}
-
textSizeSpinBox->setValue(prefsData->itemToolPrefs.textSize / 10);
textColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.textColor);
textColorShadingSpinBox->setValue(prefsData->itemToolPrefs.textShade);
@@ -84,7 +80,6 @@
textFrameFillShadingSpinBox->setValue(prefsData->itemToolPrefs.textFillColorShade);
textFrameLineColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.textLineColor);
textFrameLineShadingSpinBox->setValue(prefsData->itemToolPrefs.textLineColorShade);
-
textTabFillCharComboBox->clear();
textTabFillCharComboBox->addItem( tr("None", "tab fill" ));
textTabFillCharComboBox->addItem( tr("Dot"));
@@ -113,7 +108,6 @@
textTabFillCharComboBox->setEditable(true);
textTabFillCharComboBox->setItemText(textTabFillCharComboBox->currentIndex(), CommonStrings::trCustomTabFill + prefsData->itemToolPrefs.textTabFillChar);
}
-
textTabWidthSpinBox->setValue(prefsData->itemToolPrefs.textTabWidth * unitRatio);
textColumnsSpinBox->setValue(prefsData->itemToolPrefs.textColumns);
textColumnGapSpinBox->setValue(prefsData->itemToolPrefs.textColumnGap * unitRatio);
@@ -132,18 +126,14 @@
*/
//Image Tool
-
//TODO imageFrameLineColorComboBox
//TODO imageFrameLineShadingSpinBox
-
imageFreeScalingRadioButton->setChecked( prefsData->itemToolPrefs.imageScaleType );
imageFrameScalingRadioButton->setChecked( !prefsData->itemToolPrefs.imageScaleType );
imageHorizontalScalingSpinBox->setValue(qRound(prefsData->itemToolPrefs.imageScaleX * 100));
imageVerticalScalingSpinBox->setValue(qRound(prefsData->itemToolPrefs.imageScaleY * 100));
-
imageKeepAspectRatioCheckBox->setChecked(prefsData->itemToolPrefs.imageAspectRatio);
imageFrameFillColorComboBox->initColorList(colorList, m_doc, prefsData->itemToolPrefs.imageFillColor);
-
imageFrameFillShadingSpinBox->setValue(prefsData->itemToolPrefs.imageFillColorShade );
imageUseEmbeddedClippingPathCheckBox->setChecked(prefsData->itemToolPrefs.imageUseEmbeddedPath);
switch (prefsData->itemToolPrefs.imageLowResType)
@@ -205,7 +195,6 @@
lineWidthSpinBox->setValue(prefsData->itemToolPrefs.lineWidth);
//
-
enableSignals(true);
}
@@ -323,12 +312,12 @@
{
if (on)
{
-// connect(fontComboText, SIGNAL(activated(int)), this, SLOT(setSample()));
-// connect(sizeComboText, SIGNAL(activated(int)), this, SLOT(setSample()));
-// connect(colorComboText, SIGNAL(activated(int)), this, SLOT(setSample()));
-// connect(colorComboTextBackground, SIGNAL(activated(int)), this, SLOT(setSample()));
-// connect(shadingTextBack, SIGNAL(valueChanged(int)), this, SLOT(setSample()));
-// connect(shadingText, SIGNAL(valueChanged(int)), this, SLOT(setSample()));
+ connect(textFontComboBox, SIGNAL(activated(int)), this, SLOT(updateFontPreview()));
+ connect(textSizeSpinBox, SIGNAL(valueChanged(double)), this, SLOT(updateFontPreview()));
+ connect(textColorComboBox, SIGNAL(activated(int)), this, SLOT(updateFontPreview()));
+ connect(textFrameFillColorComboBox, SIGNAL(activated(int)), this, SLOT(updateFontPreview()));
+ connect(textFrameFillShadingSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateFontPreview()));
+ connect(textColorShadingSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateFontPreview()));
// connect(buttonGroup3, SIGNAL(toggled(bool)), this, SLOT(changeImageScalingFree(bool)));
// connect(buttonGroup5, SIGNAL(toggled(bool)), this, SLOT(changeImageScalingRatio(bool)));
// connect(chainButton, SIGNAL(clicked()), this, SLOT(toggleChain()));
@@ -338,12 +327,12 @@
}
else
{
-// disconnect(fontComboText, SIGNAL(activated(int)), this, SLOT(setSample()));
-// disconnect(sizeComboText, SIGNAL(activated(int)), this, SLOT(setSample()));
-// disconnect(colorComboText, SIGNAL(activated(int)), this, SLOT(setSample()));
-// disconnect(colorComboTextBackground, SIGNAL(activated(int)), this, SLOT(setSample()));
-// disconnect(shadingTextBack, SIGNAL(valueChanged(int)), this, SLOT(setSample()));
-// disconnect(shadingText, SIGNAL(valueChanged(int)), this, SLOT(setSample()));
+ disconnect(textFontComboBox, SIGNAL(activated(int)), this, SLOT(updateFontPreview()));
+ disconnect(textSizeSpinBox, SIGNAL(valueChanged(double)), this, SLOT(updateFontPreview()));
+ disconnect(textColorComboBox, SIGNAL(activated(int)), this, SLOT(updateFontPreview()));
+ disconnect(textFrameFillColorComboBox, SIGNAL(activated(int)), this, SLOT(updateFontPreview()));
+ disconnect(textFrameFillShadingSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateFontPreview()));
+ disconnect(textColorShadingSpinBox, SIGNAL(valueChanged(int)), this, SLOT(updateFontPreview()));
// disconnect(buttonGroup3, SIGNAL(toggled(bool)), this, SLOT(changeImageScalingFree(bool)));
// disconnect(buttonGroup5, SIGNAL(toggled(bool)), this, SLOT(changeImageScalingRatio(bool)));
// disconnect(chainButton, SIGNAL(clicked()), this, SLOT(toggleChain()));
@@ -352,3 +341,55 @@
// disconnect(tabFillCombo, SIGNAL(activated(int)), this, SLOT(setFillChar(int)));
}
}
+
+void Prefs_ItemTools::enableFontPreview(bool showPreview)
+{
+ showFontPreview = showPreview;
+ updateFontPreview();
+}
+
+void Prefs_ItemTools::updateFontPreview()
+{
+ if (!showFontPreview)
+ return;
+
+ SampleItem si(m_doc);
+ si.setText( tr("Woven silk pyjamas exchanged for blue quartz"));
+ if (textFrameFillColorComboBox->currentText() != CommonStrings::tr_NoneColor)
+ {
+ if (m_doc != 0)
+ {
+ si.setBgColor(m_doc->PageColors[textFrameFillColorComboBox->currentText()].getRawRGBColor());
+ }
+ else
+ {
+ PrefsManager* prefsManager=PrefsManager::instance();
+ ColorList* colorList=prefsManager->colorSetPtr();
+ si.setBgColor((*colorList)[textFrameFillColorComboBox->currentText()].getRawRGBColor());
+ }
+ si.setBgShade(textFrameFillShadingSpinBox->value());
+ }
+ else
+ si.setBgColor(palette().color(QPalette::Window));
+
+ if (textColorComboBox->currentText() != CommonStrings::tr_NoneColor)
+ {
+ if (m_doc != 0)
+ {
+ si.setTxColor(m_doc->PageColors[textColorComboBox->currentText()].getRawRGBColor());
+ }
+ else
+ {
+ PrefsManager* prefsManager=PrefsManager::instance();
+ ColorList* colorList=prefsManager->colorSetPtr();
+ si.setTxColor((*colorList)[textColorComboBox->currentText()].getRawRGBColor());
+ }
+ si.setTxShade(textColorShadingSpinBox->value());
+ }
+ else
+ si.setTxColor(palette().color(QPalette::Window));
+ si.setFont(textFontComboBox->currentText());
+ si.setFontSize(textSizeSpinBox->value() * 10, true);
+ textPreviewWidget->setPixmap(si.getSample(textPreviewWidget->width(), textPreviewWidget->height()));
+}
+
Index: scribus/ui/prefs_itemtoolsbase.ui
===================================================================
--- scribus/ui/prefs_itemtoolsbase.ui (revision 14389)
+++ scribus/ui/prefs_itemtoolsbase.ui (revision 14390)
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>563</width>
- <height>747</height>
+ <width>656</width>
+ <height>823</height>
</rect>
</property>
<property name="windowTitle">
@@ -67,8 +67,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>489</width>
- <height>617</height>
+ <width>582</width>
+ <height>693</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
@@ -438,14 +438,56 @@
</widget>
</item>
<item>
- <widget class="QWidget" name="textPreviewWidget" native="true">
- <property name="minimumSize">
- <size>
- <width>0</width>
- <height>100</height>
- </size>
- </property>
- </widget>
+ <layout class="QHBoxLayout" name="horizontalLayout_9">
+ <item>
+ <spacer name="horizontalSpacer_15">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="textPreviewWidget">
+ <property name="minimumSize">
+ <size>
+ <width>400</width>
+ <height>170</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>400</width>
+ <height>170</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_16">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
</item>
<item>
<spacer name="verticalSpacer_2">
@@ -1248,7 +1290,7 @@
<resources/>
<connections/>
<buttongroups>
+ <buttongroup name="scalingButtonGroup"/>
<buttongroup name="previewButtonGroup"/>
- <buttongroup name="scalingButtonGroup"/>
</buttongroups>
</ui>
Index: scribus/ui/tabtools.cpp
===================================================================
--- scribus/ui/tabtools.cpp (revision 14389)
+++ scribus/ui/tabtools.cpp (revision 14390)
@@ -903,18 +903,12 @@
void TabTools::changeImageScalingFree(bool)
{
- if (buttonGroup3->isChecked())
- buttonGroup5->setChecked(false);
- else
- buttonGroup5->setChecked(true);
+ buttonGroup5->setChecked(!buttonGroup3->isChecked());
}
void TabTools::changeImageScalingRatio(bool)
{
- if (buttonGroup5->isChecked())
- buttonGroup3->setChecked(false);
- else
- buttonGroup3->setChecked(true);
+ buttonGroup3->setChecked(!buttonGroup5->isChecked());
}
void TabTools::setSample()
Index: scribus/ui/prefs_itemtools.h
===================================================================
--- scribus/ui/prefs_itemtools.h (revision 14389)
+++ scribus/ui/prefs_itemtools.h (revision 14390)
@@ -27,12 +27,16 @@
public slots:
void languageChange();
void unitChange(int newIndex);
+ void enableFontPreview(bool);
protected slots:
void enableSignals(bool on);
+ void updateFontPreview();
protected:
ScribusDoc* m_doc;
+ bool showFontPreview;
+
};
#endif // PREFS_ITEMTOOLS_H
Index: scribus/ui/preferencesdialog.cpp
===================================================================
--- scribus/ui/preferencesdialog.cpp (revision 14389)
+++ scribus/ui/preferencesdialog.cpp (revision 14390)
@@ -198,6 +198,8 @@
{
//emit aboutToShow(prefsWidgets->widget(itemMap[ic]));
prefsStackWidget->setCurrentIndex(stackWidgetMap[ic]);
+ if (prefsStackWidget->currentWidget()==dynamic_cast<QWidget*>(prefs_ItemTools))
+ prefs_ItemTools->enableFontPreview(true);
}
}
More information about the scribus-commit
mailing list