1 #include "branchpropwindow.h"
3 #include <QColorDialog>
8 extern Settings settings;
10 BranchPropertyWindow::BranchPropertyWindow (QWidget *parent): QDialog (parent)
17 ui.tabWidget->setEnabled(false);
19 penColor=QColor (Qt::black);
20 brushColor=QColor (Qt::black);
23 ui.framePenColorButton->setPixmap (pix);
24 ui.frameBrushColorButton->setPixmap (pix);
28 //FIXME setSatelliteName ( "propertyWindow" );
29 resize (settings.value ( "/satellite/propertywindow/geometry/size", QSize(450,600)).toSize());
30 move (settings.value ( "/satellite/propertywindow/geometry/pos", QPoint (250,50)).toPoint());
32 if (settings.value ( "/satellite/propertywindow/showWithMain",true).toBool())
39 BranchPropertyWindow::~BranchPropertyWindow ()
41 settings.setValue( "/satellite/propertywindow/geometry/size", size() );
42 settings.setValue( "/satellite/propertywindow/geometry/pos", pos() );
46 void BranchPropertyWindow::setBranch (BranchObj *bo)
52 ui.tabWidget->setEnabled (true);
55 FrameObj::FrameType t=branch->getFrameType();
56 if (t==FrameObj::NoFrame)
58 ui.frameTypeCombo->setCurrentIndex (0);
61 ui.colorGroupBox->setEnabled (false);
62 ui.framePaddingSpinBox->setEnabled (false);
63 ui.frameWidthSpinBox->setEnabled (false);
64 ui.framePaddingLabel->setEnabled (false);
65 ui.frameBorderLabel->setEnabled (false);
68 penColor=bo->getFramePenColor();
69 brushColor=bo->getFrameBrushColor();
72 ui.framePenColorButton->setPixmap (pix);
73 pix.fill (brushColor);
74 ui.frameBrushColorButton->setPixmap (pix);
75 ui.colorGroupBox->setEnabled (true);
76 ui.framePaddingSpinBox->setEnabled (true);
77 ui.framePaddingSpinBox->setValue (bo->getFramePadding());
78 ui.frameWidthSpinBox->setEnabled (true);
79 ui.frameWidthSpinBox->setValue (bo->getFrameBorderWidth());
80 ui.framePaddingLabel->setEnabled (true);
81 ui.frameBorderLabel->setEnabled (true);
85 case FrameObj::Rectangle:
86 ui.frameTypeCombo->setCurrentIndex (1);
88 case FrameObj::Ellipse:
89 ui.frameTypeCombo->setCurrentIndex (2);
97 if (branch->getHideLinkUnselected())
98 ui.hideLinkIfUnselected->setCheckState (Qt::Checked);
100 ui.hideLinkIfUnselected->setCheckState (Qt::Unchecked);
103 if (branch->getIncludeImagesVer())
104 ui.incImgVer->setCheckState (Qt::Checked);
106 ui.incImgVer->setCheckState (Qt::Unchecked);
107 if (branch->getIncludeImagesHor())
108 ui.incImgHor->setCheckState (Qt::Checked);
110 ui.incImgHor->setCheckState (Qt::Unchecked);
112 // Finally activate signals
116 ui.tabWidget->setEnabled (false);
120 void BranchPropertyWindow::setMapEditor (MapEditor *me)
124 setBranch (mapEditor->getSelectedBranch() );
126 ui.tabWidget->setEnabled (false);
130 void BranchPropertyWindow::frameTypeChanged (int i)
136 case 0: mapEditor->setFrameType (FrameObj::NoFrame); break;
137 case 1: mapEditor->setFrameType (FrameObj::Rectangle); break;
138 case 2: mapEditor->setFrameType (FrameObj::Ellipse); break;
144 void BranchPropertyWindow::framePenColorClicked()
148 QColor col = QColorDialog::getColor( penColor, this );
152 mapEditor->setFramePenColor (penColor);
157 void BranchPropertyWindow::frameBrushColorClicked()
161 QColor col = QColorDialog::getColor( brushColor, this );
165 mapEditor->setFrameBrushColor (brushColor);
170 void BranchPropertyWindow::framePaddingChanged(int i)
172 if (mapEditor) mapEditor->setFramePadding (i);
175 void BranchPropertyWindow::frameBorderWidthChanged(int i)
177 if (mapEditor) mapEditor->setFrameBorderWidth(i);
180 void BranchPropertyWindow::linkHideUnselectedChanged (int i)
183 mapEditor->setHideLinkUnselected(i);
186 void BranchPropertyWindow::incImgVerChanged (int i)
188 if (mapEditor) mapEditor->setIncludeImagesVer (i);
191 void BranchPropertyWindow::incImgHorChanged (int i)
193 if (mapEditor) mapEditor->setIncludeImagesHor (i);
196 void BranchPropertyWindow::closeEvent( QCloseEvent* ce )
198 ce->accept(); // can be reopened with show()
200 emit (windowClosed() );
205 void BranchPropertyWindow::connectSignals()
209 ui.framePenColorButton, SIGNAL (clicked()),
210 this, SLOT (framePenColorClicked()));
212 ui.framePaddingSpinBox, SIGNAL (valueChanged( int)),
213 this, SLOT (framePaddingChanged (int)));
215 ui.frameWidthSpinBox, SIGNAL (valueChanged( int)),
216 this, SLOT (frameBorderWidthChanged (int)));
218 ui.frameBrushColorButton, SIGNAL (clicked()),
219 this, SLOT (frameBrushColorClicked()));
221 ui.frameTypeCombo, SIGNAL (currentIndexChanged( int)),
222 this, SLOT (frameTypeChanged (int)));
227 ui.hideLinkIfUnselected, SIGNAL (stateChanged( int)),
228 this, SLOT (linkHideUnselectedChanged (int)));
232 ui.incImgVer, SIGNAL (stateChanged( int)),
233 this, SLOT (incImgVerChanged (int)));
235 ui.incImgHor, SIGNAL (stateChanged( int)),
236 this, SLOT (incImgHorChanged (int)));
240 void BranchPropertyWindow::disconnectSignals()
243 disconnect ( ui.frameTypeCombo, 0,0,0);
244 disconnect ( ui.framePenColorButton, 0,0,0);
245 disconnect ( ui.framePaddingSpinBox, 0,0,0);
246 disconnect ( ui.frameWidthSpinBox, 0,0,0);
247 disconnect ( ui.frameBrushColorButton, 0,0,0);
250 disconnect ( ui.hideLinkIfUnselected, 0,0,0);
253 disconnect ( ui.incImgVer, 0,0,0);
254 disconnect ( ui.incImgHor, 0,0,0);