1.1 --- a/branchpropwindow.cpp Wed Mar 21 11:51:38 2007 +0000
1.2 +++ b/branchpropwindow.cpp Sat Mar 31 09:28:27 2007 +0000
1.3 @@ -1,5 +1,7 @@
1.4 #include "branchpropwindow.h"
1.5
1.6 +#include <QColorDialog>
1.7 +
1.8 #include "frameobj.h"
1.9
1.10
1.11 @@ -10,39 +12,87 @@
1.12 branch=NULL;
1.13 mapEditor=NULL;
1.14
1.15 - connect ( ui.frameTypeCombo, SIGNAL (currentIndexChanged( int)), this, SLOT (frameTypeChanged (int)));
1.16 - connect ( ui.hideLinkIfUnselected, SIGNAL (stateChanged( int)), this, SLOT (linkHideUnselectedChanged (int)));
1.17 + ui.tabWidget->setEnabled(false);
1.18 +
1.19 + penColor=QColor (Qt::black);
1.20 + brushColor=QColor (Qt::black);
1.21 + QPixmap pix( 16,16);
1.22 + pix.fill (penColor);
1.23 + ui.framePenColorButton->setPixmap (pix);
1.24 + ui.frameBrushColorButton->setPixmap (pix);
1.25 +
1.26 + connect (
1.27 + ui.framePenColorButton, SIGNAL (clicked()),
1.28 + this, SLOT (framePenColorClicked()));
1.29 + connect (
1.30 + ui.frameBrushColorButton, SIGNAL (clicked()),
1.31 + this, SLOT (frameBrushColorClicked()));
1.32 + connect (
1.33 + ui.frameTypeCombo, SIGNAL (currentIndexChanged( int)),
1.34 + this, SLOT (frameTypeChanged (int)));
1.35 + connect (
1.36 + ui.hideLinkIfUnselected, SIGNAL (stateChanged( int)),
1.37 + this, SLOT (linkHideUnselectedChanged (int)));
1.38 }
1.39
1.40 void BranchPropertyWindow::setBranch (BranchObj *bo)
1.41 {
1.42 - if (!bo) return;
1.43 branch=bo;
1.44 + if (bo)
1.45 + {
1.46 + ui.tabWidget->setEnabled (true);
1.47
1.48 - // Frame
1.49 - switch (branch->getFrameType())
1.50 + // Frame
1.51 + FrameType t=branch->getFrameType();
1.52 + if (t==NoFrame)
1.53 + {
1.54 + ui.frameTypeCombo->setCurrentIndex (0);
1.55 + penColor=Qt::white;
1.56 + brushColor=Qt::white;
1.57 + ui.colorGroupBox->setEnabled (false);
1.58 + } else
1.59 + {
1.60 + penColor=bo->getFramePenColor();
1.61 + brushColor=bo->getFrameBrushColor();
1.62 + QPixmap pix( 16,16);
1.63 + pix.fill (penColor);
1.64 + ui.frameBrushColorButton->setPixmap (pix);
1.65 + pix.fill (brushColor);
1.66 + ui.frameBrushColorButton->setPixmap (pix);
1.67 + ui.colorGroupBox->setEnabled (true);
1.68 +
1.69 + switch (t)
1.70 + {
1.71 + case Rectangle:
1.72 + ui.frameTypeCombo->setCurrentIndex (1);
1.73 + break;
1.74 + case Ellipse:
1.75 + ui.frameTypeCombo->setCurrentIndex (2);
1.76 + break;
1.77 + default:
1.78 + break;
1.79 + }
1.80 + }
1.81 +
1.82 + // Link
1.83 + if (branch->getHideLinkUnselected())
1.84 + ui.hideLinkIfUnselected->setCheckState (Qt::Checked);
1.85 + else
1.86 + ui.hideLinkIfUnselected->setCheckState (Qt::Unchecked);
1.87 + } else
1.88 {
1.89 - case NoFrame:
1.90 - ui.frameTypeCombo->setCurrentIndex (0);
1.91 - break;
1.92 - case Rectangle:
1.93 - ui.frameTypeCombo->setCurrentIndex (1);
1.94 - break;
1.95 - case Ellipse:
1.96 - ui.frameTypeCombo->setCurrentIndex (2);
1.97 - break;
1.98 + ui.tabWidget->setEnabled (false);
1.99 }
1.100 -
1.101 - // Link
1.102 - if (branch->getHideLinkUnselected())
1.103 - ui.hideLinkIfUnselected->setCheckState (Qt::Checked);
1.104 - else
1.105 - ui.hideLinkIfUnselected->setCheckState (Qt::Unchecked);
1.106 }
1.107
1.108 void BranchPropertyWindow::setMapEditor (MapEditor *me)
1.109 {
1.110 - if (me) mapEditor=me;
1.111 + mapEditor=me;
1.112 + if (mapEditor)
1.113 + setBranch (mapEditor->getSelectedBranch() );
1.114 + else
1.115 + ui.tabWidget->setEnabled (false);
1.116 +
1.117 }
1.118
1.119 void BranchPropertyWindow::frameTypeChanged (int i)
1.120 @@ -50,12 +100,38 @@
1.121 if (mapEditor)
1.122 switch (i)
1.123 {
1.124 - case 0: mapEditor->setFrame (NoFrame); break;
1.125 - case 1: mapEditor->setFrame (Rectangle); break;
1.126 - case 2: mapEditor->setFrame (Ellipse); break;
1.127 + case 0: mapEditor->setFrameType (NoFrame); break;
1.128 + case 1: mapEditor->setFrameType (Rectangle); break;
1.129 + case 2: mapEditor->setFrameType (Ellipse); break;
1.130 }
1.131 }
1.132
1.133 +void BranchPropertyWindow::framePenColorClicked()
1.134 +{
1.135 + if (mapEditor)
1.136 + {
1.137 + QColor col = QColorDialog::getColor( penColor, this );
1.138 + if ( col.isValid() )
1.139 + {
1.140 + penColor=col;
1.141 + mapEditor->setFramePenColor (penColor);
1.142 + }
1.143 + }
1.144 +}
1.145 +
1.146 +void BranchPropertyWindow::frameBrushColorClicked()
1.147 +{
1.148 + if (mapEditor)
1.149 + {
1.150 + QColor col = QColorDialog::getColor( brushColor, this );
1.151 + if ( col.isValid() )
1.152 + {
1.153 + brushColor=col;
1.154 + mapEditor->setFrameBrushColor (brushColor);
1.155 + }
1.156 + }
1.157 +}
1.158 +
1.159 void BranchPropertyWindow::linkHideUnselectedChanged (int i)
1.160 {
1.161 if (!branch) return;