Merge branch 'gui-updates'

master
Marius Kintel 2015-01-15 23:47:48 -05:00
commit 0860021a52
32 changed files with 221 additions and 130 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 722 B

BIN
images/Command-Redo-32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
images/Command-Reset-32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 726 B

BIN
images/Command-Undo-32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 580 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 577 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 425 B

After

Width:  |  Height:  |  Size: 529 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 500 B

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 265 B

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 B

BIN
images/zoom-text-in.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

BIN
images/zoom-text-out.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 535 B

View File

@ -1,5 +1,19 @@
<RCC>
<qresource prefix="/">
<file>images/zoom-text-in-white.png</file>
<file>images/zoom-text-in.png</file>
<file>images/zoom-text-out-white.png</file>
<file>images/zoom-text-out.png</file>
<file>images/Command-Redo-32-white.png</file>
<file>images/Command-Reset-32-white.png</file>
<file>images/Command-Undo-32-white.png</file>
<file>images/Decrease-Indent-32-white.png</file>
<file>images/Increase-Indent-32-white.png</file>
<file>images/Command-Redo-32.png</file>
<file>images/Command-Reset-32.png</file>
<file>images/Command-Undo-32.png</file>
<file>images/Decrease-Indent-32.png</file>
<file>images/Increase-Indent-32.png</file>
<file>icons/close.png</file>
<file>icons/information-icons-error.png</file>
<file>icons/information-icons-info.png</file>
@ -59,11 +73,12 @@
<file>images/perspective1.png</file>
<file>images/Preview-32.png</file>
<file>images/animate.png</file>
<file>images/Preview-32 (1).png</file>
<file>images/orthogonalwhite.png</file>
<file>images/perspective1white.png</file>
<file>images/Preview-32-white.png</file>
<file>images/crosswhite.png</file>
<file>icons/background.png</file>
<file>images/scalemarkers.png</file>
<file>images/scalemarkers-white.png</file>
</qresource>
</RCC>

View File

@ -26,8 +26,7 @@ void Camera::setup(std::vector<double> params)
type = Camera::GIMBAL;
object_trans << params[0], params[1], params[2];
object_rot << params[3], params[4], params[5];
viewer_distance = params[6];
height = params[6];
height = viewer_distance = params[6];
} else if (params.size() == 6) {
type = Camera::VECTOR;
eye << params[0], params[1], params[2];
@ -74,13 +73,13 @@ void Camera::viewAll(const BoundingBox &bbox, float scalefactor)
switch (this->projection) {
case Camera::ORTHOGONAL:
this->height = bbox.diagonal().norm();
this->height = this->viewer_distance = bbox.diagonal().norm();
break;
case Camera::PERSPECTIVE: {
double radius = bbox.diagonal().norm()/2;
switch (this->type) {
case Camera::GIMBAL:
this->viewer_distance = radius / tan(this->fov*M_PI/360);
this->height = this->viewer_distance = radius / tan(this->fov*M_PI/360);
break;
case Camera::VECTOR: {
Vector3d cameradir = (this->center - this->eye).normalized();
@ -101,8 +100,7 @@ void Camera::viewAll(const BoundingBox &bbox, float scalefactor)
void Camera::zoom(int delta)
{
this->viewer_distance *= pow(0.9, delta / 120.0);
this->height = this->viewer_distance;
this->height = this->viewer_distance *= pow(0.9, delta / 120.0);
}
void Camera::setProjection(ProjectionType type)
@ -115,8 +113,7 @@ void Camera::resetView()
type = Camera::GIMBAL;
object_rot << 35, 0, -25;
object_trans << 0, 0, 0;
height = 140;
viewer_distance = 140;
height = viewer_distance = 140;
}
double Camera::zoomValue()

View File

@ -99,6 +99,7 @@ private slots:
void showProgress();
void openCSGSettingsChanged();
private:
void initActionIcon(QAction *action, const char *darkResource, const char *lightResource);
void openFile(const QString &filename);
void handleFileDrop(const QString &filename);
void refreshDocument();
@ -205,7 +206,7 @@ public slots:
void actionReloadRenderPreview();
void on_editorDock_visibilityChanged(bool);
void on_consoleDock_visibilityChanged(bool);
void on_pushButtonCompileResultClose_clicked();
void on_toolButtonCompileResultClose_clicked();
void editorTopLevelChanged(bool);
void consoleTopLevelChanged(bool);
#ifdef ENABLE_OPENCSG

View File

@ -43,39 +43,20 @@
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="leftMargin">
<number>9</number>
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>2</number>
<number>6</number>
</property>
<property name="bottomMargin">
<number>2</number>
<number>4</number>
</property>
<property name="horizontalSpacing">
<number>4</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelCompileResultIcon">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>26</width>
<height>26</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../openscad.qrc">:/icons/information-icons-error.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelCompileResultMessage">
<property name="sizePolicy">
@ -86,7 +67,6 @@
</property>
<property name="font">
<font>
<pointsize>14</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
@ -94,10 +74,16 @@
<property name="text">
<string>Message</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButtonCompileResultClose">
<widget class="QToolButton" name="toolButtonCompileResultClose">
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text">
<string/>
</property>
@ -105,11 +91,43 @@
<iconset resource="../openscad.qrc">
<normaloff>:/icons/close.png</normaloff>:/icons/close.png</iconset>
</property>
<property name="flat">
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QToolButton" name="toolButtonCompileResultIcon">
<property name="styleSheet">
<string notr="true">QToolButton { border: none; }</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../openscad.qrc">
<normaloff>:/icons/information-icons-error.png</normaloff>:/icons/information-icons-error.png</iconset>
</property>
<property name="iconSize">
<size>
<width>22</width>
<height>22</height>
</size>
</property>
<property name="autoRaise">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -195,6 +213,7 @@
<addaction name="viewActionViewAll"/>
<addaction name="viewActionZoomIn"/>
<addaction name="viewActionZoomOut"/>
<addaction name="viewActionResetView"/>
<addaction name="separator"/>
<addaction name="viewActionRight"/>
<addaction name="viewActionTop"/>
@ -205,7 +224,9 @@
<addaction name="separator"/>
<addaction name="viewActionPerspective"/>
<addaction name="viewActionOrthogonal"/>
<addaction name="separator"/>
<addaction name="viewActionShowAxes"/>
<addaction name="viewActionShowScaleProportional"/>
<addaction name="viewActionShowEdges"/>
</widget>
</item>
@ -296,8 +317,8 @@
<addaction name="editActionFindPrevious"/>
<addaction name="editActionUseSelectionForFind"/>
<addaction name="separator"/>
<addaction name="editActionZoomIn"/>
<addaction name="editActionZoomOut"/>
<addaction name="editActionZoomTextIn"/>
<addaction name="editActionZoomTextOut"/>
<addaction name="editActionPreferences"/>
</widget>
<widget class="QMenu" name="menu_Design">
@ -389,6 +410,11 @@
<addaction name="fileActionOpen"/>
<addaction name="fileActionSave"/>
<addaction name="separator"/>
<addaction name="editActionUndo"/>
<addaction name="editActionRedo"/>
<addaction name="editActionUnindent"/>
<addaction name="editActionIndent"/>
<addaction name="separator"/>
<addaction name="designActionPreview"/>
<addaction name="designActionRender"/>
<addaction name="separator"/>
@ -586,6 +612,10 @@
</property>
</action>
<action name="editActionUndo">
<property name="icon">
<iconset resource="../openscad.qrc">
<normaloff>:/images/Command-Undo-32.png</normaloff>:/images/Command-Undo-32.png</iconset>
</property>
<property name="text">
<string>&amp;Undo</string>
</property>
@ -597,6 +627,10 @@
</property>
</action>
<action name="editActionRedo">
<property name="icon">
<iconset resource="../openscad.qrc">
<normaloff>:/images/Command-Redo-32.png</normaloff>:/images/Command-Redo-32.png</iconset>
</property>
<property name="text">
<string>&amp;Redo</string>
</property>
@ -641,6 +675,10 @@
</property>
</action>
<action name="editActionIndent">
<property name="icon">
<iconset resource="../openscad.qrc">
<normaloff>:/images/Increase-Indent-32.png</normaloff>:/images/Increase-Indent-32.png</iconset>
</property>
<property name="text">
<string>&amp;Indent</string>
</property>
@ -648,14 +686,6 @@
<string>Ctrl+I</string>
</property>
</action>
<action name="editActionUnindent">
<property name="text">
<string>U&amp;nindent</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+I</string>
</property>
</action>
<action name="editActionComment">
<property name="text">
<string>C&amp;omment</string>
@ -685,17 +715,17 @@
<string>Paste viewport rotation</string>
</property>
</action>
<action name="editActionZoomIn">
<action name="editActionZoomTextIn">
<property name="text">
<string>Zoom In</string>
<string>Increase Font Size</string>
</property>
<property name="shortcut">
<string>Ctrl++</string>
</property>
</action>
<action name="editActionZoomOut">
<action name="editActionZoomTextOut">
<property name="text">
<string>Zoom Out</string>
<string>Decrease Font Size</string>
</property>
<property name="shortcut">
<string>Ctrl+-</string>
@ -1122,6 +1152,10 @@
</property>
</action>
<action name="viewActionResetView">
<property name="icon">
<iconset resource="../openscad.qrc">
<normaloff>:/images/Command-Reset-32.png</normaloff>:/images/Command-Reset-32.png</iconset>
</property>
<property name="text">
<string>Reset View</string>
</property>
@ -1187,6 +1221,18 @@
<string>Hide toolbars</string>
</property>
</action>
<action name="editActionUnindent">
<property name="icon">
<iconset resource="../openscad.qrc">
<normaloff>:/images/Decrease-Indent-32.png</normaloff>:/images/Decrease-Indent-32.png</iconset>
</property>
<property name="text">
<string>U&amp;nindent</string>
</property>
<property name="shortcut">
<string>Ctrl+Shift+I</string>
</property>
</action>
<action name="helpActionCheatSheet">
<property name="text">
<string>Cheat Sheet</string>

View File

@ -31,6 +31,7 @@
#include <QKeyEvent>
#include <QSettings>
#include <QStatusBar>
#include <boost/algorithm/string.hpp>
#include "GeometryCache.h"
#include "AutoUpdater.h"
#include "feature.h"
@ -49,18 +50,27 @@ class SettingsReader : public Settings::Visitor
{
QSettings settings;
const Value getValue(const Settings::SettingsEntry& entry, const std::string& value) const {
if (value.empty()) {
std::string trimmed_value(value);
boost::trim(trimmed_value);
if (trimmed_value.empty()) {
return entry.defaultValue();
}
try {
switch (entry.defaultValue().type()) {
case Value::STRING:
return Value(value);
return Value(trimmed_value);
case Value::NUMBER:
return Value(boost::lexical_cast<int>(value));
return Value(boost::lexical_cast<int>(trimmed_value));
case Value::BOOL:
return Value(boost::lexical_cast<bool>(value));
boost::to_lower(trimmed_value);
if ("false" == trimmed_value) {
return Value(false);
} else if ("true" == trimmed_value) {
return Value(true);
}
return Value(boost::lexical_cast<bool>(trimmed_value));
default:
assert(false && "invalid value type for settings");
}
@ -74,7 +84,9 @@ class SettingsReader : public Settings::Visitor
std::string key = entry.category() + "/" + entry.name();
std::string value = settings.value(QString::fromStdString(key)).toString().toStdString();
s->set(entry, getValue(entry, value));
const Value v = getValue(entry, value);
PRINTDB("SettingsReader R: %s = '%s' => '%s'", key.c_str() % value.c_str() % v.toString());
s->set(entry, v);
}
};
@ -87,9 +99,11 @@ class SettingsWriter : public Settings::Visitor
QString key = QString::fromStdString(entry.category() + "/" + entry.name());
if (entry.is_default()) {
settings.remove(key);
PRINTDB("SettingsWriter D: %s", key.toStdString().c_str());
} else {
Value value = s->get(entry);
settings.setValue(key, QString::fromStdString(value.toString()));
PRINTDB("SettingsWriter W: %s = '%s'", key.toStdString().c_str() % value.toString().c_str());
}
}
};
@ -471,6 +485,12 @@ void Preferences::on_launcherBox_toggled(bool state)
settings.setValue("launcher/showOnStartup", state);
}
void Preferences::on_checkBoxShowWarningsIn3dView_toggled(bool val)
{
Settings::Settings::inst()->set(Settings::Settings::showWarningsIn3dView, Value(val));
writeSettings();
}
void Preferences::on_spinBoxIndentationWidth_valueChanged(int val)
{
Settings::Settings::inst()->set(Settings::Settings::indentationWidth, Value(val));
@ -669,6 +689,7 @@ void Preferences::updateGUI()
this->checkBoxAutoIndent->setChecked(s->get(Settings::Settings::autoIndent).toBool());
this->checkBoxHighlightCurrentLine->setChecked(s->get(Settings::Settings::highlightCurrentLine).toBool());
this->checkBoxEnableBraceMatching->setChecked(s->get(Settings::Settings::enableBraceMatching).toBool());
this->checkBoxShowWarningsIn3dView->setChecked(s->get(Settings::Settings::showWarningsIn3dView).toBool());
}
void Preferences::initComboBox(QComboBox *comboBox, const Settings::SettingsEntry& entry)

View File

@ -46,6 +46,7 @@ public slots:
void on_launcherBox_toggled(bool);
void on_editorType_editTextChanged(const QString &);
void on_checkBoxShowWarningsIn3dView_toggled(bool);
//
// editor settings
//

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>621</width>
<height>413</height>
<width>675</width>
<height>476</height>
</rect>
</property>
<property name="sizePolicy">
@ -31,6 +31,9 @@
</property>
<widget class="QWidget" name="page3DView">
<layout class="QVBoxLayout" name="verticalLayout_4">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,3">
<item>
@ -75,6 +78,16 @@
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBoxShowWarningsIn3dView">
<property name="text">
<string>Show Warnings and Errors in 3D View</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageEditor">

View File

@ -25,8 +25,8 @@ LaunchingScreen::LaunchingScreen(QWidget *parent) : QDialog(parent)
{
LaunchingScreen::inst = this;
setupUi(this);
this->setStyleSheet("QDialog {background-image:url(':/icons/background.png')}"
"QPushButton {color:white;}");
this->setStyleSheet("QDialog {background-image:url(':/icons/background.png')} QPushButton {color:white;}");
this->versionNumberLabel->setText(openscad_version.c_str());

View File

@ -256,7 +256,7 @@ MainWindow::MainWindow(const QString &filename)
knownFileExtensions["scad"] = "";
knownFileExtensions["csg"] = "";
editActionZoomIn->setShortcuts(QList<QKeySequence>() << editActionZoomIn->shortcuts() << QKeySequence("CTRL+="));
editActionZoomTextIn->setShortcuts(QList<QKeySequence>() << editActionZoomTextIn->shortcuts() << QKeySequence("CTRL+="));
connect(this, SIGNAL(highlightError(int)), editor, SLOT(highlightError(int)));
connect(this, SIGNAL(unhighlightLastError()), editor, SLOT(unhighlightLastError()));
@ -330,8 +330,8 @@ MainWindow::MainWindow(const QString &filename)
connect(this->editActionConvertTabsToSpaces, SIGNAL(triggered()), this, SLOT(convertTabsToSpaces()));
connect(this->editActionPasteVPT, SIGNAL(triggered()), this, SLOT(pasteViewportTranslation()));
connect(this->editActionPasteVPR, SIGNAL(triggered()), this, SLOT(pasteViewportRotation()));
connect(this->editActionZoomIn, SIGNAL(triggered()), editor, SLOT(zoomIn()));
connect(this->editActionZoomOut, SIGNAL(triggered()), editor, SLOT(zoomOut()));
connect(this->editActionZoomTextIn, SIGNAL(triggered()), editor, SLOT(zoomIn()));
connect(this->editActionZoomTextOut, SIGNAL(triggered()), editor, SLOT(zoomOut()));
connect(this->editActionPreferences, SIGNAL(triggered()), this, SLOT(preferences()));
// Edit->Find
connect(this->editActionFind, SIGNAL(triggered()), this, SLOT(find()));
@ -474,60 +474,37 @@ MainWindow::MainWindow(const QString &filename)
addKeyboardShortCut(this->viewerToolBar->actions());
addKeyboardShortCut(this->editortoolbar->actions());
//Toolbar
int defaultcolor = viewerToolBar->palette().background().color().lightness();
if (defaultcolor > 165) {
fileActionNew->setIcon(QIcon("://images/blackNew.png"));
fileActionOpen->setIcon(QIcon("://images/Open-32.png"));
fileActionSave->setIcon(QIcon("://images/Save-32.png"));
editActionZoomIn->setIcon(QIcon("://images/zoomin.png"));
editActionZoomOut->setIcon(QIcon("://images/zoomout.png"));
designActionRender->setIcon(QIcon("://images/blackRender.png"));
viewActionShowAxes->setIcon(QIcon("://images/blackaxes.png"));
viewActionShowEdges->setIcon(QIcon("://images/Rotation-32.png"));
viewActionZoomIn->setIcon(QIcon("://images/zoomin.png"));
viewActionZoomOut->setIcon(QIcon("://images/zoomout.png"));
viewActionTop->setIcon(QIcon("://images/blackUp.png"));
viewActionBottom->setIcon(QIcon("://images/blackbottom.png"));
viewActionLeft->setIcon(QIcon("://images/blackleft (copy).png"));
viewActionRight->setIcon(QIcon("://images/rightright.png"));
viewActionFront->setIcon(QIcon("://images/blackfront.png"));
viewActionBack->setIcon(QIcon("://images/blackback.png"));
viewActionSurfaces->setIcon(QIcon("://images/surface.png"));
viewActionWireframe->setIcon(QIcon("://images/wireframe1.png"));
viewActionShowCrosshairs->setIcon(QIcon("://images/cross.png"));
viewActionPerspective->setIcon(QIcon("://images/perspective1.png"));
viewActionOrthogonal->setIcon(QIcon("://images/orthogonal.png"));
viewActionPreview->setIcon(QIcon("://images/Preview-32.png"));
viewActionAnimate->setIcon(QIcon("://images/animate.png"));
} else {
fileActionNew->setIcon(QIcon("://images/Document-New-128.png"));
fileActionOpen->setIcon(QIcon("://images/Open-128.png"));
fileActionSave->setIcon(QIcon("://images/Save-128.png"));
editActionZoomIn->setIcon(QIcon("://images/Zoom-In-32.png"));
editActionZoomOut->setIcon(QIcon("://images/Zoom-Out-32.png"));
designActionRender->setIcon(QIcon("://images/Arrowhead-Right-32.png"));
viewActionZoomIn->setIcon(QIcon("://images/Zoom-In-32.png"));
viewActionZoomOut->setIcon(QIcon("://images/Zoom-Out-32.png"));
viewActionShowAxes->setIcon(QIcon("://images/axes.png"));
viewActionShowEdges->setIcon(QIcon("://images/grid.png"));
viewActionTop->setIcon(QIcon("://images/up.png"));
viewActionBottom->setIcon(QIcon("://images/bottom.png"));
viewActionLeft->setIcon(QIcon("://images/left.png"));
viewActionRight->setIcon(QIcon("://images/right.png"));
viewActionFront->setIcon(QIcon("://images/front.png"));
viewActionBack->setIcon(QIcon("://images/back.png"));
viewActionSurfaces->setIcon(QIcon("://images/surfaceWhite.png"));
viewActionWireframe->setIcon(QIcon("://images/wireframeWhite.png"));
viewActionShowCrosshairs->setIcon(QIcon("://images/crosswhite.png"));
viewActionPreview->setIcon(QIcon("://images/Preview-32(1).png"));
viewActionPerspective->setIcon(QIcon("://images/perspective1white.png"));
viewActionOrthogonal->setIcon(QIcon("://images/orthogonalwhite.png"));
viewActionAnimate->setIcon(QIcon("://images/animate.png"));
designActionExportSTL->setIcon(QIcon(":/images/export-white.png"));
viewActionViewAll->setIcon(QIcon(":/images/zoom-all-white.png"));
}
initActionIcon(fileActionNew, ":/images/blackNew.png", ":/images/Document-New-128.png");
initActionIcon(fileActionOpen, ":/images/Open-32.png", ":/images/Open-128.png");
initActionIcon(fileActionSave, ":/images/Save-32.png", ":/images/Save-128.png");
initActionIcon(editActionZoomTextIn, ":/images/zoom-text-in.png", ":/images/zoom-text-in-white.png");
initActionIcon(editActionZoomTextOut, ":/images/zoom-text-out.png", ":/images/zoom-text-out-white.png");
initActionIcon(designActionRender, ":/images/blackRender.png", ":/images/Arrowhead-Right-32.png");
initActionIcon(viewActionShowAxes, ":/images/blackaxes.png", ":/images/axes.png");
initActionIcon(viewActionShowEdges, ":/images/Rotation-32.png", ":/images/grid.png");
initActionIcon(viewActionZoomIn, ":/images/zoomin.png", ":/images/Zoom-In-32.png");
initActionIcon(viewActionZoomOut, ":/images/zoomout.png", ":/images/Zoom-Out-32.png");
initActionIcon(viewActionTop, ":/images/blackUp.png", ":/images/up.png");
initActionIcon(viewActionBottom, ":/images/blackbottom.png", ":/images/bottom.png");
initActionIcon(viewActionLeft, ":/images/blackleft (copy).png", ":/images/left.png");
initActionIcon(viewActionRight, ":/images/rightright.png", ":/images/right.png");
initActionIcon(viewActionFront, ":/images/blackfront.png", ":/images/front.png");
initActionIcon(viewActionBack, ":/images/blackback.png", ":/images/back.png");
initActionIcon(viewActionSurfaces, ":/images/surface.png", ":/images/surfaceWhite.png");
initActionIcon(viewActionWireframe, ":/images/wireframe1.png", ":/images/wireframeWhite.png");
initActionIcon(viewActionShowCrosshairs, ":/images/cross.png", ":/images/crosswhite.png");
initActionIcon(viewActionPerspective, ":/images/perspective1.png", ":/images/perspective1white.png");
initActionIcon(viewActionOrthogonal, ":/images/orthogonal.png", ":/images/orthogonalwhite.png");
initActionIcon(designActionPreview, ":/images/Preview-32.png", ":/images/Preview-32-white.png");
initActionIcon(viewActionAnimate, ":/images/animate.png", ":/images/animate.png");
initActionIcon(designActionExportSTL, ":/images/export.png", ":/images/export-white.png");
initActionIcon(viewActionViewAll, ":/images/zoom-all.png", ":/images/zoom-all-white.png");
initActionIcon(editActionUndo, ":/images/Command-Undo-32.png", ":/images/Command-Undo-32-white.png");
initActionIcon(editActionRedo, ":/images/Command-Redo-32.png", ":/images/Command-Redo-32-white.png");
initActionIcon(editActionUnindent, ":/images/Decrease-Indent-32.png", ":/images/Decrease-Indent-32-white.png");
initActionIcon(editActionIndent, ":/images/Increase-Indent-32.png", ":/images/Increase-Indent-32-white.png");
initActionIcon(viewActionResetView, ":/images/Command-Reset-32.png", ":/images/Command-Reset-32-white.png");
initActionIcon(viewActionShowScaleProportional, ":/images/scalemarkers.png", ":/images/scalemarkers-white.png");
// make sure it looks nice..
QByteArray windowState = settings.value("window/state", QByteArray()).toByteArray();
@ -588,6 +565,13 @@ MainWindow::MainWindow(const QString &filename)
clearCurrentOutput();
}
void MainWindow::initActionIcon(QAction *action, const char *darkResource, const char *lightResource)
{
int defaultcolor = viewerToolBar->palette().background().color().lightness();
const char *resource = (defaultcolor > 165) ? darkResource : lightResource;
action->setIcon(QIcon(resource));
}
void MainWindow::addKeyboardShortCut(const QList<QAction *> &actions)
{
foreach (QAction *action, actions) {
@ -958,7 +942,7 @@ void MainWindow::waitAfterReload()
}
}
void MainWindow::on_pushButtonCompileResultClose_clicked()
void MainWindow::on_toolButtonCompileResultClose_clicked()
{
frameCompileResult->hide();
}
@ -970,6 +954,11 @@ void MainWindow::updateCompileResult()
return;
}
Settings::Settings *s = Settings::Settings::inst();
if (!s->get(Settings::Settings::showWarningsIn3dView).toBool()) {
return;
}
QString msg;
if (compileErrors > 0) {
if (fileName.isEmpty()) {
@ -978,11 +967,18 @@ void MainWindow::updateCompileResult()
QFileInfo fileInfo(fileName);
msg = QString(_("Error while compiling '%1'.")).arg(fileInfo.fileName());
}
labelCompileResultIcon->setPixmap(QPixmap(QString::fromUtf8(":/icons/information-icons-error.png")));
toolButtonCompileResultIcon->setIcon(QIcon(QString::fromUtf8(":/icons/information-icons-error.png")));
} else {
msg = QString(_("Compilation generated %1 warnings.")).arg(compileWarnings);
labelCompileResultIcon->setPixmap(QPixmap(QString::fromUtf8(":/icons/information-icons-warning.png")));
const char *fmt = ngettext("Compilation generated %1 warning.", "Compilation generated %1 warnings.", compileWarnings);
msg = QString(fmt).arg(compileWarnings);
toolButtonCompileResultIcon->setIcon(QIcon(QString::fromUtf8(":/icons/information-icons-warning.png")));
}
QFontMetrics fm(labelCompileResultMessage->font());
int sizeIcon = std::max(12, std::min(32, fm.height()));
int sizeClose = std::max(10, std::min(32, fm.height()) - 4);
toolButtonCompileResultIcon->setIconSize(QSize(sizeIcon, sizeIcon));
toolButtonCompileResultClose->setIconSize(QSize(sizeClose, sizeClose));
msg += _(" For details see <a href=\"#console\">console window</a>.");
labelCompileResultMessage->setText(msg);
frameCompileResult->show();
@ -1995,7 +1991,7 @@ void MainWindow::actionExport(export_type_e, QString, QString)
setCurrentOutput();
if (!this->root_geom) {
PRINT("Nothing to export! Try building first (press F6).");
PRINT("WARNING: Nothing to export! Try building first (press F6).");
clearCurrentOutput();
return;
}
@ -2075,13 +2071,13 @@ QString MainWindow::get2dExportFilename(QString format, QString extension) {
setCurrentOutput();
if (!this->root_geom) {
PRINT("Nothing to export! Try building first (press F6).");
PRINT("WARNING: Nothing to export! Try building first (press F6).");
clearCurrentOutput();
return QString();
}
if (this->root_geom->getDimension() != 2) {
PRINT("Current top level object is not a 2D object.");
PRINT("WARNING: Current top level object is not a 2D object.");
clearCurrentOutput();
return QString();
}
@ -2134,7 +2130,7 @@ void MainWindow::actionExportCSG()
setCurrentOutput();
if (!this->root_node) {
PRINT("Nothing to export. Please try compiling first...");
PRINT("WARNING: Nothing to export. Please try compiling first...");
clearCurrentOutput();
return;
}

View File

@ -331,7 +331,6 @@ void ScintillaEditor::noColor()
qsci->setIndicatorForegroundColor(QColor(255, 0, 0, 128), indicatorNumber);
qsci->setIndicatorOutlineColor(QColor(0, 0, 0, 255), indicatorNumber); // only alpha part is used
qsci->setCaretLineBackgroundColor(Qt::white);
qsci->setWhitespaceBackgroundColor(Qt::white);
qsci->setWhitespaceForegroundColor(Qt::black);
qsci->setMarginsBackgroundColor(Qt::white);
qsci->setMarginsForegroundColor(Qt::black);

View File

@ -121,6 +121,7 @@ Visitor::~Visitor()
* external settings file. The second value is the display value that
* can be translated.
*/
SettingsEntry Settings::showWarningsIn3dView("3dview", "showWarningsIn3dView", Value(true), Value(true));
SettingsEntry Settings::indentationWidth("editor", "indentationWidth", Value(Value::RangeType(1, 16)), Value(4));
SettingsEntry Settings::tabWidth("editor", "tabWidth", Value(Value::RangeType(1, 16)), Value(8));
SettingsEntry Settings::lineWrap("editor", "lineWrap", values("None", _("None"), "Char", _("Wrap at character boundaries"), "Word", _("Wrap at word boundaries")), Value("Word"));

View File

@ -35,6 +35,7 @@ protected:
class Settings
{
public:
static SettingsEntry showWarningsIn3dView;
static SettingsEntry indentationWidth;
static SettingsEntry tabWidth;
static SettingsEntry lineWrap;