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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/***************************************************************************
copyright : (C) 2005-2006 by Robby Stephenson
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of version 2 of the GNU General Public License as *
* published by the Free Software Foundation; *
* *
***************************************************************************/
#include "statusbar.h"
#include "tellico_debug.h"
#include "progressmanager.h"
#include "tellico_debug.h"
#include "gui/progress.h"
#include <tdelocale.h>
#include <tdeapplication.h>
#include <kpushbutton.h>
#include <kiconloader.h>
#include <tqobjectlist.h>
#include <tqpainter.h>
#include <tqstyle.h>
#include <tqtimer.h>
#include <tqtooltip.h>
using Tellico::StatusBar;
StatusBar* StatusBar::s_self = 0;
StatusBar::StatusBar(TQWidget* parent_) : KStatusBar(parent_) {
s_self = this;
// don't care about text and id
m_mainLabel = new KStatusBarLabel(TQString(), 0, this);
m_mainLabel->setIndent(4);
m_mainLabel->setAlignment(TQt::AlignLeft | TQt::AlignVCenter);
addWidget(m_mainLabel, 3 /*stretch*/, true /*permanent*/);
m_countLabel = new KStatusBarLabel(TQString(), 1, this);
m_countLabel->setAlignment(TQt::AlignLeft | TQt::AlignVCenter);
m_countLabel->setIndent(4);
addWidget(m_countLabel, 0, true);
m_progress = new GUI::Progress(100, this);
addWidget(m_progress, 1, true);
m_cancelButton = new KPushButton(SmallIcon(TQString::fromLatin1("cancel")), TQString(), this);
TQToolTip::add(m_cancelButton, i18n("Cancel"));
addWidget(m_cancelButton, 0, true);
m_progress->hide();
m_cancelButton->hide();
ProgressManager* pm = ProgressManager::self();
connect(pm, TQ_SIGNAL(signalTotalProgress(uint)), TQ_SLOT(slotProgress(uint)));
connect(m_cancelButton, TQ_SIGNAL(clicked()), pm, TQ_SLOT(slotCancelAll()));
}
void StatusBar::polish() {
KStatusBar::polish();
int h = 0;
TQObjectList* list = queryList("TQWidget", 0, false, false);
for(TQObject* o = list->first(); o; o = list->next()) {
int _h = static_cast<TQWidget*>(o)->minimumSizeHint().height();
if(_h > h) {
h = _h;
}
}
h -= 4; // hint from amarok, it's too big usually
for(TQObject* o = list->first(); o; o = list->next()) {
static_cast<TQWidget*>(o)->setFixedHeight(h);
}
delete list;
}
void StatusBar::clearStatus() {
setStatus(i18n("Ready."));
}
void StatusBar::setStatus(const TQString& status_) {
// always add a space for asthetics
m_mainLabel->setText(status_ + ' ');
}
void StatusBar::setCount(const TQString& count_) {
m_countLabel->setText(count_ + ' ');
}
void StatusBar::slotProgress(uint progress_) {
m_progress->setProgress(progress_);
if(m_progress->isDone()) {
m_progress->hide();
m_cancelButton->hide();
} else if(m_progress->isHidden()) {
m_progress->show();
if(ProgressManager::self()->anyCanBeCancelled()) {
m_cancelButton->show();
}
kapp->processEvents(); // needed so the window gets updated ???
}
}
void StatusBar::slotUpdate() {
/*
myDebug() << "StatusBar::slotUpdate() - " << m_progress->isShown() << endl;
if(m_progressBox->isEmpty()) {
TQTimer::singleShot(0, m_progress, TQ_SLOT(hide()));
// m_progressBox->hide();
} else {
TQTimer::singleShot(0, m_progress, TQ_SLOT(show()));
// m_progressBox->show();
}
*/
}
#include "statusbar.moc"
|