r17388 by jghali - - Convert more text properties widgets to new model
scribus-commit
scribus-commit at lists.scribus.net
Mon Mar 19 00:25:49 UTC 2012
Author: jghali
Date: Mon Mar 19 00:25:48 2012
New Revision: 17388
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17388
Log:
- Convert more text properties widgets to new model
- Various fixes
Modified:
trunk/Scribus/scribus/scribus.cpp
trunk/Scribus/scribus/scribus.h
trunk/Scribus/scribus/selection.cpp
trunk/Scribus/scribus/ui/cpalette.cpp
trunk/Scribus/scribus/ui/propertiespalette.cpp
trunk/Scribus/scribus/ui/propertiespalette.h
trunk/Scribus/scribus/ui/propertiespalette_group.cpp
trunk/Scribus/scribus/ui/propertiespalette_group.h
trunk/Scribus/scribus/ui/propertiespalette_text.cpp
trunk/Scribus/scribus/ui/propertiespalette_text.h
trunk/Scribus/scribus/ui/propertywidget_advanced.cpp
trunk/Scribus/scribus/ui/propertywidget_advanced.h
trunk/Scribus/scribus/ui/propertywidget_distance.cpp
trunk/Scribus/scribus/ui/propertywidget_distance.h
trunk/Scribus/scribus/ui/propertywidget_dropcap.cpp
trunk/Scribus/scribus/ui/propertywidget_dropcap.h
trunk/Scribus/scribus/ui/propertywidget_flop.h
trunk/Scribus/scribus/ui/propertywidget_optmargins.cpp
trunk/Scribus/scribus/ui/propertywidget_optmargins.h
trunk/Scribus/scribus/ui/propertywidget_orphans.cpp
trunk/Scribus/scribus/ui/propertywidget_orphans.h
trunk/Scribus/scribus/ui/propertywidget_pathtext.cpp
trunk/Scribus/scribus/ui/propertywidget_pathtext.h
trunk/Scribus/scribus/ui/propertywidget_textcolor.cpp
trunk/Scribus/scribus/ui/propertywidget_textcolor.h
trunk/Scribus/scribus/ui/propertywidget_textcolorbase.ui
Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Mon Mar 19 00:25:48 2012
@@ -158,7 +158,6 @@
#include "ui/insertaframe.h"
#include "ui/inspage.h"
#include "ui/javadocs.h"
-#include "langmgr.h"
#include "ui/layers.h"
#include "ui/loremipsum.h"
#include "ui/marginwidget.h"
@@ -592,8 +591,6 @@
connect(outlinePalette, SIGNAL(editElementByItem(PageItem *)), this, SLOT(editItemsFromOutlines(PageItem *)));
connect(outlinePalette, SIGNAL(selectPage(int)), this, SLOT(selectPagesFromOutlines(int)));
connect(outlinePalette, SIGNAL(selectMasterPage(QString)), this, SLOT(manageMasterPages(QString)));
- connect(propertiesPalette->textPal->paraStyleCombo, SIGNAL(newStyle(const QString&)), this, SLOT(setNewParStyle(const QString&)));
- connect(propertiesPalette->textPal->charStyleCombo, SIGNAL(newStyle(const QString&)), this, SLOT(setNewCharStyle(const QString&)));
// connect(propertiesPalette, SIGNAL(EditLSt()), this, SLOT(slotEditLineStyles()));
// connect(nodePalette, SIGNAL(paletteClosed()), propertiesPalette, SLOT(endEdit2()));
connect(nodePalette, SIGNAL(paletteClosed()), this, SLOT(slotSelect()));
@@ -7362,22 +7359,6 @@
}
}
-void ScribusMainWindow::updtGradMask()
-{
- if (!HaveDoc)
- return;
- VGradient vg(propertiesPalette->getMaskGradient());
- doc->itemSelection_SetMaskGradient(vg);
-}
-
-void ScribusMainWindow::updtGradMaskGroup()
-{
- if (!HaveDoc)
- return;
- VGradient vg(propertiesPalette->getMaskGradientGroup());
- doc->itemSelection_SetMaskGradient(vg);
-}
-
//CB-->??
void ScribusMainWindow::MakeFrame(int f, int c, double *vals)
{
@@ -9173,7 +9154,6 @@
if (datein.isEmpty())
prefsManager->appPrefs.hyphPrefs.Language = "English";
}
-// propertiesPalette->fillLangCombo(LangTransl);
}
QString ScribusMainWindow::GetLang(QString inLang)
@@ -9917,6 +9897,7 @@
doc->m_Selection->delaySignalsOff();
propertiesPalette->updateColorList();
symbolPalette->updateSymbolList();
+ emit UpdateRequest(reqColorsUpdate);
if (outlinePalette->isVisible())
outlinePalette->BuildTree();
view->DrawNew();
Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h (original)
+++ trunk/Scribus/scribus/scribus.h Mon Mar 19 00:25:48 2012
@@ -433,9 +433,6 @@
/** Color Replacement */
void slotReplaceColors();
/** Style Manager */
-
- void updtGradMask();
- void updtGradMaskGroup();
/** Erzeugt einen Rahmen */
void MakeFrame(int f, int c, double *vals);
Modified: trunk/Scribus/scribus/selection.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/selection.cpp
==============================================================================
--- trunk/Scribus/scribus/selection.cpp (original)
+++ trunk/Scribus/scribus/selection.cpp Mon Mar 19 00:25:48 2012
@@ -194,7 +194,7 @@
{
if (item==NULL)
return false;
- bool listWasEmpty=m_SelList.isEmpty();
+ bool listWasEmpty = m_SelList.isEmpty();
if (listWasEmpty || !m_SelList.contains(item))
{
m_SelList.append(item);
Modified: trunk/Scribus/scribus/ui/cpalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/cpalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/cpalette.cpp (original)
+++ trunk/Scribus/scribus/ui/cpalette.cpp Mon Mar 19 00:25:48 2012
@@ -859,7 +859,7 @@
}
if (number == 0)
fillModeCombo->setCurrentIndex(0);
- else if (((number > 0) && (number < 8)) || (number == 9) || (number == 10) || (number == 11) || (number == 12) || (number == 13))
+ else if (((number > 0) && (number < 8)) || ((number >= 9) && (number <= 13)))
{
if ((number == 5) || (number == 7) || (number == 13))
{
Modified: trunk/Scribus/scribus/ui/propertiespalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertiespalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette.cpp Mon Mar 19 00:25:48 2012
@@ -174,7 +174,7 @@
//connect(this->Cpal, SIGNAL(gradientChanged()), m_ScMW, SLOT(updtGradFill()));
//connect(this->Cpal, SIGNAL(strokeGradientChanged()), m_ScMW, SLOT(updtGradStroke()));
- connect(this->Tpal, SIGNAL(gradientChanged()), m_ScMW, SLOT(updtGradMask()));
+ connect(this->Tpal, SIGNAL(gradientChanged()), this, SLOT(handleGradientChanged()));
connect(m_ScMW, SIGNAL(AppModeChanged(int,int)), this, SLOT(AppModeChanged()));
}
@@ -609,13 +609,6 @@
repaint();
}
-void PropertiesPalette::NewAlignement(int a)
-{
- if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
- return;
- m_doc->itemSelection_SetAlignment(a);
-}
-
void PropertiesPalette::handleNewShape(int frameType)
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
@@ -874,16 +867,6 @@
tablePal->languageChange();
}
-const VGradient PropertiesPalette::getMaskGradient()
-{
- return Tpal->gradEdit->gradient();
-}
-
-const VGradient PropertiesPalette::getMaskGradientGroup()
-{
- return groupPal->getMaskGradientGroup();
-}
-
void PropertiesPalette::setGradientEditMode(bool on)
{
Cpal->gradEditButton->setChecked(on);
@@ -940,3 +923,14 @@
shapePal->setRoundRectEnabled(false);
}
}
+
+void PropertiesPalette::handleGradientChanged()
+{
+ if (!m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+ if ((m_haveDoc) && (m_haveItem))
+ {
+ VGradient vg(Tpal->gradEdit->gradient());
+ m_doc->itemSelection_SetMaskGradient(vg);
+ }
+}
Modified: trunk/Scribus/scribus/ui/propertiespalette.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertiespalette.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette.h (original)
+++ trunk/Scribus/scribus/ui/propertiespalette.h Mon Mar 19 00:25:48 2012
@@ -59,8 +59,6 @@
void endPatchAdd();
void updateColorSpecialGradient();
- const VGradient getMaskGradient();
- const VGradient getMaskGradientGroup();
void updateColorList();
void setGradientEditMode(bool);
void setTextFlowMode(PageItem::TextFlowMode mode);
@@ -106,7 +104,7 @@
void SelTab(int t);
void NewLineMode(int mode);
- void NewAlignement(int a);
+ void handleGradientChanged();
void handleNewShape(int frameType);
void NewSpGradient(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk, double cx, double cy);
void toggleGradientEdit(int);
Modified: trunk/Scribus/scribus/ui/propertiespalette_group.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertiespalette_group.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_group.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_group.cpp Mon Mar 19 00:25:48 2012
@@ -98,10 +98,10 @@
connect(textFlowBtnGroup, SIGNAL(buttonClicked(int)), this, SLOT(handleTextFlow()));
connect(customShape , SIGNAL(FormSel(int, int, qreal *)), this, SLOT(handleNewShape(int, int, qreal *)));
- connect(editShape, SIGNAL(clicked()) , this, SLOT(handleShapeEdit()));
- connect(evenOdd , SIGNAL(clicked()) , this, SLOT(handleFillRule()) );
- connect(nonZero , SIGNAL(clicked()) , this, SLOT(handleFillRule()) );
- connect(transPalWidget , SIGNAL(editGradient()) , this, SLOT(handleGradientEdit()));
+ connect(editShape , SIGNAL(clicked()) , this, SLOT(handleShapeEdit()));
+ connect(evenOdd , SIGNAL(clicked()) , this, SLOT(handleFillRule()) );
+ connect(nonZero , SIGNAL(clicked()) , this, SLOT(handleFillRule()) );
+ connect(transPalWidget , SIGNAL(editGradient()) , this, SLOT(handleGradientEdit()));
connect(transPalWidget , SIGNAL(NewSpecial(double, double, double, double, double, double, double, double, double, double)), this, SLOT(handleSpecialGradient(double, double, double, double, double, double, double, double )));
}
@@ -128,7 +128,7 @@
{
m_ScMW = mw;
- connect(this->transPalWidget, SIGNAL(gradientChanged()), m_ScMW, SLOT(updtGradMaskGroup()));
+ connect(this->transPalWidget, SIGNAL(gradientChanged()), this, SLOT(handleGradientChanged()));
connect(m_ScMW, SIGNAL(UpdateRequest(int)), this, SLOT(handleUpdateRequest(int)));
}
@@ -364,11 +364,6 @@
}
}
-const VGradient PropertiesPalette_Group::getMaskGradientGroup()
-{
- return transPalWidget->gradEdit->gradient();
-}
-
void PropertiesPalette_Group::updateColorList()
{
if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning())
@@ -402,6 +397,15 @@
if (currItem->isGroup())
transPalWidget->setSpecialGradient(currItem->GrMaskStartX * ratio, currItem->GrMaskStartY * ratio, currItem->GrMaskEndX * ratio, currItem->GrMaskEndY * ratio, currItem->GrMaskFocalX * ratio, currItem->GrMaskFocalY * ratio, currItem->GrMaskScale, currItem->GrMaskSkew);
}
+ }
+}
+
+void PropertiesPalette_Group::handleGradientChanged()
+{
+ if (m_haveDoc)
+ {
+ VGradient vg(transPalWidget->gradEdit->gradient());
+ m_doc->itemSelection_SetMaskGradient(vg);
}
}
Modified: trunk/Scribus/scribus/ui/propertiespalette_group.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertiespalette_group.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_group.h (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_group.h Mon Mar 19 00:25:48 2012
@@ -26,8 +26,6 @@
~PropertiesPalette_Group() {};
virtual void changeEvent(QEvent *e);
-
- const VGradient getMaskGradientGroup();
void displayTextFlowMode(PageItem::TextFlowMode mode);
@@ -67,6 +65,7 @@
private slots:
+ void handleGradientChanged();
void handleGroupTransparency(double trans);
void handleGroupBlending(int blend);
void handleGroupGradMask(int typ);
Modified: trunk/Scribus/scribus/ui/propertiespalette_text.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertiespalette_text.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_text.cpp (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_text.cpp Mon Mar 19 00:25:48 2012
@@ -105,29 +105,8 @@
connect(charStyleClear, SIGNAL(clicked()), this, SLOT(doClearCStyle()));
connect(paraStyleClear, SIGNAL(clicked()), this, SLOT(doClearPStyle()));
- connect(distanceWidgets->columns , SIGNAL(valueChanged(int)) , this, SLOT(handleColumns()));
- connect(distanceWidgets->columnGap , SIGNAL(valueChanged(double)), this, SLOT(handleColumnGap()));
- connect(distanceWidgets->columnGapLabel, SIGNAL(activated(int)) , this, SLOT(handleGapSwitch()));
- connect(distanceWidgets->topDistance , SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()));
- connect(distanceWidgets->leftDistance , SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()));
- connect(distanceWidgets->rightDistance , SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()));
- connect(distanceWidgets->bottomDistance, SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()));
- connect(distanceWidgets->tabsButton , SIGNAL( clicked() ) , this, SLOT( handleTabs() ) );
-
connect(flopBox->flopGroup, SIGNAL(buttonClicked( int )), this, SLOT(handleFirstLinePolicy(int)));
- connect(optMargins->optMarginRadioNone , SIGNAL(clicked()), this, SLOT(handleOpticalMargins()) );
- connect(optMargins->optMarginRadioBoth , SIGNAL(clicked()), this, SLOT(handleOpticalMargins()) );
- connect(optMargins->optMarginRadioLeft , SIGNAL(clicked()), this, SLOT(handleOpticalMargins()) );
- connect(optMargins->optMarginRadioRight , SIGNAL(clicked()), this, SLOT(handleOpticalMargins()) );
- connect(optMargins->optMarginResetButton, SIGNAL(clicked()), this, SLOT(resetOpticalMargins()) );
-
- connect(pathTextWidgets->showCurveCheckBox, SIGNAL(clicked()) , this, SLOT(handlePathLine()));
- connect(pathTextWidgets->pathTextType , SIGNAL(activated(int)), this, SLOT(handlePathType()));
- connect(pathTextWidgets->flippedPathText , SIGNAL(clicked()) , this, SLOT(handlePathFlip()));
- connect(pathTextWidgets->startOffset , SIGNAL(valueChanged(double)), this, SLOT(handlePathDist()));
- connect(pathTextWidgets->distFromCurve , SIGNAL(valueChanged(double)), this, SLOT(handlePathOffs()));
-
connect(lineSpacingModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(handleLineSpacingMode(int)));
m_haveItem = false;
@@ -136,14 +115,19 @@
void PropertiesPalette_Text::setMainWindow(ScribusMainWindow* mw)
{
- m_ScMW=mw;
+ m_ScMW = mw;
advancedWidgets->setMainWindow(mw);
colorWidgets->setMainWindow(mw);
-
- connect(this , SIGNAL(NewAlignment(int)) , m_ScMW, SLOT(setNewAlignment(int)));
- connect(this , SIGNAL(NewFont(const QString&)), m_ScMW, SLOT(SetNewFont(const QString&)));
+ distanceWidgets->setMainWindow(mw);
+ dropcapsBox->setMainWindow(mw);
+ optMargins->setMainWindow(mw);
+ pathTextWidgets->setMainWindow(mw);
+
connect(m_ScMW, SIGNAL(UpdateRequest(int)) , this , SLOT(handleUpdateRequest(int)));
+
+ connect(paraStyleCombo, SIGNAL(newStyle(const QString&)), m_ScMW, SLOT(setNewParStyle(const QString&)), Qt::UniqueConnection);
+ connect(charStyleCombo, SIGNAL(newStyle(const QString&)), m_ScMW, SLOT(setNewCharStyle(const QString&)), Qt::UniqueConnection);
}
void PropertiesPalette_Text::setDoc(ScribusDoc *d)
@@ -172,10 +156,10 @@
advancedWidgets->setDoc(m_doc);
colorWidgets->setDoc(m_doc);
distanceWidgets->setDoc(m_doc);
+ dropcapsBox->setDoc(m_doc);
flopBox->setDoc(m_doc);
optMargins->setDoc(m_doc);
orphanBox->setDoc(m_doc);
- dropcapsBox->setDoc(m_doc);
pathTextWidgets->setDoc(m_doc);
fonts->RebuildList(m_doc);
@@ -209,6 +193,7 @@
optMargins->setDoc(0);
orphanBox->setDoc(0);
dropcapsBox->setDoc(0);
+ pathTextWidgets->setDoc(0);
m_haveItem = false;
@@ -324,56 +309,7 @@
m_haveItem = false;
m_item = i;
- if (m_item->asTextFrame() || m_item->asPathText() || m_item->asTable())
- {
- fonts->RebuildList(m_doc, m_item->isAnnotation());
- }
- PageItem_TextFrame *i2;
- if (m_doc->appMode == modeEditTable)
- i2 = m_item->asTable()->activeCell().textFrame();
- else
- i2 = m_item->asTextFrame();
- if (i2 != 0)
- {
- disconnect(distanceWidgets->columnGap, SIGNAL(valueChanged(double)), this, SLOT(handleColumnGap()));
- disconnect(distanceWidgets->columns , SIGNAL(valueChanged(int)), this, SLOT(handleColumns()));
- distanceWidgets->columns->setMaximum(qMax(qRound(i2->width() / qMax(i2->ColGap, 10.0)), 1));
- distanceWidgets->columns->setMinimum(1);
- distanceWidgets->columns->setValue(i2->Cols);
- distanceWidgets->columnGap->setMinimum(0);
- if (distanceWidgets->columnGapLabel->currentIndex() == 0)
- {
- distanceWidgets->columnGap->setMaximum(qMax((i2->width() / i2->Cols - i2->textToFrameDistLeft() - i2->textToFrameDistRight())*m_unitRatio, 0.0));
- distanceWidgets->columnGap->setValue(i2->ColGap*m_unitRatio);
- }
- else
- {
- distanceWidgets->columnGap->setMaximum(qMax((i2->width() / i2->Cols)*m_unitRatio, 0.0));
- distanceWidgets->columnGap->setValue(i2->columnWidth()*m_unitRatio);
- }
- distanceWidgets->leftDistance->setValue(i2->textToFrameDistLeft()*m_unitRatio);
- distanceWidgets->topDistance->setValue(i2->textToFrameDistTop()*m_unitRatio);
- distanceWidgets->bottomDistance->setValue(i2->textToFrameDistBottom()*m_unitRatio);
- distanceWidgets->rightDistance->setValue(i2->textToFrameDistRight()*m_unitRatio);
- if (distanceWidgets->columns->value() == 1)
- {
- distanceWidgets->columnGap->setEnabled(false);
- distanceWidgets->columnGapLabel->setEnabled(false);
- }
- else
- {
- distanceWidgets->columnGap->setEnabled(true);
- distanceWidgets->columnGapLabel->setEnabled(true);
- }
- // I put it here because itâs visually grouped with these elements
- // but itâs a PageItem prop. and as such should be set without considering
- // the frame type.
- displayFirstLinePolicy(i2->firstLineOffset());
-
- connect(distanceWidgets->columnGap, SIGNAL(valueChanged(double)), this, SLOT(handleColumnGap()));
- connect(distanceWidgets->columns, SIGNAL(valueChanged(int)) , this, SLOT(handleColumns()));
- }
-
+ displayFirstLinePolicy(m_item->firstLineOffset());
if ((m_item->isGroup()) && (!m_item->isSingleSel))
{
@@ -386,11 +322,6 @@
orphanItem->setHidden(true);
dropcapsItem->setHidden(true);
pathTextItem->setHidden(false);
- pathTextWidgets->pathTextType->setCurrentIndex(m_item->textPathType);
- pathTextWidgets->flippedPathText->setChecked(m_item->textPathFlipped);
- pathTextWidgets->showCurveCheckBox->setChecked(m_item->PoShow);
- pathTextWidgets->distFromCurve->setValue(m_item->BaseOffs * -1);
- pathTextWidgets->startOffset->setValue(m_item->textToFrameDistLeft());
}
else if (m_item->asTextFrame() || m_item->asTable())
{
@@ -410,8 +341,6 @@
}
m_haveItem = true;
- if (i2 != 0)
- displayTextDistances(i2->textToFrameDistLeft(),i2->textToFrameDistTop(),i2->textToFrameDistBottom(),i2->textToFrameDistRight());
if (m_item->asTextFrame() || m_item->asPathText() || m_item->asTable())
{
@@ -447,51 +376,6 @@
pathTextWidgets->unitChange();
dropcapsBox->unitChange();
- m_haveItem = tmp;
-}
-
-void PropertiesPalette_Text::displayColumns(int r, double g)
-{
- if (!m_ScMW || m_ScMW->scriptIsRunning())
- return;
- bool tmp = m_haveItem;
- m_haveItem = false;
- distanceWidgets->columns->setValue(r);
- distanceWidgets->columnGap->setValue(g*m_unitRatio);
- if (tmp)
- {
- PageItem_TextFrame *i2;
- if (m_doc->appMode == modeEditTable)
- i2 = m_item->asTable()->activeCell().textFrame();
- else
- i2 = m_item->asTextFrame();
- if (i2 != 0)
- {
- distanceWidgets->columns->setMaximum(qMax(qRound(i2->width() / qMax(i2->ColGap, 10.0)), 1));
- if (distanceWidgets->columnGapLabel->currentIndex() == 0)
- {
- distanceWidgets->columnGap->setMaximum(qMax((i2->width() / i2->Cols - i2->textToFrameDistLeft() - i2->textToFrameDistRight())*m_unitRatio, 0.0));
- distanceWidgets->columnGap->setValue(i2->ColGap*m_unitRatio);
- }
- else
- {
- distanceWidgets->columnGap->setMaximum(qMax((i2->width() / i2->Cols)*m_unitRatio, 0.0));
- distanceWidgets->columnGap->setValue(i2->columnWidth()*m_unitRatio);
- }
- }
- }
- distanceWidgets->columns->setMinimum(1);
- distanceWidgets->columnGap->setMinimum(0);
- if (distanceWidgets->columns->value() == 1)
- {
- distanceWidgets->columnGap->setEnabled(false);
- distanceWidgets->columnGapLabel->setEnabled(false);
- }
- else
- {
- distanceWidgets->columnGap->setEnabled(true);
- distanceWidgets->columnGapLabel->setEnabled(true);
- }
m_haveItem = tmp;
}
@@ -535,13 +419,6 @@
m_haveItem = tmp;
}
-void PropertiesPalette_Text::displayTextDistances(double left, double top, double bottom, double right)
-{
- if (!m_ScMW || m_ScMW->scriptIsRunning())
- return;
- distanceWidgets->displayTextDistances(left, top, bottom, right);
-}
-
void PropertiesPalette_Text::displayFontFace(const QString& newFont)
{
if (!m_ScMW || m_ScMW->scriptIsRunning())
@@ -615,6 +492,7 @@
advancedWidgets->updateStyle(newCurrent);
colorWidgets->updateStyle(newCurrent);
+ optMargins->updateStyle(newCurrent);
orphanBox->updateStyle (newCurrent);
dropcapsBox->updateStyle(newCurrent);
@@ -628,8 +506,6 @@
lineSpacingModeCombo->setCurrentIndex(newCurrent.lineSpacingMode());
textAlignment->setStyle(newCurrent.alignment());
- displayOpticalMargins(newCurrent);
-
m_haveItem = tmp;
}
@@ -681,18 +557,10 @@
paraStyleCombo->blockSignals(blocked);
}
-void PropertiesPalette_Text::handleOpticalMargins()
+void PropertiesPalette_Text::handleLineSpacing()
{
if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
return;
- int omt(ParagraphStyle::OM_None);
- if (optMargins->optMarginRadioBoth->isChecked())
- omt = ParagraphStyle::OM_Default;
- else if (optMargins->optMarginRadioLeft->isChecked())
- omt = ParagraphStyle::OM_LeftHangingPunct;
- else if (optMargins->optMarginRadioRight->isChecked())
- omt = ParagraphStyle::OM_RightHangingPunct;
-
PageItem *i2 = m_item;
if (m_doc->appMode == modeEditTable)
i2 = m_item->asTable()->activeCell().textFrame();
@@ -700,11 +568,11 @@
{
Selection tempSelection(this, false);
tempSelection.addItem(i2, true);
- m_doc->itemSelection_SetOpticalMargins(omt, &tempSelection);
- }
-}
-
-void PropertiesPalette_Text::resetOpticalMargins()
+ m_doc->itemSelection_SetLineSpacing(lineSpacing->value(), &tempSelection);
+ }
+}
+
+void PropertiesPalette_Text::handleFontSize()
{
if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
return;
@@ -715,26 +583,11 @@
{
Selection tempSelection(this, false);
tempSelection.addItem(i2, true);
- m_doc->itemSelection_resetOpticalMargins(&tempSelection);
- }
-}
-
-void PropertiesPalette_Text::displayOpticalMargins(const ParagraphStyle & pStyle)
-{
- ParagraphStyle::OpticalMarginType omt(static_cast<ParagraphStyle::OpticalMarginType>(pStyle.opticalMargins()));
- bool blocked = optMargins->optMarginRadioBoth->blockSignals(true);
- if (omt == ParagraphStyle::OM_Default)
- optMargins->optMarginRadioBoth->setChecked(true);
- else if (omt == ParagraphStyle::OM_LeftHangingPunct)
- optMargins->optMarginRadioLeft->setChecked(true);
- else if (omt == ParagraphStyle::OM_RightHangingPunct)
- optMargins->optMarginRadioRight->setChecked(true);
- else
- optMargins->optMarginRadioNone->setChecked(true);
- optMargins->optMarginRadioBoth->blockSignals(blocked);
-}
-
-void PropertiesPalette_Text::handleLineSpacing()
+ m_doc->itemSelection_SetFontSize(qRound(fontSize->value()*10.0), &tempSelection);
+ }
+}
+
+void PropertiesPalette_Text::handleAlignement(int a)
{
if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
return;
@@ -745,149 +598,15 @@
{
Selection tempSelection(this, false);
tempSelection.addItem(i2, true);
- m_doc->itemSelection_SetLineSpacing(lineSpacing->value(), &tempSelection);
- }
-}
-
-void PropertiesPalette_Text::handleGapSwitch()
+ m_doc->itemSelection_SetAlignment(a, &tempSelection);
+ }
+}
+
+void PropertiesPalette_Text::handleTextFont(QString c)
{
if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
return;
- PageItem *i2 = m_item;
- if (m_doc->appMode == modeEditTable)
- i2 = m_item->asTable()->activeCell().textFrame();
- if (i2 != NULL)
- displayColumns(i2->Cols, i2->ColGap);
- distanceWidgets->columnGap->setToolTip("");
- if (distanceWidgets->columnGapLabel->currentIndex() == 0)
- distanceWidgets->columnGap->setToolTip( tr( "Distance between columns" ) );
- else
- distanceWidgets->columnGap->setToolTip( tr( "Column width" ) );
-}
-
-void PropertiesPalette_Text::handleColumns()
-{
- if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
- return;
- PageItem *i2 = m_item;
- if (m_doc->appMode == modeEditTable)
- i2 = m_item->asTable()->activeCell().textFrame();
- if (i2 != NULL)
- {
- i2->Cols = distanceWidgets->columns->value();
- displayColumns(i2->Cols, i2->ColGap);
- if (distanceWidgets->columns->value() == 1)
- {
- distanceWidgets->columnGap->setEnabled(false);
- distanceWidgets->columnGapLabel->setEnabled(false);
- }
- else
- {
- distanceWidgets->columnGap->setEnabled(true);
- distanceWidgets->columnGapLabel->setEnabled(true);
- }
- i2->update();
- if (m_doc->appMode == modeEditTable)
- m_item->asTable()->update();
- else
- m_item->update();
- m_doc->regionsChanged()->update(QRect());
- }
-}
-
-void PropertiesPalette_Text::handleColumnGap()
-{
- if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
- return;
- PageItem *i2 = m_item;
- if (m_doc->appMode == modeEditTable)
- i2 = m_item->asTable()->activeCell().textFrame();
- if (i2 != NULL)
- {
- if (distanceWidgets->columnGapLabel->currentIndex() == 0)
- i2->ColGap = distanceWidgets->columnGap->value() / m_unitRatio;
- else
- {
- double lineCorr;
- if ((i2->lineColor() != CommonStrings::None) || (!i2->strokePattern().isEmpty()))
- lineCorr = i2->lineWidth();
- else
- lineCorr = 0;
- double newWidth = distanceWidgets->columnGap->value() / m_unitRatio;
- double newGap = qMax(((i2->width() - i2->textToFrameDistLeft() - i2->textToFrameDistRight() - lineCorr) - (newWidth * i2->Cols)) / (i2->Cols - 1), 0.0);
- i2->ColGap = newGap;
- }
- i2->update();
- if (m_doc->appMode == modeEditTable)
- m_item->asTable()->update();
- else
- m_item->update();
- m_doc->regionsChanged()->update(QRect());
- }
-}
-
-void PropertiesPalette_Text::handleFontSize()
-{
- if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
- return;
- PageItem *i2 = m_item;
- if (m_doc->appMode == modeEditTable)
- i2 = m_item->asTable()->activeCell().textFrame();
- if (i2 != NULL)
- {
- Selection tempSelection(this, false);
- tempSelection.addItem(i2, true);
- m_doc->itemSelection_SetFontSize(qRound(fontSize->value()*10.0), &tempSelection);
- }
-}
-
-void PropertiesPalette_Text::handleAlignement(int a)
-{
- if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
- return;
- PageItem *i2 = m_item;
- if (m_doc->appMode == modeEditTable)
- i2 = m_item->asTable()->activeCell().textFrame();
- if (i2 != NULL)
- {
- Selection tempSelection(this, false);
- tempSelection.addItem(i2, true);
- m_doc->itemSelection_SetAlignment(a, &tempSelection);
- }
-}
-
-void PropertiesPalette_Text::handleTextDistances()
-{
- if (!m_ScMW || m_ScMW->scriptIsRunning())
- return;
- if ((m_haveDoc) && (m_haveItem))
- {
- PageItem *i2 = m_item;
- if (m_doc->appMode == modeEditTable)
- i2 = m_item->asTable()->activeCell().textFrame();
- if (i2 != NULL)
- {
- double left = distanceWidgets->leftDistance->value() / m_unitRatio;
- double right = distanceWidgets->rightDistance->value() / m_unitRatio;
- double top = distanceWidgets->topDistance->value() / m_unitRatio;
- double bottom = distanceWidgets->bottomDistance->value() / m_unitRatio;
- i2->setTextToFrameDist(left, right, top, bottom);
- displayColumns(i2->Cols, i2->ColGap);
- i2->update();
- if (m_doc->appMode == modeEditTable)
- m_item->asTable()->update();
- else
- m_item->update();
- m_doc->regionsChanged()->update(QRect());
- }
- }
-}
-
-void PropertiesPalette_Text::handleTextFont(QString c)
-{
- if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
- return;
- emit NewFont(c);
+ m_ScMW->SetNewFont(c);
}
void PropertiesPalette_Text::doClearCStyle()
@@ -937,109 +656,6 @@
colorWidgets->updateColorList();
}
-void PropertiesPalette_Text::handlePathType()
-{
- if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
- return;
- m_item->textPathType = pathTextWidgets->pathTextType->currentIndex();
- m_item->update();
- m_doc->regionsChanged()->update(QRect());
-}
-
-void PropertiesPalette_Text::handlePathFlip()
-{
- if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
- return;
- m_item->textPathFlipped = pathTextWidgets->flippedPathText->isChecked();
- m_item->updatePolyClip();
- m_item->update();
- m_doc->regionsChanged()->update(QRect());
-}
-
-void PropertiesPalette_Text::handlePathLine()
-{
- if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
- return;
- m_item->PoShow = pathTextWidgets->showCurveCheckBox->isChecked();
- m_item->update();
-}
-
-void PropertiesPalette_Text::handlePathDist()
-{
- if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
- return;
- m_item->setTextToFrameDistLeft(pathTextWidgets->startOffset->value());
- m_doc->AdjustItemSize(m_item);
- m_item->updatePolyClip();
- m_item->update();
- m_doc->regionsChanged()->update(QRect());
-}
-
-void PropertiesPalette_Text::handlePathOffs()
-{
- if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning())
- return;
- m_item->BaseOffs = -pathTextWidgets->distFromCurve->value();
- m_doc->AdjustItemSize(m_item);
- m_item->updatePolyClip();
- m_item->update();
- m_doc->regionsChanged()->update(QRect());
-}
-
-void PropertiesPalette_Text::fillLangCombo(QMap<QString,QString> langMap)
-{
- QStringList sortList;
- QMap<QString,QString>::Iterator it;
- if (!m_ScMW || m_ScMW->scriptIsRunning())
- return;
- langCombo->clear();
- for (it = langMap.begin(); it != langMap.end(); ++it)
- sortList.push_back(it.value());
- langCombo->addItems(sortQStringList(sortList));
- QListView *tmpView = dynamic_cast<QListView*>(langCombo->view()); Q_ASSERT(tmpView);
- int tmpWidth = tmpView->sizeHintForColumn(0);
- if (tmpWidth > 0)
- tmpView->setMinimumWidth(tmpWidth + 24);
-}
-
-void PropertiesPalette_Text::handleHyphLanguage()
-{
- if ((m_haveDoc) && (m_haveItem))
- {
- m_item->doc()->setHyphLanguage(m_ScMW->GetLang(langCombo->currentText()));
- m_doc->changed();
- }
-}
-
-void PropertiesPalette_Text::handleTabs()
-{
- if ((m_haveDoc) && (m_haveItem))
- {
- PageItem_TextFrame *i2=m_item->asTextFrame();
- if (i2==0)
- return;
- const ParagraphStyle& style(m_doc->appMode == modeEdit ? i2->currentStyle() : i2->itemText.defaultStyle());
- TabManager *dia = new TabManager(this, m_doc->unitIndex(), style.tabValues(), i2->columnWidth());
- if (dia->exec())
- {
- if (m_doc->appMode != modeEdit)
- {
- ParagraphStyle newStyle(m_item->itemText.defaultStyle());
- newStyle.setTabValues(dia->tmpTab);
- m_item->itemText.setDefaultStyle(newStyle);
- }
- else
- {
- ParagraphStyle newStyle;
- newStyle.setTabValues(dia->tmpTab);
- m_doc->itemSelection_ApplyParagraphStyle(newStyle);
- }
- m_item->update();
- }
- delete dia;
- }
-}
-
void PropertiesPalette_Text::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange)
@@ -1062,7 +678,6 @@
optMarginsItem->setText(0, tr("Optical Margins"));
orphanItem->setText(0, tr("Orphans and Widows"));
pathTextItem->setText(0, tr("Path Text Properties"));
-
int oldLineSpacingMode = lineSpacingModeCombo->currentIndex();
lineSpacingModeCombo->clear();
Modified: trunk/Scribus/scribus/ui/propertiespalette_text.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertiespalette_text.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette_text.h (original)
+++ trunk/Scribus/scribus/ui/propertiespalette_text.h Mon Mar 19 00:25:48 2012
@@ -47,11 +47,7 @@
virtual void changeEvent(QEvent *e);
void updateColorList();
- /*! \brief fills the langs combobox in language specific order
- \author 10/07/2004 - Petr Vanek - rewritten to fix #1185.
- Uses sortQStringList from utils.cpp - STL!
- \param langMap a structure with languages/hyphs*/
- void fillLangCombo(QMap<QString,QString> langMap);
+
/** @brief Returns true if there is a user action going on at the moment of call. */
bool userActionOn(); // not yet implemented!!! This is needed badly.
// When user releases the mouse button or arrow key, changes must be checked
@@ -88,14 +84,11 @@
void displayAlignment(int e);
void displayCharStyle(const QString& name);
- void displayColumns(int r, double g);
void displayFontFace(const QString&);
void displayFontSize(double s);
void displayFirstLinePolicy(FirstLineOffsetPolicy);
void displayLineSpacing(double r);
- void displayOpticalMargins(const ParagraphStyle& pStyle);
void displayParStyle(const QString& name);
- void displayTextDistances(double left, double top, double bottom, double right);
void setupLineSpacingSpinbox(int mode, double value);
@@ -108,35 +101,20 @@
void updateTextStyles();
void handleLineSpacingMode(int id);
- void handleOpticalMargins();
- void resetOpticalMargins();
- void handleTabs();
void handleTextFont(QString);
private slots:
void handleAlignement(int a);
- void handleColumns();
- void handleColumnGap();
void handleFirstLinePolicy(int);
void handleFontSize();
- void handleGapSwitch();
- void handleHyphLanguage();
void handleLineSpacing();
- void handleTextDistances();
void doClearCStyle();
void doClearPStyle();
- void handlePathType();
- void handlePathFlip();
- void handlePathLine();
- void handlePathDist();
- void handlePathOffs();
-
protected:
ScComboBox* pathTextType;
- QComboBox* langCombo;
PropertyWidget_TextColor* colorWidgets;
QTreeWidgetItem* colorWidgetsItem;
@@ -161,10 +139,6 @@
PropertyWidget_PathText* pathTextWidgets;
QTreeWidgetItem* pathTextItem;
-
-signals:
- void NewAlignment(int);
- void NewFont(const QString&);
};
#endif
Modified: trunk/Scribus/scribus/ui/propertywidget_advanced.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_advanced.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_advanced.cpp (original)
+++ trunk/Scribus/scribus/ui/propertywidget_advanced.cpp Mon Mar 19 00:25:48 2012
@@ -99,7 +99,7 @@
m_item = item;
disconnectSignals();
- enableFromSelection();
+ configureWidgets();
if (m_item)
{
@@ -140,7 +140,7 @@
disconnect(maxGlyphExtSpinBox , SIGNAL(valueChanged(double)), this, SLOT(handleMaxGlyphExtension()) );
}
-void PropertyWidget_Advanced::enableFromSelection(void)
+void PropertyWidget_Advanced::configureWidgets(void)
{
bool enabled = false;
if (m_item && m_doc)
Modified: trunk/Scribus/scribus/ui/propertywidget_advanced.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_advanced.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_advanced.h (original)
+++ trunk/Scribus/scribus/ui/propertywidget_advanced.h Mon Mar 19 00:25:48 2012
@@ -25,8 +25,6 @@
PropertyWidget_Advanced(QWidget* parent);
~PropertyWidget_Advanced() {};
- virtual void changeEvent(QEvent *e);
-
protected:
void connectSignals();
void disconnectSignals();
@@ -37,8 +35,10 @@
PageItem* m_item;
ScribusMainWindow* m_ScMW;
- void enableFromSelection(void);
+ void configureWidgets(void);
void setCurrentItem(PageItem *i);
+
+ virtual void changeEvent(QEvent *e);
public slots:
void setMainWindow(ScribusMainWindow *mw);
Modified: trunk/Scribus/scribus/ui/propertywidget_distance.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_distance.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_distance.cpp (original)
+++ trunk/Scribus/scribus/ui/propertywidget_distance.cpp Mon Mar 19 00:25:48 2012
@@ -7,12 +7,20 @@
#include "propertywidget_distance.h"
+#include "pageitem_table.h"
+#include "pageitem_textframe.h"
+#include "scribus.h"
#include "scribusdoc.h"
+#include "selection.h"
+#include "tabmanager.h"
#include "units.h"
#include "util_icon.h"
PropertyWidget_Distance::PropertyWidget_Distance(QWidget* parent) : QFrame(parent)
{
+ m_item = 0;
+ m_ScMW = 0;
+
setupUi(this);
setFrameStyle(QFrame::Box | QFrame::Plain);
@@ -40,15 +48,33 @@
columnGapLabel->setCurrentIndex(0);
}
+void PropertyWidget_Distance::setMainWindow(ScribusMainWindow* mw)
+{
+ m_ScMW = mw;
+
+ connect(m_ScMW, SIGNAL(AppModeChanged(int, int)), this, SLOT(handleAppModeChanged(int, int)));
+ connect(m_ScMW, SIGNAL(UpdateRequest(int)) , this, SLOT(handleUpdateRequest(int)));
+}
+
void PropertyWidget_Distance::setDoc(ScribusDoc *d)
{
if(d == (ScribusDoc*) m_doc)
return;
+ if (m_doc)
+ {
+ disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+ disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged()));
+ }
+
m_doc = d;
+ m_item = NULL;
if (m_doc.isNull())
- return;
+ {
+ disconnectSignals();
+ return;
+ }
m_unitRatio = m_doc->unitRatio();
m_unitIndex = m_doc->unitIndex();
@@ -58,6 +84,312 @@
leftDistance->setDecimals(2);
bottomDistance->setDecimals(2);
rightDistance->setDecimals(2);
+
+ connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+ connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged()));
+}
+
+void PropertyWidget_Distance::setCurrentItem(PageItem *item)
+{
+ if (!m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+ //CB We shouldnt really need to process this if our item is the same one
+ //maybe we do if the item has been changed by scripter.. but that should probably
+ //set some status if so.
+ //FIXME: This wont work until when a canvas deselect happens, m_item must be NULL.
+ //if (m_item == i)
+ // return;
+
+ if (item && m_doc.isNull())
+ setDoc(item->doc());
+
+ m_item = item;
+
+ disconnectSignals();
+ configureWidgets();
+
+ if (!m_item) return;
+
+ PageItem_TextFrame *textItem = m_item->asTextFrame();
+ if (m_doc->appMode == modeEditTable)
+ textItem = m_item->asTable()->activeCell().textFrame();
+ if (!textItem) return;
+
+ columns->setMaximum(qMax(qRound(textItem->width() / qMax(textItem->ColGap, 10.0)), 1));
+ columns->setMinimum(1);
+ columns->setValue(textItem->Cols);
+ columnGap->setMinimum(0);
+ if (columnGapLabel->currentIndex() == 0)
+ {
+ columnGap->setMaximum(qMax((textItem->width() / textItem->Cols - textItem->textToFrameDistLeft() - textItem->textToFrameDistRight()) * m_unitRatio, 0.0));
+ columnGap->setValue(textItem->ColGap*m_unitRatio);
+ }
+ else
+ {
+ columnGap->setMaximum(qMax((textItem->width() / textItem->Cols) * m_unitRatio, 0.0));
+ columnGap->setValue(textItem->columnWidth() * m_unitRatio);
+ }
+ leftDistance->setValue(textItem->textToFrameDistLeft()*m_unitRatio);
+ topDistance->setValue(textItem->textToFrameDistTop()*m_unitRatio);
+ bottomDistance->setValue(textItem->textToFrameDistBottom()*m_unitRatio);
+ rightDistance->setValue(textItem->textToFrameDistRight()*m_unitRatio);
+ if (columns->value() == 1)
+ {
+ columnGap->setEnabled(false);
+ columnGapLabel->setEnabled(false);
+ }
+ else
+ {
+ columnGap->setEnabled(true);
+ columnGapLabel->setEnabled(true);
+ }
+
+ displayTextDistances(textItem->textToFrameDistLeft(), textItem->textToFrameDistTop(), textItem->textToFrameDistBottom(), textItem->textToFrameDistRight());
+ connectSignals();
+}
+
+void PropertyWidget_Distance::connectSignals()
+{
+ connect(columns , SIGNAL(valueChanged(int)) , this, SLOT(handleColumns()), Qt::UniqueConnection);
+ connect(columnGap , SIGNAL(valueChanged(double)), this, SLOT(handleColumnGap()), Qt::UniqueConnection);
+ connect(columnGapLabel, SIGNAL(activated(int)) , this, SLOT(handleGapSwitch()), Qt::UniqueConnection);
+ connect(topDistance , SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()), Qt::UniqueConnection);
+ connect(leftDistance , SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()), Qt::UniqueConnection);
+ connect(rightDistance , SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()), Qt::UniqueConnection);
+ connect(bottomDistance, SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()), Qt::UniqueConnection);
+ connect(tabsButton , SIGNAL(clicked()) , this, SLOT(handleTabs()), Qt::UniqueConnection);
+}
+
+void PropertyWidget_Distance::disconnectSignals()
+{
+ disconnect(columns , SIGNAL(valueChanged(int)) , this, SLOT(handleColumns()));
+ disconnect(columnGap , SIGNAL(valueChanged(double)), this, SLOT(handleColumnGap()));
+ disconnect(columnGapLabel, SIGNAL(activated(int)) , this, SLOT(handleGapSwitch()));
+ disconnect(topDistance , SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()));
+ disconnect(leftDistance , SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()));
+ disconnect(rightDistance , SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()));
+ disconnect(bottomDistance, SIGNAL(valueChanged(double)), this, SLOT(handleTextDistances()));
+ disconnect(tabsButton , SIGNAL(clicked()) , this, SLOT(handleTabs()));
+}
+
+void PropertyWidget_Distance::configureWidgets(void)
+{
+ bool enabled = false;
+ if (m_item && m_doc)
+ {
+ PageItem_TextFrame *textItem = m_item->asTextFrame();
+ if (m_doc->appMode == modeEditTable)
+ textItem = m_item->asTable()->activeCell().textFrame();
+
+ enabled = (textItem != NULL);
+ enabled &= (m_doc->m_Selection->count() == 1);
+
+ if (textItem)
+ {
+ int numCols = textItem->Cols;
+
+ columnGap->setEnabled(numCols != 1);
+ columnGapLabel->setEnabled(numCols != 1);
+ }
+ }
+ setEnabled(enabled);
+}
+
+void PropertyWidget_Distance::handleAppModeChanged(int oldMode, int mode)
+{
+ if (oldMode == modeEditTable || mode == modeEditTable)
+ {
+ setCurrentItem(m_item);
+ }
+}
+
+void PropertyWidget_Distance::handleSelectionChanged()
+{
+ if (!m_doc || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+
+ PageItem* currItem = currentItemFromSelection();
+ setCurrentItem(currItem);
+ updateGeometry();
+ repaint();
+}
+
+void PropertyWidget_Distance::handleUpdateRequest(int /*updateFlags*/)
+{
+ // Nothing to do in this widget
+}
+
+void PropertyWidget_Distance::displayColumns(int r, double g)
+{
+ if (!m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+
+ bool cSigWasBlocked = columns->blockSignals(true);
+ bool cGapSigWasBlocked = columnGap->blockSignals(true);
+
+ columns->setValue(r);
+ columnGap->setValue(g * m_unitRatio);
+ if (m_item)
+ {
+ PageItem_TextFrame *textItem = m_item->asTextFrame();
+ if (m_doc->appMode == modeEditTable)
+ textItem = m_item->asTable()->activeCell().textFrame();
+
+ if (textItem != 0)
+ {
+ columns->setMaximum(qMax(qRound(textItem->width() / qMax(textItem->ColGap, 10.0)), 1));
+ if (columnGapLabel->currentIndex() == 0)
+ {
+ columnGap->setMaximum(qMax((textItem->width() / textItem->Cols - textItem->textToFrameDistLeft() - textItem->textToFrameDistRight()) * m_unitRatio, 0.0));
+ columnGap->setValue(textItem->ColGap * m_unitRatio);
+ }
+ else
+ {
+ columnGap->setMaximum(qMax((textItem->width() / textItem->Cols) * m_unitRatio, 0.0));
+ columnGap->setValue(textItem->columnWidth() * m_unitRatio);
+ }
+ }
+ }
+ columns->setMinimum(1);
+ columnGap->setMinimum(0);
+ columnGap->setEnabled(columns->value() != 1);
+ columnGapLabel->setEnabled(columns->value() != 1);
+
+ columns->blockSignals(cSigWasBlocked);
+ columnGap->blockSignals(cGapSigWasBlocked);
+}
+
+void PropertyWidget_Distance::displayTextDistances(double left, double top, double bottom, double right)
+{
+ leftDistance->showValue(left * m_unitRatio);
+ topDistance->showValue(top * m_unitRatio);
+ bottomDistance->showValue(bottom * m_unitRatio);
+ rightDistance->showValue(right * m_unitRatio);
+}
+
+void PropertyWidget_Distance::handleColumns()
+{
+ if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+
+ PageItem *textItem = m_item;
+ if (m_doc->appMode == modeEditTable)
+ textItem = m_item->asTable()->activeCell().textFrame();
+
+ if (textItem)
+ {
+ textItem->Cols = columns->value();
+ displayColumns(textItem->Cols, textItem->ColGap);
+ if (columns->value() == 1)
+ {
+ columnGap->setEnabled(false);
+ columnGapLabel->setEnabled(false);
+ }
+ else
+ {
+ columnGap->setEnabled(true);
+ columnGapLabel->setEnabled(true);
+ }
+ textItem->update();
+ if (m_doc->appMode == modeEditTable)
+ m_item->asTable()->update();
+ m_doc->regionsChanged()->update(QRect());
+ }
+}
+
+void PropertyWidget_Distance::handleColumnGap()
+{
+ if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+
+ PageItem *textItem = m_item;
+ if (m_doc->appMode == modeEditTable)
+ textItem = m_item->asTable()->activeCell().textFrame();
+ if (!textItem) return;
+
+ if (columnGapLabel->currentIndex() == 0)
+ textItem->ColGap = columnGap->value() / m_unitRatio;
+ else
+ {
+ double lineCorr;
+ if ((textItem->lineColor() != CommonStrings::None) || (!textItem->strokePattern().isEmpty()))
+ lineCorr = textItem->lineWidth();
+ else
+ lineCorr = 0;
+ double newWidth = columnGap->value() / m_unitRatio;
+ double newGap = qMax(((textItem->width() - textItem->textToFrameDistLeft() - textItem->textToFrameDistRight() - lineCorr) - (newWidth * textItem->Cols)) / (textItem->Cols - 1), 0.0);
+ textItem->ColGap = newGap;
+ }
+ textItem->update();
+ if (m_doc->appMode == modeEditTable)
+ m_item->asTable()->update();
+ m_doc->regionsChanged()->update(QRect());
+}
+
+void PropertyWidget_Distance::handleGapSwitch()
+{
+ if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+ PageItem *textItem = m_item;
+ if (m_doc->appMode == modeEditTable)
+ textItem = m_item->asTable()->activeCell().textFrame();
+ if (textItem != NULL)
+ displayColumns(textItem->Cols, textItem->ColGap);
+
+ int index = columnGapLabel->currentIndex();
+ columnGap->setToolTip((index == 0) ? tr( "Distance between columns" ) : tr( "Column width" ));
+}
+
+void PropertyWidget_Distance::handleTabs()
+{
+ if (m_doc && m_item)
+ {
+ PageItem_TextFrame *tItem = m_item->asTextFrame();
+ if (tItem == 0)
+ return;
+ const ParagraphStyle& style(m_doc->appMode == modeEdit ? tItem->currentStyle() : tItem->itemText.defaultStyle());
+ TabManager *dia = new TabManager(this, m_doc->unitIndex(), style.tabValues(), tItem->columnWidth());
+ if (dia->exec())
+ {
+ if (m_doc->appMode != modeEdit)
+ {
+ ParagraphStyle newStyle(m_item->itemText.defaultStyle());
+ newStyle.setTabValues(dia->tmpTab);
+ m_item->itemText.setDefaultStyle(newStyle);
+ }
+ else
+ {
+ ParagraphStyle newStyle;
+ newStyle.setTabValues(dia->tmpTab);
+ m_doc->itemSelection_ApplyParagraphStyle(newStyle);
+ }
+ m_item->update();
+ }
+ delete dia;
+ }
+}
+
+void PropertyWidget_Distance::handleTextDistances()
+{
+ if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+
+ PageItem *textItem = m_item;
+ if (m_doc->appMode == modeEditTable)
+ textItem = m_item->asTable()->activeCell().textFrame();
+ if (!textItem) return;
+
+ double left = leftDistance->value() / m_unitRatio;
+ double right = rightDistance->value() / m_unitRatio;
+ double top = topDistance->value() / m_unitRatio;
+ double bottom = bottomDistance->value() / m_unitRatio;
+ textItem->setTextToFrameDist(left, right, top, bottom);
+ displayColumns(textItem->Cols, textItem->ColGap);
+
+ textItem->update();
+ if (m_doc->appMode == modeEditTable)
+ m_item->asTable()->update();
+ m_doc->regionsChanged()->update(QRect());
}
void PropertyWidget_Distance::changeEvent(QEvent *e)
@@ -68,41 +400,6 @@
return;
}
QWidget::changeEvent(e);
-}
-
-void PropertyWidget_Distance::displayTextDistances(double left, double top, double bottom, double right)
-{
- leftDistance->showValue(left*m_unitRatio);
- topDistance->showValue(top*m_unitRatio);
- bottomDistance->showValue(bottom*m_unitRatio);
- rightDistance->showValue(right*m_unitRatio);
-}
-
-void PropertyWidget_Distance::unitChange()
-{
- if (!m_doc)
- return;
-
- m_unitRatio = m_doc->unitRatio();
- m_unitIndex = m_doc->unitIndex();
-
- columnGap->blockSignals(true);
- leftDistance->blockSignals(true);
- topDistance->blockSignals(true);
- bottomDistance->blockSignals(true);
- rightDistance->blockSignals(true);
-
- columnGap->setNewUnit( m_unitIndex );
- leftDistance->setNewUnit( m_unitIndex );
- topDistance->setNewUnit( m_unitIndex );
- bottomDistance->setNewUnit( m_unitIndex );
- rightDistance->setNewUnit( m_unitIndex );
-
- columnGap->blockSignals(false);
- leftDistance->blockSignals(false);
- topDistance->blockSignals(false);
- bottomDistance->blockSignals(false);
- rightDistance->blockSignals(false);
}
void PropertyWidget_Distance::languageChange()
@@ -140,4 +437,31 @@
leftDistance->setToolTip( tr("Distance of text from left of frame"));
rightDistance->setToolTip( tr("Distance of text from right of frame"));
tabsButton->setToolTip( tr("Edit tab settings of text frame..."));
+}
+
+void PropertyWidget_Distance::unitChange()
+{
+ if (!m_doc)
+ return;
+
+ m_unitRatio = m_doc->unitRatio();
+ m_unitIndex = m_doc->unitIndex();
+
+ columnGap->blockSignals(true);
+ leftDistance->blockSignals(true);
+ topDistance->blockSignals(true);
+ bottomDistance->blockSignals(true);
+ rightDistance->blockSignals(true);
+
+ columnGap->setNewUnit( m_unitIndex );
+ leftDistance->setNewUnit( m_unitIndex );
+ topDistance->setNewUnit( m_unitIndex );
+ bottomDistance->setNewUnit( m_unitIndex );
+ rightDistance->setNewUnit( m_unitIndex );
+
+ columnGap->blockSignals(false);
+ leftDistance->blockSignals(false);
+ topDistance->blockSignals(false);
+ bottomDistance->blockSignals(false);
+ rightDistance->blockSignals(false);
}
Modified: trunk/Scribus/scribus/ui/propertywidget_distance.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_distance.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_distance.h (original)
+++ trunk/Scribus/scribus/ui/propertywidget_distance.h Mon Mar 19 00:25:48 2012
@@ -9,11 +9,13 @@
#include "ui_propertywidget_distancebase.h"
-#include "scguardedptr.h"
+#include "propertywidgetbase.h"
class ScribusDoc;
+class ScribusMainWindow;
-class PropertyWidget_Distance : public QFrame, public Ui::PropertyWidget_DistanceBase
+class PropertyWidget_Distance : public QFrame, public Ui::PropertyWidget_DistanceBase,
+ public PropertyWidgetBase
{
Q_OBJECT
@@ -21,23 +23,41 @@
PropertyWidget_Distance(QWidget* parent);
~PropertyWidget_Distance() {};
- virtual void changeEvent(QEvent *e);
+protected:
+ void connectSignals();
+ void disconnectSignals();
-protected:
+ PageItem * m_item;
+ ScribusMainWindow* m_ScMW;
double m_unitRatio;
int m_unitIndex;
- ScGuardedPtr<ScribusDoc> m_doc;
+ void configureWidgets(void);
+ void setCurrentItem(PageItem *item);
+
+ virtual void changeEvent(QEvent *e);
public slots:
+ void setMainWindow(ScribusMainWindow *mw);
+ void setDoc(ScribusDoc *d);
- void setDoc(ScribusDoc *d);
+ void handleAppModeChanged(int oldMode, int mode);
+ void handleSelectionChanged();
+ void handleUpdateRequest(int);
void languageChange();
void unitChange();
+ void displayColumns(int r, double g);
void displayTextDistances(double left, double top, double bottom, double right);
+
+private slots:
+ void handleColumns();
+ void handleColumnGap();
+ void handleGapSwitch();
+ void handleTabs();
+ void handleTextDistances();
};
#endif
Modified: trunk/Scribus/scribus/ui/propertywidget_dropcap.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_dropcap.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_dropcap.cpp (original)
+++ trunk/Scribus/scribus/ui/propertywidget_dropcap.cpp Mon Mar 19 00:25:48 2012
@@ -1,187 +1,284 @@
-/*
-For general Scribus (>=1.3.2) copyright and licensing information please refer
-to the COPYING file provided with the program. Following this notice may exist
-a copyright and/or license notice that predates the release of Scribus 1.3.2
-for which a new license (GPL+exception) is in place.
-*/
-
-#include "pageitem_table.h"
-#include "propertywidget_dropcap.h"
-#include "scribus.h"
-#include "selection.h"
-#include "units.h"
-#include "util.h"
-
-PropertyWidget_DropCap::PropertyWidget_DropCap(QWidget *parent) : QFrame(parent)
-{
- setupUi(this);
- setFrameStyle(QFrame::Box | QFrame::Plain);
- setLineWidth(1);
- layout()->setAlignment( Qt::AlignTop );
-
- languageChange();
-
- if (!m_doc) return;
- dropCapCharStyleCombo->updateFormatList();
-}
-
-void PropertyWidget_DropCap::setDoc(ScribusDoc *doc)
-{
- m_doc = doc;
- dropCapCharStyleCombo->setDoc(doc);
-
- if (!m_doc)
- return;
-
- m_unitRatio = m_doc->unitRatio();
- m_unitIndex = m_doc->unitIndex();
- dropCapOffset->setSuffix(unitGetSuffixFromIndex(0));
-}
-
-void PropertyWidget_DropCap::unitChange()
-{
- if (!m_doc)
- return;
-
- m_unitRatio = m_doc->unitRatio();
- m_unitIndex = m_doc->unitIndex();
-
- dropCapOffset->blockSignals(true);
- dropCapOffset->setNewUnit( m_unitIndex );
- dropCapOffset->blockSignals(false);
-}
-
-void PropertyWidget_DropCap::updateCharStyles()
-{
- dropCapCharStyleCombo->updateFormatList();
-}
-
-void PropertyWidget_DropCap::displayCharStyle(const QString& name)
-{
- bool blocked = dropCapCharStyleCombo->blockSignals(true);
- dropCapCharStyleCombo->setFormat(name);
- dropCapCharStyleCombo->blockSignals(blocked);
-}
-
-void PropertyWidget_DropCap::enableDropCap(bool enable)
-{
- dropCapLines->setEnabled(enable);
- dropCapOffset->setEnabled(enable);
- dropCapCharStyleCombo->setEnabled(enable);
-}
-
-void PropertyWidget_DropCap::updateStyle(const ParagraphStyle& newCurrent)
-{
- disconnectSignals ();
- dropCapBox->setChecked(newCurrent.hasDropCap());
- dropCapLines->setValue(newCurrent.dropCapLines());
- dropCapOffset->setValue(newCurrent.dropCapOffset() * m_unitRatio);
- displayCharStyle(newCurrent.dcCharStyleName());
- connectSignals ();
-}
-
-void PropertyWidget_DropCap::connectSignals()
-{
- connect(dropCapBox, SIGNAL(stateChanged(int)), this, SLOT(handleDropCapUse()));
- connect(dropCapLines, SIGNAL(valueChanged(int)), this, SLOT(handleDropCapLines()));
- connect(dropCapOffset, SIGNAL(valueChanged(double)), this, SLOT(handleDropCapOffset()));
- connect(dropCapCharStyleCombo, SIGNAL(activated(int)), this, SLOT(handleDropCapCharStyle()));
-}
-
-void PropertyWidget_DropCap::disconnectSignals()
-{
- disconnect(dropCapBox, SIGNAL(stateChanged(int)), this, SLOT(handleDropCapUse()));
- disconnect(dropCapLines, SIGNAL(valueChanged(int)), this, SLOT(handleDropCapLines()));
- disconnect(dropCapOffset, SIGNAL(valueChanged(double)), this, SLOT(handleDropCapOffset()));
- disconnect(dropCapCharStyleCombo, SIGNAL(activated(int)), this, SLOT(handleDropCapCharStyle()));
-}
-
-void PropertyWidget_DropCap::handleDropCapUse()
-{
- if (!m_doc) return;
- ParagraphStyle newStyle;
- newStyle.setHasDropCap(dropCapBox->isChecked());
- PageItem *i2 = m_doc->m_Selection->itemAt(0);
- if (m_doc->appMode == modeEditTable)
- i2 = i2->asTable()->activeCell().textFrame();
- if (i2 != NULL)
- {
- Selection tempSelection(this, false);
- tempSelection.addItem(i2, true);
- m_doc->itemSelection_ApplyParagraphStyle(newStyle, &tempSelection);
- }
- enableDropCap(dropCapBox->isChecked());
-}
-
-void PropertyWidget_DropCap::handleDropCapLines()
-{
- if (!m_doc) return;
- ParagraphStyle newStyle;
- newStyle.setDropCapLines(dropCapLines->value());
- newStyle.setHasDropCap(dropCapBox->isChecked());
- PageItem *i2 = m_doc->m_Selection->itemAt(0);
- if (m_doc->appMode == modeEditTable)
- i2 = i2->asTable()->activeCell().textFrame();
- if (i2 != NULL)
- {
- Selection tempSelection(this, false);
- tempSelection.addItem(i2, true);
- m_doc->itemSelection_ApplyParagraphStyle(newStyle, &tempSelection);
- }
-}
-
-void PropertyWidget_DropCap::handleDropCapOffset()
-{
- if (!m_doc) return;
- ParagraphStyle newStyle;
- newStyle.setDropCapOffset(dropCapOffset->value());
- newStyle.setHasDropCap(dropCapBox->isChecked());
- PageItem *i2 = m_doc->m_Selection->itemAt(0);
- if (m_doc->appMode == modeEditTable)
- i2 = i2->asTable()->activeCell().textFrame();
- if (i2 != NULL)
- {
- Selection tempSelection(this, false);
- tempSelection.addItem(i2, true);
- m_doc->itemSelection_ApplyParagraphStyle(newStyle, &tempSelection);
- }
-}
-
-void PropertyWidget_DropCap::handleDropCapCharStyle()
-{
- if (!m_doc) return;
- ParagraphStyle newStyle;
- QString name = dropCapCharStyleCombo->currentText();
- if (!name.isEmpty())
- newStyle.setDcCharStyleName(name);
- newStyle.setHasDropCap(dropCapBox->isChecked());
- PageItem *i2 = m_doc->m_Selection->itemAt(0);
- if (m_doc->appMode == modeEditTable)
- i2 = i2->asTable()->activeCell().textFrame();
- if (i2 != NULL)
- {
- Selection tempSelection(this, false);
- tempSelection.addItem(i2, true);
- m_doc->itemSelection_ApplyParagraphStyle(newStyle, &tempSelection);
- }
-}
-
-void PropertyWidget_DropCap::changeEvent(QEvent *e)
-{
- if (e->type() == QEvent::LanguageChange)
- {
- languageChange();
- return;
- }
- QWidget::changeEvent(e);
-}
-
-void PropertyWidget_DropCap::languageChange()
-{
- dropCapBox->setText(tr("Use Drop Caps"));
- dropCapLinesLabel->setText(tr("Drop Caps lines"));
- dropCapOffsetLabel->setText(tr("Drop Caps offset"));
- dropCapCharStyleLabel->setText(tr("Drop Cap use character style..."));
- dropCapCharStyleCombo->setToolTip("<qt>" + tr("Choose chracter style or leave blank for use default paragraph style"));
-}
-
+/*
+For general Scribus (>=1.3.2) copyright and licensing information please refer
+to the COPYING file provided with the program. Following this notice may exist
+a copyright and/or license notice that predates the release of Scribus 1.3.2
+for which a new license (GPL+exception) is in place.
+*/
+
+#include "pageitem.h"
+#include "pageitem_table.h"
+#include "propertywidget_dropcap.h"
+#include "scribus.h"
+#include "selection.h"
+#include "units.h"
+#include "util.h"
+
+PropertyWidget_DropCap::PropertyWidget_DropCap(QWidget *parent) : QFrame(parent)
+{
+ m_item = 0;
+ m_ScMW = 0;
+
+ setupUi(this);
+ setFrameStyle(QFrame::Box | QFrame::Plain);
+ setLineWidth(1);
+ layout()->setAlignment( Qt::AlignTop );
+
+ languageChange();
+
+ if (!m_doc) return;
+ dropCapCharStyleCombo->updateFormatList();
+}
+
+void PropertyWidget_DropCap::setMainWindow(ScribusMainWindow* mw)
+{
+ m_ScMW = mw;
+
+ connect(m_ScMW, SIGNAL(AppModeChanged(int, int)), this, SLOT(handleAppModeChanged(int, int)));
+ connect(m_ScMW, SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
+}
+
+void PropertyWidget_DropCap::setDoc(ScribusDoc *doc)
+{
+ if(doc == (ScribusDoc*) m_doc)
+ return;
+
+ if (m_doc)
+ {
+ disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+ disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged()));
+ }
+
+ m_doc = doc;
+ dropCapCharStyleCombo->setDoc(doc);
+
+ if (m_doc.isNull())
+ {
+ disconnectSignals();
+ return;
+ }
+
+ m_unitRatio = m_doc->unitRatio();
+ m_unitIndex = m_doc->unitIndex();
+ dropCapOffset->setSuffix(unitGetSuffixFromIndex(0));
+
+ connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+ connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged()));
+}
+
+void PropertyWidget_DropCap::setCurrentItem(PageItem *item)
+{
+ if (item && m_doc.isNull())
+ setDoc(item->doc());
+
+ m_item = item;
+
+ disconnectSignals();
+ configureWidgets();
+
+ if (!m_item) return;
+
+ if (m_item->asTextFrame() || m_item->asPathText() || m_item->asTable())
+ {
+ ParagraphStyle parStyle = m_item->itemText.defaultStyle();
+ if (m_doc->appMode == modeEdit)
+ m_item->currentTextProps(parStyle);
+ else if (m_doc->appMode == modeEditTable)
+ m_item->asTable()->activeCell().textFrame()->currentTextProps(parStyle);
+ updateStyle(parStyle);
+
+ connectSignals();
+ }
+}
+
+void PropertyWidget_DropCap::unitChange()
+{
+ if (!m_doc)
+ return;
+
+ m_unitRatio = m_doc->unitRatio();
+ m_unitIndex = m_doc->unitIndex();
+
+ dropCapOffset->blockSignals(true);
+ dropCapOffset->setNewUnit( m_unitIndex );
+ dropCapOffset->blockSignals(false);
+}
+
+void PropertyWidget_DropCap::updateCharStyles()
+{
+ dropCapCharStyleCombo->updateFormatList();
+}
+
+void PropertyWidget_DropCap::displayCharStyle(const QString& name)
+{
+ bool blocked = dropCapCharStyleCombo->blockSignals(true);
+ dropCapCharStyleCombo->setFormat(name);
+ dropCapCharStyleCombo->blockSignals(blocked);
+}
+
+void PropertyWidget_DropCap::enableDropCap(bool enable)
+{
+ dropCapLines->setEnabled(enable);
+ dropCapOffset->setEnabled(enable);
+ dropCapCharStyleCombo->setEnabled(enable);
+}
+
+void PropertyWidget_DropCap::updateStyle(const ParagraphStyle& newCurrent)
+{
+ disconnectSignals ();
+ dropCapBox->setChecked(newCurrent.hasDropCap());
+ dropCapLines->setValue(newCurrent.dropCapLines());
+ dropCapOffset->setValue(newCurrent.dropCapOffset() * m_unitRatio);
+ displayCharStyle(newCurrent.dcCharStyleName());
+ connectSignals ();
+}
+
+void PropertyWidget_DropCap::connectSignals()
+{
+ connect(dropCapBox, SIGNAL(stateChanged(int)), this, SLOT(handleDropCapUse()), Qt::UniqueConnection);
+ connect(dropCapLines, SIGNAL(valueChanged(int)), this, SLOT(handleDropCapLines()), Qt::UniqueConnection);
+ connect(dropCapOffset, SIGNAL(valueChanged(double)), this, SLOT(handleDropCapOffset()), Qt::UniqueConnection);
+ connect(dropCapCharStyleCombo, SIGNAL(activated(int)), this, SLOT(handleDropCapCharStyle()), Qt::UniqueConnection);
+}
+
+void PropertyWidget_DropCap::disconnectSignals()
+{
+ disconnect(dropCapBox, SIGNAL(stateChanged(int)), this, SLOT(handleDropCapUse()));
+ disconnect(dropCapLines, SIGNAL(valueChanged(int)), this, SLOT(handleDropCapLines()));
+ disconnect(dropCapOffset, SIGNAL(valueChanged(double)), this, SLOT(handleDropCapOffset()));
+ disconnect(dropCapCharStyleCombo, SIGNAL(activated(int)), this, SLOT(handleDropCapCharStyle()));
+}
+
+void PropertyWidget_DropCap::configureWidgets(void)
+{
+ bool enabled = false;
+ if (m_item && m_doc)
+ {
+ PageItem_TextFrame *textItem = m_item->asTextFrame();
+ if (m_doc->appMode == modeEditTable)
+ textItem = m_item->asTable()->activeCell().textFrame();
+ if (textItem || m_item->asPathText())
+ enabled = true;
+ }
+ setEnabled(enabled);
+}
+
+void PropertyWidget_DropCap::handleAppModeChanged(int oldMode, int mode)
+{
+ if (oldMode == modeEditTable || mode == modeEditTable)
+ {
+ setCurrentItem(m_item);
+ }
+}
+
+void PropertyWidget_DropCap::handleSelectionChanged()
+{
+ if (!m_doc || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+
+ PageItem* currItem = currentItemFromSelection();
+ setCurrentItem(currItem);
+ updateGeometry();
+ repaint();
+}
+
+void PropertyWidget_DropCap::handleUpdateRequest(int updateFlags)
+{
+ if (updateFlags & reqCharStylesUpdate)
+ updateCharStyles();
+ if (updateFlags & reqStyleComboDocUpdate)
+ setDoc(m_doc ? m_doc : 0);
+}
+
+void PropertyWidget_DropCap::handleDropCapUse()
+{
+ if (!m_doc || !m_item)
+ return;
+ ParagraphStyle newStyle;
+ newStyle.setHasDropCap(dropCapBox->isChecked());
+ PageItem *item = m_item;
+ if (m_doc->appMode == modeEditTable)
+ item = item->asTable()->activeCell().textFrame();
+ if (item != NULL)
+ {
+ Selection tempSelection(this, false);
+ tempSelection.addItem(item, true);
+ m_doc->itemSelection_ApplyParagraphStyle(newStyle, &tempSelection);
+ }
+ enableDropCap(dropCapBox->isChecked());
+}
+
+void PropertyWidget_DropCap::handleDropCapLines()
+{
+ if (!m_doc || !m_item)
+ return;
+ ParagraphStyle newStyle;
+ newStyle.setDropCapLines(dropCapLines->value());
+ newStyle.setHasDropCap(dropCapBox->isChecked());
+ PageItem *item = m_doc->m_Selection->itemAt(0);
+ if (m_doc->appMode == modeEditTable)
+ item = item->asTable()->activeCell().textFrame();
+ if (item != NULL)
+ {
+ Selection tempSelection(this, false);
+ tempSelection.addItem(item, true);
+ m_doc->itemSelection_ApplyParagraphStyle(newStyle, &tempSelection);
+ }
+}
+
+void PropertyWidget_DropCap::handleDropCapOffset()
+{
+ if (!m_doc || !m_item)
+ return;
+ ParagraphStyle newStyle;
+ newStyle.setDropCapOffset(dropCapOffset->value());
+ newStyle.setHasDropCap(dropCapBox->isChecked());
+ PageItem *item = m_item;
+ if (m_doc->appMode == modeEditTable)
+ item = item->asTable()->activeCell().textFrame();
+ if (item != NULL)
+ {
+ Selection tempSelection(this, false);
+ tempSelection.addItem(item, true);
+ m_doc->itemSelection_ApplyParagraphStyle(newStyle, &tempSelection);
+ }
+}
+
+void PropertyWidget_DropCap::handleDropCapCharStyle()
+{
+ if (!m_doc || !m_item)
+ return;
+ ParagraphStyle newStyle;
+ QString name = dropCapCharStyleCombo->currentText();
+ if (!name.isEmpty())
+ newStyle.setDcCharStyleName(name);
+ newStyle.setHasDropCap(dropCapBox->isChecked());
+ PageItem *item = m_item;
+ if (m_doc->appMode == modeEditTable)
+ item = item->asTable()->activeCell().textFrame();
+ if (item != NULL)
+ {
+ Selection tempSelection(this, false);
+ tempSelection.addItem(item, true);
+ m_doc->itemSelection_ApplyParagraphStyle(newStyle, &tempSelection);
+ }
+}
+
+void PropertyWidget_DropCap::changeEvent(QEvent *e)
+{
+ if (e->type() == QEvent::LanguageChange)
+ {
+ languageChange();
+ return;
+ }
+ QWidget::changeEvent(e);
+}
+
+void PropertyWidget_DropCap::languageChange()
+{
+ dropCapBox->setText(tr("Use Drop Caps"));
+ dropCapLinesLabel->setText(tr("Drop Caps lines"));
+ dropCapOffsetLabel->setText(tr("Drop Caps offset"));
+ dropCapCharStyleLabel->setText(tr("Drop Cap use character style..."));
+ dropCapCharStyleCombo->setToolTip("<qt>" + tr("Choose chracter style or leave blank for use default paragraph style"));
+}
+
Modified: trunk/Scribus/scribus/ui/propertywidget_dropcap.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_dropcap.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_dropcap.h (original)
+++ trunk/Scribus/scribus/ui/propertywidget_dropcap.h Mon Mar 19 00:25:48 2012
@@ -5,7 +5,9 @@
#include "propertywidgetbase.h"
+class PageItem;
class ParagraphStyle;
+class ScribusMainWindow;
class PropertyWidget_DropCap : public QFrame, private Ui::PropertyWidget_DropCapBase, public PropertyWidgetBase
{
@@ -17,17 +19,32 @@
void updateStyle(const ParagraphStyle& newCurrent);
void updateCharStyles();
- void setDoc(ScribusDoc *doc);
+
void displayCharStyle(const QString& name);
protected:
double m_unitRatio;
int m_unitIndex;
- void changeEvent(QEvent *e);
+
+ PageItem * m_item;
+ ScribusMainWindow* m_ScMW;
+
+ void configureWidgets();
+ void setCurrentItem(PageItem *item);
+
+ virtual void changeEvent(QEvent *e);
public slots:
+ void setMainWindow(ScribusMainWindow *mw);
+ void setDoc(ScribusDoc *doc);
+
+ void handleAppModeChanged(int oldMode, int mode);
+ void handleSelectionChanged();
+ void handleUpdateRequest(int);
+
void languageChange();
void unitChange();
+
void handleDropCapUse();
void handleDropCapLines();
void handleDropCapOffset();
Modified: trunk/Scribus/scribus/ui/propertywidget_flop.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_flop.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_flop.h (original)
+++ trunk/Scribus/scribus/ui/propertywidget_flop.h Mon Mar 19 00:25:48 2012
@@ -29,11 +29,11 @@
PropertyWidget_Flop(QWidget* parent);
~PropertyWidget_Flop() {};
- virtual void changeEvent(QEvent *e);
-
protected:
ScGuardedPtr<ScribusDoc> m_doc;
+
+ virtual void changeEvent(QEvent *e);
public slots:
Modified: trunk/Scribus/scribus/ui/propertywidget_optmargins.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_optmargins.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_optmargins.cpp (original)
+++ trunk/Scribus/scribus/ui/propertywidget_optmargins.cpp Mon Mar 19 00:25:48 2012
@@ -5,14 +5,19 @@
for which a new license (GPL+exception) is in place.
*/
+#include "pageitem_table.h"
#include "propertywidget_optmargins.h"
-
+#include "scribus.h"
#include "scribusdoc.h"
+#include "selection.h"
#include "units.h"
#include "util_icon.h"
PropertyWidget_OptMargins::PropertyWidget_OptMargins(QWidget* parent) : QFrame(parent)
{
+ m_item = 0;
+ m_ScMW = 0;
+
setupUi(this);
setFrameStyle(QFrame::Box | QFrame::Plain);
@@ -22,15 +27,179 @@
languageChange();
}
+void PropertyWidget_OptMargins::setMainWindow(ScribusMainWindow* mw)
+{
+ m_ScMW = mw;
+
+ connect(m_ScMW, SIGNAL(AppModeChanged(int, int)), this, SLOT(handleAppModeChanged(int, int)));
+ connect(m_ScMW, SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
+}
+
void PropertyWidget_OptMargins::setDoc(ScribusDoc *d)
{
- if(d == (ScribusDoc*) m_doc)
- return;
+ if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning()))
+ return;
+
+ if (m_doc)
+ {
+ disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+ disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged()));
+ }
m_doc = d;
+ m_item = NULL;
if (m_doc.isNull())
- return;
+ {
+ disconnectSignals();
+ return;
+ }
+
+ connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+ connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged()));
+}
+
+void PropertyWidget_OptMargins::setCurrentItem(PageItem *item)
+{
+ if (!m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+ //CB We shouldnt really need to process this if our item is the same one
+ //maybe we do if the item has been changed by scripter.. but that should probably
+ //set some status if so.
+ //FIXME: This wont work until when a canvas deselect happens, m_item must be NULL.
+ //if (m_item == i)
+ // return;
+
+ if (item && m_doc.isNull())
+ setDoc(item->doc());
+
+ m_item = item;
+
+ disconnectSignals();
+ configureWidgets();
+
+ if (m_item)
+ {
+ if (m_item->asTextFrame() || m_item->asPathText())
+ {
+ ParagraphStyle parStyle = m_item->itemText.defaultStyle();
+ if (m_doc->appMode == modeEdit)
+ m_item->currentTextProps(parStyle);
+ displayOpticalMargins(parStyle);
+ }
+
+ connectSignals();
+ }
+}
+
+void PropertyWidget_OptMargins::connectSignals()
+{
+ connect(optMarginRadioNone , SIGNAL(clicked()), this, SLOT(handleOpticalMargins()) );
+ connect(optMarginRadioBoth , SIGNAL(clicked()), this, SLOT(handleOpticalMargins()) );
+ connect(optMarginRadioLeft , SIGNAL(clicked()), this, SLOT(handleOpticalMargins()) );
+ connect(optMarginRadioRight , SIGNAL(clicked()), this, SLOT(handleOpticalMargins()) );
+ connect(optMarginResetButton, SIGNAL(clicked()), this, SLOT(resetOpticalMargins()) );
+}
+
+void PropertyWidget_OptMargins::disconnectSignals()
+{
+ disconnect(optMarginRadioNone , SIGNAL(clicked()), this, SLOT(handleOpticalMargins()) );
+ disconnect(optMarginRadioBoth , SIGNAL(clicked()), this, SLOT(handleOpticalMargins()) );
+ disconnect(optMarginRadioLeft , SIGNAL(clicked()), this, SLOT(handleOpticalMargins()) );
+ disconnect(optMarginRadioRight , SIGNAL(clicked()), this, SLOT(handleOpticalMargins()) );
+ disconnect(optMarginResetButton, SIGNAL(clicked()), this, SLOT(resetOpticalMargins()) );
+}
+
+void PropertyWidget_OptMargins::configureWidgets(void)
+{
+ bool enabled = false;
+ if (m_item && m_doc)
+ {
+ PageItem_TextFrame* textItem = m_item->asTextFrame();
+ if (m_doc->appMode == modeEditTable)
+ textItem = m_item->asTable()->activeCell().textFrame();
+
+ enabled = (m_item->isPathText() || (textItem != NULL));
+ enabled &= (m_doc->m_Selection->count() == 1);
+ }
+ setEnabled(enabled);
+}
+
+void PropertyWidget_OptMargins::handleAppModeChanged(int oldMode, int mode)
+{
+ if (oldMode == modeEditTable || mode == modeEditTable)
+ {
+ setCurrentItem(m_item);
+ }
+}
+
+void PropertyWidget_OptMargins::handleSelectionChanged()
+{
+ if (!m_doc || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+
+ PageItem* currItem = currentItemFromSelection();
+ setCurrentItem(currItem);
+ updateGeometry();
+ repaint();
+}
+
+void PropertyWidget_OptMargins::displayOpticalMargins(const ParagraphStyle & pStyle)
+{
+ ParagraphStyle::OpticalMarginType omt(static_cast<ParagraphStyle::OpticalMarginType>(pStyle.opticalMargins()));
+ bool blocked = optMarginRadioBoth->blockSignals(true);
+ if (omt == ParagraphStyle::OM_Default)
+ optMarginRadioBoth->setChecked(true);
+ else if (omt == ParagraphStyle::OM_LeftHangingPunct)
+ optMarginRadioLeft->setChecked(true);
+ else if (omt == ParagraphStyle::OM_RightHangingPunct)
+ optMarginRadioRight->setChecked(true);
+ else
+ optMarginRadioNone->setChecked(true);
+ optMarginRadioBoth->blockSignals(blocked);
+}
+
+void PropertyWidget_OptMargins::updateStyle(const ParagraphStyle& newCurrent)
+{
+ displayOpticalMargins(newCurrent);
+}
+
+void PropertyWidget_OptMargins::handleOpticalMargins()
+{
+ if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+ int omt(ParagraphStyle::OM_None);
+ if (optMarginRadioBoth->isChecked())
+ omt = ParagraphStyle::OM_Default;
+ else if (optMarginRadioLeft->isChecked())
+ omt = ParagraphStyle::OM_LeftHangingPunct;
+ else if (optMarginRadioRight->isChecked())
+ omt = ParagraphStyle::OM_RightHangingPunct;
+
+ PageItem *item = m_item;
+ if (m_doc->appMode == modeEditTable)
+ item = m_item->asTable()->activeCell().textFrame();
+ if (item != NULL)
+ {
+ Selection tempSelection(this, false);
+ tempSelection.addItem(item, true);
+ m_doc->itemSelection_SetOpticalMargins(omt, &tempSelection);
+ }
+}
+
+void PropertyWidget_OptMargins::resetOpticalMargins()
+{
+ if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+ PageItem *item = m_item;
+ if (m_doc->appMode == modeEditTable)
+ item = m_item->asTable()->activeCell().textFrame();
+ if (item != NULL)
+ {
+ Selection tempSelection(this, false);
+ tempSelection.addItem(item, true);
+ m_doc->itemSelection_resetOpticalMargins(&tempSelection);
+ }
}
void PropertyWidget_OptMargins::changeEvent(QEvent *e)
Modified: trunk/Scribus/scribus/ui/propertywidget_optmargins.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_optmargins.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_optmargins.h (original)
+++ trunk/Scribus/scribus/ui/propertywidget_optmargins.h Mon Mar 19 00:25:48 2012
@@ -9,11 +9,14 @@
#include "ui_propertywidget_optmarginsbase.h"
-#include "scguardedptr.h"
+#include "propertywidgetbase.h"
+class ParagraphStyle;
class ScribusDoc;
+class ScribusMainWindow;
-class PropertyWidget_OptMargins : public QFrame, public Ui::PropertyWidget_OptMarginsBase
+class PropertyWidget_OptMargins : public QFrame, public Ui::PropertyWidget_OptMarginsBase,
+ public PropertyWidgetBase
{
Q_OBJECT
@@ -21,18 +24,36 @@
PropertyWidget_OptMargins(QWidget* parent);
~PropertyWidget_OptMargins() {};
+ void updateStyle(const ParagraphStyle& newCurrent);
+
+protected:
+ PageItem * m_item;
+ ScribusMainWindow* m_ScMW;
+
+ void connectSignals();
+ void disconnectSignals();
+
+ void configureWidgets(void);
+ void setCurrentItem(PageItem *item);
+
virtual void changeEvent(QEvent *e);
-protected:
+public slots:
+ void setMainWindow(ScribusMainWindow *mw);
+ void setDoc(ScribusDoc *d);
- ScGuardedPtr<ScribusDoc> m_doc;
-
-public slots:
-
- void setDoc(ScribusDoc *d);
+ void handleAppModeChanged(int oldMode, int mode);
+ void handleSelectionChanged();
+ void handleUpdateRequest(int) {};
void languageChange();
void unitChange() {};
+
+ void displayOpticalMargins(const ParagraphStyle& pStyle);
+
+private slots:
+ void handleOpticalMargins();
+ void resetOpticalMargins();
};
#endif
Modified: trunk/Scribus/scribus/ui/propertywidget_orphans.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_orphans.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_orphans.cpp (original)
+++ trunk/Scribus/scribus/ui/propertywidget_orphans.cpp Mon Mar 19 00:25:48 2012
@@ -71,8 +71,8 @@
void PropertyWidget_Orphans::updateStyle(const ParagraphStyle& newCurrent)
{
disconnectSignals ();
- keepLinesStart->setValue (newCurrent.keepLinesStart());
- keepLinesEnd->setValue (newCurrent.keepLinesEnd());
+ keepLinesStart->setValue (newCurrent.keepLinesStart());
+ keepLinesEnd->setValue (newCurrent.keepLinesEnd());
keepTogether->setChecked (newCurrent.keepTogether());
keepWithNext->setChecked (newCurrent.keepWithNext());
connectSignals ();
Modified: trunk/Scribus/scribus/ui/propertywidget_orphans.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_orphans.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_orphans.h (original)
+++ trunk/Scribus/scribus/ui/propertywidget_orphans.h Mon Mar 19 00:25:48 2012
@@ -22,11 +22,12 @@
PropertyWidget_Orphans(QWidget* parent);
~PropertyWidget_Orphans() {};
+ void updateStyle(const ParagraphStyle& newCurrent);
+
+protected:
virtual void changeEvent(QEvent *e);
- void updateStyle(const ParagraphStyle& newCurrent);
public slots:
-
void languageChange();
void handleKeepLinesStart();
void handleKeepLinesEnd();
Modified: trunk/Scribus/scribus/ui/propertywidget_pathtext.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_pathtext.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_pathtext.cpp (original)
+++ trunk/Scribus/scribus/ui/propertywidget_pathtext.cpp Mon Mar 19 00:25:48 2012
@@ -8,11 +8,17 @@
#include "propertywidget_pathtext.h"
#include "scribusdoc.h"
+#include "scribus.h"
+#include "selection.h"
#include "units.h"
#include "util_icon.h"
PropertyWidget_PathText::PropertyWidget_PathText(QWidget* parent) : QFrame(parent)
{
+ m_ScMW = 0;
+ m_doc = 0;
+ m_unitRatio = 1.0;
+
setupUi(this);
setFrameStyle(QFrame::Box | QFrame::Plain);
@@ -28,15 +34,32 @@
languageChange();
}
+void PropertyWidget_PathText::setMainWindow(ScribusMainWindow* mw)
+{
+ m_ScMW = mw;
+
+ connect(m_ScMW, SIGNAL(UpdateRequest(int)), this , SLOT(handleUpdateRequest(int)));
+}
+
void PropertyWidget_PathText::setDoc(ScribusDoc *d)
{
if(d == (ScribusDoc*) m_doc)
return;
+ if (m_doc)
+ {
+ disconnect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+ disconnect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged()));
+ }
+
m_doc = d;
+ m_item = NULL;
if (m_doc.isNull())
- return;
+ {
+ disconnectSignals();
+ return;
+ }
m_unitRatio = m_doc->unitRatio();
m_unitIndex = m_doc->unitIndex();
@@ -47,6 +70,135 @@
distFromCurve->setMaximum( 300 );
distFromCurve->setMinimum( -300 );
distFromCurve->setSingleStep(10);
+
+ connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged()));
+ connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged()));
+}
+
+void PropertyWidget_PathText::setCurrentItem(PageItem *item)
+{
+ if (!m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+ //CB We shouldnt really need to process this if our item is the same one
+ //maybe we do if the item has been changed by scripter.. but that should probably
+ //set some status if so.
+ //FIXME: This wont work until when a canvas deselect happens, m_item must be NULL.
+ //if (m_item == i)
+ // return;
+
+ if (item && m_doc.isNull())
+ setDoc(item->doc());
+
+ m_item = item;
+
+ disconnectSignals();
+ configureWidgets();
+
+ if (m_item)
+ {
+ if (m_item->asPathText())
+ {
+ pathTextType->setCurrentIndex(m_item->textPathType);
+ flippedPathText->setChecked(m_item->textPathFlipped);
+ showCurveCheckBox->setChecked(m_item->PoShow);
+ distFromCurve->setValue(m_item->BaseOffs * -1);
+ startOffset->setValue(m_item->textToFrameDistLeft());
+ }
+ connectSignals();
+ }
+}
+
+void PropertyWidget_PathText::connectSignals()
+{
+ connect(showCurveCheckBox, SIGNAL(clicked()) , this, SLOT(handlePathLine()));
+ connect(pathTextType , SIGNAL(activated(int)), this, SLOT(handlePathType()));
+ connect(flippedPathText , SIGNAL(clicked()) , this, SLOT(handlePathFlip()));
+ connect(startOffset , SIGNAL(valueChanged(double)), this, SLOT(handlePathDist()));
+ connect(distFromCurve , SIGNAL(valueChanged(double)), this, SLOT(handlePathOffs()));
+}
+
+void PropertyWidget_PathText::disconnectSignals()
+{
+ disconnect(showCurveCheckBox, SIGNAL(clicked()) , this, SLOT(handlePathLine()));
+ disconnect(pathTextType , SIGNAL(activated(int)), this, SLOT(handlePathType()));
+ disconnect(flippedPathText , SIGNAL(clicked()) , this, SLOT(handlePathFlip()));
+ disconnect(startOffset , SIGNAL(valueChanged(double)), this, SLOT(handlePathDist()));
+ disconnect(distFromCurve , SIGNAL(valueChanged(double)), this, SLOT(handlePathOffs()));
+}
+
+void PropertyWidget_PathText::configureWidgets(void)
+{
+ bool enabled = false;
+ if (m_item && m_doc)
+ {
+ enabled = m_item->isPathText();
+ enabled &= (m_doc->m_Selection->count() == 1);
+ }
+ setEnabled(enabled);
+}
+
+void PropertyWidget_PathText::handleSelectionChanged()
+{
+ if (!m_doc || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+
+ PageItem* currItem = currentItemFromSelection();
+ setCurrentItem(currItem);
+ updateGeometry();
+ repaint();
+}
+
+void PropertyWidget_PathText::handleUpdateRequest(int /*updateFlags*/)
+{
+ // Nothing to do
+}
+
+void PropertyWidget_PathText::handlePathDist()
+{
+ if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+ m_item->setTextToFrameDistLeft(startOffset->value());
+ m_doc->AdjustItemSize(m_item);
+ m_item->updatePolyClip();
+ m_item->update();
+ m_doc->regionsChanged()->update(QRect());
+}
+
+void PropertyWidget_PathText::handlePathFlip()
+{
+ if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+ m_item->textPathFlipped = flippedPathText->isChecked();
+ m_item->updatePolyClip();
+ m_item->update();
+ m_doc->regionsChanged()->update(QRect());
+}
+
+void PropertyWidget_PathText::handlePathLine()
+{
+ if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+ m_item->PoShow = showCurveCheckBox->isChecked();
+ m_item->update();
+}
+
+void PropertyWidget_PathText::handlePathOffs()
+{
+ if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+ m_item->BaseOffs = -distFromCurve->value();
+ m_doc->AdjustItemSize(m_item);
+ m_item->updatePolyClip();
+ m_item->update();
+}
+
+void PropertyWidget_PathText::handlePathType()
+{
+ if (!m_doc || !m_item || !m_ScMW || m_ScMW->scriptIsRunning())
+ return;
+ m_item->textPathType = pathTextType->currentIndex();
+ m_item->update();
+ m_doc->regionsChanged()->update(QRect());
}
void PropertyWidget_PathText::changeEvent(QEvent *e)
@@ -57,18 +209,6 @@
return;
}
QWidget::changeEvent(e);
-}
-
-void PropertyWidget_PathText::unitChange()
-{
- if (!m_doc)
- return;
-
- m_unitRatio = m_doc->unitRatio();
- m_unitIndex = m_doc->unitIndex();
-
- startOffset->setNewUnit( m_unitIndex );
- distFromCurve->setNewUnit( m_unitIndex );
}
void PropertyWidget_PathText::languageChange()
@@ -89,4 +229,16 @@
QString ptSuffix = tr(" pt");
startOffset->setSuffix(ptSuffix);
distFromCurve->setSuffix(ptSuffix);
-}
+}
+
+void PropertyWidget_PathText::unitChange()
+{
+ if (!m_doc)
+ return;
+
+ m_unitRatio = m_doc->unitRatio();
+ m_unitIndex = m_doc->unitIndex();
+
+ startOffset->setNewUnit( m_unitIndex );
+ distFromCurve->setNewUnit( m_unitIndex );
+}
Modified: trunk/Scribus/scribus/ui/propertywidget_pathtext.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_pathtext.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_pathtext.h (original)
+++ trunk/Scribus/scribus/ui/propertywidget_pathtext.h Mon Mar 19 00:25:48 2012
@@ -9,11 +9,13 @@
#include "ui_propertywidget_pathtextbase.h"
-#include "scguardedptr.h"
+#include "propertywidgetbase.h"
class ScribusDoc;
+class ScribusMainWindow;
-class PropertyWidget_PathText : public QFrame, public Ui::PropertyWidget_PathTextBase
+class PropertyWidget_PathText : public QFrame, public Ui::PropertyWidget_PathTextBase,
+ public PropertyWidgetBase
{
Q_OBJECT
@@ -21,21 +23,37 @@
PropertyWidget_PathText(QWidget* parent);
~PropertyWidget_PathText() {};
- virtual void changeEvent(QEvent *e);
-
protected:
+ PageItem * m_item;
+ ScribusMainWindow* m_ScMW;
double m_unitRatio;
int m_unitIndex;
- ScGuardedPtr<ScribusDoc> m_doc;
+ void connectSignals();
+ void disconnectSignals();
+
+ void configureWidgets(void);
+ void setCurrentItem(PageItem *item);
+
+ virtual void changeEvent(QEvent *e);
public slots:
+ void setMainWindow(ScribusMainWindow *mw);
+ void setDoc(ScribusDoc *d);
- void setDoc(ScribusDoc *d);
+ void handleSelectionChanged();
+ void handleUpdateRequest(int);
void languageChange();
void unitChange();
+
+private slots:
+ void handlePathType();
+ void handlePathFlip();
+ void handlePathLine();
+ void handlePathDist();
+ void handlePathOffs();
};
#endif
Modified: trunk/Scribus/scribus/ui/propertywidget_textcolor.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_textcolor.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_textcolor.cpp (original)
+++ trunk/Scribus/scribus/ui/propertywidget_textcolor.cpp Mon Mar 19 00:25:48 2012
@@ -97,7 +97,7 @@
{
m_item = item;
disconnectSignals();
- enableFromSelection();
+ configureWidgets();
if (m_item)
{
PageItem_TextFrame *i2;
@@ -157,7 +157,7 @@
disconnect(textEffects->StrikeVal->LWidth , SIGNAL(valueChanged(double)), this, SLOT(handleStrikeThru()));
}
-void PropertyWidget_TextColor::enableFromSelection(void)
+void PropertyWidget_TextColor::configureWidgets(void)
{
bool enabled = false;
if (m_item && m_doc)
Modified: trunk/Scribus/scribus/ui/propertywidget_textcolor.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_textcolor.h
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_textcolor.h (original)
+++ trunk/Scribus/scribus/ui/propertywidget_textcolor.h Mon Mar 19 00:25:48 2012
@@ -23,19 +23,19 @@
PropertyWidget_TextColor(QWidget* parent);
~PropertyWidget_TextColor() {};
- virtual void changeEvent(QEvent *e);
-
void updateColorList();
protected:
+ PageItem * m_item;
+ ScribusMainWindow* m_ScMW;
+
void connectSignals();
void disconnectSignals();
- PageItem * m_item;
- ScribusMainWindow* m_ScMW;
+ void configureWidgets(void);
+ void setCurrentItem(PageItem *i);
- void enableFromSelection(void);
- void setCurrentItem(PageItem *i);
+ virtual void changeEvent(QEvent *e);
public slots:
void setMainWindow(ScribusMainWindow *mw);
Modified: trunk/Scribus/scribus/ui/propertywidget_textcolorbase.ui
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17388&path=/trunk/Scribus/scribus/ui/propertywidget_textcolorbase.ui
==============================================================================
--- trunk/Scribus/scribus/ui/propertywidget_textcolorbase.ui (original)
+++ trunk/Scribus/scribus/ui/propertywidget_textcolorbase.ui Mon Mar 19 00:25:48 2012
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>210</width>
- <height>88</height>
+ <height>94</height>
</rect>
</property>
<property name="windowTitle">
@@ -45,7 +45,14 @@
</widget>
</item>
<item>
- <widget class="ColorCombo" name="strokeColor"/>
+ <widget class="ColorCombo" name="strokeColor">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
</item>
<item>
<widget class="QLabel" name="strokeShadeLabel">
@@ -63,19 +70,6 @@
<string/>
</property>
</widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <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>
@@ -95,7 +89,14 @@
</widget>
</item>
<item>
- <widget class="ColorCombo" name="fillColor"/>
+ <widget class="ColorCombo" name="fillColor">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
</item>
<item>
<widget class="QLabel" name="fillShadeLabel">
@@ -114,8 +115,15 @@
</property>
</widget>
</item>
+ </layout>
+ </item>
+ <item row="2" column="0">
+ <layout class="QHBoxLayout" name="effectsLayout">
+ <property name="spacing">
+ <number>3</number>
+ </property>
<item>
- <spacer name="horizontalSpacer_2">
+ <spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@@ -127,13 +135,6 @@
</property>
</spacer>
</item>
- </layout>
- </item>
- <item row="2" column="0">
- <layout class="QHBoxLayout" name="effectsLayout">
- <property name="spacing">
- <number>3</number>
- </property>
<item>
<widget class="StyleSelect" name="textEffects" native="true"/>
</item>
@@ -152,19 +153,6 @@
<bool>true</bool>
</property>
</widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_3">
- <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>
More information about the scribus-commit
mailing list