summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO34
-rw-r--r--PKGBUILD48
-rw-r--r--gwenview-auto-resize-git.install12
-rw-r--r--window-sizing-auto.patch116
4 files changed, 210 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..72597801716f
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,34 @@
+pkgbase = gwenview-auto-resize-git
+ pkgdesc = A fast and easy to use image viewer for KDE - Patched to resize window to fit image
+ pkgver = r6357.3da2a238
+ pkgrel = 1
+ url = http://kde.org/applications/graphics/gwenview/
+ install = gwenview-auto-resize-git.install
+ arch = i686
+ arch = x86_64
+ license = GPL
+ makedepends = git
+ makedepends = extra-cmake-modules
+ makedepends = kdoctools
+ depends = kactivities
+ depends = baloo
+ depends = libkipi
+ depends = libkdcraw
+ depends = kparts
+ depends = kitemmodels
+ depends = cfitsio
+ depends = phonon-qt5
+ depends = purpose
+ depends = perl
+ optdepends = qt5-imageformats: support for tiff, webp, and more image formats
+ optdepends = kimageformats: support for dds, xcf, exr, psd, and more image formats
+ optdepends = kipi-plugins: export to various online services
+ optdepends = kamera: import pictures from gphoto2 cameras
+ provides = gwenview
+ conflicts = kdegraphics-gwenview
+ conflicts = gwenview
+ source = git://anongit.kde.org/gwenview.git
+ sha256sums = SKIP
+
+pkgname = gwenview-auto-resize-git
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..9d16197a70de
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,48 @@
+# Maintainer: Pietro Carrara <pbcarrara@inf.ufrgs.br>
+
+pkgname=gwenview-auto-resize-git
+pkgver=r6357.3da2a238
+pkgrel=1
+pkgdesc='A fast and easy to use image viewer for KDE - Patched to resize window to fit image'
+arch=('i686' 'x86_64')
+url='http://kde.org/applications/graphics/gwenview/'
+license=('GPL')
+depends=(kactivities baloo libkipi libkdcraw kparts kitemmodels cfitsio phonon-qt5 purpose perl)
+optdepends=('qt5-imageformats: support for tiff, webp, and more image formats'
+ 'kimageformats: support for dds, xcf, exr, psd, and more image formats'
+ 'kipi-plugins: export to various online services'
+ 'kamera: import pictures from gphoto2 cameras')
+makedepends=(git extra-cmake-modules kdoctools)
+conflicts=('kdegraphics-gwenview' 'gwenview')
+provides=('gwenview')
+source=("git://anongit.kde.org/gwenview.git")
+install=$pkgname.install
+sha256sums=('SKIP')
+
+pkgver() {
+ cd gwenview
+ printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
+}
+
+prepare() {
+ cd gwenview
+ git apply ../../window-sizing-auto.patch
+ cd ..
+
+ mkdir -p build
+}
+
+build() {
+ cd build
+ cmake ../gwenview \
+ -DCMAKE_INSTALL_PREFIX=/usr \
+ -DCMAKE_BUILD_TYPE=Release \
+ -DLIB_INSTALL_DIR=lib \
+ -DKDE_INSTALL_USE_QT_SYS_PATHS=ON
+ make
+}
+
+package() {
+ cd build
+ make DESTDIR="$pkgdir" install
+}
diff --git a/gwenview-auto-resize-git.install b/gwenview-auto-resize-git.install
new file mode 100644
index 000000000000..8bccbee5d4c7
--- /dev/null
+++ b/gwenview-auto-resize-git.install
@@ -0,0 +1,12 @@
+post_install() {
+ update-desktop-database -q
+ xdg-icon-resource forceupdate --theme hicolor &> /dev/null
+}
+
+post_update() {
+ post_install
+}
+
+post_remove() {
+ post_install
+} \ No newline at end of file
diff --git a/window-sizing-auto.patch b/window-sizing-auto.patch
new file mode 100644
index 000000000000..c46bf8c2e287
--- /dev/null
+++ b/window-sizing-auto.patch
@@ -0,0 +1,116 @@
+diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp
+index f206dc87..c2a46e82 100644
+--- a/app/mainwindow.cpp
++++ b/app/mainwindow.cpp
+@@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ #include <QMenuBar>
+ #include <QUrl>
+ #include <QMouseEvent>
++#include <QScreen>
+ #ifdef Q_OS_OSX
+ #include <QFileOpenEvent>
+ #endif
+@@ -334,6 +335,8 @@ struct MainWindow::Private
+ q, &MainWindow::slotUpdateCaption);
+ connect(mViewMainPage, &ViewMainPage::completed,
+ q, &MainWindow::slotPartCompleted);
++ connect(mViewMainPage, &ViewMainPage::completed,
++ q, &MainWindow::autoResize);
+ connect(mViewMainPage, &ViewMainPage::previousImageRequested,
+ q, &MainWindow::goToPrevious);
+ connect(mViewMainPage, &ViewMainPage::nextImageRequested,
+@@ -401,7 +404,7 @@ struct MainWindow::Private
+ action->setText(i18nc("@action reload the currently viewed image", "Reload"));
+ action->setIcon(QIcon::fromTheme("view-refresh"));
+ actionCollection->setDefaultShortcuts(action, KStandardShortcut::reload());
+-
++
+ QAction * replaceLocationAction = actionCollection->addAction(QStringLiteral("replace_location"));
+ replaceLocationAction->setText(i18nc("@action:inmenu Navigation Bar", "Replace Location"));
+ actionCollection->setDefaultShortcut(replaceLocationAction, Qt::CTRL + Qt::Key_L);
+@@ -1013,7 +1016,7 @@ void MainWindow::setActiveViewModeAction(QAction* action)
+ setCaption(QString());
+ }
+ d->autoAssignThumbnailProvider();
+- toggleSideBar(d->sideBarVisibility());
++ toggleSideBar(d->sideBarVisibility());
+ toggleStatusBar(d->statusBarVisibility());
+
+ emit viewModeChanged();
+@@ -1548,7 +1551,7 @@ void MainWindow::showConfigDialog()
+ {
+ // Save first so changes like thumbnail zoom level are not lost when reloading config
+ saveConfig();
+-
++
+ DialogGuard<ConfigDialog> dialog(this);
+ connect(dialog.data(), &KConfigDialog::settingsChanged, this, &MainWindow::loadConfig);
+ dialog->exec();
+@@ -1816,4 +1819,50 @@ void MainWindow::replaceLocation()
+ }
+ }
+
++// Automatically resize window to fit the image's
++// aspect ratio
++void MainWindow::autoResize()
++{
++ // TODO: Configuration menu entry
++ const bool preserveHeight = true;
++
++ QSize size = d->mViewMainPage->currentDocument()->size();
++ float imgAspect = size.width() / (float)size.height();
++
++ QRect windowGeometry = geometry();
++
++ float width = windowGeometry.width();
++ float height = windowGeometry.height();
++
++ // Which measure to change?
++ if (preserveHeight) {
++ width = (int)(height * imgAspect);
++ } else {
++ height = (int)(width * (1 / imgAspect));
++ }
++
++ // Check if the new size grows past the desktop
++ QSizeF desktopSize = QSizeF(qApp->screens()[0]->availableSize()) * 0.8;
++ if (width > desktopSize.width()) {
++ float scale = desktopSize.width() / (float)width;
++ width = (int)(width * scale);
++ height = (int)(height * scale);
++ } else if (height > desktopSize.height()) {
++ float scale = desktopSize.height() / (float)height;
++ width = (int)(width * scale);
++ height = (int)(height * scale);
++ }
++
++ // Keep window centered
++ int xDiff = width - windowGeometry.width();
++ int yDiff = height - windowGeometry.height();
++
++ setGeometry(
++ windowGeometry.x() - xDiff / 2,
++ windowGeometry.y() - yDiff / 2,
++ width,
++ height
++ );
++}
++
+ } // namespace
+diff --git a/app/mainwindow.h b/app/mainwindow.h
+index 33ac31f5..d8bae5f8 100644
+--- a/app/mainwindow.h
++++ b/app/mainwindow.h
+@@ -132,9 +132,11 @@ private Q_SLOTS:
+
+ void showFirstDocumentReached();
+ void showLastDocumentReached();
+-
++
+ void replaceLocation();
+
++ void autoResize();
++
+ private:
+ struct Private;
+ MainWindow::Private* const d;