remove debugging statements

felipesanches-svg
don bright 2012-07-22 20:45:12 -05:00
parent 3c7a85af57
commit b33a02b372
4 changed files with 4 additions and 50 deletions

View File

@ -55,32 +55,19 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent)
this->defaultmap["editor/fontfamily"] = found_family; this->defaultmap["editor/fontfamily"] = found_family;
this->defaultmap["editor/fontsize"] = 12; this->defaultmap["editor/fontsize"] = 12;
uint savedsize = getValue("editor/fontsize").toUInt(); 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; QFontDatabase db;
foreach(uint size, db.standardSizes()) { 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)); this->fontSize->addItem(QString::number(size));
std::cout <<"fontsize->additem completed\n";
if (size == savedsize) { 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); this->fontSize->setCurrentIndex(this->fontSize->count()-1);
} }
} }
std::cout << "connect fontsize to onfontsize_edittextchanged\n";
connect(this->fontSize, SIGNAL(currentIndexChanged(const QString&)), connect(this->fontSize, SIGNAL(currentIndexChanged(const QString&)),
this, SLOT(on_fontSize_editTextChanged(const QString &))); this, SLOT(on_fontSize_editTextChanged(const QString &)));
std::cout << "connect fontsize to onfontsize_edittextchanged done \n";
std::cout << "pref constr: setedtext\n"; // reset GUI fontsize if fontSize->addItem emitted signals that changed it.
this->fontSize->setEditText( QString("%1").arg( savedsize ) ); this->fontSize->setEditText( QString("%1").arg( savedsize ) );
// Setup default settings // Setup default settings
@ -180,20 +167,14 @@ void Preferences::on_colorSchemeChooser_itemSelectionChanged()
void Preferences::on_fontChooser_activated(const QString &family) void Preferences::on_fontChooser_activated(const QString &family)
{ {
std::cout << "on fontchooser activated\n";
QSettings settings; QSettings settings;
settings.setValue("editor/fontfamily", family); settings.setValue("editor/fontfamily", family);
std::cout << "emitting fontchanged " << getValue("editor/fontsize").toString().toStdString() << "\n";
emit fontChanged(family, getValue("editor/fontsize").toUInt()); emit fontChanged(family, getValue("editor/fontsize").toUInt());
} }
void Preferences::on_fontSize_editTextChanged(const QString &size) 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(); uint intsize = size.toUInt();
std::cout << "on fontsize edittextchanged. intsize: " << intsize << "\n";
std::cout << "on fontisze edittextchanged. othsize" << fontSize->currentText().toStdString() << "\n";
QSettings settings; QSettings settings;
settings.setValue("editor/fontsize", intsize); settings.setValue("editor/fontsize", intsize);
emit fontChanged(getValue("editor/fontfamily").toString(), intsize); emit fontChanged(getValue("editor/fontfamily").toString(), intsize);
@ -273,11 +254,6 @@ void Preferences::removeDefaultSettings()
QVariant Preferences::getValue(const QString &key) const QVariant Preferences::getValue(const QString &key) const
{ {
QSettings settings; 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)); assert(settings.contains(key) || this->defaultmap.contains(key));
return settings.value(key, this->defaultmap[key]); return settings.value(key, this->defaultmap[key]);
} }
@ -290,25 +266,20 @@ void Preferences::updateGUI()
Qt::MatchExactly); Qt::MatchExactly);
if (!found.isEmpty()) this->colorSchemeChooser->setCurrentItem(found.first()); if (!found.isEmpty()) this->colorSchemeChooser->setCurrentItem(found.first());
#include <iostream>
QString fontfamily = getValue("editor/fontfamily").toString(); QString fontfamily = getValue("editor/fontfamily").toString();
int fidx = this->fontChooser->findText(fontfamily,Qt::MatchContains); int fidx = this->fontChooser->findText(fontfamily,Qt::MatchContains);
if (fidx >= 0) { if (fidx >= 0) {
std::cout << "font family nofind, set curent index\n";
this->fontChooser->setCurrentIndex(fidx); this->fontChooser->setCurrentIndex(fidx);
} }
QString fontsize = getValue("editor/fontsize").toString(); QString fontsize = getValue("editor/fontsize").toString();
std::cout << "updateGUI fontsize:" << fontsize.toStdString() << "\n";
int sidx = this->fontSize->findText(fontsize); int sidx = this->fontSize->findText(fontsize);
if (sidx >= 0) { if (sidx >= 0) {
std::cout << "font size nofind, set curent index\n";
this->fontSize->setCurrentIndex(sidx); this->fontSize->setCurrentIndex(sidx);
} }
else { else {
this->fontSize->setEditText(fontsize); this->fontSize->setEditText(fontsize);
} }
std::cout << "updateGUI sidx:" << sidx << "\n";
this->openCSGWarningBox->setChecked(getValue("advanced/opencsg_show_warning").toBool()); this->openCSGWarningBox->setChecked(getValue("advanced/opencsg_show_warning").toBool());
this->enableOpenCSGBox->setChecked(getValue("advanced/enable_opencsg_opengl1x").toBool()); this->enableOpenCSGBox->setChecked(getValue("advanced/enable_opencsg_opengl1x").toBool());
@ -320,8 +291,6 @@ void Preferences::updateGUI()
void Preferences::apply() const 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 fontChanged(getValue("editor/fontfamily").toString(), getValue("editor/fontsize").toUInt());
emit requestRedraw(); emit requestRedraw();
emit openCSGSettingsChanged(); emit openCSGSettingsChanged();

View File

@ -1,8 +1,6 @@
#include "editor.h" #include "editor.h"
#include "Preferences.h" #include "Preferences.h"
#include <iostream>
#ifndef _QCODE_EDIT_ #ifndef _QCODE_EDIT_
void Editor::indentSelection() void Editor::indentSelection()
{ {
@ -76,23 +74,13 @@ void Editor::uncommentSelection()
void Editor::zoomIn() void Editor::zoomIn()
{ {
// We have the fontsize in two places. one, in the in-memory window font // See also QT's implementation of QEditor.
// 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; QSettings settings;
QFont tmp_font = this->font() ; QFont tmp_font = this->font() ;
std::cout << "in fontsize cur" << tmp_font.pointSize() << "\n";
if ( font().pointSize() >= 1 ) if ( font().pointSize() >= 1 )
tmp_font.setPointSize( 1 + font().pointSize() ); tmp_font.setPointSize( 1 + font().pointSize() );
else else
tmp_font.setPointSize( 1 ); tmp_font.setPointSize( 1 );
std::cout << "in new fontsize cur" << tmp_font.pointSize() << "\n";
settings.setValue("editor/fontsize", tmp_font.pointSize()); settings.setValue("editor/fontsize", tmp_font.pointSize());
this->setFont( tmp_font ); this->setFont( tmp_font );
} }
@ -101,12 +89,10 @@ void Editor::zoomOut()
{ {
QSettings settings; QSettings settings;
QFont tmp_font = this->font(); QFont tmp_font = this->font();
std::cout << "out fontsize cur" << tmp_font.pointSize() << "\n";
if ( font().pointSize() >= 2 ) if ( font().pointSize() >= 2 )
tmp_font.setPointSize( -1 + font().pointSize() ); tmp_font.setPointSize( -1 + font().pointSize() );
else else
tmp_font.setPointSize( 1 ); tmp_font.setPointSize( 1 );
std::cout << "out new fontsize cur" << tmp_font.pointSize() << "\n";
settings.setValue("editor/fontsize", tmp_font.pointSize()); settings.setValue("editor/fontsize", tmp_font.pointSize());
this->setFont( tmp_font ); this->setFont( tmp_font );
} }

View File

@ -18,7 +18,9 @@ public:
void setPlainText(const QString& text) { setText(text); } void setPlainText(const QString& text) { setText(text); }
public slots: public slots:
//void zoomIn() { zoom(1); } //void zoomIn() { zoom(1); }
void zoomIn(int n = 1) { zoom(n); }
//void zoomOut() { zoom(-1); } //void zoomOut() { zoom(-1); }
void zoomOut(int n = 1) { zoom(-n); }
#else #else
Editor(QWidget *parent) : QTextEdit(parent) { setAcceptRichText(false); } Editor(QWidget *parent) : QTextEdit(parent) { setAcceptRichText(false); }
public slots: public slots:

View File

@ -1822,9 +1822,6 @@ MainWindow::preferences()
void MainWindow::setFont(const QString &family, uint size) 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; QFont font;
if (!family.isEmpty()) font.setFamily(family); if (!family.isEmpty()) font.setFamily(family);
else font.setFixedPitch(true); else font.setFixedPitch(true);