[Kstars-devel] [kstars] kstars: _Quickfix_ to enable inversion of colors in the Image Viewer. This is
Akarsh Simha
akarshsimha at gmail.com
Thu Apr 19 08:24:24 UTC 2012
Git commit 589d993b63a545c6e49361f5c636bd0a4ff640f2 by Akarsh Simha.
Committed on 19/04/2012 at 10:22.
Pushed by asimha into branch 'master'.
_Quickfix_ to enable inversion of colors in the Image Viewer. This is
important as it enhances contrast, making it easy to view the galaxies
under low-light conditions.
This should be redone in a more elegant way, adding more options, but
this is a quick feature for now. If there are any objections, do feel
free to revert / discuss them.
I almost did this because I needed it right away.
CCMAIL: kstars-devel at kde.org
M +21 -2 kstars/imageviewer.cpp
M +5 -2 kstars/imageviewer.h
http://commits.kde.org/kstars/589d993b63a545c6e49361f5c636bd0a4ff640f2
diff --git a/kstars/imageviewer.cpp b/kstars/imageviewer.cpp
index f7b7b51..8ef8c4e 100644
--- a/kstars/imageviewer.cpp
+++ b/kstars/imageviewer.cpp
@@ -69,10 +69,17 @@ ImageViewer::ImageViewer (const KUrl &url, const QString &capText, QWidget *pare
{
init(url.fileName(), capText);
// Add save button
- setButtons( KDialog::User1 | KDialog::Close );
+ setButtons( KDialog::User2 | KDialog::User1 | KDialog::Close );
+
KGuiItem saveButton( i18n("Save"), "document-save", i18n("Save the image to disk") );
setButtonGuiItem( KDialog::User1, saveButton );
+
+ // FIXME: Add more options, and do this more nicely
+ KGuiItem invertButton( i18n("Invert colors"), "", i18n("Reverse colors of the image. This is useful to enhance contrast at times. This affects only the display and not the saving.") );
+ setButtonGuiItem( KDialog::User2, invertButton );
+
connect( this, SIGNAL( user1Clicked() ), this, SLOT ( saveFileToDisc() ) );
+ connect( this, SIGNAL( user2Clicked() ), this, SLOT ( invertColors() ) );
// check URL
if (!m_ImageUrl.isValid())
kDebug() << "URL is malformed: " << m_ImageUrl;
@@ -101,7 +108,13 @@ void ImageViewer::init(QString caption, QString capText) {
setAttribute( Qt::WA_DeleteOnClose, true );
setModal( false );
setCaption( i18n( "KStars image viewer" ) + QString( " : " ) + caption );
- setButtons( KDialog::Close );
+ setButtons( KDialog::Close | KDialog::User1);
+
+ // FIXME: Add more options, and do this more nicely
+ KGuiItem invertButton( i18n("Invert colors"), "", i18n("Reverse colors of the image. This is useful to enhance contrast at times. This affects only the display and not the saving.") );
+ setButtonGuiItem( KDialog::User1, invertButton );
+ connect( this, SIGNAL( user1Clicked() ), this, SLOT ( invertColors() ) );
+
// Create widget
QFrame* page = new QFrame( this );
@@ -245,4 +258,10 @@ void ImageViewer::saveFile (KUrl &url) {
}
}
+void ImageViewer::invertColors() {
+ // Invert colors
+ m_View->m_Image.invertPixels();
+ m_View->update();
+}
+
#include "imageviewer.moc"
diff --git a/kstars/imageviewer.h b/kstars/imageviewer.h
index 0fc8608..4466109 100644
--- a/kstars/imageviewer.h
+++ b/kstars/imageviewer.h
@@ -37,10 +37,10 @@ public:
~ImageLabel();
void setImage( const QImage &img ) { m_Image = img; }
+ QImage m_Image; // ImageViewer needs access to the image in order to modify it
protected:
void paintEvent( QPaintEvent *e);
-private:
- QImage m_Image;
+
};
/**@class ImageViewer
@@ -101,6 +101,9 @@ private slots:
/**Saves file to disc. */
void saveFileToDisc();
+
+ /** Inverts colors **/
+ void invertColors();
};
#endif
More information about the Kstars-devel
mailing list