From 3869eaaf2bfacf4a44733b8346d790999588c37f Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Fri, 25 Dec 2015 21:57:23 +0000 Subject: Transferring the savegame widget into gamebryo + some cleanup --- src/mainwindow.cpp | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) (limited to 'src/mainwindow.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8f71f636..0a690a8e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -29,6 +29,7 @@ along with Mod Organizer. If not, see . #include "iplugingame.h" #include "iplugindiagnose.h" #include "isavegame.h" +#include "isavegameinfowidget.h" #include "nexusinterface.h" #include "organizercore.h" #include "pluginlistsortproxy.h" @@ -864,33 +865,25 @@ void MainWindow::setBrowserGeometry(const QByteArray &geometry) m_IntegratedBrowser.restoreGeometry(geometry); } -ISaveGame const *MainWindow::getSaveGame(QListWidgetItem *item) +void MainWindow::displaySaveGameInfo(QListWidgetItem *newItem) { - try { + QString const &save = newItem->data(Qt::UserRole).toString(); + if (m_CurrentSaveView == nullptr) { + //FIXME Is this the right place? IPluginGame const *game = m_OrganizerCore.managedGame(); SaveGameInfo const *info = game->feature(); if (info != nullptr) { - return info->getSaveGameInfo(item->data(Qt::UserRole).toString()); + m_CurrentSaveView = info->getSaveGameWidget(this); + } + if (m_CurrentSaveView == nullptr) { + return; } - //SaveGameGamebryo *saveGame = new SaveGameGamebryo(/*this,*/ item->data(Qt::UserRole).toString(), game); - //saveGame->setParent(item->listWidget()); - //return saveGame; - } catch (const std::exception &e) { - reportError(tr("failed to read savegame: %1").arg(e.what())); - } - return nullptr; -} - -void MainWindow::displaySaveGameInfo(MOBase::ISaveGame const *save, QPoint pos) -{ - if (m_CurrentSaveView == nullptr) { - m_CurrentSaveView = new SaveGameInfoWidgetGamebryo(save, m_OrganizerCore.pluginList(), this); - } else { - m_CurrentSaveView->setSave(save); } + m_CurrentSaveView->setSave(save); QRect screenRect = QApplication::desktop()->availableGeometry(m_CurrentSaveView); + QPoint pos = QCursor::pos(); if (pos.x() + m_CurrentSaveView->width() > screenRect.right()) { pos.rx() -= (m_CurrentSaveView->width() + 2); } else { @@ -905,8 +898,9 @@ void MainWindow::displaySaveGameInfo(MOBase::ISaveGame const *save, QPoint pos) m_CurrentSaveView->move(pos); m_CurrentSaveView->show(); + m_CurrentSaveView->setProperty("displayItem", qVariantFromValue(static_cast(newItem))); + ui->savegameList->activateWindow(); - connect(m_CurrentSaveView, SIGNAL(closeSaveInfo()), this, SLOT(hideSaveGameInfo())); } @@ -915,20 +909,14 @@ void MainWindow::saveSelectionChanged(QListWidgetItem *newItem) if (newItem == nullptr) { hideSaveGameInfo(); } else if (m_CurrentSaveView == nullptr || newItem != m_CurrentSaveView->property("displayItem").value()) { - MOBase::ISaveGame const *save = getSaveGame(newItem); - if (save != nullptr) { - displaySaveGameInfo(save, QCursor::pos()); - m_CurrentSaveView->setProperty("displayItem", qVariantFromValue(static_cast(newItem))); - } + displaySaveGameInfo(newItem); } } - void MainWindow::hideSaveGameInfo() { if (m_CurrentSaveView != nullptr) { - disconnect(m_CurrentSaveView, SIGNAL(closeSaveInfo()), this, SLOT(hideSaveGameInfo())); m_CurrentSaveView->deleteLater(); m_CurrentSaveView = nullptr; } -- cgit v1.3.1