Skip to content

Commit

Permalink
Merge pull request #1 from hkiel/omshell_settings_fontsize
Browse files Browse the repository at this point in the history
store font size in settings file
  • Loading branch information
hkiel committed Feb 8, 2016
2 parents 12b2653 + ed1011a commit 56525d3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -25,3 +25,4 @@ mosh/src/Makefile
mosh/src/OMShell-terminal
mosh/src/omc_communication.cc
mosh/src/omc_communication.h
qmake.sh
34 changes: 29 additions & 5 deletions OMShell/OMShellGUI/oms.cpp
Expand Up @@ -213,7 +213,7 @@ void MyTextEdit::insertFromMimeData(const QMimeData *source)


OMS::OMS( QWidget* parent )
: QMainWindow( parent )
: QMainWindow( parent ), mpSettings(getApplicationSettings())
{
delegate_ = 0;
omc_version_ = "(version)";
Expand All @@ -235,7 +235,11 @@ OMS::OMS( QWidget* parent )
layout_->setMargin( 0 );
layout_->setSpacing( 5 );

fontSize_ = 11;
mpSettings->sync();
if (mpSettings->contains("FontSize"))
fontSize_ = mpSettings->value("FontSize").toInt();
else
fontSize_ = 11;
createMoshEdit();
//createMoshError();
createAction();
Expand All @@ -252,7 +256,7 @@ OMS::OMS( QWidget* parent )
setWindowTitle( tr("OMShell - OpenModelica Shell") );
setWindowIcon( QIcon(":/Resources/omshell-large.svg") );

// sett start message
// set start message
const char* dateStr = __DATE__; // "Mmm dd yyyy", so dateStr+7 = "yyyy"
copyright_info_ = QString("OMShell 1.1 Copyright Open Source Modelica Consortium (OSMC) 2002-") + (dateStr+7) + "\nDistributed under OMSC-PL and GPL, see www.openmodelica.org\n\nConnected to " + omc_version_;
cursor_.insertText( copyright_info_, textFormat_ );
Expand Down Expand Up @@ -446,7 +450,7 @@ void OMS::addCommandLine()
cursor_.movePosition( QTextCursor::End, QTextCursor::MoveAnchor );
moshEdit_->setTextCursor( cursor_ );

// sett original text settings
// set original text settings
moshEdit_->document()->setDefaultFont(QFont("Courier New", fontSize_, QFont::Normal));
textFormat_.setFontFamily( "Courier New" );
textFormat_.setFontWeight( QFont::Normal );
Expand Down Expand Up @@ -838,10 +842,14 @@ void OMS::fontSize()
font.setPointSize(fontSize_);
moshEdit_->document()->setDefaultFont(font);
textFormat_.setFontPointSize( fontSize_ );
commandSignFormat_.setFontPointSize( fontSize_ );

//cursor_ = moshEdit_->textCursor();
cursor_.clearSelection();
moshEdit_->setTextCursor(cursor_);

mpSettings->setValue("FontSize", fontSize_);
mpSettings->sync();
}
else
{
Expand Down Expand Up @@ -944,7 +952,7 @@ void OMS::clear()
{
moshEdit_->clear();

// sett original text settings
// set original text settings
moshEdit_->document()->setDefaultFont(QFont("Courier New", fontSize_, QFont::Normal));

addCommandLine();
Expand Down Expand Up @@ -976,3 +984,19 @@ void OMS::paste()
((MyTextEdit*)moshEdit_)->sendKey( key );
}

QString OMS::organization = "openmodelica"; /* case-sensitive string. Don't change it. Used by ini settings file. */
QString OMS::application = "omshell"; /* case-sensitive string. Don't change it. Used by ini settings file. */
QString OMS::utf8 = "UTF-8";

QSettings* OMS::getApplicationSettings()
{
static int init = 0;
static QSettings *pSettings;
if (!init) {
init = 1;
pSettings = new QSettings(QSettings::IniFormat, QSettings::UserScope, organization, application);
pSettings->setIniCodec(utf8.toStdString().data());
}
return pSettings;
}

8 changes: 8 additions & 0 deletions OMShell/OMShellGUI/oms.h
Expand Up @@ -68,6 +68,7 @@ using namespace std;
#include <QtGui/QTextCharFormat>
#include <QtGui/QTextCursor>
#include <QtGui/QPlainTextEdit>
#include <QtCore/QSettings>
#endif

//IAEX Headers
Expand Down Expand Up @@ -136,6 +137,7 @@ private slots:
QVBoxLayout* layout_;
QString clipboard_;
QString copyright_info_;
QSettings *mpSettings;

IAEX::CommandCompletion* commandcompletion_;
int fontSize_;
Expand All @@ -162,6 +164,12 @@ private slots:
QAction* aboutOMS_;
QAction* aboutQT_; // Added 2006-02-21 AF
QAction* clearWindow_;

static QString organization;
static QString application;
static QString utf8;

QSettings* getApplicationSettings();
};

//********************************
Expand Down

0 comments on commit 56525d3

Please sign in to comment.