Commit 98943bcb authored by Harald Sitter's avatar Harald Sitter 🚔

fully port away from using kparts (still including tho)

parent 990e3280
...@@ -57,7 +57,8 @@ ...@@ -57,7 +57,8 @@
namespace Filelight { namespace Filelight {
MainWindow::MainWindow() MainWindow::MainWindow()
: KParts::MainWindow() // : KParts::MainWindow()
: KXmlGuiWindow()
, m_part(new Part(nullptr, this, QList<QVariant>())) , m_part(new Part(nullptr, this, QList<QVariant>()))
, m_histories(0) , m_histories(0)
{ {
...@@ -66,7 +67,9 @@ MainWindow::MainWindow() ...@@ -66,7 +67,9 @@ MainWindow::MainWindow()
setStandardToolBarMenuEnabled(true); setStandardToolBarMenuEnabled(true);
setupActions(); setupActions();
createGUI(m_part); #warning port
setXMLFile(QStringLiteral( "filelightpartui.rc" ));
// createGUI(m_part);
setCentralWidget(m_part->widget()); setCentralWidget(m_part->widget());
stateChanged(QStringLiteral( "scan_failed" )); //bah! doesn't affect the parts' actions, should I add them to the actionCollection here? stateChanged(QStringLiteral( "scan_failed" )); //bah! doesn't affect the parts' actions, should I add them to the actionCollection here?
...@@ -76,7 +79,8 @@ MainWindow::MainWindow() ...@@ -76,7 +79,8 @@ MainWindow::MainWindow()
connect(m_part, &Part::canceled, this, &MainWindow::scanFailed); connect(m_part, &Part::canceled, this, &MainWindow::scanFailed);
connect(m_part, &Part::canceled, m_histories, &HistoryCollection::stop); connect(m_part, &Part::canceled, m_histories, &HistoryCollection::stop);
connect(BrowserExtension::childObject(m_part), &KParts::BrowserExtension::openUrlNotify, this, &MainWindow::urlAboutToChange); #warning port
// connect(BrowserExtension::childObject(m_part), &KParts::BrowserExtension::openUrlNotify, this, &MainWindow::urlAboutToChange);
const KConfigGroup config = KSharedConfig::openConfig()->group("general"); const KConfigGroup config = KSharedConfig::openConfig()->group("general");
m_combo->setHistoryItems(config.readPathEntry("comboHistory", QStringList())); m_combo->setHistoryItems(config.readPathEntry("comboHistory", QStringList()));
...@@ -154,7 +158,7 @@ void MainWindow::closeEvent(QCloseEvent *event) ...@@ -154,7 +158,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
config.writePathEntry("comboHistory", m_combo->historyItems()); config.writePathEntry("comboHistory", m_combo->historyItems());
config.sync(); config.sync();
KParts::MainWindow::closeEvent(event); KXmlGuiWindow::closeEvent(event);
} }
void MainWindow::configToolbars() //slot void MainWindow::configToolbars() //slot
...@@ -163,7 +167,8 @@ void MainWindow::configToolbars() //slot ...@@ -163,7 +167,8 @@ void MainWindow::configToolbars() //slot
if (dialog.exec()) //krazy:exclude=crashy if (dialog.exec()) //krazy:exclude=crashy
{ {
createGUI(m_part); #warning port
// createGUI(m_part);
applyMainWindowSettings(KSharedConfig::openConfig()->group("window")); applyMainWindowSettings(KSharedConfig::openConfig()->group("window"));
} }
} }
......
...@@ -35,7 +35,7 @@ namespace Filelight { ...@@ -35,7 +35,7 @@ namespace Filelight {
class Part; class Part;
class MainWindow : public KParts::MainWindow class MainWindow : public KXmlGuiWindow // Maybe use qmainwindow
{ {
Q_OBJECT Q_OBJECT
......
...@@ -50,37 +50,26 @@ ...@@ -50,37 +50,26 @@
namespace Filelight { namespace Filelight {
K_PLUGIN_FACTORY(filelightPartFactory, registerPlugin<Part>();) // produce a factory
BrowserExtension::BrowserExtension(Part *parent) BrowserExtension::BrowserExtension(Part *parent)
: KParts::BrowserExtension(parent) // : KParts::BrowserExtension(parent)
: QObject(parent)
{} {}
Part::Part(QWidget *parentWidget, QObject *parent, const QList<QVariant>&) Part::Part(QWidget *parentWidget, QObject *parent, const QList<QVariant>&)
: ReadOnlyPart(parent) // : ReadOnlyPart(parent)
: QObject(parent)
, m_summary(0) , m_summary(0)
, m_ext(new BrowserExtension(this)) , m_ext(new BrowserExtension(this))
, m_statusbar(new StatusBarExtension(this)) , m_statusbar(new StatusBarExtension(this))
, m_map(0) , m_map(0)
, m_started(false) , m_started(false)
, m_widget(nullptr)
{ {
Config::read(); Config::read();
KAboutData aboutData( // Q_ASSERT(false); // todo
QStringLiteral("filelightpart"), // setXMLFile(QStringLiteral( "filelightpartui.rc" ));
i18n(APP_PRETTYNAME),
QStringLiteral(APP_VERSION),
i18n("Displays file usage in an easy to understand way."),
KAboutLicense::GPL,
i18n("(c) 2002-2004 Max Howell\n"
"(c) 2008-2014 Martin T. Sandsmark"),
QString(),
QStringLiteral("http://utils.kde.org/projects/filelight"),
QStringLiteral("martin.sandsmark@kde.org"));
setComponentData(aboutData);
setXMLFile(QStringLiteral( "filelightpartui.rc" ));
QScrollArea *scrollArea = new QScrollArea(parentWidget); QScrollArea *scrollArea = new QScrollArea(parentWidget);
scrollArea->setWidgetResizable(true); scrollArea->setWidgetResizable(true);
...@@ -107,12 +96,14 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QList<QVariant>&) ...@@ -107,12 +96,14 @@ Part::Part(QWidget *parentWidget, QObject *parent, const QList<QVariant>&)
m_numberOfFiles = new QLabel(); m_numberOfFiles = new QLabel();
m_statusbar->addStatusBarItem(m_numberOfFiles, 0, true); m_statusbar->addStatusBarItem(m_numberOfFiles, 0, true);
KStandardAction::zoomIn(m_map, SLOT(zoomIn()), actionCollection()); #warning port
KStandardAction::zoomOut(m_map, SLOT(zoomOut()), actionCollection()); // Q_ASSERT(false); // todo
QAction *action = actionCollection()->addAction(QStringLiteral("configure_filelight")); // KStandardAction::zoomIn(m_map, SLOT(zoomIn()), actionCollection());
action->setText(i18n("Configure Filelight...")); // KStandardAction::zoomOut(m_map, SLOT(zoomOut()), actionCollection());
action->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); // QAction *action = actionCollection()->addAction(QStringLiteral("configure_filelight"));
connect(action, &QAction::triggered, this, &Part::configFilelight); // action->setText(i18n("Configure Filelight..."));
// action->setIcon(QIcon::fromTheme(QStringLiteral("configure")));
// connect(action, &QAction::triggered, this, &Part::configFilelight);
connect(m_map, &RadialMap::Widget::folderCreated, this, static_cast<void (Part::*)()>(&Part::completed)); connect(m_map, &RadialMap::Widget::folderCreated, this, static_cast<void (Part::*)()>(&Part::completed));
connect(m_map, &RadialMap::Widget::folderCreated, this, &Part::mapChanged); connect(m_map, &RadialMap::Widget::folderCreated, this, &Part::mapChanged);
...@@ -203,7 +194,9 @@ Part::closeUrl() ...@@ -203,7 +194,9 @@ Part::closeUrl()
showSummary(); showSummary();
return ReadOnlyPart::closeUrl(); Q_ASSERT(false); // todo
return false;
// return ReadOnlyPart::closeUrl();
} }
QString Part::prettyUrl() const { QString Part::prettyUrl() const {
...@@ -227,6 +220,32 @@ Part::updateURL(const QUrl &u) ...@@ -227,6 +220,32 @@ Part::updateURL(const QUrl &u)
setUrl(u); setUrl(u);
} }
QUrl Part::url() const
{
return m_url;
}
void Part::setUrl(const QUrl &url)
{
m_url = url;
}
void Part::stateChanged(const QString &state)
{
#warning port this calls xmlguiclient::stateChanged in parts
// Q_ASSERT(false);
}
void Part::setWidget(QWidget *widget)
{
m_widget = widget;
}
QWidget *Part::widget() const
{
return m_widget;
}
void void
Part::configFilelight() Part::configFilelight()
{ {
...@@ -330,6 +349,10 @@ Part::mapChanged(const Folder *tree) ...@@ -330,6 +349,10 @@ Part::mapChanged(const Folder *tree)
m_numberOfFiles->setText(text); m_numberOfFiles->setText(text);
} }
QStatusBar *Part::statusBar() {
return m_statusbar->statusBar();
}
void void
Part::showSummary() Part::showSummary()
{ {
...@@ -350,3 +373,31 @@ bool Filelight::Part::openFile() { ...@@ -350,3 +373,31 @@ bool Filelight::Part::openFile() {
} //namespace Filelight } //namespace Filelight
#include "part.moc" #include "part.moc"
StatusBarExtension::StatusBarExtension(QObject *parent)
: QObject(parent)
, m_statusBar(new QStatusBar)
{
}
StatusBarExtension::~StatusBarExtension()
{
delete m_statusBar;
}
QStatusBar *StatusBarExtension::statusBar() const
{
return m_statusBar;
}
void StatusBarExtension::addStatusBarItem(QWidget *widget, int stretch, bool permanent)
{
// Q_ASSERT(false);
#warning port
}
void StatusBarExtension::removeStatusBarItem(QWidget *widget)
{
// Q_ASSERT(false);
#warning port
}
...@@ -29,7 +29,23 @@ ...@@ -29,7 +29,23 @@
#include <QLabel> #include <QLabel>
using KParts::StatusBarExtension; // COMPAT
//using KParts::StatusBarExtension;
class StatusBarExtension : public QObject
{
Q_OBJECT
public:
StatusBarExtension(QObject *parent = nullptr);
~StatusBarExtension();
QStatusBar *statusBar() const;
void addStatusBarItem(QWidget *widget, int stretch, bool permanent);
void removeStatusBarItem(QWidget *widget);
private:
QStatusBar *m_statusBar;
};
namespace RadialMap { namespace RadialMap {
class Widget; class Widget;
} }
...@@ -41,16 +57,26 @@ namespace Filelight ...@@ -41,16 +57,26 @@ namespace Filelight
class Part; class Part;
class SummaryWidget; class SummaryWidget;
class BrowserExtension : public KParts::BrowserExtension
// COMPAT
class BrowserExtension : public
// KParts::BrowserExtension
QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit BrowserExtension(Part*); explicit BrowserExtension(Part*);
signals:
void openUrlNotify();
void setLocationBarUrl(QString);
}; };
class Part : public KParts::ReadOnlyPart class Part : public
// KParts::ReadOnlyPart
QObject
{ {
Q_OBJECT Q_OBJECT
...@@ -62,6 +88,12 @@ public: ...@@ -62,6 +88,12 @@ public:
QString prettyUrl() const; QString prettyUrl() const;
signals:
void started(KJob *);
void completed();
void canceled(QString);
void setWindowCaption(QString);
public slots: public slots:
virtual bool openUrl(const QUrl&); virtual bool openUrl(const QUrl&);
void configFilelight(); void configFilelight();
...@@ -73,9 +105,7 @@ private slots: ...@@ -73,9 +105,7 @@ private slots:
void mapChanged(const Folder*); void mapChanged(const Folder*);
private: private:
QStatusBar *statusBar() { QStatusBar *statusBar();
return m_statusbar->statusBar();
}
void showSummary(); void showSummary();
QLayout *m_layout; QLayout *m_layout;
...@@ -94,6 +124,18 @@ private: ...@@ -94,6 +124,18 @@ private:
private slots: private slots:
void updateURL(const QUrl &); void updateURL(const QUrl &);
// Compat
public:
QUrl url() const;
QWidget *widget() const;
private:
void setUrl(const QUrl &url);
void stateChanged(const QString &state);
void setWidget(QWidget *widget);
QWidget *m_widget = nullptr;
QUrl m_url;
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment