mainwindow.cpp
changeset 408 c2a05fa925a1
parent 407 5db8dfd30ea2
child 412 8059b6aa74d7
     1.1 --- a/mainwindow.cpp	Thu Nov 23 16:18:26 2006 +0000
     1.2 +++ b/mainwindow.cpp	Fri Dec 08 20:18:56 2006 +0000
     1.3 @@ -169,9 +169,10 @@
     1.4  	// Save Settings
     1.5  	settings.setValue ( "/mainwindow/geometry/size", size() );
     1.6  	settings.setValue ( "/mainwindow/geometry/pos", pos() );
     1.7 -
     1.8  	settings.setValue ("/mainwindow/state",saveState(0));
     1.9  
    1.10 +	settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn());
    1.11 +	settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn());
    1.12  	settings.setValue( "/version/version", vymVersion );
    1.13  	settings.setValue( "/version/builddate", vymBuildDate );
    1.14  
    1.15 @@ -891,6 +892,12 @@
    1.16  	formatMenu->addAction (a);
    1.17      connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) );
    1.18      actionFormatBackColor=a;
    1.19 +
    1.20 +    a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this );
    1.21 +	a->setStatusTip (tr( "Set Background image" ));
    1.22 +	formatMenu->addAction (a);
    1.23 +    connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) );
    1.24 +    actionFormatBackImage=a;
    1.25  }
    1.26  
    1.27  // View Actions
    1.28 @@ -946,14 +953,30 @@
    1.29      connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) );
    1.30  	actionViewToggleHistoryWindow=a;
    1.31  
    1.32 +    a = new QAction(tr( "Antialiasing","View action" ),this );
    1.33 +	a->setStatusTip ( tr( "Antialiasing" ));
    1.34 +	a->setToggleAction(true);
    1.35 +	a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool());
    1.36 +	viewMenu->addAction (a);
    1.37 +    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) );
    1.38 +	actionViewToggleAntiAlias=a;
    1.39 +
    1.40 +    a = new QAction(tr( "Smooth pixmap transformations","View action" ),this );
    1.41 +	a->setStatusTip (a->text());
    1.42 +	a->setToggleAction(true);
    1.43 +	a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool());
    1.44 +	viewMenu->addAction (a);
    1.45 +    connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) );
    1.46 +	actionViewToggleSmoothPixmapTransform=a;
    1.47 +
    1.48      a = new QAction(tr( "Next Window","View action" ), this);
    1.49 -	a->setStatusTip ( tr( "&Next Window" ) );
    1.50 +	a->setStatusTip (a->text());
    1.51  	a->setShortcut (Qt::ALT + Qt::Key_N );
    1.52  	viewMenu->addAction (a);
    1.53      connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) );
    1.54  
    1.55      a = new QAction (tr( "Previous Window","View action" ), this );
    1.56 -	a->setStatusTip (tr( "&Previous Window" ));
    1.57 +	a->setStatusTip (a->text());
    1.58  	a->setShortcut (Qt::ALT + Qt::Key_P );
    1.59  	viewMenu->addAction (a);
    1.60      connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) );
    1.61 @@ -1041,7 +1064,7 @@
    1.62  	standardFlagsDefault->setName ("standardFlagsDef");
    1.63  	standardFlagsDefault->setToolBar (tb);
    1.64  
    1.65 -	fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
    1.66 +	fo->load(flagsPath+"flag-exclamationmark.png");
    1.67  	fo->setName ("exclamationmark");
    1.68  	fo->setGroup("standard-mark");
    1.69  	QAction *a=new QAction (fo->getPixmap(),fo->getName(),this);
    1.70 @@ -1053,7 +1076,7 @@
    1.71  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
    1.72  	standardFlagsDefault->addFlag (fo);	// makes deep copy
    1.73  	
    1.74 -	fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
    1.75 +	fo->load(flagsPath+"flag-questionmark.png");
    1.76  	fo->setName("questionmark");
    1.77  	fo->setGroup("standard-mark");
    1.78  	a=new QAction (fo->getPixmap(),fo->getName(),this);
    1.79 @@ -1065,7 +1088,7 @@
    1.80  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
    1.81  	standardFlagsDefault->addFlag (fo);	
    1.82  
    1.83 -	fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
    1.84 +	fo->load(flagsPath+"flag-hook-green.png");
    1.85  	fo->setName("hook-green");
    1.86  	fo->setGroup("standard-hook");
    1.87  	a=new QAction (fo->getPixmap(),fo->getName(),this);
    1.88 @@ -1077,7 +1100,7 @@
    1.89  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
    1.90  	standardFlagsDefault->addFlag (fo);	
    1.91  
    1.92 -	fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
    1.93 +	fo->load(flagsPath+"flag-cross-red.png");
    1.94  	fo->setName("cross-red");
    1.95  	fo->setGroup("standard-hook");
    1.96  	a=new QAction (fo->getPixmap(),fo->getName(),this);
    1.97 @@ -1089,7 +1112,7 @@
    1.98  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
    1.99  	standardFlagsDefault->addFlag (fo);	
   1.100  
   1.101 -	fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
   1.102 +	fo->load(flagsPath+"flag-stopsign.png");
   1.103  	fo->setName("stopsign");
   1.104  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.105  	tb->addAction (a);
   1.106 @@ -1100,7 +1123,7 @@
   1.107  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.108  	standardFlagsDefault->addFlag (fo);	
   1.109  
   1.110 -	fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
   1.111 +	fo->load(flagsPath+"flag-smiley-good.png");
   1.112  	fo->setName("smiley-good");
   1.113  	fo->setGroup("standard-smiley");
   1.114  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.115 @@ -1112,7 +1135,7 @@
   1.116  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.117  	standardFlagsDefault->addFlag (fo);	
   1.118  
   1.119 -	fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
   1.120 +	fo->load(flagsPath+"flag-smiley-sad.png");
   1.121  	fo->setName("smiley-sad");
   1.122  	fo->setGroup("standard-smiley");
   1.123  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.124 @@ -1124,7 +1147,7 @@
   1.125  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.126  	standardFlagsDefault->addFlag (fo);	
   1.127  
   1.128 -	fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
   1.129 +	fo->load(flagsPath+"flag-smiley-omg.png");
   1.130  	// Original omg.png (in KDE emoticons)
   1.131  	fo->setName("smiley-omg");
   1.132  	fo->setGroup("standard-smiley");
   1.133 @@ -1137,7 +1160,7 @@
   1.134  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.135  	standardFlagsDefault->addFlag (fo);	
   1.136  
   1.137 -	fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
   1.138 +	fo->load(flagsPath+"flag-kalarm.png");
   1.139  	fo->setName("clock");
   1.140  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.141  	tb->addAction (a);
   1.142 @@ -1148,7 +1171,7 @@
   1.143  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.144  	standardFlagsDefault->addFlag (fo);	
   1.145  
   1.146 -	fo->load(QPixmap(flagsPath+"flag-phone.png"));
   1.147 +	fo->load(flagsPath+"flag-phone.png");
   1.148  	fo->setName("phone");
   1.149  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.150  	tb->addAction (a);
   1.151 @@ -1159,7 +1182,7 @@
   1.152  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.153  	standardFlagsDefault->addFlag (fo);	
   1.154  
   1.155 -	fo->load(QPixmap(flagsPath+"flag-lamp.png"));
   1.156 +	fo->load(flagsPath+"flag-lamp.png");
   1.157  	fo->setName("lamp");
   1.158  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.159  	tb->addAction (a);
   1.160 @@ -1170,7 +1193,7 @@
   1.161  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.162  	standardFlagsDefault->addFlag (fo);	
   1.163  
   1.164 -	fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
   1.165 +	fo->load(flagsPath+"flag-arrow-up.png");
   1.166  	fo->setName("arrow-up");
   1.167  	fo->setGroup("standard-arrow");
   1.168  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.169 @@ -1182,7 +1205,7 @@
   1.170  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.171  	standardFlagsDefault->addFlag (fo);	
   1.172  
   1.173 -	fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
   1.174 +	fo->load(flagsPath+"flag-arrow-down.png");
   1.175  	fo->setName("arrow-down");
   1.176  	fo->setGroup("standard-arrow");
   1.177  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.178 @@ -1194,7 +1217,7 @@
   1.179  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.180  	standardFlagsDefault->addFlag (fo);	
   1.181  
   1.182 -	fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
   1.183 +	fo->load(flagsPath+"flag-arrow-2up.png");
   1.184  	fo->setName("2arrow-up");
   1.185  	fo->setGroup("standard-arrow");
   1.186  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.187 @@ -1206,7 +1229,7 @@
   1.188  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.189  	standardFlagsDefault->addFlag (fo);	
   1.190  
   1.191 -	fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
   1.192 +	fo->load(flagsPath+"flag-arrow-2down.png");
   1.193  	fo->setName("2arrow-down");
   1.194  	fo->setGroup("standard-arrow");
   1.195  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.196 @@ -1218,7 +1241,7 @@
   1.197  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.198  	standardFlagsDefault->addFlag (fo);	
   1.199  
   1.200 -	fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
   1.201 +	fo->load(flagsPath+"flag-thumb-up.png");
   1.202  	fo->setName("thumb-up");
   1.203  	fo->setGroup("standard-thumb");
   1.204  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.205 @@ -1230,7 +1253,7 @@
   1.206  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.207  	standardFlagsDefault->addFlag (fo);	
   1.208  
   1.209 -	fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
   1.210 +	fo->load(flagsPath+"flag-thumb-down.png");
   1.211  	fo->setName("thumb-down");
   1.212  	fo->setGroup("standard-thumb");
   1.213  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.214 @@ -1242,7 +1265,7 @@
   1.215  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.216  	standardFlagsDefault->addFlag (fo);	
   1.217  	
   1.218 -	fo->load(QPixmap(flagsPath+"flag-rose.png"));
   1.219 +	fo->load(flagsPath+"flag-rose.png");
   1.220  	fo->setName("rose");
   1.221  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.222  	tb->addAction (a);
   1.223 @@ -1253,7 +1276,7 @@
   1.224  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.225  	standardFlagsDefault->addFlag (fo);	
   1.226  
   1.227 -	fo->load(QPixmap(flagsPath+"flag-heart.png"));
   1.228 +	fo->load(flagsPath+"flag-heart.png");
   1.229  	fo->setName("heart");
   1.230  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.231  	tb->addAction (a);
   1.232 @@ -1263,7 +1286,7 @@
   1.233  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.234  	standardFlagsDefault->addFlag (fo);	
   1.235  
   1.236 -	fo->load(QPixmap(flagsPath+"flag-present.png"));
   1.237 +	fo->load(flagsPath+"flag-present.png");
   1.238  	fo->setName("present");
   1.239  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.240  	tb->addAction (a);
   1.241 @@ -1274,7 +1297,7 @@
   1.242  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.243  	standardFlagsDefault->addFlag (fo);	
   1.244  
   1.245 -	fo->load(QPixmap(flagsPath+"flag-flash.png"));
   1.246 +	fo->load(flagsPath+"flag-flash.png");
   1.247  	fo->setName("flash");
   1.248  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.249  	tb->addAction (a);
   1.250 @@ -1285,7 +1308,7 @@
   1.251  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.252  	standardFlagsDefault->addFlag (fo);	
   1.253  	
   1.254 -	fo->load(QPixmap(flagsPath+"flag-info.png"));
   1.255 +	fo->load(flagsPath+"flag-info.png");
   1.256  	// Original: xsldbg_output.png
   1.257  	fo->setName("info");
   1.258  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.259 @@ -1297,7 +1320,7 @@
   1.260  	connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) );
   1.261  	standardFlagsDefault->addFlag (fo);	
   1.262  
   1.263 -	fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
   1.264 +	fo->load(flagsPath+"flag-lifebelt.png");
   1.265  	// Original khelpcenter.png
   1.266  	fo->setName("lifebelt");
   1.267  	a=new QAction (fo->getPixmap(),fo->getName(),this);
   1.268 @@ -1507,6 +1530,7 @@
   1.269  	actionFormatLinkColorHint->addTo( canvasContextMenu );
   1.270  	actionFormatLinkColor->addTo( canvasContextMenu );
   1.271  	actionFormatBackColor->addTo( canvasContextMenu );
   1.272 +	actionFormatBackImage->addTo( canvasContextMenu );
   1.273  
   1.274  	// Menu for last opened files
   1.275  	// Create actions
   1.276 @@ -1620,12 +1644,15 @@
   1.277  void Main::fileNew()
   1.278  {
   1.279  	QString fn="unnamed";
   1.280 -	MapEditor* medit = new MapEditor ( NULL);
   1.281 -	tabWidget->addTab (medit,fn);
   1.282 -	tabWidget->showPage(medit);
   1.283 -	medit->viewport()->setFocus();
   1.284 +	MapEditor* me = new MapEditor ( NULL);
   1.285 +	tabWidget->addTab (me,fn);
   1.286 +	tabWidget->showPage(me);
   1.287 +	me->viewport()->setFocus();
   1.288 +	me->setAntiAlias (actionViewToggleAntiAlias->isOn());
   1.289 +	me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
   1.290 +	
   1.291  	// For the very first map we do not have flagrows yet...
   1.292 -	medit->select("mc:");
   1.293 +	me->select("mc:");
   1.294  }
   1.295  
   1.296  ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
   1.297 @@ -1692,6 +1719,8 @@
   1.298  			tabWidget->addTab (me,fn);
   1.299  			tabIndex=tabWidget->indexOf (me);
   1.300  			tabWidget->setCurrentPage (tabIndex);
   1.301 +			me->setAntiAlias (actionViewToggleAntiAlias->isOn());
   1.302 +			me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn());
   1.303  		}
   1.304  		
   1.305  		// Check, if file exists (important for creating new files
   1.306 @@ -2629,7 +2658,7 @@
   1.307  			if (ok)
   1.308  			{
   1.309  #if defined(Q_OS_MACX)
   1.310 -				p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p));
   1.311 +				p=currentMapEditor()->mapTo (this,p);
   1.312  				QDialog *d =new QDialog(NULL);
   1.313  				QLineEdit *le=new QLineEdit (d);
   1.314  				d->setWindowFlags (Qt::FramelessWindowHint);
   1.315 @@ -2645,7 +2674,7 @@
   1.316  				delete (d);
   1.317  				editHeadingFinished();
   1.318  #else
   1.319 -				p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p));
   1.320 +				p=currentMapEditor()->mapTo (this,p);
   1.321  				lineedit->setGeometry(p.x(),p.y(),230,25);
   1.322  				lineedit->setText(s);
   1.323  				lineedit->setCursorPosition(1);
   1.324 @@ -3011,6 +3040,12 @@
   1.325  		currentMapEditor()->selectMapBackgroundColor();
   1.326  }
   1.327  
   1.328 +void Main::formatSelectBackImage()
   1.329 +{
   1.330 +	if (currentMapEditor())
   1.331 +		currentMapEditor()->selectMapBackgroundImage();
   1.332 +}
   1.333 +
   1.334  void Main::formatSelectLinkColor()
   1.335  {
   1.336  	if (currentMapEditor())
   1.337 @@ -3058,7 +3093,7 @@
   1.338  	{
   1.339  		QMatrix m;
   1.340  		m.reset();
   1.341 -		currentMapEditor()->setWorldMatrix( m );
   1.342 +		currentMapEditor()->setMatrix( m );
   1.343  		currentMapEditor()->setViewCenter();
   1.344  		currentMapEditor()->adjustCanvasSize();
   1.345  	}	
   1.346 @@ -3068,9 +3103,9 @@
   1.347  {
   1.348  	if (currentMapEditor())
   1.349  	{
   1.350 -		QMatrix m = currentMapEditor()->worldMatrix();
   1.351 +		QMatrix m = currentMapEditor()->matrix();
   1.352  		m.scale( 1.25, 1.25 );
   1.353 -		currentMapEditor()->setWorldMatrix( m );
   1.354 +		currentMapEditor()->setMatrix( m );
   1.355  		currentMapEditor()->setViewCenter();
   1.356  		currentMapEditor()->adjustCanvasSize();
   1.357  	}	
   1.358 @@ -3080,9 +3115,9 @@
   1.359  {
   1.360  	if (currentMapEditor())
   1.361  	{
   1.362 -		QMatrix m = currentMapEditor()->worldMatrix();
   1.363 +		QMatrix m = currentMapEditor()->matrix();
   1.364  		m.scale( 0.8, 0.8 );
   1.365 -		currentMapEditor()->setWorldMatrix( m );
   1.366 +		currentMapEditor()->setMatrix( m );
   1.367  		currentMapEditor()->setViewCenter();
   1.368  		currentMapEditor()->adjustCanvasSize();
   1.369  	}	
   1.370 @@ -3142,6 +3177,31 @@
   1.371  
   1.372  }
   1.373  
   1.374 +void Main::windowToggleAntiAlias()
   1.375 +{
   1.376 +	bool b=actionViewToggleAntiAlias->isOn();
   1.377 +	MapEditor *me;
   1.378 +	for (int i=0;i<tabWidget->count();i++)
   1.379 +	{
   1.380 +		
   1.381 +		me=(MapEditor*)tabWidget->page(i);
   1.382 +		me->setAntiAlias(b);
   1.383 +	}	
   1.384 +
   1.385 +}
   1.386 +
   1.387 +void Main::windowToggleSmoothPixmap()
   1.388 +{
   1.389 +	bool b=actionViewToggleSmoothPixmapTransform->isOn();
   1.390 +	MapEditor *me;
   1.391 +	for (int i=0;i<tabWidget->count();i++)
   1.392 +	{
   1.393 +		
   1.394 +		me=(MapEditor*)tabWidget->page(i);
   1.395 +		me->setSmoothPixmap(b);
   1.396 +	}	
   1.397 +}
   1.398 +
   1.399  void Main::updateHistory(SimpleSettings &undoSet)
   1.400  {
   1.401  	historyWindow->update (undoSet);
   1.402 @@ -3457,12 +3517,12 @@
   1.403  	}
   1.404  	
   1.405  	QString docpath=docdir.path()+"/"+docname;
   1.406 +	QStringList args;
   1.407  	Process *pdfProc = new Process();
   1.408 -	pdfProc->clearArguments();
   1.409 -	pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString());
   1.410 -	pdfProc->addArgument( docpath);
   1.411 -
   1.412 -	if ( !pdfProc->start() ) 
   1.413 +	args <<docpath;
   1.414 +
   1.415 +	pdfProc->start( settings.value("/mainwindow/readerPDF").toString());
   1.416 +	if ( !pdfProc->waitForStarted() ) 
   1.417  	{
   1.418  		// error handling
   1.419  		QMessageBox::warning(0,