LibrePCB Developers Documentation
Loading...
Searching...
No Matches
dismissablemessagecontext.h
Go to the documentation of this file.
1/*
2 * LibrePCB - Professional EDA for everyone!
3 * Copyright (C) 2013 LibrePCB Developers, see AUTHORS.md for contributors.
4 * https://librepcb.org/
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef LIBREPCB_EDITOR_DISMISSABLEMESSAGECONTEXT_H
21#define LIBREPCB_EDITOR_DISMISSABLEMESSAGECONTEXT_H
22
23/*******************************************************************************
24 * Includes
25 ******************************************************************************/
26#include "appwindow.h"
27
28#include <QtCore>
29
30/*******************************************************************************
31 * Namespace / Forward Declarations
32 ******************************************************************************/
33namespace librepcb {
34
35class Workspace;
36
37namespace editor {
38
39/*******************************************************************************
40 * Class DismissableMessageContext
41 ******************************************************************************/
42
53class DismissableMessageContext final : public QObject {
54 Q_OBJECT
55
56public:
65 explicit DismissableMessageContext(bool active = false,
66 QObject* parent = nullptr) noexcept;
67
79 explicit DismissableMessageContext(Workspace& workspace,
80 const QString& dismissKey,
81 bool active = false,
82 QObject* parent = nullptr) noexcept;
85
91 ui::DismissableMessageData getUiData() const noexcept;
92
98 void setUiData(const ui::DismissableMessageData& data) noexcept;
99
108 void setActive(bool active) noexcept;
109
113 void dismiss() noexcept;
114
118 void dontShowAgain() noexcept;
119
126 bool isVisible() const noexcept { return mVisible; }
127
128 // Operator Overloadings
130 delete;
131
132signals:
133 void visibilityChanged(bool visible);
134
135private: // Methods
136 void trigger(ui::DismissableMessageAction a) noexcept;
138 void updateVisibility() noexcept;
139
140private: // Data
141 const QPointer<Workspace> mWorkspace;
142 const QString mDismissKey;
146};
147
148/*******************************************************************************
149 * End of File
150 ******************************************************************************/
151
152} // namespace editor
153} // namespace librepcb
154
155#endif
The Workspace class represents a workspace with all its data (library, projects, settings,...
Definition workspace.h:54
A handle to a optionally dismissable message in the UI.
Definition dismissablemessagecontext.h:53
DismissableMessageContext(const DismissableMessageContext &other)=delete
bool mVisible
Definition dismissablemessagecontext.h:145
void setUiData(const ui::DismissableMessageData &data) noexcept
Set UI data.
Definition dismissablemessagecontext.cpp:83
void setActive(bool active) noexcept
Set whether the message should be shown (if not dismissed) or not.
Definition dismissablemessagecontext.cpp:93
~DismissableMessageContext() noexcept
Definition dismissablemessagecontext.cpp:67
const QPointer< Workspace > mWorkspace
Definition dismissablemessagecontext.h:141
void dontShowAgain() noexcept
Dismiss (hide) the message persistently.
Definition dismissablemessagecontext.cpp:108
const QString mDismissKey
Definition dismissablemessagecontext.h:142
DismissableMessageContext & operator=(const DismissableMessageContext &rhs)=delete
bool mActive
Definition dismissablemessagecontext.h:143
ui::DismissableMessageData getUiData() const noexcept
Get UI data.
Definition dismissablemessagecontext.cpp:74
void dismiss() noexcept
Dismiss (hide) the message temporarily.
Definition dismissablemessagecontext.cpp:101
bool mTemporarilyHidden
Definition dismissablemessagecontext.h:144
void updateVisibility() noexcept
Definition dismissablemessagecontext.cpp:144
void trigger(ui::DismissableMessageAction a) noexcept
Definition dismissablemessagecontext.cpp:125
bool isVisible() const noexcept
Get whether the message shall currently be visible or not.
Definition dismissablemessagecontext.h:126
Definition occmodel.cpp:77