[kde-doc-english] extragear/graphics/kphotoalbum/Viewer
Wes Hardaker
wjhns25 at hardakers.net
Fri Jan 15 02:51:38 CET 2010
SVN commit 1074959 by hardaker:
GUI:Added full screen viewer 'filters'
M +26 -0 ImageDisplay.cpp
M +4 -0 ImageDisplay.h
M +44 -0 ViewerWidget.cpp
M +8 -0 ViewerWidget.h
--- trunk/extragear/graphics/kphotoalbum/Viewer/ImageDisplay.cpp #1074958:1074959
@@ -330,6 +330,32 @@
update();
}
+void Viewer::ImageDisplay::filterNone()
+{
+ cropAndScale();
+ update();
+}
+
+void Viewer::ImageDisplay::filterMono()
+{
+ _croppedAndScaledImg = _croppedAndScaledImg.convertToFormat(_croppedAndScaledImg.Format_Mono);
+ update();
+}
+
+// I can't believe there isn't a standard conversion for this??? -- WH
+void Viewer::ImageDisplay::filterBW()
+{
+ for (int y = 0; y < _croppedAndScaledImg.height(); ++y) {
+ for (int x = 0; x < _croppedAndScaledImg.width(); ++x) {
+ int pixel = _croppedAndScaledImg.pixel(x, y);
+ int gray = qGray(pixel);
+ int alpha = qAlpha(pixel);
+ _croppedAndScaledImg.setPixel(x, y, qRgba(gray, gray, gray, alpha));
+ }
+ }
+ update();
+}
+
void Viewer::ImageDisplay::updateZoomCaption() {
const QSize imgSize = _loadedImage.size();
// similar to sizeRatio(), but we take the _highest_ factor.
--- trunk/extragear/graphics/kphotoalbum/Viewer/ImageDisplay.h #1074958:1074959
@@ -59,6 +59,10 @@
virtual void pixmapLoaded( const QString& fileName, const QSize& size, const QSize& fullSize, int angle, const QImage&, const bool loadedOK);
void setImageList( const QStringList& list );
+ void filterNone();
+ void filterMono();
+ void filterBW();
+
public slots:
void zoomIn();
void zoomOut();
--- trunk/extragear/graphics/kphotoalbum/Viewer/ViewerWidget.cpp #1074958:1074959
@@ -146,6 +146,7 @@
createInvokeExternalMenu();
createVideoMenu();
createCategoryImageMenu();
+ createFilterMenu();
KAction* action = _actions->addAction( QString::fromLatin1("viewer-edit-image-properties"), this, SLOT( editImage() ) );
action->setText( i18n("Annotate...") );
@@ -426,6 +427,7 @@
_rotateMenu->setEnabled( !isVideo );
_wallpaperMenu->setEnabled( !isVideo );
_categoryImagePopup->setEnabled( !isVideo );
+ _filterMenu->setEnabled( !isVideo );
#ifdef HAVE_EXIV2
_showExifViewer->setEnabled( !isVideo );
#endif
@@ -864,6 +866,27 @@
MainWindow::Window::configureImages( list, true );
}
+void Viewer::ViewerWidget::filterNone()
+{
+ if ( _display == _imageDisplay ) {
+ _imageDisplay->filterNone();
+ }
+}
+
+void Viewer::ViewerWidget::filterBW()
+{
+ if ( _display == _imageDisplay ) {
+ _imageDisplay->filterBW();
+ }
+}
+
+void Viewer::ViewerWidget::filterMono()
+{
+ if ( _display == _imageDisplay ) {
+ _imageDisplay->filterMono();
+ }
+}
+
void Viewer::ViewerWidget::slotSetStackHead()
{
MainWindow::Window::theMainWindow()->setStackHead( DB::ImageDB::instance()->ID_FOR_FILE( _list[ _current ] ) );
@@ -1087,6 +1110,27 @@
connect( _categoryImagePopup, SIGNAL( aboutToShow() ), this, SLOT( populateCategoryImagePopup() ) );
}
+void Viewer::ViewerWidget::createFilterMenu()
+{
+ _filterMenu = new QMenu( _popup );
+ _filterMenu->setTitle( i18n("Filters") );
+
+ _filterNone = _actions->addAction( QString::fromLatin1("filter-empty"), this, SLOT( filterNone() ) );
+ _filterNone->setText( i18n("Remove All Filters") );
+ _filterMenu->addAction( _filterNone );
+
+ _filterBW = _actions->addAction( QString::fromLatin1("filter-bw"), this, SLOT( filterBW() ) );
+ _filterBW->setText( i18n("Apply Grayscale Filter") );
+ _filterMenu->addAction( _filterBW );
+
+ _filterMono = _actions->addAction( QString::fromLatin1("filter-mono"), this, SLOT( filterMono() ) );
+ _filterMono->setText( i18n("Apply Monochrome Filter") );
+ _filterMenu->addAction( _filterMono );
+
+ _popup->addMenu( _filterMenu );
+}
+
+
void Viewer::ViewerWidget::test()
{
#ifdef TESTING
--- trunk/extragear/graphics/kphotoalbum/Viewer/ViewerWidget.h #1074958:1074959
@@ -94,6 +94,7 @@
void createSlideShowMenu();
void createVideoMenu();
void createCategoryImageMenu();
+ void createFilterMenu();
void changeSlideShowInterval( int delta );
void createVideoViewer();
@@ -126,6 +127,9 @@
void slotSlideShowFaster();
void slotSlideShowSlower();
void editImage();
+ void filterNone();
+ void filterBW();
+ void filterMono();
void slotSetStackHead();
void updateCategoryConfig();
void slotSetWallpaperC();
@@ -157,6 +161,9 @@
KAction* _slideShowRunFaster;
KAction* _slideShowRunSlower;
KAction* _setStackHead;
+ KAction* _filterNone;
+ KAction* _filterBW;
+ KAction* _filterMono;
Display* _display;
ImageDisplay* _imageDisplay;
@@ -170,6 +177,7 @@
QMenu* _popup;
QMenu* _rotateMenu;
QMenu* _wallpaperMenu;
+ QMenu* _filterMenu;
MainWindow::ExternalPopup* _externalPopup;
MainWindow::CategoryImagePopup* _categoryImagePopup;
int _width, _height;
More information about the kde-doc-english
mailing list