Merge pull request #155 from openscad/fontsize_save

Fontsize save
felipesanches-svg
Marius Kintel 2012-07-23 19:40:22 -07:00
commit dcb8c20119
3 changed files with 45 additions and 0 deletions

View File

@ -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;

View File

@ -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

View File

@ -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
};