View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0016988 | Scribus | User Interface | public | 2023-08-01 20:06 | 2023-12-24 10:00 |
Reporter | nitramr | Assigned To | nitramr | ||
Priority | normal | Severity | feature | Reproducibility | N/A |
Status | closed | Resolution | fixed | ||
Platform | Desktop PC | OS | Ubuntu | OS Version | 23.04 64-bit |
Product Version | 1.7.0.svn | ||||
Target Version | 1.7.0 | Fixed in Version | 1.7.0.svn | ||
Summary | 0016988: Implement IndigoUI collapsible section container as UI widget | ||||
Description | I replaced the ScTreeWidget of property panel and content panel with a new UI widget. Patch Notes: - add new UI container widget "SectionContainer" - add two new icons "action-chevron-up.svg" & "action-chevron-down.svg" for SectionContainer class - font properties of "propertiespalette_text.cpp" has been moved into separate class "propertywidget_text.cpp" SectionContainer: - widget is a layout container that has a collapsible and expandable body section - widget header supports widget plugins, like buttons and combo boxes - widget supports application QPalette colors | ||||
Tags | No tags attached. | ||||
Patch | No | ||||
|
indigouicontainer_23-08-01_01.patch (101,624 bytes)
Index: resources/iconsets/1_7_0/16/action-chevron-down.svg =================================================================== Kann nicht anzeigen: Dateityp ist als binär angegeben. svn:mime-type = image/svg+xml Property changes on: resources/iconsets/1_7_0/16/action-chevron-down.svg ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -image/svg+xml \ No newline at end of property Index: resources/iconsets/1_7_0/16/action-chevron-up.svg =================================================================== Kann nicht anzeigen: Dateityp ist als binär angegeben. svn:mime-type = image/svg+xml Property changes on: resources/iconsets/1_7_0/16/action-chevron-up.svg ___________________________________________________________________ Deleted: svn:mime-type ## -1 +0,0 ## -image/svg+xml \ No newline at end of property Index: resources/iconsets/1_7_0/1_7_0.xml =================================================================== --- resources/iconsets/1_7_0/1_7_0.xml (Revision 25566) +++ resources/iconsets/1_7_0/1_7_0.xml (Arbeitskopie) @@ -139,6 +139,8 @@ <icon id="u_group.png" file="16/object-group.svg" /><!-- Outliner --> <icon id="u_undo16.png" file="16/action-undo.svg" /><!-- Barcode --> <icon id="ungroup.png" file="16/object-ungroup.svg" /> + <icon id="collapse" file="16/action-chevron-down.svg" /> + <icon id="expand" file="16/action-chevron-up.svg" /> <!-- Alerts --> <icon onLight="#E54545" onDark="#FF6666" id="22/dialog-error.png" file="16/alert-error.svg" /> Index: scribus/CMakeLists_Sources.txt =================================================================== --- scribus/CMakeLists_Sources.txt (Revision 25566) +++ scribus/CMakeLists_Sources.txt (Arbeitskopie) @@ -445,6 +445,7 @@ ui/propertywidget_optmargins.cpp ui/propertywidget_orphans.cpp ui/propertywidget_pathtext.cpp + ui/propertywidget_text.cpp ui/propertywidget_textcolor.cpp ui/propertywidget_fontfeatures.cpp ui/propertywidgetbase.cpp @@ -538,6 +539,7 @@ ui/weldedit.cpp ui/docks/dock_centralwidget.cpp ui/docks/dock_panelbase.cpp + ui/widgets/section_container.cpp ${SCRIBUS_OSG_SRC} ${SCRIBUS_GMAGICK_SRC} ${SCRIBUS_JPEGXL_SRC} Index: scribus/ui/propertiespalette.cpp =================================================================== --- scribus/ui/propertiespalette.cpp (Revision 25566) +++ scribus/ui/propertiespalette.cpp (Arbeitskopie) @@ -33,6 +33,7 @@ #include "appmodehelper.h" #include "appmodes.h" #include "cpalette.h" +#include "iconmanager.h" #include "pageitem_table.h" #include "propertiespalette_line.h" #include "propertiespalette_shadow.h" @@ -57,46 +58,76 @@ f.setPointSize(f.pointSize()-1); setFont(f); - TabStack = new ScTreeWidget( this ); -// Uncomment this line if the new behaviour makes any trouble. -// TabStack->setToolBoxMode(true); + IconManager &iconManager = IconManager::instance(); + // XZY xyzPal = new PropertiesPalette_XYZ( this ); - idXYZItem = TabStack->addItem( xyzPal, "X, Y, &Z" ); + scXYZ = new SectionContainer("X, Y, &Z"); + scXYZ->addPage(xyzPal); + scXYZ->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + // Drop Shadow shadowPal = new PropertiesPalette_Shadow( this ); - idShadowItem = TabStack->addItem( shadowPal, "Drop Shadow" ); + scShadow = new SectionContainer("Drop Shadow"); + scShadow->addPage(shadowPal); + scShadow->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scShadow->setIsCollapsed(true); + // Shape shapePal = new PropertiesPalette_Shape( this ); - idShapeItem = TabStack->addItem( shapePal, "&Shape" ); + scShape = new SectionContainer("&Shape"); + scShape->addPage(shapePal); + scShape->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scShape->setIsCollapsed(true); + // Line linePal = new PropertiesPalette_Line(this); - idLineItem=TabStack->addItem( linePal, "&Line" ); + scLine = new SectionContainer("&Line"); + scLine->addPage(linePal); + scLine->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scLine->setIsCollapsed(true); + // Color colorPalette = new ColorPalette(this); - idColorsItem = TabStack->addItem(colorPalette, "&Colors" ); + scColor = new SectionContainer("&Colors"); + scColor->addPage(colorPalette); + scColor->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scColor->setIsCollapsed(true); + // Transparency transparencyPalette = new TransparencyPalette(this); - idTransparencyItem = TabStack->addItem(transparencyPalette, "&Transparency" ); + scTransparency = new SectionContainer("&Transparency"); + scTransparency->addPage(transparencyPalette); + scTransparency->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scTransparency->setIsCollapsed(true); - setWidget( TabStack ); + // Layout stack + QVBoxLayout * lyt = new QVBoxLayout(); + lyt->setContentsMargins(0, 0, 0, 0); + lyt->setSpacing(0); + lyt->addWidget(scXYZ); + lyt->addWidget(scShadow); + lyt->addWidget(scShape); + lyt->addWidget(scLine); + lyt->addWidget(scColor); + lyt->addWidget(scTransparency); + lyt->addStretch(1); + QWidget * wdg = new QWidget(); + wdg->setLayout(lyt); + setWidget(wdg); + languageChange(); + enablePalettes(false); - connect(linePal, SIGNAL(lineModeChanged(int)), this, SLOT(NewLineMode(int))); - connect(TabStack, SIGNAL(currentChanged2(int)), this, SLOT(SelTab(int))); - - connect(colorPalette, SIGNAL(NewSpecial(double,double,double,double,double,double,double,double,double,double)), this, SLOT(NewSpGradient(double,double,double,double,double,double,double,double,double,double))); + connect(linePal, SIGNAL(lineModeChanged(int)), this, SLOT(newLineMode(int))); + connect(colorPalette, SIGNAL(NewSpecial(double,double,double,double,double,double,double,double,double,double)), this, SLOT(newSpGradient(double,double,double,double,double,double,double,double,double,double))); connect(colorPalette, SIGNAL(editGradient(int)), this, SLOT(toggleGradientEdit(int))); - connect(transparencyPalette, SIGNAL(NewSpecial(double,double,double,double,double,double,double,double,double,double)), this, SLOT(NewSpGradientM(double,double,double,double,double,double,double,double))); + connect(transparencyPalette, SIGNAL(NewSpecial(double,double,double,double,double,double,double,double,double,double)), this, SLOT(newSpGradientM(double,double,double,double,double,double,double,double))); connect(transparencyPalette, SIGNAL(editGradient()), this, SLOT(toggleGradientEditM())); m_haveItem = false; - for (int i = 1; i < 10; ++i) - TabStack->setItemEnabled(i, false); - TabStack->setCurrentIndex(0); - TabStack->widget(0)->setEnabled(false); - TabStack->setItemEnabled(0, false); + } void PropertiesPalette::closeEvent(QCloseEvent *closeEvent) @@ -136,39 +167,6 @@ connect(m_ScMW->appModeHelper, SIGNAL(AppModeChanged(int,int)), this, SLOT(AppModeChanged())); } -void PropertiesPalette::SelTab(int t) -{ - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - - if (!TabStack->widget(t)->isVisible()) - return; - - bool focusNowSet = false; - foreach (QObject *o, TabStack->widget(t)->children()) - { - // Layouts, boxes etc aren't widgets at all - // so let's skip them silently... - QWidget *w = qobject_cast<QWidget*>(o); - if (!w) - continue; - - QWidget *i = TabStack->widget(t); - while ((i = i->nextInFocusChain()) != TabStack->widget(t)) - { - if (((i->focusPolicy() & Qt::TabFocus) == Qt::TabFocus) && !i->focusProxy() && i->isEnabled()) - { - focusNowSet = true; - i->setFocus(); - break; - } - } - - if (focusNowSet) - break; - } -} - void PropertiesPalette::setDoc(ScribusDoc *d) { if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) @@ -235,10 +233,7 @@ transparencyPalette->setDocument(nullptr); m_haveItem = false; - for (int ws = 1; ws < 10; ++ws) - TabStack->setItemEnabled(ws, false); - TabStack->widget(0)->setEnabled(false); - TabStack->setItemEnabled(idXYZItem, false); + enablePalettes(false); } void PropertiesPalette::unsetItem() @@ -266,6 +261,16 @@ return nullptr; } +void PropertiesPalette::enablePalettes(bool enable) +{ + scXYZ->setEnabled(enable); + scShape->setEnabled(enable); + scLine->setEnabled(enable); + scColor->setEnabled(enable); + scTransparency->setEnabled(enable); + scShadow->setEnabled(enable); +} + void PropertiesPalette::AppModeChanged() { if (!m_ScMW || m_ScMW->scriptIsRunning()) @@ -300,13 +305,10 @@ return; } - int oldTabIndex = TabStack->currentIndex(); - if (!m_doc) setDoc(item->doc()); - disconnect(TabStack, SIGNAL(currentChanged2(int)) , this, SLOT(SelTab(int))); - disconnect(linePal , SIGNAL(lineModeChanged(int)), this, SLOT(NewLineMode(int))); + disconnect(linePal , SIGNAL(lineModeChanged(int)), this, SLOT(newLineMode(int))); m_haveItem = false; m_item = item; @@ -315,7 +317,7 @@ setTextFlowMode(m_item->textFlowMode()); - connect(linePal , SIGNAL(lineModeChanged(int)), this, SLOT(NewLineMode(int))); + connect(linePal , SIGNAL(lineModeChanged(int)), this, SLOT(newLineMode(int))); //CB replaces old emits from PageItem::emitAllToGUI() setLocked(item->locked()); @@ -322,23 +324,17 @@ if ((m_item->isGroup()) && (!m_item->isSingleSel)) { - TabStack->setItemEnabled(idXYZItem, true); - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, false); - TabStack->setItemEnabled(idColorsItem, false); - TabStack->setItemEnabled(idTransparencyItem, true); + scXYZ->setEnabled(true); + scShadow->setEnabled(true); + scShape->setEnabled(true); + scLine->setEnabled(false); + scColor->setEnabled(false); + scTransparency->setEnabled(true); + } m_haveItem = true; - if (oldTabIndex != TabStack->currentIndex()) - { - //Must be called only when necessary : cause focus problem - //in spinboxes when processing valueChanged() signals - SelTab(TabStack->currentIndex()); - } - if (!sender() || (m_doc->appMode == modeEditTable)) { xyzPal->handleSelectionChanged(); @@ -350,23 +346,22 @@ if (m_item->isOSGFrame()) { - TabStack->setItemEnabled(idXYZItem, true); - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, false); - TabStack->setItemEnabled(idColorsItem, true); - TabStack->setItemEnabled(idTransparencyItem, false); + scXYZ->setEnabled(true); + scShadow->setEnabled(true); + scShape->setEnabled(true); + scLine->setEnabled(false); + scColor->setEnabled(true); + scTransparency->setEnabled(false); } if (m_item->asSymbol()) { - TabStack->setItemEnabled(idXYZItem, true); - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, false); - TabStack->setItemEnabled(idLineItem, false); - TabStack->setItemEnabled(idColorsItem, false); - TabStack->setItemEnabled(idTransparencyItem, false); + scXYZ->setEnabled(true); + scShadow->setEnabled(true); + scShape->setEnabled(false); + scLine->setEnabled(false); + scColor->setEnabled(false); + scTransparency->setEnabled(false); } - connect(TabStack, SIGNAL(currentChanged2(int)), this, SLOT(SelTab(int))); } void PropertiesPalette::handleSelectionChanged() @@ -373,20 +368,17 @@ { if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning()) return; - int currentTab = TabStack->currentIndex(); - disconnect(TabStack, SIGNAL(currentChanged2(int)), this, SLOT(SelTab(int))); + enablePalettes(false); + PageItem* currItem = currentItemFromSelection(); if (m_doc->m_Selection->count() > 1) { - for (int ws = 1; ws < 10; ++ws) - TabStack->setItemEnabled(ws, false); - TabStack->widget(0)->setEnabled(true); - TabStack->setItemEnabled(idXYZItem, true); - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idLineItem, true); - TabStack->setItemEnabled(idColorsItem, true); - TabStack->setItemEnabled(idTransparencyItem, true); + scXYZ->setEnabled(true); + scShadow->setEnabled(true); + scLine->setEnabled(true); + scColor->setEnabled(true); + scTransparency->setEnabled(true); } else { @@ -393,19 +385,10 @@ int itemType = currItem ? (int) currItem->itemType() : -1; m_haveItem = (itemType != -1); -// int visID = TabStack->currentIndex(); - TabStack->widget(0)->setEnabled(true); - TabStack->setItemEnabled(idXYZItem, true); - TabStack->setItemEnabled(idColorsItem, true); - TabStack->setItemEnabled(idTransparencyItem, true); switch (itemType) { case -1: m_haveItem = false; - for (int ws = 1; ws < 10; ++ws) - TabStack->setItemEnabled(ws, false); - TabStack->widget(0)->setEnabled(false); - TabStack->setItemEnabled(idXYZItem, false); colorPalette->showGradient(0); break; case PageItem::ImageFrame: @@ -413,61 +396,42 @@ case PageItem::OSGFrame: if (currItem->isOSGFrame()) { - TabStack->setItemEnabled(idXYZItem, true); - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, false); - TabStack->setItemEnabled(idColorsItem, true); - TabStack->setItemEnabled(idTransparencyItem, false); + scXYZ->setEnabled(true); + scShadow->setEnabled(true); + scShape->setEnabled(true); + scColor->setEnabled(true); } else { - TabStack->setItemEnabled(idXYZItem, true); - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, true); + enablePalettes(true); } break; + case PageItem::Line: + scXYZ->setEnabled(true); + scShadow->setEnabled(true); + scLine->setEnabled(true); + scColor->setEnabled(true); + scTransparency->setEnabled(true); + break; case PageItem::Group: case PageItem::Symbol: case PageItem::Table: case PageItem::TextFrame: - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, true); - break; - case PageItem::Line: - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, false); - TabStack->setItemEnabled(idLineItem, true); - break; case PageItem::ItemType1: case PageItem::ItemType3: case PageItem::Polygon: case PageItem::RegularPolygon: case PageItem::Arc: - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, true); - break; case PageItem::PolyLine: case PageItem::Spiral: - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, true); - break; case PageItem::PathText: - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, true); + enablePalettes(true); break; } } - if (TabStack->isItemEnabled(currentTab) && (TabStack->currentIndex() != currentTab)) - TabStack->setCurrentIndex(currentTab); + updateGeometry(); update(); - connect(TabStack, SIGNAL(currentChanged2(int)), this, SLOT(SelTab(int))); if (currItem) { @@ -495,7 +459,7 @@ m_haveItem = tmp; } -void PropertiesPalette::NewLineMode(int mode) +void PropertiesPalette::newLineMode(int mode) { if (!m_ScMW || m_ScMW->scriptIsRunning()) return; @@ -517,7 +481,7 @@ } } -void PropertiesPalette::NewSpGradient(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk, double cx, double cy) +void PropertiesPalette::newSpGradient(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk, double cx, double cy) { if (!m_ScMW || m_ScMW->scriptIsRunning()) return; @@ -653,7 +618,7 @@ } } -void PropertiesPalette::NewSpGradientM(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk) +void PropertiesPalette::newSpGradientM(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk) { if (!m_ScMW || m_ScMW->scriptIsRunning()) return; @@ -742,12 +708,12 @@ { setWindowTitle( tr("Properties")); - TabStack->setItemText(idXYZItem, tr("X, Y, &Z")); - TabStack->setItemText(idShadowItem, tr("Drop Shadow")); - TabStack->setItemText(idShapeItem, tr("&Shape")); - TabStack->setItemText(idLineItem, tr("&Line")); - TabStack->setItemText(idColorsItem, tr("&Colors")); - TabStack->setItemText(idTransparencyItem, tr("&Transparency")); + scXYZ->setText(tr("X, Y, &Z")); + scShadow->setText(tr("Drop Shadow")); + scShape->setText(tr("&Shape")); + scLine->setText(tr("&Line")); + scColor->setText(tr("&Colors")); + scTransparency->setText(tr("&Transparency")); xyzPal->languageChange(); shadowPal->languageChange(); Index: scribus/ui/propertiespalette.h =================================================================== --- scribus/ui/propertiespalette.h (Revision 25566) +++ scribus/ui/propertiespalette.h (Arbeitskopie) @@ -31,6 +31,7 @@ #include "stylecombos.h" #include "units.h" #include "docks/dock_panelbase.h" +#include "widgets/section_container.h" class ColorCombo; class ColorPalette; @@ -80,6 +81,7 @@ private: PageItem* currentItemFromSelection(); + void enablePalettes(bool enable); public slots: void setMainWindow(ScribusMainWindow *mw); @@ -98,20 +100,25 @@ void setLocked(bool); private slots: - void SelTab(int t); - void NewLineMode(int mode); + void newLineMode(int mode); 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 newSpGradient(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk, double cx, double cy); void toggleGradientEdit(int); - void NewSpGradientM(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk); + void newSpGradientM(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk); void toggleGradientEditM(); void handleShapeEdit(); protected: - ScTreeWidget* TabStack {nullptr}; + SectionContainer * scXYZ {nullptr}; + SectionContainer * scShape {nullptr}; + SectionContainer * scLine {nullptr}; + SectionContainer * scColor {nullptr}; + SectionContainer * scTransparency {nullptr}; + SectionContainer * scShadow {nullptr}; + bool m_haveDoc {false}; bool m_haveItem {false}; double m_unitRatio {1.0}; @@ -121,15 +128,6 @@ UndoManager *undoManager {nullptr}; ScGuardedPtr<ScribusDoc> m_doc; - - int idXYZItem {0}; - int idShapeItem {0}; - int idTableItem {0}; - int idLineItem {0}; - int idColorsItem {0}; - int idTransparencyItem {0}; - int idGroupItem {0}; - int idShadowItem {0}; }; #endif Index: scribus/ui/propertiespalette_text.cpp =================================================================== --- scribus/ui/propertiespalette_text.cpp (Revision 25566) +++ scribus/ui/propertiespalette_text.cpp (Arbeitskopie) @@ -31,6 +31,7 @@ #include "propertywidget_orphans.h" #include "propertywidget_pareffect.h" #include "propertywidget_pathtext.h" +#include "propertywidget_text.h" #include "propertywidget_textcolor.h" #include "scribus.h" #include "scribusapp.h" @@ -38,69 +39,104 @@ #include "stylecombos.h" #include "undomanager.h" #include "langmgr.h" +#include "widgets/section_container.h" //using namespace std; PropertiesPalette_Text::PropertiesPalette_Text( QWidget* parent) : QWidget(parent) { - setupUi(this); - fontSize->setPrefix(""); - - iconSetChange(); + IconManager &iconManager = IconManager::instance(); - colorWidgets = new PropertyWidget_TextColor(textTree); - colorWidgetsItem = textTree->addItem( colorWidgets, tr("Color && Effects") ); + advancedWidgets = new PropertyWidget_Advanced(this); + scAdvanced = new SectionContainer(tr("Advanced Settings")); + scAdvanced->addPage(advancedWidgets); + scAdvanced->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scAdvanced->setIsCollapsed(true); - flopBox = new PropertyWidget_Flop(textTree); - flopItem = textTree->addItem( flopBox, tr("First Line Offset")); + distanceWidgets = new PropertyWidget_Distance(this); + scDistance = new SectionContainer(tr("Columns && Text Distances")); + scDistance->addPage(distanceWidgets); + scDistance->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scDistance->setIsCollapsed(true); - orphanBox = new PropertyWidget_Orphans(textTree); - orphanItem = textTree->addItem(orphanBox, tr("Orphans and Widows")); + flopBox = new PropertyWidget_Flop(this); + scFlop = new SectionContainer(tr("First Line Offset")); + scFlop->addPage(flopBox); + scFlop->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scFlop->setIsCollapsed(true); - parEffectWidgets = new PropertyWidget_ParEffect(textTree); - parEffectItem = textTree->addItem(parEffectWidgets, tr("Paragraph Effects")); + fontfeaturesWidget = new PropertyWidget_FontFeatures(this); + scFontFeatures = new SectionContainer(tr("Font Features")); + scFontFeatures->addPage(fontfeaturesWidget); + scFontFeatures->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scFontFeatures->setIsCollapsed(true); - distanceWidgets = new PropertyWidget_Distance(textTree); - distanceItem = textTree->addItem(distanceWidgets, tr("Columns && Text Distances")); + hyphenationWidget = new PropertyWidget_Hyphenation(this); + scHyphenation = new SectionContainer(tr("Hyphenation")); + scHyphenation->addPage(hyphenationWidget); + scHyphenation->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scHyphenation->setIsCollapsed(true); - //<< Optical Margins - optMargins = new PropertyWidget_OptMargins(textTree); - optMarginsItem = textTree->addItem(optMargins, tr("Optical Margins")); - //>> Optical Margins + optMargins = new PropertyWidget_OptMargins(this); + scOptMargins = new SectionContainer(tr("Optical Margins")); + scOptMargins->addPage(optMargins); + scOptMargins->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scOptMargins->setIsCollapsed(true); - hyphenationWidget = new PropertyWidget_Hyphenation(textTree); - hyphenationWidgetItem = textTree->addItem(hyphenationWidget, tr("Hyphenation")); + orphanBox = new PropertyWidget_Orphans(this); + scOrphans = new SectionContainer(tr("Orphans and Widows")); + scOrphans->addPage(orphanBox); + scOrphans->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scOrphans->setIsCollapsed(true); - //<<Advanced Settings - advancedWidgets = new PropertyWidget_Advanced(textTree); - advancedWidgetsItem = textTree->addItem(advancedWidgets, tr("Advanced Settings")); + parEffectWidgets = new PropertyWidget_ParEffect(this); + scParEffect = new SectionContainer(tr("Paragraph Effects")); + scParEffect->addPage(parEffectWidgets); + scParEffect->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scParEffect->setIsCollapsed(true); - //>>Advanced Settings - fontfeaturesWidget = new PropertyWidget_FontFeatures(textTree); - fontfeaturesWidgetItem = textTree->addItem(fontfeaturesWidget, tr("Font Features")); + pathTextWidgets = new PropertyWidget_PathText(this); + scPathText = new SectionContainer(tr("Path Text Properties")); + scPathText->addPage(pathTextWidgets); + scPathText->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scPathText->setIsCollapsed(true); - pathTextWidgets = new PropertyWidget_PathText(textTree); - pathTextItem = textTree->addItem(pathTextWidgets, tr("Path Text Properties")); + textWidgets = new PropertyWidget_Text(this); + scText = new SectionContainer(tr("Text")); + scText->addPage(textWidgets); + scText->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scText->setIsCollapsed(false); + colorWidgets = new PropertyWidget_TextColor(this); + scTextColor = new SectionContainer(tr("Color && Effects")); + scTextColor->addPage(colorWidgets); + scTextColor->setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); + scTextColor->setIsCollapsed(true); + + // Layout stack + QVBoxLayout * lyt = new QVBoxLayout(); + lyt->setContentsMargins(0, 0, 0, 0); + lyt->setSpacing(0); + lyt->addWidget(scText); + lyt->addWidget(scTextColor); + lyt->addWidget(scFlop); + lyt->addWidget(scOrphans); + lyt->addWidget(scParEffect); + lyt->addWidget(scDistance); + lyt->addWidget(scOptMargins); + lyt->addWidget(scHyphenation); + lyt->addWidget(scAdvanced); + lyt->addWidget(scFontFeatures); + lyt->addWidget(scPathText); + lyt->addStretch(1); + setLayout(lyt); + + iconSetChange(); languageChange(); - connect(lineSpacing , SIGNAL(valueChanged(double)), this, SLOT(handleLineSpacing())); - connect(fonts , SIGNAL(fontSelected(QString)), this, SLOT(handleTextFont(QString))); - connect(fontSize , SIGNAL(valueChanged(double)), this, SLOT(handleFontSize())); - connect(textAlignment , SIGNAL(State(int)) , this, SLOT(handleAlignment(int))); - connect(textDirection , SIGNAL(State(int)) , this, SLOT(handleDirection(int))); - connect(charStyleClear, SIGNAL(clicked()), this, SLOT(doClearCStyle())); - connect(paraStyleClear, SIGNAL(clicked()), this, SLOT(doClearPStyle())); - connect(flopBox->flopGroup, SIGNAL(idClicked(int)), this, SLOT(handleFirstLinePolicy(int))); - connect(lineSpacingModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(handleLineSpacingMode(int))); - connect(langCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changeLang(int))); - - connect(fontfeaturesWidget, SIGNAL(needsRelayout()), this, SLOT(updateTreeLayout())); - connect(parEffectWidgets, SIGNAL(needsRelayout()), this, SLOT(updateTreeLayout())); - connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange())); connect(ScQApp, SIGNAL(localeChanged()), this, SLOT(localeChange())); @@ -111,6 +147,7 @@ { m_ScMW = mw; + textWidgets->setMainWindow(mw); advancedWidgets->setMainWindow(mw); fontfeaturesWidget->setMainWindow(mw); colorWidgets->setMainWindow(mw); @@ -122,8 +159,6 @@ connect(m_ScMW, SIGNAL(UpdateRequest(int)) , this , SLOT(handleUpdateRequest(int))); - connect(paraStyleCombo, SIGNAL(newStyle(QString)), m_ScMW, SLOT(setNewParStyle(QString)), Qt::UniqueConnection); - connect(charStyleCombo, SIGNAL(newStyle(QString)), m_ScMW, SLOT(setNewCharStyle(QString)), Qt::UniqueConnection); } void PropertiesPalette_Text::setDoc(ScribusDoc *d) @@ -146,9 +181,7 @@ m_haveDoc = true; m_haveItem = false; - fontSize->setValues(0.5, 2048, 2, 1); - lineSpacing->setValues(1, 2048, 2, 1); - + textWidgets->setDoc(m_doc); advancedWidgets->setDoc(m_doc); fontfeaturesWidget->setDoc(m_doc); colorWidgets->setDoc(m_doc); @@ -160,10 +193,6 @@ orphanBox->setDoc(m_doc); pathTextWidgets->setDoc(m_doc); - fonts->rebuildList(m_doc); - paraStyleCombo->setDoc(m_doc); - charStyleCombo->setDoc(m_doc); - connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } @@ -181,9 +210,7 @@ m_doc = nullptr; m_item = nullptr; - paraStyleCombo->setDoc(nullptr); - charStyleCombo->setDoc(nullptr); - + textWidgets->setDoc(nullptr); advancedWidgets->setDoc(nullptr); fontfeaturesWidget->setDoc(nullptr); colorWidgets->setDoc(nullptr); @@ -195,8 +222,6 @@ parEffectWidgets->setDoc(nullptr); pathTextWidgets->setDoc(nullptr); - m_haveItem = false; - setEnabled(false); } @@ -272,21 +297,24 @@ // ColorWidget will handle its update itself /*if (updateFlags & reqColorsUpdate) updateColorList();*/ + + textWidgets->handleUpdateRequest(updateFlags); + if (updateFlags & reqCharStylesUpdate) { - charStyleCombo->updateStyleList(); +// charStyleCombo->updateStyleList(); parEffectWidgets->updateCharStyles(); } - if (updateFlags & reqParaStylesUpdate) - paraStyleCombo->updateStyleList(); - if (updateFlags & reqDefFontListUpdate) - fonts->rebuildList(nullptr); - if (updateFlags & reqDocFontListUpdate) - fonts->rebuildList(m_haveDoc ? m_doc : nullptr); +// if (updateFlags & reqParaStylesUpdate) +// paraStyleCombo->updateStyleList(); +// if (updateFlags & reqDefFontListUpdate) +// fonts->rebuildList(nullptr); +// if (updateFlags & reqDocFontListUpdate) +// fonts->rebuildList(m_haveDoc ? m_doc : nullptr); if (updateFlags & reqStyleComboDocUpdate) { - paraStyleCombo->setDoc(m_haveDoc ? m_doc : nullptr); - charStyleCombo->setDoc(m_haveDoc ? m_doc : nullptr); +// paraStyleCombo->setDoc(m_haveDoc ? m_doc : nullptr); +// charStyleCombo->setDoc(m_haveDoc ? m_doc : nullptr); parEffectWidgets->setDoc(m_haveDoc ? m_doc : nullptr); } } @@ -343,17 +371,7 @@ void PropertiesPalette_Text::iconSetChange() { - IconManager& iconManager = IconManager::instance(); - - fontSizeLabel->setPixmap(iconManager.loadPixmap("zeichen.png")); - lineSpacingLabel->setPixmap(iconManager.loadPixmap("linespacing2.png")); - textAlignmentLabel->setPixmap(iconManager.loadPixmap("22/text-align.png")); - langLabel->setPixmap(iconManager.loadPixmap("22/language.png")); - paraStyleLabel->setPixmap(iconManager.loadPixmap("22/paragraph-style.png")); - charStyleLabel->setPixmap(iconManager.loadPixmap("22/character-style.png")); - - paraStyleClear->setIcon(iconManager.loadPixmap("16/edit-clear.png")); - charStyleClear->setIcon(iconManager.loadPixmap("16/edit-clear.png")); + textWidgets->iconSetChange(); } void PropertiesPalette_Text::unitChange() @@ -371,6 +389,7 @@ optMargins->unitChange(); pathTextWidgets->unitChange(); parEffectWidgets->unitChange(); + textWidgets->unitChange(); m_haveItem = tmp; } @@ -377,9 +396,7 @@ void PropertiesPalette_Text::localeChange() { - const QLocale& l(LocaleManager::instance().userPreferredLocale()); - fontSize->setLocale(l); - lineSpacing->setLocale(l); + textWidgets->localeChange(); advancedWidgets->localeChange(); colorWidgets->localeChange(); distanceWidgets->localeChange(); @@ -387,76 +404,14 @@ pathTextWidgets->localeChange(); } -void PropertiesPalette_Text::handleLineSpacingMode(int id) -{ - if (!m_haveDoc || !m_haveItem) - return; - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_SetLineSpacingMode(id, &tempSelection); -// updateStyle(((m_doc->appMode == modeEdit) || (m_doc->appMode == modeEditTable)) ? m_item->currentStyle() : m_item->itemText.defaultStyle()); - m_doc->regionsChanged()->update(QRect()); -} - -void PropertiesPalette_Text::changeLang(int id) -{ - if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) - return; - QStringList languageList; - LanguageManager::instance()->fillInstalledStringList(&languageList); - QString abrv = LanguageManager::instance()->getAbbrevFromLang(languageList.value(id),false); - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_SetLanguage(abrv, &tempSelection); -} - -void PropertiesPalette_Text::showLineSpacing(double r) -{ - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - bool inEditMode = (m_doc->appMode == modeEdit || m_doc->appMode == modeEditTable); - bool tmp = m_haveItem; - m_haveItem = false; - lineSpacing->showValue(r); - const ParagraphStyle& curStyle(m_haveItem && inEditMode ? m_item->currentStyle() : m_item->itemText.defaultStyle()); - if (tmp) - { - setupLineSpacingSpinbox(curStyle.lineSpacingMode(), r); - lineSpacingModeCombo->setCurrentIndex(curStyle.lineSpacingMode()); - } - m_haveItem = tmp; -} - -void PropertiesPalette_Text::showFontFace(const QString& newFont) -{ - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - bool tmp = m_haveItem; - m_haveItem = false; - if (m_item != nullptr) - fonts->rebuildList(m_doc, m_item->isAnnotation()); - fonts->setCurrentFont(newFont); - m_haveItem = tmp; -} - void PropertiesPalette_Text::showFontSize(double s) { - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - fontSize->showValue(s / 10.0); + textWidgets->showFontSize(s); } void PropertiesPalette_Text::showLanguage(const QString& w) { - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - QStringList lang; - LanguageManager::instance()->fillInstalledStringList(&lang); - QString langName = LanguageManager::instance()->getLangFromAbbrev(w, true); - - bool sigBlocked = langCombo->blockSignals(true); - langCombo->setCurrentIndex(lang.indexOf(langName)); - langCombo->blockSignals(sigBlocked); + textWidgets->showLanguage(w); } void PropertiesPalette_Text::showFirstLinePolicy( FirstLineOffsetPolicy f ) @@ -471,29 +426,6 @@ flopBox->flopBaselineGrid->setChecked(true); } -void PropertiesPalette_Text::setupLineSpacingSpinbox(int mode, double value) -{ - bool blocked = lineSpacing->blockSignals(true); - if (mode > 0) - { - if (mode == 1) - lineSpacing->setSpecialValueText( tr( "Auto" ) ); - if (mode == 2) - lineSpacing->setSpecialValueText( tr( "Baseline" ) ); - lineSpacing->setMinimum(0); - lineSpacing->setValue(0); - lineSpacing->setEnabled(false); - } - else - { - lineSpacing->setSpecialValueText(""); - lineSpacing->setMinimum(1); - lineSpacing->setValue(value); - lineSpacing->setEnabled(true); - } - lineSpacing->blockSignals(blocked); -} - void PropertiesPalette_Text::updateCharStyle(const CharStyle& charStyle) { if (!m_ScMW || m_ScMW->scriptIsRunning()) @@ -503,10 +435,7 @@ fontfeaturesWidget->updateCharStyle(charStyle); colorWidgets->updateCharStyle(charStyle); hyphenationWidget->updateCharStyle(charStyle); - - showFontFace(charStyle.font().scName()); - showFontSize(charStyle.fontSize()); - showLanguage(charStyle.language()); + textWidgets->updateCharStyle(charStyle); } void PropertiesPalette_Text::updateStyle(const ParagraphStyle& newCurrent) @@ -514,8 +443,6 @@ if (!m_ScMW || m_ScMW->scriptIsRunning()) return; - const CharStyle& charStyle = newCurrent.charStyle(); - advancedWidgets->updateStyle(newCurrent); fontfeaturesWidget->updateStyle(newCurrent); colorWidgets->updateStyle(newCurrent); @@ -523,202 +450,36 @@ orphanBox->updateStyle (newCurrent); parEffectWidgets->updateStyle(newCurrent); hyphenationWidget->updateStyle(newCurrent); - - showFontFace(charStyle.font().scName()); - showFontSize(charStyle.fontSize()); - showLanguage(charStyle.language()); - - if (m_item) - { - QString defaultParStyle = m_item->itemText.defaultStyle().parent(); - if (defaultParStyle.isEmpty()) - defaultParStyle = CommonStrings::DefaultParagraphStyle; - paraStyleCombo->setDefaultStyle(defaultParStyle); - } - showParStyle(newCurrent.parent()); - - if (m_item) - { - QString defaultCharStyle; - if (!newCurrent.parent().isEmpty()) - { - const ParagraphStyle* paraStyle = m_doc->paragraphStyles().getPointer(newCurrent.parent()); - if (paraStyle) - defaultCharStyle = paraStyle->charStyle().parent(); - if (defaultCharStyle.isEmpty()) - defaultCharStyle = CommonStrings::DefaultCharacterStyle; - } - if (defaultCharStyle.isEmpty()) - defaultCharStyle = m_item->itemText.defaultStyle().charStyle().parent(); - if (defaultCharStyle.isEmpty()) - defaultCharStyle = CommonStrings::DefaultCharacterStyle; - charStyleCombo->setDefaultStyle(defaultCharStyle); - } - showCharStyle(charStyle.parent()); - - bool tmp = m_haveItem; - m_haveItem = false; - - setupLineSpacingSpinbox(newCurrent.lineSpacingMode(), newCurrent.lineSpacing()); - lineSpacingModeCombo->setCurrentIndex(newCurrent.lineSpacingMode()); - textAlignment->setStyle(newCurrent.alignment(), newCurrent.direction()); - textDirection->setStyle(newCurrent.direction()); - - m_haveItem = tmp; + textWidgets->updateStyle(newCurrent); } void PropertiesPalette_Text::updateCharStyles() { - charStyleCombo->updateStyleList(); + textWidgets->updateCharStyles(); parEffectWidgets->updateCharStyles(); } void PropertiesPalette_Text::updateParagraphStyles() { - paraStyleCombo->updateStyleList(); - charStyleCombo->updateStyleList(); + textWidgets->updateParagraphStyles(); parEffectWidgets->updateCharStyles(); } void PropertiesPalette_Text::updateTextStyles() { - paraStyleCombo->updateStyleList(); - charStyleCombo->updateStyleList(); + textWidgets->updateTextStyles(); } -void PropertiesPalette_Text::updateTreeLayout() -{ - textTree->doItemsLayout(); -} - void PropertiesPalette_Text::showAlignment(int e) { - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - bool tmp = m_haveItem; - m_haveItem = false; - textAlignment->setEnabled(true); - textAlignment->setStyle(e, textDirection->getStyle()); - m_haveItem = tmp; + textWidgets->showAlignment(e); } void PropertiesPalette_Text::showDirection(int e) { - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - bool tmp = m_haveItem; - m_haveItem = false; - textDirection->setEnabled(true); - textDirection->setStyle(e); - m_haveItem = tmp; + textWidgets->showDirection(e); } -void PropertiesPalette_Text::showCharStyle(const QString& name) -{ - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - bool blocked = charStyleCombo->blockSignals(true); - charStyleCombo->setStyle(name); - charStyleCombo->blockSignals(blocked); -} - -void PropertiesPalette_Text::showParStyle(const QString& name) -{ - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - bool blocked = paraStyleCombo->blockSignals(true); - paraStyleCombo->setStyle(name); - paraStyleCombo->blockSignals(blocked); -} - -void PropertiesPalette_Text::handleLineSpacing() -{ - if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) - return; - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_SetLineSpacing(lineSpacing->value(), &tempSelection); -} - -void PropertiesPalette_Text::handleFontSize() -{ - if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) - return; - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_SetFontSize(qRound(fontSize->value()*10.0), &tempSelection); -} - -void PropertiesPalette_Text::handleAlignment(int a) -{ - if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) - return; - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_SetAlignment(a, &tempSelection); - if (m_item->isPathText()) - pathTextWidgets->handleSelectionChanged(); -} - -void PropertiesPalette_Text::handleDirection(int d) -{ - if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) - return; - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_SetDirection(d, &tempSelection); - // If current text alignment is left or right, change it to match direction - if (d == ParagraphStyle::RTL && textAlignment->selectedId() == ParagraphStyle::LeftAligned) - { - m_doc->itemSelection_SetAlignment(ParagraphStyle::RightAligned, &tempSelection); - textAlignment->setTypeStyle(ParagraphStyle::RightAligned); - } - else if (d == ParagraphStyle::LTR && textAlignment->selectedId() == ParagraphStyle::RightAligned) - { - m_doc->itemSelection_SetAlignment(ParagraphStyle::LeftAligned, &tempSelection); - textAlignment->setTypeStyle(ParagraphStyle::LeftAligned); - } -} - -void PropertiesPalette_Text::handleTextFont(const QString& font) -{ - if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) - return; - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_SetFont(font, &tempSelection); -} - -void PropertiesPalette_Text::doClearCStyle() -{ - if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveDoc || !m_haveItem) - return; - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_EraseCharStyle(&tempSelection); -} - - -void PropertiesPalette_Text::doClearPStyle() -{ - if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveDoc || !m_haveItem) - return; - - UndoTransaction activeTransaction; - if (UndoManager::undoEnabled()) - activeTransaction = UndoManager::instance()->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::RemoveTextStyle, tr( "remove direct paragraph formatting" ), Um::IFont); - - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_ClearBulNumStrings(&tempSelection); - m_doc->itemSelection_EraseParagraphStyle(&tempSelection); - CharStyle emptyCStyle; - m_doc->itemSelection_SetCharStyle(emptyCStyle, &tempSelection); - - if (activeTransaction) - activeTransaction.commit(); -} - void PropertiesPalette_Text::updateColorList() { if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning()) @@ -739,35 +500,18 @@ void PropertiesPalette_Text::languageChange() { - retranslateUi(this); + scAdvanced->setText(tr("Advanced Settings")); + scDistance->setText(tr("Columns && Text Distances")); + scFlop->setText(tr("First Line Offset")); + scFontFeatures->setText(tr("Font Features")); + scHyphenation->setText(tr("Hyphenation")); + scOptMargins->setText(tr("Optical Margins")); + scOrphans->setText(tr("Orphans and Widows")); + scParEffect->setText(tr("Paragraph Effects")); + scPathText->setText(tr("Path Text Properties")); + scText->setText(tr("Text")); + scTextColor->setText(tr("Color && Effects")); - textTree->setItemText(colorWidgetsItem, tr("Color && Effects")); - textTree->setItemText(flopItem, tr("First Line Offset")); - textTree->setItemText(hyphenationWidgetItem, tr("Hyphenation")); - textTree->setItemText(orphanItem, tr("Orphans and Widows")); - textTree->setItemText(parEffectItem, tr("Paragraph Effects")); - textTree->setItemText(distanceItem, tr("Columns && Text Distances")); - textTree->setItemText(optMarginsItem, tr("Optical Margins")); - textTree->setItemText(advancedWidgetsItem, tr("Advanced Settings")); - textTree->setItemText(fontfeaturesWidgetItem, tr("Font Features")); - textTree->setItemText(pathTextItem, tr("Path Text Properties")); - - QSignalBlocker lineSpacingModeBlocker(lineSpacingModeCombo); - int oldLineSpacingMode = lineSpacingModeCombo->currentIndex(); - lineSpacingModeCombo->clear(); - lineSpacingModeCombo->addItem( tr("Fixed Linespacing")); - lineSpacingModeCombo->addItem( tr("Automatic Linespacing")); - lineSpacingModeCombo->addItem( tr("Align to Baseline Grid")); - lineSpacingModeCombo->setCurrentIndex(oldLineSpacingMode); - - QSignalBlocker langComboBlocker(langCombo); - QStringList languageList; - LanguageManager::instance()->fillInstalledStringList(&languageList); - int oldLang = langCombo->currentIndex(); - langCombo->clear(); - langCombo->addItems(languageList); - langCombo->setCurrentIndex(oldLang); - colorWidgets->languageChange(); flopBox->languageChange(); orphanBox->languageChange(); @@ -777,9 +521,7 @@ pathTextWidgets->languageChange(); fontfeaturesWidget->languageChange(); hyphenationWidget->languageChange(); - - textAlignment->languageChange(); - textDirection->languageChange(); + textWidgets->languageChange(); } void PropertiesPalette_Text::handleFirstLinePolicy(int radioFlop) Index: scribus/ui/propertiespalette_text.h =================================================================== --- scribus/ui/propertiespalette_text.h (Revision 25566) +++ scribus/ui/propertiespalette_text.h (Arbeitskopie) @@ -7,8 +7,6 @@ #ifndef PROPERTIESPALETTE_TEXT_H #define PROPERTIESPALETTE_TEXT_H -#include "ui_propertiespalette_textbase.h" - #include "scribusapi.h" #include "scrpalettebase.h" #include "scrspinbox.h" @@ -27,12 +25,14 @@ class PropertyWidget_OptMargins; class PropertyWidget_Orphans; class PropertyWidget_PathText; +class PropertyWidget_Text; class PropertyWidget_TextColor; +class SectionContainer; class ScribusDoc; class ScribusMainWindow; class Selection; -class SCRIBUS_API PropertiesPalette_Text : public QWidget, public Ui::PropertiesPalette_TextBase +class SCRIBUS_API PropertiesPalette_Text : public QWidget { Q_OBJECT @@ -76,43 +76,23 @@ void languageChange(); void unitChange(); void localeChange(); - void changeLang(int id); void showAlignment(int e); void showDirection(int e); - void showCharStyle(const QString& name); - void showFontFace(const QString&); void showFontSize(double s); void showLanguage(const QString& w); void showFirstLinePolicy(FirstLineOffsetPolicy); - void showLineSpacing(double r); - void showParStyle(const QString& name); - - void setupLineSpacingSpinbox(int mode, double value); - + /// update TB values: void updateCharStyle(const CharStyle& charStyle); - void updateStyle(const ParagraphStyle& newCurrent); - + void updateStyle(const ParagraphStyle& newCurrent); void updateCharStyles(); void updateParagraphStyles(); - void updateTextStyles(); - - void handleLineSpacingMode(int id); - void handleTextFont(const QString&); + void updateTextStyles(); - // update widget layout - void updateTreeLayout(); +private slots: -private slots: - void handleAlignment(int a); - void handleDirection(int d); void handleFirstLinePolicy(int); - void handleFontSize(); - void handleLineSpacing(); - - void doClearCStyle(); - void doClearPStyle(); protected: PropertyWidget_Advanced* advancedWidgets; @@ -124,18 +104,20 @@ PropertyWidget_Orphans* orphanBox; PropertyWidget_ParEffect* parEffectWidgets; PropertyWidget_PathText* pathTextWidgets; + PropertyWidget_Text* textWidgets; PropertyWidget_TextColor* colorWidgets; - int advancedWidgetsItem; - int colorWidgetsItem; - int distanceItem; - int flopItem; - int fontfeaturesWidgetItem; - int hyphenationWidgetItem; - int optMarginsItem; - int orphanItem; - int parEffectItem; - int pathTextItem; + SectionContainer * scAdvanced = {nullptr}; + SectionContainer * scDistance = {nullptr}; + SectionContainer * scFlop = {nullptr}; + SectionContainer * scFontFeatures = {nullptr}; + SectionContainer * scHyphenation = {nullptr}; + SectionContainer * scOptMargins = {nullptr}; + SectionContainer * scOrphans = {nullptr}; + SectionContainer * scParEffect = {nullptr}; + SectionContainer * scPathText = {nullptr}; + SectionContainer * scText = {nullptr}; + SectionContainer * scTextColor = {nullptr}; }; Index: scribus/ui/propertiespalette_textbase.ui =================================================================== --- scribus/ui/propertiespalette_textbase.ui (Revision 25566) +++ scribus/ui/propertiespalette_textbase.ui (nicht existent) @@ -1,370 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>PropertiesPalette_TextBase</class> - <widget class="QWidget" name="PropertiesPalette_TextBase"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>308</width> - <height>390</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>3</number> - </property> - <property name="leftMargin"> - <number>3</number> - </property> - <property name="topMargin"> - <number>3</number> - </property> - <property name="rightMargin"> - <number>3</number> - </property> - <property name="bottomMargin"> - <number>3</number> - </property> - <item> - <widget class="FontComboH" name="fonts" native="true"/> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>3</number> - </property> - <item> - <widget class="QLabel" name="fontSizeLabel"> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>22</width> - <height>22</height> - </size> - </property> - <property name="text"> - <string/> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item> - <widget class="ScrSpinBox" name="fontSize"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip"> - <string>Font Size</string> - </property> - <property name="suffix"> - <string> pt</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="spacing"> - <number>3</number> - </property> - <item> - <widget class="QLabel" name="lineSpacingLabel"> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>22</width> - <height>22</height> - </size> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="lineSpacingModeCombo"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip"> - <string>Select the line spacing mode</string> - </property> - </widget> - </item> - <item> - <widget class="ScrSpinBox" name="lineSpacing"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip"> - <string>Line Spacing</string> - </property> - <property name="suffix"> - <string> pt</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_5"> - <property name="spacing"> - <number>3</number> - </property> - <item> - <widget class="QLabel" name="textAlignmentLabel"> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>22</width> - <height>22</height> - </size> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="AlignSelect" name="textAlignment" native="true"/> - </item> - <item alignment="Qt::AlignLeft"> - <widget class="DirectionSelect" name="textDirection" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <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> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <property name="spacing"> - <number>3</number> - </property> - <item> - <widget class="QLabel" name="langLabel"> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>22</width> - <height>22</height> - </size> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="langCombo"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip"> - <string>Text Language</string> - </property> - <property name="editable"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <property name="spacing"> - <number>3</number> - </property> - <item> - <widget class="QLabel" name="paraStyleLabel"> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>22</width> - <height>22</height> - </size> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="ParaStyleComboBox" name="paraStyleCombo"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip"> - <string>Paragraph style of currently selected text or paragraph</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="paraStyleClear"> - <property name="toolTip"> - <string>Remove Direct Paragraph Formatting</string> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <property name="spacing"> - <number>3</number> - </property> - <item> - <widget class="QLabel" name="charStyleLabel"> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>22</width> - <height>22</height> - </size> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="CharStyleComboBox" name="charStyleCombo"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip"> - <string>Character style of currently selected text or paragraph</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="charStyleClear"> - <property name="toolTip"> - <string>Remove Direct Character Formatting</string> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="ScTreeWidget" name="textTree"> - <column> - <property name="text"> - <string notr="true">1</string> - </property> - </column> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>ScrSpinBox</class> - <extends>QDoubleSpinBox</extends> - <header>ui/scrspinbox.h</header> - </customwidget> - <customwidget> - <class>FontComboH</class> - <extends>QWidget</extends> - <header>ui/fontcombo.h</header> - <container>1</container> - </customwidget> - <customwidget> - <class>CharStyleComboBox</class> - <extends>QComboBox</extends> - <header>ui/stylecombos.h</header> - </customwidget> - <customwidget> - <class>ScTreeWidget</class> - <extends>QTreeWidget</extends> - <header>ui/sctreewidget.h</header> - </customwidget> - <customwidget> - <class>ParaStyleComboBox</class> - <extends>QComboBox</extends> - <header>ui/stylecombos.h</header> - </customwidget> - <customwidget> - <class>AlignSelect</class> - <extends>QWidget</extends> - <header>ui/alignselect.h</header> - <container>1</container> - </customwidget> - <customwidget> - <class>DirectionSelect</class> - <extends>QWidget</extends> - <header>ui/directionselect.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> Index: scribus/ui/propertywidget_text.cpp =================================================================== --- scribus/ui/propertywidget_text.cpp (nicht existent) +++ scribus/ui/propertywidget_text.cpp (Arbeitskopie) @@ -0,0 +1,574 @@ +/* +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 "propertywidget_text.h" +#include "ui_propertywidget_textbase.h" + +#include "appmodes.h" +#include "commonstrings.h" +#include "fontcombo.h" +#include "iconmanager.h" +#include "localemgr.h" +#include "pageitem.h" +#include "pageitem_table.h" +#include "pageitem_textframe.h" +#include "scribus.h" +#include "scribusapp.h" +#include "selection.h" +#include "stylecombos.h" +#include "undomanager.h" +#include "langmgr.h" + + +PropertyWidget_Text::PropertyWidget_Text( QWidget* parent) : QFrame(parent) +{ + setupUi(this); + + fontSize->setPrefix(""); + + iconSetChange(); + languageChange(); + + connect(lineSpacing , SIGNAL(valueChanged(double)), this, SLOT(handleLineSpacing())); + connect(fonts , SIGNAL(fontSelected(QString)), this, SLOT(handleTextFont(QString))); + connect(fontSize , SIGNAL(valueChanged(double)), this, SLOT(handleFontSize())); + connect(textAlignment , SIGNAL(State(int)) , this, SLOT(handleAlignment(int))); + connect(textDirection , SIGNAL(State(int)) , this, SLOT(handleDirection(int))); + connect(charStyleClear, SIGNAL(clicked()), this, SLOT(doClearCStyle())); + connect(paraStyleClear, SIGNAL(clicked()), this, SLOT(doClearPStyle())); + + connect(lineSpacingModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(handleLineSpacingMode(int))); + connect(langCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changeLang(int))); + +// connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange())); +// connect(ScQApp, SIGNAL(localeChanged()), this, SLOT(localeChange())); + + setEnabled(false); +} + +void PropertyWidget_Text::setMainWindow(ScribusMainWindow* mw) +{ + m_ScMW = mw; + +// connect(m_ScMW, SIGNAL(UpdateRequest(int)) , this , SLOT(handleUpdateRequest(int))); + + connect(paraStyleCombo, SIGNAL(newStyle(QString)), m_ScMW, SLOT(setNewParStyle(QString)), Qt::UniqueConnection); + connect(charStyleCombo, SIGNAL(newStyle(QString)), m_ScMW, SLOT(setNewCharStyle(QString)), Qt::UniqueConnection); +} + +void PropertyWidget_Text::setDoc(ScribusDoc *d) +{ + 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 = nullptr; + m_haveDoc = true; + m_haveItem = false; + + fontSize->setValues(0.5, 2048, 2, 1); + lineSpacing->setValues(1, 2048, 2, 1); + + fonts->rebuildList(m_doc); + paraStyleCombo->setDoc(m_doc); + charStyleCombo->setDoc(m_doc); + + if (m_doc.isNull()) + { + return; + } + + connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); + connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); +} + +PageItem* PropertyWidget_Text::currentItemFromSelection() +{ + PageItem *currentItem = nullptr; + + if (m_doc) + { + if (m_doc->m_Selection->count() > 1) + currentItem = m_doc->m_Selection->itemAt(0); + else if (m_doc->m_Selection->count() == 1) + currentItem = m_doc->m_Selection->itemAt(0); + if (currentItem && currentItem->isTable() && m_doc->appMode == modeEditTable) + currentItem = currentItem->asTable()->activeCell().textFrame(); + } + + return currentItem; +} + +void PropertyWidget_Text::handleSelectionChanged() +{ + if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning()) + return; + + PageItem* currItem = currentItemFromSelection(); + if (m_doc->m_Selection->count() > 1) + { + setEnabled(false); + } + else + { + int itemType = currItem ? (int) currItem->itemType() : -1; + m_haveItem = (itemType != -1); + + switch (itemType) + { + case -1: + m_haveItem = false; + m_item = nullptr; + setEnabled(false); + break; + case PageItem::TextFrame: + case PageItem::PathText: + setEnabled(true); + break; + case PageItem::Table: + setEnabled(m_doc->appMode == modeEditTable); + break; + default: + setEnabled(false); + break; + } + } + if (currItem) + { + setCurrentItem(currItem); + } + updateGeometry(); +} + +void PropertyWidget_Text::handleUpdateRequest(int updateFlags) +{ + // ColorWidget will handle its update itself + /*if (updateFlags & reqColorsUpdate) + updateColorList();*/ + if (updateFlags & reqCharStylesUpdate) + { + charStyleCombo->updateStyleList(); + } + if (updateFlags & reqParaStylesUpdate) + paraStyleCombo->updateStyleList(); + if (updateFlags & reqDefFontListUpdate) + fonts->rebuildList(nullptr); + if (updateFlags & reqDocFontListUpdate) + fonts->rebuildList(m_haveDoc ? m_doc : nullptr); + if (updateFlags & reqStyleComboDocUpdate) + { + paraStyleCombo->setDoc(m_haveDoc ? m_doc : nullptr); + charStyleCombo->setDoc(m_haveDoc ? m_doc : nullptr); + } +} + +void PropertyWidget_Text::setCurrentItem(PageItem *item) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + //CB We shouldn't 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 won't work until when a canvas deselect happens, m_item must be nullptr. + //if (m_item == i) + // return; + + if (!m_doc) + setDoc(item->doc()); + + m_haveItem = false; + m_item = item; + + if ((m_item->isGroup()) && (!m_item->isSingleSel)) + { + setEnabled(false); + } + + m_haveItem = true; + + + if (m_item->isTextFrame() || m_item->isPathText() || m_item->isTable()) + { + ParagraphStyle parStyle = m_item->itemText.defaultStyle(); + if (m_doc->appMode == modeEdit || m_doc->appMode == modeEditTable) + m_item->currentTextProps(parStyle); + updateStyle(parStyle); + } + if (m_item->isOSGFrame()) + { + setEnabled(false); + } + if (m_item->asSymbol()) + { + setEnabled(false); + } +} + +void PropertyWidget_Text::iconSetChange() +{ + IconManager& iconManager = IconManager::instance(); + + fontSizeLabel->setPixmap(iconManager.loadPixmap("zeichen.png")); + lineSpacingLabel->setPixmap(iconManager.loadPixmap("linespacing2.png")); + textAlignmentLabel->setPixmap(iconManager.loadPixmap("22/text-align.png")); + langLabel->setPixmap(iconManager.loadPixmap("22/language.png")); + paraStyleLabel->setPixmap(iconManager.loadPixmap("22/paragraph-style.png")); + charStyleLabel->setPixmap(iconManager.loadPixmap("22/character-style.png")); + + paraStyleClear->setIcon(iconManager.loadPixmap("16/edit-clear.png")); + charStyleClear->setIcon(iconManager.loadPixmap("16/edit-clear.png")); +} + + +void PropertyWidget_Text::localeChange() +{ + const QLocale& l(LocaleManager::instance().userPreferredLocale()); + fontSize->setLocale(l); + lineSpacing->setLocale(l); +} + +void PropertyWidget_Text::handleLineSpacingMode(int id) +{ + if (!m_haveDoc || !m_haveItem) + return; + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_SetLineSpacingMode(id, &tempSelection); + updateStyle(((m_doc->appMode == modeEdit) || (m_doc->appMode == modeEditTable)) ? m_item->currentStyle() : m_item->itemText.defaultStyle()); + m_doc->regionsChanged()->update(QRect()); +} + +void PropertyWidget_Text::changeLang(int id) +{ + if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) + return; + QStringList languageList; + LanguageManager::instance()->fillInstalledStringList(&languageList); + QString abrv = LanguageManager::instance()->getAbbrevFromLang(languageList.value(id),false); + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_SetLanguage(abrv, &tempSelection); +} + +void PropertyWidget_Text::showLineSpacing(double r) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + bool inEditMode = (m_doc->appMode == modeEdit || m_doc->appMode == modeEditTable); + bool tmp = m_haveItem; + m_haveItem = false; + lineSpacing->showValue(r); + const ParagraphStyle& curStyle(m_haveItem && inEditMode ? m_item->currentStyle() : m_item->itemText.defaultStyle()); + if (tmp) + { + setupLineSpacingSpinbox(curStyle.lineSpacingMode(), r); + lineSpacingModeCombo->setCurrentIndex(curStyle.lineSpacingMode()); + } + m_haveItem = tmp; +} + +void PropertyWidget_Text::showFontFace(const QString& newFont) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + bool tmp = m_haveItem; + m_haveItem = false; + if (m_item != nullptr) + fonts->rebuildList(m_doc, m_item->isAnnotation()); + fonts->setCurrentFont(newFont); + m_haveItem = tmp; +} + +void PropertyWidget_Text::showFontSize(double s) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + fontSize->showValue(s / 10.0); +} + +void PropertyWidget_Text::showLanguage(const QString& w) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + QStringList lang; + LanguageManager::instance()->fillInstalledStringList(&lang); + QString langName = LanguageManager::instance()->getLangFromAbbrev(w, true); + + bool sigBlocked = langCombo->blockSignals(true); + langCombo->setCurrentIndex(lang.indexOf(langName)); + langCombo->blockSignals(sigBlocked); +} + +void PropertyWidget_Text::setupLineSpacingSpinbox(int mode, double value) +{ + bool blocked = lineSpacing->blockSignals(true); + if (mode > 0) + { + if (mode == 1) + lineSpacing->setSpecialValueText( tr( "Auto" ) ); + if (mode == 2) + lineSpacing->setSpecialValueText( tr( "Baseline" ) ); + lineSpacing->setMinimum(0); + lineSpacing->setValue(0); + lineSpacing->setEnabled(false); + } + else + { + lineSpacing->setSpecialValueText(""); + lineSpacing->setMinimum(1); + lineSpacing->setValue(value); + lineSpacing->setEnabled(true); + } + lineSpacing->blockSignals(blocked); +} + +void PropertyWidget_Text::updateCharStyle(const CharStyle& charStyle) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + + showFontFace(charStyle.font().scName()); + showFontSize(charStyle.fontSize()); + showLanguage(charStyle.language()); +} + +void PropertyWidget_Text::updateStyle(const ParagraphStyle& newCurrent) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + + const CharStyle& charStyle = newCurrent.charStyle(); + + showFontFace(charStyle.font().scName()); + showFontSize(charStyle.fontSize()); + showLanguage(charStyle.language()); + + if (m_item) + { + QString defaultParStyle = m_item->itemText.defaultStyle().parent(); + if (defaultParStyle.isEmpty()) + defaultParStyle = CommonStrings::DefaultParagraphStyle; + paraStyleCombo->setDefaultStyle(defaultParStyle); + } + showParStyle(newCurrent.parent()); + + if (m_item) + { + QString defaultCharStyle; + if (!newCurrent.parent().isEmpty()) + { + const ParagraphStyle* paraStyle = m_doc->paragraphStyles().getPointer(newCurrent.parent()); + if (paraStyle) + defaultCharStyle = paraStyle->charStyle().parent(); + if (defaultCharStyle.isEmpty()) + defaultCharStyle = CommonStrings::DefaultCharacterStyle; + } + if (defaultCharStyle.isEmpty()) + defaultCharStyle = m_item->itemText.defaultStyle().charStyle().parent(); + if (defaultCharStyle.isEmpty()) + defaultCharStyle = CommonStrings::DefaultCharacterStyle; + charStyleCombo->setDefaultStyle(defaultCharStyle); + } + showCharStyle(charStyle.parent()); + + bool tmp = m_haveItem; + m_haveItem = false; + + setupLineSpacingSpinbox(newCurrent.lineSpacingMode(), newCurrent.lineSpacing()); + lineSpacingModeCombo->setCurrentIndex(newCurrent.lineSpacingMode()); + textAlignment->setStyle(newCurrent.alignment(), newCurrent.direction()); + textDirection->setStyle(newCurrent.direction()); + + m_haveItem = tmp; +} + +void PropertyWidget_Text::updateCharStyles() +{ + charStyleCombo->updateStyleList(); +} + +void PropertyWidget_Text::updateParagraphStyles() +{ + paraStyleCombo->updateStyleList(); + charStyleCombo->updateStyleList(); +} + +void PropertyWidget_Text::updateTextStyles() +{ + paraStyleCombo->updateStyleList(); + charStyleCombo->updateStyleList(); +} + +void PropertyWidget_Text::showAlignment(int e) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + bool tmp = m_haveItem; + m_haveItem = false; + textAlignment->setEnabled(true); + textAlignment->setStyle(e, textDirection->getStyle()); + m_haveItem = tmp; +} + +void PropertyWidget_Text::showDirection(int e) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + bool tmp = m_haveItem; + m_haveItem = false; + textDirection->setEnabled(true); + textDirection->setStyle(e); + m_haveItem = tmp; +} + +void PropertyWidget_Text::showCharStyle(const QString& name) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + bool blocked = charStyleCombo->blockSignals(true); + charStyleCombo->setStyle(name); + charStyleCombo->blockSignals(blocked); +} + +void PropertyWidget_Text::showParStyle(const QString& name) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + bool blocked = paraStyleCombo->blockSignals(true); + paraStyleCombo->setStyle(name); + paraStyleCombo->blockSignals(blocked); +} + +void PropertyWidget_Text::handleLineSpacing() +{ + if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) + return; + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_SetLineSpacing(lineSpacing->value(), &tempSelection); +} + +void PropertyWidget_Text::handleFontSize() +{ + if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) + return; + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_SetFontSize(qRound(fontSize->value()*10.0), &tempSelection); +} + +void PropertyWidget_Text::handleAlignment(int a) +{ + if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) + return; + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_SetAlignment(a, &tempSelection); + + emit alignmentHandled(); + +// if (m_item->isPathText()) +// pathTextWidgets->handleSelectionChanged(); +} + +void PropertyWidget_Text::handleDirection(int d) +{ + if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) + return; + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_SetDirection(d, &tempSelection); + // If current text alignment is left or right, change it to match direction + if (d == ParagraphStyle::RTL && textAlignment->selectedId() == ParagraphStyle::LeftAligned) + { + m_doc->itemSelection_SetAlignment(ParagraphStyle::RightAligned, &tempSelection); + textAlignment->setTypeStyle(ParagraphStyle::RightAligned); + } + else if (d == ParagraphStyle::LTR && textAlignment->selectedId() == ParagraphStyle::RightAligned) + { + m_doc->itemSelection_SetAlignment(ParagraphStyle::LeftAligned, &tempSelection); + textAlignment->setTypeStyle(ParagraphStyle::LeftAligned); + } +} + +void PropertyWidget_Text::handleTextFont(const QString& font) +{ + if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) + return; + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_SetFont(font, &tempSelection); +} + +void PropertyWidget_Text::doClearCStyle() +{ + if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveDoc || !m_haveItem) + return; + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_EraseCharStyle(&tempSelection); +} + + +void PropertyWidget_Text::doClearPStyle() +{ + if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveDoc || !m_haveItem) + return; + + UndoTransaction activeTransaction; + if (UndoManager::undoEnabled()) + activeTransaction = UndoManager::instance()->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::RemoveTextStyle, tr( "remove direct paragraph formatting" ), Um::IFont); + + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_ClearBulNumStrings(&tempSelection); + m_doc->itemSelection_EraseParagraphStyle(&tempSelection); + CharStyle emptyCStyle; + m_doc->itemSelection_SetCharStyle(emptyCStyle, &tempSelection); + + if (activeTransaction) + activeTransaction.commit(); +} + +void PropertyWidget_Text::changeEvent(QEvent *e) +{ + if (e->type() == QEvent::LanguageChange) + { + languageChange(); + return; + } + QWidget::changeEvent(e); +} + +void PropertyWidget_Text::languageChange() +{ + retranslateUi(this); + + QSignalBlocker lineSpacingModeBlocker(lineSpacingModeCombo); + int oldLineSpacingMode = lineSpacingModeCombo->currentIndex(); + lineSpacingModeCombo->clear(); + lineSpacingModeCombo->addItem( tr("Fixed Linespacing")); + lineSpacingModeCombo->addItem( tr("Automatic Linespacing")); + lineSpacingModeCombo->addItem( tr("Align to Baseline Grid")); + lineSpacingModeCombo->setCurrentIndex(oldLineSpacingMode); + + QSignalBlocker langComboBlocker(langCombo); + QStringList languageList; + LanguageManager::instance()->fillInstalledStringList(&languageList); + int oldLang = langCombo->currentIndex(); + langCombo->clear(); + langCombo->addItems(languageList); + langCombo->setCurrentIndex(oldLang); + + textAlignment->languageChange(); + textDirection->languageChange(); +} Index: scribus/ui/propertywidget_text.h =================================================================== --- scribus/ui/propertywidget_text.h (nicht existent) +++ scribus/ui/propertywidget_text.h (Arbeitskopie) @@ -0,0 +1,89 @@ +#ifndef PROPERTYWIDGET_TEXT_H +#define PROPERTYWIDGET_TEXT_H + +#include "ui_propertywidget_textbase.h" +#include "propertywidgetbase.h" +#include <QFrame> + +//namespace Ui { +//class PropertyWidget_Text; +//} + +class CharStyle; +class ParagraphStyle; +class ScribusDoc; +class ScribusMainWindow; + + +class PropertyWidget_Text : public QFrame, Ui::PropertyWidget_TextBase, + public PropertyWidgetBase +{ + Q_OBJECT + +public: + PropertyWidget_Text(QWidget *parent = nullptr); + ~PropertyWidget_Text() {}; + +private: + PageItem* currentItemFromSelection(); + +protected: + void connectSignals(); + void disconnectSignals(); + + void configureWidgets(); + void setCurrentItem(PageItem *item); + void changeEvent(QEvent *e) override; + + bool m_haveDoc {false}; + bool m_haveItem {false}; + PageItem* m_item { nullptr }; + ScribusMainWindow* m_ScMW { nullptr }; + +public slots: + void setMainWindow(ScribusMainWindow *mw); + void setDoc(ScribusDoc *d); + + void handleSelectionChanged(); + void handleUpdateRequest(int); + void iconSetChange(); + void languageChange(); + void localeChange(); + void changeLang(int id); + void unitChange() {}; + + void showAlignment(int e); + void showDirection(int e); + void showCharStyle(const QString& name); + void showFontFace(const QString&); + void showFontSize(double s); + void showLanguage(const QString& w); + void showLineSpacing(double r); + void showParStyle(const QString& name); + + void setupLineSpacingSpinbox(int mode, double value); + + void updateCharStyle(const CharStyle& charStyle); + void updateStyle(const ParagraphStyle& newCurrent); + + void updateCharStyles(); + void updateParagraphStyles(); + void updateTextStyles(); + + void handleLineSpacingMode(int id); + void handleTextFont(const QString&); + +private slots: + void handleAlignment(int a); + void handleDirection(int d); + void handleFontSize(); + void handleLineSpacing(); + + void doClearCStyle(); + void doClearPStyle(); + +signals: + void alignmentHandled(); +}; + +#endif // PROPERTYWIDGET_TEXT_H Index: scribus/ui/propertywidget_textbase.ui =================================================================== --- scribus/ui/propertywidget_textbase.ui (nicht existent) +++ scribus/ui/propertywidget_textbase.ui (Arbeitskopie) @@ -0,0 +1,359 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PropertyWidget_TextBase</class> + <widget class="QFrame" name="PropertyWidget_TextBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>281</width> + <height>241</height> + </rect> + </property> + <property name="windowTitle"> + <string>Frame</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>3</number> + </property> + <property name="topMargin"> + <number>3</number> + </property> + <property name="rightMargin"> + <number>3</number> + </property> + <property name="bottomMargin"> + <number>3</number> + </property> + <item> + <widget class="FontComboH" name="fonts" native="true"/> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="spacing"> + <number>3</number> + </property> + <item> + <widget class="QLabel" name="fontSizeLabel"> + <property name="minimumSize"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item> + <widget class="ScrSpinBox" name="fontSize"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Font Size</string> + </property> + <property name="suffix"> + <string> pt</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="spacing"> + <number>3</number> + </property> + <item> + <widget class="QLabel" name="lineSpacingLabel"> + <property name="minimumSize"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="lineSpacingModeCombo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Select the line spacing mode</string> + </property> + </widget> + </item> + <item> + <widget class="ScrSpinBox" name="lineSpacing"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Line Spacing</string> + </property> + <property name="suffix"> + <string> pt</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <property name="spacing"> + <number>3</number> + </property> + <item> + <widget class="QLabel" name="textAlignmentLabel"> + <property name="minimumSize"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="AlignSelect" name="textAlignment" native="true"/> + </item> + <item alignment="Qt::AlignLeft"> + <widget class="DirectionSelect" name="textDirection" native="true"/> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <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> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <property name="spacing"> + <number>3</number> + </property> + <item> + <widget class="QLabel" name="langLabel"> + <property name="minimumSize"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="langCombo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Text Language</string> + </property> + <property name="editable"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <property name="spacing"> + <number>3</number> + </property> + <item> + <widget class="QLabel" name="paraStyleLabel"> + <property name="minimumSize"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="ParaStyleComboBox" name="paraStyleCombo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Paragraph style of currently selected text or paragraph</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="paraStyleClear"> + <property name="toolTip"> + <string>Remove Direct Paragraph Formatting</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <property name="spacing"> + <number>3</number> + </property> + <item> + <widget class="QLabel" name="charStyleLabel"> + <property name="minimumSize"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="CharStyleComboBox" name="charStyleCombo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Character style of currently selected text or paragraph</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="charStyleClear"> + <property name="toolTip"> + <string>Remove Direct Character Formatting</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>ScrSpinBox</class> + <extends>QDoubleSpinBox</extends> + <header>ui/scrspinbox.h</header> + </customwidget> + <customwidget> + <class>FontComboH</class> + <extends>QWidget</extends> + <header>ui/fontcombo.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>CharStyleComboBox</class> + <extends>QComboBox</extends> + <header>ui/stylecombos.h</header> + </customwidget> + <customwidget> + <class>ParaStyleComboBox</class> + <extends>QComboBox</extends> + <header>ui/stylecombos.h</header> + </customwidget> + <customwidget> + <class>AlignSelect</class> + <extends>QWidget</extends> + <header>ui/alignselect.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>DirectionSelect</class> + <extends>QWidget</extends> + <header>ui/directionselect.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> Index: scribus/ui/widgets/section_container.cpp =================================================================== --- scribus/ui/widgets/section_container.cpp (nicht existent) +++ scribus/ui/widgets/section_container.cpp (Arbeitskopie) @@ -0,0 +1,430 @@ +#include "section_container.h" + +#include <QPainter> +#include <QPen> +#include <QMouseEvent> +// #include "color_utils.h" + + +/* ********************************************************************************* * + * + * Constructor + Setup + * + * ********************************************************************************* */ + +SectionContainer::SectionContainer(QWidget *parent) : SectionContainer("Title", true, parent){} + +SectionContainer::SectionContainer(QString title, bool isCollapsible, QWidget *parent) + : QWidget{parent} + // , headerLayout (new QHBoxLayout) + // , layoutHeaderPrefix (new QHBoxLayout) + // , layoutHeaderSuffix (new QHBoxLayout) + // , bodyWidget(new QStackedWidget) + // , labelTitle (new QLabel("Title")) + // , buttonCollapse (new QToolButton) + // , headerWidget (new QWidget) + // , iconCollapsed(QIcon()) + // , iconExpanded (QIcon()) + // , boolIsCollapsible(isCollapsible) + // , boolIsCollapsed(false) + // , boolHasStyle(true) +{ + int padding = 4; + headerLayout = new QHBoxLayout; + layoutHeaderPrefix = new QHBoxLayout; + layoutHeaderSuffix = new QHBoxLayout; + bodyWidget= new QStackedWidget; + labelTitle = new QLabel(title); + buttonCollapse = new QToolButton; + headerWidget = new QWidget; + iconCollapsed = QIcon(); + iconExpanded = QIcon(); + boolIsCollapsible = isCollapsible; + boolIsCollapsed = false; + boolHasStyle = true; + + + + // Label + // QFont m_font(this->font()); + // m_font.setBold( true ); + // labelTitle->setFont(m_font); + labelTitle->setText(title); + labelTitle->setBuddy(this); + + // Buttons + buttonCollapse->setAutoRaise(true); + buttonCollapse->adjustSize(); // needed to calculate the header height later + + // Header Prefix layout + layoutHeaderPrefix->setContentsMargins( 0,0,0,0 ); + layoutHeaderPrefix->setSpacing(padding); + + // Header Suffix Layout + layoutHeaderSuffix->setContentsMargins( 0,0,0,0 ); + layoutHeaderSuffix->setSpacing(padding); + + // Header Layout + headerLayout->addWidget( buttonCollapse ); + headerLayout->addLayout( layoutHeaderPrefix ); + headerLayout->addWidget( labelTitle ); + headerLayout->addStretch( 0 ); + headerLayout->addLayout( layoutHeaderSuffix ); + headerLayout->setContentsMargins( padding, padding/2, padding, padding/2 ); + + // Header Widget + headerWidget->setLayout(headerLayout); + headerWidget->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum ); + headerWidget->setMaximumHeight(buttonCollapse->height() + padding); + headerWidget->installEventFilter(this); + + + // Main Layout + QVBoxLayout * mainLayout = new QVBoxLayout(this); + mainLayout->setSpacing(0); + mainLayout->setContentsMargins(0,0,0,0); + mainLayout->addWidget(headerWidget); + mainLayout->addWidget(bodyWidget); + + + // Size Policy + QSizePolicy sizePol = QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Maximum ); + setSizePolicy(sizePol); + tmpSizePolicy = sizePol; + + // initial Setup + setIsCollapsible(isCollapsible); + connectSlots(); + + +} + +void SectionContainer::connectSlots() +{ + connect( buttonCollapse, &QToolButton::clicked,this, &SectionContainer::toggleCollpasedState ); +} + +/* ********************************************************************************* * + * + * Header + * + * ********************************************************************************* */ + +void SectionContainer::addHeaderSuffixWidget(QWidget *widget) +{ + insertHeaderSuffixWidget(-1, widget); +} + +void SectionContainer::insertHeaderSuffixWidget(int index, QWidget *widget) +{ + QToolButton *toolButton = static_cast<QToolButton*>(widget); + + if(toolButton){ + toolButton->setAutoRaise(true); + //m_addonLayout->insertWidget( m_headerLayout->count(), toolButton ); + layoutHeaderSuffix->insertWidget(index, toolButton); + }else{ + //m_addonLayout->insertWidget( m_headerLayout->count(), widget ); + layoutHeaderSuffix->insertWidget(index, widget); + } +} + +void SectionContainer::removeHeaderSuffixWidget(QWidget *widget) +{ + layoutHeaderSuffix->removeWidget( widget ); + widget->deleteLater(); +} + +void SectionContainer::addHeaderSuffixSpacing(int size) +{ + insertHeaderSuffixSpacing(-1, size); +} + +void SectionContainer::insertHeaderSuffixSpacing(int index, int size) +{ + layoutHeaderSuffix->insertSpacing(index, size); +} + +void SectionContainer::addHeaderPrefixWidget(QWidget *widget) +{ + insertHeaderPrefixWidget(-1, widget); +} + +void SectionContainer::insertHeaderPrefixWidget(int index, QWidget *widget) +{ + QToolButton *toolButton = static_cast<QToolButton*>(widget); + + if(toolButton){ + toolButton->setAutoRaise(true); + //m_addonLayout->insertWidget( m_headerLayout->count(), toolButton ); + layoutHeaderPrefix->insertWidget(index, toolButton); + }else{ + //m_addonLayout->insertWidget( m_headerLayout->count(), widget ); + layoutHeaderPrefix->insertWidget(index, widget); + } +} + +void SectionContainer::removeHeaderPrefixWidget(QWidget *widget) +{ + layoutHeaderPrefix->removeWidget( widget ); + widget->deleteLater(); +} + +void SectionContainer::addHeaderPrefixSpacing(int size) +{ + insertHeaderPrefixSpacing(-1, size); +} + +void SectionContainer::insertHeaderPrefixSpacing(int index, int size) +{ + layoutHeaderPrefix->insertSpacing(index, size); +} + + + +/* ********************************************************************************* * + * + * Properties + * + * ********************************************************************************* */ + +void SectionContainer::setText(QString text) +{ + labelTitle->setText(text); +} + +QString SectionContainer::text() const +{ + return labelTitle->text(); +} + +void SectionContainer::setFont(QFont font) +{ + labelTitle->setFont(font); + QWidget::setFont(font); +} + +QFont SectionContainer::font() +{ + return labelTitle->font(); +} + +void SectionContainer::setHasStyle(bool isSimple) +{ + boolHasStyle = isSimple; + update(); +} + +bool SectionContainer::hasStyle() +{ + return boolHasStyle; +} + +void SectionContainer::setIsCollapsible(bool isCollapsible) +{ + boolIsCollapsible = isCollapsible; + buttonCollapse->setVisible(isCollapsible); +} + +bool SectionContainer::isCollapsible() +{ + return boolIsCollapsible; +} + +bool SectionContainer::isCollapsed() +{ + return boolIsCollapsed; +} + +void SectionContainer::setIsCollapsed(bool state) +{ + if(isCollapsible() == false) return; + + boolIsCollapsed = state; + + if( boolIsCollapsed ){ + // save size policy + // tmpSizePolicy = this->sizePolicy(); + + bodyWidget->hide(); + buttonCollapse->setIcon(iconCollapsed); + + // // optimize size policy for collapsed state + // QSizePolicy sizePol = QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Maximum ); + // setSizePolicy(sizePol); + + } else { + // restore size policy + // this->setSizePolicy(tmpSizePolicy); + + bodyWidget->show(); + buttonCollapse->setIcon(iconExpanded); + } + + adjustSize(); + + emit collapsedState(boolIsCollapsed); +} + + +void SectionContainer::setCollapseIcons(QIcon collapsed, QIcon expanded) +{ + iconCollapsed = collapsed; + iconExpanded = expanded; + + if( boolIsCollapsed ){ + buttonCollapse->setIcon(iconCollapsed); + } else { + buttonCollapse->setIcon(iconExpanded); + } +} + +/* ********************************************************************************* * + * + * Slots + * + * ********************************************************************************* */ + +void SectionContainer::toggleCollpasedState() +{ + if(isCollapsible() == false) return; + + ( boolIsCollapsed ) ? boolIsCollapsed = false : boolIsCollapsed = true; + + setIsCollapsed(boolIsCollapsed); +} + + +/* ********************************************************************************* * + * + * Plugin (StackedWidget) + * + * ********************************************************************************* */ + +QWidget* SectionContainer::widget(int index) +{ + return bodyWidget->widget(index); +} + +void SectionContainer::addPage(QWidget *page) +{ + insertPage(count(), page); +} + +void SectionContainer::insertPage(int index, QWidget *page) +{ + page->setParent(bodyWidget); + + bodyWidget->insertWidget(index, page); +} + +void SectionContainer::removePage(int index) +{ + QWidget *widget = bodyWidget->widget(index); + bodyWidget->removeWidget(widget); +} + +int SectionContainer::count() const +{ + return bodyWidget->count(); +} + +int SectionContainer::currentIndex() const +{ + return bodyWidget->currentIndex(); +} + +void SectionContainer::setCurrentIndex(int index) +{ + if (index != currentIndex()) { + bodyWidget->setCurrentIndex(index); + emit currentIndexChanged(index); + } +} + + +/* ********************************************************************************* * + * + * Events + * + * ********************************************************************************* */ + +bool SectionContainer::eventFilter(QObject *object, QEvent *event) +{ + // Header Widget + if(object == headerWidget){ + switch(event->type()) + { + case QEvent::MouseButtonDblClick:{ + QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event); + if (mouseEvent->button() == Qt::LeftButton && isCollapsible()) { + toggleCollpasedState(); + return true; + } + break; + } + case QEvent::Paint:{ + + if(boolHasStyle){ + + // QColor topLineColor( palette().color(QPalette::Mid) ); + QColor bottomLineColor( palette().color(QPalette::Dark) ); + // lineColor.setAlphaF(0.12f); + + QColor bgColor( palette().color(QPalette::WindowText) ); + bgColor.setAlphaF(0.07f); + + int lineWidth = 1; + int headerheight = headerWidget->height(); + QRect headerRect(0, 0, this->width(), headerheight - lineWidth); + + QPainter painter( headerWidget ); + + painter.setPen( Qt::NoPen ); + painter.setBrush(bgColor); + painter.drawRect(headerRect); + + painter.setBrush(Qt::NoBrush); + + // // Top Line + // painter.setPen( QPen(topLineColor, lineWidth) ); + // painter.drawLine( 0, 0,this->width(), 0 ); + + // Bottom Line + painter.setPen( QPen(bottomLineColor, lineWidth) ); + painter.drawLine( 0, headerheight - lineWidth, this->width(), headerheight - lineWidth ); + } + return true; + + break; + } + default: + return false; + } + + + } + + return false; +} + + +void SectionContainer::paintEvent(QPaintEvent *event) +{ + + QWidget::paintEvent(event); + + if(!boolHasStyle){ + + int lineWidth = 1; + QColor bottomLineColor( palette().color(QPalette::Dark) ); + + QPainter painter( this ); + + // Bottom Line + painter.setPen( QPen(bottomLineColor, lineWidth) ); + painter.drawLine( 8, this->height() - lineWidth, this->width() - 8, this->height() - lineWidth ); + + } + +} Index: scribus/ui/widgets/section_container.h =================================================================== --- scribus/ui/widgets/section_container.h (nicht existent) +++ scribus/ui/widgets/section_container.h (Arbeitskopie) @@ -0,0 +1,95 @@ +#ifndef SECTIONCONTAINER_H +#define SECTIONCONTAINER_H + +#include <QLabel> +#include <QStackedWidget> +#include <QToolButton> +#include <QVBoxLayout> +#include <QWidget> + +class SectionContainer : public QWidget +{ + Q_OBJECT + Q_CLASSINFO("Version", "1.0.0") + + Q_PROPERTY(QString title READ text WRITE setText) + Q_PROPERTY(bool isCollapsible READ isCollapsible WRITE setIsCollapsible) + Q_PROPERTY(bool isCollapsed READ isCollapsed WRITE setIsCollapsed) + Q_PROPERTY(bool hasStyle READ hasStyle WRITE setHasStyle) + + +public: + SectionContainer(QWidget *parent = nullptr); + SectionContainer(QString title, bool isCollapsible = true, QWidget *parent = nullptr); + + void addHeaderSuffixWidget(QWidget *widget); + void insertHeaderSuffixWidget(int index, QWidget *widget); + void removeHeaderSuffixWidget(QWidget *widget); + void addHeaderSuffixSpacing(int size); + void insertHeaderSuffixSpacing(int index, int size); + + void addHeaderPrefixWidget(QWidget *widget); + void insertHeaderPrefixWidget(int index, QWidget *widget); + void removeHeaderPrefixWidget(QWidget *widget); + void addHeaderPrefixSpacing(int size); + void insertHeaderPrefixSpacing(int index, int size); + + + void setText(QString text); + QString text() const; + + void setFont(QFont font); + QFont font(); + + void setHasStyle(bool hasStyle); + bool hasStyle(); + + void setIsCollapsible(bool isCollapsible); + bool isCollapsible(); + bool isCollapsed(); + + void setCollapseIcons(QIcon collapsed, QIcon expanded); + + QWidget *widget(int index); + + void addPage(QWidget * page); + + int count() const; + int currentIndex() const; + +private: + QHBoxLayout * headerLayout; + QHBoxLayout * layoutHeaderPrefix; + QHBoxLayout * layoutHeaderSuffix; + QStackedWidget * bodyWidget; + QLabel * labelTitle; + QToolButton * buttonCollapse; + QWidget * headerWidget; + QIcon iconCollapsed; + QIcon iconExpanded; + bool boolIsCollapsible; + bool boolIsCollapsed; + QSizePolicy tmpSizePolicy; + bool boolHasStyle; + + void connectSlots(); + + void paintEvent(QPaintEvent *event); + bool eventFilter(QObject *object, QEvent *event); + +public slots: + void toggleCollpasedState(); + void setIsCollapsed(bool state); + + void insertPage(int index, QWidget *page); + void removePage(int index); + void setCurrentIndex(int index); + +signals: + void collapsedState(bool); + void currentIndexChanged(int index); + + +}; + +#endif // SECTIONCONTAINER_H |
|
I simplified the container widget. What does the patch changes? - ScTreeWidget has been replaced by new SectionContainer widget with collapsible body => affects content properties and frame properties panel - Content properties: general text settings has been move into a collapsible container too Know issues - DropShadow widget has a scrollbar In the constructor of the PropTreeWidget, the minimum height of the widget is calculated based on the individual items. I compared this size to the display size in the container widget and it is the same. It looks like the item height calculation in the PropTreeWidget itself is not correct. The SectionContainer widget takes the height specified by the child widget. I'll leave this behavior as it is for now, as I also plan to rebuild the DropShadowWidget. indigouicontainer_23-10-30_1.patch (101,364 bytes)
Index: resources/iconsets/1_7_0/1_7_0.xml =================================================================== --- resources/iconsets/1_7_0/1_7_0.xml (Revision 25786) +++ resources/iconsets/1_7_0/1_7_0.xml (Arbeitskopie) @@ -136,12 +136,14 @@ <icon id="shade.png" file="16/color-shade.svg" /> <icon id="trashcan.png" file="16/action-delete.svg" /> <icon id="trashcan2.png" file="16/action-delete-open.svg" /> - <icon id="u_group.png" file="16/object-group.svg" /><!-- Outliner --> - <icon id="u_undo16.png" file="16/action-undo.svg" /><!-- Barcode --> - <icon id="ungroup.png" file="16/object-ungroup.svg" /> + <icon id="u_group.png" file="16/object-group.svg" /><!-- Outliner --> + <icon id="u_undo16.png" file="16/action-undo.svg" /><!-- Barcode --> + <icon id="ungroup.png" file="16/object-ungroup.svg" /> + <icon id="expand" file="16/action-chevron-down.svg" /> + <icon id="collapse" file="16/action-chevron-right.svg" /> - <!-- Alerts --> - <icon onLight="#E54545" onDark="#FF6666" id="22/dialog-error.png" file="16/alert-error.svg" /> + <!-- Alerts --> + <icon onLight="#E54545" onDark="#FF6666" id="22/dialog-error.png" file="16/alert-error.svg" /> <icon onLight="#D6922B" onDark="#FFC266" id="22/dialog-warning.png" file="16/alert-warning.svg" /> <icon onLight="#D6922B" onDark="#FFC266" id="alert.png" file="16/alert-warning.svg" /> <icon onLight="#68B259" onDark="#88CC7A" id="ok.png" file="16/alert-ok.svg" /> Index: resources/iconsets/CMakeLists.txt =================================================================== --- resources/iconsets/CMakeLists.txt (Revision 25786) +++ resources/iconsets/CMakeLists.txt (Arbeitskopie) @@ -111,10 +111,6 @@ file( GLOB SCRIBUS_ICONS_1_7_0_16 1_7_0/16/*.svg ) install(FILES ${SCRIBUS_ICONS_1_7_0_16} DESTINATION ${ICONDIR}/1_7_0/16) -#Install our 24x24 icons -file( GLOB SCRIBUS_ICONS_1_7_0_24 1_7_0/24/*.svg ) -install(FILES ${SCRIBUS_ICONS_1_7_0_24} DESTINATION ${ICONDIR}/1_7_0/24) - #Install our 32x32 icons file( GLOB SCRIBUS_ICONS_1_7_0_32 1_7_0/32/*.svg) install(FILES ${SCRIBUS_ICONS_1_7_0_32} DESTINATION ${ICONDIR}/1_7_0/32) Index: scribus/CMakeLists_Sources.txt =================================================================== --- scribus/CMakeLists_Sources.txt (Revision 25786) +++ scribus/CMakeLists_Sources.txt (Arbeitskopie) @@ -445,6 +445,7 @@ ui/propertywidget_optmargins.cpp ui/propertywidget_orphans.cpp ui/propertywidget_pathtext.cpp + ui/propertywidget_text.cpp ui/propertywidget_textcolor.cpp ui/propertywidget_fontfeatures.cpp ui/propertywidgetbase.cpp @@ -538,6 +539,7 @@ ui/weldedit.cpp ui/docks/dock_centralwidget.cpp ui/docks/dock_panelbase.cpp + ui/widgets/section_container.cpp ${SCRIBUS_OSG_SRC} ${SCRIBUS_GMAGICK_SRC} ${SCRIBUS_JPEGXL_SRC} Index: scribus/ui/propertiespalette.cpp =================================================================== --- scribus/ui/propertiespalette.cpp (Revision 25786) +++ scribus/ui/propertiespalette.cpp (Arbeitskopie) @@ -33,6 +33,7 @@ #include "appmodehelper.h" #include "appmodes.h" #include "colorpalette.h" +#include "iconmanager.h" #include "pageitem_table.h" #include "propertiespalette_line.h" #include "propertiespalette_shadow.h" @@ -57,46 +58,68 @@ f.setPointSize(f.pointSize()-1); setFont(f); - TabStack = new ScTreeWidget( this ); -// Uncomment this line if the new behaviour makes any trouble. -// TabStack->setToolBoxMode(true); - + // XZY xyzPal = new PropertiesPalette_XYZ( this ); - idXYZItem = TabStack->addItem( xyzPal, "X, Y, &Z" ); + scXYZ = new SectionContainer("X, Y, &Z"); + scXYZ->setWidget(xyzPal); + // Drop Shadow shadowPal = new PropertiesPalette_Shadow( this ); - idShadowItem = TabStack->addItem( shadowPal, "Drop Shadow" ); + scShadow = new SectionContainer("Drop Shadow"); + scShadow->setWidget(shadowPal); + scShadow->setIsCollapsed(true); + // Shape shapePal = new PropertiesPalette_Shape( this ); - idShapeItem = TabStack->addItem( shapePal, "&Shape" ); + scShape = new SectionContainer("&Shape"); + scShape->setWidget(shapePal); + scShape->setIsCollapsed(true); + // Line linePal = new PropertiesPalette_Line(this); - idLineItem=TabStack->addItem( linePal, "&Line" ); + scLine = new SectionContainer("&Line"); + scLine->setWidget(linePal); + scLine->setIsCollapsed(true); + // Color colorPalette = new ColorPalette(this); - idColorsItem = TabStack->addItem(colorPalette, "&Colors" ); + scColor = new SectionContainer("&Colors"); + scColor->setWidget(colorPalette); + scColor->setIsCollapsed(true); + // Transparency transparencyPalette = new TransparencyPalette(this); - idTransparencyItem = TabStack->addItem(transparencyPalette, "&Transparency" ); + scTransparency = new SectionContainer("&Transparency"); + scTransparency->setWidget(transparencyPalette); + scTransparency->setIsCollapsed(true); - setWidget( TabStack ); + // Layout stack + QVBoxLayout * lyt = new QVBoxLayout(); + lyt->setContentsMargins(0, 0, 0, 0); + lyt->setSpacing(0); + lyt->addWidget(scXYZ); + lyt->addWidget(scShadow); + lyt->addWidget(scShape); + lyt->addWidget(scLine); + lyt->addWidget(scColor); + lyt->addWidget(scTransparency); + lyt->addStretch(1); + QWidget * wdg = new QWidget(); + wdg->setLayout(lyt); + setWidget(wdg); + languageChange(); + enablePalettes(false); - connect(linePal, SIGNAL(lineModeChanged(int)), this, SLOT(NewLineMode(int))); - connect(TabStack, SIGNAL(currentChanged2(int)), this, SLOT(SelTab(int))); - - connect(colorPalette, SIGNAL(NewSpecial(double,double,double,double,double,double,double,double,double,double)), this, SLOT(NewSpGradient(double,double,double,double,double,double,double,double,double,double))); + connect(linePal, SIGNAL(lineModeChanged(int)), this, SLOT(newLineMode(int))); + connect(colorPalette, SIGNAL(NewSpecial(double,double,double,double,double,double,double,double,double,double)), this, SLOT(newSpGradient(double,double,double,double,double,double,double,double,double,double))); connect(colorPalette, SIGNAL(editGradient(int)), this, SLOT(toggleGradientEdit(int))); - connect(transparencyPalette, SIGNAL(NewSpecial(double,double,double,double,double,double,double,double,double,double)), this, SLOT(NewSpGradientM(double,double,double,double,double,double,double,double))); + connect(transparencyPalette, SIGNAL(NewSpecial(double,double,double,double,double,double,double,double,double,double)), this, SLOT(newSpGradientM(double,double,double,double,double,double,double,double))); connect(transparencyPalette, SIGNAL(editGradient()), this, SLOT(toggleGradientEditM())); m_haveItem = false; - for (int i = 1; i < 10; ++i) - TabStack->setItemEnabled(i, false); - TabStack->setCurrentIndex(0); - TabStack->widget(0)->setEnabled(false); - TabStack->setItemEnabled(0, false); + } void PropertiesPalette::closeEvent(QCloseEvent *closeEvent) @@ -136,39 +159,6 @@ connect(m_ScMW->appModeHelper, SIGNAL(AppModeChanged(int,int)), this, SLOT(AppModeChanged())); } -void PropertiesPalette::SelTab(int t) -{ - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - - if (!TabStack->widget(t)->isVisible()) - return; - - bool focusNowSet = false; - foreach (QObject *o, TabStack->widget(t)->children()) - { - // Layouts, boxes etc aren't widgets at all - // so let's skip them silently... - QWidget *w = qobject_cast<QWidget*>(o); - if (!w) - continue; - - QWidget *i = TabStack->widget(t); - while ((i = i->nextInFocusChain()) != TabStack->widget(t)) - { - if (((i->focusPolicy() & Qt::TabFocus) == Qt::TabFocus) && !i->focusProxy() && i->isEnabled()) - { - focusNowSet = true; - i->setFocus(); - break; - } - } - - if (focusNowSet) - break; - } -} - void PropertiesPalette::setDoc(ScribusDoc *d) { if((d == (ScribusDoc*) m_doc) || (m_ScMW && m_ScMW->scriptIsRunning())) @@ -235,10 +225,7 @@ transparencyPalette->setDocument(nullptr); m_haveItem = false; - for (int ws = 1; ws < 10; ++ws) - TabStack->setItemEnabled(ws, false); - TabStack->widget(0)->setEnabled(false); - TabStack->setItemEnabled(idXYZItem, false); + enablePalettes(false); } void PropertiesPalette::unsetItem() @@ -266,6 +253,16 @@ return nullptr; } +void PropertiesPalette::enablePalettes(bool enable) +{ + scXYZ->setEnabled(enable); + scShape->setEnabled(enable); + scLine->setEnabled(enable); + scColor->setEnabled(enable); + scTransparency->setEnabled(enable); + scShadow->setEnabled(enable); +} + void PropertiesPalette::AppModeChanged() { if (!m_ScMW || m_ScMW->scriptIsRunning()) @@ -300,13 +297,10 @@ return; } - int oldTabIndex = TabStack->currentIndex(); - if (!m_doc) setDoc(item->doc()); - disconnect(TabStack, SIGNAL(currentChanged2(int)) , this, SLOT(SelTab(int))); - disconnect(linePal , SIGNAL(lineModeChanged(int)), this, SLOT(NewLineMode(int))); + disconnect(linePal , SIGNAL(lineModeChanged(int)), this, SLOT(newLineMode(int))); m_haveItem = false; m_item = item; @@ -315,7 +309,7 @@ setTextFlowMode(m_item->textFlowMode()); - connect(linePal , SIGNAL(lineModeChanged(int)), this, SLOT(NewLineMode(int))); + connect(linePal , SIGNAL(lineModeChanged(int)), this, SLOT(newLineMode(int))); //CB replaces old emits from PageItem::emitAllToGUI() setLocked(item->locked()); @@ -322,23 +316,17 @@ if ((m_item->isGroup()) && (!m_item->isSingleSel)) { - TabStack->setItemEnabled(idXYZItem, true); - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, false); - TabStack->setItemEnabled(idColorsItem, false); - TabStack->setItemEnabled(idTransparencyItem, true); + scXYZ->setEnabled(true); + scShadow->setEnabled(true); + scShape->setEnabled(true); + scLine->setEnabled(false); + scColor->setEnabled(false); + scTransparency->setEnabled(true); + } m_haveItem = true; - if (oldTabIndex != TabStack->currentIndex()) - { - //Must be called only when necessary : cause focus problem - //in spinboxes when processing valueChanged() signals - SelTab(TabStack->currentIndex()); - } - if (!sender() || (m_doc->appMode == modeEditTable)) { xyzPal->handleSelectionChanged(); @@ -350,23 +338,22 @@ if (m_item->isOSGFrame()) { - TabStack->setItemEnabled(idXYZItem, true); - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, false); - TabStack->setItemEnabled(idColorsItem, true); - TabStack->setItemEnabled(idTransparencyItem, false); + scXYZ->setEnabled(true); + scShadow->setEnabled(true); + scShape->setEnabled(true); + scLine->setEnabled(false); + scColor->setEnabled(true); + scTransparency->setEnabled(false); } if (m_item->asSymbol()) { - TabStack->setItemEnabled(idXYZItem, true); - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, false); - TabStack->setItemEnabled(idLineItem, false); - TabStack->setItemEnabled(idColorsItem, false); - TabStack->setItemEnabled(idTransparencyItem, false); + scXYZ->setEnabled(true); + scShadow->setEnabled(true); + scShape->setEnabled(false); + scLine->setEnabled(false); + scColor->setEnabled(false); + scTransparency->setEnabled(false); } - connect(TabStack, SIGNAL(currentChanged2(int)), this, SLOT(SelTab(int))); } void PropertiesPalette::handleSelectionChanged() @@ -373,20 +360,17 @@ { if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning()) return; - int currentTab = TabStack->currentIndex(); - disconnect(TabStack, SIGNAL(currentChanged2(int)), this, SLOT(SelTab(int))); + enablePalettes(false); + PageItem* currItem = currentItemFromSelection(); if (m_doc->m_Selection->count() > 1) { - for (int ws = 1; ws < 10; ++ws) - TabStack->setItemEnabled(ws, false); - TabStack->widget(0)->setEnabled(true); - TabStack->setItemEnabled(idXYZItem, true); - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idLineItem, true); - TabStack->setItemEnabled(idColorsItem, true); - TabStack->setItemEnabled(idTransparencyItem, true); + scXYZ->setEnabled(true); + scShadow->setEnabled(true); + scLine->setEnabled(true); + scColor->setEnabled(true); + scTransparency->setEnabled(true); } else { @@ -393,19 +377,10 @@ int itemType = currItem ? (int) currItem->itemType() : -1; m_haveItem = (itemType != -1); -// int visID = TabStack->currentIndex(); - TabStack->widget(0)->setEnabled(true); - TabStack->setItemEnabled(idXYZItem, true); - TabStack->setItemEnabled(idColorsItem, true); - TabStack->setItemEnabled(idTransparencyItem, true); switch (itemType) { case -1: m_haveItem = false; - for (int ws = 1; ws < 10; ++ws) - TabStack->setItemEnabled(ws, false); - TabStack->widget(0)->setEnabled(false); - TabStack->setItemEnabled(idXYZItem, false); colorPalette->showGradient(0); break; case PageItem::ImageFrame: @@ -413,61 +388,42 @@ case PageItem::OSGFrame: if (currItem->isOSGFrame()) { - TabStack->setItemEnabled(idXYZItem, true); - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, false); - TabStack->setItemEnabled(idColorsItem, true); - TabStack->setItemEnabled(idTransparencyItem, false); + scXYZ->setEnabled(true); + scShadow->setEnabled(true); + scShape->setEnabled(true); + scColor->setEnabled(true); } else { - TabStack->setItemEnabled(idXYZItem, true); - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, true); + enablePalettes(true); } break; + case PageItem::Line: + scXYZ->setEnabled(true); + scShadow->setEnabled(true); + scLine->setEnabled(true); + scColor->setEnabled(true); + scTransparency->setEnabled(true); + break; case PageItem::Group: case PageItem::Symbol: case PageItem::Table: case PageItem::TextFrame: - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, true); - break; - case PageItem::Line: - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, false); - TabStack->setItemEnabled(idLineItem, true); - break; case PageItem::ItemType1: case PageItem::ItemType3: case PageItem::Polygon: case PageItem::RegularPolygon: case PageItem::Arc: - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, true); - break; case PageItem::PolyLine: case PageItem::Spiral: - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, true); - break; case PageItem::PathText: - TabStack->setItemEnabled(idShadowItem, true); - TabStack->setItemEnabled(idShapeItem, true); - TabStack->setItemEnabled(idLineItem, true); + enablePalettes(true); break; } } - if (TabStack->isItemEnabled(currentTab) && (TabStack->currentIndex() != currentTab)) - TabStack->setCurrentIndex(currentTab); + updateGeometry(); update(); - connect(TabStack, SIGNAL(currentChanged2(int)), this, SLOT(SelTab(int))); if (currItem) { @@ -495,7 +451,7 @@ m_haveItem = tmp; } -void PropertiesPalette::NewLineMode(int mode) +void PropertiesPalette::newLineMode(int mode) { if (!m_ScMW || m_ScMW->scriptIsRunning()) return; @@ -517,7 +473,7 @@ } } -void PropertiesPalette::NewSpGradient(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk, double cx, double cy) +void PropertiesPalette::newSpGradient(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk, double cx, double cy) { if (!m_ScMW || m_ScMW->scriptIsRunning()) return; @@ -654,7 +610,7 @@ } } -void PropertiesPalette::NewSpGradientM(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk) +void PropertiesPalette::newSpGradientM(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk) { if (!m_ScMW || m_ScMW->scriptIsRunning()) return; @@ -744,12 +700,12 @@ { setWindowTitle( tr("Properties")); - TabStack->setItemText(idXYZItem, tr("X, Y, &Z")); - TabStack->setItemText(idShadowItem, tr("Drop Shadow")); - TabStack->setItemText(idShapeItem, tr("&Shape")); - TabStack->setItemText(idLineItem, tr("&Line")); - TabStack->setItemText(idColorsItem, tr("&Colors")); - TabStack->setItemText(idTransparencyItem, tr("&Transparency")); + scXYZ->setText(tr("X, Y, &Z")); + scShadow->setText(tr("Drop Shadow")); + scShape->setText(tr("&Shape")); + scLine->setText(tr("&Line")); + scColor->setText(tr("&Colors")); + scTransparency->setText(tr("&Transparency")); xyzPal->languageChange(); shadowPal->languageChange(); Index: scribus/ui/propertiespalette.h =================================================================== --- scribus/ui/propertiespalette.h (Revision 25786) +++ scribus/ui/propertiespalette.h (Arbeitskopie) @@ -31,6 +31,7 @@ #include "stylecombos.h" #include "units.h" #include "docks/dock_panelbase.h" +#include "widgets/section_container.h" class ColorCombo; class ColorPalette; @@ -80,6 +81,7 @@ private: PageItem* currentItemFromSelection(); + void enablePalettes(bool enable); public slots: void setMainWindow(ScribusMainWindow *mw); @@ -98,20 +100,25 @@ void setLocked(bool); private slots: - void SelTab(int t); - void NewLineMode(int mode); + void newLineMode(int mode); 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 newSpGradient(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk, double cx, double cy); void toggleGradientEdit(int); - void NewSpGradientM(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk); + void newSpGradientM(double x1, double y1, double x2, double y2, double fx, double fy, double sg, double sk); void toggleGradientEditM(); void handleShapeEdit(); protected: - ScTreeWidget* TabStack {nullptr}; + SectionContainer * scXYZ {nullptr}; + SectionContainer * scShape {nullptr}; + SectionContainer * scLine {nullptr}; + SectionContainer * scColor {nullptr}; + SectionContainer * scTransparency {nullptr}; + SectionContainer * scShadow {nullptr}; + bool m_haveDoc {false}; bool m_haveItem {false}; double m_unitRatio {1.0}; @@ -121,15 +128,6 @@ UndoManager *undoManager {nullptr}; ScGuardedPtr<ScribusDoc> m_doc; - - int idXYZItem {0}; - int idShapeItem {0}; - int idTableItem {0}; - int idLineItem {0}; - int idColorsItem {0}; - int idTransparencyItem {0}; - int idGroupItem {0}; - int idShadowItem {0}; }; #endif Index: scribus/ui/propertiespalette_shadow.cpp =================================================================== --- scribus/ui/propertiespalette_shadow.cpp (Revision 25786) +++ scribus/ui/propertiespalette_shadow.cpp (Arbeitskopie) @@ -69,8 +69,20 @@ softShadowObjTrans = new PropTreeItem(this, PropTreeItem::CheckBox, tr( "Inherit Object\nTransparency")); softShadowObjTrans->setBoolValue(false); + setFrameShape(QFrame::NoFrame); + setSizePolicy( QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding)); + adjustSize(); + + int treeHeight = this->frameWidth()*2; + for( int i = 0; i < this->topLevelItemCount(); ++i ) + { + QTreeWidgetItem *item = this->topLevelItem( i ); + treeHeight += visualItemRect(item).height(); + } + setMinimumHeight(treeHeight); + languageChange(); - setSizePolicy( QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum)); + connect(this->model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(handleNewValues())); connect(ScQApp, SIGNAL(localeChanged()), this, SLOT(localeChange())); } Index: scribus/ui/propertiespalette_text.cpp =================================================================== --- scribus/ui/propertiespalette_text.cpp (Revision 25786) +++ scribus/ui/propertiespalette_text.cpp (Arbeitskopie) @@ -31,6 +31,7 @@ #include "propertywidget_orphans.h" #include "propertywidget_pareffect.h" #include "propertywidget_pathtext.h" +#include "propertywidget_text.h" #include "propertywidget_textcolor.h" #include "scribus.h" #include "scribusapp.h" @@ -38,69 +39,91 @@ #include "stylecombos.h" #include "undomanager.h" #include "langmgr.h" +#include "widgets/section_container.h" //using namespace std; PropertiesPalette_Text::PropertiesPalette_Text( QWidget* parent) : QWidget(parent) { - setupUi(this); - fontSize->setPrefix(""); - - iconSetChange(); + advancedWidgets = new PropertyWidget_Advanced(this); + scAdvanced = new SectionContainer(tr("Advanced Settings")); + scAdvanced->setWidget(advancedWidgets); + scAdvanced->setIsCollapsed(true); - colorWidgets = new PropertyWidget_TextColor(textTree); - colorWidgetsItem = textTree->addItem( colorWidgets, tr("Color && Effects") ); + distanceWidgets = new PropertyWidget_Distance(this); + scDistance = new SectionContainer(tr("Columns && Text Distances")); + scDistance->setWidget(distanceWidgets); + scDistance->setIsCollapsed(true); - flopBox = new PropertyWidget_Flop(textTree); - flopItem = textTree->addItem( flopBox, tr("First Line Offset")); + flopBox = new PropertyWidget_Flop(this); + scFlop = new SectionContainer(tr("First Line Offset")); + scFlop->setWidget(flopBox); + scFlop->setIsCollapsed(true); - orphanBox = new PropertyWidget_Orphans(textTree); - orphanItem = textTree->addItem(orphanBox, tr("Orphans and Widows")); + fontfeaturesWidget = new PropertyWidget_FontFeatures(this); + scFontFeatures = new SectionContainer(tr("Font Features")); + scFontFeatures->setWidget(fontfeaturesWidget); + scFontFeatures->setIsCollapsed(true); - parEffectWidgets = new PropertyWidget_ParEffect(textTree); - parEffectItem = textTree->addItem(parEffectWidgets, tr("Paragraph Effects")); + hyphenationWidget = new PropertyWidget_Hyphenation(this); + scHyphenation = new SectionContainer(tr("Hyphenation")); + scHyphenation->setWidget(hyphenationWidget); + scHyphenation->setIsCollapsed(true); - distanceWidgets = new PropertyWidget_Distance(textTree); - distanceItem = textTree->addItem(distanceWidgets, tr("Columns && Text Distances")); + optMargins = new PropertyWidget_OptMargins(this); + scOptMargins = new SectionContainer(tr("Optical Margins")); + scOptMargins->setWidget(optMargins); + scOptMargins->setIsCollapsed(true); - //<< Optical Margins - optMargins = new PropertyWidget_OptMargins(textTree); - optMarginsItem = textTree->addItem(optMargins, tr("Optical Margins")); - //>> Optical Margins + orphanBox = new PropertyWidget_Orphans(this); + scOrphans = new SectionContainer(tr("Orphans and Widows")); + scOrphans->setWidget(orphanBox); + scOrphans->setIsCollapsed(true); - hyphenationWidget = new PropertyWidget_Hyphenation(textTree); - hyphenationWidgetItem = textTree->addItem(hyphenationWidget, tr("Hyphenation")); + parEffectWidgets = new PropertyWidget_ParEffect(this); + scParEffect = new SectionContainer(tr("Paragraph Effects")); + scParEffect->setWidget(parEffectWidgets); + scParEffect->setIsCollapsed(true); - //<<Advanced Settings - advancedWidgets = new PropertyWidget_Advanced(textTree); - advancedWidgetsItem = textTree->addItem(advancedWidgets, tr("Advanced Settings")); + pathTextWidgets = new PropertyWidget_PathText(this); + scPathText = new SectionContainer(tr("Path Text Properties")); + scPathText->setWidget(pathTextWidgets); + scPathText->setIsCollapsed(true); - //>>Advanced Settings - fontfeaturesWidget = new PropertyWidget_FontFeatures(textTree); - fontfeaturesWidgetItem = textTree->addItem(fontfeaturesWidget, tr("Font Features")); + textWidgets = new PropertyWidget_Text(this); + scText = new SectionContainer(tr("Text")); + scText->setWidget(textWidgets); + scText->setIsCollapsed(false); - pathTextWidgets = new PropertyWidget_PathText(textTree); - pathTextItem = textTree->addItem(pathTextWidgets, tr("Path Text Properties")); + colorWidgets = new PropertyWidget_TextColor(this); + scTextColor = new SectionContainer(tr("Color && Effects")); + scTextColor->setWidget(colorWidgets); + scTextColor->setIsCollapsed(true); + // Layout stack + QVBoxLayout * lyt = new QVBoxLayout(); + lyt->setContentsMargins(0, 0, 0, 0); + lyt->setSpacing(0); + lyt->addWidget(scText); + lyt->addWidget(scTextColor); + lyt->addWidget(scFlop); + lyt->addWidget(scOrphans); + lyt->addWidget(scParEffect); + lyt->addWidget(scDistance); + lyt->addWidget(scOptMargins); + lyt->addWidget(scHyphenation); + lyt->addWidget(scAdvanced); + lyt->addWidget(scFontFeatures); + lyt->addWidget(scPathText); + lyt->addStretch(1); + setLayout(lyt); + + iconSetChange(); languageChange(); - connect(lineSpacing , SIGNAL(valueChanged(double)), this, SLOT(handleLineSpacing())); - connect(fonts , SIGNAL(fontSelected(QString)), this, SLOT(handleTextFont(QString))); - connect(fontSize , SIGNAL(valueChanged(double)), this, SLOT(handleFontSize())); - connect(textAlignment , SIGNAL(State(int)) , this, SLOT(handleAlignment(int))); - connect(textDirection , SIGNAL(State(int)) , this, SLOT(handleDirection(int))); - connect(charStyleClear, SIGNAL(clicked()), this, SLOT(doClearCStyle())); - connect(paraStyleClear, SIGNAL(clicked()), this, SLOT(doClearPStyle())); - connect(flopBox->flopGroup, SIGNAL(idClicked(int)), this, SLOT(handleFirstLinePolicy(int))); - connect(lineSpacingModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(handleLineSpacingMode(int))); - connect(langCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changeLang(int))); - - connect(fontfeaturesWidget, SIGNAL(needsRelayout()), this, SLOT(updateTreeLayout())); - connect(parEffectWidgets, SIGNAL(needsRelayout()), this, SLOT(updateTreeLayout())); - connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange())); connect(ScQApp, SIGNAL(localeChanged()), this, SLOT(localeChange())); @@ -111,6 +134,7 @@ { m_ScMW = mw; + textWidgets->setMainWindow(mw); advancedWidgets->setMainWindow(mw); fontfeaturesWidget->setMainWindow(mw); colorWidgets->setMainWindow(mw); @@ -122,8 +146,6 @@ connect(m_ScMW, SIGNAL(UpdateRequest(int)) , this , SLOT(handleUpdateRequest(int))); - connect(paraStyleCombo, SIGNAL(newStyle(QString)), m_ScMW, SLOT(setNewParStyle(QString)), Qt::UniqueConnection); - connect(charStyleCombo, SIGNAL(newStyle(QString)), m_ScMW, SLOT(setNewCharStyle(QString)), Qt::UniqueConnection); } void PropertiesPalette_Text::setDoc(ScribusDoc *d) @@ -146,9 +168,7 @@ m_haveDoc = true; m_haveItem = false; - fontSize->setValues(0.5, 2048, 2, 1); - lineSpacing->setValues(1, 2048, 2, 1); - + textWidgets->setDoc(m_doc); advancedWidgets->setDoc(m_doc); fontfeaturesWidget->setDoc(m_doc); colorWidgets->setDoc(m_doc); @@ -160,10 +180,6 @@ orphanBox->setDoc(m_doc); pathTextWidgets->setDoc(m_doc); - fonts->rebuildList(m_doc); - paraStyleCombo->setDoc(m_doc); - charStyleCombo->setDoc(m_doc); - connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); } @@ -181,9 +197,7 @@ m_doc = nullptr; m_item = nullptr; - paraStyleCombo->setDoc(nullptr); - charStyleCombo->setDoc(nullptr); - + textWidgets->setDoc(nullptr); advancedWidgets->setDoc(nullptr); fontfeaturesWidget->setDoc(nullptr); colorWidgets->setDoc(nullptr); @@ -195,8 +209,6 @@ parEffectWidgets->setDoc(nullptr); pathTextWidgets->setDoc(nullptr); - m_haveItem = false; - setEnabled(false); } @@ -272,21 +284,24 @@ // ColorWidget will handle its update itself /*if (updateFlags & reqColorsUpdate) updateColorList();*/ + + textWidgets->handleUpdateRequest(updateFlags); + if (updateFlags & reqCharStylesUpdate) { - charStyleCombo->updateStyleList(); +// charStyleCombo->updateStyleList(); parEffectWidgets->updateCharStyles(); } - if (updateFlags & reqParaStylesUpdate) - paraStyleCombo->updateStyleList(); - if (updateFlags & reqDefFontListUpdate) - fonts->rebuildList(nullptr); - if (updateFlags & reqDocFontListUpdate) - fonts->rebuildList(m_haveDoc ? m_doc : nullptr); +// if (updateFlags & reqParaStylesUpdate) +// paraStyleCombo->updateStyleList(); +// if (updateFlags & reqDefFontListUpdate) +// fonts->rebuildList(nullptr); +// if (updateFlags & reqDocFontListUpdate) +// fonts->rebuildList(m_haveDoc ? m_doc : nullptr); if (updateFlags & reqStyleComboDocUpdate) { - paraStyleCombo->setDoc(m_haveDoc ? m_doc : nullptr); - charStyleCombo->setDoc(m_haveDoc ? m_doc : nullptr); +// paraStyleCombo->setDoc(m_haveDoc ? m_doc : nullptr); +// charStyleCombo->setDoc(m_haveDoc ? m_doc : nullptr); parEffectWidgets->setDoc(m_haveDoc ? m_doc : nullptr); } } @@ -343,17 +358,7 @@ void PropertiesPalette_Text::iconSetChange() { - IconManager& iconManager = IconManager::instance(); - - fontSizeLabel->setPixmap(iconManager.loadPixmap("zeichen.png")); - lineSpacingLabel->setPixmap(iconManager.loadPixmap("linespacing2.png")); - textAlignmentLabel->setPixmap(iconManager.loadPixmap("22/text-align.png")); - langLabel->setPixmap(iconManager.loadPixmap("22/language.png")); - paraStyleLabel->setPixmap(iconManager.loadPixmap("22/paragraph-style.png")); - charStyleLabel->setPixmap(iconManager.loadPixmap("22/character-style.png")); - - paraStyleClear->setIcon(iconManager.loadPixmap("16/edit-clear.png")); - charStyleClear->setIcon(iconManager.loadPixmap("16/edit-clear.png")); + textWidgets->iconSetChange(); } void PropertiesPalette_Text::unitChange() @@ -371,6 +376,7 @@ optMargins->unitChange(); pathTextWidgets->unitChange(); parEffectWidgets->unitChange(); + textWidgets->unitChange(); m_haveItem = tmp; } @@ -377,9 +383,7 @@ void PropertiesPalette_Text::localeChange() { - const QLocale& l(LocaleManager::instance().userPreferredLocale()); - fontSize->setLocale(l); - lineSpacing->setLocale(l); + textWidgets->localeChange(); advancedWidgets->localeChange(); colorWidgets->localeChange(); distanceWidgets->localeChange(); @@ -387,76 +391,14 @@ pathTextWidgets->localeChange(); } -void PropertiesPalette_Text::handleLineSpacingMode(int id) -{ - if (!m_haveDoc || !m_haveItem) - return; - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_SetLineSpacingMode(id, &tempSelection); -// updateStyle(((m_doc->appMode == modeEdit) || (m_doc->appMode == modeEditTable)) ? m_item->currentStyle() : m_item->itemText.defaultStyle()); - m_doc->regionsChanged()->update(QRect()); -} - -void PropertiesPalette_Text::changeLang(int id) -{ - if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) - return; - QStringList languageList; - LanguageManager::instance()->fillInstalledStringList(&languageList); - QString abrv = LanguageManager::instance()->getAbbrevFromLang(languageList.value(id),false); - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_SetLanguage(abrv, &tempSelection); -} - -void PropertiesPalette_Text::showLineSpacing(double r) -{ - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - bool inEditMode = (m_doc->appMode == modeEdit || m_doc->appMode == modeEditTable); - bool tmp = m_haveItem; - m_haveItem = false; - lineSpacing->showValue(r); - const ParagraphStyle& curStyle(m_haveItem && inEditMode ? m_item->currentStyle() : m_item->itemText.defaultStyle()); - if (tmp) - { - setupLineSpacingSpinbox(curStyle.lineSpacingMode(), r); - lineSpacingModeCombo->setCurrentIndex(curStyle.lineSpacingMode()); - } - m_haveItem = tmp; -} - -void PropertiesPalette_Text::showFontFace(const QString& newFont) -{ - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - bool tmp = m_haveItem; - m_haveItem = false; - if (m_item != nullptr) - fonts->rebuildList(m_doc, m_item->isAnnotation()); - fonts->setCurrentFont(newFont); - m_haveItem = tmp; -} - void PropertiesPalette_Text::showFontSize(double s) { - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - fontSize->showValue(s / 10.0); + textWidgets->showFontSize(s); } void PropertiesPalette_Text::showLanguage(const QString& w) { - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - QStringList lang; - LanguageManager::instance()->fillInstalledStringList(&lang); - QString langName = LanguageManager::instance()->getLangFromAbbrev(w, true); - - bool sigBlocked = langCombo->blockSignals(true); - langCombo->setCurrentIndex(lang.indexOf(langName)); - langCombo->blockSignals(sigBlocked); + textWidgets->showLanguage(w); } void PropertiesPalette_Text::showFirstLinePolicy( FirstLineOffsetPolicy f ) @@ -471,29 +413,6 @@ flopBox->flopBaselineGrid->setChecked(true); } -void PropertiesPalette_Text::setupLineSpacingSpinbox(int mode, double value) -{ - bool blocked = lineSpacing->blockSignals(true); - if (mode > 0) - { - if (mode == 1) - lineSpacing->setSpecialValueText( tr( "Auto" ) ); - if (mode == 2) - lineSpacing->setSpecialValueText( tr( "Baseline" ) ); - lineSpacing->setMinimum(0); - lineSpacing->setValue(0); - lineSpacing->setEnabled(false); - } - else - { - lineSpacing->setSpecialValueText(""); - lineSpacing->setMinimum(1); - lineSpacing->setValue(value); - lineSpacing->setEnabled(true); - } - lineSpacing->blockSignals(blocked); -} - void PropertiesPalette_Text::updateCharStyle(const CharStyle& charStyle) { if (!m_ScMW || m_ScMW->scriptIsRunning()) @@ -503,10 +422,7 @@ fontfeaturesWidget->updateCharStyle(charStyle); colorWidgets->updateCharStyle(charStyle); hyphenationWidget->updateCharStyle(charStyle); - - showFontFace(charStyle.font().scName()); - showFontSize(charStyle.fontSize()); - showLanguage(charStyle.language()); + textWidgets->updateCharStyle(charStyle); } void PropertiesPalette_Text::updateStyle(const ParagraphStyle& newCurrent) @@ -514,8 +430,6 @@ if (!m_ScMW || m_ScMW->scriptIsRunning()) return; - const CharStyle& charStyle = newCurrent.charStyle(); - advancedWidgets->updateStyle(newCurrent); fontfeaturesWidget->updateStyle(newCurrent); colorWidgets->updateStyle(newCurrent); @@ -523,202 +437,36 @@ orphanBox->updateStyle (newCurrent); parEffectWidgets->updateStyle(newCurrent); hyphenationWidget->updateStyle(newCurrent); - - showFontFace(charStyle.font().scName()); - showFontSize(charStyle.fontSize()); - showLanguage(charStyle.language()); - - if (m_item) - { - QString defaultParStyle = m_item->itemText.defaultStyle().parent(); - if (defaultParStyle.isEmpty()) - defaultParStyle = CommonStrings::DefaultParagraphStyle; - paraStyleCombo->setDefaultStyle(defaultParStyle); - } - showParStyle(newCurrent.parent()); - - if (m_item) - { - QString defaultCharStyle; - if (!newCurrent.parent().isEmpty()) - { - const ParagraphStyle* paraStyle = m_doc->paragraphStyles().getPointer(newCurrent.parent()); - if (paraStyle) - defaultCharStyle = paraStyle->charStyle().parent(); - if (defaultCharStyle.isEmpty()) - defaultCharStyle = CommonStrings::DefaultCharacterStyle; - } - if (defaultCharStyle.isEmpty()) - defaultCharStyle = m_item->itemText.defaultStyle().charStyle().parent(); - if (defaultCharStyle.isEmpty()) - defaultCharStyle = CommonStrings::DefaultCharacterStyle; - charStyleCombo->setDefaultStyle(defaultCharStyle); - } - showCharStyle(charStyle.parent()); - - bool tmp = m_haveItem; - m_haveItem = false; - - setupLineSpacingSpinbox(newCurrent.lineSpacingMode(), newCurrent.lineSpacing()); - lineSpacingModeCombo->setCurrentIndex(newCurrent.lineSpacingMode()); - textAlignment->setStyle(newCurrent.alignment(), newCurrent.direction()); - textDirection->setStyle(newCurrent.direction()); - - m_haveItem = tmp; + textWidgets->updateStyle(newCurrent); } void PropertiesPalette_Text::updateCharStyles() { - charStyleCombo->updateStyleList(); + textWidgets->updateCharStyles(); parEffectWidgets->updateCharStyles(); } void PropertiesPalette_Text::updateParagraphStyles() { - paraStyleCombo->updateStyleList(); - charStyleCombo->updateStyleList(); + textWidgets->updateParagraphStyles(); parEffectWidgets->updateCharStyles(); } void PropertiesPalette_Text::updateTextStyles() { - paraStyleCombo->updateStyleList(); - charStyleCombo->updateStyleList(); + textWidgets->updateTextStyles(); } -void PropertiesPalette_Text::updateTreeLayout() -{ - textTree->doItemsLayout(); -} - void PropertiesPalette_Text::showAlignment(int e) { - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - bool tmp = m_haveItem; - m_haveItem = false; - textAlignment->setEnabled(true); - textAlignment->setStyle(e, textDirection->getStyle()); - m_haveItem = tmp; + textWidgets->showAlignment(e); } void PropertiesPalette_Text::showDirection(int e) { - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - bool tmp = m_haveItem; - m_haveItem = false; - textDirection->setEnabled(true); - textDirection->setStyle(e); - m_haveItem = tmp; + textWidgets->showDirection(e); } -void PropertiesPalette_Text::showCharStyle(const QString& name) -{ - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - bool blocked = charStyleCombo->blockSignals(true); - charStyleCombo->setStyle(name); - charStyleCombo->blockSignals(blocked); -} - -void PropertiesPalette_Text::showParStyle(const QString& name) -{ - if (!m_ScMW || m_ScMW->scriptIsRunning()) - return; - bool blocked = paraStyleCombo->blockSignals(true); - paraStyleCombo->setStyle(name); - paraStyleCombo->blockSignals(blocked); -} - -void PropertiesPalette_Text::handleLineSpacing() -{ - if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) - return; - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_SetLineSpacing(lineSpacing->value(), &tempSelection); -} - -void PropertiesPalette_Text::handleFontSize() -{ - if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) - return; - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_SetFontSize(qRound(fontSize->value()*10.0), &tempSelection); -} - -void PropertiesPalette_Text::handleAlignment(int a) -{ - if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) - return; - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_SetAlignment(a, &tempSelection); - if (m_item->isPathText()) - pathTextWidgets->handleSelectionChanged(); -} - -void PropertiesPalette_Text::handleDirection(int d) -{ - if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) - return; - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_SetDirection(d, &tempSelection); - // If current text alignment is left or right, change it to match direction - if (d == ParagraphStyle::RTL && textAlignment->selectedId() == ParagraphStyle::LeftAligned) - { - m_doc->itemSelection_SetAlignment(ParagraphStyle::RightAligned, &tempSelection); - textAlignment->setTypeStyle(ParagraphStyle::RightAligned); - } - else if (d == ParagraphStyle::LTR && textAlignment->selectedId() == ParagraphStyle::RightAligned) - { - m_doc->itemSelection_SetAlignment(ParagraphStyle::LeftAligned, &tempSelection); - textAlignment->setTypeStyle(ParagraphStyle::LeftAligned); - } -} - -void PropertiesPalette_Text::handleTextFont(const QString& font) -{ - if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) - return; - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_SetFont(font, &tempSelection); -} - -void PropertiesPalette_Text::doClearCStyle() -{ - if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveDoc || !m_haveItem) - return; - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_EraseCharStyle(&tempSelection); -} - - -void PropertiesPalette_Text::doClearPStyle() -{ - if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveDoc || !m_haveItem) - return; - - UndoTransaction activeTransaction; - if (UndoManager::undoEnabled()) - activeTransaction = UndoManager::instance()->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::RemoveTextStyle, tr( "remove direct paragraph formatting" ), Um::IFont); - - Selection tempSelection(this, false); - tempSelection.addItem(m_item, true); - m_doc->itemSelection_ClearBulNumStrings(&tempSelection); - m_doc->itemSelection_EraseParagraphStyle(&tempSelection); - CharStyle emptyCStyle; - m_doc->itemSelection_SetCharStyle(emptyCStyle, &tempSelection); - - if (activeTransaction) - activeTransaction.commit(); -} - void PropertiesPalette_Text::updateColorList() { if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning()) @@ -739,35 +487,18 @@ void PropertiesPalette_Text::languageChange() { - retranslateUi(this); + scAdvanced->setText(tr("Advanced Settings")); + scDistance->setText(tr("Columns && Text Distances")); + scFlop->setText(tr("First Line Offset")); + scFontFeatures->setText(tr("Font Features")); + scHyphenation->setText(tr("Hyphenation")); + scOptMargins->setText(tr("Optical Margins")); + scOrphans->setText(tr("Orphans and Widows")); + scParEffect->setText(tr("Paragraph Effects")); + scPathText->setText(tr("Path Text Properties")); + scText->setText(tr("Text")); + scTextColor->setText(tr("Color && Effects")); - textTree->setItemText(colorWidgetsItem, tr("Color && Effects")); - textTree->setItemText(flopItem, tr("First Line Offset")); - textTree->setItemText(hyphenationWidgetItem, tr("Hyphenation")); - textTree->setItemText(orphanItem, tr("Orphans and Widows")); - textTree->setItemText(parEffectItem, tr("Paragraph Effects")); - textTree->setItemText(distanceItem, tr("Columns && Text Distances")); - textTree->setItemText(optMarginsItem, tr("Optical Margins")); - textTree->setItemText(advancedWidgetsItem, tr("Advanced Settings")); - textTree->setItemText(fontfeaturesWidgetItem, tr("Font Features")); - textTree->setItemText(pathTextItem, tr("Path Text Properties")); - - QSignalBlocker lineSpacingModeBlocker(lineSpacingModeCombo); - int oldLineSpacingMode = lineSpacingModeCombo->currentIndex(); - lineSpacingModeCombo->clear(); - lineSpacingModeCombo->addItem( tr("Fixed Linespacing")); - lineSpacingModeCombo->addItem( tr("Automatic Linespacing")); - lineSpacingModeCombo->addItem( tr("Align to Baseline Grid")); - lineSpacingModeCombo->setCurrentIndex(oldLineSpacingMode); - - QSignalBlocker langComboBlocker(langCombo); - QStringList languageList; - LanguageManager::instance()->fillInstalledStringList(&languageList); - int oldLang = langCombo->currentIndex(); - langCombo->clear(); - langCombo->addItems(languageList); - langCombo->setCurrentIndex(oldLang); - colorWidgets->languageChange(); flopBox->languageChange(); orphanBox->languageChange(); @@ -777,9 +508,7 @@ pathTextWidgets->languageChange(); fontfeaturesWidget->languageChange(); hyphenationWidget->languageChange(); - - textAlignment->languageChange(); - textDirection->languageChange(); + textWidgets->languageChange(); } void PropertiesPalette_Text::handleFirstLinePolicy(int radioFlop) Index: scribus/ui/propertiespalette_text.h =================================================================== --- scribus/ui/propertiespalette_text.h (Revision 25786) +++ scribus/ui/propertiespalette_text.h (Arbeitskopie) @@ -7,8 +7,6 @@ #ifndef PROPERTIESPALETTE_TEXT_H #define PROPERTIESPALETTE_TEXT_H -#include "ui_propertiespalette_textbase.h" - #include "scribusapi.h" #include "scrpalettebase.h" #include "scrspinbox.h" @@ -27,12 +25,14 @@ class PropertyWidget_OptMargins; class PropertyWidget_Orphans; class PropertyWidget_PathText; +class PropertyWidget_Text; class PropertyWidget_TextColor; +class SectionContainer; class ScribusDoc; class ScribusMainWindow; class Selection; -class SCRIBUS_API PropertiesPalette_Text : public QWidget, public Ui::PropertiesPalette_TextBase +class SCRIBUS_API PropertiesPalette_Text : public QWidget { Q_OBJECT @@ -76,43 +76,23 @@ void languageChange(); void unitChange(); void localeChange(); - void changeLang(int id); void showAlignment(int e); void showDirection(int e); - void showCharStyle(const QString& name); - void showFontFace(const QString&); void showFontSize(double s); void showLanguage(const QString& w); void showFirstLinePolicy(FirstLineOffsetPolicy); - void showLineSpacing(double r); - void showParStyle(const QString& name); - - void setupLineSpacingSpinbox(int mode, double value); - + /// update TB values: void updateCharStyle(const CharStyle& charStyle); - void updateStyle(const ParagraphStyle& newCurrent); - + void updateStyle(const ParagraphStyle& newCurrent); void updateCharStyles(); void updateParagraphStyles(); - void updateTextStyles(); - - void handleLineSpacingMode(int id); - void handleTextFont(const QString&); + void updateTextStyles(); - // update widget layout - void updateTreeLayout(); +private slots: -private slots: - void handleAlignment(int a); - void handleDirection(int d); void handleFirstLinePolicy(int); - void handleFontSize(); - void handleLineSpacing(); - - void doClearCStyle(); - void doClearPStyle(); protected: PropertyWidget_Advanced* advancedWidgets; @@ -124,18 +104,20 @@ PropertyWidget_Orphans* orphanBox; PropertyWidget_ParEffect* parEffectWidgets; PropertyWidget_PathText* pathTextWidgets; + PropertyWidget_Text* textWidgets; PropertyWidget_TextColor* colorWidgets; - int advancedWidgetsItem; - int colorWidgetsItem; - int distanceItem; - int flopItem; - int fontfeaturesWidgetItem; - int hyphenationWidgetItem; - int optMarginsItem; - int orphanItem; - int parEffectItem; - int pathTextItem; + SectionContainer * scAdvanced = {nullptr}; + SectionContainer * scDistance = {nullptr}; + SectionContainer * scFlop = {nullptr}; + SectionContainer * scFontFeatures = {nullptr}; + SectionContainer * scHyphenation = {nullptr}; + SectionContainer * scOptMargins = {nullptr}; + SectionContainer * scOrphans = {nullptr}; + SectionContainer * scParEffect = {nullptr}; + SectionContainer * scPathText = {nullptr}; + SectionContainer * scText = {nullptr}; + SectionContainer * scTextColor = {nullptr}; }; Index: scribus/ui/propertiespalette_textbase.ui =================================================================== --- scribus/ui/propertiespalette_textbase.ui (Revision 25786) +++ scribus/ui/propertiespalette_textbase.ui (nicht existent) @@ -1,370 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>PropertiesPalette_TextBase</class> - <widget class="QWidget" name="PropertiesPalette_TextBase"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>308</width> - <height>390</height> - </rect> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="spacing"> - <number>3</number> - </property> - <property name="leftMargin"> - <number>3</number> - </property> - <property name="topMargin"> - <number>3</number> - </property> - <property name="rightMargin"> - <number>3</number> - </property> - <property name="bottomMargin"> - <number>3</number> - </property> - <item> - <widget class="FontComboH" name="fonts" native="true"/> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <property name="spacing"> - <number>3</number> - </property> - <item> - <widget class="QLabel" name="fontSizeLabel"> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>22</width> - <height>22</height> - </size> - </property> - <property name="text"> - <string/> - </property> - <property name="alignment"> - <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> - </property> - </widget> - </item> - <item> - <widget class="ScrSpinBox" name="fontSize"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip"> - <string>Font Size</string> - </property> - <property name="suffix"> - <string> pt</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_2"> - <property name="spacing"> - <number>3</number> - </property> - <item> - <widget class="QLabel" name="lineSpacingLabel"> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>22</width> - <height>22</height> - </size> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="lineSpacingModeCombo"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip"> - <string>Select the line spacing mode</string> - </property> - </widget> - </item> - <item> - <widget class="ScrSpinBox" name="lineSpacing"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip"> - <string>Line Spacing</string> - </property> - <property name="suffix"> - <string> pt</string> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_5"> - <property name="spacing"> - <number>3</number> - </property> - <item> - <widget class="QLabel" name="textAlignmentLabel"> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>22</width> - <height>22</height> - </size> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="AlignSelect" name="textAlignment" native="true"/> - </item> - <item alignment="Qt::AlignLeft"> - <widget class="DirectionSelect" name="textDirection" native="true"/> - </item> - <item> - <spacer name="horizontalSpacer_2"> - <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> - <layout class="QHBoxLayout" name="horizontalLayout_6"> - <property name="spacing"> - <number>3</number> - </property> - <item> - <widget class="QLabel" name="langLabel"> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>22</width> - <height>22</height> - </size> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="QComboBox" name="langCombo"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip"> - <string>Text Language</string> - </property> - <property name="editable"> - <bool>true</bool> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_3"> - <property name="spacing"> - <number>3</number> - </property> - <item> - <widget class="QLabel" name="paraStyleLabel"> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>22</width> - <height>22</height> - </size> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="ParaStyleComboBox" name="paraStyleCombo"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip"> - <string>Paragraph style of currently selected text or paragraph</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="paraStyleClear"> - <property name="toolTip"> - <string>Remove Direct Paragraph Formatting</string> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <layout class="QHBoxLayout" name="horizontalLayout_4"> - <property name="spacing"> - <number>3</number> - </property> - <item> - <widget class="QLabel" name="charStyleLabel"> - <property name="minimumSize"> - <size> - <width>20</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>22</width> - <height>22</height> - </size> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - <item> - <widget class="CharStyleComboBox" name="charStyleCombo"> - <property name="sizePolicy"> - <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="toolTip"> - <string>Character style of currently selected text or paragraph</string> - </property> - </widget> - </item> - <item> - <widget class="QToolButton" name="charStyleClear"> - <property name="toolTip"> - <string>Remove Direct Character Formatting</string> - </property> - <property name="text"> - <string/> - </property> - </widget> - </item> - </layout> - </item> - <item> - <widget class="ScTreeWidget" name="textTree"> - <column> - <property name="text"> - <string notr="true">1</string> - </property> - </column> - </widget> - </item> - </layout> - </widget> - <customwidgets> - <customwidget> - <class>ScrSpinBox</class> - <extends>QDoubleSpinBox</extends> - <header>ui/scrspinbox.h</header> - </customwidget> - <customwidget> - <class>FontComboH</class> - <extends>QWidget</extends> - <header>ui/fontcombo.h</header> - <container>1</container> - </customwidget> - <customwidget> - <class>CharStyleComboBox</class> - <extends>QComboBox</extends> - <header>ui/stylecombos.h</header> - </customwidget> - <customwidget> - <class>ScTreeWidget</class> - <extends>QTreeWidget</extends> - <header>ui/sctreewidget.h</header> - </customwidget> - <customwidget> - <class>ParaStyleComboBox</class> - <extends>QComboBox</extends> - <header>ui/stylecombos.h</header> - </customwidget> - <customwidget> - <class>AlignSelect</class> - <extends>QWidget</extends> - <header>ui/alignselect.h</header> - <container>1</container> - </customwidget> - <customwidget> - <class>DirectionSelect</class> - <extends>QWidget</extends> - <header>ui/directionselect.h</header> - <container>1</container> - </customwidget> - </customwidgets> - <resources/> - <connections/> -</ui> Index: scribus/ui/propertywidget_text.cpp =================================================================== --- scribus/ui/propertywidget_text.cpp (nicht existent) +++ scribus/ui/propertywidget_text.cpp (Arbeitskopie) @@ -0,0 +1,574 @@ +/* +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 "propertywidget_text.h" +#include "ui_propertywidget_textbase.h" + +#include "appmodes.h" +#include "commonstrings.h" +#include "fontcombo.h" +#include "iconmanager.h" +#include "localemgr.h" +#include "pageitem.h" +#include "pageitem_table.h" +#include "pageitem_textframe.h" +#include "scribus.h" +#include "scribusapp.h" +#include "selection.h" +#include "stylecombos.h" +#include "undomanager.h" +#include "langmgr.h" + + +PropertyWidget_Text::PropertyWidget_Text( QWidget* parent) : QFrame(parent) +{ + setupUi(this); + + fontSize->setPrefix(""); + + iconSetChange(); + languageChange(); + + connect(lineSpacing , SIGNAL(valueChanged(double)), this, SLOT(handleLineSpacing())); + connect(fonts , SIGNAL(fontSelected(QString)), this, SLOT(handleTextFont(QString))); + connect(fontSize , SIGNAL(valueChanged(double)), this, SLOT(handleFontSize())); + connect(textAlignment , SIGNAL(State(int)) , this, SLOT(handleAlignment(int))); + connect(textDirection , SIGNAL(State(int)) , this, SLOT(handleDirection(int))); + connect(charStyleClear, SIGNAL(clicked()), this, SLOT(doClearCStyle())); + connect(paraStyleClear, SIGNAL(clicked()), this, SLOT(doClearPStyle())); + + connect(lineSpacingModeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(handleLineSpacingMode(int))); + connect(langCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(changeLang(int))); + +// connect(ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange())); +// connect(ScQApp, SIGNAL(localeChanged()), this, SLOT(localeChange())); + + setEnabled(false); +} + +void PropertyWidget_Text::setMainWindow(ScribusMainWindow* mw) +{ + m_ScMW = mw; + +// connect(m_ScMW, SIGNAL(UpdateRequest(int)) , this , SLOT(handleUpdateRequest(int))); + + connect(paraStyleCombo, SIGNAL(newStyle(QString)), m_ScMW, SLOT(setNewParStyle(QString)), Qt::UniqueConnection); + connect(charStyleCombo, SIGNAL(newStyle(QString)), m_ScMW, SLOT(setNewCharStyle(QString)), Qt::UniqueConnection); +} + +void PropertyWidget_Text::setDoc(ScribusDoc *d) +{ + 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 = nullptr; + m_haveDoc = true; + m_haveItem = false; + + fontSize->setValues(0.5, 2048, 2, 1); + lineSpacing->setValues(1, 2048, 2, 1); + + fonts->rebuildList(m_doc); + paraStyleCombo->setDoc(m_doc); + charStyleCombo->setDoc(m_doc); + + if (m_doc.isNull()) + { + return; + } + + connect(m_doc->m_Selection, SIGNAL(selectionChanged()), this, SLOT(handleSelectionChanged())); + connect(m_doc , SIGNAL(docChanged()) , this, SLOT(handleSelectionChanged())); +} + +PageItem* PropertyWidget_Text::currentItemFromSelection() +{ + PageItem *currentItem = nullptr; + + if (m_doc) + { + if (m_doc->m_Selection->count() > 1) + currentItem = m_doc->m_Selection->itemAt(0); + else if (m_doc->m_Selection->count() == 1) + currentItem = m_doc->m_Selection->itemAt(0); + if (currentItem && currentItem->isTable() && m_doc->appMode == modeEditTable) + currentItem = currentItem->asTable()->activeCell().textFrame(); + } + + return currentItem; +} + +void PropertyWidget_Text::handleSelectionChanged() +{ + if (!m_haveDoc || !m_ScMW || m_ScMW->scriptIsRunning()) + return; + + PageItem* currItem = currentItemFromSelection(); + if (m_doc->m_Selection->count() > 1) + { + setEnabled(false); + } + else + { + int itemType = currItem ? (int) currItem->itemType() : -1; + m_haveItem = (itemType != -1); + + switch (itemType) + { + case -1: + m_haveItem = false; + m_item = nullptr; + setEnabled(false); + break; + case PageItem::TextFrame: + case PageItem::PathText: + setEnabled(true); + break; + case PageItem::Table: + setEnabled(m_doc->appMode == modeEditTable); + break; + default: + setEnabled(false); + break; + } + } + if (currItem) + { + setCurrentItem(currItem); + } + updateGeometry(); +} + +void PropertyWidget_Text::handleUpdateRequest(int updateFlags) +{ + // ColorWidget will handle its update itself + /*if (updateFlags & reqColorsUpdate) + updateColorList();*/ + if (updateFlags & reqCharStylesUpdate) + { + charStyleCombo->updateStyleList(); + } + if (updateFlags & reqParaStylesUpdate) + paraStyleCombo->updateStyleList(); + if (updateFlags & reqDefFontListUpdate) + fonts->rebuildList(nullptr); + if (updateFlags & reqDocFontListUpdate) + fonts->rebuildList(m_haveDoc ? m_doc : nullptr); + if (updateFlags & reqStyleComboDocUpdate) + { + paraStyleCombo->setDoc(m_haveDoc ? m_doc : nullptr); + charStyleCombo->setDoc(m_haveDoc ? m_doc : nullptr); + } +} + +void PropertyWidget_Text::setCurrentItem(PageItem *item) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + //CB We shouldn't 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 won't work until when a canvas deselect happens, m_item must be nullptr. + //if (m_item == i) + // return; + + if (!m_doc) + setDoc(item->doc()); + + m_haveItem = false; + m_item = item; + + if ((m_item->isGroup()) && (!m_item->isSingleSel)) + { + setEnabled(false); + } + + m_haveItem = true; + + + if (m_item->isTextFrame() || m_item->isPathText() || m_item->isTable()) + { + ParagraphStyle parStyle = m_item->itemText.defaultStyle(); + if (m_doc->appMode == modeEdit || m_doc->appMode == modeEditTable) + m_item->currentTextProps(parStyle); + updateStyle(parStyle); + } + if (m_item->isOSGFrame()) + { + setEnabled(false); + } + if (m_item->asSymbol()) + { + setEnabled(false); + } +} + +void PropertyWidget_Text::iconSetChange() +{ + IconManager& iconManager = IconManager::instance(); + + fontSizeLabel->setPixmap(iconManager.loadPixmap("zeichen.png")); + lineSpacingLabel->setPixmap(iconManager.loadPixmap("linespacing2.png")); + textAlignmentLabel->setPixmap(iconManager.loadPixmap("22/text-align.png")); + langLabel->setPixmap(iconManager.loadPixmap("22/language.png")); + paraStyleLabel->setPixmap(iconManager.loadPixmap("22/paragraph-style.png")); + charStyleLabel->setPixmap(iconManager.loadPixmap("22/character-style.png")); + + paraStyleClear->setIcon(iconManager.loadPixmap("16/edit-clear.png")); + charStyleClear->setIcon(iconManager.loadPixmap("16/edit-clear.png")); +} + + +void PropertyWidget_Text::localeChange() +{ + const QLocale& l(LocaleManager::instance().userPreferredLocale()); + fontSize->setLocale(l); + lineSpacing->setLocale(l); +} + +void PropertyWidget_Text::handleLineSpacingMode(int id) +{ + if (!m_haveDoc || !m_haveItem) + return; + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_SetLineSpacingMode(id, &tempSelection); + updateStyle(((m_doc->appMode == modeEdit) || (m_doc->appMode == modeEditTable)) ? m_item->currentStyle() : m_item->itemText.defaultStyle()); + m_doc->regionsChanged()->update(QRect()); +} + +void PropertyWidget_Text::changeLang(int id) +{ + if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) + return; + QStringList languageList; + LanguageManager::instance()->fillInstalledStringList(&languageList); + QString abrv = LanguageManager::instance()->getAbbrevFromLang(languageList.value(id),false); + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_SetLanguage(abrv, &tempSelection); +} + +void PropertyWidget_Text::showLineSpacing(double r) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + bool inEditMode = (m_doc->appMode == modeEdit || m_doc->appMode == modeEditTable); + bool tmp = m_haveItem; + m_haveItem = false; + lineSpacing->showValue(r); + const ParagraphStyle& curStyle(m_haveItem && inEditMode ? m_item->currentStyle() : m_item->itemText.defaultStyle()); + if (tmp) + { + setupLineSpacingSpinbox(curStyle.lineSpacingMode(), r); + lineSpacingModeCombo->setCurrentIndex(curStyle.lineSpacingMode()); + } + m_haveItem = tmp; +} + +void PropertyWidget_Text::showFontFace(const QString& newFont) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + bool tmp = m_haveItem; + m_haveItem = false; + if (m_item != nullptr) + fonts->rebuildList(m_doc, m_item->isAnnotation()); + fonts->setCurrentFont(newFont); + m_haveItem = tmp; +} + +void PropertyWidget_Text::showFontSize(double s) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + fontSize->showValue(s / 10.0); +} + +void PropertyWidget_Text::showLanguage(const QString& w) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + QStringList lang; + LanguageManager::instance()->fillInstalledStringList(&lang); + QString langName = LanguageManager::instance()->getLangFromAbbrev(w, true); + + bool sigBlocked = langCombo->blockSignals(true); + langCombo->setCurrentIndex(lang.indexOf(langName)); + langCombo->blockSignals(sigBlocked); +} + +void PropertyWidget_Text::setupLineSpacingSpinbox(int mode, double value) +{ + bool blocked = lineSpacing->blockSignals(true); + if (mode > 0) + { + if (mode == 1) + lineSpacing->setSpecialValueText( tr( "Auto" ) ); + if (mode == 2) + lineSpacing->setSpecialValueText( tr( "Baseline" ) ); + lineSpacing->setMinimum(0); + lineSpacing->setValue(0); + lineSpacing->setEnabled(false); + } + else + { + lineSpacing->setSpecialValueText(""); + lineSpacing->setMinimum(1); + lineSpacing->setValue(value); + lineSpacing->setEnabled(true); + } + lineSpacing->blockSignals(blocked); +} + +void PropertyWidget_Text::updateCharStyle(const CharStyle& charStyle) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + + showFontFace(charStyle.font().scName()); + showFontSize(charStyle.fontSize()); + showLanguage(charStyle.language()); +} + +void PropertyWidget_Text::updateStyle(const ParagraphStyle& newCurrent) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + + const CharStyle& charStyle = newCurrent.charStyle(); + + showFontFace(charStyle.font().scName()); + showFontSize(charStyle.fontSize()); + showLanguage(charStyle.language()); + + if (m_item) + { + QString defaultParStyle = m_item->itemText.defaultStyle().parent(); + if (defaultParStyle.isEmpty()) + defaultParStyle = CommonStrings::DefaultParagraphStyle; + paraStyleCombo->setDefaultStyle(defaultParStyle); + } + showParStyle(newCurrent.parent()); + + if (m_item) + { + QString defaultCharStyle; + if (!newCurrent.parent().isEmpty()) + { + const ParagraphStyle* paraStyle = m_doc->paragraphStyles().getPointer(newCurrent.parent()); + if (paraStyle) + defaultCharStyle = paraStyle->charStyle().parent(); + if (defaultCharStyle.isEmpty()) + defaultCharStyle = CommonStrings::DefaultCharacterStyle; + } + if (defaultCharStyle.isEmpty()) + defaultCharStyle = m_item->itemText.defaultStyle().charStyle().parent(); + if (defaultCharStyle.isEmpty()) + defaultCharStyle = CommonStrings::DefaultCharacterStyle; + charStyleCombo->setDefaultStyle(defaultCharStyle); + } + showCharStyle(charStyle.parent()); + + bool tmp = m_haveItem; + m_haveItem = false; + + setupLineSpacingSpinbox(newCurrent.lineSpacingMode(), newCurrent.lineSpacing()); + lineSpacingModeCombo->setCurrentIndex(newCurrent.lineSpacingMode()); + textAlignment->setStyle(newCurrent.alignment(), newCurrent.direction()); + textDirection->setStyle(newCurrent.direction()); + + m_haveItem = tmp; +} + +void PropertyWidget_Text::updateCharStyles() +{ + charStyleCombo->updateStyleList(); +} + +void PropertyWidget_Text::updateParagraphStyles() +{ + paraStyleCombo->updateStyleList(); + charStyleCombo->updateStyleList(); +} + +void PropertyWidget_Text::updateTextStyles() +{ + paraStyleCombo->updateStyleList(); + charStyleCombo->updateStyleList(); +} + +void PropertyWidget_Text::showAlignment(int e) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + bool tmp = m_haveItem; + m_haveItem = false; + textAlignment->setEnabled(true); + textAlignment->setStyle(e, textDirection->getStyle()); + m_haveItem = tmp; +} + +void PropertyWidget_Text::showDirection(int e) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + bool tmp = m_haveItem; + m_haveItem = false; + textDirection->setEnabled(true); + textDirection->setStyle(e); + m_haveItem = tmp; +} + +void PropertyWidget_Text::showCharStyle(const QString& name) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + bool blocked = charStyleCombo->blockSignals(true); + charStyleCombo->setStyle(name); + charStyleCombo->blockSignals(blocked); +} + +void PropertyWidget_Text::showParStyle(const QString& name) +{ + if (!m_ScMW || m_ScMW->scriptIsRunning()) + return; + bool blocked = paraStyleCombo->blockSignals(true); + paraStyleCombo->setStyle(name); + paraStyleCombo->blockSignals(blocked); +} + +void PropertyWidget_Text::handleLineSpacing() +{ + if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) + return; + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_SetLineSpacing(lineSpacing->value(), &tempSelection); +} + +void PropertyWidget_Text::handleFontSize() +{ + if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) + return; + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_SetFontSize(qRound(fontSize->value()*10.0), &tempSelection); +} + +void PropertyWidget_Text::handleAlignment(int a) +{ + if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) + return; + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_SetAlignment(a, &tempSelection); + + emit alignmentHandled(); + +// if (m_item->isPathText()) +// pathTextWidgets->handleSelectionChanged(); +} + +void PropertyWidget_Text::handleDirection(int d) +{ + if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) + return; + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_SetDirection(d, &tempSelection); + // If current text alignment is left or right, change it to match direction + if (d == ParagraphStyle::RTL && textAlignment->selectedId() == ParagraphStyle::LeftAligned) + { + m_doc->itemSelection_SetAlignment(ParagraphStyle::RightAligned, &tempSelection); + textAlignment->setTypeStyle(ParagraphStyle::RightAligned); + } + else if (d == ParagraphStyle::LTR && textAlignment->selectedId() == ParagraphStyle::RightAligned) + { + m_doc->itemSelection_SetAlignment(ParagraphStyle::LeftAligned, &tempSelection); + textAlignment->setTypeStyle(ParagraphStyle::LeftAligned); + } +} + +void PropertyWidget_Text::handleTextFont(const QString& font) +{ + if (!m_haveDoc || !m_haveItem || !m_ScMW || m_ScMW->scriptIsRunning()) + return; + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_SetFont(font, &tempSelection); +} + +void PropertyWidget_Text::doClearCStyle() +{ + if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveDoc || !m_haveItem) + return; + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_EraseCharStyle(&tempSelection); +} + + +void PropertyWidget_Text::doClearPStyle() +{ + if (!m_ScMW || m_ScMW->scriptIsRunning() || !m_haveDoc || !m_haveItem) + return; + + UndoTransaction activeTransaction; + if (UndoManager::undoEnabled()) + activeTransaction = UndoManager::instance()->beginTransaction(Um::SelectionGroup, Um::IGroup, Um::RemoveTextStyle, tr( "remove direct paragraph formatting" ), Um::IFont); + + Selection tempSelection(this, false); + tempSelection.addItem(m_item, true); + m_doc->itemSelection_ClearBulNumStrings(&tempSelection); + m_doc->itemSelection_EraseParagraphStyle(&tempSelection); + CharStyle emptyCStyle; + m_doc->itemSelection_SetCharStyle(emptyCStyle, &tempSelection); + + if (activeTransaction) + activeTransaction.commit(); +} + +void PropertyWidget_Text::changeEvent(QEvent *e) +{ + if (e->type() == QEvent::LanguageChange) + { + languageChange(); + return; + } + QWidget::changeEvent(e); +} + +void PropertyWidget_Text::languageChange() +{ + retranslateUi(this); + + QSignalBlocker lineSpacingModeBlocker(lineSpacingModeCombo); + int oldLineSpacingMode = lineSpacingModeCombo->currentIndex(); + lineSpacingModeCombo->clear(); + lineSpacingModeCombo->addItem( tr("Fixed Linespacing")); + lineSpacingModeCombo->addItem( tr("Automatic Linespacing")); + lineSpacingModeCombo->addItem( tr("Align to Baseline Grid")); + lineSpacingModeCombo->setCurrentIndex(oldLineSpacingMode); + + QSignalBlocker langComboBlocker(langCombo); + QStringList languageList; + LanguageManager::instance()->fillInstalledStringList(&languageList); + int oldLang = langCombo->currentIndex(); + langCombo->clear(); + langCombo->addItems(languageList); + langCombo->setCurrentIndex(oldLang); + + textAlignment->languageChange(); + textDirection->languageChange(); +} Index: scribus/ui/propertywidget_text.h =================================================================== --- scribus/ui/propertywidget_text.h (nicht existent) +++ scribus/ui/propertywidget_text.h (Arbeitskopie) @@ -0,0 +1,89 @@ +#ifndef PROPERTYWIDGET_TEXT_H +#define PROPERTYWIDGET_TEXT_H + +#include "ui_propertywidget_textbase.h" +#include "propertywidgetbase.h" +#include <QFrame> + +//namespace Ui { +//class PropertyWidget_Text; +//} + +class CharStyle; +class ParagraphStyle; +class ScribusDoc; +class ScribusMainWindow; + + +class PropertyWidget_Text : public QFrame, Ui::PropertyWidget_TextBase, + public PropertyWidgetBase +{ + Q_OBJECT + +public: + PropertyWidget_Text(QWidget *parent = nullptr); + ~PropertyWidget_Text() {}; + +private: + PageItem* currentItemFromSelection(); + +protected: + void connectSignals(); + void disconnectSignals(); + + void configureWidgets(); + void setCurrentItem(PageItem *item); + void changeEvent(QEvent *e) override; + + bool m_haveDoc {false}; + bool m_haveItem {false}; + PageItem* m_item { nullptr }; + ScribusMainWindow* m_ScMW { nullptr }; + +public slots: + void setMainWindow(ScribusMainWindow *mw); + void setDoc(ScribusDoc *d); + + void handleSelectionChanged(); + void handleUpdateRequest(int); + void iconSetChange(); + void languageChange(); + void localeChange(); + void changeLang(int id); + void unitChange() {}; + + void showAlignment(int e); + void showDirection(int e); + void showCharStyle(const QString& name); + void showFontFace(const QString&); + void showFontSize(double s); + void showLanguage(const QString& w); + void showLineSpacing(double r); + void showParStyle(const QString& name); + + void setupLineSpacingSpinbox(int mode, double value); + + void updateCharStyle(const CharStyle& charStyle); + void updateStyle(const ParagraphStyle& newCurrent); + + void updateCharStyles(); + void updateParagraphStyles(); + void updateTextStyles(); + + void handleLineSpacingMode(int id); + void handleTextFont(const QString&); + +private slots: + void handleAlignment(int a); + void handleDirection(int d); + void handleFontSize(); + void handleLineSpacing(); + + void doClearCStyle(); + void doClearPStyle(); + +signals: + void alignmentHandled(); +}; + +#endif // PROPERTYWIDGET_TEXT_H Index: scribus/ui/propertywidget_textbase.ui =================================================================== --- scribus/ui/propertywidget_textbase.ui (nicht existent) +++ scribus/ui/propertywidget_textbase.ui (Arbeitskopie) @@ -0,0 +1,359 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PropertyWidget_TextBase</class> + <widget class="QFrame" name="PropertyWidget_TextBase"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>281</width> + <height>241</height> + </rect> + </property> + <property name="windowTitle"> + <string>Frame</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <property name="spacing"> + <number>4</number> + </property> + <property name="leftMargin"> + <number>3</number> + </property> + <property name="topMargin"> + <number>3</number> + </property> + <property name="rightMargin"> + <number>3</number> + </property> + <property name="bottomMargin"> + <number>3</number> + </property> + <item> + <widget class="FontComboH" name="fonts" native="true"/> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="spacing"> + <number>3</number> + </property> + <item> + <widget class="QLabel" name="fontSizeLabel"> + <property name="minimumSize"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string/> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> + </property> + </widget> + </item> + <item> + <widget class="ScrSpinBox" name="fontSize"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Font Size</string> + </property> + <property name="suffix"> + <string> pt</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="spacing"> + <number>3</number> + </property> + <item> + <widget class="QLabel" name="lineSpacingLabel"> + <property name="minimumSize"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="lineSpacingModeCombo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Select the line spacing mode</string> + </property> + </widget> + </item> + <item> + <widget class="ScrSpinBox" name="lineSpacing"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Line Spacing</string> + </property> + <property name="suffix"> + <string> pt</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_5"> + <property name="spacing"> + <number>3</number> + </property> + <item> + <widget class="QLabel" name="textAlignmentLabel"> + <property name="minimumSize"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="AlignSelect" name="textAlignment" native="true"/> + </item> + <item alignment="Qt::AlignLeft"> + <widget class="DirectionSelect" name="textDirection" native="true"/> + </item> + <item> + <spacer name="horizontalSpacer_2"> + <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> + <layout class="QHBoxLayout" name="horizontalLayout_6"> + <property name="spacing"> + <number>3</number> + </property> + <item> + <widget class="QLabel" name="langLabel"> + <property name="minimumSize"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="langCombo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Text Language</string> + </property> + <property name="editable"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <property name="spacing"> + <number>3</number> + </property> + <item> + <widget class="QLabel" name="paraStyleLabel"> + <property name="minimumSize"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="ParaStyleComboBox" name="paraStyleCombo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Paragraph style of currently selected text or paragraph</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="paraStyleClear"> + <property name="toolTip"> + <string>Remove Direct Paragraph Formatting</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <property name="spacing"> + <number>3</number> + </property> + <item> + <widget class="QLabel" name="charStyleLabel"> + <property name="minimumSize"> + <size> + <width>20</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="CharStyleComboBox" name="charStyleCombo"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="toolTip"> + <string>Character style of currently selected text or paragraph</string> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="charStyleClear"> + <property name="toolTip"> + <string>Remove Direct Character Formatting</string> + </property> + <property name="text"> + <string/> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>ScrSpinBox</class> + <extends>QDoubleSpinBox</extends> + <header>ui/scrspinbox.h</header> + </customwidget> + <customwidget> + <class>FontComboH</class> + <extends>QWidget</extends> + <header>ui/fontcombo.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>CharStyleComboBox</class> + <extends>QComboBox</extends> + <header>ui/stylecombos.h</header> + </customwidget> + <customwidget> + <class>ParaStyleComboBox</class> + <extends>QComboBox</extends> + <header>ui/stylecombos.h</header> + </customwidget> + <customwidget> + <class>AlignSelect</class> + <extends>QWidget</extends> + <header>ui/alignselect.h</header> + <container>1</container> + </customwidget> + <customwidget> + <class>DirectionSelect</class> + <extends>QWidget</extends> + <header>ui/directionselect.h</header> + <container>1</container> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> Index: scribus/ui/widgets/section_container.cpp =================================================================== --- scribus/ui/widgets/section_container.cpp (nicht existent) +++ scribus/ui/widgets/section_container.cpp (Arbeitskopie) @@ -0,0 +1,425 @@ +#include "section_container.h" + +#include <QPainter> +#include <QPen> +#include <QMouseEvent> +#include <QToolButton> +#include "iconmanager.h" +#include "scribusapp.h" + + + +/* ********************************************************************************* * + * + * Constructor + Setup + * + * ********************************************************************************* */ + +SectionContainer::SectionContainer(QWidget *parent) : SectionContainer("Title", true, parent){} + +SectionContainer::SectionContainer(QString title, bool isCollapsible, QWidget *parent) + : QWidget{parent} +{ + widgetHeader = new SectionContainerHeader(title); + iconCollapsed = QIcon(); + iconExpanded = QIcon(); + boolIsCollapsible = isCollapsible; + boolIsCollapsed = false; + boolHasStyle = true; + + // Main Layout + mainLayout = new QVBoxLayout(this); + mainLayout->setSpacing(0); + mainLayout->setContentsMargins(0,0,0,0); + mainLayout->addWidget(widgetHeader); + + // Size Policy + QSizePolicy sizePol = QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Maximum ); + setSizePolicy(sizePol); + + iconSetChange(); + + // initial Setup + setIsCollapsible(isCollapsible); + connectSlots(); + +} + +void SectionContainer::connectSlots() +{ + connect( widgetHeader->buttonCollapse, &QPushButton::clicked,this, &SectionContainer::toggleCollpasedState ); + connect( widgetHeader, &SectionContainerHeader::toggleCollpasedState,this, &SectionContainer::toggleCollpasedState ); + connect( ScQApp, SIGNAL(iconSetChanged()), this, SLOT(iconSetChange()) ); +} + +/* ********************************************************************************* * + * + * Properties + * + * ********************************************************************************* */ + +void SectionContainer::setText(QString text) +{ + widgetHeader->labelTitle->setText(text); +} + +QString SectionContainer::text() const +{ + return widgetHeader->labelTitle->text(); +} + +void SectionContainer::setFont(QFont font) +{ + widgetHeader->labelTitle->setFont(font); + QWidget::setFont(font); +} + +QFont SectionContainer::font() +{ + return widgetHeader->font(); +} + +void SectionContainer::setHasStyle(bool isSimple) +{ + boolHasStyle = isSimple; + widgetHeader->boolHasStyle = isSimple; + update(); +} + +bool SectionContainer::hasStyle() +{ + return boolHasStyle; +} + +void SectionContainer::setIsCollapsible(bool isCollapsible) +{ + boolIsCollapsible = isCollapsible; + widgetHeader->buttonCollapse->setVisible(isCollapsible); +} + +bool SectionContainer::isCollapsible() +{ + return boolIsCollapsible; +} + +bool SectionContainer::isCollapsed() +{ + return boolIsCollapsed; +} + +void SectionContainer::setIsCollapsed(bool state) +{ + if(isCollapsible() == false || mainLayout->count() != 2) + return; + + QWidget *widget = mainLayout->itemAt(1)->widget(); + boolIsCollapsed = state; + + if( boolIsCollapsed ) + { + widget->hide(); + widgetHeader->buttonCollapse->setIcon(iconCollapsed); + } + else + { + widget->show(); + widgetHeader->buttonCollapse->setIcon(iconExpanded); + } + + emit collapsedState(boolIsCollapsed); +} + +void SectionContainer::setCollapseIcons(QIcon collapsed, QIcon expanded) +{ + iconCollapsed = collapsed; + iconExpanded = expanded; + + if( boolIsCollapsed ) + widgetHeader->buttonCollapse->setIcon(iconCollapsed); + else + widgetHeader->buttonCollapse->setIcon(iconExpanded); +} + +void SectionContainer::setWidget(QWidget *widget) +{ + // Has no body widget + if(mainLayout->count() == 1) + { + mainLayout->insertWidget(1, widget); + } + // Has body widget + else if(mainLayout->count() == 2) + { + QWidget *oldWidget = mainLayout->itemAt(1)->widget(); + mainLayout->replaceWidget(oldWidget, widget); + } + else + return; + + // Override widget policy to fit into the body container + widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding); + widget->installEventFilter(this); + widget->adjustSize(); + +} + +QWidget* SectionContainer::widget() +{ + return mainLayout->count() == 2 ? mainLayout->itemAt(1)->widget() : nullptr; +} + +/* ********************************************************************************* * + * + * Slots + * + * ********************************************************************************* */ + +void SectionContainer::toggleCollpasedState() +{ + if(isCollapsible() == false) return; + setIsCollapsed(!boolIsCollapsed); +} + +void SectionContainer::iconSetChange() +{ + IconManager &iconManager = IconManager::instance(); + setCollapseIcons(iconManager.loadPixmap("collapse"), iconManager.loadPixmap("expand")); +} + +/* ********************************************************************************* * + * + * Header + * + * ********************************************************************************* */ + +void SectionContainer::addHeaderSuffixWidget(QWidget *widget) +{ + insertHeaderSuffixWidget(-1, widget); +} + +void SectionContainer::insertHeaderSuffixWidget(int index, QWidget *widget) +{ + QToolButton *toolButton = static_cast<QToolButton*>(widget); + + if(toolButton) + { + toolButton->setAutoRaise(true); + widgetHeader->layoutHeaderSuffix->insertWidget(index, toolButton); + } + else + { + widgetHeader->layoutHeaderSuffix->insertWidget(index, widget); + } +} + +void SectionContainer::removeHeaderSuffixWidget(QWidget *widget) +{ + widgetHeader->layoutHeaderSuffix->removeWidget( widget ); + widget->deleteLater(); +} + +void SectionContainer::addHeaderSuffixSpacing(int size) +{ + insertHeaderSuffixSpacing(-1, size); +} + +void SectionContainer::insertHeaderSuffixSpacing(int index, int size) +{ + widgetHeader->layoutHeaderSuffix->insertSpacing(index, size); +} + +void SectionContainer::addHeaderPrefixWidget(QWidget *widget) +{ + insertHeaderPrefixWidget(-1, widget); +} + +void SectionContainer::insertHeaderPrefixWidget(int index, QWidget *widget) +{ + QToolButton *toolButton = static_cast<QToolButton*>(widget); + + if(toolButton) + { + toolButton->setAutoRaise(true); + widgetHeader->layoutHeaderPrefix->insertWidget(index, toolButton); + } + else + { + widgetHeader->layoutHeaderPrefix->insertWidget(index, widget); + } +} + +void SectionContainer::removeHeaderPrefixWidget(QWidget *widget) +{ + widgetHeader->layoutHeaderPrefix->removeWidget( widget ); + widget->deleteLater(); +} + +void SectionContainer::addHeaderPrefixSpacing(int size) +{ + insertHeaderPrefixSpacing(-1, size); +} + +void SectionContainer::insertHeaderPrefixSpacing(int index, int size) +{ + widgetHeader->layoutHeaderPrefix->insertSpacing(index, size); +} + + +/* ********************************************************************************* * + * + * Events + * + * ********************************************************************************* */ + +void SectionContainer::paintEvent(QPaintEvent *event) +{ + QWidget::paintEvent(event); + + if(!boolHasStyle) + { + int lineWidth = 1; + QColor bottomLineColor( palette().color(QPalette::Dark) ); + + QPainter painter( this ); + + // Bottom Line + painter.setPen( QPen(bottomLineColor, lineWidth) ); + painter.drawLine( 8, this->height() - lineWidth, this->width() - 8, this->height() - lineWidth ); + } + +} + +bool SectionContainer::eventFilter(QObject *object, QEvent *event) +{ + QWidget *widget = qobject_cast<QWidget*>(object); + + switch(event->type()) + { + case QEvent::Resize: + { + if(widget) + qDebug() << "height" << widget->height() << widget->objectName(); + + qDebug() << "resize body widget"; + break; + } + default: + break; + } + + return false; +} + +/* ********************************************************************************* * + * + * + * SECTION CONTAINER HEADER + * + * + * ********************************************************************************* */ + +/* ********************************************************************************* * + * + * Constructor + Setup + * + * ********************************************************************************* */ + +SectionContainerHeader::SectionContainerHeader(QWidget *parent) : SectionContainerHeader("Title", parent){} + +SectionContainerHeader::SectionContainerHeader(QString title, QWidget *parent) +{ + + int padding = 4; + boolHasStyle = true; + + layoutHeader = new QHBoxLayout; + layoutHeaderPrefix = new QHBoxLayout; + layoutHeaderSuffix = new QHBoxLayout; + labelTitle = new QLabel(title); + buttonCollapse = new QPushButton; + + // Label + // QFont m_font(this->font()); + // m_font.setBold( true ); + // labelTitle->setFont(m_font); + labelTitle->setText(title); + labelTitle->setBuddy(this); + + // Buttons + //buttonCollapse->setAutoRaise(true); + buttonCollapse->setFlat(true); + buttonCollapse->adjustSize(); // needed to calculate the header height later + buttonCollapse->setMaximumWidth(buttonCollapse->height()); + + // Header Prefix layout + layoutHeaderPrefix->setContentsMargins( 0,0,0,0 ); + layoutHeaderPrefix->setSpacing(padding); + + // Header Suffix Layout + layoutHeaderSuffix->setContentsMargins( 0,0,0,0 ); + layoutHeaderSuffix->setSpacing(padding); + + // Header Layout + layoutHeader->addWidget( buttonCollapse ); + layoutHeader->addLayout( layoutHeaderPrefix ); + layoutHeader->addWidget( labelTitle ); + layoutHeader->addStretch( 0 ); + layoutHeader->addLayout( layoutHeaderSuffix ); + layoutHeader->setContentsMargins( padding, padding/2, padding, padding/2 ); + + // Header Widget + this->setLayout(layoutHeader); + this->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Maximum ); + this->setMaximumHeight(buttonCollapse->height() + padding); +} + +/* ********************************************************************************* * + * + * Events + * + * ********************************************************************************* */ + +void SectionContainerHeader::paintEvent(QPaintEvent *event) +{ + + if(boolHasStyle) + { + int lineWidth = 1; + // QColor topLineColor( palette().color(QPalette::Mid) ); + QColor bottomLineColor( palette().color(QPalette::Dark) ); + + QColor bgColor( palette().color(QPalette::WindowText) ); + bgColor.setAlphaF(0.07f); + + + int headerheight = this->height(); + QRect headerRect(0, 0, this->width(), headerheight - lineWidth); + + QPainter painter( this ); + + painter.setPen( Qt::NoPen ); + painter.setBrush(bgColor); + painter.drawRect(headerRect); + + painter.setBrush(Qt::NoBrush); + + // // Top Line + // painter.setPen( QPen(topLineColor, lineWidth) ); + // painter.drawLine( 0, 0,this->width(), 0 ); + + // Bottom Line + painter.setPen( QPen(bottomLineColor, lineWidth) ); + painter.drawLine( 0, headerheight - lineWidth, this->width(), headerheight - lineWidth ); + + } +} + +void SectionContainerHeader::mouseDoubleClickEvent(QMouseEvent *mouseEvent) +{ + QWidget::mouseDoubleClickEvent(mouseEvent); + + if (mouseEvent->button() == Qt::LeftButton) + { + emit toggleCollpasedState(); + } +} Index: scribus/ui/widgets/section_container.h =================================================================== --- scribus/ui/widgets/section_container.h (nicht existent) +++ scribus/ui/widgets/section_container.h (Arbeitskopie) @@ -0,0 +1,126 @@ +#ifndef SECTIONCONTAINER_H +#define SECTIONCONTAINER_H + +#include <QLabel> +#include <QStackedWidget> +#include <QPushButton> +#include <QVBoxLayout> +#include <QWidget> + +#include "scribusapi.h" + +/* ********************************************************************************* * + * + * Section Container Header + * + * ********************************************************************************* */ + +class SCRIBUS_API SectionContainerHeader : public QWidget +{ + Q_OBJECT + + friend class SectionContainer; + +public: + SectionContainerHeader(QWidget *parent = nullptr); + SectionContainerHeader(QString title, QWidget *parent = nullptr); + + QPushButton * buttonCollapse; + +private: + + QHBoxLayout * layoutHeader; + QHBoxLayout * layoutHeaderPrefix; + QHBoxLayout * layoutHeaderSuffix; + + QLabel * labelTitle; + + bool boolHasStyle; + +protected: + void paintEvent(QPaintEvent *event); + void mouseDoubleClickEvent(QMouseEvent *mouseEvent); + +signals: + void toggleCollpasedState(); + +}; + +/* ********************************************************************************* * + * + * Section Container + * + * ********************************************************************************* */ + +class SCRIBUS_API SectionContainer : public QWidget +{ + Q_OBJECT + Q_CLASSINFO("Version", "1.0.0") + + Q_PROPERTY(QString title READ text WRITE setText) + Q_PROPERTY(bool isCollapsible READ isCollapsible WRITE setIsCollapsible) + Q_PROPERTY(bool isCollapsed READ isCollapsed WRITE setIsCollapsed) + Q_PROPERTY(bool hasStyle READ hasStyle WRITE setHasStyle) + + +public: + SectionContainer(QWidget *parent = nullptr); + SectionContainer(QString title, bool isCollapsible = true, QWidget *parent = nullptr); + + void setText(QString text); + QString text() const; + + void setFont(QFont font); + QFont font(); + + void setHasStyle(bool hasStyle); + bool hasStyle(); + + void setIsCollapsible(bool isCollapsible); + bool isCollapsible(); + bool isCollapsed(); + + void setCollapseIcons(QIcon collapsed, QIcon expanded); + + void setWidget(QWidget * widget); + QWidget *widget(); + + void addHeaderSuffixWidget(QWidget *widget); + void insertHeaderSuffixWidget(int index, QWidget *widget); + void removeHeaderSuffixWidget(QWidget *widget); + void addHeaderSuffixSpacing(int size); + void insertHeaderSuffixSpacing(int index, int size); + + void addHeaderPrefixWidget(QWidget *widget); + void insertHeaderPrefixWidget(int index, QWidget *widget); + void removeHeaderPrefixWidget(QWidget *widget); + void addHeaderPrefixSpacing(int size); + void insertHeaderPrefixSpacing(int index, int size); + +private: + SectionContainerHeader *widgetHeader; + QVBoxLayout *mainLayout; + QIcon iconCollapsed; + QIcon iconExpanded; + bool boolIsCollapsible; + bool boolIsCollapsed; + bool boolHasStyle; + + void connectSlots(); + + void paintEvent(QPaintEvent *event); + bool eventFilter(QObject *object, QEvent *event); + +public slots: + void toggleCollpasedState(); + void setIsCollapsed(bool state); + void iconSetChange(); + +signals: + void collapsedState(bool); + void currentIndexChanged(int index); + + +}; + +#endif // SECTIONCONTAINER_H |
|
looking good as tested, email sent to you separately with my comments. thank you! |
Date Modified | Username | Field | Change |
---|---|---|---|
2023-08-01 20:06 | nitramr | New Issue | |
2023-08-01 20:06 | nitramr | Status | new => assigned |
2023-08-01 20:06 | nitramr | Assigned To | => nitramr |
2023-08-01 20:06 | nitramr | File Added: indigouicontainer_23-08-01_01.patch | |
2023-08-01 20:06 | nitramr | File Added: action-chevron-down.svg | |
2023-08-01 20:06 | nitramr | File Added: action-chevron-up.svg | |
2023-08-01 20:06 | nitramr | File Added: Bildschirmfoto vom 2023-08-01 21-57-41.png | |
2023-08-01 20:07 | nitramr | Summary | Implement IndigoUI collapsable section container as UI widget => Implement IndigoUI collapsible section container as UI widget |
2023-10-30 10:34 | nitramr | Note Added: 0050409 | |
2023-10-30 10:34 | nitramr | File Added: indigouicontainer_23-10-30_1.patch | |
2023-10-30 10:34 | nitramr | File Added: action-chevron-down-2.svg | |
2023-10-30 10:34 | nitramr | File Added: action-chevron-right.svg | |
2023-10-30 10:34 | nitramr | File Added: Bildschirmfoto vom 2023-10-30 11-03-37.png | |
2023-10-30 21:59 | cbradney | Note Added: 0050410 | |
2023-12-04 11:22 | nitramr | Status | assigned => resolved |
2023-12-04 11:22 | nitramr | Resolution | open => fixed |
2023-12-04 11:22 | nitramr | Fixed in Version | => 1.7.0.svn |
2023-12-24 10:00 | cbradney | Status | resolved => closed |