summaryrefslogtreecommitdiffstats
path: root/src/dolphinstatusbar.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-17 23:39:35 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-17 23:39:35 +0000
commitf48aef5ed7f2e333984766d9ceb02e01ecbd47a7 (patch)
tree6ed79de882f3051cf7999a9cee2b633d8daabeab /src/dolphinstatusbar.cpp
downloaddolphin-f48aef5ed7f2e333984766d9ceb02e01ecbd47a7.tar.gz
dolphin-f48aef5ed7f2e333984766d9ceb02e01ecbd47a7.zip
Added old KDE3 version of dolphin
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/dolphin@1076309 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/dolphinstatusbar.cpp')
-rw-r--r--src/dolphinstatusbar.cpp166
1 files changed, 166 insertions, 0 deletions
diff --git a/src/dolphinstatusbar.cpp b/src/dolphinstatusbar.cpp
new file mode 100644
index 0000000..cfa5fb4
--- /dev/null
+++ b/src/dolphinstatusbar.cpp
@@ -0,0 +1,166 @@
+/***************************************************************************
+ * Copyright (C) 2006 by Peter Penz *
+ * *
+ * 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 2 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include "dolphinstatusbar.h"
+#include <kprogress.h>
+#include <qlabel.h>
+#include <qtimer.h>
+#include <kiconloader.h>
+
+#include "dolphinview.h"
+#include "statusbarmessagelabel.h"
+#include "statusbarspaceinfo.h"
+
+DolphinStatusBar::DolphinStatusBar(DolphinView* parent) :
+ QHBox(parent),
+ m_messageLabel(0),
+ m_spaceInfo(0),
+ m_progressBar(0),
+ m_progress(100)
+{
+ m_messageLabel = new StatusBarMessageLabel(this);
+ m_messageLabel->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
+
+ m_spaceInfo = new StatusBarSpaceInfo(this);
+ m_spaceInfo->setURL(parent->url());
+
+ m_progressText = new QLabel(this);
+ m_progressText->hide();
+
+ m_progressBar = new KProgress(this);
+ m_progressBar->hide();
+
+ m_progressTimer = new QTimer(this);
+ connect(m_progressTimer, SIGNAL(timeout()),
+ this, SLOT(slotProgressTimer()));
+
+ const QSize size(m_progressBar->sizeHint());
+ m_progressBar->setMaximumWidth(size.width());
+ setMinimumHeight(size.height());
+ m_messageLabel->setMinimumTextHeight(size.height());
+
+ connect(parent, SIGNAL(signalURLChanged(const KURL&)),
+ this, SLOT(slotURLChanged(const KURL&)));
+}
+
+
+DolphinStatusBar::~DolphinStatusBar()
+{
+}
+
+void DolphinStatusBar::setMessage(const QString& msg,
+ Type type)
+{
+ m_messageLabel->setText(msg);
+ if (msg.isEmpty() || (msg == m_defaultText)) {
+ type = Default;
+ }
+ m_messageLabel->setType(type);
+
+ if ((type == Error) && (m_progress < 100)) {
+ // If an error message is shown during a progress is ongoing,
+ // the (never finishing) progress information should be hidden immediately
+ // (invoking 'setProgress(100)' only leads to a delayed hiding).
+ m_progressBar->hide();
+ m_progressText->hide();
+ setProgress(100);
+ }
+}
+
+DolphinStatusBar::Type DolphinStatusBar::type() const
+{
+ return m_messageLabel->type();
+}
+
+QString DolphinStatusBar::message() const
+{
+ return m_messageLabel->text();
+}
+
+void DolphinStatusBar::setProgressText(const QString& text)
+{
+ m_progressText->setText(text);
+}
+
+QString DolphinStatusBar::progressText() const
+{
+ return m_progressText->text();
+}
+
+void DolphinStatusBar::setProgress(int percent)
+{
+ if (percent < 0) {
+ percent = 0;
+ }
+ else if (percent > 100) {
+ percent = 100;
+ }
+
+ m_progress = percent;
+ m_progressBar->setProgress(m_progress);
+ m_progressTimer->start(300, true);
+
+ const QString msg(m_messageLabel->text());
+ if (msg.isEmpty() || (msg == m_defaultText)) {
+ if (percent == 0) {
+ m_messageLabel->setText(QString::null);
+ m_messageLabel->setType(Default);
+ }
+ else if (percent == 100) {
+ m_messageLabel->setText(m_defaultText);
+ }
+ }
+}
+
+void DolphinStatusBar::clear()
+{
+ // TODO: check for timeout, so that it's prevented that
+ // a message is cleared too early.
+ m_messageLabel->setText(m_defaultText);
+ m_messageLabel->setType(Default);
+}
+
+void DolphinStatusBar::setDefaultText(const QString& text)
+{
+ m_defaultText = text;
+}
+
+void DolphinStatusBar::slotProgressTimer()
+{
+ if (m_progress < 100) {
+ // progress should be shown
+ m_progressBar->show();
+ m_progressText->show();
+ m_spaceInfo->hide();
+ }
+ else {
+ // progress should not be shown anymore
+ m_progressBar->hide();
+ m_progressText->hide();
+ m_spaceInfo->show();
+ }
+}
+
+void DolphinStatusBar::slotURLChanged(const KURL& url)
+{
+ m_spaceInfo->setURL(url);
+}
+
+#include "dolphinstatusbar.moc"