#include <QTranslator>
#include <QKeyEvent>
-#include "player/player.h"
-
#include "library.h"
#include "timerdialog.h"
#include "equalizerdialog.h"
#include "saveplaylistdialog.h"
#include "settingsform.h"
-#include <QtGui/QX11Info>
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-
using namespace SomePlayer::DataObjects;
using namespace SomePlayer::Storage;
_manage_library_form = new ManageLibraryForm(_library, this);
_settings_form = new SettingsForm(this);
_settings_form->hide();
+ _about_form = new AboutForm(this);
+ _about_form->hide();
connect(_player_form, SIGNAL(library()), this, SLOT(library()));
connect(_library_form, SIGNAL(refreshPlayer()), this, SLOT(player()));
connect(ui->actionManageLibrary, SIGNAL(triggered()), this, SLOT(_manage_library()));
connect(_player_form, SIGNAL(clearPlaylist()), this, SLOT(_clear_current_playlist()));
connect(ui->actionSetTimer, SIGNAL(triggered()), this, SLOT(_set_timer()));
connect(ui->actionEqualizer, SIGNAL(triggered()), this, SLOT(_equalizer()));
+ connect(ui->actionOnlineHelp, SIGNAL(triggered()), _about_form, SLOT(onlineHelp()));
connect(_library, SIGNAL(done()), _library_form, SLOT(refresh()));
connect(_player_form, SIGNAL(refreshLibrary()), _library_form, SLOT(refresh()));
connect(_manage_library_form, SIGNAL(refreshLibrary()), _library_form, SLOT(refresh()));
connect(_settings_form, SIGNAL(iconsChanged()), _library_form, SLOT(updateIcons()));
connect(_settings_form, SIGNAL(iconsChanged()), _manage_library_form, SLOT(updateIcons()));
connect(_settings_form, SIGNAL(iconsChanged()), _directory_form, SLOT(updateIcons()));
+ connect(_settings_form, SIGNAL(iconsChanged()), _about_form, SLOT(updateIcons()));
connect(_settings_form, SIGNAL(gradientChanged()), _player_form, SLOT(checkGradient()));
connect(_settings_form, SIGNAL(gradientChanged()), _library_form, SLOT(checkGradient()));
connect(_settings_form, SIGNAL(gradientChanged()), _directory_form, SLOT(checkGradient()));
_hw_zoom_policy_changed();
config.setValue("fmtx/enabled", "no");
setWindowTitle("SomePlayer");
+
+ QList<QWidget *> widgets = ui->centralWidget->findChildren<QWidget *>();
+ foreach (QWidget *widget, widgets) {
+ if (widget->objectName() != "searchLine") {
+ widget->installEventFilter(this);
+ }
+ }
}
MainWindow::~MainWindow()
}
void MainWindow::about() {
- QMessageBox::about(this, QString("About SomePlayer v")+_SOMEPLAYER_VERSION_, "Alternate music player for Maemo 5 "
- "written in C++ with Qt4\n\n"
- "Author: Nikolay Tischenko aka \"somebody\" <niktischenko@gmail.com>");
+ _about_form->show();
}
void MainWindow::player() {
QString name = dialog.selectedName();
bool append = false;
if (playlists.contains(name)) {
- if (QMessageBox::question(this, "Append to playlist?", "Playlist with name \""+name+"\" already exists.\n"
- "Dow you want to append current playlist to it?",
- QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok) {
- append = true;
- } else {
- append = false;
+ if (QMessageBox::question(this, "Overwrite playlist?", "Overwrite playlist \""+name+"\"?", QMessageBox::Ok, QMessageBox::Cancel)
+ != QMessageBox::Ok) {
+ return;
}
+ append = (QMessageBox::question(this, "Append to playlist?", "Playlist with name \""+name+"\" already exists.\n"
+ "Dow you want to append current playlist to it?",
+ QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok);
}
if (append) {
Playlist target = _library->getPlaylist(name);
}
void MainWindow::_clear_current_playlist() {
+ CONFIRM_ACTION(this, tr("Clear playlist?"))
Playlist playlist = _library->getCurrentPlaylist();
playlist.clear();
_library->saveCurrentPlaylist(playlist);
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();
_manage_library_form->updateTranslations();
_directory_form->updateTranslations();
_settings_form->updateTranslations();
+ _about_form->updateTranslations();
}
void MainWindow::_hw_zoom_policy_changed() {
}
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);
}
}
system("fmtx_client -p 0 2>&1 >/dev/null");
}
}
+
+bool MainWindow::eventFilter(QObject *obj, QEvent *event) {
+ if (event->type() != QEvent::KeyPress) {
+ return QObject::eventFilter(obj, event);
+ }
+ QKeyEvent *keyEvent = (QKeyEvent *) event;
+ int mod = keyEvent->modifiers();
+
+ switch (keyEvent->key()) {
+ case Qt::Key_Space:
+ if ((mod & Qt::ControlModifier) == 0) {
+ _player_form->toggle();
+ }
+ break;
+ case Qt::Key_Enter:
+ // TODO
+ break;
+ case Qt::Key_Right:
+ _player_form->next();
+ break;
+ case Qt::Key_Left:
+ _player_form->prev();
+ break;
+ case Qt::Key_T:
+ _player_form->stop();
+ break;
+ case Qt::Key_R:
+ _player_form->toggleRandom();
+ break;
+ case Qt::Key_V:
+ _player_form->toggleView();
+ break;
+ case Qt::Key_M:
+ _directory_form->show();
+ break;
+ case Qt::Key_L:
+ _library_form->show();
+ break;
+ case Qt::Key_E:
+ _player_form->toggleRepeat();
+ break;
+ case Qt::Key_S:
+ _player_form->toggleToolsWidget();
+ break;
+ case Qt::Key_H:
+ _about_form->onlineHelp();
+ break;
+ default:
+ return QObject::eventFilter(obj, event);
+ }
+
+ return true;
+}