Commit 301cfdc7 authored by Silvio Heinrich's avatar Silvio Heinrich

Add image docker again to master. Was removed... Why??

parent 06e5c4cd
......@@ -6,3 +6,4 @@ add_subdirectory(advancedcolorselector)
add_subdirectory(presetdocker)
add_subdirectory(historydocker)
add_subdirectory(channeldocker)
add_subdirectory(imagedocker)
\ No newline at end of file
set(kritaimagedocker_PART_SRCS
imagedocker.cpp
imagedocker_dock.cpp
kis_image_strip_scene.cpp
kis_image_view.cpp
)
kde4_add_ui_files(kritaimagedocker_PART_SRCS forms/wdgimagedocker.ui forms/wdgImageViewPopup.ui)
kde4_add_plugin(kritaimagedocker ${kritaimagedocker_PART_SRCS})
target_link_libraries(kritaimagedocker kritaui)
install(TARGETS kritaimagedocker DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES kritaimagedocker.desktop DESTINATION ${SERVICES_INSTALL_DIR})
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>wdgImageViewPopup</class>
<widget class="QWidget" name="wdgImageViewPopup">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>340</width>
<height>59</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="bnZoomFit">
<property name="text">
<string>Fit</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="autoDefault">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bnZoomAdjust">
<property name="text">
<string>Adjust</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bnZoom100">
<property name="text">
<string>100%</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bnZoom75">
<property name="text">
<string>75%</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bnZoom50">
<property name="text">
<string>50%</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bnZoom25">
<property name="text">
<string>25%</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="KisSliderSpinBox" name="zoomSlider" native="true"/>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KisSliderSpinBox</class>
<extends>QWidget</extends>
<header location="global">kis_slider_spin_box.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>wdgImageDocker</class>
<widget class="QWidget" name="wdgImageDocker">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>399</width>
<height>300</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="tabPosition">
<enum>QTabWidget::North</enum>
</property>
<property name="tabShape">
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<property name="elideMode">
<enum>Qt::ElideNone</enum>
</property>
<property name="usesScrollButtons">
<bool>true</bool>
</property>
<property name="documentMode">
<bool>true</bool>
</property>
<property name="tabsClosable">
<bool>false</bool>
</property>
<widget class="QWidget" name="imgBrowserTab">
<attribute name="title">
<string>Browse</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QComboBox" name="cmbPath">
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="bnBack">
<property name="text">
<string>Back</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="bnUp">
<property name="text">
<string>Up</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="bnHome">
<property name="text">
<string>Home</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTreeView" name="treeView">
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="rootIsDecorated">
<bool>true</bool>
</property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="itemsExpandable">
<bool>true</bool>
</property>
<property name="expandsOnDoubleClick">
<bool>false</bool>
</property>
<attribute name="headerVisible">
<bool>true</bool>
</attribute>
<attribute name="headerCascadingSectionResizes">
<bool>false</bool>
</attribute>
<attribute name="headerDefaultSectionSize">
<number>200</number>
</attribute>
<attribute name="headerHighlightSections">
<bool>false</bool>
</attribute>
<attribute name="headerStretchLastSection">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout>
</widget>
<widget class="QGraphicsView" name="thumbView">
<property name="minimumSize">
<size>
<width>50</width>
<height>50</height>
</size>
</property>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="imgViewTab">
<attribute name="title">
<string>Images</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,1">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,1,0,0,0">
<item>
<widget class="KisPopupButton" name="bnPopup">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="flat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="cmbImg">
<property name="frame">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="bnImgPrev">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Prev</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="bnImgNext">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Next</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="bnImgClose">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Close</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="KisImageView" name="imgView">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KisImageView</class>
<extends>QFrame</extends>
<header>kis_image_view.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>KisPopupButton</class>
<extends>QPushButton</extends>
<header location="global">kis_popup_button.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
/*
* Copyright (c) 2011 Silvio Heinrich <plassy@web.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2 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 Lesser 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 "imagedocker.h"
#include "imagedocker_dock.h"
#include <kpluginfactory.h>
#include <klocale.h>
#include <KoDockFactoryBase.h>
#include <KoDockRegistry.h>
K_PLUGIN_FACTORY(ImageDockerPluginFactory, registerPlugin<ImageDockerPlugin>();)
K_EXPORT_PLUGIN(ImageDockerPluginFactory("krita"))
class ImageDockerDockFactory: public KoDockFactoryBase {
public:
ImageDockerDockFactory() { }
virtual QString id() const
{
return QString("ImageDocker");
}
virtual Qt::DockWidgetArea defaultDockWidgetArea() const
{
return Qt::RightDockWidgetArea;
}
virtual QDockWidget* createDockWidget()
{
ImageDockerDock* dockWidget = new ImageDockerDock();
dockWidget->setObjectName(id());
return dockWidget;
}
DockPosition defaultDockPosition() const
{
return DockMinimized;
}
};
ImageDockerPlugin::ImageDockerPlugin(QObject* parent, const QVariantList&):
QObject(parent)
{
KoDockRegistry::instance()->add(new ImageDockerDockFactory());
}
/*
* Copyright (c) 2011 Silvio Heinrich <plassy@web.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2 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 Lesser 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 H_IMAGEDOCKER_H_
#define H_IMAGEDOCKER_H_
#include <QObject>
#include <QVariantList>
class ImageDockerPlugin: public QObject
{
Q_OBJECT
public:
ImageDockerPlugin(QObject* parent, const QVariantList&);
};
#endif // H_IMAGEDOCKER_H_
/*
* Copyright (c) 2011 Silvio Heinrich <plassy@web.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2 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 Lesser 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 H_IMAGEDOCKER_DOCK_H_
#define H_IMAGEDOCKER_DOCK_H_
#include <QDockWidget>
#include <KoCanvasObserverBase.h>
#include <QStringList>
#include <QPixmap>
#include <QMap>
class QModelIndex;
class QFileSystemModel;
class QButtonGroup;
class KoCanvasBase;
class ImageFilter;
class KisImageStripScene;
class ImageListModel;
struct ImageDockerUI;
struct PopupWidgetUI;
class ImageDockerDock: public QDockWidget, public KoCanvasObserverBase
{
Q_OBJECT
struct ImageInfo
{
qint64 id;
int viewMode;
QString path;
QString name;
float scale;
QPixmap pixmap;
QPoint scrollPos;
};
typedef QMap<qint64,ImageInfo>::iterator ImageInfoIter;
public:
ImageDockerDock();
virtual ~ImageDockerDock();
virtual void setCanvas(KoCanvasBase* canvas);
virtual void unsetCanvas() { m_canvas = 0; }
private slots:
void slotItemDoubleClicked(const QModelIndex& index);
void slotBackButtonClicked();
void slotUpButtonClicked();
void slotHomeButtonClicked();
void slotCloseCurrentImage();
void slotNextImage();
void slotPrevImage();
void slotOpenImage(const QString& path);
void slotImageChoosenFromComboBox(int index);
void slotZoomChanged(int zoom);
void slotColorSelected(const QColor& color);
void slotDockLocationChanged(Qt::DockWidgetArea area);
void slotTopLevelChanged(bool topLevel);
void slotViewModeChanged(int viewMode, qreal scale);
void slotCloseZoomPopup();
private:
void addCurrentPathToHistory();
void updatePath(const QString& path);
qint64 generateImageID() const;
void setCurrentImage(qint64 imageID);
bool isImageLoaded() const { return m_currImageID != -1; }
void setZoom(const ImageInfo& info);
private:
QFileSystemModel* m_model;
QButtonGroup* m_zoomButtons;
KoCanvasBase* m_canvas;
ImageFilter* m_proxyModel;
ImageListModel* m_imgListModel;
QStringList m_history;
KisImageStripScene* m_thumbModel;
ImageDockerUI* m_ui;
PopupWidgetUI* m_popupUi;
QMap<qint64,ImageInfo> m_imgInfoMap;
qint64 m_currImageID;
};
#endif // H_IMAGEDOCKER_DOCK_H_
/*
* Copyright (c) 2011 Silvio Heinrich <plassy@web.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2 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 Lesser 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 "kis_image_strip_scene.h"
#include <QDir>
#include <QPainter>
#include <QHash>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsLinearLayout>
#include <QGraphicsWidget>
#include <QMutexLocker>
#include <QIcon>
/////////////////////////////////////////////////////////////////////////////////////////////
// ------------- KisImageLoader ---------------------------------------------------------- //
void KisImageLoader::run()
{
typedef QHash<KisImageItem*,Data>::iterator Iterator;
QImageReader reader;
for(Iterator data=m_data.begin(); data!=m_data.end() && m_run; ++data) {
reader.setFileName(data->path);
qreal w = m_size;
qreal h = m_size;
if(reader.supportsOption(QImageIOHandler::Size)) {
QSizeF imgSize = reader.size();
if(imgSize.width() > imgSize.height()) {
qreal div = m_size / imgSize.width();
h = imgSize.height() * div;
}
else {
qreal div = m_size / imgSize.height();
w = imgSize.width() * div;
}
}
reader.setScaledSize(QSize(w,h));
data->image = reader.read();
data->isLoaded = true;
emit sigItemContentChanged(data.key());
}
}
/////////////////////////////////////////////////////////////////////////////////////////////
// ------------- KisImageItem ------------------------------------------------------------ //
void KisImageItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
Q_UNUSED(option);
Q_UNUSED(widget);
if(m_loader->isImageLoaded(this)) {
QImage image = m_loader->getImage(this);
if(!image.isNull()) {
QPointF offset((m_size-image.width()) / 2.0, (m_size-image.height()) / 2.0);
painter->drawImage(offset, image);
}
else {
QIcon icon = QIcon::fromTheme("image-missing");
QRect rect = boundingRect().toRect();
QPixmap img = icon.pixmap(rect.size());
painter->drawPixmap(rect, img, img.rect());
}
}
else {
QIcon icon = QIcon::fromTheme("image-loading");
QRect rect = boundingRect().toRect();
QPixmap img = icon.pixmap(rect.size());
painter->drawPixmap(rect, img, img.rect());
}
if(isSelected())
painter->fillRect(boundingRect(), Qt::Dense5Pattern);
painter->drawRect(boundingRect());
}
QSizeF KisImageItem::sizeHint(Qt::SizeHint which, const QSizeF& constraint) const
{
return QSizeF(m_size, m_size);