Akonadi

controlgui.h
1/*
2 SPDX-FileCopyrightText: 2007 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "akonadiwidgets_export.h"
10
11#include <QObject>
12
13#include <memory>
14
15namespace Akonadi
16{
17class ControlGuiPrivate;
18
19/**
20 * @short Provides methods to ControlGui the Akonadi server process.
21 *
22 * This class provides synchronous methods (ie. use a sub-eventloop)
23 * to ControlGui the Akonadi service. For asynchronous methods see
24 * Akonadi::ServerManager.
25 *
26 * The most important method in here is widgetNeedsAkonadi(). It is
27 * recommended to call it with every top-level widget of your application
28 * as argument, assuming your application relies on Akonadi being operational
29 * of course.
30 *
31 * While the Akonadi server automatically started by Akonadi::Session
32 * on first use, it might be necessary for some use-cases to guarantee
33 * a running Akonadi service at some point. This can be done using
34 * start().
35 *
36 * Example:
37 *
38 * @code
39 *
40 * if ( !Akonadi::ControlGui::start() ) {
41 * qDebug() << "Unable to start Akonadi server, exit application";
42 * return 1;
43 * } else {
44 * ...
45 * }
46 *
47 * @endcode
48 *
49 * @author Volker Krause <vkrause@kde.org>
50 *
51 * @see Akonadi::ServerManager
52 */
53class AKONADIWIDGETS_EXPORT ControlGui : public QObject
54{
55 Q_OBJECT
56
57public:
58 /**
59 * Destroys the ControlGui object.
60 */
61 ~ControlGui() override;
62
63 /**
64 * Starts the Akonadi server synchronously if it is not already running.
65 * @return @c true if the server was started successfully or was already
66 * running, @c false otherwise
67 */
68 static bool start();
69
70 /**
71 * Same as start(), but with GUI feedback.
72 * @param parent The parent widget.
73 * @since 4.2
74 */
75 static bool start(QWidget *parent);
76
77 /**
78 * Stops the Akonadi server synchronously if it is currently running.
79 * @return @c true if the server was shutdown successfully or was
80 * not running at all, @c false otherwise.
81 * @since 4.2
82 */
83 static bool stop();
84
85 /**
86 * Same as stop(), but with GUI feedback.
87 * @param parent The parent widget.
88 * @since 4.2
89 */
90 static bool stop(QWidget *parent);
91
92 /**
93 * Restarts the Akonadi server synchronously.
94 * @return @c true if the restart was successful, @c false otherwise,
95 * the server state is undefined in this case.
96 * @since 4.2
97 */
98 static bool restart();
99
100 /**
101 * Same as restart(), but with GUI feedback.
102 * @param parent The parent widget.
103 * @since 4.2
104 */
105 static bool restart(QWidget *parent);
106
107 /**
108 * Disable the given widget when Akonadi is not operational and show
109 * an error overlay (given enough space). Cascading use is automatically
110 * detected and resolved.
111 * @param widget The widget depending on Akonadi being operational.
112 * @since 4.2
113 */
114 static void widgetNeedsAkonadi(QWidget *widget);
115
116protected:
117 /**
118 * Creates the ControlGui object.
119 */
120 ControlGui();
121
122private:
123 /// @cond PRIVATE
124 std::unique_ptr<ControlGuiPrivate> const d;
125 /// @endcond
126};
127
128}
Provides methods to ControlGui the Akonadi server process.
Definition controlgui.h:54
~ControlGui() override
Destroys the ControlGui object.
void stop(Ekos::AlignState mode)
Q_SCRIPTABLE Q_NOREPLY void start()
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 13 2024 11:54:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.