Switched to QDockWidget

This commit is contained in:
stojce 2014-03-27 21:50:41 +01:00
parent c1b7a56070
commit 8b6db350da
5 changed files with 55 additions and 103 deletions

View file

@ -132,112 +132,112 @@
<context>
<name>PreferencesDialog</name>
<message>
<location filename="ui/preferencesDialog.ui" line="93"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="619"/>
<location filename="ui/preferencesDialog.ui" line="90"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="618"/>
<source>Cancel</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="128"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="620"/>
<location filename="ui/preferencesDialog.ui" line="125"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="619"/>
<source>Save all changes</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="199"/>
<location filename="ui/preferencesDialog.ui" line="576"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="621"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="630"/>
<location filename="ui/preferencesDialog.ui" line="196"/>
<location filename="ui/preferencesDialog.ui" line="573"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="620"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="629"/>
<source>Avatar</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="233"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="622"/>
<location filename="ui/preferencesDialog.ui" line="230"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="621"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Avatar display name &lt;span style=&quot; color:#909090;&quot;&gt;(optional)&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="269"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="623"/>
<location filename="ui/preferencesDialog.ui" line="266"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="622"/>
<source>Not showing a name</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="297"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="624"/>
<location filename="ui/preferencesDialog.ui" line="294"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="623"/>
<source>Head</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="398"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="626"/>
<location filename="ui/preferencesDialog.ui" line="395"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="625"/>
<source>Body</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="509"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="628"/>
<location filename="ui/preferencesDialog.ui" line="506"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="627"/>
<source>Advanced Tuning</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="540"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="629"/>
<location filename="ui/preferencesDialog.ui" line="537"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="628"/>
<source>It&apos;s not recomended that you play with these settings unless you&apos;ve looked into exactly what they do.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="608"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="631"/>
<location filename="ui/preferencesDialog.ui" line="605"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="630"/>
<source>Vertical field of view</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="711"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="632"/>
<location filename="ui/preferencesDialog.ui" line="708"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="631"/>
<source>Lean scale (applies to Faceshift users)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="796"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="633"/>
<location filename="ui/preferencesDialog.ui" line="793"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="632"/>
<source>Avatar scale &lt;span style=&quot; color:#909090;&quot;&gt;(default is 1.0)&lt;/span&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="878"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="634"/>
<location filename="ui/preferencesDialog.ui" line="875"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="633"/>
<source>Pupil dillation</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="957"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="635"/>
<location filename="ui/preferencesDialog.ui" line="954"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="634"/>
<source>Audio Jitter Buffer Samples (0 for automatic)</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="1048"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="636"/>
<location filename="ui/preferencesDialog.ui" line="1045"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="635"/>
<source>Faceshift eye detection</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="1128"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="637"/>
<location filename="ui/preferencesDialog.ui" line="1125"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="636"/>
<source>Voxels</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="1160"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="638"/>
<location filename="ui/preferencesDialog.ui" line="1157"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="637"/>
<source>Maximum voxels</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="ui/preferencesDialog.ui" line="1239"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="639"/>
<location filename="ui/preferencesDialog.ui" line="1236"/>
<location filename="../build/interface/ui_preferencesDialog.h" line="638"/>
<source>Max voxels sent each second</source>
<translation type="unfinished"></translation>
</message>

View file

@ -714,10 +714,11 @@ void Menu::loginForCurrentDomain() {
void Menu::editPreferences() {
if (!_preferencesDialog) {
_preferencesDialog = new PreferencesDialog(Application::getInstance()->getWindow());
_preferencesDialog->show();
Application::getInstance()->getWindow()->addDockWidget(Qt::LeftDockWidgetArea, _preferencesDialog = new PreferencesDialog());
} else {
Application::getInstance()->getWindow()->removeDockWidget(_preferencesDialog);
_preferencesDialog->close();
}
_preferencesDialog->raise();
}
void Menu::goToDomain(const QString newDomain) {

View file

@ -15,38 +15,17 @@
#include "Application.h"
#include "FramelessDialog.h"
const int RESIZE_HANDLE_WIDTH = 7;
FramelessDialog::FramelessDialog(QWidget *parent, Qt::WindowFlags flags) :
QDialog(parent, flags | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint),
_isResizing(false) {
QDockWidget(parent, flags) {
setAttribute(Qt::WA_DeleteOnClose);
installEventFilter(this);
startTimer(20);
}
// set as floating
setFeatures(QDockWidget::DockWidgetFloatable);
void FramelessDialog::timerEvent(QTimerEvent *event) {
move(parentWidget()->pos().x(), parentWidget()->pos().y() + 22);
setFixedHeight(parentWidget()->size().height());
}
// remove titlebar
setTitleBarWidget(new QWidget());
void FramelessDialog::paintEvent(QPaintEvent* event) {
//move(parentWidget()->pos());
//resize(size().width(), parentWidget()->size().height());
}
void FramelessDialog::showEvent(QShowEvent* event) {
QDesktopWidget desktop;
// move to upper left
// move(desktop.availableGeometry().x(), desktop.availableGeometry().y());
move(parentWidget()->pos().x(), parentWidget()->pos().y() + 22);
// keep full height
setFixedHeight(parentWidget()->size().height());
// resize(size().width(), desktop.availableGeometry().height());
setAllowedAreas(Qt::LeftDockWidgetArea);
}
void FramelessDialog::setStyleSheetFile(const QString& fileName) {
@ -54,29 +33,6 @@ void FramelessDialog::setStyleSheetFile(const QString& fileName) {
QFile styleSheet(Application::resourcesPath() + fileName);
if (styleSheet.open(QIODevice::ReadOnly) && globalStyleSheet.open(QIODevice::ReadOnly) ) {
QDir::setCurrent(Application::resourcesPath());
QDialog::setStyleSheet(globalStyleSheet.readAll() + styleSheet.readAll());
setStyleSheet(globalStyleSheet.readAll() + styleSheet.readAll());
}
}
void FramelessDialog::mousePressEvent(QMouseEvent* mouseEvent) {
if (abs(mouseEvent->pos().x() - size().width()) < RESIZE_HANDLE_WIDTH && mouseEvent->button() == Qt::LeftButton) {
_isResizing = true;
QApplication::setOverrideCursor(Qt::SizeHorCursor);
}
}
void FramelessDialog::mouseReleaseEvent(QMouseEvent* mouseEvent) {
QApplication::restoreOverrideCursor();
_isResizing = false;
}
void FramelessDialog::mouseMoveEvent(QMouseEvent* mouseEvent) {
if (_isResizing) {
resize(mouseEvent->pos().x(), size().height());
}
}
FramelessDialog::~FramelessDialog() {
}

View file

@ -9,29 +9,27 @@
#ifndef __hifi__FramelessDialog__
#define __hifi__FramelessDialog__
#include <QDialog>
#include <QDockWidget>
#include <QGridLayout>
#include <QString>
#include <QPainter>
#include <QStyleOptionTitleBar>
#include <QtCore/QTimer>
class FramelessDialog : public QDialog {
class FramelessDialog : public QDockWidget {
Q_OBJECT
public:
FramelessDialog(QWidget* parent = 0, Qt::WindowFlags flags = 0);
virtual ~FramelessDialog();
void setStyleSheetFile(const QString& fileName);
protected:
/*
virtual void mouseMoveEvent(QMouseEvent* mouseEvent);
virtual void mousePressEvent(QMouseEvent* mouseEvent);
virtual void mouseReleaseEvent(QMouseEvent* mouseEvent);
virtual void showEvent(QShowEvent* event);
void paintEvent(QPaintEvent* event);
void timerEvent(QTimerEvent *event);
*/
private:
bool _isResizing;

View file

@ -2,9 +2,6 @@
<ui version="4.0">
<class>PreferencesDialog</class>
<widget class="FramelessDialog" name="PreferencesDialog">
<property name="windowModality">
<enum>Qt::NonModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
@ -251,7 +248,7 @@ color: #0e7077</string>
<property name="minimumSize">
<size>
<width>280</width>
<height>20</height>
<height>0</height>
</size>
</property>
<property name="font">