This commit is contained in:
stojce 2014-04-09 22:14:35 +02:00
parent c9605be193
commit a1c6843bd4
4 changed files with 26 additions and 23 deletions

View file

@ -1,9 +1,12 @@
//
// FramelessDialog.cpp
// hifi
// interface/src/ui
//
// Created by Stojce Slavkovski on 2/20/14.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "Application.h"
@ -25,20 +28,17 @@ QDialog(parent, flags | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint) {
bool FramelessDialog::eventFilter(QObject* sender, QEvent* event) {
switch (event->type()) {
case QEvent::Move:
if (sender == parentWidget()) {
// move to upper left corner on app move
move(parentWidget()->geometry().topLeft());
}
break;
case QEvent::Resize:
if (sender == parentWidget()) {
// keep full app height on resizing the app
setFixedHeight(parentWidget()->size().height());
}
break;
case QEvent::WindowStateChange:
if (parentWidget()->isMinimized()) {
setHidden(true);
@ -46,16 +46,13 @@ bool FramelessDialog::eventFilter(QObject* sender, QEvent* event) {
setHidden(false);
}
break;
case QEvent::ApplicationDeactivate:
// hide on minimize and focus lost
setHidden(true);
break;
case QEvent::ApplicationActivate:
setHidden(false);
break;
default:
break;
}
@ -63,10 +60,6 @@ bool FramelessDialog::eventFilter(QObject* sender, QEvent* event) {
return false;
}
FramelessDialog::~FramelessDialog() {
deleteLater();
}
void FramelessDialog::setStyleSheetFile(const QString& fileName) {
QFile globalStyleSheet(Application::resourcesPath() + "styles/global.qss");
QFile styleSheet(Application::resourcesPath() + fileName);

View file

@ -1,13 +1,17 @@
//
// FramelessDialog.h
// hifi
// interface/src/ui
//
// Created by Stojce Slavkovski on 2/20/14.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef __hifi__FramelessDialog__
#define __hifi__FramelessDialog__
#ifndef hifi_FramelessDialog_h
#define hifi_FramelessDialog_h
#include <QDialog>
@ -16,7 +20,6 @@ class FramelessDialog : public QDialog {
public:
FramelessDialog(QWidget* parent = 0, Qt::WindowFlags flags = 0);
~FramelessDialog();
void setStyleSheetFile(const QString& fileName);
protected:
@ -32,4 +35,4 @@ private:
};
#endif /* defined(__hifi__FramelessDialog__) */
#endif // hifi_FramelessDialog_h

View file

@ -1,11 +1,15 @@
//
// PreferencesDialog.cpp
// hifi
// interface/src/ui
//
// Created by Stojce Slavkovski on 2/22/14.
// Created by Stojce Slavkovski on 2/20/14.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "Application.h"
#include "Menu.h"
#include "PreferencesDialog.h"

View file

@ -1,13 +1,16 @@
//
// PreferencesDialog.h
// hifi
// interface/src/ui
//
// Created by Stojce Slavkovski on 2/22/14.
// Created by Stojce Slavkovski on 2/20/14.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef __hifi__PreferencesDialog__
#define __hifi__PreferencesDialog__
#ifndef hifi_PreferencesDialog_h
#define hifi_PreferencesDialog_h
#include "FramelessDialog.h"
#include "ui_preferencesDialog.h"
@ -42,4 +45,4 @@ private slots:
};
#endif /* defined(__hifi__PreferencesDialog__) */
#endif // hifi_PreferencesDialog_h