Commit f4fee423 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Make it possible to show the pointer position label

Set EnablePositionLabel to true in kritarc's main section, and
the statusbar will show the coordinates.
parent 2385e198
......@@ -411,10 +411,13 @@ void KisViewManager::setCurrentView(KisView *view)
// Wait for the async image to have loaded
KisDocument* doc = view->document();
// connect(d->currentImageView->canvasController()->proxyObject,
// SIGNAL(documentMousePositionChanged(QPointF)),
// &d->statusBar,
// SLOT(documentMousePositionChanged(QPointF)));
if (KisConfig(true).readEntry<bool>("EnablePositionLabel", false)) {
connect(d->currentImageView->canvasController()->proxyObject,
SIGNAL(documentMousePositionChanged(QPointF)),
&d->statusBar,
SLOT(documentMousePositionChanged(QPointF)));
}
// Restore the last used brush preset, color and background color.
if (first) {
......@@ -569,16 +572,6 @@ KisStatusBar * KisViewManager::statusBar() const
return &d->statusBar;
}
void KisViewManager::addStatusBarItem(QWidget *widget, int stretch, bool permanent)
{
d->statusBar.addStatusBarItem(widget, stretch, permanent);
}
void KisViewManager::removeStatusBarItem(QWidget *widget)
{
d->statusBar.removeStatusBarItem(widget);
}
KisPaintopBox* KisViewManager::paintOpBox() const
{
return d->controlFrame.paintopBox();
......
......@@ -98,21 +98,6 @@ public: // Krita specific interfaces
/// Return the wrapper class around the statusbar
KisStatusBar *statusBar() const;
/**
* This adds a widget to the statusbar for this view.
* If you use this method instead of using statusBar() directly,
* KisView will take care of removing the items when the view GUI is deactivated
* and readding them when it is reactivated.
* The parameters are the same as QStatusBar::addWidget().
*/
void addStatusBarItem(QWidget * widget, int stretch = 0, bool permanent = false);
/**
* Remove a widget from the statusbar for this view.
*/
void removeStatusBarItem(QWidget * widget);
KisPaintopBox* paintOpBox() const;
/// create a new progress updater
......
......@@ -35,7 +35,6 @@
#include "kis_selection.h"
#include "kis_node_commands_adapter.h"
#include "kis_group_layer.h"
#include "kis_statusbar.h"
#include "kis_progress_widget.h"
#include "kis_config.h"
#include "KisPart.h"
......
......@@ -33,7 +33,10 @@
#include <KoColorProfile.h>
#include <KoColorSpace.h>
#include "kis_icon_utils.h"
#include <KoToolManager.h>
#include <KoViewConverter.h>
#include <kis_icon_utils.h>
#include <kis_types.h>
#include <kis_image.h>
......@@ -42,46 +45,47 @@
#include <kis_selection_manager.h>
#include "kis_memory_statistics_server.h"
#include <KisView.h>
#include "KisView.h"
#include "KisViewManager.h"
#include "canvas/kis_canvas2.h"
#include "kis_progress_widget.h"
#include "kis_zoom_manager.h"
#include <KoToolManager.h>
#include <KoViewConverter.h>
#include <KisMainWindow.h>
#include "KisMainWindow.h"
#include "kis_config.h"
enum {
IMAGE_SIZE_ID,
POINTER_POSITION_ID
};
KisStatusBar::KisStatusBar(KisViewManager *view)
: m_view(view),
m_imageView(0),
m_statusBar(0)
KisStatusBar::KisStatusBar(KisViewManager *viewManager)
: m_viewManager(viewManager)
, m_imageView(0)
, m_statusBar(0)
{
}
void KisStatusBar::setup()
{
m_selectionStatus = new QToolButton();
m_selectionStatus->setObjectName("selection status");
m_selectionStatus->setIconSize(QSize(16,16));
m_selectionStatus->setAutoRaise(true);
m_selectionStatus->setEnabled(false);
updateSelectionIcon();
m_statusBar = m_view->mainWindow()->statusBar();
m_statusBar = m_viewManager->mainWindow()->statusBar();
connect(m_selectionStatus, SIGNAL(clicked()), m_view->selectionManager(), SLOT(slotToggleSelectionDecoration()));
connect(m_view->selectionManager(), SIGNAL(displaySelectionChanged()), SLOT(updateSelectionToolTip()));
connect(m_view->mainWindow(), SIGNAL(themeChanged()), this, SLOT(updateSelectionIcon()));
connect(m_selectionStatus, SIGNAL(clicked()), m_viewManager->selectionManager(), SLOT(slotToggleSelectionDecoration()));
connect(m_viewManager->selectionManager(), SIGNAL(displaySelectionChanged()), SLOT(updateSelectionToolTip()));
connect(m_viewManager->mainWindow(), SIGNAL(themeChanged()), this, SLOT(updateSelectionIcon()));
addStatusBarItem(m_selectionStatus);
m_selectionStatus->setVisible(false);
m_statusBarStatusLabel = new KSqueezedTextLabel();
m_statusBarStatusLabel->setObjectName("statsBarStatusLabel");
m_statusBarStatusLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
m_statusBarStatusLabel->setContentsMargins(5, 5, 5, 5);
connect(KoToolManager::instance(), SIGNAL(changedStatusText(const QString &)),
......@@ -90,12 +94,14 @@ void KisStatusBar::setup()
m_statusBarStatusLabel->setVisible(false);
m_statusBarProfileLabel = new KSqueezedTextLabel();
m_statusBarProfileLabel->setObjectName("statsBarProfileLabel");
m_statusBarProfileLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
m_statusBarProfileLabel->setContentsMargins(5, 5, 5, 5);
addStatusBarItem(m_statusBarProfileLabel, 3);
m_statusBarProfileLabel->setVisible(false);
m_progress = new KisProgressWidget();
m_progress->setObjectName("ProgressBar");
addStatusBarItem(m_progress);
m_progress->setVisible(false);
connect(m_progress, SIGNAL(sigCancellationRequested()), this, SIGNAL(sigCancellationRequested()));
......@@ -104,6 +110,7 @@ void KisStatusBar::setup()
m_progressUpdater->setAutoNestNames(true);
m_memoryReportBox = new QPushButton();
m_memoryReportBox->setObjectName("memoryReportBox");
m_memoryReportBox->setFlat(true);
m_memoryReportBox->setContentsMargins(5, 5, 5, 5);
m_memoryReportBox->setMinimumWidth(120);
......@@ -113,6 +120,7 @@ void KisStatusBar::setup()
connect(m_memoryReportBox, SIGNAL(clicked()), SLOT(showMemoryInfoToolTip()));
m_pointerPositionLabel = new QLabel(QString());
m_pointerPositionLabel->setObjectName("pointerPositionLabel");
m_pointerPositionLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_pointerPositionLabel->setMinimumWidth(100);
m_pointerPositionLabel->setContentsMargins(5,5, 5, 5);
......@@ -165,9 +173,6 @@ void KisStatusBar::addStatusBarItem(QWidget *widget, int stretch, bool permanent
else {
m_statusBar->addWidget(widget, stretch);
}
sbItem.show();
m_statusBarItems.append(sbItem);
}
......@@ -207,8 +212,8 @@ void KisStatusBar::documentMousePositionChanged(const QPointF &pos)
QPoint pixelPos = m_imageView->image()->documentToImagePixelFloored(pos);
pixelPos.setX(qBound(0, pixelPos.x(), m_view->image()->width() - 1));
pixelPos.setY(qBound(0, pixelPos.y(), m_view->image()->height() - 1));
pixelPos.setX(qBound(0, pixelPos.x(), m_viewManager->image()->width() - 1));
pixelPos.setY(qBound(0, pixelPos.y(), m_viewManager->image()->height() - 1));
m_pointerPositionLabel->setText(QString("%1, %2").arg(pixelPos.x()).arg(pixelPos.y()));
}
......@@ -234,9 +239,9 @@ void KisStatusBar::imageSizeChanged()
void KisStatusBar::updateSelectionIcon()
{
QIcon icon;
if (!m_view->selectionManager()->displaySelection()) {
if (!m_viewManager->selectionManager()->displaySelection()) {
icon = KisIconUtils::loadIcon("selection-mode_invisible");
} else if (m_view->selectionManager()->showSelectionAsMask()) {
} else if (m_viewManager->selectionManager()->showSelectionAsMask()) {
icon = KisIconUtils::loadIcon("selection-mode_mask");
} else /* if (!m_view->selectionManager()->showSelectionAsMask()) */ {
icon = KisIconUtils::loadIcon("selection-mode_ants");
......@@ -315,16 +320,16 @@ void KisStatusBar::updateSelectionToolTip()
{
updateSelectionIcon();
KisSelectionSP selection = m_view->selection();
KisSelectionSP selection = m_viewManager->selection();
if (selection) {
m_selectionStatus->setEnabled(true);
QRect r = selection->selectedExactRect();
QString displayMode =
!m_view->selectionManager()->displaySelection() ?
!m_viewManager->selectionManager()->displaySelection() ?
i18n("Hidden") :
(m_view->selectionManager()->showSelectionAsMask() ?
(m_viewManager->selectionManager()->showSelectionAsMask() ?
i18n("Mask") : i18n("Ants"));
m_selectionStatus->setToolTip(
......@@ -350,7 +355,6 @@ void KisStatusBar::setProfile(KisImageWSP image)
}
if (!image) return;
if (image->profile() == 0) {
m_statusBarProfileLabel->setText(i18n("No profile"));
} else {
......
......@@ -76,13 +76,11 @@ class KRITAUI_EXPORT KisStatusBar : public QObject
public:
KisStatusBar(KisViewManager *view);
explicit KisStatusBar(KisViewManager *view);
~KisStatusBar() override;
void setup();
void setView(QPointer<KisView> imageView);
void addStatusBarItem(QWidget *widget, int stretch = 0, bool permanent = false);
void removeStatusBarItem(QWidget *widget);
void hideAllStatusBarItems();
void showAllStatusBarItems();
......@@ -110,11 +108,14 @@ Q_SIGNALS:
void memoryStatusUpdated();
private:
void removeStatusBarItem(QWidget *widget);
void addStatusBarItem(QWidget *widget, int stretch = 0, bool permanent = false);
void updateMemoryStatus();
private:
QPointer<KisViewManager> m_view;
QPointer<KisViewManager> m_viewManager;
QPointer<KisView> m_imageView;
QPointer<QStatusBar> m_statusBar;
KisProgressWidget *m_progress;
......@@ -127,7 +128,6 @@ private:
KSqueezedTextLabel *m_statusBarStatusLabel;
KSqueezedTextLabel *m_statusBarProfileLabel;
QString m_shortMemoryTag;
QString m_longMemoryTag;
QIcon m_memoryStatusIcon;
......
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