summaryrefslogtreecommitdiff
authoralwin <alwin>2004-04-05 22:09:25 (UTC)
committer alwin <alwin>2004-04-05 22:09:25 (UTC)
commit266b184c615022484b988e1638be768b11c0c19b (patch) (side-by-side diff)
treeb2560b3a64c49db414fa950fc3ef4670e25cd5ca
parent930abeed35ee6dd3aaec491f13d400f825b9d9d1 (diff)
downloadopie-266b184c615022484b988e1638be768b11c0c19b.zip
opie-266b184c615022484b988e1638be768b11c0c19b.tar.gz
opie-266b184c615022484b988e1638be768b11c0c19b.tar.bz2
yeah - autoresize and autoscale now have toggle-buttons and the image display
respect these buttons ToDo: find a good way for prescaled loading of images if autoScale is on (in respect to autorotate and so on)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/graphics/opie-eye/gui/imagescrollview.cpp56
-rw-r--r--noncore/graphics/opie-eye/gui/imagescrollview.h4
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.cpp41
-rw-r--r--noncore/graphics/opie-eye/gui/mainwindow.h5
4 files changed, 95 insertions, 11 deletions
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.cpp b/noncore/graphics/opie-eye/gui/imagescrollview.cpp
index 7d83e29..ee20f40 100644
--- a/noncore/graphics/opie-eye/gui/imagescrollview.cpp
+++ b/noncore/graphics/opie-eye/gui/imagescrollview.cpp
@@ -34,4 +34,5 @@ void ImageScrollView::setImage(const QImage&img)
_original_data=img;
- first_resize_done = false;
- init();
+ if (first_resize_done) {
+ generateImage();
+ }
}
@@ -39,3 +40,8 @@ void ImageScrollView::setImage(const QImage&img)
void ImageScrollView::setImage( const QString& path ) {
-
+ odebug << "load new image " << oendl;
+ _original_data.load(path);
+ _image_data = QImage();
+ if (first_resize_done) {
+ generateImage();
+ }
}
@@ -45,7 +51,31 @@ void ImageScrollView::init()
{
+ odebug << "init " << oendl;
viewport()->setBackgroundColor(white);
- if (_original_data.size().isValid()) {
+ if (first_resize_done) {
+ last_rot = Rotate0;
+ generateImage();
+ odebug << "reinit display " << oendl;
+ } else if (_original_data.size().isValid()) {
resizeContents(_original_data.width(),_original_data.height());
}
- last_rot = Rotate0;
+}
+
+void ImageScrollView::setAutoRotate(bool how)
+{
+ /* to avoid double repaints */
+ if (rotate_to_fit != how) {
+ rotate_to_fit = how;
+ _image_data = QImage();
+ generateImage();
+ }
+}
+
+void ImageScrollView::setAutoScale(bool how)
+{
+ scale_to_fit = how;
+ if (!how) {
+ rotate_to_fit = false;
+ }
+ _image_data = QImage();
+ generateImage();
}
@@ -183,6 +213,4 @@ void ImageScrollView::rotate_into_data(Rotation r)
-void ImageScrollView::resizeEvent(QResizeEvent * e)
+void ImageScrollView::generateImage()
{
- odebug << "ImageScrollView resizeEvent" << oendl;
- QScrollView::resizeEvent(e);
Rotation r = Rotate0;
@@ -195,2 +223,3 @@ void ImageScrollView::resizeEvent(QResizeEvent * e)
if (!_image_data.size().isValid()||width()>_image_data.width()||height()>_image_data.height()) {
+ odebug << "Rescaling data" << oendl;
if (r==Rotate0) {
@@ -202,4 +231,4 @@ void ImageScrollView::resizeEvent(QResizeEvent * e)
rescaleImage(width(),height());
- resizeContents(width()-10,height()-10);
- } else if (!first_resize_done||r!=last_rot) {
+ resizeContents(_image_data.width(),_image_data.height());
+ } else if (!first_resize_done||r!=last_rot||_image_data.width()==0) {
if (r==Rotate0) {
@@ -212,2 +241,9 @@ void ImageScrollView::resizeEvent(QResizeEvent * e)
}
+}
+
+void ImageScrollView::resizeEvent(QResizeEvent * e)
+{
+ odebug << "ImageScrollView resizeEvent" << oendl;
+ QScrollView::resizeEvent(e);
+ generateImage();
first_resize_done = true;
diff --git a/noncore/graphics/opie-eye/gui/imagescrollview.h b/noncore/graphics/opie-eye/gui/imagescrollview.h
index 864a015..dcf54ce 100644
--- a/noncore/graphics/opie-eye/gui/imagescrollview.h
+++ b/noncore/graphics/opie-eye/gui/imagescrollview.h
@@ -23,2 +23,5 @@ public:
+ void setAutoRotate(bool);
+ void setAutoScale(bool);
+
enum Rotation {
@@ -50,2 +53,3 @@ protected:
void rotate_into_data(Rotation r);
+ void generateImage();
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.cpp b/noncore/graphics/opie-eye/gui/mainwindow.cpp
index 7f384bd..88acd59 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.cpp
+++ b/noncore/graphics/opie-eye/gui/mainwindow.cpp
@@ -94,2 +94,16 @@ PMainWindow::PMainWindow(QWidget* wid, const char* name, WFlags style)
this, SLOT(slotConfig() ) );
+
+ rotateButton = new QToolButton(bar);
+ rotateButton->setIconSet( Resource::loadIconSet( "rotate" ) );
+ rotateButton->setToggleButton(true);
+ rotateButton->setOn(true);
+ connect(rotateButton,SIGNAL(toggled(bool)),this,SLOT(slotRotateToggled(bool)));
+ autoRotate = true;
+
+ btn = new QToolButton(bar);
+ btn->setIconSet( Resource::loadIconSet( "1to1" ) );
+ btn->setToggleButton(true);
+ btn->setOn(false);
+ connect(btn,SIGNAL(toggled(bool)),this,SLOT(slotScaleToggled(bool)));
+ autoScale = true;
@@ -101,2 +115,21 @@ PMainWindow::~PMainWindow() {
+void PMainWindow::slotRotateToggled(bool how)
+{
+ autoRotate = how;
+ if (m_disp) {
+ m_disp->setAutoRotate(how);
+ }
+}
+
+void PMainWindow::slotScaleToggled(bool how)
+{
+ autoScale = !how;
+ if (m_disp) {
+ m_disp->setAutoScale(autoScale);
+ }
+ if (!autoScale && autoRotate) {
+ rotateButton->setOn(false);
+ }
+ rotateButton->setEnabled(!how);
+}
@@ -182,2 +215,7 @@ void PMainWindow::initDisp() {
initT<ImageScrollView>( "Image ScrollView", &m_disp, ImageDisplay );
+ if (m_disp) {
+ m_disp->setAutoScale(autoScale);
+ m_disp->setAutoRotate(autoRotate);
+ }
+
}
@@ -200,4 +238,5 @@ void PMainWindow::slotShowInfo( const QString& inf ) {
void PMainWindow::slotDisplay( const QString& inf ) {
- if ( !m_disp )
+ if ( !m_disp ) {
initDisp();
+ }
m_disp->setImage( inf );
diff --git a/noncore/graphics/opie-eye/gui/mainwindow.h b/noncore/graphics/opie-eye/gui/mainwindow.h
index 35116ae..6debf7f 100644
--- a/noncore/graphics/opie-eye/gui/mainwindow.h
+++ b/noncore/graphics/opie-eye/gui/mainwindow.h
@@ -39,2 +39,4 @@ public slots:
void slotReturn();
+ void slotRotateToggled(bool);
+ void slotScaleToggled(bool);
@@ -55,2 +57,5 @@ private:
ImageScrollView *m_disp;
+ bool autoRotate;
+ bool autoScale;
+ QToolButton*rotateButton;