Commit cace16dd authored by DreamSourceLab's avatar DreamSourceLab

Make windows frameless and add own titlebar

parent aa9d7c40
......@@ -68,5 +68,9 @@
<file>icons/Hamming.png</file>
<file>icons/Hann.png</file>
<file>icons/Rectangle.png</file>
<file>icons/close.png</file>
<file>icons/maximize.png</file>
<file>icons/minimize.png</file>
<file>icons/restore.png</file>
</qresource>
</RCC>
......@@ -531,7 +531,6 @@ QMenu::separator
margin-right: 5px;
}
QFrame
{
border-radius: 2px;
......@@ -800,28 +799,39 @@ QTabBar::tab:bottom:!selected:hover {
/* LEFT TABS */
QTabBar::tab:left {
color: #b1b1b1;
border: 1px solid #4A4949;
border: 1px transparent #4A4949;
border-left: 1px transparent black;
background-color: #302F2F;
background-color: #48576b;
padding: 5px;
border-top-right-radius: 2px;
border-bottom-right-radius: 2px;
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
}
QTabBar::tab:left:!selected
{
color: #b1b1b1;
background-color: #201F1F;
background-color: #302F2F;
border: 1px transparent #4A4949;
border-right: 1px transparent #4A4949;
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
}
QTabBar::tab:left:!selected:hover {
QTabBar::tab:left:hover {
background-color: #48576b;
}
QTabBar::tab:left:disabled
{
color: #3A3939;
background-color: #302F2F;
border: 1px transparent #4A4949;
border-right: 1px transparent #4A4949;
border-top-right-radius: 0px;
border-bottom-right-radius: 0px;
}
/* RIGHT TABS */
QTabBar::tab:right {
......@@ -975,6 +985,44 @@ QSlider::handle:vertical {
margin: 0 -4px;
border-radius: 2px;
}
QToolButton#MaximizeButton {
background-color: transparent;
border-left: 1px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0.0 #302F2F, stop: 0.3 #606060,
stop: 0.5 #707070,
stop: 0.7 #606060, stop: 1 #302F2F);
border-right: 1px solid QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0.0 #302F2F, stop: 0.3 #606060,
stop: 0.5 #707070,
stop: 0.7 #606060, stop: 1 #302F2F);
border-radius: 0px;
margin: 0px;
padding: 0px;
}
QToolButton#MinimizeButton,
QToolButton#CloseButton {
background-color: transparent;
border: 1px transparent #808080;
border-radius: 0px;
margin: 0px;
padding: 0px;
}
QToolButton#MinimizeButton:hover, QToolButton#MinimizeButton::menu-button:hover,
QToolButton#MaximizeButton:hover, QToolButton#MaximizeButton::menu-button:hover{
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0.0 #302F2F, stop: 0.4 #4E4D4D,
stop: 0.5 #4A4949,
stop: 0.6 #4E4D4D, stop: 1 #302F2F);
}
QToolButton#CloseButton:hover, QToolButton#CloseButton::menu-button:hover {
background-color: QLinearGradient( x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0.0 #302F2F, stop: 0.2 #A82F2F,
stop: 0.5 #E83E4A,
stop: 0.8 #A82F2F, stop: 1 #302F2F);
}
QToolButton {
background-color: transparent;
......
......@@ -37,7 +37,7 @@
#include "dsapplication.h"
#include "pv/devicemanager.h"
#include "pv/mainwindow.h"
#include "pv/mainframe.h"
#include "config.h"
......@@ -134,13 +134,13 @@ int main(int argc, char *argv[])
// Create the device manager, initialise the drivers
pv::DeviceManager device_manager(sr_ctx);
// Initialise the main window
pv::MainWindow w(device_manager, open_file);
//QFile qss(":/stylesheet.qss");
QFile qss(":qdarkstyle/style.qss");
qss.open(QFile::ReadOnly);
a.setStyleSheet(qss.readAll());
qss.close();
// Initialise the main frame
pv::MainFrame w(device_manager, open_file);
//QFile qss(":/stylesheet.qss");
QFile qss(":qdarkstyle/style.qss");
qss.open(QFile::ReadOnly);
a.setStyleSheet(qss.readAll());
qss.close();
w.show();
// Run the application
......
......@@ -126,6 +126,7 @@ public:
virtual void* get_id() const;
signals:
void device_updated();
void config_changed();
protected:
......
......@@ -47,8 +47,6 @@ using std::ostringstream;
using std::runtime_error;
using std::string;
extern char AppDataPath[256];
namespace pv {
DeviceManager::DeviceManager(struct sr_context *sr_ctx) :
......
......@@ -21,45 +21,41 @@
*/
#include <QTextDocument>
#include <QPixmap>
#include <QApplication>
#include "about.h"
#include <ui_about.h>
/* __STDC_FORMAT_MACROS is required for PRIu64 and friends (in C++). */
#define __STDC_FORMAT_MACROS
#include <glib.h>
#include <libsigrok4DSL/libsigrok.h>
namespace pv {
namespace dialogs {
About::About(QWidget *parent) :
QDialog(parent),
ui(new Ui::About)
DSDialog(parent, true)
{
ui->setupUi(this);
/* Setup the version field */
ui->versionInfo->setText(tr("%1 %2<br /><a href=\"%4\">%4</a>")
.arg(QApplication::applicationName())
.arg(QApplication::applicationVersion())
.arg(QApplication::organizationDomain()));
ui->versionInfo->setOpenExternalLinks(true);
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
QPixmap pix(":/icons/dsl_logo.png");
_logo = new QLabel(this);
_logo->setPixmap(pix);
_logo->setAlignment(Qt::AlignCenter);
_info = new QLabel(this);
_info->setText(tr("%1 %2<br /><a href=\"%4\">%4</a>")
.arg(QApplication::applicationName())
.arg(QApplication::applicationVersion())
.arg(QApplication::organizationDomain()));
_info->setOpenExternalLinks(true);
_info->setAlignment(Qt::AlignCenter);
QVBoxLayout *xlayout = new QVBoxLayout();
xlayout->addWidget(_logo);
xlayout->addWidget(_info);
layout()->addLayout(xlayout);
setTitle(tr("About"));
setFixedWidth(500);
}
About::~About()
{
delete ui;
}
void About::accept()
{
using namespace Qt;
QDialog::accept();
}
} // namespace dialogs
......
......@@ -24,18 +24,13 @@
#ifndef DSVIEW_PV_ABOUT_H
#define DSVIEW_PV_ABOUT_H
#include <QDialog>
#include <memory>
namespace Ui {
class About;
}
#include <QLabel>
#include "dsdialog.h"
namespace pv {
namespace dialogs {
class About : public QDialog
class About : public DSDialog
{
Q_OBJECT
......@@ -43,11 +38,9 @@ public:
explicit About(QWidget *parent = 0);
~About();
protected:
void accept();
private:
Ui::About *ui;
QLabel *_logo;
QLabel *_info;
};
} // namespace dialogs
......
......@@ -43,11 +43,10 @@ const QString Calibration::VGAIN = tr(" VGAIN");
const QString Calibration::VOFF = tr(" VOFF");
Calibration::Calibration(QWidget *parent) :
QDialog(parent)
DSDialog(parent)
{
this->setFixedSize(400, 200);
this->setWindowOpacity(0.7);
this->setWindowFlags(Qt::Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
this->setModal(false);
_dev_inst = NULL;
......@@ -56,16 +55,19 @@ Calibration::Calibration(QWidget *parent) :
_exit_btn = new QPushButton(tr("Exit"), this);
_flayout = new QFormLayout();
QGridLayout *glayout = new QGridLayout(this);
glayout->addLayout(_flayout, 0, 0, 1, 5);
glayout->addWidget(_save_btn, 1, 0);
glayout->addWidget(new QWidget(this), 1, 1);
QGridLayout *glayout = new QGridLayout();
glayout->addLayout(_flayout, 1, 0, 1, 5);
glayout->addWidget(_save_btn, 2, 0);
glayout->addWidget(new QWidget(this), 2, 1);
glayout->setColumnStretch(1, 1);
glayout->addWidget(_reset_btn, 1, 2);
glayout->addWidget(new QWidget(this), 1, 3);
glayout->addWidget(_reset_btn, 2, 2);
glayout->addWidget(new QWidget(this), 2, 3);
glayout->setColumnStretch(3, 1);
glayout->addWidget(_exit_btn, 1, 4);
setLayout(glayout);
glayout->addWidget(_exit_btn, 2, 4);
layout()->addLayout(glayout);
setTitle(tr("Manual Calibration"));
connect(_save_btn, SIGNAL(clicked()), this, SLOT(on_save()));
connect(_reset_btn, SIGNAL(clicked()), this, SLOT(on_reset()));
......
......@@ -23,7 +23,6 @@
#ifndef DSVIEW_PV_CALIBRATION_H
#define DSVIEW_PV_CALIBRATION_H
#include <QDialog>
#include <QDialogButtonBox>
#include <QPushButton>
#include <QLabel>
......@@ -34,11 +33,13 @@
#include <boost/shared_ptr.hpp>
#include <pv/device/devinst.h>
#include "../toolbars/titlebar.h"
#include "dsdialog.h"
namespace pv {
namespace dialogs {
class Calibration : public QDialog
class Calibration : public DSDialog
{
Q_OBJECT
......@@ -63,6 +64,7 @@ private slots:
private:
boost::shared_ptr<pv::device::DevInst> _dev_inst;
toolbars::TitleBar *_titlebar;
QPushButton *_save_btn;
QPushButton *_reset_btn;
QPushButton *_exit_btn;
......
......@@ -27,8 +27,8 @@
#include <QFormLayout>
#include <QListWidget>
#include <QMessageBox>
#include "dsmessagebox.h"
#include <pv/prop/property.h>
using namespace boost;
......@@ -38,16 +38,12 @@ namespace pv {
namespace dialogs {
DeviceOptions::DeviceOptions(QWidget *parent, boost::shared_ptr<pv::device::DevInst> dev_inst) :
QDialog(parent),
DSDialog(parent),
_dev_inst(dev_inst),
_layout(this),
_button_box(QDialogButtonBox::Ok,
Qt::Horizontal, this),
_device_options_binding(_dev_inst->dev_inst())
{
setWindowTitle(tr("Configure Device"));
setLayout(&_layout);
_props_box = new QGroupBox(tr("Mode"), this);
_props_box->setLayout(&_props_box_layout);
_props_box_layout.addWidget(get_property_form());
......@@ -58,7 +54,7 @@ DeviceOptions::DeviceOptions(QWidget *parent, boost::shared_ptr<pv::device::DevI
setup_probes();
_probes_box->setLayout(&_probes_box_layout);
_layout.addWidget(_probes_box);
} else {
} else if (_dev_inst->name().contains("DSCope")){
_config_button = new QPushButton(tr("Zero Adjustment"), this);
_layout.addWidget(_config_button);
connect(_config_button, SIGNAL(clicked()), this, SLOT(zero_adj()));
......@@ -71,8 +67,12 @@ DeviceOptions::DeviceOptions(QWidget *parent, boost::shared_ptr<pv::device::DevI
_layout.addStretch(1);
_layout.addWidget(&_button_box);
layout()->addLayout(&_layout);
setTitle(tr("Device Options"));
connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept()));
//connect(&_button_box, SIGNAL(rejected()), this, SLOT(reject()));
connect(_dev_inst.get(), SIGNAL(device_updated()), this, SLOT(reject()));
GVariant* gvar = _dev_inst->get_config(NULL, NULL, SR_CONF_OPERATION_MODE);
if (gvar != NULL) {
......@@ -113,7 +113,9 @@ void DeviceOptions::accept()
void DeviceOptions::reject()
{
accept();
using namespace Qt;
QDialog::reject();
}
QWidget* DeviceOptions::get_property_form()
......@@ -232,15 +234,14 @@ void DeviceOptions::zero_adj()
using namespace Qt;
QDialog::accept();
QMessageBox msg(this);
msg.setText(tr("Information"));
msg.setInformativeText(tr("Zero adjustment program will be started. Please keep all channels out of singal input. It can take a while!"));
//msg.setStandardButtons(QMessageBox::);
msg.addButton(tr("Ok"), QMessageBox::AcceptRole);
msg.addButton(tr("Cancel"), QMessageBox::RejectRole);
msg.setIcon(QMessageBox::Information);
int ret = msg.exec();
if ( ret == QMessageBox::AcceptRole) {
dialogs::DSMessageBox msg(this);
msg.mBox()->setText(tr("Information"));
msg.mBox()->setInformativeText(tr("Zero adjustment program will be started. Please keep all channels out of singal input. It can take a while!"));
//msg.mBox()->setStandardButtons(QMessageBox::);
msg.mBox()->addButton(tr("Ok"), QMessageBox::AcceptRole);
msg.mBox()->addButton(tr("Cancel"), QMessageBox::RejectRole);
msg.mBox()->setIcon(QMessageBox::Information);
if (msg.exec()) {
_dev_inst->set_config(NULL, NULL, SR_CONF_ZERO, g_variant_new_boolean(true));
}
}
......
......@@ -42,11 +42,13 @@
#include <pv/device/devinst.h>
#include <pv/prop/binding/deviceoptions.h>
#include "../toolbars/titlebar.h"
#include "../dialogs/dsdialog.h"
namespace pv {
namespace dialogs {
class DeviceOptions : public QDialog
class DeviceOptions : public DSDialog
{
Q_OBJECT
......@@ -76,6 +78,7 @@ private slots:
private:
boost::shared_ptr<pv::device::DevInst> _dev_inst;
QVBoxLayout _layout;
toolbars::TitleBar *_titlebar;
QGroupBox *_probes_box;
QGridLayout _probes_box_layout;
......
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2016 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "dsdialog.h"
#include "shadow.h"
#include <QObject>
#include <QEvent>
#include <QMouseEvent>
#include <QVBoxLayout>
#include <QAbstractButton>
namespace pv {
namespace dialogs {
DSDialog::DSDialog(QWidget *parent, bool hasClose) :
QDialog(parent),
_moving(false)
{
setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
setAttribute(Qt::WA_TranslucentBackground);
build_main(hasClose);
_layout = new QVBoxLayout(this);
_layout->addWidget(_main);
setLayout(_layout);
}
void DSDialog::accept()
{
using namespace Qt;
QDialog::accept();
}
void DSDialog::reject()
{
using namespace Qt;
QDialog::reject();
}
bool DSDialog::eventFilter(QObject *object, QEvent *event)
{
const QEvent::Type type = event->type();
const QMouseEvent *const mouse_event = (QMouseEvent*)event;
if (type == QEvent::MouseMove) {
if (_moving && mouse_event->buttons().testFlag(Qt::LeftButton)) {
move(mouse_event->globalPos() - _startPos);
}
return true;
} else if (type == QEvent::MouseButtonPress) {
if (mouse_event->buttons().testFlag(Qt::LeftButton)) {
_moving = true;
#ifndef _WIN32
_startPos = mouse_event->pos() +
QPoint(_layout->margin(), _layout->margin()) +
QPoint(_layout->spacing(), _layout->spacing()) +
QPoint(_mlayout->margin(), _mlayout->margin()) +
QPoint(_mlayout->spacing(), _mlayout->spacing());
#else
_startPos = mouse_event->pos() +
QPoint(_layout->margin(), _layout->margin()) +
QPoint(_layout->spacing(), _layout->spacing());
#endif
}
} else if (type == QEvent::MouseButtonRelease) {
if (mouse_event->buttons().testFlag(Qt::LeftButton)) {
_moving = false;
}
}
return false;
}
QVBoxLayout* DSDialog::layout()
{
return _mlayout;
}
QWidget* DSDialog::mainWidget()
{
return _main;
}
void DSDialog::setTitle(QString title)
{
_titlebar->setTitle(title);
}
void DSDialog::reload(bool hasClose)
{
QString title;
if (_titlebar)
title = _titlebar->title();
if (_main)
delete _main;
build_main(hasClose);
_titlebar->setTitle(title);
_layout->addWidget(_main);
}
void DSDialog::build_main(bool hasClose)
{
_main = new QWidget(this);
_mlayout = new QVBoxLayout(_main);
_main->setLayout(_mlayout);
//_mlayout->setMargin(5);
//_mlayout->setSpacing(5);
Shadow *bodyShadow = new Shadow(_main);
bodyShadow->setBlurRadius(10.0);
bodyShadow->setDistance(3.0);
bodyShadow->setColor(QColor(0, 0, 0, 80));
_main->setAutoFillBackground(true);
_main->setGraphicsEffect(bodyShadow);
_titlebar = new toolbars::TitleBar(false, this, hasClose);
_titlebar->installEventFilter(this);
_mlayout->addWidget(_titlebar);
}
} // namespace dialogs
} // namespace pv
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2016 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef DSVIEW_PV_DSDIALOG_H
#define DSVIEW_PV_DSDIALOG_H
#include <QDialog>
#include <QWidget>
#include <QVBoxLayout>
#include "../toolbars/titlebar.h"
namespace pv {
namespace dialogs {
class DSDialog : public QDialog
{
Q_OBJECT
public:
DSDialog(QWidget *parent = 0, bool hasClose = false);
QVBoxLayout *layout();
QWidget *mainWidget();
void setTitle(QString title);
void reload(bool hasClose);
protected:
void accept();
void reject();
//void mousePressEvent(QMouseEvent *event);
//void mouseReleaseEvent(QMouseEvent *event);
bool eventFilter(QObject *object, QEvent *event);
private:
void build_main(bool hasClose);
private:
QVBoxLayout *_layout;
QVBoxLayout *_mlayout;
QWidget *_main;
toolbars::TitleBar *_titlebar;
bool _moving;
QPoint _startPos;
};
} // namespace dialogs
} // namespace pv
#endif // DSVIEW_PV_DSDIALOG_H
/*
* This file is part of the DSView project.
* DSView is based on PulseView.
*
* Copyright (C) 2016 DreamSourceLab <support@dreamsourcelab.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "dsmessagebox.h"
#include "shadow.h"
#include <QObject>
#include <QEvent>
#include <QMouseEvent>
#include <QVBoxLayout>
#include <QAbstractButton>
namespace pv {
namespace dialogs {
DSMessageBox::DSMessageBox(QWidget *parent) :
QDialog(parent),
_moving(false)
{
setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
setAttribute(Qt::WA_TranslucentBackground);
_main = new QWidget(this);
QVBoxLayout *mlayout = new QVBoxLayout(_main);
_main->setLayout(mlayout);
Shadow *bodyShadow = new Shadow();