Skip to content

Commit

Permalink
generic: what's new carousel popup
Browse files Browse the repository at this point in the history
Signed-off-by: IonutMuthi <[email protected]>
  • Loading branch information
IonutMuthi committed Dec 4, 2024
1 parent 72ef3a8 commit dee6a2d
Show file tree
Hide file tree
Showing 7 changed files with 404 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,13 @@ file(GLOB UI_LIST *.ui)

set(PROJECT_SOURCES ${SRC_LIST} ${HEADER_LIST} ${UI_LIST})

include(ScopyWhatsNew)
set(FOLDER ${CMAKE_SOURCE_DIR}/resources/whatsnew/)
set(RESOURCE_FILE ${CMAKE_SOURCE_DIR}/resources/whatsnew/whatsnew.qrc)
generate_whats_new("${RESOURCE_FILE}" "${FOLDER}")
file(GLOB WHATS_NEW_RESOURCES resources/whatsnew/whatsnew.qrc)
qt_add_resources(SCOPY_RESOURCES ${WHATS_NEW_RESOURCES})

include(ScopyAbout)
configure_about(./resources/about)
file(GLOB SCOPY_RESOURCE_FILES gui/res/resources.qrc resources/aboutpage.qrc)
Expand Down
45 changes: 45 additions & 0 deletions cmake/Modules/ScopyWhatsNew.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Copyright (c) 2024 Analog Devices Inc.
#
# This file is part of Scopy
# (see https://www.github.com/analogdevicesinc/scopy).
#
# 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.
#
# 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 <https://www.gnu.org/licenses/>.
#

if(DEFINED __INCLUDED_SCOPY_WHATS_NEW_CMAKE)
return()
endif()
set(__INCLUDED_SCOPY_WHATS_NEW_CMAKE TRUE)

function(generate_whats_new RESOURCE_FILE FOLDER)
# Specify the folder containing resources Create the list of HTML files recursively

file(GLOB_RECURSE HTML_FILES "${FOLDER}*.html")

# Start writing to the resource file
file(WRITE "${RESOURCE_FILE}" "<RCC>\n <qresource prefix=\"/whatsnew/\">\n")

# Loop through each HTML file and add it to the resource file
foreach(HTML_FILE ${HTML_FILES})
# Convert the file path to a resource path
file(RELATIVE_PATH relative ${FOLDER} ${HTML_FILE})

# Write the file to the resource file
file(APPEND "${RESOURCE_FILE}" " <file>${relative}</file>\n")
endforeach()

# End the resource file
file(APPEND "${RESOURCE_FILE}" " </qresource>\n</RCC>\n")
endfunction()
1 change: 1 addition & 0 deletions core/include/core/scopymainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public Q_SLOTS:
void handleScanner();
void enableScanner();
void deviceAutoconnect();
void showWhatsNew();

protected:
void closeEvent(QCloseEvent *event) override;
Expand Down
55 changes: 55 additions & 0 deletions core/include/core/whatsnewoverlay.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (c) 2024 Analog Devices Inc.
*
* This file is part of Scopy
* (see https://www.github.com/analogdevicesinc/scopy).
*
* 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.
*
* 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 <https://www.gnu.org/licenses/>.
*
*/

#ifndef WHATSNEWOVERLAY_H
#define WHATSNEWOVERLAY_H

#include <QLabel>
#include <QWidget>
#include <popupwidget.h>
#include "scopy-core_export.h"
#include <QButtonGroup>
#include <QComboBox>
#include <QStackedWidget>

namespace scopy {
class SCOPY_CORE_EXPORT WhatsNewOverlay : public QWidget
{
Q_OBJECT
public:
explicit WhatsNewOverlay(QWidget *parent = nullptr);
~WhatsNewOverlay();

void showOverlay();
void enableTintedOverlay(bool enable = true);

private:
PopupWidget *m_popupWidget;
QString getHtmlPageContent(QString fileName);
void initCarousel();
void generateVersionPage(QString filePath);

QStackedWidget *m_carouselWidget;
QComboBox *m_versionCb;
gui::TintedOverlay *m_tintedOverlay;
};
} // namespace scopy
#endif // WHATSNEWOVERLAY_H
18 changes: 17 additions & 1 deletion core/src/scopymainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <browsemenu.h>
#include <deviceautoconnect.h>
#include <style.h>
#include <whatsnewoverlay.h>

#include "logging_categories.h"
#include "qmessagebox.h"
Expand Down Expand Up @@ -254,6 +255,13 @@ void ScopyMainWindow::deviceAutoconnect()
}
}

void ScopyMainWindow::showWhatsNew()
{
WhatsNewOverlay *whatsNew = new WhatsNewOverlay(this);
whatsNew->move(this->rect().center() - whatsNew->rect().center());
QMetaObject::invokeMethod(whatsNew, &WhatsNewOverlay::showOverlay, Qt::QueuedConnection);
}

void ScopyMainWindow::save()
{
QString selectedFilter;
Expand Down Expand Up @@ -351,16 +359,23 @@ void ScopyMainWindow::setupPreferences()
if(p->get("general_show_status_bar").toBool()) {
StatusBarManager::GetInstance()->setEnabled(true);
}

if(p->get("general_first_run").toBool()) {
license = new LicenseOverlay(this);
auto versionCheckInfo = new VersionCheckMessage(this);

StatusBarManager::pushWidget(versionCheckInfo, "Should Scopy check for online versions?");

QMetaObject::invokeMethod(license, &LicenseOverlay::showOverlay, Qt::QueuedConnection);

connect(license->getContinueBtn(), &QPushButton::clicked, this, &ScopyMainWindow::showWhatsNew,
Qt::QueuedConnection);
}
}

if(p->get("general_show_whats_new").toBool() && !p->get("general_first_run").toBool()) {
showWhatsNew();
}
}
void ScopyMainWindow::initPreferences()
{
QElapsedTimer timer;
Expand All @@ -374,6 +389,7 @@ void ScopyMainWindow::initPreferences()
p->init("general_save_session", true);
p->init("general_save_attached", true);
p->init("general_doubleclick_attach", true);
p->init("general_show_whats_new", true);
#if defined(__linux__) && (defined(__arm__) || defined(__aarch64__))
p->init("general_use_opengl", false);
#else
Expand Down
Loading

0 comments on commit dee6a2d

Please sign in to comment.