diff --git a/common/lc_application.cpp b/common/lc_application.cpp index 476342e4..7f3bede5 100644 --- a/common/lc_application.cpp +++ b/common/lc_application.cpp @@ -277,49 +277,30 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstal // Create a new project. mProject = new Project(); - GL_DisableVertexBufferObject(); - // Load project. if (ProjectName && gMainWindow->OpenProject(ProjectName)) { if (!SaveImage) return true; - // Check if there's a file name and it has an extension. - bool NeedExt = true; - String FileName; + QString FileName; - if (!ImageName) - { + if (ImageName) + FileName = ImageName; + else FileName = ProjectName; - int i = FileName.ReverseFind('.'); - if (i != -1) - FileName[i] = 0; - } - else + QString Extension = QFileInfo(FileName).suffix().toLower(); + + if (Extension.isEmpty()) { - FileName = ImageName; - - int i = FileName.ReverseFind('.'); - String Ext; - - if (i != -1) - { - Ext = FileName.Right(FileName.GetLength() - i); - Ext.MakeLower(); - } - - if (Ext == "bmp") - NeedExt = false; - else if ((Ext == "jpg") || (Ext == "jpeg")) - NeedExt = false; - else if (Ext == "png") - NeedExt = false; - } - - if (NeedExt) FileName += lcGetProfileString(LC_PROFILE_IMAGE_EXTENSION); + } + else if (Extension != "bmp" && Extension != "jpg" && Extension != "jpeg" && Extension != "png") + { + FileName = FileName.left(FileName.length() - Extension.length() - 1); + FileName += lcGetProfileString(LC_PROFILE_IMAGE_EXTENSION); + } if (ImageEnd < ImageStart) ImageEnd = ImageStart; @@ -345,18 +326,17 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstal if (ImageEnd > 255) ImageEnd = 255; - String Frame; + QString Frame; if (ImageStart != ImageEnd) { - int Ext = FileName.ReverseFind('.'); - - Frame = FileName.Left(Ext) + "%1" + FileName.Right(FileName.GetLength() - Ext); + QString Extension = QFileInfo(FileName).suffix(); + Frame = FileName.left(FileName.length() - Extension.length() - 1) + QLatin1String("%1.") + Extension; } else Frame = FileName; - lcGetActiveModel()->SaveStepImages(Frame.Buffer(), ImageWidth, ImageHeight, ImageStart, ImageEnd); + lcGetActiveModel()->SaveStepImages(Frame, ImageWidth, ImageHeight, ImageStart, ImageEnd); return false; } diff --git a/common/lc_model.cpp b/common/lc_model.cpp index d5fbb4f6..57b8a59c 100644 --- a/common/lc_model.cpp +++ b/common/lc_model.cpp @@ -1072,7 +1072,13 @@ void lcModel::SaveStepImages(const QString& BaseName, int Width, int Height, lcS SetCurrentStep(Step); View.OnDraw(); - QString FileName = BaseName.arg(Step, 2, 10, QLatin1Char('0')); + QString FileName; + + if (Start == End) + FileName = BaseName; + else + FileName = BaseName.arg(Step, 2, 10, QLatin1Char('0')); + if (!Context->SaveRenderToTextureImage(FileName, Width, Height)) break; } diff --git a/qt/lc_qmainwindow.cpp b/qt/lc_qmainwindow.cpp index 2e56e2fe..6eabe6e0 100644 --- a/qt/lc_qmainwindow.cpp +++ b/qt/lc_qmainwindow.cpp @@ -43,37 +43,14 @@ lcQMainWindow::lcQMainWindow(QWidget *parent) QGridLayout *previewLayout = new QGridLayout(previewFrame); previewLayout->setContentsMargins(0, 0, 0, 0); - QWidget *viewWidget = new lcQGLWidget(previewFrame, piecePreview, new View(lcGetActiveModel()), true); + QWidget *viewWidget = new lcQGLWidget(previewFrame, piecePreview, new View(NULL), true); previewLayout->addWidget(viewWidget, 0, 0, 1, 1); connect(QApplication::clipboard(), SIGNAL(dataChanged()), this, SLOT(clipboardChanged())); clipboardChanged(); - lcPiecesLibrary* Library = lcGetPiecesLibrary(); - PieceInfo* Info = Library->FindPiece("3005", false); - - GL_EnableVertexBufferObject(); - - if (!lcGetActiveModel()->GetPieces().IsEmpty()) - { - for (int PieceIdx = 0; PieceIdx < Library->mPieces.GetSize(); PieceIdx++) - { - lcMesh* Mesh = Library->mPieces[PieceIdx]->GetMesh(); - - if (Mesh) - Mesh->UpdateBuffers(); - } - } - - if (!Info) - Info = Library->mPieces[0]; - - if (Info) - { - PiecePreview* Preview = (PiecePreview*)piecePreview->widget; - gMainWindow->mPreviewWidget = Preview; - Preview->SetCurrentPiece(Info); - } + PiecePreview* Preview = (PiecePreview*)piecePreview->widget; + gMainWindow->mPreviewWidget = Preview; QSettings settings; settings.beginGroup("MainWindow"); @@ -88,6 +65,23 @@ lcQMainWindow::~lcQMainWindow() { } +void lcQMainWindow::LibraryLoaded() +{ + lcPiecesLibrary* Library = lcGetPiecesLibrary(); + PieceInfo* Info = Library->FindPiece("3005", false); + + if (!Info) + Info = Library->mPieces[0]; + + if (Info) + gMainWindow->mPreviewWidget->SetCurrentPiece(Info); + + QCompleter *completer = new QCompleter(this); + completer->setModel(new lcQPartsListModel(completer)); + completer->setCaseSensitivity(Qt::CaseInsensitive); + partSearch->setCompleter(completer); +} + void lcQMainWindow::createActions() { for (int Command = 0; Command < LC_NUM_COMMANDS; Command++) @@ -502,11 +496,6 @@ void lcQMainWindow::createToolBars() connect(partSearch, SIGNAL(returnPressed()), this, SLOT(partSearchReturn())); connect(partSearch, SIGNAL(textChanged(QString)), this, SLOT(partSearchChanged(QString))); - QCompleter *completer = new QCompleter(this); - completer->setModel(new lcQPartsListModel(completer)); - completer->setCaseSensitivity(Qt::CaseInsensitive); - partSearch->setCompleter(completer); - QFrame *colorFrame = new QFrame(partsSplitter); colorFrame->setFrameShape(QFrame::StyledPanel); colorFrame->setFrameShadow(QFrame::Sunken); diff --git a/qt/lc_qmainwindow.h b/qt/lc_qmainwindow.h index c6e185d9..7e574252 100644 --- a/qt/lc_qmainwindow.h +++ b/qt/lc_qmainwindow.h @@ -21,6 +21,8 @@ public: explicit lcQMainWindow(QWidget *parent = 0); ~lcQMainWindow(); + void LibraryLoaded(); + void showPrintDialog(); void splitHorizontal(); diff --git a/qt/qtmain.cpp b/qt/qtmain.cpp index 3c3e877a..3f014807 100644 --- a/qt/qtmain.cpp +++ b/qt/qtmain.cpp @@ -176,12 +176,13 @@ int main(int argc, char *argv[]) QDir dir; dir.mkpath(cachePath); gMainWindow = new lcMainWindow(); + lcQMainWindow w; + gMainWindow->mHandle = &w; if (!g_App->Initialize(argc, argv, libPath, LDrawPath, cachePath.toLocal8Bit().data())) return 1; - lcQMainWindow w; - gMainWindow->mHandle = &w; + w.LibraryLoaded(); lcGetActiveModel()->UpdateInterface(); gMainWindow->SetColorIndex(lcGetColorIndex(4)); gMainWindow->UpdateRecentFiles();