From 4e2d3c95495a2ae1beb9156ec74bf299cddf604b Mon Sep 17 00:00:00 2001 From: stojce Date: Fri, 14 Mar 2014 23:24:32 +0100 Subject: [PATCH] styling QSlider --- interface/interface_en.ts | 125 ++++++++++++++++++++++- interface/resources/styles/global.qss | 30 ++++-- interface/src/Menu.cpp | 142 +------------------------- interface/src/ui/FramelessDialog.cpp | 10 +- interface/src/ui/FramelessDialog.h | 2 +- 5 files changed, 154 insertions(+), 155 deletions(-) diff --git a/interface/interface_en.ts b/interface/interface_en.ts index c52ec91671..18ae5f446c 100644 --- a/interface/interface_en.ts +++ b/interface/interface_en.ts @@ -113,22 +113,139 @@ Menu - + Open .ini config file - - + + Text files (*.ini) - + Save .ini config file + + PreferencesDialog + + + + Avatar + + + + + + <html><head/><body><p>Avatar display name <span style=" color:#909090;">(optional)</span></p></body></html> + + + + + + Not showing a name + + + + + + Head + + + + + + Body + + + + + + Advanced Tuning + + + + + + It's not recomended that you play with these settings unless you've looked into exactly what they do. + + + + + + <p>Avatar</p> + + + + + + Lean scale (applies to Faceshift users) + + + + + + Vertical field of view + + + + + + Avatar scale (default is 1.0) + + + + + + Pupil dillation + + + + + + Audio Jitter Buffer Samples (0 for automatic) + + + + + + Faceshift eye detection + + + + + + <html><head/><body><p>Voxels</p></body></html> + + + + + + Maximum voxels + + + + + + Max voxels sent each second + + + + + + Cancel + + + + + + Save all changes + + + QObject diff --git a/interface/resources/styles/global.qss b/interface/resources/styles/global.qss index e3548fb52e..87e142eb00 100644 --- a/interface/resources/styles/global.qss +++ b/interface/resources/styles/global.qss @@ -33,18 +33,18 @@ QPushButton { padding: 10px 15px; } - QSpinBox { padding: 5px; border-width: 1; } +QDoubleSpinBox::up-button, QSpinBox::up-button { width: 25px; height: 18px; - background-image: url(resources/styles/up.svg); + background-image: url(styles/up.svg); background-repeat: no-repeat; border: 1px #ccc solid; @@ -52,14 +52,32 @@ QSpinBox::up-button { border-top-right-radius: 2px; } +QDoubleSpinBox::down-button, QSpinBox::down-button { width: 25px; height: 18px; - background-image: url(resources/styles/down.svg); + background-image: url(styles/down.svg); background-repeat: no-repeat; border: 1px #ccc solid; - - border-top-left-radius: 2px; - border-top-right-radius: 2px; +} + +QSlider { + width: 125px; + height: 18px; +} + +QSlider::groove:horizontal { + border: none; + background-image: url(styles/slider-bg.svg); + background-repeat: no-repeat; + background-position: center center; +} + +QSlider::handle:horizontal { + width: 18px; + height: 18px; + background-image: url(styles/slider-handle.svg); + background-repeat: no-repeat; + background-position: center center; } diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 1d3b6753ff..df9e1d40dc 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -687,148 +687,8 @@ void Menu::loginForCurrentDomain() { void Menu::editPreferences() { if (! _preferencesDialog) { _preferencesDialog = new PreferencesDialog(Application::getInstance()->getGLWidget()); - _preferencesDialog->show(); } - _preferencesDialog->raise(); - - /* - - Application* applicationInstance = Application::getInstance(); - - QDialog dialog(applicationInstance->getWindow()); - dialog.setWindowTitle("Interface Preferences"); - - QBoxLayout* layout = new QBoxLayout(QBoxLayout::TopToBottom); - dialog.setLayout(layout); - - QFormLayout* form = new QFormLayout(); - layout->addLayout(form, 1); - - QString faceURLString = applicationInstance->getAvatar()->getHead()->getFaceModel().getURL().toString(); - QLineEdit* faceURLEdit = new QLineEdit(faceURLString); - faceURLEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH); - faceURLEdit->setPlaceholderText(DEFAULT_HEAD_MODEL_URL.toString()); - form->addRow("Face URL:", faceURLEdit); - - QString skeletonURLString = applicationInstance->getAvatar()->getSkeletonModel().getURL().toString(); - QLineEdit* skeletonURLEdit = new QLineEdit(skeletonURLString); - skeletonURLEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH); - skeletonURLEdit->setPlaceholderText(DEFAULT_BODY_MODEL_URL.toString()); - form->addRow("Skeleton URL:", skeletonURLEdit); - - QString displayNameString = applicationInstance->getAvatar()->getDisplayName(); - QLineEdit* displayNameEdit = new QLineEdit(displayNameString); - displayNameEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH); - form->addRow("Display name:", displayNameEdit); - - QSlider* pupilDilation = new QSlider(Qt::Horizontal); - pupilDilation->setValue(applicationInstance->getAvatar()->getHead()->getPupilDilation() * pupilDilation->maximum()); - form->addRow("Pupil Dilation:", pupilDilation); - - QSlider* faceshiftEyeDeflection = new QSlider(Qt::Horizontal); - faceshiftEyeDeflection->setValue(_faceshiftEyeDeflection * faceshiftEyeDeflection->maximum()); - form->addRow("Faceshift Eye Deflection:", faceshiftEyeDeflection); - - QSpinBox* fieldOfView = new QSpinBox(); - fieldOfView->setMaximum(180.f); - fieldOfView->setMinimum(1.f); - fieldOfView->setValue(_fieldOfView); - form->addRow("Vertical Field of View (Degrees):", fieldOfView); - - QDoubleSpinBox* leanScale = new QDoubleSpinBox(); - leanScale->setValue(applicationInstance->getAvatar()->getLeanScale()); - form->addRow("Lean Scale:", leanScale); - - QDoubleSpinBox* avatarScale = new QDoubleSpinBox(); - avatarScale->setValue(applicationInstance->getAvatar()->getScale()); - form->addRow("Avatar Scale:", avatarScale); - - QSpinBox* audioJitterBufferSamples = new QSpinBox(); - audioJitterBufferSamples->setMaximum(10000); - audioJitterBufferSamples->setMinimum(-10000); - audioJitterBufferSamples->setValue(_audioJitterBufferSamples); - form->addRow("Audio Jitter Buffer Samples (0 for automatic):", audioJitterBufferSamples); - - QSpinBox* maxVoxels = new QSpinBox(); - const int MAX_MAX_VOXELS = 5000000; - const int MIN_MAX_VOXELS = 0; - const int STEP_MAX_VOXELS = 50000; - maxVoxels->setMaximum(MAX_MAX_VOXELS); - maxVoxels->setMinimum(MIN_MAX_VOXELS); - maxVoxels->setSingleStep(STEP_MAX_VOXELS); - maxVoxels->setValue(_maxVoxels); - form->addRow("Maximum Voxels:", maxVoxels); - - QSpinBox* maxVoxelsPPS = new QSpinBox(); - const int MAX_MAX_VOXELS_PPS = 6000; - const int MIN_MAX_VOXELS_PPS = 60; - const int STEP_MAX_VOXELS_PPS = 10; - maxVoxelsPPS->setMaximum(MAX_MAX_VOXELS_PPS); - maxVoxelsPPS->setMinimum(MIN_MAX_VOXELS_PPS); - maxVoxelsPPS->setSingleStep(STEP_MAX_VOXELS_PPS); - maxVoxelsPPS->setValue(_maxVoxelPacketsPerSecond); - form->addRow("Maximum Voxels Packets Per Second:", maxVoxelsPPS); - - QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); - dialog.connect(buttons, SIGNAL(accepted()), SLOT(accept())); - dialog.connect(buttons, SIGNAL(rejected()), SLOT(reject())); - layout->addWidget(buttons); - - int ret = dialog.exec(); - if (ret == QDialog::Accepted) { - QUrl faceModelURL(faceURLEdit->text()); - - bool shouldDispatchIdentityPacket = false; - - if (faceModelURL.toString() != faceURLString) { - // change the faceModelURL in the profile, it will also update this user's BlendFace - applicationInstance->getAvatar()->setFaceModelURL(faceModelURL); - shouldDispatchIdentityPacket = true; - } - - QUrl skeletonModelURL(skeletonURLEdit->text()); - - if (skeletonModelURL.toString() != skeletonURLString) { - // change the skeletonModelURL in the profile, it will also update this user's Body - applicationInstance->getAvatar()->setSkeletonModelURL(skeletonModelURL); - shouldDispatchIdentityPacket = true; - } - - QString displayNameStr(displayNameEdit->text()); - - if (displayNameStr != displayNameString) { - applicationInstance->getAvatar()->setDisplayName(displayNameStr); - shouldDispatchIdentityPacket = true; - } - - if (shouldDispatchIdentityPacket) { - applicationInstance->getAvatar()->sendIdentityPacket(); - } - - applicationInstance->getAvatar()->getHead()->setPupilDilation(pupilDilation->value() / (float)pupilDilation->maximum()); - - _maxVoxels = maxVoxels->value(); - applicationInstance->getVoxels()->setMaxVoxels(_maxVoxels); - - _maxVoxelPacketsPerSecond = maxVoxelsPPS->value(); - - applicationInstance->getAvatar()->setLeanScale(leanScale->value()); - applicationInstance->getAvatar()->setClampedTargetScale(avatarScale->value()); - - _audioJitterBufferSamples = audioJitterBufferSamples->value(); - - if (_audioJitterBufferSamples != 0) { - applicationInstance->getAudio()->setJitterBufferSamples(_audioJitterBufferSamples); - } - - _fieldOfView = fieldOfView->value(); - applicationInstance->resizeGL(applicationInstance->getGLWidget()->width(), applicationInstance->getGLWidget()->height()); - - _faceshiftEyeDeflection = faceshiftEyeDeflection->value() / (float)faceshiftEyeDeflection->maximum(); - } - QMetaObject::invokeMethod(applicationInstance->getAudio(), "reset", Qt::QueuedConnection); -*/ - sendFakeEnterEvent(); + _preferencesDialog->show(); } void Menu::goToDomain(const QString newDomain) { diff --git a/interface/src/ui/FramelessDialog.cpp b/interface/src/ui/FramelessDialog.cpp index 4ca765b352..94bb218171 100644 --- a/interface/src/ui/FramelessDialog.cpp +++ b/interface/src/ui/FramelessDialog.cpp @@ -6,13 +6,17 @@ // // -#include "FramelessDialog.h" -#include #include +#include + +#include "Application.h" +#include "FramelessDialog.h" FramelessDialog::FramelessDialog(QWidget *parent, Qt::WindowFlags flags) : QDialog(parent, flags | Qt::FramelessWindowHint) { - QFile styleSheet("resources/styles/global.qss"); + + QFile styleSheet(Application::resourcesPath() + "styles/global.qss"); if (styleSheet.open(QIODevice::ReadOnly)) { + QDir::setCurrent(Application::resourcesPath()); setStyleSheet(styleSheet.readAll()); } setWindowOpacity(0.95); diff --git a/interface/src/ui/FramelessDialog.h b/interface/src/ui/FramelessDialog.h index ca11c3eb2f..fd2121ddad 100644 --- a/interface/src/ui/FramelessDialog.h +++ b/interface/src/ui/FramelessDialog.h @@ -20,7 +20,7 @@ class FramelessDialog : public QDialog { public: FramelessDialog(QWidget* parent = 0, Qt::WindowFlags flags = 0); - ~FramelessDialog(); + virtual ~FramelessDialog(); };