akonadi
21 #include "servermanager.h"
22 #include "ui_controlprogressindicator.h"
23 #include "selftestdialog_p.h"
24 #include "erroroverlay_p.h"
28 #include <klocalizedstring.h>
30 #include <QtCore/QEventLoop>
31 #include <QtCore/QCoreApplication>
32 #include <QtCore/QTimer>
33 #include <QtCore/QPointer>
41 class ControlProgressIndicator :
public QFrame
44 ControlProgressIndicator(QWidget *parent = 0)
47 setWindowModality(Qt::ApplicationModal);
49 setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
52 setFrameShadow(QFrame::Plain);
53 setFrameShape(QFrame::Box);
56 void setMessage(
const QString &msg)
58 ui.statusLabel->setText(msg);
61 Ui::ControlProgressIndicator ui;
64 class StaticControl :
public Control
75 K_GLOBAL_STATIC(Internal::StaticControl, s_instance)
80 class Control::Private
86 , mProgressIndicator(0)
95 delete mProgressIndicator;
98 void setupProgressIndicator(
const QString &msg, QWidget *parent = 0)
100 if (!mProgressIndicator) {
101 mProgressIndicator =
new Internal::ControlProgressIndicator(parent);
104 mProgressIndicator->setMessage(msg);
107 void createErrorOverlays()
109 foreach (QWidget *widget, mPendingOverlays) {
114 mPendingOverlays.clear();
119 s_instance.destroy();
125 QPointer<Control> mParent;
126 QEventLoop *mEventLoop;
127 QPointer<Internal::ControlProgressIndicator> mProgressIndicator;
128 QList<QPointer<QWidget> > mPendingOverlays;
135 bool Control::Private::exec()
137 if (mProgressIndicator) {
138 mProgressIndicator->show();
141 kDebug() <<
"Starting/Stopping Akonadi (using an event loop).";
142 mEventLoop =
new QEventLoop(mParent);
144 mEventLoop->deleteLater();
148 kWarning() <<
"Could not start/stop Akonadi!";
149 if (mProgressIndicator && mStarting) {
150 QPointer<SelfTestDialog> dlg =
new SelfTestDialog(mProgressIndicator->parentWidget());
159 delete mProgressIndicator;
160 mProgressIndicator = 0;
164 const bool rv = mSuccess;
172 if (mEventLoop && mEventLoop->isRunning()) {
183 : d(new Private(this))
189 if (QCoreApplication::instance()) {
190 connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()),
this, SLOT(cleanup()));
202 kDebug() <<
"Server is currently being stopped, wont try to start it now";
206 kDebug() <<
"Server is already running";
209 s_instance->d->mStarting =
true;
211 kDebug() <<
"ServerManager::start failed -> return false";
214 return s_instance->d->exec();
225 s_instance->d->mStopping =
true;
229 return s_instance->d->exec();
244 s_instance->d->setupProgressIndicator(i18n(
"Starting Akonadi server..."), parent);
250 s_instance->d->setupProgressIndicator(i18n(
"Stopping Akonadi server..."), parent);
261 return start(parent);
266 s_instance->d->mPendingOverlays.append(widget);
269 QTimer::singleShot(0, s_instance, SLOT(createErrorOverlays()));
274 #include "moc_control.cpp"
static bool start()
Starts the server.
static State state()
Returns the state of the server.
static bool stop()
Stops the server.
@ Upgrading
Server is performing a database upgrade as part of a new startup.
@ Starting
Server was started but is not yet running.
~Control()
Destroys the control object.
static ServerManager * self()
Returns the singleton instance of this class, for connecting to its signals.
A dialog that checks the current status of the Akonadi system.
static bool stop()
Stops the Akonadi server synchronously if it is currently running.
@ Running
Server is running and operational.
static bool restart()
Restarts the Akonadi server synchronously.
@ NotRunning
Server is not running, could be no one started it yet or it failed to start.
static bool isRunning()
Checks if the server is available currently.
static void widgetNeedsAkonadi(QWidget *widget)
Disable the given widget when Akonadi is not operational and show an error overlay (given enough spac...
Provides methods to control the Akonadi server process.
State
Enum for the various states the server can be in.
Control()
Creates the control object.
static bool start()
Starts the Akonadi server synchronously if it is not already running.
@ Stopping
Server is shutting down.
FreeBusyManager::Singleton.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Jul 28 2020 00:00:00 by
doxygen 1.8.18 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.