mirror of
https://bitbucket.org/smil3y/kde-extraapps.git
synced 2025-02-23 18:32:53 +00:00
generic: adjust to kparts changes
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
a533e0d19c
commit
b510355f1b
7 changed files with 18 additions and 230 deletions
|
@ -133,8 +133,6 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList& args)
|
||||||
connect(this, SIGNAL(completed()),
|
connect(this, SIGNAL(completed()),
|
||||||
this, SLOT(setFileNameFromArchive()));
|
this, SLOT(setFileNameFromArchive()));
|
||||||
|
|
||||||
m_statusBarExtension = new KParts::StatusBarExtension(this);
|
|
||||||
|
|
||||||
setXMLFile(QLatin1String( "ark_part.rc" ));
|
setXMLFile(QLatin1String( "ark_part.rc" ));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +149,6 @@ void Part::registerJob(KJob* job)
|
||||||
{
|
{
|
||||||
if (!m_jobTracker) {
|
if (!m_jobTracker) {
|
||||||
m_jobTracker = new JobTracker(widget());
|
m_jobTracker = new JobTracker(widget());
|
||||||
m_statusBarExtension->addStatusBarItem(m_jobTracker->widget(0), 0, true);
|
|
||||||
m_jobTracker->widget(job)->show();
|
m_jobTracker->widget(job)->show();
|
||||||
}
|
}
|
||||||
m_jobTracker->registerJob(job);
|
m_jobTracker->registerJob(job);
|
||||||
|
|
|
@ -25,18 +25,16 @@
|
||||||
|
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
|
|
||||||
#include <KParts/Part>
|
|
||||||
#include <KParts/StatusBarExtension>
|
|
||||||
#include <KTempDir>
|
|
||||||
|
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QSplitter>
|
#include <QSplitter>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
|
|
||||||
|
#include <KParts/Part>
|
||||||
|
#include <KTempDir>
|
||||||
|
|
||||||
class ArchiveModel;
|
class ArchiveModel;
|
||||||
class InfoPanel;
|
class InfoPanel;
|
||||||
|
|
||||||
class KAbstractWidgetJobTracker;
|
class KAbstractWidgetJobTracker;
|
||||||
class KAboutData;
|
class KAboutData;
|
||||||
class KAction;
|
class KAction;
|
||||||
|
@ -126,7 +124,6 @@ private:
|
||||||
PreviewMode m_previewMode;
|
PreviewMode m_previewMode;
|
||||||
|
|
||||||
KAbstractWidgetJobTracker *m_jobTracker;
|
KAbstractWidgetJobTracker *m_jobTracker;
|
||||||
KParts::StatusBarExtension *m_statusBarExtension;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Ark
|
} // namespace Ark
|
||||||
|
|
|
@ -26,7 +26,6 @@ set(filelight_PART_SRCS
|
||||||
radialMap/labels.cpp
|
radialMap/labels.cpp
|
||||||
part.cpp
|
part.cpp
|
||||||
scan.cpp
|
scan.cpp
|
||||||
progressBox.cpp
|
|
||||||
Config.cpp
|
Config.cpp
|
||||||
settingsDialog.cpp
|
settingsDialog.cpp
|
||||||
fileTree.cpp
|
fileTree.cpp
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "define.h"
|
#include "define.h"
|
||||||
#include "fileTree.h"
|
#include "fileTree.h"
|
||||||
#include "progressBox.h"
|
|
||||||
#include "radialMap/widget.h"
|
#include "radialMap/widget.h"
|
||||||
#include "scan.h"
|
#include "scan.h"
|
||||||
#include "settingsDialog.h"
|
#include "settingsDialog.h"
|
||||||
|
@ -66,7 +65,6 @@ K_EXPORT_PLUGIN(filelightPartFactory(KAboutData(
|
||||||
Part::Part(QWidget *parentWidget, QObject *parent, const QList<QVariant>&)
|
Part::Part(QWidget *parentWidget, QObject *parent, const QList<QVariant>&)
|
||||||
: ReadOnlyPart(parent)
|
: ReadOnlyPart(parent)
|
||||||
, m_summary(0)
|
, m_summary(0)
|
||||||
, m_statusbar(new StatusBarExtension(this))
|
|
||||||
, m_map(0)
|
, m_map(0)
|
||||||
, m_started(false)
|
, m_started(false)
|
||||||
{
|
{
|
||||||
|
@ -94,13 +92,6 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QList<QVariant>&)
|
||||||
m_map = new RadialMap::Widget(partWidget);
|
m_map = new RadialMap::Widget(partWidget);
|
||||||
m_layout->addWidget(m_map);
|
m_layout->addWidget(m_map);
|
||||||
|
|
||||||
m_stateWidget = new ProgressBox(statusBar(), this, m_manager);
|
|
||||||
m_layout->addWidget(m_stateWidget);
|
|
||||||
m_stateWidget->hide();
|
|
||||||
|
|
||||||
m_numberOfFiles = new QLabel();
|
|
||||||
m_statusbar->addStatusBarItem(m_numberOfFiles, 0, true);
|
|
||||||
|
|
||||||
KStandardAction::zoomIn(m_map, SLOT(zoomIn()), actionCollection());
|
KStandardAction::zoomIn(m_map, SLOT(zoomIn()), actionCollection());
|
||||||
KStandardAction::zoomOut(m_map, SLOT(zoomOut()), actionCollection());
|
KStandardAction::zoomOut(m_map, SLOT(zoomOut()), actionCollection());
|
||||||
KAction *action = actionCollection()->addAction(QLatin1String("configure_filelight"));
|
KAction *action = actionCollection()->addAction(QLatin1String("configure_filelight"));
|
||||||
|
@ -178,9 +169,6 @@ Part::openUrl(const KUrl &u)
|
||||||
if (m_summary != 0)
|
if (m_summary != 0)
|
||||||
m_summary->hide();
|
m_summary->hide();
|
||||||
|
|
||||||
m_stateWidget->show();
|
|
||||||
m_layout->addWidget(m_stateWidget);
|
|
||||||
|
|
||||||
return start(uri);
|
return start(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,10 +179,9 @@ bool
|
||||||
Part::closeUrl()
|
Part::closeUrl()
|
||||||
{
|
{
|
||||||
if (m_manager->abort())
|
if (m_manager->abort())
|
||||||
statusBar()->showMessage(i18n("Aborting Scan..."));
|
emit setStatusBarText(i18n("Aborting Scan..."));
|
||||||
|
|
||||||
m_map->hide();
|
m_map->hide();
|
||||||
m_stateWidget->hide();
|
|
||||||
|
|
||||||
showSummary();
|
showSummary();
|
||||||
|
|
||||||
|
@ -229,15 +216,15 @@ bool
|
||||||
Part::start(const KUrl &url)
|
Part::start(const KUrl &url)
|
||||||
{
|
{
|
||||||
if (!m_started) {
|
if (!m_started) {
|
||||||
connect(m_map, SIGNAL(mouseHover(QString)), statusBar(), SLOT(showMessage(QString)));
|
connect(m_map, SIGNAL(mouseHover(QString)), this, SIGNAL(setStatusBarText(QString)));
|
||||||
connect(m_map, SIGNAL(created(const Folder*)), statusBar(), SLOT(clearMessage()));
|
connect(m_map, SIGNAL(created(const Folder*)), this, SLOT(clearStatusBarMessage()));
|
||||||
m_started = true;
|
m_started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_manager->running())
|
if (m_manager->running())
|
||||||
m_manager->abort();
|
m_manager->abort();
|
||||||
|
|
||||||
m_numberOfFiles->setText(QString());
|
emit setStatusBarText(QString());
|
||||||
|
|
||||||
if (m_manager->start(url)) {
|
if (m_manager->start(url)) {
|
||||||
setUrl(url);
|
setUrl(url);
|
||||||
|
@ -246,7 +233,7 @@ Part::start(const KUrl &url)
|
||||||
stateChanged(QLatin1String( "scan_started" ));
|
stateChanged(QLatin1String( "scan_started" ));
|
||||||
emit started(0); //as a Part, we have to do this
|
emit started(0); //as a Part, we have to do this
|
||||||
emit setWindowCaption(s);
|
emit setWindowCaption(s);
|
||||||
statusBar()->showMessage(s);
|
emit setStatusBarText(s);
|
||||||
m_map->hide();
|
m_map->hide();
|
||||||
m_map->invalidate(); //to maintain ui consistency
|
m_map->invalidate(); //to maintain ui consistency
|
||||||
|
|
||||||
|
@ -270,7 +257,6 @@ Part::rescan()
|
||||||
//FIXME we have to empty the cache because otherwise rescan picks up the old tree..
|
//FIXME we have to empty the cache because otherwise rescan picks up the old tree..
|
||||||
m_manager->emptyCache(); //causes canvas to invalidate
|
m_manager->emptyCache(); //causes canvas to invalidate
|
||||||
m_map->hide();
|
m_map->hide();
|
||||||
m_stateWidget->show();
|
|
||||||
start(url());
|
start(url());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -278,9 +264,8 @@ void
|
||||||
Part::scanCompleted(Folder *tree)
|
Part::scanCompleted(Folder *tree)
|
||||||
{
|
{
|
||||||
if (tree) {
|
if (tree) {
|
||||||
statusBar()->showMessage(i18n("Scan completed, generating map..."));
|
emit setStatusBarText(i18n("Scan completed, generating map..."));
|
||||||
|
|
||||||
m_stateWidget->hide();
|
|
||||||
m_map->show();
|
m_map->show();
|
||||||
m_map->create(tree);
|
m_map->create(tree);
|
||||||
|
|
||||||
|
@ -291,7 +276,7 @@ Part::scanCompleted(Folder *tree)
|
||||||
emit canceled(i18n("Scan failed: %1", prettyUrl()));
|
emit canceled(i18n("Scan failed: %1", prettyUrl()));
|
||||||
emit setWindowCaption(QString());
|
emit setWindowCaption(QString());
|
||||||
|
|
||||||
statusBar()->clearMessage();
|
emit setStatusBarText(QString());
|
||||||
|
|
||||||
setUrl(KUrl());
|
setUrl(KUrl());
|
||||||
}
|
}
|
||||||
|
@ -309,7 +294,13 @@ Part::mapChanged(const Folder *tree)
|
||||||
i18n("No files.") :
|
i18n("No files.") :
|
||||||
i18np("1 file", "%1 files",fileCount);
|
i18np("1 file", "%1 files",fileCount);
|
||||||
|
|
||||||
m_numberOfFiles->setText(text);
|
emit setStatusBarText(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Part::clearStatusBarMessage()
|
||||||
|
{
|
||||||
|
emit setStatusBarText(QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -22,13 +22,11 @@
|
||||||
#ifndef FILELIGHTPART_H
|
#ifndef FILELIGHTPART_H
|
||||||
#define FILELIGHTPART_H
|
#define FILELIGHTPART_H
|
||||||
|
|
||||||
#include <KParts/StatusBarExtension>
|
|
||||||
#include <KParts/Part>
|
#include <KParts/Part>
|
||||||
#include <KUrl>
|
#include <KUrl>
|
||||||
|
|
||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
|
|
||||||
using KParts::StatusBarExtension;
|
|
||||||
namespace RadialMap {
|
namespace RadialMap {
|
||||||
class Widget;
|
class Widget;
|
||||||
}
|
}
|
||||||
|
@ -64,20 +62,15 @@ private slots:
|
||||||
void postInit();
|
void postInit();
|
||||||
void scanCompleted(Folder*);
|
void scanCompleted(Folder*);
|
||||||
void mapChanged(const Folder*);
|
void mapChanged(const Folder*);
|
||||||
|
void clearStatusBarMessage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KStatusBar *statusBar() {
|
|
||||||
return m_statusbar->statusBar();
|
|
||||||
}
|
|
||||||
void showSummary();
|
void showSummary();
|
||||||
|
|
||||||
QLayout *m_layout;
|
QLayout *m_layout;
|
||||||
QWidget *m_summary;
|
QWidget *m_summary;
|
||||||
StatusBarExtension *m_statusbar;
|
|
||||||
RadialMap::Widget *m_map;
|
RadialMap::Widget *m_map;
|
||||||
QWidget *m_stateWidget;
|
|
||||||
class ScanManager *m_manager;
|
class ScanManager *m_manager;
|
||||||
QLabel *m_numberOfFiles;
|
|
||||||
|
|
||||||
bool m_started;
|
bool m_started;
|
||||||
|
|
||||||
|
|
|
@ -1,131 +0,0 @@
|
||||||
/***********************************************************************
|
|
||||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
|
||||||
* Copyright 2008-2009 Martin Sandsmark <martin.sandsmark@kde.org>
|
|
||||||
*
|
|
||||||
* 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) version 3 or any later version
|
|
||||||
* accepted by the membership of KDE e.V. (or its successor approved
|
|
||||||
* by the membership of KDE e.V.), which shall act as a proxy
|
|
||||||
* defined in Section 14 of version 3 of the license.
|
|
||||||
*
|
|
||||||
* 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
***********************************************************************/
|
|
||||||
|
|
||||||
#include "progressBox.h"
|
|
||||||
|
|
||||||
#include "scan.h"
|
|
||||||
|
|
||||||
#include <KGlobal>
|
|
||||||
#include <KGlobalSettings>
|
|
||||||
#include <KColorScheme>
|
|
||||||
#include <KIO/Job>
|
|
||||||
#include <KLocale>
|
|
||||||
|
|
||||||
#include <QtGui/QLabel>
|
|
||||||
#include <QPainter>
|
|
||||||
#include <QtCore/QDebug>
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
|
|
||||||
ProgressBox::ProgressBox(QWidget *parent, QObject *part, Filelight::ScanManager *m)
|
|
||||||
: QWidget(parent)
|
|
||||||
, m_manager(m)
|
|
||||||
{
|
|
||||||
hide();
|
|
||||||
|
|
||||||
setObjectName(QLatin1String( "ProgressBox" ));
|
|
||||||
|
|
||||||
setFont(KGlobalSettings::fixedFont());
|
|
||||||
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed);
|
|
||||||
|
|
||||||
setText(999999);
|
|
||||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
||||||
setMinimumSize(200, 200);
|
|
||||||
|
|
||||||
connect(&m_timer, SIGNAL(timeout()), SLOT(report()));
|
|
||||||
connect(part, SIGNAL(started(KIO::Job*)), SLOT(start()));
|
|
||||||
connect(part, SIGNAL(completed()), SLOT(stop()));
|
|
||||||
connect(part, SIGNAL(canceled(QString)), SLOT(halt()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ProgressBox::start() //slot
|
|
||||||
{
|
|
||||||
m_timer.start(50); //20 times per second - very smooth
|
|
||||||
report();
|
|
||||||
show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ProgressBox::report() //slot
|
|
||||||
{
|
|
||||||
setText(m_manager->files());
|
|
||||||
repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ProgressBox::stop()
|
|
||||||
{
|
|
||||||
m_timer.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ProgressBox::halt()
|
|
||||||
{
|
|
||||||
// canceled by stop button
|
|
||||||
m_timer.stop();
|
|
||||||
QTimer::singleShot(2000, this, SLOT(hide()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
ProgressBox::setText(int files)
|
|
||||||
{
|
|
||||||
m_text = i18np("%1 File", "%1 Files", files);
|
|
||||||
m_textWidth = fontMetrics().width(m_text);
|
|
||||||
m_textHeight = fontMetrics().height();
|
|
||||||
}
|
|
||||||
|
|
||||||
static const int pieces = 4;
|
|
||||||
static const float angleFactor[] = { -0.75, 0.5, 1.0, -0.3 };
|
|
||||||
static const int length[] = { 30, 40, 50, 60 };
|
|
||||||
static const int aLength[] = { 300, 2000, 200, 2000 };
|
|
||||||
|
|
||||||
void ProgressBox::paintEvent(QPaintEvent*)
|
|
||||||
{
|
|
||||||
KColorScheme view = KColorScheme(QPalette::Active, KColorScheme::Tooltip);
|
|
||||||
|
|
||||||
QPainter paint(this);
|
|
||||||
paint.setRenderHint(QPainter::Antialiasing);
|
|
||||||
static int tick = 0;
|
|
||||||
tick+=16;
|
|
||||||
|
|
||||||
for (int i=0; i<pieces; i++) {
|
|
||||||
const QRect rect(length[i]/2, length[i]/2, 200- length[i], 200-length[i]);
|
|
||||||
int angle = angleFactor[i] + tick*angleFactor[i];
|
|
||||||
QRadialGradient gradient(rect.center(), sin(angle/160.0f) * 100);
|
|
||||||
gradient.setColorAt(0, QColor::fromHsv(abs(angle/16) % 360 , 160, 255));
|
|
||||||
gradient.setColorAt(1, QColor::fromHsv(abs(angle/16) % 360 , 160, 128));
|
|
||||||
QBrush brush(gradient);
|
|
||||||
paint.setBrush(brush);
|
|
||||||
paint.drawPie(QRect(rect), angle, aLength[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
paint.setBrush(view.background(KColorScheme::ActiveBackground));
|
|
||||||
paint.setPen(view.foreground().color());
|
|
||||||
paint.translate(0.5, 0.5);
|
|
||||||
paint.drawRoundedRect(95-m_textWidth/2, 85, m_textWidth+10, m_textHeight+10, 5, 5);
|
|
||||||
paint.translate(-0.5, -0.5);
|
|
||||||
paint.drawText(100 - m_textWidth/2, 100, m_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#include "moc_progressBox.cpp"
|
|
|
@ -1,58 +0,0 @@
|
||||||
/***********************************************************************
|
|
||||||
* Copyright 2003-2004 Max Howell <max.howell@methylblue.com>
|
|
||||||
* Copyright 2008-2009 Martin Sandsmark <martin.sandsmark@kde.org>
|
|
||||||
*
|
|
||||||
* 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) version 3 or any later version
|
|
||||||
* accepted by the membership of KDE e.V. (or its successor approved
|
|
||||||
* by the membership of KDE e.V.), which shall act as a proxy
|
|
||||||
* defined in Section 14 of version 3 of the license.
|
|
||||||
*
|
|
||||||
* 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, see <http://www.gnu.org/licenses/>.
|
|
||||||
***********************************************************************/
|
|
||||||
|
|
||||||
#ifndef PROGRESSBOX_H
|
|
||||||
#define PROGRESSBOX_H
|
|
||||||
|
|
||||||
#include <QtGui/QLabel>
|
|
||||||
#include <QtCore/QTimer>
|
|
||||||
|
|
||||||
namespace Filelight {
|
|
||||||
class ScanManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
class ProgressBox : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ProgressBox(QWidget*, QObject*, Filelight::ScanManager*);
|
|
||||||
|
|
||||||
void setText(int);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void start();
|
|
||||||
void report();
|
|
||||||
void stop();
|
|
||||||
void halt();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void paintEvent(QPaintEvent *event);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QTimer m_timer;
|
|
||||||
Filelight::ScanManager* m_manager;
|
|
||||||
QString m_text;
|
|
||||||
int m_textWidth;
|
|
||||||
int m_textHeight;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Add table
Reference in a new issue