2006-11-21 06:02:05 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* Copyright (C) 2006 by Peter Penz *
|
|
|
|
* peter.penz@gmx.at *
|
|
|
|
* *
|
|
|
|
* 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., *
|
2006-12-08 21:24:08 +00:00
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
|
2006-11-21 06:02:05 +00:00
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#ifndef DOLPHINSTATUSBAR_H
|
|
|
|
#define DOLPHINSTATUSBAR_H
|
|
|
|
|
2006-11-23 07:54:24 +00:00
|
|
|
#include <khbox.h>
|
2007-01-23 18:33:43 +00:00
|
|
|
|
|
|
|
class DolphinView;
|
|
|
|
class KUrl;
|
|
|
|
class StatusBarMessageLabel;
|
|
|
|
class StatusBarSpaceInfo;
|
2006-11-21 06:02:05 +00:00
|
|
|
class QProgressBar;
|
|
|
|
class QLabel;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Represents the statusbar of a Dolphin view.
|
|
|
|
*
|
|
|
|
* The statusbar allows to show messages and progress
|
|
|
|
* information.
|
|
|
|
*/
|
2007-04-09 19:12:54 +00:00
|
|
|
class DolphinStatusBar : public KHBox
|
|
|
|
{
|
2006-11-21 06:02:05 +00:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Describes the type of the message text. Dependent
|
|
|
|
* from the type a corresponding icon and color is
|
|
|
|
* used for the message text.
|
|
|
|
*/
|
|
|
|
enum Type {
|
|
|
|
Default,
|
|
|
|
OperationCompleted,
|
|
|
|
Information,
|
|
|
|
Error
|
|
|
|
};
|
|
|
|
|
2007-06-07 21:10:48 +00:00
|
|
|
DolphinStatusBar(QWidget* parent,
|
|
|
|
const KUrl& url);
|
|
|
|
|
2006-11-21 06:02:05 +00:00
|
|
|
virtual ~DolphinStatusBar();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the message text to \a msg. Dependant
|
|
|
|
* from the given type \a type an icon is shown and
|
|
|
|
* the color of the text is adjusted. The height of
|
|
|
|
* the statusbar is automatically adjusted in a way,
|
|
|
|
* that the full text fits into the available width.
|
|
|
|
*
|
|
|
|
* If a progress is ongoing and a message
|
|
|
|
* with the type Type::Error is set, the progress
|
|
|
|
* is cleared automatically.
|
|
|
|
*/
|
|
|
|
void setMessage(const QString& msg, Type type);
|
|
|
|
QString message() const;
|
2007-01-23 18:33:43 +00:00
|
|
|
|
2006-11-21 06:02:05 +00:00
|
|
|
Type type() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the text for the progress information.
|
|
|
|
* The text is shown with a delay of 300 milliseconds:
|
|
|
|
* if the progress set by DolphinStatusBar::setProgress()
|
|
|
|
* does reach 100 % within 300 milliseconds,
|
|
|
|
* the progress text is not shown at all. This assures that
|
|
|
|
* no flickering occurs for showing a progress of fast
|
|
|
|
* operations.
|
|
|
|
*/
|
|
|
|
void setProgressText(const QString& text);
|
|
|
|
QString progressText() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the progress in percent (0 - 100). The
|
|
|
|
* progress is shown with a delay of 300 milliseconds:
|
|
|
|
* if the progress does reach 100 % within 300 milliseconds,
|
|
|
|
* the progress is not shown at all. This assures that
|
|
|
|
* no flickering occurs for showing a progress of fast
|
|
|
|
* operations.
|
|
|
|
*/
|
|
|
|
void setProgress(int percent);
|
2007-04-09 19:12:54 +00:00
|
|
|
int progress() const
|
|
|
|
{
|
|
|
|
return m_progress;
|
|
|
|
}
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clears the message text of the status bar by replacing
|
|
|
|
* the message with the default text, which can be set
|
|
|
|
* by DolphinStatusBar::setDefaultText(). The progress
|
|
|
|
* information is not cleared.
|
|
|
|
*/
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the default text, which is shown if the status bar
|
|
|
|
* is cleared by DolphinStatusBar::clear().
|
|
|
|
*/
|
|
|
|
void setDefaultText(const QString& text);
|
2007-01-31 22:03:35 +00:00
|
|
|
const QString& defaultText() const;
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2007-01-26 19:38:32 +00:00
|
|
|
protected:
|
|
|
|
/** @see QWidget::resizeEvent() */
|
|
|
|
virtual void resizeEvent(QResizeEvent* event);
|
|
|
|
|
2006-11-21 06:02:05 +00:00
|
|
|
private slots:
|
2007-01-23 18:33:43 +00:00
|
|
|
void updateProgressInfo();
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
/**
|
2007-01-23 18:33:43 +00:00
|
|
|
* Is invoked, when the URL of the DolphinView, where the
|
|
|
|
* statusbar belongs too, has been changed. The space information
|
2007-01-26 19:38:32 +00:00
|
|
|
* content is updated.
|
|
|
|
*/
|
|
|
|
void updateSpaceInfoContent(const KUrl& url);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows the space information if there is enough room to show it
|
|
|
|
* without the need to clip the status bar text. If the progress
|
|
|
|
* bar is shown, the space information won't be shown.
|
2006-11-21 06:02:05 +00:00
|
|
|
*/
|
2007-01-26 19:38:32 +00:00
|
|
|
void showSpaceInfo();
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
StatusBarMessageLabel* m_messageLabel;
|
|
|
|
StatusBarSpaceInfo* m_spaceInfo;
|
2007-01-23 18:33:43 +00:00
|
|
|
|
2006-11-21 06:02:05 +00:00
|
|
|
QLabel* m_progressText;
|
|
|
|
QProgressBar* m_progressBar;
|
|
|
|
int m_progress;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|