vktraceviewer::vktraceviewer(QWidget *parent) : QMainWindow(parent), ui(new Ui::vktraceviewer), m_settingsDialog(this), m_pTraceFileModel(NULL), m_pProxyModel(NULL), m_pController(NULL), m_pGenerateTraceButton(NULL), m_pTimeline(NULL), m_pGenerateTraceDialog(NULL), m_bDelayUpdateUIForContext(false), m_bGeneratingTrace(false) { ui->setupUi(this); qRegisterMetaType<uint64_t>("uint64_t"); qRegisterMetaType<VktraceLogLevel>("VktraceLogLevel"); m_pTraceStatsTab = new QWidget(); m_pTraceStatsTab->setObjectName(QStringLiteral("m_pTraceStatsTab")); m_pTraceStatsTabLayout = new QGridLayout(m_pTraceStatsTab); m_pTraceStatsTabLayout->setSpacing(6); m_pTraceStatsTabLayout->setContentsMargins(11,11,11,11); m_pTraceStatsTabLayout->setObjectName(QStringLiteral("m_pTraceStatsTabLayout")); m_pTraceStatsTabText = new QTextBrowser(m_pTraceStatsTab); m_pTraceStatsTabText->setObjectName(QStringLiteral("m_pTraceStatsTabText")); m_pTraceStatsTabText->setLineWrapMode(QTextEdit::NoWrap); m_pTraceStatsTabLayout->addWidget(m_pTraceStatsTabText, 0, 0, 1, 1); QFont font("monospace", 10); m_pTraceStatsTabText->setFont(font); ui->outputTextBrowser->setFont(font); // Hide unused, default tab ui->stateTabWidget->removeTab(0); memset(&m_traceFileInfo, 0, sizeof(vktraceviewer_trace_file_info)); m_settingsDialog.resize(g_settings.settings_dialog_width, g_settings.settings_dialog_height); connect(&m_settingsDialog, SIGNAL(SaveSettings(vktrace_SettingGroup*, unsigned int)), this, SLOT(on_settingsSaved(vktrace_SettingGroup*, unsigned int))); connect(&m_settingsDialog, SIGNAL(Resized(unsigned int, unsigned int)), this, SLOT(on_settingsDialogResized(unsigned int, unsigned int))); this->move(g_settings.window_position_left, g_settings.window_position_top); this->resize(g_settings.window_size_width, g_settings.window_size_height); connect(ui->outputTextBrowser, SIGNAL(anchorClicked(const QUrl&)), this, SLOT(on_hyperlinkClicked(const QUrl&))); // setup Output Window vktraceviewer_output_init(ui->outputTextBrowser); vktrace_LogSetCallback(loggingCallback); vktrace_LogSetLevel(VKTRACE_LOG_ERROR); vktrace_LogAlways("Welcome to VkTraceViewer!"); // cache the original background color of the search text box m_searchTextboxBackgroundColor = ui->searchTextBox->palette().base().color(); // add buttons to toolbar m_pGenerateTraceButton = new QToolButton(ui->mainToolBar); m_pGenerateTraceButton->setText("Generate Trace..."); m_pGenerateTraceButton->setEnabled(true); connect(m_pGenerateTraceButton, SIGNAL(clicked()), this, SLOT(prompt_generate_trace())); ui->mainToolBar->addWidget(m_pGenerateTraceButton); ui->treeView->setModel(NULL); ui->treeView->setContextMenuPolicy(Qt::ActionsContextMenu); ui->treeView->setUniformRowHeights(true); // setup timeline m_pTimeline = new vktraceviewer_QTimelineView(); if (m_pTimeline != NULL) { m_pTimeline->setMinimumHeight(100); connect(m_pTimeline, SIGNAL(clicked(const QModelIndex &)), this, SLOT(slot_timeline_clicked(const QModelIndex &))); ui->timelineLayout->addWidget(m_pTimeline); ui->timelineLayout->removeWidget(ui->timelineViewPlaceholder); delete ui->timelineViewPlaceholder; ui->timelineViewPlaceholder = NULL; }
void vktraceviewer::onTraceFileLoaded(bool bSuccess, vktraceviewer_trace_file_info fileInfo, const QString& controllerFilename) { QApplication::restoreOverrideCursor(); if (fileInfo.packetCount == 0) { LogWarning("The trace file has 0 packets."); } else if (fileInfo.pPacketOffsets == NULL) { LogError("No packet offsets read from trace file."); bSuccess = false; } if (!bSuccess) { LogAlways("...FAILED!"); QMessageBox::critical(this, tr("Error"), tr("Could not open trace file.")); close_trace_file(); if (m_bGeneratingTrace) { // if the user was generating a trace file, but the trace failed to load, // then re-spawn the generate trace dialog. prompt_generate_trace(); } } else { m_traceFileInfo = fileInfo; setWindowTitle(QString(m_traceFileInfo.filename) + " - " + g_PROJECT_NAME); LogAlways("...success!"); // update settings to reflect the currently open file g_settings.trace_file_to_open = vktrace_allocate_and_copy(m_traceFileInfo.filename); vktraceviewer_settings_updated(); #ifndef USE_STATIC_CONTROLLER_LIBRARY if (!controllerFilename.isEmpty()) { m_pController = m_controllerFactory.Load(controllerFilename.toStdString().c_str()); } #else m_pController = vtvCreateQController(); #endif if (m_pController != NULL) { connect(m_pController, SIGNAL(OutputMessage(VktraceLogLevel, const QString&)), this, SLOT(OnOutputMessage(VktraceLogLevel, const QString&))); connect(m_pController, SIGNAL(OutputMessage(VktraceLogLevel, uint64_t, const QString&)), this, SLOT(OnOutputMessage(VktraceLogLevel, uint64_t, const QString&))); // Merge in settings from the controller. // This won't replace settings that may have already been loaded from disk. vktrace_SettingGroup_merge(m_pController->GetSettings(), &g_pAllSettings, &g_numAllSettings); // now update the controller with the loaded settings m_pController->UpdateFromSettings(g_pAllSettings, g_numAllSettings); //// trace file was loaded, now attempt to open additional session data //if (load_or_create_session(filename.c_str(), m_pTraceReader) == false) //{ // // failing to load session data is not critical, but may result in unexpected behavior at times. // vktraceviewer_output_error("VkTraceViewer was unable to create a session folder to save viewing information. Functionality may be limited."); //} // Update the UI with the controller m_pController->LoadTraceFile(&m_traceFileInfo, this); } // update toolbar ui->searchTextBox->setEnabled(true); ui->searchPrevButton->setEnabled(true); ui->searchNextButton->setEnabled(true); ui->action_Close->setEnabled(true); ui->actionExport_API_Calls->setEnabled(true); ui->prevDrawcallButton->setEnabled(true); ui->nextDrawcallButton->setEnabled(true); // reset flag indicating that the ui may have been generating a trace file. m_bGeneratingTrace = false; GenerateTraceFileStats(); }