From b510355f1b0858a14c7412e6447d58a2fa674d70 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Thu, 31 Aug 2023 05:02:50 +0300 Subject: [PATCH] generic: adjust to kparts changes Signed-off-by: Ivailo Monev --- ark/part/part.cpp | 3 - ark/part/part.h | 9 +- filelight/src/part/CMakeLists.txt | 1 - filelight/src/part/part.cpp | 37 +++----- filelight/src/part/part.h | 9 +- filelight/src/part/progressBox.cpp | 131 ----------------------------- filelight/src/part/progressBox.h | 58 ------------- 7 files changed, 18 insertions(+), 230 deletions(-) delete mode 100644 filelight/src/part/progressBox.cpp delete mode 100644 filelight/src/part/progressBox.h diff --git a/ark/part/part.cpp b/ark/part/part.cpp index c1b76c20..872fcf97 100644 --- a/ark/part/part.cpp +++ b/ark/part/part.cpp @@ -133,8 +133,6 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QVariantList& args) connect(this, SIGNAL(completed()), this, SLOT(setFileNameFromArchive())); - m_statusBarExtension = new KParts::StatusBarExtension(this); - setXMLFile(QLatin1String( "ark_part.rc" )); } @@ -151,7 +149,6 @@ void Part::registerJob(KJob* job) { if (!m_jobTracker) { m_jobTracker = new JobTracker(widget()); - m_statusBarExtension->addStatusBarItem(m_jobTracker->widget(0), 0, true); m_jobTracker->widget(job)->show(); } m_jobTracker->registerJob(job); diff --git a/ark/part/part.h b/ark/part/part.h index 1b324b1b..291bdb7b 100644 --- a/ark/part/part.h +++ b/ark/part/part.h @@ -25,18 +25,16 @@ #include "interface.h" -#include -#include -#include - #include #include #include #include +#include +#include + class ArchiveModel; class InfoPanel; - class KAbstractWidgetJobTracker; class KAboutData; class KAction; @@ -126,7 +124,6 @@ private: PreviewMode m_previewMode; KAbstractWidgetJobTracker *m_jobTracker; - KParts::StatusBarExtension *m_statusBarExtension; }; } // namespace Ark diff --git a/filelight/src/part/CMakeLists.txt b/filelight/src/part/CMakeLists.txt index ca436839..06e4f110 100644 --- a/filelight/src/part/CMakeLists.txt +++ b/filelight/src/part/CMakeLists.txt @@ -26,7 +26,6 @@ set(filelight_PART_SRCS radialMap/labels.cpp part.cpp scan.cpp - progressBox.cpp Config.cpp settingsDialog.cpp fileTree.cpp diff --git a/filelight/src/part/part.cpp b/filelight/src/part/part.cpp index 4bf85e98..bd8fe487 100644 --- a/filelight/src/part/part.cpp +++ b/filelight/src/part/part.cpp @@ -24,7 +24,6 @@ #include "Config.h" #include "define.h" #include "fileTree.h" -#include "progressBox.h" #include "radialMap/widget.h" #include "scan.h" #include "settingsDialog.h" @@ -66,7 +65,6 @@ K_EXPORT_PLUGIN(filelightPartFactory(KAboutData( Part::Part(QWidget *parentWidget, QObject *parent, const QList&) : ReadOnlyPart(parent) , m_summary(0) - , m_statusbar(new StatusBarExtension(this)) , m_map(0) , m_started(false) { @@ -94,13 +92,6 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QList&) m_map = new RadialMap::Widget(partWidget); 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::zoomOut(m_map, SLOT(zoomOut()), actionCollection()); KAction *action = actionCollection()->addAction(QLatin1String("configure_filelight")); @@ -178,9 +169,6 @@ Part::openUrl(const KUrl &u) if (m_summary != 0) m_summary->hide(); - m_stateWidget->show(); - m_layout->addWidget(m_stateWidget); - return start(uri); } @@ -191,10 +179,9 @@ bool Part::closeUrl() { if (m_manager->abort()) - statusBar()->showMessage(i18n("Aborting Scan...")); + emit setStatusBarText(i18n("Aborting Scan...")); m_map->hide(); - m_stateWidget->hide(); showSummary(); @@ -229,15 +216,15 @@ bool Part::start(const KUrl &url) { if (!m_started) { - connect(m_map, SIGNAL(mouseHover(QString)), statusBar(), SLOT(showMessage(QString))); - connect(m_map, SIGNAL(created(const Folder*)), statusBar(), SLOT(clearMessage())); + connect(m_map, SIGNAL(mouseHover(QString)), this, SIGNAL(setStatusBarText(QString))); + connect(m_map, SIGNAL(created(const Folder*)), this, SLOT(clearStatusBarMessage())); m_started = true; } if (m_manager->running()) m_manager->abort(); - m_numberOfFiles->setText(QString()); + emit setStatusBarText(QString()); if (m_manager->start(url)) { setUrl(url); @@ -246,7 +233,7 @@ Part::start(const KUrl &url) stateChanged(QLatin1String( "scan_started" )); emit started(0); //as a Part, we have to do this emit setWindowCaption(s); - statusBar()->showMessage(s); + emit setStatusBarText(s); m_map->hide(); 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.. m_manager->emptyCache(); //causes canvas to invalidate m_map->hide(); - m_stateWidget->show(); start(url()); } @@ -278,9 +264,8 @@ void Part::scanCompleted(Folder *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->create(tree); @@ -291,7 +276,7 @@ Part::scanCompleted(Folder *tree) emit canceled(i18n("Scan failed: %1", prettyUrl())); emit setWindowCaption(QString()); - statusBar()->clearMessage(); + emit setStatusBarText(QString()); setUrl(KUrl()); } @@ -309,7 +294,13 @@ Part::mapChanged(const Folder *tree) i18n("No files.") : i18np("1 file", "%1 files",fileCount); - m_numberOfFiles->setText(text); + emit setStatusBarText(text); +} + +void +Part::clearStatusBarMessage() +{ + emit setStatusBarText(QString()); } void diff --git a/filelight/src/part/part.h b/filelight/src/part/part.h index 25343477..20f49046 100644 --- a/filelight/src/part/part.h +++ b/filelight/src/part/part.h @@ -22,13 +22,11 @@ #ifndef FILELIGHTPART_H #define FILELIGHTPART_H -#include #include #include #include -using KParts::StatusBarExtension; namespace RadialMap { class Widget; } @@ -64,20 +62,15 @@ private slots: void postInit(); void scanCompleted(Folder*); void mapChanged(const Folder*); + void clearStatusBarMessage(); private: - KStatusBar *statusBar() { - return m_statusbar->statusBar(); - } void showSummary(); QLayout *m_layout; QWidget *m_summary; - StatusBarExtension *m_statusbar; RadialMap::Widget *m_map; - QWidget *m_stateWidget; class ScanManager *m_manager; - QLabel *m_numberOfFiles; bool m_started; diff --git a/filelight/src/part/progressBox.cpp b/filelight/src/part/progressBox.cpp deleted file mode 100644 index 9dfefcd2..00000000 --- a/filelight/src/part/progressBox.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/*********************************************************************** -* Copyright 2003-2004 Max Howell -* Copyright 2008-2009 Martin Sandsmark -* -* 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 . -***********************************************************************/ - -#include "progressBox.h" - -#include "scan.h" - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - - -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 -* Copyright 2008-2009 Martin Sandsmark -* -* 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 . -***********************************************************************/ - -#ifndef PROGRESSBOX_H -#define PROGRESSBOX_H - -#include -#include - -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