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) ...@@ -411,10 +411,13 @@ void KisViewManager::setCurrentView(KisView *view)
// Wait for the async image to have loaded // Wait for the async image to have loaded
KisDocument* doc = view->document(); KisDocument* doc = view->document();
// connect(d->currentImageView->canvasController()->proxyObject,
// SIGNAL(documentMousePositionChanged(QPointF)), if (KisConfig(true).readEntry<bool>("EnablePositionLabel", false)) {
// &d->statusBar, connect(d->currentImageView->canvasController()->proxyObject,
// SLOT(documentMousePositionChanged(QPointF))); SIGNAL(documentMousePositionChanged(QPointF)),
&d->statusBar,
SLOT(documentMousePositionChanged(QPointF)));
}
// Restore the last used brush preset, color and background color. // Restore the last used brush preset, color and background color.
if (first) { if (first) {
...@@ -569,16 +572,6 @@ KisStatusBar * KisViewManager::statusBar() const ...@@ -569,16 +572,6 @@ KisStatusBar * KisViewManager::statusBar() const
return &d->statusBar; 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 KisPaintopBox* KisViewManager::paintOpBox() const
{ {
return d->controlFrame.paintopBox(); return d->controlFrame.paintopBox();
......
...@@ -98,21 +98,6 @@ public: // Krita specific interfaces ...@@ -98,21 +98,6 @@ public: // Krita specific interfaces
/// Return the wrapper class around the statusbar /// Return the wrapper class around the statusbar
KisStatusBar *statusBar() const; 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; KisPaintopBox* paintOpBox() const;
/// create a new progress updater /// create a new progress updater
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include "kis_selection.h" #include "kis_selection.h"
#include "kis_node_commands_adapter.h" #include "kis_node_commands_adapter.h"
#include "kis_group_layer.h" #include "kis_group_layer.h"
#include "kis_statusbar.h"
#include "kis_progress_widget.h" #include "kis_progress_widget.h"
#include "kis_config.h" #include "kis_config.h"
#include "KisPart.h" #include "KisPart.h"
......
...@@ -33,7 +33,10 @@ ...@@ -33,7 +33,10 @@
#include <KoColorProfile.h> #include <KoColorProfile.h>
#include <KoColorSpace.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_types.h>
#include <kis_image.h> #include <kis_image.h>
...@@ -42,46 +45,47 @@ ...@@ -42,46 +45,47 @@
#include <kis_selection_manager.h> #include <kis_selection_manager.h>
#include "kis_memory_statistics_server.h" #include "kis_memory_statistics_server.h"
#include <KisView.h> #include "KisView.h"
#include "KisViewManager.h" #include "KisViewManager.h"
#include "canvas/kis_canvas2.h" #include "canvas/kis_canvas2.h"
#include "kis_progress_widget.h" #include "kis_progress_widget.h"
#include "kis_zoom_manager.h" #include "kis_zoom_manager.h"
#include <KoToolManager.h> #include "KisMainWindow.h"
#include <KoViewConverter.h> #include "kis_config.h"
#include <KisMainWindow.h>
enum { enum {
IMAGE_SIZE_ID, IMAGE_SIZE_ID,
POINTER_POSITION_ID POINTER_POSITION_ID
}; };
KisStatusBar::KisStatusBar(KisViewManager *view) KisStatusBar::KisStatusBar(KisViewManager *viewManager)
: m_view(view), : m_viewManager(viewManager)
m_imageView(0), , m_imageView(0)
m_statusBar(0) , m_statusBar(0)
{ {
} }
void KisStatusBar::setup() void KisStatusBar::setup()
{ {
m_selectionStatus = new QToolButton(); m_selectionStatus = new QToolButton();
m_selectionStatus->setObjectName("selection status");
m_selectionStatus->setIconSize(QSize(16,16)); m_selectionStatus->setIconSize(QSize(16,16));
m_selectionStatus->setAutoRaise(true); m_selectionStatus->setAutoRaise(true);
m_selectionStatus->setEnabled(false); m_selectionStatus->setEnabled(false);
updateSelectionIcon(); 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_selectionStatus, SIGNAL(clicked()), m_viewManager->selectionManager(), SLOT(slotToggleSelectionDecoration()));
connect(m_view->selectionManager(), SIGNAL(displaySelectionChanged()), SLOT(updateSelectionToolTip())); connect(m_viewManager->selectionManager(), SIGNAL(displaySelectionChanged()), SLOT(updateSelectionToolTip()));
connect(m_view->mainWindow(), SIGNAL(themeChanged()), this, SLOT(updateSelectionIcon())); connect(m_viewManager->mainWindow(), SIGNAL(themeChanged()), this, SLOT(updateSelectionIcon()));
addStatusBarItem(m_selectionStatus); addStatusBarItem(m_selectionStatus);
m_selectionStatus->setVisible(false); m_selectionStatus->setVisible(false);
m_statusBarStatusLabel = new KSqueezedTextLabel(); m_statusBarStatusLabel = new KSqueezedTextLabel();
m_statusBarStatusLabel->setObjectName("statsBarStatusLabel");
m_statusBarStatusLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); m_statusBarStatusLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
m_statusBarStatusLabel->setContentsMargins(5, 5, 5, 5); m_statusBarStatusLabel->setContentsMargins(5, 5, 5, 5);
connect(KoToolManager::instance(), SIGNAL(changedStatusText(const QString &)), connect(KoToolManager::instance(), SIGNAL(changedStatusText(const QString &)),
...@@ -90,12 +94,14 @@ void KisStatusBar::setup() ...@@ -90,12 +94,14 @@ void KisStatusBar::setup()
m_statusBarStatusLabel->setVisible(false); m_statusBarStatusLabel->setVisible(false);
m_statusBarProfileLabel = new KSqueezedTextLabel(); m_statusBarProfileLabel = new KSqueezedTextLabel();
m_statusBarProfileLabel->setObjectName("statsBarProfileLabel");
m_statusBarProfileLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); m_statusBarProfileLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
m_statusBarProfileLabel->setContentsMargins(5, 5, 5, 5); m_statusBarProfileLabel->setContentsMargins(5, 5, 5, 5);
addStatusBarItem(m_statusBarProfileLabel, 3); addStatusBarItem(m_statusBarProfileLabel, 3);
m_statusBarProfileLabel->setVisible(false); m_statusBarProfileLabel->setVisible(false);
m_progress = new KisProgressWidget(); m_progress = new KisProgressWidget();
m_progress->setObjectName("ProgressBar");
addStatusBarItem(m_progress); addStatusBarItem(m_progress);
m_progress->setVisible(false); m_progress->setVisible(false);
connect(m_progress, SIGNAL(sigCancellationRequested()), this, SIGNAL(sigCancellationRequested())); connect(m_progress, SIGNAL(sigCancellationRequested()), this, SIGNAL(sigCancellationRequested()));
...@@ -104,6 +110,7 @@ void KisStatusBar::setup() ...@@ -104,6 +110,7 @@ void KisStatusBar::setup()
m_progressUpdater->setAutoNestNames(true); m_progressUpdater->setAutoNestNames(true);
m_memoryReportBox = new QPushButton(); m_memoryReportBox = new QPushButton();
m_memoryReportBox->setObjectName("memoryReportBox");
m_memoryReportBox->setFlat(true); m_memoryReportBox->setFlat(true);
m_memoryReportBox->setContentsMargins(5, 5, 5, 5); m_memoryReportBox->setContentsMargins(5, 5, 5, 5);
m_memoryReportBox->setMinimumWidth(120); m_memoryReportBox->setMinimumWidth(120);
...@@ -113,6 +120,7 @@ void KisStatusBar::setup() ...@@ -113,6 +120,7 @@ void KisStatusBar::setup()
connect(m_memoryReportBox, SIGNAL(clicked()), SLOT(showMemoryInfoToolTip())); connect(m_memoryReportBox, SIGNAL(clicked()), SLOT(showMemoryInfoToolTip()));
m_pointerPositionLabel = new QLabel(QString()); m_pointerPositionLabel = new QLabel(QString());
m_pointerPositionLabel->setObjectName("pointerPositionLabel");
m_pointerPositionLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter); m_pointerPositionLabel->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
m_pointerPositionLabel->setMinimumWidth(100); m_pointerPositionLabel->setMinimumWidth(100);
m_pointerPositionLabel->setContentsMargins(5,5, 5, 5); m_pointerPositionLabel->setContentsMargins(5,5, 5, 5);
...@@ -165,9 +173,6 @@ void KisStatusBar::addStatusBarItem(QWidget *widget, int stretch, bool permanent ...@@ -165,9 +173,6 @@ void KisStatusBar::addStatusBarItem(QWidget *widget, int stretch, bool permanent
else { else {
m_statusBar->addWidget(widget, stretch); m_statusBar->addWidget(widget, stretch);
} }
sbItem.show();
m_statusBarItems.append(sbItem); m_statusBarItems.append(sbItem);
} }
...@@ -207,8 +212,8 @@ void KisStatusBar::documentMousePositionChanged(const QPointF &pos) ...@@ -207,8 +212,8 @@ void KisStatusBar::documentMousePositionChanged(const QPointF &pos)
QPoint pixelPos = m_imageView->image()->documentToImagePixelFloored(pos); QPoint pixelPos = m_imageView->image()->documentToImagePixelFloored(pos);
pixelPos.setX(qBound(0, pixelPos.x(), m_view->image()->width() - 1)); pixelPos.setX(qBound(0, pixelPos.x(), m_viewManager->image()->width() - 1));
pixelPos.setY(qBound(0, pixelPos.y(), m_view->image()->height() - 1)); pixelPos.setY(qBound(0, pixelPos.y(), m_viewManager->image()->height() - 1));
m_pointerPositionLabel->setText(QString("%1, %2").arg(pixelPos.x()).arg(pixelPos.y())); m_pointerPositionLabel->setText(QString("%1, %2").arg(pixelPos.x()).arg(pixelPos.y()));
} }
...@@ -234,9 +239,9 @@ void KisStatusBar::imageSizeChanged() ...@@ -234,9 +239,9 @@ void KisStatusBar::imageSizeChanged()
void KisStatusBar::updateSelectionIcon() void KisStatusBar::updateSelectionIcon()
{ {
QIcon icon; QIcon icon;
if (!m_view->selectionManager()->displaySelection()) { if (!m_viewManager->selectionManager()->displaySelection()) {
icon = KisIconUtils::loadIcon("selection-mode_invisible"); icon = KisIconUtils::loadIcon("selection-mode_invisible");
} else if (m_view->selectionManager()->showSelectionAsMask()) { } else if (m_viewManager->selectionManager()->showSelectionAsMask()) {
icon = KisIconUtils::loadIcon("selection-mode_mask"); icon = KisIconUtils::loadIcon("selection-mode_mask");
} else /* if (!m_view->selectionManager()->showSelectionAsMask()) */ { } else /* if (!m_view->selectionManager()->showSelectionAsMask()) */ {
icon = KisIconUtils::loadIcon("selection-mode_ants"); icon = KisIconUtils::loadIcon("selection-mode_ants");
...@@ -247,8 +252,8 @@ void KisStatusBar::updateSelectionIcon() ...@@ -247,8 +252,8 @@ void KisStatusBar::updateSelectionIcon()
void KisStatusBar::updateMemoryStatus() void KisStatusBar::updateMemoryStatus()
{ {
KisMemoryStatisticsServer::Statistics stats = KisMemoryStatisticsServer::Statistics stats =
KisMemoryStatisticsServer::instance() KisMemoryStatisticsServer::instance()
->fetchMemoryStatistics(m_imageView ? m_imageView->image() : 0); ->fetchMemoryStatistics(m_imageView ? m_imageView->image() : 0);
const KFormat format; const KFormat format;
const QString imageStatsMsg = const QString imageStatsMsg =
...@@ -289,13 +294,13 @@ void KisStatusBar::updateMemoryStatus() ...@@ -289,13 +294,13 @@ void KisStatusBar::updateMemoryStatus()
const qint64 warnLevel = stats.tilesHardLimit - stats.tilesHardLimit / 8; const qint64 warnLevel = stats.tilesHardLimit - stats.tilesHardLimit / 8;
if (stats.imageSize > warnLevel || if (stats.imageSize > warnLevel ||
stats.realMemorySize > warnLevel) { stats.realMemorySize > warnLevel) {
icon = KisIconUtils::loadIcon("dialog-warning"); icon = KisIconUtils::loadIcon("dialog-warning");
QString suffix = QString suffix =
i18nc("tooltip on statusbar memory reporting button", i18nc("tooltip on statusbar memory reporting button",
"\n\nWARNING:\tOut of memory! Swapping has been started.\n" "\n\nWARNING:\tOut of memory! Swapping has been started.\n"
"\t\tPlease configure more RAM for Krita in Settings dialog"); "\t\tPlease configure more RAM for Krita in Settings dialog");
longStats += suffix; longStats += suffix;
} }
...@@ -315,22 +320,22 @@ void KisStatusBar::updateSelectionToolTip() ...@@ -315,22 +320,22 @@ void KisStatusBar::updateSelectionToolTip()
{ {
updateSelectionIcon(); updateSelectionIcon();
KisSelectionSP selection = m_view->selection(); KisSelectionSP selection = m_viewManager->selection();
if (selection) { if (selection) {
m_selectionStatus->setEnabled(true); m_selectionStatus->setEnabled(true);
QRect r = selection->selectedExactRect(); QRect r = selection->selectedExactRect();
QString displayMode = QString displayMode =
!m_view->selectionManager()->displaySelection() ? !m_viewManager->selectionManager()->displaySelection() ?
i18n("Hidden") : i18n("Hidden") :
(m_view->selectionManager()->showSelectionAsMask() ? (m_viewManager->selectionManager()->showSelectionAsMask() ?
i18n("Mask") : i18n("Ants")); i18n("Mask") : i18n("Ants"));
m_selectionStatus->setToolTip( m_selectionStatus->setToolTip(
i18n("Selection: x = %1 y = %2 width = %3 height = %4\n" i18n("Selection: x = %1 y = %2 width = %3 height = %4\n"
"Display Mode: %5", "Display Mode: %5",
r.x(), r.y(), r.width(), r.height(), displayMode)); r.x(), r.y(), r.width(), r.height(), displayMode));
} else { } else {
m_selectionStatus->setEnabled(false); m_selectionStatus->setEnabled(false);
m_selectionStatus->setToolTip(i18n("No Selection")); m_selectionStatus->setToolTip(i18n("No Selection"));
...@@ -350,7 +355,6 @@ void KisStatusBar::setProfile(KisImageWSP image) ...@@ -350,7 +355,6 @@ void KisStatusBar::setProfile(KisImageWSP image)
} }
if (!image) return; if (!image) return;
if (image->profile() == 0) { if (image->profile() == 0) {
m_statusBarProfileLabel->setText(i18n("No profile")); m_statusBarProfileLabel->setText(i18n("No profile"));
} else { } else {
......
...@@ -76,13 +76,11 @@ class KRITAUI_EXPORT KisStatusBar : public QObject ...@@ -76,13 +76,11 @@ class KRITAUI_EXPORT KisStatusBar : public QObject
public: public:
KisStatusBar(KisViewManager *view); explicit KisStatusBar(KisViewManager *view);
~KisStatusBar() override; ~KisStatusBar() override;
void setup(); void setup();
void setView(QPointer<KisView> imageView); void setView(QPointer<KisView> imageView);
void addStatusBarItem(QWidget *widget, int stretch = 0, bool permanent = false);
void removeStatusBarItem(QWidget *widget);
void hideAllStatusBarItems(); void hideAllStatusBarItems();
void showAllStatusBarItems(); void showAllStatusBarItems();
...@@ -110,11 +108,14 @@ Q_SIGNALS: ...@@ -110,11 +108,14 @@ Q_SIGNALS:
void memoryStatusUpdated(); void memoryStatusUpdated();
private: private:
void updateMemoryStatus();
void removeStatusBarItem(QWidget *widget);
void addStatusBarItem(QWidget *widget, int stretch = 0, bool permanent = false);
void updateMemoryStatus();
private: private:
QPointer<KisViewManager> m_view; QPointer<KisViewManager> m_viewManager;
QPointer<KisView> m_imageView; QPointer<KisView> m_imageView;
QPointer<QStatusBar> m_statusBar; QPointer<QStatusBar> m_statusBar;
KisProgressWidget *m_progress; KisProgressWidget *m_progress;
...@@ -127,7 +128,6 @@ private: ...@@ -127,7 +128,6 @@ private:
KSqueezedTextLabel *m_statusBarStatusLabel; KSqueezedTextLabel *m_statusBarStatusLabel;
KSqueezedTextLabel *m_statusBarProfileLabel; KSqueezedTextLabel *m_statusBarProfileLabel;
QString m_shortMemoryTag; QString m_shortMemoryTag;
QString m_longMemoryTag; QString m_longMemoryTag;
QIcon m_memoryStatusIcon; 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