summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Cullmann <cullmann@kde.org>2014-01-22 15:32:46 (GMT)
committerChristoph Cullmann <cullmann@kde.org>2014-01-22 15:32:46 (GMT)
commitbb37e9e944394fedeeea9e1e894beffe800348e3 (patch)
tree65cb75719548a2cdd5304ba89556a38b242c48f5
parent6c19b27f84777671d4ab43d5a17df0bab15707c7 (diff)
fixup pixmap computation
-rw-r--r--src/view/katestatusbar.cpp50
-rw-r--r--src/view/katestatusbar.h3
2 files changed, 32 insertions, 21 deletions
diff --git a/src/view/katestatusbar.cpp b/src/view/katestatusbar.cpp
index c81b1e9..437a9b7 100644
--- a/src/view/katestatusbar.cpp
+++ b/src/view/katestatusbar.cpp
@@ -25,15 +25,17 @@
#include "katemodemanager.h"
#include "katedocument.h"
-#include <KIconUtils>
#include <KLocalizedString>
+#include <KIconLoader>
#include <QHBoxLayout>
#include <QFontDatabase>
+#include <QPixmap>
KateStatusBar::KateStatusBar(KTextEditor::ViewPrivate *view)
: KateViewBarWidget(false)
, m_view(view)
+ , m_modifiedStatus (0)
{
setFocusProxy(m_view);
@@ -46,7 +48,7 @@ KateStatusBar::KateStatusBar(KTextEditor::ViewPrivate *view)
topLayout->addSpacing(4);
m_modifiedLabel = new QLabel( this );
- m_modifiedLabel->setFixedSize( 16, 16 );
+ m_modifiedLabel->setFixedSize (SmallIcon(QStringLiteral("document-save")).size());
topLayout->addWidget( m_modifiedLabel, 0 );
m_modifiedLabel->setAlignment( Qt::AlignCenter );
m_modifiedLabel->setFocusProxy(m_view);
@@ -95,13 +97,6 @@ KateStatusBar::KateStatusBar(KTextEditor::ViewPrivate *view)
topLayout->addWidget( m_lineColLabel, 0 );
m_lineColLabel->setFocusProxy(m_view);
topLayout->addSpacing(4);
-
- m_modPm = QIcon::fromTheme(QStringLiteral("document-save")).pixmap(16);
- m_modDiscPm = QIcon::fromTheme(QStringLiteral("dialog-warning")).pixmap(16);
- QIcon icon = KIconUtils::addOverlay(QIcon::fromTheme(QStringLiteral("document-save")),
- QIcon::fromTheme(QStringLiteral("emblem-important")),
- Qt::TopLeftCorner);
- m_modmodPm = icon.pixmap(16);
// signals for the statusbar
connect(m_view, SIGNAL(cursorPositionChanged(KTextEditor::View*,KTextEditor::Cursor)), this, SLOT(cursorPositionChanged()));
@@ -161,16 +156,33 @@ void KateStatusBar::modifiedChanged()
{
const bool mod = m_view->doc()->isModified();
const bool modOnHD = m_view->doc()->isModifiedOnDisc();
-
- m_modifiedLabel->setPixmap(
- mod ?
- modOnHD ?
- m_modmodPm :
- m_modPm :
- modOnHD ?
- m_modDiscPm :
- QPixmap()
- );
+
+ /**
+ * combine to modified status, update only if changed
+ */
+ unsigned int newStatus = (unsigned int)mod | ((unsigned int)modOnHD << 1);
+ if (m_modifiedStatus == newStatus)
+ return;
+
+ m_modifiedStatus = newStatus;
+ switch (m_modifiedStatus) {
+ case 0x1:
+ m_modifiedLabel->setPixmap (SmallIcon(QStringLiteral("document-save")));
+ break;
+
+ case 0x2:
+ m_modifiedLabel->setPixmap (SmallIcon(QStringLiteral("dialog-warning")));
+ break;
+
+ case 0x3:
+ m_modifiedLabel->setPixmap (SmallIcon(QStringLiteral("document-save"), 0, KIconLoader::DefaultState,
+ QStringList() << QStringLiteral("emblem-important")));
+ break;
+
+ default:
+ m_modifiedLabel->setPixmap (QPixmap());
+ break;
+ }
}
void KateStatusBar::documentConfigChanged ()
diff --git a/src/view/katestatusbar.h b/src/view/katestatusbar.h
index ddd0dd2..eca8da5 100644
--- a/src/view/katestatusbar.h
+++ b/src/view/katestatusbar.h
@@ -27,7 +27,6 @@
#include <KSqueezedTextLabel>
#include <QLabel>
-#include <QPixmap>
#include <QPushButton>
class KateStatusBar : public KateViewBarWidget
@@ -63,7 +62,7 @@ private:
QPushButton* m_mode;
QPushButton* m_encoding;
KSqueezedTextLabel* m_infoLabel;
- QPixmap m_modPm, m_modDiscPm, m_modmodPm;
+ unsigned int m_modifiedStatus;
};
#endif