<rect>
<x>0</x>
<y>0</y>
- <width>280</width>
- <height>348</height>
+ <width>302</width>
+ <height>407</height>
</rect>
</property>
<property name="windowTitle">
<property name="title">
<string>AniDB Connection Settings</string>
</property>
- <layout class="QFormLayout" name="formLayout_2">
+ <layout class="QFormLayout" name="formLayout_4">
<item row="0" column="0">
<widget class="QLabel" name="lHost">
<property name="text">
<widget class="QLineEdit" name="user"/>
</item>
<item row="4" column="0">
- <widget class="QLabel" name="pPass">
+ <widget class="QLabel" name="lPass">
<property name="text">
<string>Password:</string>
</property>
</layout>
</widget>
</item>
+ <item>
+ <widget class="QGroupBox" name="encryption">
+ <property name="title">
+ <string>Encryption</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ <layout class="QFormLayout" name="formLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="lApiKey">
+ <property name="text">
+ <string>API Key:</string>
+ </property>
+ <property name="buddy">
+ <cstring>apiKey</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="apiKey">
+ <property name="echoMode">
+ <enum>QLineEdit::Password</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<tabstop>localPort</tabstop>
<tabstop>user</tabstop>
<tabstop>pass</tabstop>
- <tabstop>groupBox_2</tabstop>
+ <tabstop>encryption</tabstop>
+ <tabstop>apiKey</tabstop>
<tabstop>automark</tabstop>
<tabstop>paths</tabstop>
<tabstop>opSkip</tabstop>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
- <x>266</x>
- <y>338</y>
+ <x>292</x>
+ <y>397</y>
</hint>
<hint type="destinationlabel">
- <x>157</x>
+ <x>426</x>
<y>274</y>
</hint>
</hints>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
- <x>270</x>
- <y>338</y>
+ <x>292</x>
+ <y>397</y>
</hint>
<hint type="destinationlabel">
- <x>279</x>
+ <x>548</x>
<y>274</y>
</hint>
</hints>
#include <QSettings>
#include <QStyle>
#include <QDesktopServices>
+#include <QSystemTrayIcon>
+#include <QMenu>
#include <QPixmap>
#include "menu.h"
#include <QDebug>
+#ifdef Q_OS_WIN
+# include <windows.h>
+#endif
+
VideoWindow::VideoWindow(QWidget *parent) : QMainWindow(parent)
#ifdef BROWSERPLUGIN_BUILD
, QtNPBindable()
m_automark = 0;
#endif
+ tray = new QSystemTrayIcon(this);
+
videoPlayer = new VideoPlayer(this, this);
#ifdef GRAPHICS_VIEW_VIDEO
#ifndef BROWSERPLUGIN_BUILD
addAction("togglePinMenu", "Pin Menu", QKeySequence(), true);
addAction("toggleStayOnTop", "Stay on top", QKeySequence("T"), true);
+ addAction("toggleFrameless", "Frameless", QKeySequence("Y"), true);
+ addAction("toggleOverlay", "Overlay", QKeySequence("U"), true);
m_actions["togglePinMenu"]->setChecked(true);
m_actions["toggleStayOnTop"]->setChecked(false);
+ m_actions["toggleFrameless"]->setChecked(false);
+ m_actions["toggleOverlay"]->setChecked(false);
#endif
#ifndef NO_ANIDBUDPCLIENT
addAction("markWatched", "Mark Watched", QKeySequence("CTRL+M"));
menu = new Menu(this);
menu->addActions(QWidget::actions());
+ tray->setContextMenu(new QMenu);
+ tray->contextMenu()->addActions(QWidget::actions());
+ tray->setIcon(QIcon(":/icon.png"));
+ tray->show();
#ifdef GRAPHICS_VIEW_VIDEO
videoSceneMenu = new Menu();
connect(m_actions["togglePlay"], SIGNAL(triggered()), videoPlayer, SLOT(togglePlay()));
connect(m_actions["togglePinMenu"], SIGNAL(toggled(bool)), this, SLOT(setPinMenu(bool)));
connect(m_actions["toggleStayOnTop"], SIGNAL(toggled(bool)), this, SLOT(toggleStayOnTop()));
+ connect(m_actions["toggleFrameless"], SIGNAL(toggled(bool)), this, SLOT(toggleFrameless()));
+ connect(m_actions["toggleOverlay"], SIGNAL(toggled(bool)), this, SLOT(toggleOverlay()));
#endif
connect(m_actions["pause"], SIGNAL(triggered()), videoPlayer, SLOT(pause()));
connect(m_actions["stop"], SIGNAL(triggered()), videoPlayer, SLOT(stop()));
AniDBUdpClient::Client::instance()->setCompression(true);
AniDBUdpClient::Client::instance()->setIdlePolicy(AniDBUdpClient::ImmediateLogoutIdlePolicy);
#endif
-
}
VideoWindow::~VideoWindow()
void VideoWindow::toggleStayOnTop()
{
- setWindowFlags(windowFlags() ^ Qt::WindowStaysOnTopHint);
-#ifdef Q_WS_X11
- bool menuVisible = menu->isVisible();
- menu->setWindowFlags(menu->windowFlags() ^ Qt::WindowStaysOnTopHint);
- menu->setVisible(menuVisible);
-#endif
- show();
+ updateWindowFlags();
+}
+
+void VideoWindow::toggleFrameless()
+{
+ updateWindowFlags();
+}
+
+void VideoWindow::toggleOverlay()
+{
+ updateWindowFlags();
}
void VideoWindow::about()
void VideoWindow::mousePressEvent(QMouseEvent *event)
{
+ if (event->button() == Qt::LeftButton)
+ {
+ dragPosition = event->globalPos() - frameGeometry().topLeft();
+ dragged = true;
+ event->accept();
+ }
+}
+
+void VideoWindow::mouseMoveEvent(QMouseEvent *event)
+{
+ mouseMoved = true;
+ if (!dragged)
+ return;
+
+ if (event->buttons() & Qt::LeftButton)
+ {
+ move(event->globalPos() - dragPosition);
+ event->accept();
+ }
+}
+
+void VideoWindow::mouseReleaseEvent(QMouseEvent *event)
+{
+ dragged = false;
+ if (mouseMoved)
+ {
+ mouseMoved = false;
+ return;
+ }
+
if (event->button() == Qt::LeftButton)
{
toggleMenu();
}
else
{
- QMainWindow::mousePressEvent(event);
+ QMainWindow::mouseReleaseEvent(event);
}
}
dialog.setLocalPort(AniDBUdpClient::Client::instance()->localPort());
dialog.setUser(AniDBUdpClient::Client::instance()->user());
dialog.setPass(AniDBUdpClient::Client::instance()->pass());
+ dialog.setEncryption(AniDBUdpClient::Client::instance()->encryptionEnabled());
+ dialog.setApiKey(AniDBUdpClient::Client::instance()->apiKey());
dialog.setAutomark(m_automark);
dialog.setPaths(m_automarkPaths);
dialog.setOpSkip(m_opSkip);
AniDBUdpClient::Client::instance()->setLocalPort(dialog.localPort());
AniDBUdpClient::Client::instance()->setUser(dialog.user());
AniDBUdpClient::Client::instance()->setPass(dialog.pass());
+ AniDBUdpClient::Client::instance()->setEncryptionEnabled(dialog.encryption());
+ AniDBUdpClient::Client::instance()->setApiKey(dialog.apiKey());
m_automark = dialog.automark();
m_automarkPaths = dialog.paths();
m_opSkip = dialog.opSkip();
settings.beginGroup("videoWindow");
settings.setValue("geometry", saveGeometry());
settings.setValue("stayOnTop", m_actions["toggleStayOnTop"]->isChecked());
+ settings.setValue("frameless", m_actions["toggleFrameless"]->isChecked());
settings.endGroup();
settings.beginGroup("menu");
settings.setValue("geometry", menu->saveGeometry());
settings.setValue("localPort", AniDBUdpClient::Client::instance()->localPort());
settings.setValue("user", AniDBUdpClient::Client::instance()->user());
settings.setValue("pass", AniDBUdpClient::Client::instance()->pass());
+ settings.setValue("encryption", AniDBUdpClient::Client::instance()->encryptionEnabled());
+ settings.setValue("apiKey", AniDBUdpClient::Client::instance()->apiKey());
settings.setValue("automark", m_automark);
settings.setValue("paths", m_automarkPaths);
settings.endGroup();
settings.beginGroup("videoWindow");
restoreGeometry(settings.value("geometry", saveGeometry()).toByteArray());
m_actions["toggleStayOnTop"]->setChecked(settings.value("stayOnTop", false).toBool());
+ m_actions["toggleFrameless"]->setChecked(settings.value("frameless", false).toBool());
settings.endGroup();
settings.beginGroup("menu");
menu->restoreState(settings.value("state", menu->saveState()).toByteArray());
AniDBUdpClient::Client::instance()->setLocalPort(settings.value("localPort", 9001).toInt());
AniDBUdpClient::Client::instance()->setUser(settings.value("user").toString());
AniDBUdpClient::Client::instance()->setPass(settings.value("pass").toString());
+ AniDBUdpClient::Client::instance()->setEncryptionEnabled(settings.value("encryption").toBool());
+ AniDBUdpClient::Client::instance()->setApiKey(settings.value("apiKey").toString());
m_automark = settings.value("automark", 0).toInt();
m_automarkPaths = settings.value("paths", QStringList()).toStringList();
settings.endGroup();
#endif
}
+void VideoWindow::updateWindowFlags()
+{
+ if (m_actions["toggleStayOnTop"]->isChecked())
+ setWindowFlags(windowFlags() | Qt::WindowStaysOnTopHint);
+ else
+ setWindowFlags(windowFlags() & ~Qt::WindowStaysOnTopHint);
+
+#ifdef Q_WS_X11
+ bool menuVisible = menu->isVisible();
+ menu->setWindowFlags(menu->windowFlags() ^ Qt::WindowStaysOnTopHint);
+ menu->setVisible(menuVisible);
+#endif
+
+ if (m_actions["toggleFrameless"]->isChecked())
+ setWindowFlags((windowFlags() & (Qt::Window | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint)) | Qt::FramelessWindowHint);
+ else
+ setWindowFlags((windowFlags() & (Qt::Window | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint)) & ~Qt::FramelessWindowHint);
+
+
+#ifdef Q_OS_WIN
+ if (m_actions["toggleOverlay"]->isChecked())
+ {
+ setWindowOpacity(.5);
+ SetWindowLongPtr(winId(), GWL_EXSTYLE, GetWindowLongPtr(winId(), GWL_EXSTYLE) | WS_EX_LAYERED | WS_EX_TRANSPARENT);
+ }
+ else
+ {
+ setWindowOpacity(1);
+ SetWindowLongPtr(winId(), GWL_EXSTYLE, GetWindowLongPtr(winId(), GWL_EXSTYLE) & ~WS_EX_TRANSPARENT);
+ }
+#endif
+
+ show();
+}
+
#ifdef BROWSERPLUGIN_BUILD
bool VideoWindow::readData(QIODevice *source, const QString &format)
{