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
19 changes: 19 additions & 0 deletions src/app/GUI/RenderWidgets/renderwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "../mainwindow.h"
#include "../timelinedockwidget.h"

using namespace Friction;

RenderWidget::RenderWidget(QWidget *parent)
: QWidget(parent)
, mMainLayout(nullptr)
Expand All @@ -48,6 +50,9 @@ RenderWidget::RenderWidget(QWidget *parent)
, mScrollArea(nullptr)
, mCurrentRenderedSettings(nullptr)
, mState(RenderState::none)
#ifdef HAS_DBUS
, mUnity(nullptr)
#endif
{
mMainLayout = new QVBoxLayout(this);
mMainLayout->setMargin(0);
Expand Down Expand Up @@ -174,6 +179,20 @@ RenderWidget::RenderWidget(QWidget *parent)
this, &RenderWidget::handleRenderFailed);
connect(vidEmitter, &VideoEncoderEmitter::encodingStartFailed,
this, &RenderWidget::sendNextForRender);

#ifdef HAS_DBUS
mUnity = new Ui::UnityLauncherEntry(QStringLiteral("%1.desktop").arg(AppSupport::getAppID()), this);
connect(this, &RenderWidget::progress,
this, [this](int frame, int total) {
if (total > 0) {
const double currentProgress = static_cast<double>(frame) / total;
mUnity->setProgress(currentProgress);
mUnity->setProgressVisible(frame < total);
} else {
mUnity->setProgressVisible(false);
}
});
#endif
}

void RenderWidget::createNewRenderInstanceWidgetForCanvas(Canvas *canvas)
Expand Down
8 changes: 8 additions & 0 deletions src/app/GUI/RenderWidgets/renderwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
#include <QPushButton>
#include "renderinstancesettings.h"

#ifdef HAS_DBUS
#include "desktop/unitylauncherentry.h"
#endif

class ScrollArea;
class Canvas;
class RenderInstanceWidget;
Expand Down Expand Up @@ -75,6 +79,10 @@ class RenderWidget : public QWidget
QList<RenderInstanceWidget*> mAwaitingSettings;
RenderState mState;

#ifdef HAS_DBUS
Friction::Ui::UnityLauncherEntry *mUnity;
#endif

void handleRenderState(const RenderState &state);
void handleRenderStarted();
void handleRenderFinished();
Expand Down
6 changes: 6 additions & 0 deletions src/cmake/friction-common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ set(QT_LIBRARIES
#Qt${QT_VERSION_MAJOR}::Svg
)

if(UNIX AND NOT APPLE)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS DBus REQUIRED)
list(APPEND QT_LIBRARIES Qt${QT_VERSION_MAJOR}::DBus)
add_definitions(-DHAS_DBUS)
endif()

if(WIN32)
set(SKIA_LIBRARIES
skia
Expand Down
2 changes: 2 additions & 0 deletions src/ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ include_directories(

set(
SOURCES
desktop/unitylauncherentry.cpp
dialogs/adjustscenedialog.cpp
dialogs/applyexpressiondialog.cpp
dialogs/askdialog.cpp
Expand Down Expand Up @@ -129,6 +130,7 @@ endif()
set(
HEADERS
ui_global.h
desktop/unitylauncherentry.h
dialogs/adjustscenedialog.h
dialogs/applyexpressiondialog.h
dialogs/askdialog.h
Expand Down
100 changes: 100 additions & 0 deletions src/ui/desktop/unitylauncherentry.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
#
# Friction - https://friction.graphics
#
# Copyright (c) Ole-André Rodlie and contributors
#
# 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, version 3.
#
# 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/>.
#
# See 'README.md' for more information.
#
*/

#include "unitylauncherentry.h"

#ifdef HAS_DBUS
#include <QDBusMessage>
#include <QDBusConnection>
#endif

using namespace Friction::Ui;

UnityLauncherEntry::UnityLauncherEntry(const QString &desktopFileName,
QObject *parent)
: QObject(parent)
, mProgress(0.0)
, mProgressVisible(false)
, mCount(0)
, mCountVisible(false)
, mUrgent(false)
{
mAppUri = QStringLiteral("application://%1").arg(desktopFileName);
}

void UnityLauncherEntry::setProgress(double progress)
{
const double clampedProgress = qBound(0.0, progress, 1.0);
if (qFuzzyCompare(mProgress, clampedProgress)) { return; }

mProgress = clampedProgress;
sendUpdate();
}

void UnityLauncherEntry::setProgressVisible(bool visible)
{
if (mProgressVisible == visible) { return; }
mProgressVisible = visible;
sendUpdate();
}

void UnityLauncherEntry::setCount(qint64 count)
{
if (mCount == count) { return; }
mCount = count;
sendUpdate();
}

void UnityLauncherEntry::setCountVisible(bool visible)
{
if (mCountVisible == visible) { return; }
mCountVisible = visible;
sendUpdate();
}

void UnityLauncherEntry::setUrgent(bool urgent)
{
if (mUrgent == urgent) { return; }
mUrgent = urgent;
sendUpdate();
}

void UnityLauncherEntry::sendUpdate()
{
#ifdef HAS_DBUS
QVariantMap properties;
properties.insert(QStringLiteral("progress"), mProgress);
properties.insert(QStringLiteral("progress-visible"), mProgressVisible);
properties.insert(QStringLiteral("count"), mCount);
properties.insert(QStringLiteral("count-visible"), mCountVisible);
properties.insert(QStringLiteral("urgent"), mUrgent);

QDBusMessage message = QDBusMessage::createSignal(
QStringLiteral("/com/canonical/unity/launcherentry/1"),
QStringLiteral("com.canonical.Unity.LauncherEntry"),
QStringLiteral("Update")
);

message << mAppUri << properties;
QDBusConnection::sessionBus().send(message);
#endif
}
62 changes: 62 additions & 0 deletions src/ui/desktop/unitylauncherentry.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
#
# Friction - https://friction.graphics
#
# Copyright (c) Ole-André Rodlie and contributors
#
# 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, version 3.
#
# 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/>.
#
# See 'README.md' for more information.
#
*/

#ifndef FRICTION_UNITY_LAUNCHER_ENTRY_H
#define FRICTION_UNITY_LAUNCHER_ENTRY_H

#include "ui_global.h"

#include <QObject>
#include <QString>

namespace Friction
{
namespace Ui
{
class UI_EXPORT UnityLauncherEntry : public QObject
{
Q_OBJECT
public:
explicit UnityLauncherEntry(const QString &desktopFileName,
QObject *parent = nullptr);

public slots:
void setProgress(double progress);
void setProgressVisible(bool visible);
void setCount(qint64 count);
void setCountVisible(bool visible);
void setUrgent(bool urgent);

private:
void sendUpdate();

QString mAppUri;
double mProgress;
bool mProgressVisible;
qint64 mCount;
bool mCountVisible;
bool mUrgent;
};
}
}

#endif // FRICTION_UNITY_LAUNCHER_ENTRY_H
Loading