mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Merge pull request #2514 from nextcloud/make_it_easier_for_user_to_provide_debug_information
Make it easier for user to provide debug information
This commit is contained in:
commit
211dbadd1a
@ -314,7 +314,7 @@ set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
|
||||
set_target_properties( ${APPLICATION_EXECUTABLE} PROPERTIES
|
||||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/${APPLICATION_EXECUTABLE};${CMAKE_INSTALL_RPATH}" )
|
||||
|
||||
target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::Widgets Qt5::Svg Qt5::Network Qt5::Xml Qt5::Qml Qt5::Quick Qt5::QuickControls2 Qt5::WebEngineWidgets)
|
||||
target_link_libraries( ${APPLICATION_EXECUTABLE} Qt5::Widgets Qt5::GuiPrivate Qt5::Svg Qt5::Network Qt5::Xml Qt5::Qml Qt5::Quick Qt5::QuickControls2 Qt5::WebEngineWidgets)
|
||||
target_link_libraries( ${APPLICATION_EXECUTABLE} ${synclib_NAME} )
|
||||
IF(BUILD_UPDATER)
|
||||
target_link_libraries( ${APPLICATION_EXECUTABLE} updater )
|
||||
|
||||
@ -408,7 +408,9 @@ void Application::setupLogging()
|
||||
// might be called from second instance
|
||||
auto logger = Logger::instance();
|
||||
logger->setLogFile(_logFile);
|
||||
logger->setLogDir(!_logDir.isEmpty() ? _logDir : ConfigFile().logDir());
|
||||
if (_logFile.isEmpty()) {
|
||||
logger->setLogDir(_logDir.isEmpty() ? ConfigFile().logDir() : _logDir);
|
||||
}
|
||||
logger->setLogExpire(_logExpire > 0 ? _logExpire : ConfigFile().logExpire());
|
||||
logger->setLogFlush(_logFlush || ConfigFile().logFlush());
|
||||
logger->setLogDebug(_logDebug || ConfigFile().logDebug());
|
||||
|
||||
@ -30,21 +30,107 @@
|
||||
|
||||
#include "ignorelisteditor.h"
|
||||
#include "common/utility.h"
|
||||
#include "logger.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "legalnotice.h"
|
||||
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkProxy>
|
||||
#include <QDir>
|
||||
#include <QScopedValueRollback>
|
||||
|
||||
#include <private/qzipwriter_p.h>
|
||||
|
||||
#define QTLEGACY (QT_VERSION < QT_VERSION_CHECK(5,9,0))
|
||||
|
||||
#if !(QTLEGACY)
|
||||
#include <QOperatingSystemVersion>
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
struct ZipEntry {
|
||||
QString localFilename;
|
||||
QString zipFilename;
|
||||
};
|
||||
|
||||
ZipEntry fileInfoToZipEntry(const QFileInfo &info)
|
||||
{
|
||||
return {
|
||||
info.absoluteFilePath(),
|
||||
info.fileName()
|
||||
};
|
||||
}
|
||||
|
||||
ZipEntry fileInfoToLogZipEntry(const QFileInfo &info)
|
||||
{
|
||||
auto entry = fileInfoToZipEntry(info);
|
||||
entry.zipFilename.prepend(QStringLiteral("logs/"));
|
||||
return entry;
|
||||
}
|
||||
|
||||
ZipEntry syncFolderToZipEntry(OCC::Folder *f)
|
||||
{
|
||||
const auto journalPath = f->journalDb()->databaseFilePath();
|
||||
const auto journalInfo = QFileInfo(journalPath);
|
||||
return fileInfoToZipEntry(journalInfo);
|
||||
}
|
||||
|
||||
QVector<ZipEntry> createFileList()
|
||||
{
|
||||
auto list = QVector<ZipEntry>();
|
||||
OCC::ConfigFile cfg;
|
||||
|
||||
list.append(fileInfoToZipEntry(QFileInfo(cfg.configFile())));
|
||||
|
||||
const auto logger = OCC::Logger::instance();
|
||||
|
||||
if (!logger->logDir().isEmpty()) {
|
||||
list.append({QString(), QStringLiteral("logs")});
|
||||
|
||||
QDir dir(logger->logDir());
|
||||
const auto infoList = dir.entryInfoList(QDir::Files);
|
||||
std::transform(std::cbegin(infoList), std::cend(infoList),
|
||||
std::back_inserter(list),
|
||||
fileInfoToLogZipEntry);
|
||||
} else if (!logger->logFile().isEmpty()) {
|
||||
list.append(fileInfoToZipEntry(QFileInfo(logger->logFile())));
|
||||
}
|
||||
|
||||
const auto folders = OCC::FolderMan::instance()->map().values();
|
||||
std::transform(std::cbegin(folders), std::cend(folders),
|
||||
std::back_inserter(list),
|
||||
syncFolderToZipEntry);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void createDebugArchive(const QString &filename)
|
||||
{
|
||||
const auto entries = createFileList();
|
||||
|
||||
QZipWriter zip(filename);
|
||||
for (const auto &entry : entries) {
|
||||
if (entry.localFilename.isEmpty()) {
|
||||
zip.addDirectory(entry.zipFilename);
|
||||
} else {
|
||||
QFile file(entry.localFilename);
|
||||
if (!file.open(QFile::ReadOnly)) {
|
||||
continue;
|
||||
}
|
||||
zip.addFile(entry.zipFilename, &file);
|
||||
}
|
||||
}
|
||||
|
||||
zip.addFile("__nextcloud_client_parameters.txt", QCoreApplication::arguments().join(' ').toUtf8());
|
||||
|
||||
const auto buildInfo = QString(OCC::Theme::instance()->about() + "\n\n" + OCC::Theme::instance()->aboutDetails());
|
||||
zip.addFile("__nextcloud_client_buildinfo.txt", buildInfo.toUtf8());
|
||||
}
|
||||
}
|
||||
|
||||
namespace OCC {
|
||||
|
||||
GeneralSettings::GeneralSettings(QWidget *parent)
|
||||
@ -122,6 +208,7 @@ GeneralSettings::GeneralSettings(QWidget *parent)
|
||||
_ui->monoIconsCheckBox->setVisible(Theme::instance()->monoIconsAvailable());
|
||||
|
||||
connect(_ui->ignoredFilesButton, &QAbstractButton::clicked, this, &GeneralSettings::slotIgnoreFilesEditor);
|
||||
connect(_ui->debugArchiveButton, &QAbstractButton::clicked, this, &GeneralSettings::slotCreateDebugArchive);
|
||||
|
||||
// accountAdded means the wizard was finished and the wizard might change some options.
|
||||
connect(AccountManager::instance(), &AccountManager::accountAdded, this, &GeneralSettings::loadMiscSettings);
|
||||
@ -260,6 +347,17 @@ void GeneralSettings::slotIgnoreFilesEditor()
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralSettings::slotCreateDebugArchive()
|
||||
{
|
||||
const auto filename = QFileDialog::getSaveFileName(this, tr("Create Debug Archive"), QString(), tr("Zip Archives") + " (*.zip)");
|
||||
if (filename.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
createDebugArchive(filename);
|
||||
QMessageBox::information(this, tr("Debug Archive Created"), tr("Debug archive is created at %1").arg(filename));
|
||||
}
|
||||
|
||||
void GeneralSettings::slotShowLegalNotice()
|
||||
{
|
||||
auto notice = new LegalNotice();
|
||||
|
||||
@ -48,6 +48,7 @@ private slots:
|
||||
void slotToggleOptionalServerNotifications(bool);
|
||||
void slotShowInExplorerNavigationPane(bool);
|
||||
void slotIgnoreFilesEditor();
|
||||
void slotCreateDebugArchive();
|
||||
void loadMiscSettings();
|
||||
void slotShowLegalNotice();
|
||||
#if defined(BUILD_UPDATER)
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>516</width>
|
||||
<height>523</height>
|
||||
<width>553</width>
|
||||
<height>558</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -219,6 +219,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="debugArchiveButton">
|
||||
<property name="text">
|
||||
<string>Create Debug Archive...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
|
||||
@ -901,8 +901,9 @@ void ConfigFile::setAutomaticLogDir(bool enabled)
|
||||
|
||||
QString ConfigFile::logDir() const
|
||||
{
|
||||
const auto defaultLogDir = QString(configPath() + QStringLiteral("/logs"));
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
return settings.value(QLatin1String(logDirC), QString()).toString();
|
||||
return settings.value(QLatin1String(logDirC), defaultLogDir).toString();
|
||||
}
|
||||
|
||||
void ConfigFile::setLogDir(const QString &dir)
|
||||
@ -914,7 +915,7 @@ void ConfigFile::setLogDir(const QString &dir)
|
||||
bool ConfigFile::logDebug() const
|
||||
{
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
return settings.value(QLatin1String(logDebugC), false).toBool();
|
||||
return settings.value(QLatin1String(logDebugC), true).toBool();
|
||||
}
|
||||
|
||||
void ConfigFile::setLogDebug(bool enabled)
|
||||
@ -926,7 +927,7 @@ void ConfigFile::setLogDebug(bool enabled)
|
||||
int ConfigFile::logExpire() const
|
||||
{
|
||||
QSettings settings(configFile(), QSettings::IniFormat);
|
||||
return settings.value(QLatin1String(logExpireC), 0).toBool();
|
||||
return settings.value(QLatin1String(logExpireC), 24).toBool();
|
||||
}
|
||||
|
||||
void ConfigFile::setLogExpire(int hours)
|
||||
|
||||
@ -167,6 +167,11 @@ void Logger::setLogWindowActivated(bool activated)
|
||||
_logWindowActivated = activated;
|
||||
}
|
||||
|
||||
QString Logger::logFile() const
|
||||
{
|
||||
return _logFile.fileName();
|
||||
}
|
||||
|
||||
void Logger::setLogFile(const QString &name)
|
||||
{
|
||||
QMutexLocker locker(&_mutex);
|
||||
@ -204,6 +209,11 @@ void Logger::setLogExpire(int expire)
|
||||
_logExpire = expire;
|
||||
}
|
||||
|
||||
QString Logger::logDir() const
|
||||
{
|
||||
return _logDirectory;
|
||||
}
|
||||
|
||||
void Logger::setLogDir(const QString &dir)
|
||||
{
|
||||
_logDirectory = dir;
|
||||
|
||||
@ -60,9 +60,15 @@ public:
|
||||
void postGuiMessage(const QString &title, const QString &message);
|
||||
|
||||
void setLogWindowActivated(bool activated);
|
||||
|
||||
QString logFile() const;
|
||||
void setLogFile(const QString &name);
|
||||
|
||||
void setLogExpire(int expire);
|
||||
|
||||
QString logDir() const;
|
||||
void setLogDir(const QString &dir);
|
||||
|
||||
void setLogFlush(bool flush);
|
||||
|
||||
bool logDebug() const { return _logDebug; }
|
||||
|
||||
Loading…
Reference in New Issue
Block a user