branchpropwindow.cpp
author insilmaril
Wed, 25 Apr 2007 16:02:54 +0000
changeset 470 80ae7b79828c
parent 462 494a5b8c131e
child 480 4e2c9394c7da
permissions -rw-r--r--
started doxygen documentation
insilmaril@421
     1
#include "branchpropwindow.h"
insilmaril@421
     2
insilmaril@440
     3
#include <QColorDialog>
insilmaril@440
     4
insilmaril@421
     5
#include "frameobj.h"
insilmaril@462
     6
#include "settings.h"
insilmaril@421
     7
insilmaril@462
     8
extern Settings settings;
insilmaril@421
     9
insilmaril@421
    10
BranchPropertyWindow::BranchPropertyWindow (QWidget *parent):QDialog(parent)
insilmaril@421
    11
{
insilmaril@421
    12
	ui.setupUi (this);
insilmaril@421
    13
insilmaril@421
    14
	branch=NULL;
insilmaril@421
    15
	mapEditor=NULL;
insilmaril@421
    16
insilmaril@440
    17
	ui.tabWidget->setEnabled(false);
insilmaril@440
    18
insilmaril@440
    19
	penColor=QColor (Qt::black);
insilmaril@440
    20
	brushColor=QColor (Qt::black);
insilmaril@440
    21
    QPixmap pix( 16,16);
insilmaril@440
    22
    pix.fill (penColor);
insilmaril@440
    23
	ui.framePenColorButton->setPixmap (pix);
insilmaril@440
    24
	ui.frameBrushColorButton->setPixmap (pix);
insilmaril@462
    25
}
insilmaril@440
    26
insilmaril@462
    27
BranchPropertyWindow::~BranchPropertyWindow ()
insilmaril@462
    28
{
insilmaril@462
    29
	settings.setValue( "/branchpropertywindow/geometry/size", size() );
insilmaril@462
    30
	settings.setValue( "/branchpropertywindow/geometry/pos", pos() );
insilmaril@462
    31
	//settings.setValue( "/branchpropertywindow/showWithMain",showWithMain());	//FIXME add this!
insilmaril@421
    32
}
insilmaril@421
    33
insilmaril@421
    34
void BranchPropertyWindow::setBranch (BranchObj *bo)
insilmaril@421
    35
{
insilmaril@462
    36
	disconnectSignals();
insilmaril@421
    37
	branch=bo;
insilmaril@440
    38
	if (bo) 
insilmaril@440
    39
	{
insilmaril@440
    40
		ui.tabWidget->setEnabled (true);
insilmaril@421
    41
insilmaril@440
    42
		// Frame
insilmaril@462
    43
		FrameObj::FrameType t=branch->getFrameType();
insilmaril@462
    44
		if (t==FrameObj::NoFrame)
insilmaril@440
    45
		{
insilmaril@440
    46
			ui.frameTypeCombo->setCurrentIndex (0);
insilmaril@440
    47
			penColor=Qt::white;
insilmaril@440
    48
			brushColor=Qt::white;
insilmaril@440
    49
			ui.colorGroupBox->setEnabled (false);
insilmaril@462
    50
			ui.framePaddingSpinBox->setEnabled (false);
insilmaril@462
    51
			ui.frameWidthSpinBox->setEnabled (false);
insilmaril@440
    52
		} else	
insilmaril@440
    53
		{
insilmaril@440
    54
			penColor=bo->getFramePenColor();
insilmaril@440
    55
			brushColor=bo->getFrameBrushColor();
insilmaril@440
    56
			QPixmap pix( 16,16);
insilmaril@440
    57
			pix.fill (penColor);
insilmaril@440
    58
			ui.frameBrushColorButton->setPixmap (pix);
insilmaril@440
    59
			pix.fill (brushColor);
insilmaril@440
    60
			ui.frameBrushColorButton->setPixmap (pix);
insilmaril@440
    61
			ui.colorGroupBox->setEnabled (true);
insilmaril@462
    62
			ui.framePaddingSpinBox->setEnabled (true);
insilmaril@462
    63
			ui.framePaddingSpinBox->setValue (bo->getFramePadding());
insilmaril@462
    64
			ui.frameWidthSpinBox->setEnabled (true);
insilmaril@462
    65
			ui.frameWidthSpinBox->setValue (bo->getFrameBorderWidth());
insilmaril@440
    66
insilmaril@440
    67
			switch (t)
insilmaril@440
    68
			{
insilmaril@462
    69
				case FrameObj::Rectangle: 
insilmaril@440
    70
					ui.frameTypeCombo->setCurrentIndex (1);
insilmaril@440
    71
					break;
insilmaril@462
    72
				case FrameObj::Ellipse: 
insilmaril@440
    73
					ui.frameTypeCombo->setCurrentIndex (2);
insilmaril@440
    74
					break;
insilmaril@440
    75
				default: 
insilmaril@440
    76
					break;
insilmaril@440
    77
			}
insilmaril@440
    78
		}	
insilmaril@440
    79
		
insilmaril@440
    80
		// Link
insilmaril@440
    81
		if (branch->getHideLinkUnselected())
insilmaril@440
    82
			ui.hideLinkIfUnselected->setCheckState (Qt::Checked);
insilmaril@440
    83
		else	
insilmaril@440
    84
			ui.hideLinkIfUnselected->setCheckState (Qt::Unchecked);
insilmaril@462
    85
insilmaril@462
    86
		// Layout
insilmaril@462
    87
		if (branch->getIncludeImagesVer())
insilmaril@462
    88
			ui.incImgVer->setCheckState (Qt::Checked);
insilmaril@462
    89
		else	
insilmaril@462
    90
			ui.incImgVer->setCheckState (Qt::Unchecked);
insilmaril@462
    91
		if (branch->getIncludeImagesHor())
insilmaril@462
    92
			ui.incImgHor->setCheckState (Qt::Checked);
insilmaril@462
    93
		else	
insilmaril@462
    94
			ui.incImgHor->setCheckState (Qt::Unchecked);
insilmaril@462
    95
insilmaril@462
    96
		// Finally activate signals
insilmaril@462
    97
		connectSignals();
insilmaril@440
    98
	} else
insilmaril@421
    99
	{
insilmaril@440
   100
		ui.tabWidget->setEnabled (false);
insilmaril@421
   101
	}
insilmaril@421
   102
}
insilmaril@421
   103
insilmaril@421
   104
void BranchPropertyWindow::setMapEditor (MapEditor *me)
insilmaril@421
   105
{
insilmaril@440
   106
	mapEditor=me;
insilmaril@440
   107
	if (mapEditor) 
insilmaril@440
   108
		setBranch (mapEditor->getSelectedBranch() );
insilmaril@440
   109
	else
insilmaril@440
   110
		ui.tabWidget->setEnabled (false);
insilmaril@440
   111
		
insilmaril@421
   112
}
insilmaril@421
   113
insilmaril@421
   114
void BranchPropertyWindow::frameTypeChanged (int i)
insilmaril@421
   115
{
insilmaril@421
   116
	if (mapEditor)
insilmaril@421
   117
		switch (i)
insilmaril@421
   118
		{
insilmaril@462
   119
			case 0: mapEditor->setFrameType (FrameObj::NoFrame); break;
insilmaril@462
   120
			case 1: mapEditor->setFrameType (FrameObj::Rectangle); break;
insilmaril@462
   121
			case 2: mapEditor->setFrameType (FrameObj::Ellipse); break;
insilmaril@421
   122
		}
insilmaril@421
   123
}
insilmaril@421
   124
insilmaril@440
   125
void BranchPropertyWindow::framePenColorClicked()
insilmaril@440
   126
{
insilmaril@440
   127
	if (mapEditor) 
insilmaril@440
   128
	{	
insilmaril@440
   129
		QColor col = QColorDialog::getColor( penColor, this );
insilmaril@440
   130
		if ( col.isValid() ) 
insilmaril@440
   131
		{
insilmaril@440
   132
			penColor=col;
insilmaril@440
   133
			mapEditor->setFramePenColor (penColor);
insilmaril@440
   134
		}	
insilmaril@440
   135
	}
insilmaril@440
   136
}
insilmaril@440
   137
insilmaril@440
   138
void BranchPropertyWindow::frameBrushColorClicked()
insilmaril@440
   139
{
insilmaril@440
   140
	if (mapEditor) 
insilmaril@440
   141
	{
insilmaril@440
   142
		QColor col = QColorDialog::getColor( brushColor, this );
insilmaril@440
   143
		if ( col.isValid() ) 
insilmaril@440
   144
		{
insilmaril@440
   145
			brushColor=col;
insilmaril@440
   146
			mapEditor->setFrameBrushColor (brushColor);
insilmaril@440
   147
		}	
insilmaril@440
   148
	}	
insilmaril@440
   149
}
insilmaril@440
   150
insilmaril@462
   151
void BranchPropertyWindow::framePaddingChanged(int i)
insilmaril@462
   152
{
insilmaril@462
   153
	if (mapEditor) mapEditor->setFramePadding (i);
insilmaril@462
   154
}
insilmaril@462
   155
insilmaril@462
   156
void BranchPropertyWindow::frameBorderWidthChanged(int i)
insilmaril@462
   157
{
insilmaril@462
   158
	if (mapEditor) mapEditor->setFrameBorderWidth(i);
insilmaril@462
   159
}
insilmaril@462
   160
insilmaril@421
   161
void BranchPropertyWindow::linkHideUnselectedChanged (int i)
insilmaril@421
   162
{
insilmaril@421
   163
	if (!branch) return;
insilmaril@462
   164
	mapEditor->setHideLinkUnselected(i);
insilmaril@421
   165
}
insilmaril@421
   166
insilmaril@462
   167
void BranchPropertyWindow::incImgVerChanged (int  i)
insilmaril@462
   168
{
insilmaril@462
   169
	if (mapEditor) mapEditor->setIncludeImagesVer (i);
insilmaril@462
   170
}
insilmaril@462
   171
insilmaril@462
   172
void BranchPropertyWindow::incImgHorChanged (int  i)
insilmaril@462
   173
{
insilmaril@462
   174
	if (mapEditor) mapEditor->setIncludeImagesHor (i);
insilmaril@462
   175
}
insilmaril@462
   176
insilmaril@462
   177
void BranchPropertyWindow::connectSignals()
insilmaril@462
   178
{
insilmaril@462
   179
	// Frame
insilmaril@462
   180
	connect ( 
insilmaril@462
   181
		ui.framePenColorButton, SIGNAL (clicked()), 
insilmaril@462
   182
		this, SLOT (framePenColorClicked()));
insilmaril@462
   183
	connect ( 
insilmaril@462
   184
		ui.framePaddingSpinBox, SIGNAL (valueChanged( int)), 
insilmaril@462
   185
		this, SLOT (framePaddingChanged (int)));
insilmaril@462
   186
	connect ( 
insilmaril@462
   187
		ui.frameWidthSpinBox, SIGNAL (valueChanged( int)), 
insilmaril@462
   188
		this, SLOT (frameBorderWidthChanged (int)));
insilmaril@462
   189
	connect ( 
insilmaril@462
   190
		ui.frameBrushColorButton, SIGNAL (clicked()), 
insilmaril@462
   191
		this, SLOT (frameBrushColorClicked()));
insilmaril@462
   192
	connect ( 
insilmaril@462
   193
		ui.frameTypeCombo, SIGNAL (currentIndexChanged( int)), 
insilmaril@462
   194
		this, SLOT (frameTypeChanged (int)));
insilmaril@462
   195
insilmaril@462
   196
insilmaril@462
   197
	// Link	
insilmaril@462
   198
	connect ( 
insilmaril@462
   199
		ui.hideLinkIfUnselected, SIGNAL (stateChanged( int)), 
insilmaril@462
   200
		this, SLOT (linkHideUnselectedChanged (int)));
insilmaril@462
   201
insilmaril@462
   202
	// Layout	
insilmaril@462
   203
	connect ( 
insilmaril@462
   204
		ui.incImgVer, SIGNAL (stateChanged( int)), 
insilmaril@462
   205
		this, SLOT (incImgVerChanged (int)));
insilmaril@462
   206
	connect ( 
insilmaril@462
   207
		ui.incImgHor, SIGNAL (stateChanged( int)), 
insilmaril@462
   208
		this, SLOT (incImgHorChanged (int)));
insilmaril@462
   209
}
insilmaril@462
   210
insilmaril@462
   211
insilmaril@462
   212
void BranchPropertyWindow::disconnectSignals()
insilmaril@462
   213
{
insilmaril@462
   214
	// Frame
insilmaril@462
   215
	disconnect ( ui.frameTypeCombo, 0,0,0);
insilmaril@462
   216
	disconnect ( ui.framePenColorButton, 0,0,0);
insilmaril@462
   217
	disconnect ( ui.framePaddingSpinBox, 0,0,0);
insilmaril@462
   218
	disconnect ( ui.frameWidthSpinBox, 0,0,0);
insilmaril@462
   219
	disconnect ( ui.frameBrushColorButton, 0,0,0);
insilmaril@462
   220
insilmaril@462
   221
	// Link	
insilmaril@462
   222
	disconnect ( ui.hideLinkIfUnselected, 0,0,0);
insilmaril@462
   223
insilmaril@462
   224
	// Layout	
insilmaril@462
   225
	disconnect ( ui.incImgVer, 0,0,0);
insilmaril@462
   226
	disconnect ( ui.incImgHor, 0,0,0);
insilmaril@462
   227
}
insilmaril@462
   228
insilmaril@462
   229