nextcloud-desktop/src/gui/application.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

177 lines
4.4 KiB
C
Raw Normal View History

2011-04-06 13:48:02 +04:00
/*
* Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
2011-02-17 02:21:45 +03:00
#ifndef APPLICATION_H
#define APPLICATION_H
#include <QApplication>
#include <QPointer>
#include <QQueue>
#include <QTimer>
#include <QElapsedTimer>
#include <QNetworkConfigurationManager>
2011-02-17 02:21:45 +03:00
#include "qtsingleapplication.h"
#include "syncresult.h"
#include "logbrowser.h"
#include "owncloudgui.h"
#include "connectionvalidator.h"
#include "progressdispatcher.h"
#include "clientproxy.h"
#include "folderman.h"
class QMessageBox;
2011-02-17 02:21:45 +03:00
class QSystemTrayIcon;
class QSocket;
2011-02-17 02:21:45 +03:00
namespace CrashReporter {
class Handler;
}
2014-11-10 00:34:07 +03:00
namespace OCC {
Q_DECLARE_LOGGING_CATEGORY(lcApplication)
class Theme;
class Folder;
class ShellExtensionsServer;
class SslErrorDialog;
2011-02-17 02:21:45 +03:00
#ifdef Q_OS_MACOS
namespace Mac {
class FileProvider;
}
#endif
2015-06-29 19:56:09 +03:00
/**
* @brief The Application class
* @ingroup gui
*/
class Application : public SharedTools::QtSingleApplication
2011-02-17 02:21:45 +03:00
{
Q_OBJECT
public:
2012-04-20 15:17:48 +04:00
explicit Application(int &argc, char **argv);
~Application() override;
2012-06-15 15:36:38 +04:00
bool giveHelp();
void showHelp();
void showHint(std::string errorHint);
bool debugMode();
[[nodiscard]] bool backgroundMode() const;
bool versionOnly(); // only display the version?
void showVersion();
2012-06-15 15:36:38 +04:00
void showMainDialog();
[[nodiscard]] ownCloudGui *gui() const;
bool event(QEvent *event) override;
public slots:
// TODO: this should not be public
2012-11-28 22:25:12 +04:00
void slotownCloudWizardDone(int);
void slotCrash();
/**
* Will download a virtual file, and open the result.
* The argument is the filename of the virtual file (including the extension)
*/
void openVirtualFile(const QString &filename);
2011-02-17 02:21:45 +03:00
/// Attempt to show() the tray icon again. Used if no systray was available initially.
void tryTrayAgain();
protected:
void parseOptions(const QStringList &);
void setupTranslations();
void setupLogging();
2011-02-17 02:21:45 +03:00
// Attempt to setup new settings or restore legacy settings
// The settings include the accounts and folders saved in the config file
void setupOrRestoreSettings();
signals:
void folderRemoved();
void folderStateChanged(OCC::Folder *);
void isShowingSettingsDialog();
2011-09-26 17:00:12 +04:00
protected slots:
void slotParseMessage(const QString &, QObject *);
void slotCheckConnection();
void slotUseMonoIconsChanged(bool);
void slotCleanup();
void slotAccountStateAdded(OCC::AccountState *accountState);
void slotAccountStateRemoved(OCC::AccountState *accountState);
void slotSystemOnlineConfigurationChanged(QNetworkConfiguration);
void slotGuiIsShowingSettings();
2011-02-17 02:21:45 +03:00
private:
void setHelp();
2012-06-15 15:36:38 +04:00
void handleEditLocallyFromOptions();
AccountManager::AccountsRestoreResult restoreLegacyAccount();
void createConfigFile();
/**
* Maybe a newer version of the client was used with this config file:
* if so, backup, confirm with user and remove the config that can't be read.
*/
bool configVersionMigration();
QPointer<ownCloudGui> _gui;
2011-04-04 14:23:30 +04:00
Theme *_theme;
bool _helpOnly = false;
bool _versionOnly = false;
QElapsedTimer _startedAt;
// options from command line:
bool _showLogWindow = false;
bool _quitInstance = false;
QString _logFile;
QString _logDir;
int _logExpire = 0;
bool _logFlush = false;
bool _logDebug = false;
bool _userTriggeredConnect = false;
bool _debugMode = false;
bool _backgroundMode = false;
QUrl _editFileLocallyUrl;
ClientProxy _proxy;
QNetworkConfigurationManager _networkConfigurationManager;
QTimer _checkConnectionTimer;
QString _overrideServerUrl;
QString _overrideLocalDir;
#if defined(WITH_CRASHREPORTER)
QScopedPointer<CrashReporter::Handler> _crashHandler;
#endif
QScopedPointer<FolderMan> _folderManager;
#if defined(Q_OS_WIN)
QScopedPointer<ShellExtensionsServer> _shellExtensionsServer;
#elif defined(Q_OS_MACOS)
QScopedPointer<Mac::FileProvider> _fileProvider;
#endif
2011-02-17 02:21:45 +03:00
};
2014-11-10 00:34:07 +03:00
} // namespace OCC
2011-02-17 02:21:45 +03:00
#endif // APPLICATION_H