Skip to content

Commit

Permalink
Fix some logic and remove redundant code.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Oct 20, 2023
1 parent a6dfac1 commit 772d8ae
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 44 deletions.
26 changes: 1 addition & 25 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
#include <QMessageBox>
#include <QPushButton>
#include <QApplication>
#include <QLabel>
#include <QLayout>

namespace {
#ifndef VERSION_C
Expand Down Expand Up @@ -1521,32 +1519,10 @@ void Folder::slotHydrationFailed(int errorCode, int statusCode, const QString &e
.arg(errorCode)
.arg(statusCode)
.arg(errorString);
_syncResult.appendErrorString(errorMessageDetails);

const auto errorMessageBox = new VfsDownloadErrorDialog(fileName, errorMessageDetails);

errorMessageBox->setAttribute(Qt::WA_DeleteOnClose);
errorMessageBox->setWindowTitle(Theme::instance()->appNameGUI());
errorMessageBox->setMinimumWidth(150);
errorMessageBox->setMinimumHeight(100);

// add label and hide it
const auto errorMessageDetailsLabel = new QLabel(errorMessageDetails);
errorMessageDetailsLabel->setWordWrap(true);
errorMessageBox->layout()->addWidget(errorMessageDetailsLabel);
errorMessageDetailsLabel->hide();

auto buttonsLayout = new QHBoxLayout;

// add button for showing label on click
const auto acceptButton = new QPushButton(tr("OK"));
const auto showErrorMessageDetailsButton = new QPushButton(tr("> More details"));

buttonsLayout->addWidget(showErrorMessageDetailsButton);
buttonsLayout->addWidget(acceptButton);
connect(showErrorMessageDetailsButton, &QPushButton::clicked, errorMessageDetailsLabel, &QPushButton::show);

errorMessageBox->layout()->addItem(buttonsLayout);

errorMessageBox->show();
errorMessageBox->activateWindow();
errorMessageBox->raise();
Expand Down
4 changes: 2 additions & 2 deletions src/gui/passwordinputdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>291</width>
<height>201</height>
<width>276</width>
<height>125</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down
11 changes: 6 additions & 5 deletions src/gui/vfsdownloaderrordialog.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*

Check notice on line 1 in src/gui/vfsdownloaderrordialog.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/vfsdownloaderrordialog.cpp

File src/gui/vfsdownloaderrordialog.cpp (lines 17, 21): Code does not conform to Custom style guidelines.
* Copyright (C) by Felix Weilbach <felix.weilbach@nextcloud.com>
* Copyright (C) 2023 by Oleksandr Zolotov <alex@nextcloud.com>
*
* 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
Expand All @@ -11,22 +11,23 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/

#include "vfsdownloaderrordialog.h"
#include "ui_vfsdownloaderrordialog.h"

namespace OCC {

VfsDownloadErrorDialog::VfsDownloadErrorDialog(const QString &fileName, const QString &errorMessage, QWidget *parent)
: QDialog(parent)
, _ui(new Ui::VfsDownloadErrorDialog) {
_ui->setupUi(this);
, _ui(new Ui::VfsDownloadErrorDialog)
{
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

_ui->setupUi(this);
_ui->descriptionLabel->setText(tr("Error downloading %1").arg(fileName));
_ui->explanationLabel->setText(tr("%1 could not be downloaded.").arg(fileName));
_ui->moreDetailsLabel->setText(errorMessage);
_ui->moreDetailsLabel->setVisible(false);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

connect(_ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
}

Expand Down
15 changes: 3 additions & 12 deletions src/gui/vfsdownloaderrordialog.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*

Check notice on line 1 in src/gui/vfsdownloaderrordialog.h

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/vfsdownloaderrordialog.h

File src/gui/vfsdownloaderrordialog.h (lines 18, 20): Code does not conform to Custom style guidelines.
* Copyright (C) by Felix Weilbach <felix.weilbach@nextcloud.com>
* Copyright (C) 2023 by Oleksandr Zolotov <alex@nextcloud.com>
*
* 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
Expand All @@ -11,20 +11,12 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/

#pragma once

#include <accountfwd.h>
#include <account.h>

#include <memory>

#include <QDialog>
#include <QScopedPointer>

namespace OCC {

class Folder;

namespace Ui {
class VfsDownloadErrorDialog;
}
Expand All @@ -35,10 +27,9 @@ class VfsDownloadErrorDialog : public QDialog

public:
explicit VfsDownloadErrorDialog(const QString &fileName, const QString &errorMessage, QWidget *parent = nullptr);

~VfsDownloadErrorDialog() override;

private:
std::unique_ptr<Ui::VfsDownloadErrorDialog> _ui;
QScopedPointer<Ui::VfsDownloadErrorDialog> _ui;
};
}

0 comments on commit 772d8ae

Please sign in to comment.