VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/notificationcenter/UINotificationObject.cpp@ 90290

Last change on this file since 90290 was 90290, checked in by vboxsync, 4 years ago

FE/Qt: bugref:10067: Extend notification-center with progress handling stuff.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1/* $Id: UINotificationObject.cpp 90290 2021-07-22 14:40:08Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UINotificationObject class implementation.
4 */
5
6/*
7 * Copyright (C) 2021 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18/* GUI includes: */
19#include "UINotificationObject.h"
20#include "UINotificationProgressTask.h"
21
22
23/*********************************************************************************************************************************
24* Class UINotificationObject implementation. *
25*********************************************************************************************************************************/
26
27UINotificationObject::UINotificationObject()
28{
29}
30
31void UINotificationObject::close()
32{
33 emit sigAboutToClose();
34}
35
36
37/*********************************************************************************************************************************
38* Class UINotificationProgress implementation. *
39*********************************************************************************************************************************/
40
41UINotificationProgress::UINotificationProgress()
42 : m_pTask(0)
43 , m_uPercent(0)
44{
45}
46
47UINotificationProgress::~UINotificationProgress()
48{
49 delete m_pTask;
50 m_pTask = 0;
51}
52
53ulong UINotificationProgress::percent() const
54{
55 return m_uPercent;
56}
57
58bool UINotificationProgress::isCancelable() const
59{
60 return m_pTask->isCancelable();
61}
62
63QString UINotificationProgress::error() const
64{
65 return m_pTask->errorMessage();
66}
67
68void UINotificationProgress::handle()
69{
70 /* Prepare task: */
71 m_pTask = new UINotificationProgressTask(this);
72 if (m_pTask)
73 {
74 connect(m_pTask, &UIProgressTask::sigProgressStarted,
75 this, &UINotificationProgress::sigProgressStarted);
76 connect(m_pTask, &UIProgressTask::sigProgressChange,
77 this, &UINotificationProgress::sltHandleProgressChange);
78 connect(m_pTask, &UIProgressTask::sigProgressFinished,
79 this, &UINotificationProgress::sltHandleProgressFinished);
80 }
81
82 /* And start it finally: */
83 m_pTask->start();
84}
85
86void UINotificationProgress::close()
87{
88 /* Cancel task: */
89 m_pTask->cancel();
90 /* Call to base-class: */
91 UINotificationObject::close();
92}
93
94void UINotificationProgress::sltHandleProgressChange(ulong uPercent)
95{
96 m_uPercent = uPercent;
97 emit sigProgressChange(uPercent);
98}
99
100void UINotificationProgress::sltHandleProgressFinished()
101{
102 m_uPercent = 100;
103 emit sigProgressFinished();
104}
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette