Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions YUViewLib/src/common/Functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,13 @@ std::optional<int> toInt(const std::string_view text)
return value;
}

std::optional<int> toInt(const QString &str)
{
bool ok{};
const auto value = str.toInt(&ok);
if (ok)
return value;
return {};
}

} // namespace functions
1 change: 1 addition & 0 deletions YUViewLib/src/common/Functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ template <size_t N> QStringList toQStringList(const std::array<std::string_view,

std::string toLower(const std::string_view str);
std::optional<int> toInt(const std::string_view str);
std::optional<int> toInt(const QString &str);
std::vector<std::string_view> splitString(const std::string_view str, const char delimiter);
std::string_view stripWhitespace(std::string_view str);

Expand Down
143 changes: 0 additions & 143 deletions YUViewLib/src/handler/UpdateHandler.h

This file was deleted.

82 changes: 0 additions & 82 deletions YUViewLib/src/handler/UpdateHandlerFile.h

This file was deleted.

83 changes: 83 additions & 0 deletions YUViewLib/src/handler/update/UpdateDialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* This file is part of YUView - The YUV player with advanced analytics toolset
* <https://github.com/IENT/YUView>
* Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY
*
* 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 3 of the License, or
* (at your option) any later version.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*
* You must obey the GNU General Public License in all respects for all
* of the code used other than OpenSSL. If you modify file(s) with this
* exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do
* so, delete this exception statement from your version. If you delete
* this exception statement from all source files in the program, then
* also delete it here.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "UpdateDialog.h"

#include <common/Typedef.h>

#include <QSettings>

namespace update
{

UpdateDialog::UpdateDialog(QWidget *parent) : QDialog(parent)
{
ui.setupUi(this);

// Load the update settings from the QSettings
QSettings settings;
settings.beginGroup("updates");
bool checkForUpdates = settings.value("checkForUpdates", true).toBool();
QString updateBehavior = settings.value("updateBehavior", "ask").toString();
settings.endGroup();

ui.checkUpdatesGroupBox->setChecked(checkForUpdates);
if (updateBehavior == "ask")
ui.updateSettingComboBox->setCurrentIndex(1);
else if (updateBehavior == "auto")
ui.updateSettingComboBox->setCurrentIndex(0);

connect(ui.cancelButton, &QPushButton::clicked, this, &QDialog::reject);

if (!UPDATE_FEATURE_ENABLE)
// If the update feature is not available, we will grey this out.
ui.updateSettingComboBox->setEnabled(false);
}

void UpdateDialog::on_updateButton_clicked()
{
// The user wants to download/install the update.

// First save the settings
QSettings settings;
settings.beginGroup("updates");
settings.setValue("checkForUpdates", ui.checkUpdatesGroupBox->isChecked());
QString updateBehavior = "ask";
if (ui.updateSettingComboBox->currentIndex() == 0)
updateBehavior = "auto";
settings.setValue("updateBehavior", updateBehavior);

// The update request was accepted by the user
accept();
}

} // namespace update
55 changes: 55 additions & 0 deletions YUViewLib/src/handler/update/UpdateDialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/* This file is part of YUView - The YUV player with advanced analytics toolset
* <https://github.com/IENT/YUView>
* Copyright (C) 2015 Institut für Nachrichtentechnik, RWTH Aachen University, GERMANY
*
* 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 3 of the License, or
* (at your option) any later version.
*
* In addition, as a special exception, the copyright holders give
* permission to link the code of portions of this program with the
* OpenSSL library under certain conditions as described in each
* individual source file, and distribute linked combinations including
* the two.
*
* You must obey the GNU General Public License in all respects for all
* of the code used other than OpenSSL. If you modify file(s) with this
* exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do
* so, delete this exception statement from your version. If you delete
* this exception statement from all source files in the program, then
* also delete it here.
*
* 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#include "ui_updateDialog.h"

namespace update
{

// Ask the user if he wants to update to the new version and how to handle updates in the future.
class UpdateDialog : public QDialog
{
Q_OBJECT

public:
explicit UpdateDialog(QWidget *parent = 0);

private slots:
void on_updateButton_clicked();

private:
Ui::UpdateDialog ui;
};

} // namespace update
Loading
Loading