branchpropwindow.cpp
author insilmaril
Wed May 02 15:31:18 2007 +0000 (2007-05-02)
changeset 485 aff86e2f2a4a
parent 462 494a5b8c131e
child 487 8fca3a710dc4
permissions -rw-r--r--
Mainly documentation fixes
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@480
    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@480
    25
insilmaril@480
    26
insilmaril@480
    27
	// Load Settings
insilmaril@480
    28
	//FIXME setSatelliteName ( "propertyWindow" );
insilmaril@480
    29
	resize (settings.value ( "/satellite/propertywindow/geometry/size", QSize(450,600)).toSize());
insilmaril@480
    30
	move   (settings.value ( "/satellite/propertywindow/geometry/pos", QPoint (250,50)).toPoint());
insilmaril@480
    31
	
insilmaril@480
    32
	if (settings.value ( "/satellite/propertywindow/showWithMain",true).toBool())
insilmaril@480
    33
		show();
insilmaril@480
    34
	else	
insilmaril@480
    35
		hide();
insilmaril@480
    36
insilmaril@462
    37
}
insilmaril@440
    38
insilmaril@462
    39
BranchPropertyWindow::~BranchPropertyWindow ()
insilmaril@462
    40
{
insilmaril@480
    41
	settings.setValue( "/satellite/propertywindow/geometry/size", size() );
insilmaril@480
    42
	settings.setValue( "/satellite/propertywindow/geometry/pos", pos() );
insilmaril@480
    43
insilmaril@421
    44
}
insilmaril@421
    45
insilmaril@421
    46
void BranchPropertyWindow::setBranch (BranchObj *bo)
insilmaril@421
    47
{
insilmaril@462
    48
	disconnectSignals();
insilmaril@421
    49
	branch=bo;
insilmaril@440
    50
	if (bo) 
insilmaril@440
    51
	{
insilmaril@440
    52
		ui.tabWidget->setEnabled (true);
insilmaril@421
    53
insilmaril@440
    54
		// Frame
insilmaril@462
    55
		FrameObj::FrameType t=branch->getFrameType();
insilmaril@462
    56
		if (t==FrameObj::NoFrame)
insilmaril@440
    57
		{
insilmaril@440
    58
			ui.frameTypeCombo->setCurrentIndex (0);
insilmaril@440
    59
			penColor=Qt::white;
insilmaril@440
    60
			brushColor=Qt::white;
insilmaril@440
    61
			ui.colorGroupBox->setEnabled (false);
insilmaril@462
    62
			ui.framePaddingSpinBox->setEnabled (false);
insilmaril@462
    63
			ui.frameWidthSpinBox->setEnabled (false);
insilmaril@480
    64
			ui.framePaddingLabel->setEnabled (false);
insilmaril@480
    65
			ui.frameBorderLabel->setEnabled (false);
insilmaril@440
    66
		} else	
insilmaril@440
    67
		{
insilmaril@440
    68
			penColor=bo->getFramePenColor();
insilmaril@440
    69
			brushColor=bo->getFrameBrushColor();
insilmaril@440
    70
			QPixmap pix( 16,16);
insilmaril@440
    71
			pix.fill (penColor);
insilmaril@480
    72
			ui.framePenColorButton->setPixmap (pix);
insilmaril@440
    73
			pix.fill (brushColor);
insilmaril@440
    74
			ui.frameBrushColorButton->setPixmap (pix);
insilmaril@440
    75
			ui.colorGroupBox->setEnabled (true);
insilmaril@462
    76
			ui.framePaddingSpinBox->setEnabled (true);
insilmaril@462
    77
			ui.framePaddingSpinBox->setValue (bo->getFramePadding());
insilmaril@462
    78
			ui.frameWidthSpinBox->setEnabled (true);
insilmaril@462
    79
			ui.frameWidthSpinBox->setValue (bo->getFrameBorderWidth());
insilmaril@480
    80
			ui.framePaddingLabel->setEnabled (true);
insilmaril@480
    81
			ui.frameBorderLabel->setEnabled (true);
insilmaril@440
    82
insilmaril@440
    83
			switch (t)
insilmaril@440
    84
			{
insilmaril@462
    85
				case FrameObj::Rectangle: 
insilmaril@440
    86
					ui.frameTypeCombo->setCurrentIndex (1);
insilmaril@440
    87
					break;
insilmaril@462
    88
				case FrameObj::Ellipse: 
insilmaril@440
    89
					ui.frameTypeCombo->setCurrentIndex (2);
insilmaril@440
    90
					break;
insilmaril@440
    91
				default: 
insilmaril@440
    92
					break;
insilmaril@440
    93
			}
insilmaril@440
    94
		}	
insilmaril@440
    95
		
insilmaril@440
    96
		// Link
insilmaril@440
    97
		if (branch->getHideLinkUnselected())
insilmaril@440
    98
			ui.hideLinkIfUnselected->setCheckState (Qt::Checked);
insilmaril@440
    99
		else	
insilmaril@440
   100
			ui.hideLinkIfUnselected->setCheckState (Qt::Unchecked);
insilmaril@462
   101
insilmaril@462
   102
		// Layout
insilmaril@462
   103
		if (branch->getIncludeImagesVer())
insilmaril@462
   104
			ui.incImgVer->setCheckState (Qt::Checked);
insilmaril@462
   105
		else	
insilmaril@462
   106
			ui.incImgVer->setCheckState (Qt::Unchecked);
insilmaril@462
   107
		if (branch->getIncludeImagesHor())
insilmaril@462
   108
			ui.incImgHor->setCheckState (Qt::Checked);
insilmaril@462
   109
		else	
insilmaril@462
   110
			ui.incImgHor->setCheckState (Qt::Unchecked);
insilmaril@462
   111
insilmaril@462
   112
		// Finally activate signals
insilmaril@462
   113
		connectSignals();
insilmaril@440
   114
	} else
insilmaril@421
   115
	{
insilmaril@440
   116
		ui.tabWidget->setEnabled (false);
insilmaril@421
   117
	}
insilmaril@421
   118
}
insilmaril@421
   119
insilmaril@421
   120
void BranchPropertyWindow::setMapEditor (MapEditor *me)
insilmaril@421
   121
{
insilmaril@440
   122
	mapEditor=me;
insilmaril@440
   123
	if (mapEditor) 
insilmaril@440
   124
		setBranch (mapEditor->getSelectedBranch() );
insilmaril@440
   125
	else
insilmaril@440
   126
		ui.tabWidget->setEnabled (false);
insilmaril@440
   127
		
insilmaril@421
   128
}
insilmaril@421
   129
insilmaril@421
   130
void BranchPropertyWindow::frameTypeChanged (int i)
insilmaril@421
   131
{
insilmaril@421
   132
	if (mapEditor)
insilmaril@480
   133
	{
insilmaril@421
   134
		switch (i)
insilmaril@421
   135
		{
insilmaril@462
   136
			case 0: mapEditor->setFrameType (FrameObj::NoFrame); break;
insilmaril@462
   137
			case 1: mapEditor->setFrameType (FrameObj::Rectangle); break;
insilmaril@462
   138
			case 2: mapEditor->setFrameType (FrameObj::Ellipse); break;
insilmaril@421
   139
		}
insilmaril@480
   140
		setBranch (branch);
insilmaril@480
   141
	}	
insilmaril@421
   142
}
insilmaril@421
   143
insilmaril@440
   144
void BranchPropertyWindow::framePenColorClicked()
insilmaril@440
   145
{
insilmaril@440
   146
	if (mapEditor) 
insilmaril@440
   147
	{	
insilmaril@440
   148
		QColor col = QColorDialog::getColor( penColor, this );
insilmaril@440
   149
		if ( col.isValid() ) 
insilmaril@440
   150
		{
insilmaril@440
   151
			penColor=col;
insilmaril@440
   152
			mapEditor->setFramePenColor (penColor);
insilmaril@440
   153
		}	
insilmaril@440
   154
	}
insilmaril@440
   155
}
insilmaril@440
   156
insilmaril@440
   157
void BranchPropertyWindow::frameBrushColorClicked()
insilmaril@440
   158
{
insilmaril@440
   159
	if (mapEditor) 
insilmaril@440
   160
	{
insilmaril@440
   161
		QColor col = QColorDialog::getColor( brushColor, this );
insilmaril@440
   162
		if ( col.isValid() ) 
insilmaril@440
   163
		{
insilmaril@440
   164
			brushColor=col;
insilmaril@440
   165
			mapEditor->setFrameBrushColor (brushColor);
insilmaril@440
   166
		}	
insilmaril@440
   167
	}	
insilmaril@440
   168
}
insilmaril@440
   169
insilmaril@462
   170
void BranchPropertyWindow::framePaddingChanged(int i)
insilmaril@462
   171
{
insilmaril@462
   172
	if (mapEditor) mapEditor->setFramePadding (i);
insilmaril@462
   173
}
insilmaril@462
   174
insilmaril@462
   175
void BranchPropertyWindow::frameBorderWidthChanged(int i)
insilmaril@462
   176
{
insilmaril@462
   177
	if (mapEditor) mapEditor->setFrameBorderWidth(i);
insilmaril@462
   178
}
insilmaril@462
   179
insilmaril@421
   180
void BranchPropertyWindow::linkHideUnselectedChanged (int i)
insilmaril@421
   181
{
insilmaril@421
   182
	if (!branch) return;
insilmaril@462
   183
	mapEditor->setHideLinkUnselected(i);
insilmaril@421
   184
}
insilmaril@421
   185
insilmaril@462
   186
void BranchPropertyWindow::incImgVerChanged (int  i)
insilmaril@462
   187
{
insilmaril@462
   188
	if (mapEditor) mapEditor->setIncludeImagesVer (i);
insilmaril@462
   189
}
insilmaril@462
   190
insilmaril@462
   191
void BranchPropertyWindow::incImgHorChanged (int  i)
insilmaril@462
   192
{
insilmaril@462
   193
	if (mapEditor) mapEditor->setIncludeImagesHor (i);
insilmaril@462
   194
}
insilmaril@462
   195
insilmaril@480
   196
void BranchPropertyWindow::closeEvent( QCloseEvent* ce )
insilmaril@480
   197
{
insilmaril@480
   198
    ce->accept();	// can be reopened with show()
insilmaril@480
   199
	hide();
insilmaril@480
   200
	emit (windowClosed() );
insilmaril@480
   201
    return;
insilmaril@480
   202
}
insilmaril@480
   203
insilmaril@480
   204
insilmaril@462
   205
void BranchPropertyWindow::connectSignals()
insilmaril@462
   206
{
insilmaril@462
   207
	// Frame
insilmaril@462
   208
	connect ( 
insilmaril@462
   209
		ui.framePenColorButton, SIGNAL (clicked()), 
insilmaril@462
   210
		this, SLOT (framePenColorClicked()));
insilmaril@462
   211
	connect ( 
insilmaril@462
   212
		ui.framePaddingSpinBox, SIGNAL (valueChanged( int)), 
insilmaril@462
   213
		this, SLOT (framePaddingChanged (int)));
insilmaril@462
   214
	connect ( 
insilmaril@462
   215
		ui.frameWidthSpinBox, SIGNAL (valueChanged( int)), 
insilmaril@462
   216
		this, SLOT (frameBorderWidthChanged (int)));
insilmaril@462
   217
	connect ( 
insilmaril@462
   218
		ui.frameBrushColorButton, SIGNAL (clicked()), 
insilmaril@462
   219
		this, SLOT (frameBrushColorClicked()));
insilmaril@462
   220
	connect ( 
insilmaril@462
   221
		ui.frameTypeCombo, SIGNAL (currentIndexChanged( int)), 
insilmaril@462
   222
		this, SLOT (frameTypeChanged (int)));
insilmaril@462
   223
insilmaril@462
   224
insilmaril@462
   225
	// Link	
insilmaril@462
   226
	connect ( 
insilmaril@462
   227
		ui.hideLinkIfUnselected, SIGNAL (stateChanged( int)), 
insilmaril@462
   228
		this, SLOT (linkHideUnselectedChanged (int)));
insilmaril@462
   229
insilmaril@462
   230
	// Layout	
insilmaril@462
   231
	connect ( 
insilmaril@462
   232
		ui.incImgVer, SIGNAL (stateChanged( int)), 
insilmaril@462
   233
		this, SLOT (incImgVerChanged (int)));
insilmaril@462
   234
	connect ( 
insilmaril@462
   235
		ui.incImgHor, SIGNAL (stateChanged( int)), 
insilmaril@462
   236
		this, SLOT (incImgHorChanged (int)));
insilmaril@462
   237
}
insilmaril@462
   238
insilmaril@462
   239
insilmaril@462
   240
void BranchPropertyWindow::disconnectSignals()
insilmaril@462
   241
{
insilmaril@480
   242
	// Frame 
insilmaril@462
   243
	disconnect ( ui.frameTypeCombo, 0,0,0);
insilmaril@462
   244
	disconnect ( ui.framePenColorButton, 0,0,0);
insilmaril@462
   245
	disconnect ( ui.framePaddingSpinBox, 0,0,0);
insilmaril@462
   246
	disconnect ( ui.frameWidthSpinBox, 0,0,0);
insilmaril@462
   247
	disconnect ( ui.frameBrushColorButton, 0,0,0);
insilmaril@462
   248
insilmaril@462
   249
	// Link	
insilmaril@462
   250
	disconnect ( ui.hideLinkIfUnselected, 0,0,0);
insilmaril@462
   251
insilmaril@462
   252
	// Layout	
insilmaril@462
   253
	disconnect ( ui.incImgVer, 0,0,0);
insilmaril@462
   254
	disconnect ( ui.incImgHor, 0,0,0);
insilmaril@462
   255
}
insilmaril@462
   256
insilmaril@462
   257