| 1 | // Aseprite |
|---|---|
| 2 | // Copyright (C) 2019 Igara Studio S.A. |
| 3 | // Copyright (C) 2001-2017 David Capello |
| 4 | // |
| 5 | // This program is distributed under the terms of |
| 6 | // the End-User License Agreement for Aseprite. |
| 7 | |
| 8 | #ifndef APP_UI_DATA_RECOVERY_VIEW_H_INCLUDED |
| 9 | #define APP_UI_DATA_RECOVERY_VIEW_H_INCLUDED |
| 10 | #pragma once |
| 11 | |
| 12 | #include "app/crash/raw_images_as.h" |
| 13 | #include "app/ui/drop_down_button.h" |
| 14 | #include "app/ui/tabs.h" |
| 15 | #include "app/ui/workspace_view.h" |
| 16 | #include "ui/box.h" |
| 17 | #include "ui/button.h" |
| 18 | #include "ui/listbox.h" |
| 19 | #include "ui/view.h" |
| 20 | |
| 21 | namespace app { |
| 22 | namespace crash { |
| 23 | class DataRecovery; |
| 24 | } |
| 25 | |
| 26 | class DataRecoveryView : public ui::VBox |
| 27 | , public TabView |
| 28 | , public WorkspaceView { |
| 29 | public: |
| 30 | DataRecoveryView(crash::DataRecovery* dataRecovery); |
| 31 | ~DataRecoveryView(); |
| 32 | |
| 33 | // Called after the "Refresh" button is pressed (onRefresh) and |
| 34 | // the crash::DataRecovery::SessionsListIsReady signal is received. |
| 35 | void refreshListNotification(); |
| 36 | |
| 37 | // TabView implementation |
| 38 | std::string getTabText() override; |
| 39 | TabIcon getTabIcon() override; |
| 40 | gfx::Color getTabColor() override; |
| 41 | |
| 42 | // WorkspaceView implementation |
| 43 | ui::Widget* getContentWidget() override { return this; } |
| 44 | void onWorkspaceViewSelected() override; |
| 45 | bool onCloseView(Workspace* workspace, bool quitting) override; |
| 46 | void onTabPopup(Workspace* workspace) override; |
| 47 | |
| 48 | // Triggered when the list is of crashed sessions is empty (or |
| 49 | // because the user deleted all sessions that crashed). |
| 50 | obs::signal<void()> Empty; |
| 51 | |
| 52 | private: |
| 53 | void clearList(); |
| 54 | void fillList(); |
| 55 | void fillListWith(const bool crashes); |
| 56 | void disableRefresh(); |
| 57 | bool someItemIsBusy(); |
| 58 | |
| 59 | void onOpen(); |
| 60 | void onOpenRaw(crash::RawImagesAs as); |
| 61 | void onOpenMenu(); |
| 62 | void onDelete(); |
| 63 | void onRefresh(); |
| 64 | void onChangeSelection(); |
| 65 | void onCheckIfWeCanEnableRefreshButton(); |
| 66 | void onShowFullPathPrefChange(); |
| 67 | bool thereAreCrashSessions() const; |
| 68 | |
| 69 | crash::DataRecovery* m_dataRecovery; |
| 70 | ui::View m_view; |
| 71 | ui::ListBox m_listBox; |
| 72 | DropDownButton m_openButton; |
| 73 | ui::Button m_deleteButton; |
| 74 | ui::Button m_refreshButton; |
| 75 | ui::Timer m_waitToEnableRefreshTimer; |
| 76 | |
| 77 | // Connection to to showFullPath.AfterChange signal to update the |
| 78 | // items text when the setting is changed. |
| 79 | obs::connection m_conn; |
| 80 | }; |
| 81 | |
| 82 | } // namespace app |
| 83 | |
| 84 | #endif |
| 85 |