Repository navigation
Expand file tree
/
Copy pathprogresshelper.cpp
More file actions
104 lines (83 loc) · 2.83 KB
/
Copy pathprogresshelper.cpp
File metadata and controls
104 lines (83 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// ============================================================
// progresshelper.cpp
// دوال التقدم (Progress Bar) والحالة (Status Bar)
// ============================================================
#include "progresshelper.h"
#include <QProgressBar>
#include <QStatusBar>
#include <QApplication>
#include <QDebug>
// ============================================================
// دوال Status Bar (شريط الحالة)
// ============================================================
void showStatusMessage(QStatusBar *statusBar, const QString &message, int timeout)
{
if (!statusBar) return;
statusBar->showMessage(message, timeout);
}
void showExtractStart(QStatusBar *statusBar)
{
showStatusMessage(statusBar, "Extracting...", 0);
}
void showExtractEnd(QStatusBar *statusBar, int count)
{
QString msg = QString("%1 %2 extracted successfully.")
.arg(count)
.arg(count == 1 ? "file" : "files/folders");
showStatusMessage(statusBar, msg, 7000);
}
void updateExtractStatus(QStatusBar *statusBar, const QString ¤t, int index, int total)
{
if (!statusBar) return;
QString msg = QString(" Extraction %1 (%2/%3)")
.arg(current)
.arg(index)
.arg(total);
statusBar->showMessage(msg, 0);
QApplication::processEvents();
}
// ============================================================
// دوال Progress Bar (شريط التقدم)
// ============================================================
void initProgressBar(QProgressBar *progressBar, int max)
{
if (!progressBar) return;
progressBar->setRange(0, max);
progressBar->setValue(0);
progressBar->setVisible(true);
QApplication::processEvents();
}
void setProgressValue(QProgressBar *progressBar, int value)
{
if (!progressBar) return;
progressBar->setValue(value);
QApplication::processEvents();
}
void resetProgressBar(QProgressBar *progressBar)
{
if (!progressBar) return;
qDebug() << "[DEBUG] resetProgressBar called!";
progressBar->setValue(0);
progressBar->setVisible(false);
QApplication::processEvents();
}
void setProgressBarVisible(QProgressBar *progressBar, bool visible)
{
if (!progressBar) return;
progressBar->setVisible(visible);
QApplication::processEvents();
}
// ============================================================
// دالة مساعدة (تحديث شامل)
// ============================================================
void updateProgressBar(QProgressBar *progressBar, int value, int max)
{
if (!progressBar) return;
if (max <= 0) {
progressBar->setRange(0, 0); // وضع غير محدد (Indeterminate)
return;
}
progressBar->setRange(0, max);
progressBar->setValue(value);
QApplication::processEvents();
}