mirror of https://github.com/vitalif/openscad
Made editor font configurable
git-svn-id: http://svn.clifford.at/openscad/trunk@333 b57f626f-c46c-0410-a088-ec61d464b74cstl_dim
parent
0a3a7b1579
commit
05dc585cab
|
@ -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);
|
||||
|
|
|
@ -23,7 +23,20 @@
|
|||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="QTextEdit" name="editor"/>
|
||||
<widget class="QTextEdit" name="editor">
|
||||
<property name="font">
|
||||
<font>
|
||||
<family>Monaco</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="tabStopWidth">
|
||||
<number>30</number>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextEditable|Qt::TextEditorInteraction|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
|
@ -105,7 +118,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>681</width>
|
||||
<height>25</height>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_File">
|
||||
|
|
|
@ -20,12 +20,25 @@
|
|||
|
||||
#include "Preferences.h"
|
||||
|
||||
#include <QFontDatabase>
|
||||
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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<QString, QMap<RenderColor, QColor> > colorschemes;
|
||||
QString colorscheme;
|
||||
QString fontfamily;
|
||||
uint fontsize;
|
||||
|
||||
static Preferences *instance;
|
||||
};
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
<item>
|
||||
<widget class="QStackedWidget" name="stackedWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="page3DView">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
|
@ -93,6 +93,86 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="pageEditor">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Font</string>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QFontComboBox" name="fontChooser">
|
||||
<property name="currentFont">
|
||||
<font>
|
||||
<family>Monaco</family>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QComboBox" name="fontSize">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="3">
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>77</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="pageAdvanced">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="margin">
|
||||
|
@ -193,6 +273,7 @@
|
|||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="prefsAction3DView"/>
|
||||
<addaction name="prefsActionEditor"/>
|
||||
<addaction name="prefsActionAdvanced"/>
|
||||
</widget>
|
||||
<action name="prefsAction3DView">
|
||||
|
@ -220,6 +301,18 @@
|
|||
<string>Advanced</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="prefsActionEditor">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="openscad.qrc">
|
||||
<normaloff>:/prefsEditor.png</normaloff>:/prefsEditor.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Editor</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="openscad.qrc"/>
|
||||
|
|
20
TODO.txt
20
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
|
||||
|
|
18
mainwin.cc
18
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);
|
||||
}
|
||||
|
|
|
@ -2,5 +2,6 @@
|
|||
<qresource prefix="/">
|
||||
<file>prefsAdvanced.png</file>
|
||||
<file>prefs3DView.png</file>
|
||||
<file>prefsEditor.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in New Issue