Merged main window classes.

This commit is contained in:
leo 2015-01-25 23:04:39 +00:00
parent c63cb59fd6
commit 21d622bd59
10 changed files with 1436 additions and 1760 deletions

View file

@ -11,7 +11,6 @@
#include "lc_mainwindow.h"
#include "lc_shortcuts.h"
#include "view.h"
#include "lc_qmainwindow.h"
lcApplication* g_App;
@ -238,7 +237,6 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstal
WavefrontName = argv[i];
}
}
else if ((strcmp(Param, "-v") == 0) || (strcmp(Param, "--version") == 0))
{
printf("LeoCAD Version " LC_VERSION_TEXT "\n");
@ -290,7 +288,7 @@ bool lcApplication::Initialize(int argc, char* argv[], const char* LibraryInstal
"Please visit http://www.leocad.org for information on how to download and install a library.", LC_MB_OK | LC_MB_ICONERROR);
}
gMainWindow->mHandle = new lcQMainWindow;
gMainWindow->CreateWidgets();
// Create a new project.
Project* NewProject = new Project();

View file

@ -240,7 +240,7 @@ bool lcContext::SaveRenderToTextureImage(const QString& FileName, int Width, int
bool Result = Writer.write(QImage(Buffer, Width, Height, QImage::Format_ARGB32));
if (!Result)
QMessageBox::information(gMainWindow->mHandle, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, Writer.errorString()));
QMessageBox::information(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, Writer.errorString()));
free(Buffer);

File diff suppressed because it is too large Load diff

View file

@ -8,6 +8,10 @@
class View;
class PiecePreview;
class lcQGLWidget;
class lcQPartsTree;
class lcQColorList;
class lcQPropertiesTree;
#define LC_MAX_RECENT_FILES 4
@ -21,14 +25,16 @@ struct lcSearchOptions
char Name[256];
};
class lcMainWindow
class lcMainWindow : public QMainWindow
{
Q_DECLARE_TR_FUNCTIONS(lcBaseWindow)
Q_OBJECT
public:
lcMainWindow();
~lcMainWindow();
void CreateWidgets();
lcTool GetTool() const
{
return mTool;
@ -145,7 +151,6 @@ public:
void SetLockZ(bool LockZ);
void SetRelativeTransform(bool RelativeTransform);
void Close();
void NewProject();
bool OpenProject(const QString& FileName);
void MergeProject();
@ -158,7 +163,7 @@ public:
void SplitHorizontal();
void SplitVertical();
void RemoveView();
void RemoveActiveView();
void ResetViews();
void TogglePrintPreview();
@ -166,7 +171,6 @@ public:
void UpdateFocusObject(lcObject* Focus);
void UpdateSelectedObjects(int Flags, int SelectedCount, lcObject* Focus);
void UpdateAction(int NewAction);
void UpdatePaste(bool Enabled);
void UpdateCurrentStep();
void SetAddKeys(bool AddKeys);
@ -190,10 +194,28 @@ public:
PiecePreview* mPreviewWidget;
int mColorIndex;
lcSearchOptions mSearchOptions;
QAction* mActions[LC_NUM_COMMANDS];
QWidget* mHandle;
protected slots:
void ClipboardChanged();
void ActionTriggered();
void PartsTreeItemChanged(QTreeWidgetItem* Current, QTreeWidgetItem* Previous);
void ColorChanged(int ColorIndex);
void PartSearchReturn();
void PartSearchChanged(const QString& Text);
void Print(QPrinter* Printer);
protected:
void closeEvent(QCloseEvent *event);
QMenu* createPopupMenu();
void CreateActions();
void CreateMenus();
void CreateToolBars();
void CreateStatusBar();
void SplitView(Qt::Orientation Orientation);
void ShowPrintDialog();
View* mActiveView;
lcArray<View*> mViews;
@ -207,6 +229,28 @@ protected:
bool mLockY;
bool mLockZ;
bool mRelativeTransform;
QAction* mActionFileRecentSeparator;
QToolBar* mStandardToolBar;
QToolBar* mToolsToolBar;
QToolBar* mTimeToolBar;
QDockWidget* mPartsToolBar;
QDockWidget* mPropertiesToolBar;
lcQGLWidget* mPiecePreviewWidget;
lcQPartsTree* mPartsTree;
QLineEdit* mPartSearchEdit;
lcQColorList* mColorList;
lcQPropertiesTree* mPropertiesWidget;
QLineEdit* mTransformXEdit;
QLineEdit* mTransformYEdit;
QLineEdit* mTransformZEdit;
QLabel* mStatusBarLabel;
QLabel* mStatusPositionLabel;
QLabel* mStatusSnapLabel;
QLabel* mStatusTimeLabel;
};
extern class lcMainWindow* gMainWindow;

View file

@ -109,7 +109,7 @@ void Project::CreateNewModel()
{
bool Ok = false;
Name = QInputDialog::getText(gMainWindow->mHandle, tr("New Model"), tr("Name:"), QLineEdit::Normal, Name, &Ok);
Name = QInputDialog::getText(gMainWindow, tr("New Model"), tr("Name:"), QLineEdit::Normal, Name, &Ok);
if (!Ok)
return;
@ -118,9 +118,9 @@ void Project::CreateNewModel()
break;
if (Name.isEmpty())
QMessageBox::information(gMainWindow->mHandle, tr("Empty Name"), tr("The model name cannot be empty."));
QMessageBox::information(gMainWindow, tr("Empty Name"), tr("The model name cannot be empty."));
else
QMessageBox::information(gMainWindow->mHandle, tr("Duplicate Model"), tr("A model named '%1' already exists in this project, please enter an unique name.").arg(Name));
QMessageBox::information(gMainWindow, tr("Duplicate Model"), tr("A model named '%1' already exists in this project, please enter an unique name.").arg(Name));
}
if (!Name.isEmpty())
@ -146,7 +146,7 @@ void Project::ShowModelListDialog()
Models.append(QPair<QString, lcModel*>(Model->GetProperties().mName, Model));
}
lcQModelListDialog Dialog(gMainWindow->mHandle, Models);
lcQModelListDialog Dialog(gMainWindow, Models);
if (Dialog.exec() != QDialog::Accepted || Models.isEmpty())
return;
@ -197,7 +197,7 @@ bool Project::Load(const QString& FileName)
if (!File.open(QIODevice::ReadOnly))
{
QMessageBox::warning(gMainWindow->mHandle, tr("Error"), tr("Error reading file '%1':\n%2").arg(FileName, File.errorString()));
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error reading file '%1':\n%2").arg(FileName, File.errorString()));
return false;
}
@ -263,7 +263,7 @@ bool Project::Save(const QString& FileName)
if (!File.open(QIODevice::WriteOnly))
{
QMessageBox::warning(gMainWindow->mHandle, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
return false;
}
@ -1072,7 +1072,7 @@ void Project::ExportHTML()
if (!File.open(QIODevice::WriteOnly))
{
QMessageBox::warning(gMainWindow->mHandle, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
return;
}
@ -1103,7 +1103,7 @@ void Project::ExportHTML()
if (!File.open(QIODevice::WriteOnly))
{
QMessageBox::warning(gMainWindow->mHandle, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
return;
}
@ -1128,7 +1128,7 @@ void Project::ExportHTML()
if (!File.open(QIODevice::WriteOnly))
{
QMessageBox::warning(gMainWindow->mHandle, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
return;
}
@ -1162,7 +1162,7 @@ void Project::ExportHTML()
if (!File.open(QIODevice::WriteOnly))
{
QMessageBox::warning(gMainWindow->mHandle, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
QMessageBox::warning(gMainWindow, tr("Error"), tr("Error writing to file '%1':\n%2").arg(FileName, File.errorString()));
return;
}
@ -1570,7 +1570,7 @@ void Project::ExportWavefront(const QString& FileName)
QString SaveFileName = FileName;
if (SaveFileName.isEmpty())
{
SaveFileName = QFileDialog::getSaveFileName(gMainWindow->mHandle, tr("Export Wavefront"), SaveFileName, tr("Wavefront Files (*.obj);;All Files (*.*)"));
SaveFileName = QFileDialog::getSaveFileName(gMainWindow, tr("Export Wavefront"), SaveFileName, tr("Wavefront Files (*.obj);;All Files (*.*)"));
if (SaveFileName.isEmpty())
return;

View file

@ -146,7 +146,6 @@ SOURCES += common/view.cpp \
common/group.cpp \
common/debug.cpp \
common/camera.cpp \
qt/lc_qmainwindow.cpp \
qt/system.cpp \
qt/qtmain.cpp \
qt/lc_qpovraydialog.cpp \
@ -210,7 +209,6 @@ HEADERS += \
common/group.h \
common/debug.h \
common/camera.h \
qt/lc_qmainwindow.h \
qt/lc_config.h \
qt/lc_qpovraydialog.h \
qt/lc_qarraydialog.h \

View file

@ -4,7 +4,6 @@
#include "project.h"
#include "lc_library.h"
#include "lc_application.h"
#include "lc_qmainwindow.h"
#include "lc_mainwindow.h"
#include "lc_context.h"
#include "view.h"
@ -38,9 +37,7 @@ void* lcGLWidget::GetExtensionAddress(const char* FunctionName)
void lcGLWidget::ShowPopupMenu()
{
QGLWidget* Widget = (QGLWidget*)mWidget;
lcQMainWindow *mainWindow = (lcQMainWindow*)gMainWindow->mHandle;
QAction **actions = mainWindow->actions;
QAction **actions = gMainWindow->mActions;
QMenu *popup = new QMenu(Widget);

File diff suppressed because it is too large Load diff

View file

@ -1,111 +0,0 @@
#ifndef _LC_QMAINWINDOW_H_
#define _LC_QMAINWINDOW_H_
#include <QMainWindow>
#include <QPrinter>
#include "lc_array.h"
#include "lc_commands.h"
class QComboBox;
class lcQGLWidget;
class lcQPartsTree;
class lcQColorList;
class lcQPropertiesTree;
class View;
class lcQMainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit lcQMainWindow(QWidget *parent = 0);
~lcQMainWindow();
void LibraryLoaded();
void showPrintDialog();
void splitHorizontal();
void splitVertical();
void removeView();
void resetViews();
void togglePrintPreview();
void toggleFullScreen();
void updateFocusObject(lcObject *focus);
void updateSelectedObjects(int flags, int selectedCount, lcObject* focus);
void updateAction(int newAction);
void updatePaste(bool enabled);
void updateCurrentStep();
void setAddKeys(bool addKeys);
void updateLockSnap();
void updateSnap();
void updateColor();
void updateUndoRedo(const QString& UndoText, const QString& RedoText);
void updateTransformType(int newType);
void updateCameraMenu();
void updateCurrentCamera(int cameraIndex);
void updatePerspective(View* view);
void updateModels();
void updateCategories();
void updateTitle(const QString& title, bool modified);
void updateModified(bool modified);
void updateRecentFiles();
void updateShortcuts();
lcVector3 getTransformAmount();
QAction *actions[LC_NUM_COMMANDS];
private slots:
void print(QPrinter *printer);
void actionTriggered();
void partsTreeItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
void colorChanged(int colorIndex);
void partSearchReturn();
void partSearchChanged(const QString& text);
void clipboardChanged();
private:
void createActions();
void createMenus();
void createToolBars();
void createStatusBar();
void splitView(Qt::Orientation orientation);
void closeEvent(QCloseEvent *event);
QMenu *createPopupMenu();
QAction *actionFileRecentSeparator;
QMenu *menuCamera;
QMenu *menuFile;
QMenu *menuEdit;
QMenu *menuView;
QMenu *menuPiece;
QMenu *menuModel;
QMenu *menuHelp;
QToolBar *standardToolBar;
QToolBar *toolsToolBar;
QToolBar *timeToolBar;
QDockWidget *partsToolBar;
QDockWidget *propertiesToolBar;
lcQGLWidget *piecePreview;
lcQPartsTree *partsTree;
QLineEdit *partSearch;
lcQColorList *colorList;
lcQPropertiesTree *propertiesWidget;
QLineEdit *transformX;
QLineEdit *transformY;
QLineEdit *transformZ;
QStatusBar *statusBar;
QLabel *statusBarLabel;
QLabel *statusPositionLabel;
QLabel *statusSnapLabel;
QLabel *statusTimeLabel;
};
#endif // _LC_QMAINWINDOW_H_

View file

@ -1,6 +1,5 @@
#include "lc_global.h"
#include "lc_application.h"
#include "lc_qmainwindow.h"
#include "lc_qupdatedialog.h"
#include "lc_mainwindow.h"
#include "view.h"
@ -179,12 +178,10 @@ int main(int argc, char *argv[])
if (!g_App->Initialize(argc, argv, libPath, LDrawPath, cachePath.toLocal8Bit().data()))
return 1;
lcQMainWindow* MainWindow = (lcQMainWindow*)gMainWindow->mHandle;
MainWindow->LibraryLoaded();
lcGetActiveModel()->UpdateInterface();
gMainWindow->SetColorIndex(lcGetColorIndex(4));
gMainWindow->UpdateRecentFiles();
MainWindow->show();
gMainWindow->show();
#if !LC_DISABLE_UPDATE_CHECK
lcDoInitialUpdateCheck();
@ -197,236 +194,5 @@ int main(int argc, char *argv[])
delete g_App;
g_App = NULL;
delete MainWindow;
return execReturn;
}
void lcMainWindow::Close()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
window->close();
}
void lcMainWindow::SplitHorizontal()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->splitHorizontal();
}
void lcMainWindow::SplitVertical()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->splitVertical();
}
void lcMainWindow::RemoveView()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->removeView();
}
void lcMainWindow::ResetViews()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->resetViews();
}
void lcMainWindow::TogglePrintPreview()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->togglePrintPreview();
}
void lcMainWindow::ToggleFullScreen()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->toggleFullScreen();
}
void lcMainWindow::UpdateFocusObject(lcObject* Focus)
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateFocusObject(Focus);
}
void lcMainWindow::UpdateSelectedObjects(int Flags, int SelectedCount, lcObject* Focus)
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateSelectedObjects(Flags, SelectedCount, Focus);
}
void lcMainWindow::UpdateAction(int NewAction)
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateAction(NewAction);
}
void lcMainWindow::UpdatePaste(bool Enabled)
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updatePaste(Enabled);
}
void lcMainWindow::UpdateCurrentStep()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateCurrentStep();
}
void lcMainWindow::SetAddKeys(bool AddKeys)
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->setAddKeys(AddKeys);
mAddKeys = AddKeys;
}
void lcMainWindow::UpdateLockSnap()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateLockSnap();
}
void lcMainWindow::UpdateSnap()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateSnap();
}
void lcMainWindow::UpdateColor()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateColor();
}
void lcMainWindow::UpdateUndoRedo(const QString& UndoText, const QString& RedoText)
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateUndoRedo(UndoText, RedoText);
}
void lcMainWindow::SetTransformType(lcTransformType TransformType)
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
mTransformType = TransformType;
if (window)
window->updateTransformType(TransformType);
}
void lcMainWindow::UpdateCameraMenu()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateCameraMenu();
}
void lcMainWindow::UpdateCurrentCamera(int CameraIndex)
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateCurrentCamera(CameraIndex);
}
void lcMainWindow::UpdatePerspective()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updatePerspective(mActiveView);
}
void lcMainWindow::UpdateModels()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateModels();
}
void lcMainWindow::UpdateCategories()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateCategories();
}
void lcMainWindow::UpdateTitle()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateTitle(lcGetActiveProject()->GetTitle(), lcGetActiveProject()->IsModified());
}
void lcMainWindow::UpdateModified(bool Modified)
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateModified(Modified);
}
void lcMainWindow::UpdateRecentFiles()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateRecentFiles();
}
void lcMainWindow::UpdateShortcuts()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
window->updateShortcuts();
}
lcVector3 lcMainWindow::GetTransformAmount()
{
lcQMainWindow* window = (lcQMainWindow*)mHandle;
if (window)
return window->getTransformAmount();
return lcVector3(0.0f, 0.0f, 0.0f);
}