Skip to content

Commit

Permalink
Merge branches 'feature/2041_qopenglwindow' and 'feature/2041_qopengl…
Browse files Browse the repository at this point in the history
…window' of github.com:kduske/TrenchBroom into feature/2041_qopenglwindow
  • Loading branch information
kduske committed Aug 28, 2019
2 parents 1d9f087 + c5b34aa commit 7740d86
Show file tree
Hide file tree
Showing 7 changed files with 293 additions and 152 deletions.
2 changes: 1 addition & 1 deletion cmake/Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ SET(COMMON_SOURCE
${COMMON_SOURCE_DIR}/View/ControlListBox.cpp
${COMMON_SOURCE_DIR}/View/ConvertEntityColorCommand.cpp
${COMMON_SOURCE_DIR}/View/CopyTexCoordSystemFromFaceCommand.cpp
# ${COMMON_SOURCE_DIR}/View/CrashDialog.cpp
${COMMON_SOURCE_DIR}/View/CrashDialog.cpp
${COMMON_SOURCE_DIR}/View/CreateBrushToolBase.cpp
${COMMON_SOURCE_DIR}/View/CreateComplexBrushToolController3D.cpp
${COMMON_SOURCE_DIR}/View/CreateComplexBrushTool.cpp
Expand Down
36 changes: 12 additions & 24 deletions common/src/TrenchBroomApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
#include "Model/MapFormat.h"
#include "View/AboutDialog.h"
#include "View/Actions.h"
// FIXME:
//#include "View/CrashDialog.h"
#include "View/CrashDialog.h"
#include "View/GameDialog.h"
#include "View/MainMenuBuilder.h"
#include "View/MapDocument.h"
Expand Down Expand Up @@ -292,14 +291,14 @@ namespace TrenchBroom {
return true;
}

/* FIXME: crash reporting
static String makeCrashReport(const String &stacktrace, const String &reason) {
StringStream ss;
ss << "OS:\t" << QSysInfo::prettyProductName().toStdString() << std::endl;
ss << "Qt:\t" << qVersion() << std::endl;
ss << "GL_VENDOR:\t" << MapViewBase::glVendorString().toStdString() << std::endl;
ss << "GL_RENDERER:\t" << MapViewBase::glRendererString().toStdString() << std::endl;
ss << "GL_VERSION:\t" << MapViewBase::glVersionString().toStdString() << std::endl;
// FIXME:
// ss << "GL_VENDOR:\t" << MapViewBase::glVendorString().toStdString() << std::endl;
// ss << "GL_RENDERER:\t" << MapViewBase::glRendererString().toStdString() << std::endl;
// ss << "GL_VERSION:\t" << MapViewBase::glVersionString().toStdString() << std::endl;
ss << "TrenchBroom Version:\t" << getBuildVersion().toStdString() << std::endl;
ss << "TrenchBroom Build:\t" << getBuildIdStr().toStdString() << std::endl;
ss << "Reason:\t" << reason << std::endl;
Expand Down Expand Up @@ -347,7 +346,6 @@ namespace TrenchBroom {
}
return testCrashLogPath.deleteExtension();
}
*/

static bool inReportCrashAndExit = false;
static bool crashReportGuiEnabled = true;
Expand All @@ -357,10 +355,9 @@ namespace TrenchBroom {
}

void reportCrashAndExit(const String &stacktrace, const String &reason) {
#if 0
// just abort if we reenter reportCrashAndExit (i.e. if it crashes)
if (inReportCrashAndExit)
wxAbort();
std::abort();

inReportCrashAndExit = true;

Expand Down Expand Up @@ -391,26 +388,22 @@ namespace TrenchBroom {
if (!QFile::copy(IO::pathAsQString(IO::SystemPaths::logFilePath()), QString::fromStdString(logPath.asString())))
logPath = IO::Path();

// write the crash log to stdout
// write the crash log to stderr
std::cerr << "crash log:" << std::endl;
std::cerr << report << std::endl;

if (crashReportGuiEnabled) {
CrashDialog dialog;
dialog.Create(reportPath, mapPath, logPath);
dialog.ShowModal();
CrashDialog dialog(reportPath, mapPath, logPath);
dialog.exec();
}
#endif
// FIXME:

std::abort();
}

bool isReportingCrash() {
return inReportCrashAndExit;
}

// FIXME: exception handling
#if 0
void TrenchBroomApp::OnUnhandledException() {
handleException();
}
Expand All @@ -423,7 +416,6 @@ namespace TrenchBroom {
void TrenchBroomApp::OnFatalException() {
reportCrashAndExit(TrenchBroomStackWalker::getStackTrace(), "OnFatalException");
}
#endif

#if defined(_WIN32) && defined(_MSC_VER)
LONG WINAPI TrenchBroomUnhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionPtrs) {
Expand Down Expand Up @@ -508,12 +500,8 @@ namespace TrenchBroom {
const IO::Path mapPath(IO::SystemPaths::userDataDirectory() + IO::Path("crashreport.map"));
const IO::Path logPath(IO::SystemPaths::userDataDirectory() + IO::Path("crashreport.log"));

// FIXME:
#if 0
CrashDialog dialog;
dialog.Create(reportPath, mapPath, logPath);
dialog.ShowModal();
#endif
CrashDialog dialog(reportPath, mapPath, logPath);
dialog.exec();
}

// FIXME: Probably not needed with Qt?
Expand Down
8 changes: 3 additions & 5 deletions common/src/TrenchBroomApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ namespace TrenchBroom {
void openAbout();
bool initializeGameFactory();

#if 0
bool OnExceptionInMainLoop() override;
void OnUnhandledException() override;
void OnFatalException() override;
#endif
bool OnExceptionInMainLoop();
void OnUnhandledException();
void OnFatalException();
private:
void handleException();
public:
Expand Down
49 changes: 27 additions & 22 deletions common/src/View/Actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,59 +389,63 @@ namespace TrenchBroom {

/* ========== Translation ========== */
// applies to objects, vertices, handles (e.g. rotation center)
// these preference paths are structured like "action in 2D view; action in 3D view"
m_mapViewActions.push_back(
createAction(IO::Path("Controls/Map view/Move forward"), QObject::tr("Move Forward"),
createAction(IO::Path("Controls/Map view/Move objects up; Move objects forward"), QObject::tr("Move Forward"),
ActionContext::AnyView | ActionContext::NodeSelection | ActionContext::AnyVertexTool | ActionContext::RotateTool, QKeySequence(Qt::Key_Up),
[](ActionExecutionContext& context) {
context.view()->move(vm::direction::forward);
},
[](ActionExecutionContext& context) { return context.hasDocument(); }));
m_mapViewActions.push_back(
createAction(IO::Path("Controls/Map view/Move backward"), QObject::tr("Move Backward"),
createAction(IO::Path("Controls/Map view/Move objects down; Move objects backward"), QObject::tr("Move Backward"),
ActionContext::AnyView | ActionContext::NodeSelection | ActionContext::AnyVertexTool | ActionContext::RotateTool, QKeySequence(Qt::Key_Down),
[](ActionExecutionContext& context) {
context.view()->move(vm::direction::backward);
},
[](ActionExecutionContext& context) { return context.hasDocument(); }));
m_mapViewActions.push_back(
createAction(IO::Path("Controls/Map view/Move left"), QObject::tr("Move Left"),
createAction(IO::Path("Controls/Map view/Move objects left"), QObject::tr("Move Left"),
ActionContext::AnyView | ActionContext::NodeSelection | ActionContext::AnyVertexTool | ActionContext::RotateTool, QKeySequence(Qt::Key_Left),
[](ActionExecutionContext& context) {
context.view()->move(vm::direction::left);
},
[](ActionExecutionContext& context) { return context.hasDocument(); }));
m_mapViewActions.push_back(
createAction(IO::Path("Controls/Map view/Move right"), QObject::tr("Move Right"),
createAction(IO::Path("Controls/Map view/Move objects right"), QObject::tr("Move Right"),
ActionContext::AnyView | ActionContext::NodeSelection | ActionContext::AnyVertexTool | ActionContext::RotateTool, QKeySequence(Qt::Key_Right),
[](ActionExecutionContext& context) {
context.view()->move(vm::direction::right);
},
[](ActionExecutionContext& context) { return context.hasDocument(); }));
m_mapViewActions.push_back(
createAction(IO::Path("Controls/Map view/Move up"), QObject::tr("Move Up"),
createAction(IO::Path("Controls/Map view/Move objects backward; Move objects up"), QObject::tr("Move Up"),
ActionContext::AnyView | ActionContext::NodeSelection | ActionContext::AnyVertexTool | ActionContext::RotateTool, QKeySequence(Qt::Key_PageUp),
[](ActionExecutionContext& context) {
context.view()->move(vm::direction::up);
},
[](ActionExecutionContext& context) { return context.hasDocument(); }));
m_mapViewActions.push_back(
createAction(IO::Path("Controls/Map view/Move down"), QObject::tr("Move Down"),
createAction(IO::Path("Controls/Map view/Move objects forward; Move objects down"), QObject::tr("Move Down"),
ActionContext::AnyView | ActionContext::NodeSelection | ActionContext::AnyVertexTool | ActionContext::RotateTool, QKeySequence(Qt::Key_PageDown),
[](ActionExecutionContext& context) {
context.view()->move(vm::direction::down);
},
[](ActionExecutionContext& context) { return context.hasDocument(); }));

/* ========== Duplication ========== */
// these preference paths are structured like "action in 2D view; action in 3D view"
m_mapViewActions.push_back(
createAction(IO::Path("Controls/Map view/Duplicate and move objects forward"), QObject::tr("Duplicate and Move Forward"),
createAction(IO::Path("Controls/Map view/Duplicate and move objects up; Duplicate and move objects forward"),
QObject::tr("Duplicate and Move Forward"),
ActionContext::AnyView | ActionContext::NodeSelection, QKeySequence(Qt::CTRL + Qt::Key_Up),
[](ActionExecutionContext& context) {
context.view()->duplicateAndMoveObjects(vm::direction::forward);
},
[](ActionExecutionContext& context) { return context.hasDocument(); }));
m_mapViewActions.push_back(
createAction(IO::Path("Controls/Map view/Duplicate and move objects backward"), QObject::tr("Duplicate and Move Backward"),
createAction(IO::Path("Controls/Map view/Duplicate and move objects down; Duplicate and move objects backward"),
QObject::tr("Duplicate and Move Backward"),
ActionContext::AnyView | ActionContext::NodeSelection, QKeySequence(Qt::CTRL + Qt::Key_Down),
[](ActionExecutionContext& context) {
context.view()->duplicateAndMoveObjects(vm::direction::backward);
Expand All @@ -462,14 +466,16 @@ namespace TrenchBroom {
},
[](ActionExecutionContext& context) { return context.hasDocument(); }));
m_mapViewActions.push_back(
createAction(IO::Path("Controls/Map view/Duplicate and move objects up"), QObject::tr("Duplicate and Move Up"),
createAction(IO::Path("Controls/Map view/Duplicate and move objects backward; Duplicate and move objects up"),
QObject::tr("Duplicate and Move Up"),
ActionContext::AnyView | ActionContext::NodeSelection, QKeySequence(Qt::CTRL + Qt::Key_PageUp),
[](ActionExecutionContext& context) {
context.view()->duplicateAndMoveObjects(vm::direction::up);
},
[](ActionExecutionContext& context) { return context.hasDocument(); }));
m_mapViewActions.push_back(
createAction(IO::Path("Controls/Map view/Duplicate and move objects down"), QObject::tr("Duplicate and Move Down"),
createAction(IO::Path("Controls/Map view/Duplicate and move objects forward; Duplicate and move objects down"),
QObject::tr("Duplicate and Move Down"),
ActionContext::AnyView | ActionContext::NodeSelection, QKeySequence(Qt::CTRL + Qt::Key_PageDown),
[](ActionExecutionContext& context) {
context.view()->duplicateAndMoveObjects(vm::direction::down);
Expand Down Expand Up @@ -547,7 +553,6 @@ namespace TrenchBroom {
context.view()->moveTextures(vm::direction::up);
},
[](ActionExecutionContext& context) { return context.hasDocument(); }));
// FIXME: Did we lose the fine/coarse (Ctrl/Shift) variants?
m_mapViewActions.push_back(
createAction(IO::Path("Controls/Map view/Move textures down"), QObject::tr("Move Textures Down"),
ActionContext::View3D | ActionContext::FaceSelection, QKeySequence(Qt::Key_Down),
Expand Down Expand Up @@ -682,7 +687,7 @@ namespace TrenchBroom {
},
[](ActionExecutionContext& context) { return true; }));
fileMenu.addSeparator();
fileMenu.addItem(createMenuAction(IO::Path("Menu/File/Open"), QObject::tr("Open Document..."), QKeySequence::Open,
fileMenu.addItem(createMenuAction(IO::Path("Menu/File/Open..."), QObject::tr("Open Document..."), QKeySequence::Open,
[](ActionExecutionContext& context) {
auto& app = TrenchBroomApp::instance();
app.openDocument();
Expand All @@ -695,7 +700,7 @@ namespace TrenchBroom {
context.frame()->saveDocument();
},
[](ActionExecutionContext& context) { return context.hasDocument(); }));
fileMenu.addItem(createMenuAction(IO::Path("Menu/File/Save as"), QObject::tr("Save Document as..."), QKeySequence::SaveAs,
fileMenu.addItem(createMenuAction(IO::Path("Menu/File/Save as..."), QObject::tr("Save Document as..."), QKeySequence::SaveAs,
[](ActionExecutionContext& context) {
context.frame()->saveDocumentAs();
},
Expand Down Expand Up @@ -1346,7 +1351,7 @@ namespace TrenchBroom {
return context.hasDocument() && context.frame()->currentViewMaximized();
}));
viewMenu.addSeparator();
viewMenu.addItem(createMenuAction(IO::Path("Menu/View/Preferences"), QObject::tr("Preferences..."), QKeySequence::Preferences,
viewMenu.addItem(createMenuAction(IO::Path("Menu/File/Preferences..."), QObject::tr("Preferences..."), QKeySequence::Preferences,
[](ActionExecutionContext& context) {
auto& app = TrenchBroomApp::instance();
app.showPreferences();
Expand All @@ -1358,14 +1363,14 @@ namespace TrenchBroom {

void ActionManager::createRunMenu() {
auto& runMenu = createMainMenu("Run");
runMenu.addItem(createMenuAction(IO::Path("Menu/Run/Compile"), QObject::tr("Compile Map..."), 0,
runMenu.addItem(createMenuAction(IO::Path("Menu/Run/Compile..."), QObject::tr("Compile Map..."), 0,
[](ActionExecutionContext& context) {
context.frame()->showCompileDialog();
},
[](ActionExecutionContext& context) {
return context.hasDocument();
}));
runMenu.addItem(createMenuAction(IO::Path("Menu/Run/Launch"), QObject::tr("Launch Engine..."), 0,
runMenu.addItem(createMenuAction(IO::Path("Menu/Run/Launch..."), QObject::tr("Launch Engine..."), 0,
[](ActionExecutionContext& context) {
context.frame()->showLaunchEngineDialog();
},
Expand All @@ -1384,21 +1389,21 @@ namespace TrenchBroom {
[](ActionExecutionContext& context) {
return context.hasDocument();
}));
debugMenu.addItem(createMenuAction(IO::Path("Menu/Debug/Create Brush"), QObject::tr("Create Brush..."), 0,
debugMenu.addItem(createMenuAction(IO::Path("Menu/Debug/Create Brush..."), QObject::tr("Create Brush..."), 0,
[](ActionExecutionContext& context) {
context.frame()->debugCreateBrush();
},
[](ActionExecutionContext& context) {
return context.hasDocument();
}));
debugMenu.addItem(createMenuAction(IO::Path("Menu/Debug/Create Cube"), QObject::tr("Create Cube..."), 0,
debugMenu.addItem(createMenuAction(IO::Path("Menu/Debug/Create Cube..."), QObject::tr("Create Cube..."), 0,
[](ActionExecutionContext& context) {
context.frame()->debugCreateCube();
},
[](ActionExecutionContext& context) {
return context.hasDocument();
}));
debugMenu.addItem(createMenuAction(IO::Path("Menu/Debug/Clip Brush"), QObject::tr("Clip Brush..."), 0,
debugMenu.addItem(createMenuAction(IO::Path("Menu/Debug/Clip Brush..."), QObject::tr("Clip Brush..."), 0,
[](ActionExecutionContext& context) {
context.frame()->debugClipBrush();
},
Expand All @@ -1412,7 +1417,7 @@ namespace TrenchBroom {
[](ActionExecutionContext& context) {
return context.hasDocument();
}));
debugMenu.addItem(createMenuAction(IO::Path("Menu/Debug/Crash"), QObject::tr("Crash..."), 0,
debugMenu.addItem(createMenuAction(IO::Path("Menu/Debug/Crash..."), QObject::tr("Crash..."), 0,
[](ActionExecutionContext& context) {
context.frame()->debugCrash();
},
Expand All @@ -1434,7 +1439,7 @@ namespace TrenchBroom {
[](ActionExecutionContext& context) {
return true;
}));
debugMenu.addItem(createMenuAction(IO::Path("Menu/Debug/Set Window Size"), QObject::tr("Set Window Size..."), 0,
debugMenu.addItem(createMenuAction(IO::Path("Menu/Debug/Set Window Size..."), QObject::tr("Set Window Size..."), 0,
[](ActionExecutionContext& context) {
context.frame()->debugSetWindowSize();
},
Expand All @@ -1455,7 +1460,7 @@ namespace TrenchBroom {
[](ActionExecutionContext& context) {
return true;
}));
helpMenu.addItem(createMenuAction(IO::Path("Menu/Help/About TrenchBroom"), QObject::tr("About TrenchBroom"), 0,
helpMenu.addItem(createMenuAction(IO::Path("Menu/File/About TrenchBroom"), QObject::tr("About TrenchBroom"), 0,
[](ActionExecutionContext& context) {
auto& app = TrenchBroomApp::instance();
app.showAboutDialog();
Expand Down
Loading

0 comments on commit 7740d86

Please sign in to comment.