summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2012-07-23 01:16:37 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2012-07-23 01:16:37 (GMT)
commit3c7a85af570e5609f4a6625e06410f31fa4d4f0f (patch)
tree6f2f97a520d356bba65bc4b66e824f3e5c05dd99
parent255190589527a6dbe4a6ef26f39abb126d348649 (diff)
debugging and rearranging to find issue
-rw-r--r--src/Preferences.cc34
-rw-r--r--src/editor.cc41
-rw-r--r--src/editor.h4
-rw-r--r--src/mainwin.cc3
4 files changed, 80 insertions, 2 deletions
diff --git a/src/Preferences.cc b/src/Preferences.cc
index 802c50c..d1324d4 100644
--- a/src/Preferences.cc
+++ b/src/Preferences.cc
@@ -55,17 +55,33 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent)
this->defaultmap["editor/fontfamily"] = found_family;
this->defaultmap["editor/fontsize"] = 12;
+
uint savedsize = getValue("editor/fontsize").toUInt();
+
+// disconnect(this->fontSize, SIGNAL(currentIndexChanged(const QString&)),0,0);
+// this, SLOT(on_fontSize_editTextChanged(const QString &)));
+#include <iostream>
+ std::cout << "pref constructor: savedsize" << savedsize << "\n";
QFontDatabase db;
foreach(uint size, db.standardSizes()) {
+ std::cout << "pref iterate standard sizes" << size << "\n";
+ std::cout <<"fontsize->additem started\n";
this->fontSize->addItem(QString::number(size));
+ std::cout <<"fontsize->additem completed\n";
if (size == savedsize) {
+ std::cout << "pref iterate standard sizes - size=savedsize, set index" << this->fontSize->count() - 1 << "\n";
this->fontSize->setCurrentIndex(this->fontSize->count()-1);
}
}
+
+ std::cout << "connect fontsize to onfontsize_edittextchanged\n";
connect(this->fontSize, SIGNAL(currentIndexChanged(const QString&)),
this, SLOT(on_fontSize_editTextChanged(const QString &)));
+ std::cout << "connect fontsize to onfontsize_edittextchanged done \n";
+
+ std::cout << "pref constr: setedtext\n";
+ this->fontSize->setEditText( QString("%1").arg( savedsize ) );
// Setup default settings
this->defaultmap["3dview/colorscheme"] = this->colorSchemeChooser->currentItem()->text();
@@ -164,14 +180,20 @@ void Preferences::on_colorSchemeChooser_itemSelectionChanged()
void Preferences::on_fontChooser_activated(const QString &family)
{
+ std::cout << "on fontchooser activated\n";
QSettings settings;
settings.setValue("editor/fontfamily", family);
+ std::cout << "emitting fontchanged " << getValue("editor/fontsize").toString().toStdString() << "\n";
emit fontChanged(family, getValue("editor/fontsize").toUInt());
}
void Preferences::on_fontSize_editTextChanged(const QString &size)
{
+ /// size can be wrong. ignore it.
+ std::cout << "on fontsize edittextchanged. set settings: " << size.toStdString() << "\n";
uint intsize = size.toUInt();
+ std::cout << "on fontsize edittextchanged. intsize: " << intsize << "\n";
+ std::cout << "on fontisze edittextchanged. othsize" << fontSize->currentText().toStdString() << "\n";
QSettings settings;
settings.setValue("editor/fontsize", intsize);
emit fontChanged(getValue("editor/fontfamily").toString(), intsize);
@@ -251,6 +273,11 @@ void Preferences::removeDefaultSettings()
QVariant Preferences::getValue(const QString &key) const
{
QSettings settings;
+#include <iostream>
+ std::cout << "prefs: getvalue of key: " << key.toStdString() << "\n";
+ std::cout << "prefs: settings.contains key: " << settings.contains(key) << "\n";
+ std::cout << "prefs: settings[key]: " << settings.value(key).toString().toStdString() << "\n";
+ std::cout << "prefs: defaultmap" << this->defaultmap[key].toString().toStdString() << "\n";
assert(settings.contains(key) || this->defaultmap.contains(key));
return settings.value(key, this->defaultmap[key]);
}
@@ -263,20 +290,25 @@ void Preferences::updateGUI()
Qt::MatchExactly);
if (!found.isEmpty()) this->colorSchemeChooser->setCurrentItem(found.first());
+#include <iostream>
QString fontfamily = getValue("editor/fontfamily").toString();
int fidx = this->fontChooser->findText(fontfamily,Qt::MatchContains);
if (fidx >= 0) {
+ std::cout << "font family nofind, set curent index\n";
this->fontChooser->setCurrentIndex(fidx);
}
QString fontsize = getValue("editor/fontsize").toString();
+ std::cout << "updateGUI fontsize:" << fontsize.toStdString() << "\n";
int sidx = this->fontSize->findText(fontsize);
if (sidx >= 0) {
+ std::cout << "font size nofind, set curent index\n";
this->fontSize->setCurrentIndex(sidx);
}
else {
this->fontSize->setEditText(fontsize);
}
+ std::cout << "updateGUI sidx:" << sidx << "\n";
this->openCSGWarningBox->setChecked(getValue("advanced/opencsg_show_warning").toBool());
this->enableOpenCSGBox->setChecked(getValue("advanced/enable_opencsg_opengl1x").toBool());
@@ -288,6 +320,8 @@ void Preferences::updateGUI()
void Preferences::apply() const
{
+ std::cout << "Prefs: apply\n";
+ std::cout << "editor/fontsize: " << getValue("editor/fontsize").toString().toStdString() << "\n";
emit fontChanged(getValue("editor/fontfamily").toString(), getValue("editor/fontsize").toUInt());
emit requestRedraw();
emit openCSGSettingsChanged();
diff --git a/src/editor.cc b/src/editor.cc
index 4482558..5cf5b42 100644
--- a/src/editor.cc
+++ b/src/editor.cc
@@ -1,4 +1,7 @@
#include "editor.h"
+#include "Preferences.h"
+
+#include <iostream>
#ifndef _QCODE_EDIT_
void Editor::indentSelection()
@@ -70,4 +73,42 @@ void Editor::uncommentSelection()
cursor.setPosition(p2, QTextCursor::KeepAnchor);
setTextCursor(cursor);
}
+
+void Editor::zoomIn()
+{
+ // We have the fontsize in two places. one, in the in-memory window font
+ // information that the user sees on the screen, and two, in the
+ // settings which are persistent on disk. Here we make sure they are
+ // in sync - we assume the fontsize from the in-memory window to be accurate,
+ // and trust that there is code elsewhere in OpenSCAD that has initialized
+ // it properly. We update the on-disk Settings with whatever is in the window.
+ //
+ // And of course we increment by one before we do all this.
+ // See also QT's implementation of QEditor
+ QSettings settings;
+ QFont tmp_font = this->font() ;
+ std::cout << "in fontsize cur" << tmp_font.pointSize() << "\n";
+ if ( font().pointSize() >= 1 )
+ tmp_font.setPointSize( 1 + font().pointSize() );
+ else
+ tmp_font.setPointSize( 1 );
+ std::cout << "in new fontsize cur" << tmp_font.pointSize() << "\n";
+ settings.setValue("editor/fontsize", tmp_font.pointSize());
+ this->setFont( tmp_font );
+}
+
+void Editor::zoomOut()
+{
+ QSettings settings;
+ QFont tmp_font = this->font();
+ std::cout << "out fontsize cur" << tmp_font.pointSize() << "\n";
+ if ( font().pointSize() >= 2 )
+ tmp_font.setPointSize( -1 + font().pointSize() );
+ else
+ tmp_font.setPointSize( 1 );
+ std::cout << "out new fontsize cur" << tmp_font.pointSize() << "\n";
+ settings.setValue("editor/fontsize", tmp_font.pointSize());
+ this->setFont( tmp_font );
+}
+
#endif
diff --git a/src/editor.h b/src/editor.h
index 3088d20..f39c067 100644
--- a/src/editor.h
+++ b/src/editor.h
@@ -18,12 +18,12 @@ public:
void setPlainText(const QString& text) { setText(text); }
public slots:
//void zoomIn() { zoom(1); }
- void zoomIn(int n = 1) { zoom(n); }
//void zoomOut() { zoom(-1); }
- void zoomOut(int n = 1) { zoom(-n); }
#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(); }
diff --git a/src/mainwin.cc b/src/mainwin.cc
index 3fdee6b..7c4738c 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -1822,6 +1822,9 @@ MainWindow::preferences()
void MainWindow::setFont(const QString &family, uint size)
{
+#include <iostream>
+ std::cout << "mainwin setFont\n";
+ std::cout << "pref size: " << Preferences::inst()->getValue("editor/fontsize").toUInt() << "\n";
QFont font;
if (!family.isEmpty()) font.setFamily(family);
else font.setFixedPitch(true);
contact: Jan Huwald // Impressum