Skip to Content.
Sympa Menu

idok-commit - [idok-commit] idok commit r266 - trunk/java/ch/idok/qtgui

idok-commit AT lists.psi.ch

Subject: Commit emails of the iDok project

List archive

[idok-commit] idok commit r266 - trunk/java/ch/idok/qtgui


Chronological Thread 
  • From: "AFS account Florian Huebner" <huebner AT savannah.psi.ch>
  • To: idok-commit AT lists.psi.ch
  • Subject: [idok-commit] idok commit r266 - trunk/java/ch/idok/qtgui
  • Date: Tue, 30 Sep 2008 16:34:08 +0200
  • List-archive: <https://lists.web.psi.ch/pipermail/idok-commit/>
  • List-id: Commit emails of the iDok project <idok-commit.lists.psi.ch>

Author: huebner
Date: Tue Sep 30 16:34:08 2008
New Revision: 266

Log:
Added a checkbox to decide if the content of the preview window will be
stretched to fit or not.

Modified:
trunk/java/ch/idok/qtgui/PreviewImage.java
trunk/java/ch/idok/qtgui/PreviewWidget.java

Modified: trunk/java/ch/idok/qtgui/PreviewImage.java
==============================================================================
--- trunk/java/ch/idok/qtgui/PreviewImage.java (original)
+++ trunk/java/ch/idok/qtgui/PreviewImage.java Tue Sep 30 16:34:08 2008
@@ -35,10 +35,12 @@
*/
public class PreviewImage extends QWidget {

+ private int fitWidth_;
+ private int fitHeight_;
private QImage image_;
private double zoom;
private QPoint start_;
- private boolean fitWidget_ = false;
+ private boolean fitWidget_ = true;

public PreviewImage() {
}
@@ -65,12 +67,17 @@

public void setfitWidget(boolean fit){
fitWidget_ = fit;
+ if (fit){
+
resize(this.parentWidget().width()-18,this.parentWidget().height()-18);
+ }else{
+ resize((int) Math.round(image_.width() * zoom), (int)
Math.round(image_.height()* zoom));
+ }
}

protected void paintEvent(QPaintEvent e) {
QPainter p = new QPainter(this);
p.setRenderHint(QPainter.RenderHint.SmoothPixmapTransform);
- if (image_!=null && fitWidget_) {
+ if (image_!=null && !fitWidget_) {
resize((int) Math.round(image_.width() * zoom), (int)
Math.round(image_.height() * zoom));
}
p.drawImage(rect(), image_);

Modified: trunk/java/ch/idok/qtgui/PreviewWidget.java
==============================================================================
--- trunk/java/ch/idok/qtgui/PreviewWidget.java (original)
+++ trunk/java/ch/idok/qtgui/PreviewWidget.java Tue Sep 30 16:34:08 2008
@@ -51,6 +51,7 @@
import com.trolltech.qt.core.QTime;
import com.trolltech.qt.core.Qt;
import com.trolltech.qt.core.Qt.FocusPolicy;
+import com.trolltech.qt.gui.QCheckBox;
import com.trolltech.qt.gui.QCursor;
import com.trolltech.qt.gui.QFocusEvent;
import com.trolltech.qt.gui.QFrame;
@@ -93,6 +94,8 @@
private QPushButton previewExternalButton_;

private QPushButton previewAnywayButton_;
+
+ private QCheckBox previewZoomBox_;

int numPages_;

@@ -179,6 +182,12 @@
com.trolltech.qt.gui.QSizePolicy.Policy.Minimum);
layouter_.addItem(spacerItem, 1, 1);

+ previewZoomBox_ = new QCheckBox("Fit Preview Window");
+ previewZoomBox_.setChecked(true);
+ layouter_.addWidget(previewZoomBox_, 1, 3);
+ previewZoomBox_.stateChanged.connect(this, "previewZoom()");
+ previewZoomBox_.hide();
+
previewAsTextButton_ = new QPushButton("Preview as text");
layouter_.addWidget(previewAsTextButton_, 1, 2);
previewAsTextButton_.clicked.connect(this, "enablePreviewAnyway()");
@@ -226,6 +235,15 @@
}
}
}
+
+ private void previewZoom() {
+ if (previewZoomBox_.isChecked() == true) {
+ imageView_.setfitWidget(true);
+ }else{
+ imageView_.setfitWidget(false);
+ }
+ }
+

private void enablePreviewAnyway() {
enablePreviewAnyway = true;
@@ -241,6 +259,7 @@
localFile = true;
previewAsTextButton_.hide();
previewButton_.hide();
+ previewZoomBox_.hide();
enablePreviewAnyway = false;
fileName_ = fileName;
previewData(fileName);
@@ -256,6 +275,7 @@
previewAsTextButton_.hide();
previewAnywayButton_.hide();
previewExternalButton_.hide();
+ previewZoomBox_.hide();
FileOutputStream os = null;
File tempFile = File.createTempFile("lastViewedFile", "");
fileName_ = tempFile.getAbsolutePath();
@@ -315,6 +335,7 @@
// Should contain: bmp,pbm,pgm,png,ppm,xbm,xpm
if(previewFileSizeWithin(15,"Large picture, preview might be
slow")){
previewImage();
+ previewZoomBox_.show();
pdfPageSpinBox_.hide();
}
} else if (ext.contains("txt") | ext.contains("htm")
@@ -344,6 +365,7 @@
pdfPageSpinBox_.setRange(1, numPages_);
previewPdfFile(1);
pdfPageSpinBox_.show();
+ previewZoomBox_.show();
pdfPageSpinBox_.setValue(1);
displayTime = time.elapsed();
System.out.println("Display time: " + displayTime + "
ms");
@@ -381,6 +403,7 @@
pictureArray = new QImage[numPages_];
pdfPageSpinBox_.setRange(1, numPages_);
previewPdfFile(1);
+ previewZoomBox_.show();
pdfPageSpinBox_.show();
pdfPageSpinBox_.setValue(1);
displayTime = time.elapsed();
@@ -419,6 +442,7 @@
QImage image = pixMap.toImage();
imageView_.setImage(image);
enableImageView();
+ previewZoomBox_.show();
pdfPageSpinBox_.hide();
System.out.println("Display time: " +
time.elapsed()
+ " ms");



  • [idok-commit] idok commit r266 - trunk/java/ch/idok/qtgui, AFS account Florian Huebner, 09/30/2008

Archive powered by MHonArc 2.6.19.

Top of Page