Skip to content

Commit

Permalink
Blender LDraw Render - refactor blender configured setting #416
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsandy committed May 8, 2023
1 parent be53647 commit 12852b9
Show file tree
Hide file tree
Showing 17 changed files with 123 additions and 89 deletions.
2 changes: 1 addition & 1 deletion builds/linux/obs/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Last Update: July 19, 2020
# Copyright (C) 2017 - 2023 by Trevor SANDY
pkgname=lpub3d
pkgver=2.4.6.3355
pkgver=2.4.6.3356
pkgrel=1
pkgdesc="An LDraw Building Instruction Editor"
url="https://github.com/trevorsandy/lpub3d.git"
Expand Down
2 changes: 1 addition & 1 deletion builds/linux/obs/alldeps/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Last Update: July 19, 2020
# Copyright (C) 2017 - 2023 by Trevor SANDY
pkgname=lpub3d
pkgver=2.4.6.3355
pkgver=2.4.6.3356
pkgrel=1
pkgdesc="An LDraw Building Instruction Editor"
url="https://github.com/trevorsandy/lpub3d.git"
Expand Down
6 changes: 3 additions & 3 deletions builds/linux/obs/alldeps/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lpub3d (2.4.6.3355) debian; urgency=medium
lpub3d (2.4.6.3356) debian; urgency=medium

* LPub3D version 2.4.6.244.3355_20230508 for Linux
* LPub3D version 2.4.6.245.3356_20230508 for Linux

-- Trevor SANDY <trevor.sandy@gmail.com> Mon, 08 May 2023 15:20:52 +0200
-- Trevor SANDY <trevor.sandy@gmail.com> Mon, 08 May 2023 15:21:17 +0200
2 changes: 1 addition & 1 deletion builds/linux/obs/alldeps/debian/lpub3d.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Format: 1.0
Source: lpub3d
Binary: lpub3d
Architecture: any
Version: 2.4.6.3355
Version: 2.4.6.3356
Maintainer: Trevor SANDY <trevor.sandy@gmail.com>
Homepage: https://trevorsandy.github.io/lpub3d/
Standards-Version: 3.9.7
Expand Down
4 changes: 2 additions & 2 deletions builds/linux/obs/alldeps/lpub3d.spec
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ BuildRequires: fdupes
Summary: An LDraw Building Instruction Editor
Name: lpub3d
Icon: lpub3d.xpm
Version: 2.4.6.3355
Version: 2.4.6.3356
Release: <B_CNT>%{?dist}
URL: https://trevorsandy.github.io/lpub3d
Vendor: Trevor SANDY
Expand Down Expand Up @@ -797,7 +797,7 @@ update-desktop-database || true
%endif

%changelog
* Mon May 08 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3355
* Mon May 08 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3356
- LPub3D 2.4.4 enhancements and fixes - see RELEASE_NOTES for details

* Tue May 31 2022 - trevor dot sandy at gmail dot com 2.4.4.2670
Expand Down
6 changes: 3 additions & 3 deletions builds/linux/obs/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lpub3d (2.4.6.3355) debian; urgency=medium
lpub3d (2.4.6.3356) debian; urgency=medium

* LPub3D version 2.4.6.244.3355_20230508 for Linux
* LPub3D version 2.4.6.245.3356_20230508 for Linux

-- Trevor SANDY <trevor.sandy@gmail.com> Mon, 08 May 2023 15:20:53 +0200
-- Trevor SANDY <trevor.sandy@gmail.com> Mon, 08 May 2023 15:21:19 +0200
2 changes: 1 addition & 1 deletion builds/linux/obs/debian/lpub3d.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Format: 1.0
Source: lpub3d
Binary: lpub3d
Architecture: any
Version: 2.4.6.3355
Version: 2.4.6.3356
Maintainer: Trevor SANDY <trevor.sandy@gmail.com>
Homepage: https://trevorsandy.github.io/lpub3d/
Standards-Version: 3.9.7
Expand Down
4 changes: 2 additions & 2 deletions builds/linux/obs/lpub3d.spec
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ BuildRequires: fdupes
Summary: An LDraw Building Instruction Editor
Name: lpub3d
Icon: lpub3d.xpm
Version: 2.4.6.3355
Version: 2.4.6.3356
Release: 1%{?dist}
URL: https://trevorsandy.github.io/lpub3d
Vendor: Trevor SANDY
Expand Down Expand Up @@ -313,7 +313,7 @@ update-desktop-database || true
%endif

%changelog
* Mon May 08 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3355
* Mon May 08 2023 - trevor.dot.sandy.at.gmail.dot.com 2.4.6.3356
- LPub3D 2.4.4 enhancements and fixes - see RELEASE_NOTES for details

* Tue May 31 2022 - trevor dot sandy at gmail dot com 2.4.4.2670
Expand Down
2 changes: 1 addition & 1 deletion builds/utilities/version.info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2 4 6 244 3355 edcc415d7
2 4 6 245 3356 be53647c3
6 changes: 3 additions & 3 deletions gitversion.pri
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ equals(GIT_DIR, undefined) {

# Check if we do not have a valid version number (i.e. no version tag found)
isEmpty(GIT_VERSION) {
GIT_REVISION = 244
GIT_REVISION = 245
GIT_SHA = $$system($$GIT_BASE_COMMAND rev-parse --short HEAD 2> $$NULL_DEVICE)
GIT_COMMIT = $$system($$GIT_BASE_COMMAND rev-list --count HEAD 2> $$NULL_DEVICE)
GIT_VERSION = v$${VERSION}-$${GIT_REVISION}-$${GIT_SHA}
Expand Down Expand Up @@ -69,7 +69,7 @@ equals(GIT_DIR, undefined) {
# Get commit count
GIT_COMMIT = $$system($$GIT_BASE_COMMAND rev-list --count HEAD 2> $$NULL_DEVICE)
isEmpty(GIT_COMMIT) {
GIT_COMMIT = 3355
GIT_COMMIT = 3356
message("~~~ ERROR! GIT_COMMIT NOT DEFINED, USING $$GIT_COMMIT ~~~")
}

Expand Down Expand Up @@ -117,7 +117,7 @@ if (equals(USE_GIT_VER_FILE, true)|equals(USE_VERSION_INFO_VAR, true)) {
GIT_VERSION = $$cat($$GIT_VER_FILE, lines)
} else {
message("~~~ ERROR! $$GIT_DIR_ENV VERSION_INFO FILE $$GIT_VER_FILE NOT FOUND ~~~")
GIT_VERSION = $${VERSION}.244.3355.edcc415d7
GIT_VERSION = $${VERSION}.245.3356.be53647c3
message("~~~ GIT_DIR [$$GIT_DIR_ENV, USING VERSION] $$GIT_VERSION ~~~")
GIT_VERSION ~= s/\./" "
}
Expand Down
86 changes: 52 additions & 34 deletions mainApp/blenderpreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void BlenderPreferences::getRenderSettings(

mDialogCancelled = false;

mBlenderConfigured = Preferences::blenderInstalled && !Preferences::blenderLDrawConfigFile.isEmpty();
mBlenderConfigured = !Preferences::blenderImportModule.isEmpty();

clear();

Expand Down Expand Up @@ -348,8 +348,12 @@ void BlenderPreferences::getRenderSettings(
? tr("Import MM")
: "";

QString colour, text;
if (mBlenderConfigured) {
blenderVersionLabel->setText(tr("Blender Version"));
colour = Preferences::displayTheme == THEME_DARK
? QLatin1String("white")
: QLatin1String("black");
text = tr("Blender Version");
blenderVersionEdit->setText(blenderVersion);
if (!blenderAddonVersion.isEmpty()) {
blenderAddonModulesBox->setEnabled(true);
Expand All @@ -359,15 +363,16 @@ void BlenderPreferences::getRenderSettings(
blenderImportMMActBox->setChecked(importModule.endsWith(" MM"));
}
} else {
const QString colour = Preferences::displayTheme == THEME_DARK
? Preferences::themeColors[THEME_DARK_DECORATE_LPUB3D_QUOTED_TEXT]
: QLatin1String("blue");
blenderVersionLabel->setStyleSheet(QString("QLabel { color : %1; }").arg(colour));
blenderVersionLabel->setText(tr("Blender not configured"));
colour = Preferences::displayTheme == THEME_DARK
? Preferences::themeColors[THEME_DARK_DECORATE_LPUB3D_QUOTED_TEXT]
: QLatin1String("blue");
text = tr("Blender not configured");
blenderVersionEdit->setVisible(mBlenderConfigured);
// set default LDraw import module
blenderImportActBox->setChecked(true);
}
blenderVersionLabel->setStyleSheet(QString("QLabel { color : %1; }").arg(colour));
blenderVersionLabel->setText(text);

blenderAddonUpdateButton = new QPushButton(tr("Update..."), blenderContent);
blenderAddonUpdateButton->setToolTip(tr("Update %1 Blender LDraw addon").arg(VER_PRODUCTNAME_STR));
Expand Down Expand Up @@ -875,16 +880,15 @@ bool BlenderPreferences::settingsModified(int &width, int &height, double &rende

void BlenderPreferences::resetSettings()
{
mBlenderConfigured = !Preferences::blenderImportModule.isEmpty();

blenderPaths[LBL_BLENDER_PATH].value = Preferences::blenderExe;
const QStringList versionItems = Preferences::blenderVersion.split("|");
blenderVersion = versionItems.first();
blenderAddonVersion = versionItems.size() == 2 ? versionItems.last() : QString();
blenderVersion = Preferences::blenderVersion;
blenderAddonVersion = Preferences::blenderAddonVersion;

blenderVersionEdit->setText(blenderVersion);
blenderAddonVersionEdit->setText(blenderAddonVersion);

mBlenderConfigured = !Preferences::blenderExe.isEmpty() && !Preferences::blenderLDrawConfigFile.isEmpty();;

if (blenderImportActBox->isChecked()) {
disconnect(lineEditList[IMAGE_HEIGHT_EDIT],SIGNAL(textChanged(const QString &)),
this, SLOT (sizeChanged(const QString &)));
Expand Down Expand Up @@ -1079,9 +1083,8 @@ void BlenderPreferences::loadSettings() {
}

blenderPaths[LBL_BLENDER_PATH].value = Preferences::blenderExe;
const QStringList versionItems = Preferences::blenderVersion.split("|");
blenderVersion = versionItems.first();
blenderAddonVersion = versionItems.size() == 2 ? versionItems.last() : QString();
blenderVersion = Preferences::blenderVersion;
blenderAddonVersion = Preferences::blenderAddonVersion;
}

void BlenderPreferences::saveSettings()
Expand Down Expand Up @@ -1472,6 +1475,7 @@ void BlenderPreferences::configureBlender(bool testBlender)
: QLatin1String("blue");
blenderVersionLabel->setStyleSheet(QString("QLabel { color : %1; }").arg(colour));
blenderVersionLabel->setText(tr("Blender not configured"));
blenderVersionEdit->clear();
blenderVersionEdit->setVisible(mBlenderConfigured);
blenderAddonUpdateButton->setEnabled(mBlenderConfigured);
blenderPathsBox->setEnabled(mBlenderConfigured);
Expand Down Expand Up @@ -1929,17 +1933,21 @@ int BlenderPreferences::getBlenderAddon(const QString &blenderDir)

// Remove old addon archive if exist
if (QFileInfo(blenderAddonDir).exists()) {
bool result = true;
QDir dir(blenderAddonDir);
dir.setNameFilters(QStringList() << "*.*");
dir.setFilter(QDir::Files);

for (const QString &dirFile : dir.entryList()) {
dir.remove(dirFile);
emit gui->messageSig(LOG_INFO, tr("Removed Blender addon item: [%1]").arg(dirFile));
Q_FOREACH(QFileInfo const &info, dir.entryInfoList(QDir::AllDirs | QDir::Files, QDir::DirsFirst)) {
if (info.isDir())
result &= QDir(info.absoluteFilePath()).removeRecursively();
else
result &= QFile::remove(info.absoluteFilePath());
if (result)
emit gui->messageSig(LOG_INFO, tr("Removed addon: [%1]").arg(info.absoluteFilePath()));
else
emit gui->messageSig(LOG_NOTICE, tr("Failed to remove addon: %1").arg(info.absoluteFilePath()));
}

if (!dir.rmdir("."))
emit gui->messageSig(LOG_NOTICE, tr("Failed to remove Blender folder: %1")
result &= dir.rmdir(blenderAddonDir);
if (!result)
emit gui->messageSig(LOG_NOTICE, tr("Failed to remove Blender addon: %1")
.arg(blenderAddonDir));
}

Expand Down Expand Up @@ -2037,9 +2045,12 @@ void BlenderPreferences::readStdOut()
QRegExp rxAddonVersion("^ADDON VERSION: ", Qt::CaseInsensitive);

bool errorEncountered = false;
QStringList items,messages;
QStringList items,errors;
QStringList stdOutLines = StdOut.split(QRegExp("\n|\r\n|\r"));

QString const saveAddonVersion = blenderAddonVersion;
QString const saveVersion = blenderVersion;

int lineCount = 0;
for (QString const &stdOutLine : stdOutLines) {
if (stdOutLine.isEmpty())
Expand Down Expand Up @@ -2078,16 +2089,16 @@ void BlenderPreferences::readStdOut()
} else if (stdOutLine.contains(rxError) || stdOutLine.contains(rxWarning)) {
auto cleanLine = [&] () {
return stdOutLine.trimmed()
.replace("<","&lt;")
/*.replace("<","&lt;")
.replace(">","&gt;")
.replace("&","&amp;") + "\n";
.replace("&","&amp;")*/ + "<br>";
};
errorEncountered = stdOutLine.contains(rxError);
messages << cleanLine();
errors << cleanLine();
int errorCount = lineCount;
for (;errorCount < stdOutLines.size(); errorCount++) {
if (stdOutLine.at(0) == "")
messages << cleanLine();
errors << cleanLine();
else
break;
}
Expand All @@ -2099,12 +2110,17 @@ void BlenderPreferences::readStdOut()
}
lineCount++;
}
if (messages.size()) {
if (errors.size()) {
mBlenderConfigured = false;
blenderVersionEdit->clear();
QString const stdOutLog = QDir::toNativeSeparators(QString("\n\n- See %1/Blender/stdout-blender-addon-install")
if (blenderAddonVersion != saveAddonVersion)
blenderAddonVersion = saveAddonVersion;
if (blenderVersion != saveVersion)
blenderVersion = saveVersion;
blenderAddonVersionEdit->setText(blenderAddonVersion);
blenderVersionEdit->setText(blenderVersion);
QString const stdOutLog = QDir::toNativeSeparators(QString("<br>- See %1/Blender/stdout-blender-addon-install")
.arg(Preferences::lpub3d3rdPartyConfigDir));
emit gui->messageSig(LOG_BLENDER_ADDON, messages.join(" ").append(stdOutLog), errorEncountered);
emit gui->messageSig(LOG_BLENDER_ADDON, errors.join(" ").append(stdOutLog), errorEncountered);
}
}

Expand All @@ -2125,7 +2141,8 @@ QString BlenderPreferences::readStdErr(bool &hasError) const
while ( ! in.atEnd())
{
QString line = in.readLine(0);
returnLines << line.trimmed().replace("<","&lt;")
returnLines << line.trimmed()
.replace("<","&lt;")
.replace(">","&gt;")
.replace("&","&amp;") + "<br>";
if (!hasError)
Expand Down Expand Up @@ -2199,6 +2216,7 @@ void BlenderPreferences::showResult()
message = tr("Addon install failed. See %1/stderr-blender-addon-install for details.").arg(blenderDir);
statusUpdate(false, tr("%1: Addon install failed.").arg("Error"));
mBlenderConfigured = false;
blenderAddonVersionEdit->clear();
blenderVersionEdit->clear();
emit gui->messageSig(LOG_BLENDER_ADDON, StdErrLog, true);
} else {
Expand Down
2 changes: 1 addition & 1 deletion mainApp/docs/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LPub3D 2.4.6.244.3355 (08 05 2023 15:20:53)
LPub3D 2.4.6.245.3356 (08 05 2023 15:21:19)

Features, enhancements, fixes and changes
------------
Expand Down
2 changes: 1 addition & 1 deletion mainApp/docs/RELEASE_NOTES.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<table class="tg">
<tr>
<th class="tg-0pky">
<h4><a id="LPub3D_0"></a>LPub3D 2.4.6.244.3355 (08 05 2023 15:20:53)</h4>
<h4><a id="LPub3D_0"></a>LPub3D 2.4.6.245.3356 (08 05 2023 15:21:19)</h4>
<hr>
<p>
<span class="tg-1pky">LPub3D Official release.</span><br>
Expand Down
4 changes: 2 additions & 2 deletions mainApp/extras/LPub3D_Npp_UDL.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
;;
;; Author......: Trevor SANDY
;; Name........: LPub3D_Npp_UDL.xml
;; Version.....: 2.4.6.244.3355
;; Last Update.: Mon, 08 May 2023 15:20:53 +0200
;; Version.....: 2.4.6.245.3356
;; Last Update.: Mon, 08 May 2023 15:21:19 +0200
;; License.....: GPLv3
;; Homepage....: https://trevorsandy.github.io/lpub3d
;; Copyright (C) 2021 - 2023 by Trevor SANDY
Expand Down
Loading

0 comments on commit 12852b9

Please sign in to comment.