Commit ee5f1f6e authored by Jouni Pentikäinen's avatar Jouni Pentikäinen

Remove experimental code

This commit removes the paging docker and quick layout chooser dropdown.
These were merely proofs of concept, and never meant to go into master.
parent 29ad1486
......@@ -272,8 +272,6 @@ set(kritaui_LIB_SRCS
widgets/KoStrokeConfigWidget.cpp
widgets/KoFillConfigWidget.cpp
widgets/KisLayoutSelector.cpp
utils/kis_document_aware_spin_box_unit_manager.cpp
......
......@@ -39,8 +39,6 @@ struct KisWindowLayoutManager::Private {
bool primaryWorkspaceFollowsFocus{false};
QUuid primaryWindow;
QString lastLayoutName;
QVector<DisplayLayout*> displayLayouts;
void loadDisplayLayouts() {
......@@ -209,16 +207,8 @@ void KisWindowLayoutManager::slotFocusChanged(QWidget *old, QWidget *now)
newMainWindow->windowFocused();
}
QString KisWindowLayoutManager::lastLayoutName()
{
return d->lastLayoutName;
}
void KisWindowLayoutManager::setLastUsedLayout(const KisWindowLayoutResource *layout)
{
// For layout selector, accept both window layouts and sessions
d->lastLayoutName = layout->name();
// For automatic switching, only allow a window layout proper
auto *session = dynamic_cast<const KisSessionResource*>(layout);
if (session) return;
......
......@@ -71,11 +71,6 @@ public:
void activeDocumentChanged(KisDocument *document);
/**
* The name of the last activated window layout or session.
* Used by the layout selector.
*/
QString lastLayoutName();
void setLastUsedLayout(const KisWindowLayoutResource *layout);
private Q_SLOTS:
......
......@@ -60,7 +60,6 @@
#include <kis_node.h>
#include <brushengine/kis_paintop_config_widget.h>
#include <kis_action.h>
#include <KisLayoutSelector.h>
#include "kis_canvas2.h"
#include "kis_node_manager.h"
......@@ -391,11 +390,6 @@ KisPaintopBox::KisPaintopBox(KisViewManager *view, QWidget *parent, const char *
action->setDefaultWidget(mirrorActions);
view->actionCollection()->addAction("mirror_actions", action);
action = new QWidgetAction(this);
KisActionRegistry::instance()->propertizeAction("select_layout", action);
view->actionCollection()->addAction("select_layout", action);
action->setDefaultWidget(new KisLayoutSelector(this));
action = new QWidgetAction(this);
KisActionRegistry::instance()->propertizeAction("workspaces", action);
view->actionCollection()->addAction("workspaces", action);
......
/*
* Copyright (c) 2018 Jouni Pentikäinen <joupent@gmail.com>
*
* 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 <KisWindowLayoutResource.h>
#include <KisResourceServerProvider.h>
#include <KisWindowLayoutManager.h>
#include "KisLayoutSelector.h"
#include "KisSessionResource.h"
struct KisLayoutSelector::Private {
enum ItemTypes {
WindowLayout,
Session
};
KoResourceServer<KisWindowLayoutResource> * windowLayoutServer;
KoResourceServer<KisSessionResource> * sessionServer;
bool blockChange = false;
};
KisLayoutSelector::KisLayoutSelector(QWidget *parent)
: QComboBox(parent)
, d(new Private)
{
d->windowLayoutServer = KisResourceServerProvider::instance()->windowLayoutServer();
d->sessionServer = KisResourceServerProvider::instance()->sessionServer();
connect(this, SIGNAL(activated(int)), this, SLOT(slotItemChanged(int)));
updateItems();
}
KisLayoutSelector::~KisLayoutSelector() {}
void KisLayoutSelector::updateItems() {
d->blockChange = true;
clear();
Q_FOREACH(KisWindowLayoutResource *windowLayout, d->windowLayoutServer->resources()) {
addItem(windowLayout->name(), Private::WindowLayout);
}
Q_FOREACH(KisSessionResource *session, d->sessionServer->resources()) {
addItem(session->name(), Private::Session);
}
const QString &lastLayout = KisWindowLayoutManager::instance()->lastLayoutName();
if (!lastLayout.isEmpty()) {
int index = findText(lastLayout);
if (index >=0) setCurrentIndex(index);
}
d->blockChange = false;
}
void KisLayoutSelector::slotItemChanged(int index)
{
if (index < 0) return;
if (d->blockChange) return;
const QString name = itemText(index);
switch (currentData(Qt::UserRole).toInt()) {
case Private::WindowLayout: {
KisWindowLayoutResource *windowLayout = d->windowLayoutServer->resourceByName(name);
if (windowLayout) {
windowLayout->applyLayout();
}
} break;
case Private::Session: {
KisSessionResource *session = d->sessionServer->resourceByName(name);
if (session) {
session->restore();
}
} break;
default:
qDebug() << "Unexpected item type in KisLayoutSelector.";
break;
}
}
/*
* Copyright (c) 2018 Jouni Pentikäinen <joupent@gmail.com>
*
* 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.
*/
#ifndef KISLAYOUTSELECTOR_H
#define KISLAYOUTSELECTOR_H
#include <QComboBox>
class KisLayoutSelector : public QComboBox
{
Q_OBJECT
public:
KisLayoutSelector(QWidget *parent = 0);
~KisLayoutSelector();
private Q_SLOTS:
void slotItemChanged(int);
private:
void updateItems();
struct Private;
QScopedPointer<Private> d;
};
#endif
......@@ -22,7 +22,6 @@ add_subdirectory(animation)
add_subdirectory(presethistory)
add_subdirectory(svgcollectiondocker)
add_subdirectory(histogram)
add_subdirectory(pager)
if(HAVE_QT_QUICK)
add_subdirectory(touchdocker)
option(ENABLE_CPU_THROTTLE "Build the CPU Throttle Docker" OFF)
......
set(KRITA_PAGERDOCKER_SOURCES PagerDockerPlugin.cpp PagerDockerDock.cpp)
add_library(kritapagerdocker MODULE ${KRITA_PAGERDOCKER_SOURCES})
target_link_libraries(kritapagerdocker kritaui)
install(TARGETS kritapagerdocker DESTINATION ${KRITA_PLUGIN_INSTALL_DIR})
/*
* Copyright (c) 2018 Jouni Pentikäinen <joupent@gmail.com>
*
* 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 "PagerDockerDock.h"
#include <QHBoxLayout>
#include <QPushButton>
#include <QDir>
#include <kis_canvas2.h>
#include <KisDocument.h>
#include <KisPart.h>
#include <QtWidgets/QtWidgets>
PagerDockerDock::PagerDockerDock()
: QDockWidget(i18n("Pager"))
{
auto *widget = new QWidget(this);
setWidget(widget);
auto *layout = new QHBoxLayout(widget);
widget->setLayout(layout);
auto *nextButton = new QPushButton(">>", widget);
auto *previousButton = new QPushButton("<<", widget);
layout->addWidget(previousButton);
layout->addWidget(nextButton);
connect(nextButton, SIGNAL(clicked()), this, SLOT(slotNextPage()));
connect(previousButton, SIGNAL(clicked()), this, SLOT(slotPreviousPage()));
}
PagerDockerDock::~PagerDockerDock() {}
void PagerDockerDock::setCanvas(KoCanvasBase *canvas)
{
m_canvas = qobject_cast<KisCanvas2*>(canvas);
}
void PagerDockerDock::unsetCanvas()
{
m_canvas = nullptr;
}
void PagerDockerDock::slotNextPage()
{
flipPage(true);
}
void PagerDockerDock::slotPreviousPage()
{
flipPage(false);
}
void PagerDockerDock::flipPage(bool forward)
{
if (!m_canvas) return;
KisDocument *activeDocument = m_canvas->imageView()->document();
QUrl url = activeDocument->url();
if (url.isEmpty() || !url.isLocalFile()) return;
QFileInfo fileInfo(url.toLocalFile());
QDir directory = fileInfo.absoluteDir();
QStringList openSiblingFiles = getOpenFilesInDirectory(directory.path());
QStringList allSiblingFiles = getKraFilesInDirectory(directory);
int step = chooseStepSize(fileInfo.fileName(), openSiblingFiles, allSiblingFiles, forward);
if (step == 0) return;
pageViews(directory, allSiblingFiles, step);
}
QStringList PagerDockerDock::getOpenFilesInDirectory(const QString &path)
{
QStringList openSiblingFiles;
Q_FOREACH(KisDocument *document, KisPart::instance()->documents()) {
if (!document->url().isLocalFile()) continue;
QFileInfo docFile(document->url().toLocalFile());
if (docFile.absoluteDir() == path) {
openSiblingFiles.append(docFile.fileName());
}
}
return openSiblingFiles;
}
QStringList PagerDockerDock::getKraFilesInDirectory(QDir directory)
{
directory.setNameFilters({"*.kra"});
directory.setFilter(QDir::Files);
directory.setSorting(QDir::Name | QDir::IgnoreCase);
return directory.entryList();
}
int PagerDockerDock::chooseStepSize(const QString &baseFile,
const QStringList &openSiblingFiles, const QStringList &allSiblingFiles, bool forward) const
{
int baseIndex = allSiblingFiles.indexOf(baseFile);
if (baseIndex < 0) return 0;
int step = 1;
while (baseIndex > 0 && openSiblingFiles.contains(allSiblingFiles[baseIndex - 1])) {
baseIndex--;
}
while (baseIndex + step < allSiblingFiles.count() && openSiblingFiles.contains(allSiblingFiles[baseIndex + step])) {
step++;
}
return forward ? step : -step;
}
void PagerDockerDock::pageViews(const QDir &directory, const QStringList &allSiblingFiles, int step) const
{
QList<QPointer<KisView>> views = KisPart::instance()->views();
Q_FOREACH(KisView *view, views) {
QString newFilename = getSteppedFilename(view->document(), directory, allSiblingFiles, step);
if (!newFilename.isEmpty()) {
if (!view->queryClose()) return;
}
}
Q_FOREACH(KisView *view, views) {
QString newFilename = getSteppedFilename(view->document(), directory, allSiblingFiles, step);
if (newFilename.isEmpty()) continue;
view->mainWindow()->openDocument(QUrl::fromLocalFile(newFilename), KisMainWindow::None);
view->closeView();
}
}
QString PagerDockerDock::getSteppedFilename(const KisDocument *document, const QDir &directory,
const QStringList &allSiblingFiles, int step) const
{
QFileInfo file(document->url().toLocalFile());
if (file.absoluteDir() != directory.path()) return QString();
int index = allSiblingFiles.indexOf(file.fileName());
if (index < 0) return QString();
int newIndex = index + step;
if (newIndex < 0 || newIndex >= allSiblingFiles.size()) return QString();
return directory.filePath(allSiblingFiles[newIndex]);
}
/*
* Copyright (c) 2018 Jouni Pentikäinen <joupent@gmail.com>
*
* 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.
*/
#ifndef PAGERDOCKERDOCK_H
#define PAGERDOCKERDOCK_H
#include <QObject>
#include <QDir>
#include <QString>
#include <QDockWidget>
#include <KoCanvasObserverBase.h>
class KisDocument;
class KisCanvas2;
class PagerDockerDock : public QDockWidget, public KoCanvasObserverBase
{
Q_OBJECT
public:
PagerDockerDock();
~PagerDockerDock() override;
QString observerName() override { return "PagerDockerDock"; }
protected:
void setCanvas(KoCanvasBase *canvas) override;
void unsetCanvas() override;
private Q_SLOTS:
void slotNextPage();
void slotPreviousPage();
private:
void flipPage(bool forward);
QStringList getOpenFilesInDirectory(const QString &path);
QStringList getKraFilesInDirectory(QDir directory);
int chooseStepSize(const QString &baseFile, const QStringList &openSiblingFiles, const QStringList &allSiblingFiles, bool forward) const;
void pageViews(const QDir &directory, const QStringList &allSiblingFiles, int step) const;
QString getSteppedFilename(const KisDocument *document, const QDir &directory, const QStringList &allSiblingFiles, int step) const;
KisCanvas2 *m_canvas;
};
#endif
/*
* Copyright (c) 2018 Jouni Pentikäinen <joupent@gmail.com>
*
* 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 "PagerDockerPlugin.h"
#include <kpluginfactory.h>
#include <KoDockFactoryBase.h>
#include <KoDockRegistry.h>
#include "PagerDockerDock.h"
K_PLUGIN_FACTORY_WITH_JSON(PagerDockerPluginFactory, "krita_pagerdocker.json", registerPlugin<PagerDockerPlugin>();)
class PagerDockerDockFactory : public KoDockFactoryBase {
public:
PagerDockerDockFactory()
{}
~PagerDockerDockFactory() override {}
QString id() const override
{
return QString( "PagerDocker" );
}
virtual Qt::DockWidgetArea defaultDockWidgetArea() const
{
return Qt::RightDockWidgetArea;
}
QDockWidget* createDockWidget() override
{
PagerDockerDock * dockWidget = new PagerDockerDock();
dockWidget->setObjectName(id());
return dockWidget;
}
DockPosition defaultDockPosition() const override
{
return DockMinimized;
}
};
PagerDockerPlugin::PagerDockerPlugin(QObject *parent, const QVariantList &)
: QObject(parent)
{
KoDockRegistry::instance()->add(new PagerDockerDockFactory());
}
PagerDockerPlugin::~PagerDockerPlugin()
{}
#include "PagerDockerPlugin.moc"
/*
* Copyright (c) 2018 Jouni Pentikäinen <joupent@gmail.com>
*
* 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.
*/
#ifndef PAGERDOCKER_H
#define PAGERDOCKER_H
#include <QObject>
class PagerDockerPlugin : public QObject
{
public:
PagerDockerPlugin(QObject *parent, const QVariantList &);
~PagerDockerPlugin() override;
};
#endif
{
"Id": "Pager Docker",
"Type": "Service",
"X-KDE-Library": "kritapagerdocker",
"X-KDE-ServiceTypes": [
"Krita/Dock"
],
"X-Krita-Version": "28"
}
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