src/main.cpp

changeset 237
10a6298f636f
parent 236
1fa0e1de9f0a
child 240
414d392b9ae6
equal deleted inserted replaced
236:1fa0e1de9f0a 237:10a6298f636f
1 #include <QApplication> 1 #include <QApplication>
2 #include <QFileDialog> 2 #include <QFileDialog>
3 #include <QMessageBox> 3 #include <QMessageBox>
4 #include <QMdiSubWindow> 4 #include <QMdiSubWindow>
5 #include <QScrollBar>
5 #include <QStackedWidget> 6 #include <QStackedWidget>
6 #include <QCloseEvent> 7 #include <QCloseEvent>
7 #include "mainwindow.h" 8 #include "mainwindow.h"
8 #include "ui_mainwindow.h" 9 #include "ui_mainwindow.h"
9 #include "version.h" 10 #include "version.h"
53 static void doQtRegistrations() 54 static void doQtRegistrations()
54 { 55 {
55 QCoreApplication::setApplicationName(::appName); 56 QCoreApplication::setApplicationName(::appName);
56 QCoreApplication::setOrganizationName("hecknology.net"); 57 QCoreApplication::setOrganizationName("hecknology.net");
57 QCoreApplication::setOrganizationDomain("hecknology.net"); 58 QCoreApplication::setOrganizationDomain("hecknology.net");
59 qRegisterMetaType<Message>();
58 qRegisterMetaTypeStreamOperators<Library>("Library"); 60 qRegisterMetaTypeStreamOperators<Library>("Library");
59 qRegisterMetaTypeStreamOperators<Libraries>("Libraries"); 61 qRegisterMetaTypeStreamOperators<Libraries>("Libraries");
60 qRegisterMetaTypeStreamOperators<gl::RenderStyle>(); 62 qRegisterMetaTypeStreamOperators<gl::RenderStyle>();
61 qRegisterMetaTypeStreamOperators<QMdiArea::ViewMode>(); 63 qRegisterMetaTypeStreamOperators<QMdiArea::ViewMode>();
62 } 64 }
341 result.push_back(index.row()); 343 result.push_back(index.row());
342 } 344 }
343 return result; 345 return result;
344 } 346 }
345 347
346 #include <QScrollBar>
347 int main(int argc, char *argv[]) 348 int main(int argc, char *argv[])
348 { 349 {
349 doQtRegistrations(); 350 doQtRegistrations();
350 QApplication app{argc, argv}; 351 QApplication app{argc, argv};
351 QMainWindow mainWindow; 352 QMainWindow mainWindow;
476 data->itemSelectionModel->select(qindex, QItemSelectionModel::Select); 477 data->itemSelectionModel->select(qindex, QItemSelectionModel::Select);
477 } 478 }
478 } 479 }
479 } 480 }
480 }); 481 });
482 QObject::connect(data->canvas.get(), &PartRenderer::message, &messageLog, &MessageLog::addMessage);
481 const QFileInfo fileInfo{*documents.modelPath(modelId)}; 483 const QFileInfo fileInfo{*documents.modelPath(modelId)};
482 ModelSubWindow* subWindow = new ModelSubWindow{modelId, ui.mdiArea}; 484 ModelSubWindow* subWindow = new ModelSubWindow{modelId, ui.mdiArea};
483 subWindow->setWidget(data->canvas.get()); 485 subWindow->setWidget(data->canvas.get());
484 subWindow->setWindowTitle(tabName(fileInfo)); 486 subWindow->setWindowTitle(tabName(fileInfo));
485 subWindow->show(); 487 subWindow->show();
634 QObject::connect(&messageLog, &MessageLog::rowsAboutToBeInserted, [&]{ 636 QObject::connect(&messageLog, &MessageLog::rowsAboutToBeInserted, [&]{
635 const auto bar = ui.messageLog->verticalScrollBar(); 637 const auto bar = ui.messageLog->verticalScrollBar();
636 ui.messageLog->setProperty("shouldAutoScroll", bar->value() == bar->maximum()); 638 ui.messageLog->setProperty("shouldAutoScroll", bar->value() == bar->maximum());
637 }); 639 });
638 QObject::connect(&messageLog, &MessageLog::rowsInserted, [&]{ 640 QObject::connect(&messageLog, &MessageLog::rowsInserted, [&]{
641 ui.messageLog->resizeRowsToContents();
639 if (ui.messageLog->property("shouldAutoScroll").toBool()) { 642 if (ui.messageLog->property("shouldAutoScroll").toBool()) {
640 ui.messageLog->scrollToBottom(); 643 ui.messageLog->scrollToBottom();
641 } 644 }
642 }); 645 });
643 mainWindow.setWindowTitle(title()); 646 mainWindow.setWindowTitle(title());

mercurial