mirror of https://github.com/vitalif/openscad
commit
756d3e2a97
|
@ -259,6 +259,7 @@ HEADERS += src/typedefs.h \
|
||||||
src/OpenCSGWarningDialog.h \
|
src/OpenCSGWarningDialog.h \
|
||||||
src/AboutDialog.h \
|
src/AboutDialog.h \
|
||||||
src/FontListDialog.h \
|
src/FontListDialog.h \
|
||||||
|
src/FontListTableView.h \
|
||||||
src/builtin.h \
|
src/builtin.h \
|
||||||
src/calc.h \
|
src/calc.h \
|
||||||
src/context.h \
|
src/context.h \
|
||||||
|
@ -428,6 +429,7 @@ SOURCES += src/version_check.cc \
|
||||||
src/UIUtils.cc \
|
src/UIUtils.cc \
|
||||||
src/Dock.cc \
|
src/Dock.cc \
|
||||||
src/FontListDialog.cc \
|
src/FontListDialog.cc \
|
||||||
|
src/FontListTableView.cc \
|
||||||
src/launchingscreen.cc \
|
src/launchingscreen.cc \
|
||||||
src/legacyeditor.cc \
|
src/legacyeditor.cc \
|
||||||
src/LibraryInfoDialog.cc
|
src/LibraryInfoDialog.cc
|
||||||
|
|
|
@ -60,14 +60,16 @@ void FontListDialog::selection_changed(const QItemSelection ¤t, const QIte
|
||||||
{
|
{
|
||||||
if (current.count() == 0) {
|
if (current.count() == 0) {
|
||||||
copyButton->setEnabled(false);
|
copyButton->setEnabled(false);
|
||||||
|
tableView->setDragText("");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QModelIndex &idx = proxy->mapToSource(current.indexes().at(0));
|
const QModelIndex &idx = proxy->mapToSource(current.indexes().at(0));
|
||||||
const QString name = model->item(idx.row(), 0)->text();
|
const QString name = model->item(idx.row(), 0)->text();
|
||||||
const QString style = model->item(idx.row(), 1)->text();
|
const QString style = model->item(idx.row(), 1)->text();
|
||||||
selection = QString("\"%1:style=%2\"").arg(name).arg(style);
|
selection = QString("\"%1:style=%2\"").arg(quote(name)).arg(quote(style));
|
||||||
copyButton->setEnabled(true);
|
copyButton->setEnabled(true);
|
||||||
|
tableView->setDragText(selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FontListDialog::update_font_list()
|
void FontListDialog::update_font_list()
|
||||||
|
@ -117,3 +119,28 @@ void FontListDialog::update_font_list()
|
||||||
|
|
||||||
delete list;
|
delete list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quote a string according to the requirements of font-config.
|
||||||
|
* See http://www.freedesktop.org/software/fontconfig/fontconfig-user.html
|
||||||
|
*
|
||||||
|
* The '\', '-', ':' and ',' characters in family names must be preceded
|
||||||
|
* by a '\' character to avoid having them misinterpreted. Similarly, values
|
||||||
|
* containing '\', '=', '_', ':' and ',' must also have them preceded by a
|
||||||
|
* '\' character. The '\' characters are stripped out of the family name and
|
||||||
|
* values as the font name is read.
|
||||||
|
*
|
||||||
|
* @param text unquoted string
|
||||||
|
* @return quoted text
|
||||||
|
*/
|
||||||
|
QString FontListDialog::quote(const QString& text)
|
||||||
|
{
|
||||||
|
QString result = text;
|
||||||
|
result.replace('\\', "\\\\")
|
||||||
|
.replace('-', "\\-")
|
||||||
|
.replace(':', "\\:")
|
||||||
|
.replace(',', "\\,")
|
||||||
|
.replace('=', "\\=")
|
||||||
|
.replace('_', "\\_");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -6,9 +6,6 @@
|
||||||
#include "qtgettext.h"
|
#include "qtgettext.h"
|
||||||
#include "ui_FontListDialog.h"
|
#include "ui_FontListDialog.h"
|
||||||
|
|
||||||
#define STRINGIFY(x) #x
|
|
||||||
#define TOSTRING(x) STRINGIFY(x)
|
|
||||||
|
|
||||||
class FontListDialog : public QDialog, public Ui::FontListDialog
|
class FontListDialog : public QDialog, public Ui::FontListDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
|
@ -27,6 +24,8 @@ signals:
|
||||||
void font_selected(const QString font);
|
void font_selected(const QString font);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString quote(const QString& text);
|
||||||
|
|
||||||
QString selection;
|
QString selection;
|
||||||
QStandardItemModel *model;
|
QStandardItemModel *model;
|
||||||
QSortFilterProxyModel *proxy;
|
QSortFilterProxyModel *proxy;
|
||||||
|
|
|
@ -67,7 +67,17 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="5">
|
<item row="2" column="0" colspan="5">
|
||||||
<widget class="QTableView" name="tableView"/>
|
<widget class="FontListTableView" name="tableView">
|
||||||
|
<property name="dragEnabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="dragDropMode">
|
||||||
|
<enum>QAbstractItemView::DragOnly</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionBehavior">
|
||||||
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0" colspan="5">
|
<item row="0" column="0" colspan="5">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
|
@ -100,6 +110,13 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>FontListTableView</class>
|
||||||
|
<extends>QTableView</extends>
|
||||||
|
<header>FontListTableView.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../openscad.qrc"/>
|
<include location="../openscad.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
/*
|
||||||
|
* OpenSCAD (www.openscad.org)
|
||||||
|
* Copyright (C) 2009-2011 Clifford Wolf <clifford@clifford.at> and
|
||||||
|
* Marius Kintel <marius@kintel.net>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* As a special exception, you have permission to link this program
|
||||||
|
* with the CGAL library and distribute executables, as long as you
|
||||||
|
* follow the requirements of the GNU GPL in regard to all of the
|
||||||
|
* software in the executable aside from CGAL.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#include <QDrag>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QMimeData>
|
||||||
|
|
||||||
|
#include "qtgettext.h"
|
||||||
|
#include "FontListDialog.h"
|
||||||
|
|
||||||
|
FontListTableView::FontListTableView(QWidget *parent) : QTableView(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontListTableView::setDragText(const QString &text)
|
||||||
|
{
|
||||||
|
this->text = text.trimmed();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FontListTableView::startDrag(Qt::DropActions supportedActions)
|
||||||
|
{
|
||||||
|
if (text.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMimeData *mimeData = new QMimeData;
|
||||||
|
mimeData->setText(text);
|
||||||
|
|
||||||
|
QFontMetrics fm(font());
|
||||||
|
QRect rect(0, 0, fm.width(text), fm.height());
|
||||||
|
QPixmap pixmap(rect.width(), rect.height());
|
||||||
|
pixmap.fill(Qt::transparent);
|
||||||
|
|
||||||
|
QPainter painter(&pixmap);
|
||||||
|
painter.setFont(font());
|
||||||
|
painter.drawText(rect, Qt::AlignCenter, text);
|
||||||
|
|
||||||
|
QDrag *drag = new QDrag(this);
|
||||||
|
drag->setPixmap(pixmap);
|
||||||
|
drag->setMimeData(mimeData);
|
||||||
|
drag->setHotSpot(QPoint(-10, rect.height() + 6));
|
||||||
|
drag->exec(supportedActions, Qt::CopyAction);
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QTableView>
|
||||||
|
|
||||||
|
class FontListTableView : public QTableView
|
||||||
|
{
|
||||||
|
Q_OBJECT;
|
||||||
|
|
||||||
|
public:
|
||||||
|
FontListTableView(QWidget *parent = NULL);
|
||||||
|
void setDragText(const QString &text);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void startDrag(Qt::DropActions supportedActions);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString text;
|
||||||
|
};
|
|
@ -2,6 +2,7 @@
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QListWidgetItem>
|
#include <QListWidgetItem>
|
||||||
|
|
||||||
|
#include "openscad.h"
|
||||||
#include "launchingscreen.h"
|
#include "launchingscreen.h"
|
||||||
#include "ui_launchingscreen.h"
|
#include "ui_launchingscreen.h"
|
||||||
|
|
||||||
|
@ -26,7 +27,9 @@ LaunchingScreen::LaunchingScreen(QWidget *parent) : QDialog(parent)
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
this->setStyleSheet("QDialog {background-image:url(':/icons/background.png')}"
|
this->setStyleSheet("QDialog {background-image:url(':/icons/background.png')}"
|
||||||
"QPushButton {color:white;}");
|
"QPushButton {color:white;}");
|
||||||
|
|
||||||
|
this->versionNumberLabel->setText(openscad_version.c_str());
|
||||||
|
|
||||||
QStringList recentFiles = UIUtils::recentFiles();
|
QStringList recentFiles = UIUtils::recentFiles();
|
||||||
for (int a = 0;a < recentFiles.size();a++) {
|
for (int a = 0;a < recentFiles.size();a++) {
|
||||||
QFileInfo fileInfo(recentFiles[a]);
|
QFileInfo fileInfo(recentFiles[a]);
|
||||||
|
@ -75,7 +78,7 @@ QString LaunchingScreen::selectedFile()
|
||||||
return this->selection;
|
return this->selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LaunchingScreen::enableRecentButton(const QModelIndex & current, const QModelIndex & previous)
|
void LaunchingScreen::enableRecentButton(const QModelIndex &, const QModelIndex &)
|
||||||
{
|
{
|
||||||
this->openRecentButton->setEnabled(true);
|
this->openRecentButton->setEnabled(true);
|
||||||
this->openRecentButton->setDefault(true);
|
this->openRecentButton->setDefault(true);
|
||||||
|
@ -91,7 +94,7 @@ void LaunchingScreen::openRecent()
|
||||||
checkOpen(item->data(Qt::UserRole));
|
checkOpen(item->data(Qt::UserRole));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LaunchingScreen::enableExampleButton(QTreeWidgetItem *current, QTreeWidgetItem *previous)
|
void LaunchingScreen::enableExampleButton(QTreeWidgetItem *current, QTreeWidgetItem *)
|
||||||
{
|
{
|
||||||
const bool enable = current->childCount() == 0;
|
const bool enable = current->childCount() == 0;
|
||||||
this->openExampleButton->setEnabled(enable);
|
this->openExampleButton->setEnabled(enable);
|
||||||
|
|
|
@ -6,10 +6,16 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>618</width>
|
<width>620</width>
|
||||||
<height>418</height>
|
<height>418</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>600</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Welcome to OpenSCAD</string>
|
<string>Welcome to OpenSCAD</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -331,16 +337,32 @@ QPushButton:pressed {
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0" colspan="2">
|
<item row="8" column="1">
|
||||||
|
<widget class="QLabel" name="versionNumberLabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Version</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="0">
|
||||||
<widget class="QCheckBox" name="checkBox">
|
<widget class="QCheckBox" name="checkBox">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="sizePolicy">
|
||||||
<size>
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
<width>600</width>
|
<horstretch>0</horstretch>
|
||||||
<height>0</height>
|
<verstretch>0</verstretch>
|
||||||
</size>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="autoFillBackground">
|
<property name="autoFillBackground">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "openscad.h"
|
||||||
#include "GeometryCache.h"
|
#include "GeometryCache.h"
|
||||||
#include "ModuleCache.h"
|
#include "ModuleCache.h"
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
@ -124,15 +125,8 @@ QSet<MainWindow*> *MainWindow::getWindows()
|
||||||
// Global application state
|
// Global application state
|
||||||
unsigned int GuiLocker::gui_locked = 0;
|
unsigned int GuiLocker::gui_locked = 0;
|
||||||
|
|
||||||
#define QUOTE(x__) # x__
|
static std::string helptitle = openscad_version + "\nhttp://www.openscad.org\n\n";
|
||||||
#define QUOTED(x__) QUOTE(x__)
|
|
||||||
|
|
||||||
static char helptitle[] =
|
|
||||||
"OpenSCAD " QUOTED(OPENSCAD_VERSION)
|
|
||||||
#ifdef OPENSCAD_COMMIT
|
|
||||||
" (git " QUOTED(OPENSCAD_COMMIT) ")"
|
|
||||||
#endif
|
|
||||||
"\nhttp://www.openscad.org\n\n";
|
|
||||||
static char copyrighttext[] =
|
static char copyrighttext[] =
|
||||||
"Copyright (C) 2009-2014 The OpenSCAD Developers\n"
|
"Copyright (C) 2009-2014 The OpenSCAD Developers\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -189,6 +183,9 @@ MainWindow::MainWindow(const QString &filename)
|
||||||
this->consoleDock->setConfigKey("view/hideConsole");
|
this->consoleDock->setConfigKey("view/hideConsole");
|
||||||
this->consoleDock->setAction(this->viewActionHideConsole);
|
this->consoleDock->setAction(this->viewActionHideConsole);
|
||||||
|
|
||||||
|
QLabel *versionLabel = new QLabel(openscad_version.c_str());
|
||||||
|
this->statusbar->addPermanentWidget(versionLabel);
|
||||||
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
editortype = settings.value("editor/editortype").toString();
|
editortype = settings.value("editor/editortype").toString();
|
||||||
useScintilla = (editortype != "Simple Editor");
|
useScintilla = (editortype != "Simple Editor");
|
||||||
|
|
|
@ -90,6 +90,17 @@ std::string currentdir;
|
||||||
static bool arg_info = false;
|
static bool arg_info = false;
|
||||||
static std::string arg_colorscheme;
|
static std::string arg_colorscheme;
|
||||||
|
|
||||||
|
#define QUOTE(x__) # x__
|
||||||
|
#define QUOTED(x__) QUOTE(x__)
|
||||||
|
|
||||||
|
std::string openscad_versionnumber = QUOTED(OPENSCAD_VERSION)
|
||||||
|
#ifdef OPENSCAD_COMMIT
|
||||||
|
" (git " QUOTED(OPENSCAD_COMMIT) ")"
|
||||||
|
#endif
|
||||||
|
;
|
||||||
|
|
||||||
|
std::string openscad_version = "OpenSCAD " + openscad_versionnumber;
|
||||||
|
|
||||||
class Echostream : public std::ofstream
|
class Echostream : public std::ofstream
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -616,6 +627,9 @@ int gui(vector<string> &inputFiles, const fs::path &original_path, int argc, cha
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
QApplication app(argc, argv, true); //useGUI);
|
QApplication app(argc, argv, true); //useGUI);
|
||||||
|
// remove ugly frames in the QStatusBar when using additional widgets
|
||||||
|
app.setStyleSheet("QStatusBar::item { border: 0px solid black }; ");
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
app.installEventFilter(new EventFilter(&app));
|
app.installEventFilter(new EventFilter(&app));
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -34,3 +34,11 @@ extern std::string commandline_commands;
|
||||||
// The CWD when application started. We shouldn't change CWD, but until we stop
|
// The CWD when application started. We shouldn't change CWD, but until we stop
|
||||||
// doing this, use currentdir to get the original CWD.
|
// doing this, use currentdir to get the original CWD.
|
||||||
extern std::string currentdir;
|
extern std::string currentdir;
|
||||||
|
|
||||||
|
extern std::string versionnumber;
|
||||||
|
|
||||||
|
// Just the number (might have the git commit as suffix), e.g. 2014.12.23.
|
||||||
|
extern std::string openscad_versionnumber;
|
||||||
|
|
||||||
|
// The string "OpenSCAD " and the version number.
|
||||||
|
extern std::string openscad_version;
|
||||||
|
|
Loading…
Reference in New Issue