From c296c052b644d9636ff4dda47e35c56c5cfb0144 Mon Sep 17 00:00:00 2001 From: Nikolay Tischenko Date: Sat, 18 Dec 2010 13:16:54 +0600 Subject: [PATCH] Improved hw zoom keys handling --- src/mainwindow.cpp | 22 ++++++++++++++++++++-- src/mainwindow.h | 4 ++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7c22138..681dd02 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -302,12 +302,14 @@ void MainWindow::_change_orientation() { void MainWindow::_orientation_changed() { QRect screenGeometry = QApplication::desktop()->screenGeometry(); if (screenGeometry.width() > screenGeometry.height()) { + _orientation = ORIENTATION_LANDSCAPE; _player_form->landscapeMode(); _library_form->landscapeMode(); _equalizer_dialog->landscapeMode(); _directory_form->lanscapeMode(); _settings_form->landscapeMode(); } else { + _orientation = ORIENTATION_PORTRAIT; _player_form->portraitMode(); _library_form->portraitMode(); _equalizer_dialog->portraitMode(); @@ -373,14 +375,30 @@ void MainWindow::_zoom_key_pressed(quint32 code) { } Config config; QString behavior = config.getValue("hw/zoom_action").toString(); + bool inverted = config.getValue("hw/zoom_inverted").toBool(); + if (inverted) { + if (code == MM_KEY_DOWN) { + code = MM_KEY_UP; + } else { + code = MM_KEY_DOWN; + } + } if (code == MM_KEY_DOWN) { if (behavior == "track") { - _player_form->prev(); + if (_orientation == ORIENTATION_LANDSCAPE) { + _player_form->next(); + } else { + _player_form->prev(); + } _dbus_client.setVolume(_system_volume); } } else if (code == MM_KEY_UP) { if (behavior == "track") { - _player_form->next(); + if (_orientation == ORIENTATION_LANDSCAPE) { + _player_form->prev(); + } else { + _player_form->next(); + } _dbus_client.setVolume(_system_volume); } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 99f9a72..c0bfda8 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -35,6 +35,9 @@ #include "dbusclient.h" #include +#define ORIENTATION_LANDSCAPE 0 +#define ORIENTATION_PORTRAIT 1 + namespace Ui { class MainWindow; } @@ -95,6 +98,7 @@ private: DBusClient _dbus_client; bool _display_unlocked; quint32 _system_volume; // yes, it is here + int _orientation; // 0 - landscape, 1 - portrait }; #endif // MAINWINDOW_H -- 1.7.9.5