mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 08:22:15 -07:00
create and connect signal
This commit is contained in:
parent
e9f8f4ef20
commit
09ef1b4aef
5 changed files with 34 additions and 0 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include "../../client/game_logic/abstract_client.h"
|
||||
#include "../../client/tapped_out_interface.h"
|
||||
#include "../../client/ui/widgets/cards/card_info_frame_widget.h"
|
||||
#include "../../deck/deck_edit_event_bus.h"
|
||||
#include "../../deck/deck_stats_interface.h"
|
||||
#include "../../dialogs/dlg_load_deck.h"
|
||||
#include "../../dialogs/dlg_load_deck_from_clipboard.h"
|
||||
|
|
@ -745,6 +746,8 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor) : Tab(_tabSupervisor
|
|||
connect(&SettingsCache::instance().shortcuts(), SIGNAL(shortCutChanged()), this, SLOT(refreshShortcuts()));
|
||||
refreshShortcuts();
|
||||
|
||||
connect(this, &TabDeckEditor::deckSaved, DeckEditEventBus::instance(), &DeckEditEventBus::deckModified);
|
||||
|
||||
loadLayout();
|
||||
}
|
||||
|
||||
|
|
@ -1136,6 +1139,8 @@ bool TabDeckEditor::actSaveDeck()
|
|||
return actSaveDeckAs();
|
||||
else if (deck->saveToFile(deck->getLastFileName(), deck->getLastFileFormat())) {
|
||||
setModified(false);
|
||||
|
||||
emit deckSaved(deck->getLastFileName());
|
||||
return true;
|
||||
}
|
||||
QMessageBox::critical(
|
||||
|
|
@ -1168,6 +1173,7 @@ bool TabDeckEditor::actSaveDeckAs()
|
|||
|
||||
SettingsCache::instance().recents().updateRecentlyOpenedDeckPaths(fileName);
|
||||
|
||||
emit deckSaved(fileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -189,6 +189,7 @@ public slots:
|
|||
signals:
|
||||
void openDeckEditor(const DeckLoader *deckLoader);
|
||||
void deckEditorClosing(TabDeckEditor *tab);
|
||||
void deckSaved(const QString &filePath);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "visual_deck_storage_widget.h"
|
||||
|
||||
#include "../../../../deck/deck_edit_event_bus.h"
|
||||
#include "../../../../game/cards/card_database_manager.h"
|
||||
#include "../../../../settings/cache_settings.h"
|
||||
#include "../quick_settings/settings_button_widget.h"
|
||||
|
|
@ -110,6 +111,9 @@ VisualDeckStorageWidget::VisualDeckStorageWidget(QWidget *parent) : QWidget(pare
|
|||
|
||||
retranslateUi();
|
||||
|
||||
connect(DeckEditEventBus::instance(), &DeckEditEventBus::deckModified, this,
|
||||
&VisualDeckStorageWidget::handleDeckModified);
|
||||
|
||||
// Don't waste time processing the cards if they're going to get refreshed anyway once the db finishes loading
|
||||
if (CardDatabaseManager::getInstance()->getLoadStatus() == LoadStatus::Ok) {
|
||||
createRootFolderWidget();
|
||||
|
|
@ -218,3 +222,18 @@ void VisualDeckStorageWidget::updateTagsVisibility(const bool visible)
|
|||
tagFilterWidget->setHidden(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the scenario where a deck file has been modified. Updates the visual deck storage to reflect the change.
|
||||
*
|
||||
* @param filePath filepath to the changed deck
|
||||
*/
|
||||
void VisualDeckStorageWidget::handleDeckModified(const QString &filePath)
|
||||
{
|
||||
// ignore if file isn't in deck folder
|
||||
if (!filePath.startsWith(SettingsCache::instance().getDeckPath())) {
|
||||
return;
|
||||
}
|
||||
|
||||
refreshIfPossible();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ public slots:
|
|||
void updateSearchFilter();
|
||||
void updateTagsVisibility(bool visible);
|
||||
void updateSortOrder();
|
||||
void handleDeckModified(const QString &filePath);
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void showEvent(QShowEvent *event) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,13 @@ private:
|
|||
|
||||
public:
|
||||
static DeckEditEventBus *instance();
|
||||
|
||||
signals:
|
||||
/**
|
||||
* Should be emitted when a change has been written to a deck file.
|
||||
* @param filePath Absolute path to the deck file
|
||||
*/
|
||||
void deckModified(const QString &filePath);
|
||||
};
|
||||
|
||||
#endif // DECK_EDIT_EVENT_BUS_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue