From 05dc585cab293cefd079333668a96fe8b28b04f8 Mon Sep 17 00:00:00 2001 From: kintel Date: Fri, 22 Jan 2010 12:28:30 +0000 Subject: Made editor font configurable git-svn-id: http://svn.clifford.at/openscad/trunk@333 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/MainWindow.h b/MainWindow.h index 1aba9bd..f344711 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -57,6 +57,7 @@ private slots: void updatedFps(); void updateTVal(); void setFileName(const QString &filename); + void setFont(const QString &family, uint size); private: void openFile(const QString &filename); diff --git a/MainWindow.ui b/MainWindow.ui index c67e940..24c0903 100644 --- a/MainWindow.ui +++ b/MainWindow.ui @@ -23,7 +23,20 @@ Qt::Horizontal - + + + + Monaco + 12 + + + + 30 + + + Qt::LinksAccessibleByMouse|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse + + @@ -105,7 +118,7 @@ 0 0 681 - 25 + 22 diff --git a/Preferences.cc b/Preferences.cc index 1c7f988..a18e122 100644 --- a/Preferences.cc +++ b/Preferences.cc @@ -20,12 +20,25 @@ #include "Preferences.h" +#include + Preferences *Preferences::instance = NULL; Preferences::Preferences(QWidget *parent) : QMainWindow(parent) { setupUi(this); + // Toolbar + QActionGroup *group = new QActionGroup(this); + group->addAction(prefsAction3DView); + group->addAction(prefsActionEditor); + group->addAction(prefsActionAdvanced); + connect(group, SIGNAL(triggered(QAction*)), this, SLOT(actionTriggered(QAction*))); + + prefsAction3DView->setChecked(true); + this->actionTriggered(this->prefsAction3DView); + + // 3D View pane this->colorscheme = this->colorSchemeChooser->item(0)->text(); this->colorschemes["Cornfield"][BACKGROUND_COLOR] = QColor(0xff, 0xff, 0xe5); this->colorschemes["Cornfield"][OPENCSG_FACE_FRONT_COLOR] = QColor(0xf9, 0xd7, 0x2c); @@ -60,17 +73,22 @@ Preferences::Preferences(QWidget *parent) : QMainWindow(parent) this->colorschemes["Sunset"][CGAL_EDGE_2D_COLOR] = QColor(0xff, 0x00, 0x00); this->colorschemes["Sunset"][CROSSHAIR_COLOR] = QColor(0x80, 0x00, 0x00); - QActionGroup *group = new QActionGroup(this); - group->addAction(prefsAction3DView); - group->addAction(prefsActionAdvanced); - connect(group, SIGNAL(triggered(QAction*)), this, SLOT(actionTriggered(QAction*))); - - prefsAction3DView->setChecked(true); - this->actionTriggered(this->prefsAction3DView); - connect(this->colorSchemeChooser, SIGNAL(itemSelectionChanged()), this, SLOT(colorSchemeChanged())); + // Editor pane + QFontDatabase db; + foreach(int size, db.standardSizes()) { + this->fontSize->addItem(QString::number(size)); + } + this->fontSize->setCurrentIndex(this->fontSize->findText(QString::number(12))); + fontFamilyChanged(this->fontChooser->currentText()); + fontSizeChanged(this->fontSize->currentText()); + + connect(this->fontChooser, SIGNAL(activated(const QString &)), + this, SLOT(fontFamilyChanged(const QString &))); + connect(this->fontSize, SIGNAL(activated(const QString &)), + this, SLOT(fontSizeChanged(const QString &))); } Preferences::~Preferences() @@ -83,6 +101,9 @@ Preferences::actionTriggered(QAction *action) if (action == this->prefsAction3DView) { this->stackedWidget->setCurrentWidget(this->page3DView); } + else if (action == this->prefsActionEditor) { + this->stackedWidget->setCurrentWidget(this->pageEditor); + } else if (action == this->prefsActionAdvanced) { this->stackedWidget->setCurrentWidget(this->pageAdvanced); } @@ -99,3 +120,14 @@ const QColor &Preferences::color(RenderColor idx) return this->colorschemes[this->colorscheme][idx]; } +void Preferences::fontFamilyChanged(const QString &family) +{ + this->fontfamily = family; + emit fontChanged(this->fontfamily, this->fontsize); +} + +void Preferences::fontSizeChanged(const QString &size) +{ + this->fontsize = size.toUInt(); + emit fontChanged(this->fontfamily, this->fontsize); +} diff --git a/Preferences.h b/Preferences.h index 9b8c816..5bfb3be 100644 --- a/Preferences.h +++ b/Preferences.h @@ -29,14 +29,19 @@ public: public slots: void actionTriggered(class QAction *); void colorSchemeChanged(); + void fontFamilyChanged(const QString &); + void fontSizeChanged(const QString &); signals: void requestRedraw(); + void fontChanged(const QString &family, uint size); private: Preferences(QWidget *parent = NULL); QHash > colorschemes; QString colorscheme; + QString fontfamily; + uint fontsize; static Preferences *instance; }; diff --git a/Preferences.ui b/Preferences.ui index 1bfc80a..e210d1b 100644 --- a/Preferences.ui +++ b/Preferences.ui @@ -21,7 +21,7 @@ - 0 + 1 @@ -93,6 +93,86 @@ + + + + + + + + + 75 + true + + + + Font + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + Monaco + 12 + + + + + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 77 + + + + + + @@ -193,6 +273,7 @@ false + @@ -220,6 +301,18 @@ Advanced + + + true + + + + :/prefsEditor.png:/prefsEditor.png + + + Editor + + diff --git a/TODO.txt b/TODO.txt index 3a0ed5e..4f61002 100644 --- a/TODO.txt +++ b/TODO.txt @@ -10,16 +10,14 @@ o Export STL: Exports existing CGAL model even though the current model is chang USER INTERFACE -------------- o Preferences - - background colors - - colors - - OpenCSG: face back/front, edges? - - CGAL: face back/front, edge back/front, vertex back/front + - Beautify color schemes + - Color schemes read from file + - Color scheme editor - wireframe width - pointsize - OpenGL params - Default language feature settings - Auto-view CSG/thrown together on load - - editor font o Export etc.: automatically add missing extension as in SaveAs o Mac OS X: - embed examples into bundle -> separate example menu? @@ -38,17 +36,26 @@ o 3D View - 4 x split view w/orthogonal cameras? - Quick highlighting of object under the cursor in the editor - View All + - overlay indicator displaying current view mode o Editor - Autocompletion/hints for builtin (and user-defined) functions/modules - builtin quick function reference/help + - Drawer/popup with all modules/functions listed which can be inserted into + the editor by clicking or drag&drop -> icons in toolbar? + -> This would be moving in the direction of a traditional CAD GUI + and needs a fair bit of thinking. - More infrastructur for external editor (or is the reload good enough?) - Evaluate QCodeEdit (http://qcodeedit.edyuk.org) - - don't line break + - Display some kind of line wrap indicator + - Couple the source code to the AST to allow highlighting selected elements + in the source code in the 3D view o Misc - Fix current_win hack - Reload and compile: Ask for confirmation if file is locally edited (make this configurable in preferences?) - Save: Ask for confirmation if file has been externaly changed + - Rename OpenCSG and CGAL to smth. not specific to the underlying libraries + (e.g Preview, Render) ENGINE ------ @@ -56,6 +63,7 @@ o Primitives - Springs, spirals (requested by Cathal Garvey) o 2D Subsystem - Add generic 3D->2D projection statements + - 2D->3D using clipping plane o Advanced Transformations - Add statement for 2D and 3D minkowski sum - Add statement for refinement via surface subdivision diff --git a/mainwin.cc b/mainwin.cc index 975468f..4299c50 100644 --- a/mainwin.cc +++ b/mainwin.cc @@ -138,9 +138,8 @@ MainWindow::MainWindow(const char *filename) highlighter = NULL; - QFont font; - font.setStyleHint(QFont::TypeWriter); - editor->setFont(font); + editor->setWordWrapMode(QTextOption::WrapAnywhere); // Not designable + setFont("", 0); // Init default font screen->statusLabel = new QLabel(this); statusBar()->addWidget(screen->statusLabel); @@ -260,8 +259,6 @@ MainWindow::MainWindow(const char *filename) PRINT(copyrighttext); PRINT(""); - editor->setTabStopWidth(30); - if (filename) { openFile(filename); } else { @@ -274,6 +271,8 @@ MainWindow::MainWindow(const char *filename) connect(screen, SIGNAL(doAnimateUpdate()), this, SLOT(animateUpdate())); connect(Preferences::inst(), SIGNAL(requestRedraw()), this->screen, SLOT(updateGL())); + connect(Preferences::inst(), SIGNAL(fontChanged(const QString&,uint)), + this, SLOT(setFont(const QString&,uint))); // display this window and check for OpenGL 2.0 (OpenCSG) support viewModeThrownTogether(); @@ -1755,3 +1754,12 @@ MainWindow::preferences() { Preferences::inst()->show(); } + +void MainWindow::setFont(const QString &family, uint size) +{ + QFont font(editor->font()); + if (!family.isEmpty()) font.setFamily(family); + if (size > 0) font.setPointSize(size); + font.setStyleHint(QFont::TypeWriter); + editor->setFont(font); +} diff --git a/openscad.qrc b/openscad.qrc index d1ced95..54f9bf1 100644 --- a/openscad.qrc +++ b/openscad.qrc @@ -2,5 +2,6 @@ prefsAdvanced.png prefs3DView.png + prefsEditor.png diff --git a/prefsEditor.png b/prefsEditor.png new file mode 100644 index 0000000..e65d9f7 Binary files /dev/null and b/prefsEditor.png differ -- cgit v0.10.1