Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issues #160 #239 #319

Merged
merged 5 commits into from
Mar 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion common/lc_application.cpp
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ void lcPreferences::LoadDefaults()
mViewSphereColor = lcGetProfileInt(LC_PROFILE_VIEW_SPHERE_COLOR);
mViewSphereTextColor = lcGetProfileInt(LC_PROFILE_VIEW_SPHERE_TEXT_COLOR);
mViewSphereHighlightColor = lcGetProfileInt(LC_PROFILE_VIEW_SPHERE_HIGHLIGHT_COLOR);
autoLoadMostRecent = lcGetProfileInt(LC_PROFILE_AUTOLOAD_MOSTRECENT);
}

void lcPreferences::SaveDefaults()
@@ -50,6 +51,7 @@ void lcPreferences::SaveDefaults()
lcSetProfileInt(LC_PROFILE_VIEW_SPHERE_COLOR, mViewSphereColor);
lcSetProfileInt(LC_PROFILE_VIEW_SPHERE_TEXT_COLOR, mViewSphereTextColor);
lcSetProfileInt(LC_PROFILE_VIEW_SPHERE_HIGHLIGHT_COLOR, mViewSphereHighlightColor);
lcSetProfileInt(LC_PROFILE_AUTOLOAD_MOSTRECENT, autoLoadMostRecent);
}

lcApplication::lcApplication(int& Argc, char** Argv)
@@ -196,7 +198,7 @@ bool lcApplication::Initialize(QList<QPair<QString, bool>>& LibraryPaths, bool&
QString ModelName;
QString CameraName;
QString ViewpointName;
QString ProjectName;
QString ProjectName = lcGetProfileInt(LC_PROFILE_AUTOLOAD_MOSTRECENT) ? lcGetProfileString(LC_PROFILE_RECENT_FILE1) : QString();
QString SaveWavefrontName;
QString Save3DSName;
QString SaveCOLLADAName;
1 change: 1 addition & 0 deletions common/lc_application.h
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ class lcPreferences
quint32 mViewSphereColor;
quint32 mViewSphereTextColor;
quint32 mViewSphereHighlightColor;
bool autoLoadMostRecent;
};

class lcApplication : public QApplication
2 changes: 1 addition & 1 deletion common/lc_global.h
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
#include <array>

#ifndef Q_FALLTHROUGH
#define Q_FALLTHROUGH(); [[fallthrough]];
#define Q_FALLTHROUGH(); // fall through
#endif

#if !defined(EGL_VERSION_1_0) && !defined(GL_ES_VERSION_2_0) && !defined(GL_ES_VERSION_3_0) && !defined(QT_OPENGL_ES)
3 changes: 1 addition & 2 deletions common/lc_model.cpp
Original file line number Diff line number Diff line change
@@ -592,8 +592,7 @@ void lcModel::LoadLDraw(QIODevice& Device, Project* Project)
if (Token == QLatin1String("BEGIN"))
{
QString Name = LineStream.readAll().trimmed();
QByteArray NameUtf = Name.toUtf8(); // todo: replace with qstring
lcGroup* Group = GetGroup(NameUtf.constData(), true);
lcGroup* Group = GetGroup(Name, true);
if (!CurrentGroups.IsEmpty())
Group->mGroup = CurrentGroups[CurrentGroups.GetSize() - 1];
else
1 change: 1 addition & 0 deletions common/lc_profile.cpp
Original file line number Diff line number Diff line change
@@ -82,6 +82,7 @@ static lcProfileEntry gProfileEntries[LC_NUM_PROFILE_KEYS] =
lcProfileEntry("Settings", "RecentFile2", ""), // LC_PROFILE_RECENT_FILE2
lcProfileEntry("Settings", "RecentFile3", ""), // LC_PROFILE_RECENT_FILE3
lcProfileEntry("Settings", "RecentFile4", ""), // LC_PROFILE_RECENT_FILE4
lcProfileEntry("Settings", "AutoLoadMostRecent", false), // LC_PROFILE_AUTOLOAD_MOSTRECENT
lcProfileEntry("Settings", "AutosaveInterval", 10), // LC_PROFILE_AUTOSAVE_INTERVAL
lcProfileEntry("Settings", "MouseSensitivity", 11), // LC_PROFILE_MOUSE_SENSITIVITY
lcProfileEntry("Settings", "ImageWidth", 1280), // LC_PROFILE_IMAGE_WIDTH
1 change: 1 addition & 0 deletions common/lc_profile.h
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ enum LC_PROFILE_KEY
LC_PROFILE_RECENT_FILE2,
LC_PROFILE_RECENT_FILE3,
LC_PROFILE_RECENT_FILE4,
LC_PROFILE_AUTOLOAD_MOSTRECENT,
LC_PROFILE_AUTOSAVE_INTERVAL,
LC_PROFILE_MOUSE_SENSITIVITY,
LC_PROFILE_IMAGE_WIDTH,
1 change: 1 addition & 0 deletions leocad.qrc
Original file line number Diff line number Diff line change
@@ -89,6 +89,7 @@
<file>resources/time_add_keys.png</file>
<file>resources/parts_search.png</file>
<file>resources/parts_cancel.png</file>
<file>resources/archive.png</file>
<file>resources/library.zip</file>
<file>resources/ldconfig.ldr</file>
<file>resources/minifig.ini</file>
14 changes: 12 additions & 2 deletions qt/lc_qpreferencesdialog.cpp
Original file line number Diff line number Diff line change
@@ -43,7 +43,8 @@ lcQPreferencesDialog::lcQPreferencesDialog(QWidget *parent, void *data) :
ui->lgeoPath->setText(options->LGEOPath);
ui->mouseSensitivity->setValue(options->Preferences.mMouseSensitivity);
ui->checkForUpdates->setCurrentIndex(options->CheckForUpdates);
ui->fixedDirectionKeys->setChecked((options->Preferences.mFixedAxes) != 0);
ui->fixedDirectionKeys->setChecked(options->Preferences.mFixedAxes);
ui->autoLoadMostRecent->setChecked(options->Preferences.autoLoadMostRecent);

ui->antiAliasing->setChecked(options->AASamples != 1);
if (options->AASamples == 8)
@@ -145,6 +146,7 @@ void lcQPreferencesDialog::accept()
options->Preferences.mMouseSensitivity = ui->mouseSensitivity->value();
options->CheckForUpdates = ui->checkForUpdates->currentIndex();
options->Preferences.mFixedAxes = ui->fixedDirectionKeys->isChecked();
options->Preferences.autoLoadMostRecent = ui->autoLoadMostRecent->isChecked();

if (!ui->antiAliasing->isChecked())
options->AASamples = 1;
@@ -188,7 +190,15 @@ void lcQPreferencesDialog::accept()

void lcQPreferencesDialog::on_partsLibraryBrowse_clicked()
{
QString result = QFileDialog::getExistingDirectory(this, tr("Open Parts Library Folder"), ui->partsLibrary->text());
QString result = QFileDialog::getExistingDirectory(this, tr("Select Parts Library Folder..."), ui->partsLibrary->text());

if (!result.isEmpty())
ui->partsLibrary->setText(QDir::toNativeSeparators(result));
}

void lcQPreferencesDialog::on_partsArchiveBrowse_clicked()
{
QString result = QFileDialog::getOpenFileName(this, tr("Select Parts Library Archive..."), ui->partsLibrary->text(), tr("Supported Archives (*.zip *.bin);;All Files (*.*)"));

if (!result.isEmpty())
ui->partsLibrary->setText(QDir::toNativeSeparators(result));
1 change: 1 addition & 0 deletions qt/lc_qpreferencesdialog.h
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ class lcQPreferencesDialog : public QDialog
public slots:
void accept();
void on_partsLibraryBrowse_clicked();
void on_partsArchiveBrowse_clicked();
void on_povrayExecutableBrowse_clicked();
void on_lgeoPathBrowse_clicked();
void ColorButtonClicked();
21 changes: 19 additions & 2 deletions qt/lc_qpreferencesdialog.ui
Original file line number Diff line number Diff line change
@@ -67,8 +67,17 @@
</item>
<item>
<widget class="QToolButton" name="partsLibraryBrowse">
<property name="text">
<string>...</string>
<property name="icon">
<iconset>
<normaloff>:/resources/file_open.png</normaloff>:/resources/file_open.png</iconset>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="partsArchiveBrowse">
<property name="icon">
<iconset>
<normaloff>:/resources/archive.png</normaloff>:/resources/archive.png</iconset>
</property>
</widget>
</item>
@@ -158,6 +167,13 @@
</property>
</widget>
</item>
<item row="8" column="0" colspan="2">
<widget class="QCheckBox" name="autoLoadMostRecent">
<property name="text">
<string>Open most recent file on startup</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabRendering">
@@ -982,6 +998,7 @@
<tabstop>authorName</tabstop>
<tabstop>partsLibrary</tabstop>
<tabstop>partsLibraryBrowse</tabstop>
<tabstop>partsArchiveBrowse</tabstop>
<tabstop>povrayExecutable</tabstop>
<tabstop>povrayExecutableBrowse</tabstop>
<tabstop>lgeoPath</tabstop>
4 changes: 2 additions & 2 deletions qt/lc_qpropertiestree.cpp
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ void lcQPropertiesTreeDelegate::paint(QPainter *painter, const QStyleOptionViewI
if (m_treeWidget)
hasValue = m_treeWidget->indexToItem(index)->data(0, lcQPropertiesTree::PropertyTypeRole).toInt() != lcQPropertiesTree::PropertyGroup;

QStyleOptionViewItemV3 opt = option;
QStyleOptionViewItem opt = option;

opt.state &= ~QStyle::State_HasFocus;

@@ -241,7 +241,7 @@ QSize lcQPropertiesTree::sizeHint() const

void lcQPropertiesTree::drawRow(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QStyleOptionViewItemV3 opt = option;
QStyleOptionViewItem opt = option;

QTreeWidgetItem *item = itemFromIndex(index);

67 changes: 49 additions & 18 deletions qt/lc_renderdialog.cpp
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ lcRenderDialog::lcRenderDialog(QWidget* Parent)

QImage Image(LC_POVRAY_PREVIEW_WIDTH, LC_POVRAY_PREVIEW_HEIGHT, QImage::Format_RGB32);
Image.fill(QColor(255, 255, 255));
ui->label->setPixmap(QPixmap::fromImage(Image));
ui->preview->setPixmap(QPixmap::fromImage(Image));

connect(&mUpdateTimer, SIGNAL(timeout()), this, SLOT(Update()));
mUpdateTimer.start(500);
@@ -168,10 +168,15 @@ void lcRenderDialog::on_RenderButton_clicked()
#endif

mProcess = new QProcess(this);
connect(mProcess, SIGNAL(readyReadStandardError()), this, SLOT(ReadStdErr()));
mProcess->start(POVRayPath, Arguments);

if (mProcess->waitForStarted())
{
ui->RenderButton->setText(tr("Cancel"));
ui->RenderProgress->setValue(ui->RenderProgress->minimum());
stdErrList.clear();
}
else
{
QMessageBox::warning(this, tr("Error"), tr("Error starting POV-Ray."));
@@ -180,6 +185,19 @@ void lcRenderDialog::on_RenderButton_clicked()
#endif
}

void lcRenderDialog::ReadStdErr()
{
QString stdErr = QString(mProcess->readAllStandardError());
stdErrList.append(stdErr);
QRegExp regexPovRayProgress("Rendered (\\d+) of (\\d+) pixels.*");
regexPovRayProgress.setCaseSensitivity(Qt::CaseInsensitive);
if (regexPovRayProgress.indexIn(stdErr) == 0)
{
ui->RenderProgress->setMaximum(regexPovRayProgress.cap(2).toInt());
ui->RenderProgress->setValue(regexPovRayProgress.cap(1).toInt());
}
}

void lcRenderDialog::Update()
{
#ifndef QT_NO_PROCESS
@@ -188,14 +206,12 @@ void lcRenderDialog::Update()

if (mProcess->state() == QProcess::NotRunning)
{
// QString Output = mProcess->readAllStandardError();
// QMessageBox::information(this, "LeoCAD", Output);

#ifdef Q_OS_LINUX
QByteArray Output = mProcess->readAllStandardOutput();
QImage Image = QImage::fromData(Output);
ui->label->setPixmap(QPixmap::fromImage(Image.scaled(LC_POVRAY_PREVIEW_WIDTH, LC_POVRAY_PREVIEW_HEIGHT, Qt::KeepAspectRatio, Qt::SmoothTransformation)));
mImage = QImage::fromData(Output);
ShowResult();
#endif

CloseProcess();
}
#endif
@@ -251,23 +267,38 @@ void lcRenderDialog::Update()

Header->PixelsRead = PixelsWritten;

ui->label->setPixmap(QPixmap::fromImage(mImage.scaled(LC_POVRAY_PREVIEW_WIDTH, LC_POVRAY_PREVIEW_HEIGHT, Qt::KeepAspectRatio, Qt::SmoothTransformation)));

if (PixelsWritten == Width * Height)
{
QString FileName = ui->OutputEdit->text();
ShowResult();
#endif
}

if (!FileName.isEmpty())
{
QImageWriter Writer(FileName);
void lcRenderDialog::ShowResult() {
ReadStdErr();
ui->RenderProgress->setValue(ui->RenderProgress->maximum());

if (mProcess->exitStatus() != QProcess::NormalExit || mProcess->exitCode() != 0) {
QMessageBox error;
error.setWindowTitle(tr("Error"));
error.setIcon(QMessageBox::Critical);
error.setText(tr("An error occurred while rendering. Check details or try again."));
error.setDetailedText(stdErrList.join(""));
error.exec();
return;
}

bool Result = Writer.write(mImage);
ui->preview->setPixmap(QPixmap::fromImage(mImage.scaled(LC_POVRAY_PREVIEW_WIDTH, LC_POVRAY_PREVIEW_HEIGHT, Qt::KeepAspectRatio, Qt::SmoothTransformation)));

if (!Result)
QMessageBox::information(this, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, Writer.errorString()));
}
QString FileName = ui->OutputEdit->text();

if (!FileName.isEmpty())
{
QImageWriter Writer(FileName);

bool Result = Writer.write(mImage);

if (!Result)
QMessageBox::information(this, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, Writer.errorString()));
}
#endif
}

void lcRenderDialog::on_OutputBrowseButton_clicked()
5 changes: 5 additions & 0 deletions qt/lc_renderdialog.h
Original file line number Diff line number Diff line change
@@ -20,11 +20,15 @@ public slots:
void on_OutputBrowseButton_clicked();
void Update();

protected slots:
void ReadStdErr();

protected:
QString GetOutputFileName() const;
QString GetPOVFileName() const;
void CloseProcess();
bool PromptCancel();
void ShowResult();

#ifndef QT_NO_PROCESS
QProcess* mProcess;
@@ -33,6 +37,7 @@ public slots:
QFile mOutputFile;
void* mOutputBuffer;
QImage mImage;
QStringList stdErrList;

Ui::lcRenderDialog* ui;
};
134 changes: 66 additions & 68 deletions qt/lc_renderdialog.ui
Original file line number Diff line number Diff line change
@@ -13,43 +13,43 @@
<property name="windowTitle">
<string>Render</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<layout class="QVBoxLayout" name="topLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Settings</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="1" column="1">
<widget class="QLineEdit" name="WidthEdit"/>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="HeightEdit"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="widthLabel">
<property name="text">
<string>Width:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<item>
<widget class="QLineEdit" name="WidthEdit"/>
</item>
<item>
<widget class="QLabel" name="heightLabel">
<property name="text">
<string>Height:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item>
<widget class="QLineEdit" name="HeightEdit"/>
</item>
<item>
<widget class="QLabel" name="qualityLabel">
<property name="text">
<string>Quality:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="QualityComboBox">
<item>
<property name="text">
@@ -68,68 +68,66 @@
</item>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Quality:</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Output:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLineEdit" name="OutputEdit"/>
</item>
<item>
<widget class="QToolButton" name="OutputBrowseButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QPushButton" name="RenderButton">
<property name="text">
<string>Render</string>
</property>
</widget>
<layout class="QHBoxLayout" name="outputLayout">
<item>
<widget class="QLabel" name="outputLabel">
<property name="text">
<string>Output:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="OutputEdit"/>
</item>
<item>
<widget class="QToolButton" name="OutputBrowseButton">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
<layout class="QHBoxLayout" name="renderLayout">
<item>
<widget class="QProgressBar" name="RenderProgress">
<property name="maximum">
<number>1</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="RenderButton">
<property name="text">
<string>Render</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="preview">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>WidthEdit</tabstop>
<tabstop>HeightEdit</tabstop>
<tabstop>QualityComboBox</tabstop>
<tabstop>OutputEdit</tabstop>
<tabstop>OutputBrowseButton</tabstop>
<tabstop>RenderButton</tabstop>
</tabstops>
<resources/>
<connections/>
2 changes: 1 addition & 1 deletion qt/qtmain.cpp
Original file line number Diff line number Diff line change
@@ -138,7 +138,7 @@ int main(int argc, char *argv[])
}

QTranslator Translator;
if (Translator.load(QString("leocad_") + QLocale::system().name().section('_', 0, 0) + ".qm", ":/resources"))
if (Translator.load("leocad_" + QLocale::system().name(), ":/resources"))
{
Application.installTranslator(&Translator);
}
Binary file added resources/archive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
360 changes: 190 additions & 170 deletions resources/leocad_de.ts

Large diffs are not rendered by default.

358 changes: 189 additions & 169 deletions resources/leocad_fr.ts

Large diffs are not rendered by default.

354 changes: 187 additions & 167 deletions resources/leocad_pt.ts

Large diffs are not rendered by default.