diff options
| -rw-r--r-- | src/Preferences.cc | 3 | ||||
| -rw-r--r-- | src/editor.cc | 37 | ||||
| -rw-r--r-- | src/editor.h | 5 | 
3 files changed, 45 insertions, 0 deletions
diff --git a/src/Preferences.cc b/src/Preferences.cc index 802c50c..e70a2a1 100644 --- a/src/Preferences.cc +++ b/src/Preferences.cc @@ -67,6 +67,9 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent)  	connect(this->fontSize, SIGNAL(currentIndexChanged(const QString&)),  					this, SLOT(on_fontSize_editTextChanged(const QString &))); +	// reset GUI fontsize if fontSize->addItem emitted signals that changed it. +	this->fontSize->setEditText( QString("%1").arg( savedsize ) ); +  	// Setup default settings  	this->defaultmap["3dview/colorscheme"] = this->colorSchemeChooser->currentItem()->text();  	this->defaultmap["advanced/opencsg_show_warning"] = true; diff --git a/src/editor.cc b/src/editor.cc index 4482558..bba8d4f 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -1,4 +1,5 @@  #include "editor.h" +#include "Preferences.h"  #ifndef _QCODE_EDIT_  void Editor::indentSelection() @@ -70,4 +71,40 @@ void Editor::uncommentSelection()  	cursor.setPosition(p2, QTextCursor::KeepAnchor);  	setTextCursor(cursor);  } + +void Editor::zoomIn() +{ +	// See also QT's implementation in QEditor.cpp +	QSettings settings; +	QFont tmp_font = this->font() ; +	if ( font().pointSize() >= 1 ) +		tmp_font.setPointSize( 1 + font().pointSize() ); +	else +		tmp_font.setPointSize( 1 ); +	settings.setValue("editor/fontsize", tmp_font.pointSize()); +	this->setFont( tmp_font ); +} + +void Editor::zoomOut() +{ +	QSettings settings; +	QFont tmp_font = this->font(); +	if ( font().pointSize() >= 2 ) +		tmp_font.setPointSize( -1 + font().pointSize() ); +	else +		tmp_font.setPointSize( 1 ); +	settings.setValue("editor/fontsize", tmp_font.pointSize()); +	this->setFont( tmp_font ); +} + +void Editor::wheelEvent ( QWheelEvent * event ) +{ +	if (event->modifiers() == Qt::ControlModifier) { +		if (event->delta() > 0 ) +			zoomIn(); +		else if (event->delta() < 0 ) +			zoomOut(); +	} +} +  #endif diff --git a/src/editor.h b/src/editor.h index 3088d20..bb338b0 100644 --- a/src/editor.h +++ b/src/editor.h @@ -1,6 +1,7 @@  #include <QObject>  #include <QString>  #include <QWidget> +#include <QWheelEvent>  #ifdef _QCODE_EDIT_  #include <qeditor.h> @@ -24,6 +25,8 @@ public slots:  #else  	Editor(QWidget *parent) : QTextEdit(parent) { setAcceptRichText(false); }  public slots: +	void zoomIn(); +	void zoomOut();  	void setLineWrapping(bool on) { if(on) setWordWrapMode(QTextOption::WrapAnywhere); }  	void setContentModified(bool y) { document()->setModified(y); }  	bool isContentModified() { return document()->isModified(); } @@ -31,5 +34,7 @@ public slots:  	void unindentSelection();  	void commentSelection();  	void uncommentSelection(); +private: +	void wheelEvent ( QWheelEvent * event );  #endif  };  | 
