1 #include "branchpropwindow.h"
3 #include <QColorDialog>
8 extern Settings settings;
9 extern QString vymName;
12 BranchPropertyWindow::BranchPropertyWindow (QWidget *parent): QDialog (parent)
16 setCaption(vymName +" - " +tr ("Property Editor","Window caption"));
21 ui.tabWidget->setEnabled(false);
23 penColor=QColor (Qt::black);
24 brushColor=QColor (Qt::black);
27 ui.framePenColorButton->setPixmap (pix);
28 ui.frameBrushColorButton->setPixmap (pix);
32 resize (settings.value ( "/satellite/propertywindow/geometry/size", QSize(450,600)).toSize());
33 move (settings.value ( "/satellite/propertywindow/geometry/pos", QPoint (250,50)).toPoint());
35 if (settings.value ( "/satellite/propertywindow/showWithMain",true).toBool())
42 BranchPropertyWindow::~BranchPropertyWindow ()
44 settings.setValue( "/satellite/propertywindow/geometry/size", size() );
45 settings.setValue( "/satellite/propertywindow/geometry/pos", pos() );
46 settings.setValue( "/satellite/propertywindow/showWithMain",isVisible() );
49 void BranchPropertyWindow::setBranch (BranchObj *bo)
55 ui.tabWidget->setEnabled (true);
58 FrameObj::FrameType t=branch->getFrameType();
59 if (t==FrameObj::NoFrame)
61 ui.frameTypeCombo->setCurrentIndex (0);
64 ui.colorGroupBox->setEnabled (false);
65 ui.framePaddingSpinBox->setEnabled (false);
66 ui.frameWidthSpinBox->setEnabled (false);
67 ui.framePaddingLabel->setEnabled (false);
68 ui.frameBorderLabel->setEnabled (false);
71 penColor=bo->getFramePenColor();
72 brushColor=bo->getFrameBrushColor();
75 ui.framePenColorButton->setPixmap (pix);
76 pix.fill (brushColor);
77 ui.frameBrushColorButton->setPixmap (pix);
78 ui.colorGroupBox->setEnabled (true);
79 ui.framePaddingSpinBox->setEnabled (true);
80 ui.framePaddingSpinBox->setValue (bo->getFramePadding());
81 ui.frameWidthSpinBox->setEnabled (true);
82 ui.frameWidthSpinBox->setValue (bo->getFrameBorderWidth());
83 ui.framePaddingLabel->setEnabled (true);
84 ui.frameBorderLabel->setEnabled (true);
88 case FrameObj::Rectangle:
89 ui.frameTypeCombo->setCurrentIndex (1);
91 case FrameObj::Ellipse:
92 ui.frameTypeCombo->setCurrentIndex (2);
100 if (branch->getHideLinkUnselected())
101 ui.hideLinkIfUnselected->setCheckState (Qt::Checked);
103 ui.hideLinkIfUnselected->setCheckState (Qt::Unchecked);
106 if (branch->getIncludeImagesVer())
107 ui.incImgVer->setCheckState (Qt::Checked);
109 ui.incImgVer->setCheckState (Qt::Unchecked);
110 if (branch->getIncludeImagesHor())
111 ui.incImgHor->setCheckState (Qt::Checked);
113 ui.incImgHor->setCheckState (Qt::Unchecked);
115 // Finally activate signals
119 ui.tabWidget->setEnabled (false);
123 void BranchPropertyWindow::setMapEditor (MapEditor *me)
127 setBranch (mapEditor->getSelectedBranch() );
129 ui.tabWidget->setEnabled (false);
133 void BranchPropertyWindow::frameTypeChanged (int i)
139 case 0: mapEditor->setFrameType (FrameObj::NoFrame); break;
140 case 1: mapEditor->setFrameType (FrameObj::Rectangle); break;
141 case 2: mapEditor->setFrameType (FrameObj::Ellipse); break;
147 void BranchPropertyWindow::framePenColorClicked()
151 QColor col = QColorDialog::getColor( penColor, this );
155 mapEditor->setFramePenColor (penColor);
160 void BranchPropertyWindow::frameBrushColorClicked()
164 QColor col = QColorDialog::getColor( brushColor, this );
168 mapEditor->setFrameBrushColor (brushColor);
173 void BranchPropertyWindow::framePaddingChanged(int i)
175 if (mapEditor) mapEditor->setFramePadding (i);
178 void BranchPropertyWindow::frameBorderWidthChanged(int i)
180 if (mapEditor) mapEditor->setFrameBorderWidth(i);
183 void BranchPropertyWindow::linkHideUnselectedChanged (int i)
186 mapEditor->setHideLinkUnselected(i);
189 void BranchPropertyWindow::incImgVerChanged (int i)
191 if (mapEditor) mapEditor->setIncludeImagesVer (i);
194 void BranchPropertyWindow::incImgHorChanged (int i)
196 if (mapEditor) mapEditor->setIncludeImagesHor (i);
199 void BranchPropertyWindow::closeEvent( QCloseEvent* ce )
201 ce->accept(); // can be reopened with show()
203 emit (windowClosed() );
208 void BranchPropertyWindow::connectSignals()
212 ui.framePenColorButton, SIGNAL (clicked()),
213 this, SLOT (framePenColorClicked()));
215 ui.framePaddingSpinBox, SIGNAL (valueChanged( int)),
216 this, SLOT (framePaddingChanged (int)));
218 ui.frameWidthSpinBox, SIGNAL (valueChanged( int)),
219 this, SLOT (frameBorderWidthChanged (int)));
221 ui.frameBrushColorButton, SIGNAL (clicked()),
222 this, SLOT (frameBrushColorClicked()));
224 ui.frameTypeCombo, SIGNAL (currentIndexChanged( int)),
225 this, SLOT (frameTypeChanged (int)));
230 ui.hideLinkIfUnselected, SIGNAL (stateChanged( int)),
231 this, SLOT (linkHideUnselectedChanged (int)));
235 ui.incImgVer, SIGNAL (stateChanged( int)),
236 this, SLOT (incImgVerChanged (int)));
238 ui.incImgHor, SIGNAL (stateChanged( int)),
239 this, SLOT (incImgHorChanged (int)));
243 void BranchPropertyWindow::disconnectSignals()
246 disconnect ( ui.frameTypeCombo, 0,0,0);
247 disconnect ( ui.framePenColorButton, 0,0,0);
248 disconnect ( ui.framePaddingSpinBox, 0,0,0);
249 disconnect ( ui.frameWidthSpinBox, 0,0,0);
250 disconnect ( ui.frameBrushColorButton, 0,0,0);
253 disconnect ( ui.hideLinkIfUnselected, 0,0,0);
256 disconnect ( ui.incImgVer, 0,0,0);
257 disconnect ( ui.incImgHor, 0,0,0);