mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
[OP-835] Qt 5.1.0 - migrated GCS plugins
This commit is contained in:
parent
ec09e17d6e
commit
a2ba33f28a
@ -1,5 +1,6 @@
|
|||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
TARGET = AntennaTrack
|
TARGET = AntennaTrack
|
||||||
|
QT += serialport
|
||||||
include(../../openpilotgcsplugin.pri)
|
include(../../openpilotgcsplugin.pri)
|
||||||
include(../../plugins/coreplugin/coreplugin.pri)
|
include(../../plugins/coreplugin/coreplugin.pri)
|
||||||
include(antennatrack_dependencies.pri)
|
include(antennatrack_dependencies.pri)
|
||||||
|
@ -28,11 +28,12 @@
|
|||||||
#include "antennatrackgadget.h"
|
#include "antennatrackgadget.h"
|
||||||
#include "antennatrackwidget.h"
|
#include "antennatrackwidget.h"
|
||||||
#include "antennatrackgadgetconfiguration.h"
|
#include "antennatrackgadgetconfiguration.h"
|
||||||
|
#include <QtSerialPort/QSerialPortInfo>
|
||||||
|
|
||||||
AntennaTrackGadget::AntennaTrackGadget(QString classId, AntennaTrackWidget *widget, QWidget *parent) :
|
AntennaTrackGadget::AntennaTrackGadget(QString classId, AntennaTrackWidget *widget, QWidget *parent) :
|
||||||
IUAVGadget(classId, parent),
|
IUAVGadget(classId, parent),
|
||||||
m_widget(widget),
|
m_widget(widget),
|
||||||
connected(FALSE)
|
connected(false)
|
||||||
{
|
{
|
||||||
connect(m_widget->connectButton, SIGNAL(clicked(bool)), this, SLOT(onConnect()));
|
connect(m_widget->connectButton, SIGNAL(clicked(bool)), this, SLOT(onConnect()));
|
||||||
connect(m_widget->disconnectButton, SIGNAL(clicked(bool)), this, SLOT(onDisconnect()));
|
connect(m_widget->disconnectButton, SIGNAL(clicked(bool)), this, SLOT(onDisconnect()));
|
||||||
@ -61,29 +62,23 @@ void AntennaTrackGadget::loadConfiguration(IUAVGadgetConfiguration *config)
|
|||||||
|
|
||||||
AntennaTrackGadgetConfiguration *AntennaTrackConfig = qobject_cast< AntennaTrackGadgetConfiguration *>(config);
|
AntennaTrackGadgetConfiguration *AntennaTrackConfig = qobject_cast< AntennaTrackGadgetConfiguration *>(config);
|
||||||
|
|
||||||
PortSettings portsettings;
|
m_portsettings.BaudRate = AntennaTrackConfig->speed();
|
||||||
portsettings.BaudRate = AntennaTrackConfig->speed();
|
m_portsettings.DataBits = AntennaTrackConfig->dataBits();
|
||||||
portsettings.DataBits = AntennaTrackConfig->dataBits();
|
m_portsettings.FlowControl = AntennaTrackConfig->flow();
|
||||||
portsettings.FlowControl = AntennaTrackConfig->flow();
|
m_portsettings.Parity = AntennaTrackConfig->parity();
|
||||||
portsettings.Parity = AntennaTrackConfig->parity();
|
m_portsettings.StopBits = AntennaTrackConfig->stopBits();
|
||||||
portsettings.StopBits = AntennaTrackConfig->stopBits();
|
m_portsettings.Timeout_Millisec = AntennaTrackConfig->timeOut();
|
||||||
portsettings.Timeout_Millisec = AntennaTrackConfig->timeOut();
|
|
||||||
|
|
||||||
// In case we find no port, buttons disabled
|
// In case we find no port, buttons disabled
|
||||||
m_widget->connectButton->setEnabled(false);
|
m_widget->connectButton->setEnabled(false);
|
||||||
m_widget->disconnectButton->setEnabled(false);
|
m_widget->disconnectButton->setEnabled(false);
|
||||||
|
|
||||||
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
|
QList<QSerialPortInfo> ports = QSerialPortInfo::availablePorts();
|
||||||
foreach(QextPortInfo nport, ports) {
|
foreach(QSerialPortInfo nport, ports) {
|
||||||
if (nport.friendName == AntennaTrackConfig->port()) {
|
if (nport.portName() == AntennaTrackConfig->port()) {
|
||||||
qDebug() << "Using Serial port";
|
qDebug() << "Using Serial port";
|
||||||
// parser = new NMEAParser();
|
// parser = new NMEAParser();
|
||||||
|
port = new QSerialPort(nport);
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
port = new QextSerialPort(nport.portName, portsettings, QextSerialPort::EventDriven);
|
|
||||||
#else
|
|
||||||
port = new QextSerialPort(nport.physName, portsettings, QextSerialPort::EventDriven);
|
|
||||||
#endif
|
|
||||||
m_widget->setPort(port);
|
m_widget->setPort(port);
|
||||||
m_widget->connectButton->setEnabled(true);
|
m_widget->connectButton->setEnabled(true);
|
||||||
m_widget->disconnectButton->setEnabled(false);
|
m_widget->disconnectButton->setEnabled(false);
|
||||||
@ -112,8 +107,14 @@ void AntennaTrackGadget::onConnect()
|
|||||||
bool isOpen = port->open(QIODevice::ReadWrite);
|
bool isOpen = port->open(QIODevice::ReadWrite);
|
||||||
qDebug() << "Open: " << isOpen;
|
qDebug() << "Open: " << isOpen;
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
m_widget->connectButton->setEnabled(false);
|
if (port->setBaudRate(m_portsettings.BaudRate)
|
||||||
m_widget->disconnectButton->setEnabled(true);
|
&& port->setDataBits(m_portsettings.DataBits)
|
||||||
|
&& port->setParity(m_portsettings.Parity)
|
||||||
|
&& port->setStopBits(m_portsettings.StopBits)
|
||||||
|
&& port->setFlowControl(m_portsettings.FlowControl)) {
|
||||||
|
m_widget->connectButton->setEnabled(false);
|
||||||
|
m_widget->disconnectButton->setEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Port undefined or invalid.";
|
qDebug() << "Port undefined or invalid.";
|
||||||
|
@ -28,8 +28,7 @@
|
|||||||
#ifndef ANTENNATRACKGADGET_H_
|
#ifndef ANTENNATRACKGADGET_H_
|
||||||
#define ANTENNATRACKGADGET_H_
|
#define ANTENNATRACKGADGET_H_
|
||||||
|
|
||||||
#include <qextserialport/src/qextserialport.h>
|
#include <QtSerialPort/QSerialPort>
|
||||||
#include <qextserialport/src/qextserialenumerator.h>
|
|
||||||
#include <coreplugin/iuavgadget.h>
|
#include <coreplugin/iuavgadget.h>
|
||||||
#include "antennatrackwidget.h"
|
#include "antennatrackwidget.h"
|
||||||
#include "telemetryparser.h"
|
#include "telemetryparser.h"
|
||||||
@ -64,10 +63,11 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QPointer<AntennaTrackWidget> m_widget;
|
QPointer<AntennaTrackWidget> m_widget;
|
||||||
QPointer<QextSerialPort> port;
|
QPointer<QSerialPort> port;
|
||||||
QPointer<GPSParser> parser;
|
QPointer<GPSParser> parser;
|
||||||
bool connected;
|
bool connected;
|
||||||
void processNewSerialData(QByteArray serialData);
|
void processNewSerialData(QByteArray serialData);
|
||||||
|
PortSettings m_portsettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "antennatrackgadgetconfiguration.h"
|
#include "antennatrackgadgetconfiguration.h"
|
||||||
#include <qextserialport/src/qextserialport.h>
|
#include <QtSerialPort/QSerialPort>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a saved configuration or defaults if non exist.
|
* Loads a saved configuration or defaults if non exist.
|
||||||
@ -36,20 +36,20 @@ AntennaTrackGadgetConfiguration::AntennaTrackGadgetConfiguration(QString classId
|
|||||||
IUAVGadgetConfiguration(classId, parent),
|
IUAVGadgetConfiguration(classId, parent),
|
||||||
m_connectionMode("Serial"),
|
m_connectionMode("Serial"),
|
||||||
m_defaultPort("Unknown"),
|
m_defaultPort("Unknown"),
|
||||||
m_defaultSpeed(BAUD4800),
|
m_defaultSpeed(QSerialPort::UnknownBaud),
|
||||||
m_defaultDataBits(DATA_8),
|
m_defaultDataBits(QSerialPort::UnknownDataBits),
|
||||||
m_defaultFlow(FLOW_OFF),
|
m_defaultFlow(QSerialPort::UnknownFlowControl),
|
||||||
m_defaultParity(PAR_NONE),
|
m_defaultParity(QSerialPort::UnknownParity),
|
||||||
m_defaultStopBits(STOP_1),
|
m_defaultStopBits(QSerialPort::UnknownStopBits),
|
||||||
m_defaultTimeOut(5000)
|
m_defaultTimeOut(5000)
|
||||||
{
|
{
|
||||||
// if a saved configuration exists load it
|
// if a saved configuration exists load it
|
||||||
if (qSettings != 0) {
|
if (qSettings != 0) {
|
||||||
BaudRateType speed;
|
QSerialPort::BaudRate speed;
|
||||||
DataBitsType databits;
|
QSerialPort::DataBits databits;
|
||||||
FlowType flow;
|
QSerialPort::FlowControl flow;
|
||||||
ParityType parity;
|
QSerialPort::Parity parity;
|
||||||
StopBitsType stopbits;
|
QSerialPort::StopBits stopbits;
|
||||||
|
|
||||||
int ispeed = qSettings->value("defaultSpeed").toInt();
|
int ispeed = qSettings->value("defaultSpeed").toInt();
|
||||||
int idatabits = qSettings->value("defaultDataBits").toInt();
|
int idatabits = qSettings->value("defaultDataBits").toInt();
|
||||||
@ -59,11 +59,11 @@ AntennaTrackGadgetConfiguration::AntennaTrackGadgetConfiguration(QString classId
|
|||||||
QString port = qSettings->value("defaultPort").toString();
|
QString port = qSettings->value("defaultPort").toString();
|
||||||
QString conMode = qSettings->value("connectionMode").toString();
|
QString conMode = qSettings->value("connectionMode").toString();
|
||||||
|
|
||||||
databits = (DataBitsType)idatabits;
|
databits = (QSerialPort::DataBits)idatabits;
|
||||||
flow = (FlowType)iflow;
|
flow = (QSerialPort::FlowControl)iflow;
|
||||||
parity = (ParityType)iparity;
|
parity = (QSerialPort::Parity)iparity;
|
||||||
stopbits = (StopBitsType)istopbits;
|
stopbits = (QSerialPort::StopBits)istopbits;
|
||||||
speed = (BaudRateType)ispeed;
|
speed = (QSerialPort::BaudRate)ispeed;
|
||||||
m_defaultPort = port;
|
m_defaultPort = port;
|
||||||
m_defaultSpeed = speed;
|
m_defaultSpeed = speed;
|
||||||
m_defaultDataBits = databits;
|
m_defaultDataBits = databits;
|
||||||
|
@ -29,10 +29,23 @@
|
|||||||
#define ANTENNATRACKGADGETCONFIGURATION_H
|
#define ANTENNATRACKGADGETCONFIGURATION_H
|
||||||
|
|
||||||
#include <coreplugin/iuavgadgetconfiguration.h>
|
#include <coreplugin/iuavgadgetconfiguration.h>
|
||||||
#include <qextserialport/src/qextserialport.h>
|
#include <QtSerialPort/QSerialPort>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* structure to contain port settings
|
||||||
|
*/
|
||||||
|
struct PortSettings {
|
||||||
|
QSerialPort::BaudRate BaudRate;
|
||||||
|
QSerialPort::DataBits DataBits;
|
||||||
|
QSerialPort::Parity Parity;
|
||||||
|
QSerialPort::StopBits StopBits;
|
||||||
|
QSerialPort::FlowControl FlowControl;
|
||||||
|
long Timeout_Millisec;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
class AntennaTrackGadgetConfiguration : public IUAVGadgetConfiguration {
|
class AntennaTrackGadgetConfiguration : public IUAVGadgetConfiguration {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
@ -48,23 +61,23 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set port configuration functions
|
// set port configuration functions
|
||||||
void setSpeed(BaudRateType speed)
|
void setSpeed(QSerialPort::BaudRate speed)
|
||||||
{
|
{
|
||||||
m_defaultSpeed = speed;
|
m_defaultSpeed = speed;
|
||||||
}
|
}
|
||||||
void setDataBits(DataBitsType databits)
|
void setDataBits(QSerialPort::DataBits databits)
|
||||||
{
|
{
|
||||||
m_defaultDataBits = databits;
|
m_defaultDataBits = databits;
|
||||||
}
|
}
|
||||||
void setFlow(FlowType flow)
|
void setFlow(QSerialPort::FlowControl flow)
|
||||||
{
|
{
|
||||||
m_defaultFlow = flow;
|
m_defaultFlow = flow;
|
||||||
}
|
}
|
||||||
void setParity(ParityType parity)
|
void setParity(QSerialPort::Parity parity)
|
||||||
{
|
{
|
||||||
m_defaultParity = parity;
|
m_defaultParity = parity;
|
||||||
}
|
}
|
||||||
void setStopBits(StopBitsType stopbits)
|
void setStopBits(QSerialPort::StopBits stopbits)
|
||||||
{
|
{
|
||||||
m_defaultStopBits = stopbits;
|
m_defaultStopBits = stopbits;
|
||||||
}
|
}
|
||||||
@ -82,23 +95,23 @@ public:
|
|||||||
{
|
{
|
||||||
return m_defaultPort;
|
return m_defaultPort;
|
||||||
}
|
}
|
||||||
BaudRateType speed()
|
QSerialPort::BaudRate speed()
|
||||||
{
|
{
|
||||||
return m_defaultSpeed;
|
return m_defaultSpeed;
|
||||||
}
|
}
|
||||||
FlowType flow()
|
QSerialPort::FlowControl flow()
|
||||||
{
|
{
|
||||||
return m_defaultFlow;
|
return m_defaultFlow;
|
||||||
}
|
}
|
||||||
DataBitsType dataBits()
|
QSerialPort::DataBits dataBits()
|
||||||
{
|
{
|
||||||
return m_defaultDataBits;
|
return m_defaultDataBits;
|
||||||
}
|
}
|
||||||
StopBitsType stopBits()
|
QSerialPort::StopBits stopBits()
|
||||||
{
|
{
|
||||||
return m_defaultStopBits;
|
return m_defaultStopBits;
|
||||||
}
|
}
|
||||||
ParityType parity()
|
QSerialPort::Parity parity()
|
||||||
{
|
{
|
||||||
return m_defaultParity;
|
return m_defaultParity;
|
||||||
}
|
}
|
||||||
@ -113,11 +126,11 @@ public:
|
|||||||
private:
|
private:
|
||||||
QString m_connectionMode;
|
QString m_connectionMode;
|
||||||
QString m_defaultPort;
|
QString m_defaultPort;
|
||||||
BaudRateType m_defaultSpeed;
|
QSerialPort::BaudRate m_defaultSpeed;
|
||||||
DataBitsType m_defaultDataBits;
|
QSerialPort::DataBits m_defaultDataBits;
|
||||||
FlowType m_defaultFlow;
|
QSerialPort::FlowControl m_defaultFlow;
|
||||||
ParityType m_defaultParity;
|
QSerialPort::Parity m_defaultParity;
|
||||||
StopBitsType m_defaultStopBits;
|
QSerialPort::StopBits m_defaultStopBits;
|
||||||
long m_defaultTimeOut;
|
long m_defaultTimeOut;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,135 +32,17 @@
|
|||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QtAlgorithms>
|
#include <QtAlgorithms>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
#include <QtSerialPort/QSerialPortInfo>
|
||||||
|
|
||||||
AntennaTrackGadgetOptionsPage::AntennaTrackGadgetOptionsPage(AntennaTrackGadgetConfiguration *config, QObject *parent) :
|
AntennaTrackGadgetOptionsPage::AntennaTrackGadgetOptionsPage(AntennaTrackGadgetConfiguration *config, QObject *parent) :
|
||||||
IOptionsPage(parent),
|
IOptionsPage(parent),
|
||||||
m_config(config)
|
m_config(config)
|
||||||
|
{}
|
||||||
|
|
||||||
|
bool sortPorts(QSerialPortInfo const & s1, QSerialPortInfo const & s2)
|
||||||
{
|
{
|
||||||
// Taken from the uploader gadget, since we also can use a serial port for this
|
return s1.portName() < s2.portName();
|
||||||
// Gadget
|
|
||||||
|
|
||||||
// the begining of some ugly code
|
|
||||||
// diferent OS's have diferent serial port capabilities
|
|
||||||
#ifdef Q_OS_WIN
|
|
||||||
// load windows port capabilities
|
|
||||||
BaudRateTypeString
|
|
||||||
<< "BAUD110"
|
|
||||||
<< "BAUD300"
|
|
||||||
<< "BAUD600"
|
|
||||||
<< "BAUD1200"
|
|
||||||
<< "BAUD2400"
|
|
||||||
<< "BAUD4800"
|
|
||||||
<< "BAUD9600"
|
|
||||||
<< "BAUD14400"
|
|
||||||
<< "BAUD19200"
|
|
||||||
<< "BAUD38400"
|
|
||||||
<< "BAUD56000"
|
|
||||||
<< "BAUD57600"
|
|
||||||
<< "BAUD115200"
|
|
||||||
<< "BAUD128000"
|
|
||||||
<< "BAUD256000";
|
|
||||||
DataBitsTypeString
|
|
||||||
<< "DATA_5"
|
|
||||||
<< "DATA_6"
|
|
||||||
<< "DATA_7"
|
|
||||||
<< "DATA_8";
|
|
||||||
ParityTypeString
|
|
||||||
<< "PAR_NONE"
|
|
||||||
<< "PAR_ODD"
|
|
||||||
<< "PAR_EVEN"
|
|
||||||
<< "PAR_MARK" // WINDOWS ONLY
|
|
||||||
<< "PAR_SPACE";
|
|
||||||
StopBitsTypeString
|
|
||||||
<< "STOP_1"
|
|
||||||
<< "STOP_1_5" // WINDOWS ONLY
|
|
||||||
<< "STOP_2";
|
|
||||||
#else // ifdef Q_OS_WIN
|
|
||||||
// load POSIX port capabilities
|
|
||||||
BaudRateTypeString
|
|
||||||
|
|
||||||
<< "BAUD50" // POSIX ONLY
|
|
||||||
<< "BAUD75" // POSIX ONLY
|
|
||||||
<< "BAUD110"
|
|
||||||
<< "BAUD134" // POSIX ONLY
|
|
||||||
<< "BAUD150" // POSIX ONLY
|
|
||||||
<< "BAUD200" // POSIX ONLY
|
|
||||||
<< "BAUD300"
|
|
||||||
<< "BAUD600"
|
|
||||||
<< "BAUD1200"
|
|
||||||
<< "BAUD1800" // POSIX ONLY
|
|
||||||
<< "BAUD2400"
|
|
||||||
<< "BAUD4800"
|
|
||||||
<< "BAUD9600"
|
|
||||||
<< "BAUD19200"
|
|
||||||
<< "BAUD38400"
|
|
||||||
<< "BAUD57600"
|
|
||||||
<< "BAUD76800" // POSIX ONLY
|
|
||||||
<< "BAUD115200";
|
|
||||||
DataBitsTypeString
|
|
||||||
<< "DATA_5"
|
|
||||||
<< "DATA_6"
|
|
||||||
<< "DATA_7"
|
|
||||||
<< "DATA_8";
|
|
||||||
ParityTypeString
|
|
||||||
<< "PAR_NONE"
|
|
||||||
<< "PAR_ODD"
|
|
||||||
<< "PAR_EVEN"
|
|
||||||
<< "PAR_SPACE";
|
|
||||||
StopBitsTypeString
|
|
||||||
<< "STOP_1"
|
|
||||||
<< "STOP_2";
|
|
||||||
#endif // ifdef Q_OS_WIN
|
|
||||||
// load all OS's capabilities
|
|
||||||
BaudRateTypeStringALL
|
|
||||||
<< "BAUD50" // POSIX ONLY
|
|
||||||
<< "BAUD75" // POSIX ONLY
|
|
||||||
<< "BAUD110"
|
|
||||||
<< "BAUD134" // POSIX ONLY
|
|
||||||
<< "BAUD150" // POSIX ONLY
|
|
||||||
<< "BAUD200" // POSIX ONLY
|
|
||||||
<< "BAUD300"
|
|
||||||
<< "BAUD600"
|
|
||||||
<< "BAUD1200"
|
|
||||||
<< "BAUD1800" // POSIX ONLY
|
|
||||||
<< "BAUD2400"
|
|
||||||
<< "BAUD4800"
|
|
||||||
<< "BAUD9600"
|
|
||||||
<< "BAUD14400"
|
|
||||||
<< "BAUD19200"
|
|
||||||
<< "BAUD38400"
|
|
||||||
<< "BAUD56000"
|
|
||||||
<< "BAUD57600"
|
|
||||||
<< "BAUD76800" // POSIX ONLY
|
|
||||||
<< "BAUD115200"
|
|
||||||
<< "BAUD128000"
|
|
||||||
<< "BAUD256000";
|
|
||||||
DataBitsTypeStringALL
|
|
||||||
<< "DATA_5"
|
|
||||||
<< "DATA_6"
|
|
||||||
<< "DATA_7"
|
|
||||||
<< "DATA_8";
|
|
||||||
ParityTypeStringALL
|
|
||||||
<< "PAR_NONE"
|
|
||||||
<< "PAR_ODD"
|
|
||||||
<< "PAR_EVEN"
|
|
||||||
<< "PAR_MARK" // WINDOWS ONLY
|
|
||||||
<< "PAR_SPACE";
|
|
||||||
StopBitsTypeStringALL
|
|
||||||
<< "STOP_1"
|
|
||||||
<< "STOP_1_5" // WINDOWS ONLY
|
|
||||||
<< "STOP_2";
|
|
||||||
|
|
||||||
FlowTypeString
|
|
||||||
<< "FLOW_OFF"
|
|
||||||
<< "FLOW_HARDWARE"
|
|
||||||
<< "FLOW_XONXOFF";
|
|
||||||
}
|
}
|
||||||
bool sortPorts(QextPortInfo const & s1, QextPortInfo const & s2)
|
|
||||||
{
|
|
||||||
return s1.portName < s2.portName;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// creates options page widget (uses the UI file)
|
// creates options page widget (uses the UI file)
|
||||||
QWidget *AntennaTrackGadgetOptionsPage::createPage(QWidget *parent)
|
QWidget *AntennaTrackGadgetOptionsPage::createPage(QWidget *parent)
|
||||||
@ -171,11 +53,11 @@ QWidget *AntennaTrackGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
|
|
||||||
|
|
||||||
// PORTS
|
// PORTS
|
||||||
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
|
QList<QSerialPortInfo> ports = QSerialPortInfo::availablePorts();
|
||||||
qSort(ports.begin(), ports.end(), sortPorts);
|
qSort(ports.begin(), ports.end(), sortPorts);
|
||||||
foreach(QextPortInfo port, ports) {
|
foreach(QSerialPortInfo port, ports) {
|
||||||
qDebug() << "Adding port: " << port.friendName << " (" << port.portName << ")";
|
qDebug() << "Adding port: " << port.systemLocation() << " (" << port.portName() << ")";
|
||||||
options_page->portComboBox->addItem(port.friendName, port.friendName);
|
options_page->portComboBox->addItem(port.portName(), port.portName());
|
||||||
}
|
}
|
||||||
|
|
||||||
int portIndex = options_page->portComboBox->findData(m_config->port());
|
int portIndex = options_page->portComboBox->findData(m_config->port());
|
||||||
@ -185,41 +67,64 @@ QWidget *AntennaTrackGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// BAUDRATES
|
// BAUDRATES
|
||||||
options_page->portSpeedComboBox->addItems(BaudRateTypeString);
|
options_page->portSpeedComboBox->addItem("Baud1200", QSerialPort::Baud1200);
|
||||||
|
options_page->portSpeedComboBox->addItem("Baud2400", QSerialPort::Baud2400);
|
||||||
|
options_page->portSpeedComboBox->addItem("Baud4800", QSerialPort::Baud4800);
|
||||||
|
options_page->portSpeedComboBox->addItem("Baud9600", QSerialPort::Baud9600);
|
||||||
|
options_page->portSpeedComboBox->addItem("Baud19200", QSerialPort::Baud19200);
|
||||||
|
options_page->portSpeedComboBox->addItem("Baud38400", QSerialPort::Baud38400);
|
||||||
|
options_page->portSpeedComboBox->addItem("Baud57600", QSerialPort::Baud57600);
|
||||||
|
options_page->portSpeedComboBox->addItem("Baud115200", QSerialPort::Baud115200);
|
||||||
|
options_page->portSpeedComboBox->addItem("UnknownBaud", QSerialPort::UnknownBaud);
|
||||||
|
|
||||||
int portSpeedIndex = options_page->portSpeedComboBox->findText(BaudRateTypeStringALL.at((int)m_config->speed()));
|
int portSpeedIndex = options_page->portSpeedComboBox->findData(m_config->speed());
|
||||||
if (portSpeedIndex != -1) {
|
if (portSpeedIndex != -1) {
|
||||||
options_page->portSpeedComboBox->setCurrentIndex(portSpeedIndex);
|
options_page->portSpeedComboBox->setCurrentIndex(portSpeedIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// FLOW CONTROL
|
// FLOW CONTROL
|
||||||
options_page->flowControlComboBox->addItems(FlowTypeString);
|
options_page->flowControlComboBox->addItem("NoFlowControl", QSerialPort::NoFlowControl);
|
||||||
|
options_page->flowControlComboBox->addItem("HardwareControl", QSerialPort::HardwareControl);
|
||||||
|
options_page->flowControlComboBox->addItem("SoftwareControl", QSerialPort::SoftwareControl);
|
||||||
|
options_page->flowControlComboBox->addItem("UnknownFlowControl", QSerialPort::UnknownFlowControl);
|
||||||
|
|
||||||
int flowControlIndex = options_page->flowControlComboBox->findText(FlowTypeString.at((int)m_config->flow()));
|
int flowControlIndex = options_page->flowControlComboBox->findData(m_config->flow());
|
||||||
if (flowControlIndex != -1) {
|
if (flowControlIndex != -1) {
|
||||||
options_page->flowControlComboBox->setCurrentIndex(flowControlIndex);
|
options_page->flowControlComboBox->setCurrentIndex(flowControlIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// DATABITS
|
// DATABITS
|
||||||
options_page->dataBitsComboBox->addItems(DataBitsTypeString);
|
options_page->dataBitsComboBox->addItem("Data5", QSerialPort::Data5);
|
||||||
|
options_page->dataBitsComboBox->addItem("Data6", QSerialPort::Data6);
|
||||||
|
options_page->dataBitsComboBox->addItem("Data7", QSerialPort::Data7);
|
||||||
|
options_page->dataBitsComboBox->addItem("Data8", QSerialPort::Data8);
|
||||||
|
options_page->dataBitsComboBox->addItem("UnknownDataBits", QSerialPort::UnknownDataBits);
|
||||||
|
|
||||||
int dataBitsIndex = options_page->dataBitsComboBox->findText(DataBitsTypeStringALL.at((int)m_config->dataBits()));
|
int dataBitsIndex = options_page->dataBitsComboBox->findData(m_config->dataBits());
|
||||||
if (dataBitsIndex != -1) {
|
if (dataBitsIndex != -1) {
|
||||||
options_page->dataBitsComboBox->setCurrentIndex(dataBitsIndex);
|
options_page->dataBitsComboBox->setCurrentIndex(dataBitsIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// STOPBITS
|
// STOPBITS
|
||||||
options_page->stopBitsComboBox->addItems(StopBitsTypeString);
|
options_page->stopBitsComboBox->addItem("OneStop", QSerialPort::OneStop);
|
||||||
|
options_page->stopBitsComboBox->addItem("OneAndHalfStop", QSerialPort::OneAndHalfStop);
|
||||||
|
options_page->stopBitsComboBox->addItem("TwoStop", QSerialPort::TwoStop);
|
||||||
|
options_page->stopBitsComboBox->addItem("UnknownStopBits", QSerialPort::UnknownStopBits);
|
||||||
|
|
||||||
int stopBitsIndex = options_page->stopBitsComboBox->findText(StopBitsTypeStringALL.at((int)m_config->stopBits()));
|
int stopBitsIndex = options_page->stopBitsComboBox->findData(m_config->stopBits());
|
||||||
if (stopBitsIndex != -1) {
|
if (stopBitsIndex != -1) {
|
||||||
options_page->stopBitsComboBox->setCurrentIndex(stopBitsIndex);
|
options_page->stopBitsComboBox->setCurrentIndex(stopBitsIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PARITY
|
// PARITY
|
||||||
options_page->parityComboBox->addItems(ParityTypeString);
|
options_page->parityComboBox->addItem("NoParity", QSerialPort::NoParity);
|
||||||
|
options_page->parityComboBox->addItem("EvenParity", QSerialPort::EvenParity);
|
||||||
|
options_page->parityComboBox->addItem("OddParity", QSerialPort::OddParity);
|
||||||
|
options_page->parityComboBox->addItem("SpaceParity", QSerialPort::SpaceParity);
|
||||||
|
options_page->parityComboBox->addItem("MarkParity", QSerialPort::MarkParity);
|
||||||
|
options_page->parityComboBox->addItem("UnknownParity", QSerialPort::UnknownParity);
|
||||||
|
|
||||||
int parityIndex = options_page->parityComboBox->findText(ParityTypeStringALL.at((int)m_config->parity()));
|
int parityIndex = options_page->parityComboBox->findData(m_config->parity());
|
||||||
if (parityIndex != -1) {
|
if (parityIndex != -1) {
|
||||||
options_page->parityComboBox->setCurrentIndex(parityIndex);
|
options_page->parityComboBox->setCurrentIndex(parityIndex);
|
||||||
}
|
}
|
||||||
@ -252,11 +157,11 @@ void AntennaTrackGadgetOptionsPage::apply()
|
|||||||
m_config->setPort(options_page->portComboBox->itemData(portIndex).toString());
|
m_config->setPort(options_page->portComboBox->itemData(portIndex).toString());
|
||||||
qDebug() << "apply(): port is " << m_config->port();
|
qDebug() << "apply(): port is " << m_config->port();
|
||||||
|
|
||||||
m_config->setSpeed((BaudRateType)BaudRateTypeStringALL.indexOf(options_page->portSpeedComboBox->currentText()));
|
m_config->setSpeed((QSerialPort::BaudRate)options_page->portSpeedComboBox->itemData(options_page->portSpeedComboBox->currentIndex()).toInt());
|
||||||
m_config->setFlow((FlowType)FlowTypeString.indexOf(options_page->flowControlComboBox->currentText()));
|
m_config->setFlow((QSerialPort::FlowControl)options_page->flowControlComboBox->itemData(options_page->flowControlComboBox->currentIndex()).toInt());
|
||||||
m_config->setDataBits((DataBitsType)DataBitsTypeStringALL.indexOf(options_page->dataBitsComboBox->currentText()));
|
m_config->setDataBits((QSerialPort::DataBits)options_page->dataBitsComboBox->itemData(options_page->dataBitsComboBox->currentIndex()).toInt());
|
||||||
m_config->setStopBits((StopBitsType)StopBitsTypeStringALL.indexOf(options_page->stopBitsComboBox->currentText()));
|
m_config->setStopBits((QSerialPort::StopBits)options_page->stopBitsComboBox->itemData(options_page->stopBitsComboBox->currentIndex()).toInt());
|
||||||
m_config->setParity((ParityType)ParityTypeStringALL.indexOf(options_page->parityComboBox->currentText()));
|
m_config->setParity((QSerialPort::Parity)options_page->parityComboBox->itemData(options_page->parityComboBox->currentIndex()).toInt());
|
||||||
m_config->setTimeOut(options_page->timeoutSpinBox->value());
|
m_config->setTimeOut(options_page->timeoutSpinBox->value());
|
||||||
m_config->setConnectionMode(options_page->connectionMode->currentText());
|
m_config->setConnectionMode(options_page->connectionMode->currentText());
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#ifndef ANTENNATRACKGADGETOPTIONSPAGE_H
|
#ifndef ANTENNATRACKGADGETOPTIONSPAGE_H
|
||||||
#define ANTENNATRACKGADGETOPTIONSPAGE_H
|
#define ANTENNATRACKGADGETOPTIONSPAGE_H
|
||||||
|
|
||||||
#include <qextserialport/src/qextserialenumerator.h>
|
|
||||||
#include "coreplugin/dialogs/ioptionspage.h"
|
#include "coreplugin/dialogs/ioptionspage.h"
|
||||||
#include "QString"
|
#include "QString"
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@ -59,16 +58,6 @@ private:
|
|||||||
Ui::AntennaTrackGadgetOptionsPage *options_page;
|
Ui::AntennaTrackGadgetOptionsPage *options_page;
|
||||||
AntennaTrackGadgetConfiguration *m_config;
|
AntennaTrackGadgetConfiguration *m_config;
|
||||||
|
|
||||||
QStringList BaudRateTypeString;
|
|
||||||
QStringList BaudRateTypeStringALL;
|
|
||||||
QStringList DataBitsTypeStringALL;
|
|
||||||
QStringList ParityTypeStringALL;
|
|
||||||
QStringList StopBitsTypeStringALL;
|
|
||||||
QStringList DataBitsTypeString;
|
|
||||||
QStringList ParityTypeString;
|
|
||||||
QStringList StopBitsTypeString;
|
|
||||||
QStringList FlowTypeString;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,5 +35,3 @@ void AntennaTrackPlugin::shutdown()
|
|||||||
{
|
{
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN(AntennaTrackPlugin)
|
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
class AntennaTrackGadgetFactory;
|
class AntennaTrackGadgetFactory;
|
||||||
|
|
||||||
class AntennaTrackPlugin : public ExtensionSystem::IPlugin {
|
class AntennaTrackPlugin : public ExtensionSystem::IPlugin {
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "OpenPilot.AntennaTrack")
|
||||||
public:
|
public:
|
||||||
AntennaTrackPlugin();
|
AntennaTrackPlugin();
|
||||||
~AntennaTrackPlugin();
|
~AntennaTrackPlugin();
|
||||||
|
@ -47,7 +47,7 @@ AntennaTrackWidget::AntennaTrackWidget(QWidget *parent) : QWidget(parent)
|
|||||||
|
|
||||||
AntennaTrackWidget::~AntennaTrackWidget()
|
AntennaTrackWidget::~AntennaTrackWidget()
|
||||||
{}
|
{}
|
||||||
void AntennaTrackWidget::setPort(QPointer<QextSerialPort> portx)
|
void AntennaTrackWidget::setPort(QPointer<QSerialPort> portx)
|
||||||
{
|
{
|
||||||
port = portx;
|
port = portx;
|
||||||
}
|
}
|
||||||
@ -204,9 +204,9 @@ void AntennaTrackWidget::calcAntennaPosition(void)
|
|||||||
str3.sprintf("move %d 2000 2000 2000 %d\r", stepper, servo);
|
str3.sprintf("move %d 2000 2000 2000 %d\r", stepper, servo);
|
||||||
if (port->isOpen()) {
|
if (port->isOpen()) {
|
||||||
if (azimuth_old != azimuth || elevation != elevation_old) {
|
if (azimuth_old != azimuth || elevation != elevation_old) {
|
||||||
port->write(str3.toAscii());
|
port->write(str3.toLatin1());
|
||||||
}
|
}
|
||||||
azimuth_old = azimuth;
|
|
||||||
elevation_old = elevation;
|
|
||||||
}
|
}
|
||||||
|
azimuth_old = azimuth;
|
||||||
|
elevation_old = elevation;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include <QGraphicsView>
|
#include <QGraphicsView>
|
||||||
#include <QtSvg/QSvgRenderer>
|
#include <QtSvg/QSvgRenderer>
|
||||||
#include <QtSvg/QGraphicsSvgItem>
|
#include <QtSvg/QGraphicsSvgItem>
|
||||||
#include <qextserialport/src/qextserialport.h>
|
#include <QtSerialPort/QSerialPort>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
class Ui_AntennaTrackWidget;
|
class Ui_AntennaTrackWidget;
|
||||||
@ -55,7 +55,7 @@ public:
|
|||||||
AntennaTrackWidget(QWidget *parent = 0);
|
AntennaTrackWidget(QWidget *parent = 0);
|
||||||
~AntennaTrackWidget();
|
~AntennaTrackWidget();
|
||||||
TrackData_t TrackData;
|
TrackData_t TrackData;
|
||||||
void setPort(QPointer<QextSerialPort> portx);
|
void setPort(QPointer<QSerialPort> portx);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setPosition(double, double, double);
|
void setPosition(double, double, double);
|
||||||
@ -65,7 +65,7 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void calcAntennaPosition(void);
|
void calcAntennaPosition(void);
|
||||||
QGraphicsSvgItem *marker;
|
QGraphicsSvgItem *marker;
|
||||||
QPointer<QextSerialPort> port;
|
QPointer<QSerialPort> port;
|
||||||
double azimuth_old;
|
double azimuth_old;
|
||||||
double elevation_old;
|
double elevation_old;
|
||||||
};
|
};
|
||||||
|
@ -31,16 +31,16 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QtGui/QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#define Pi 3.14159265358979323846
|
#define Pi 3.14159265358979323846
|
||||||
|
|
||||||
QStringList ConfigCcpmWidget::getChannelDescriptions()
|
QStringList ConfigCcpmWidget::getChannelDescriptions()
|
||||||
{
|
{
|
||||||
@ -126,8 +126,8 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) :
|
|||||||
SwashLvlConfigurationInProgress = 0;
|
SwashLvlConfigurationInProgress = 0;
|
||||||
SwashLvlState = 0;
|
SwashLvlState = 0;
|
||||||
SwashLvlServoInterlock = 0;
|
SwashLvlServoInterlock = 0;
|
||||||
updatingFromHardware = FALSE;
|
updatingFromHardware = false;
|
||||||
updatingToHardware = FALSE;
|
updatingToHardware = false;
|
||||||
|
|
||||||
// Initialization of the swashplaye widget
|
// Initialization of the swashplaye widget
|
||||||
m_aircraft->SwashplateImage->setScene(new QGraphicsScene(this));
|
m_aircraft->SwashplateImage->setScene(new QGraphicsScene(this));
|
||||||
@ -687,7 +687,7 @@ void ConfigCcpmWidget::UpdateMixer()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config.heli.SwashplateType > 0) { // not advanced settings
|
if (config.heli.SwashplateType > 0) { // not advanced settings
|
||||||
// get the channel data from the ui
|
// get the channel data from the ui
|
||||||
MixerChannelData[0] = m_aircraft->ccpmEngineChannel->currentIndex();
|
MixerChannelData[0] = m_aircraft->ccpmEngineChannel->currentIndex();
|
||||||
MixerChannelData[1] = m_aircraft->ccpmTailChannel->currentIndex();
|
MixerChannelData[1] = m_aircraft->ccpmTailChannel->currentIndex();
|
||||||
MixerChannelData[2] = m_aircraft->ccpmServoWChannel->currentIndex();
|
MixerChannelData[2] = m_aircraft->ccpmServoWChannel->currentIndex();
|
||||||
@ -796,11 +796,11 @@ QString ConfigCcpmWidget::updateConfigObjects()
|
|||||||
bool useCCPM;
|
bool useCCPM;
|
||||||
bool useCyclic;
|
bool useCyclic;
|
||||||
|
|
||||||
if (updatingFromHardware == TRUE) {
|
if (updatingFromHardware == true) {
|
||||||
return airframeType;
|
return airframeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
updatingFromHardware = TRUE;
|
updatingFromHardware = true;
|
||||||
|
|
||||||
// get the user options
|
// get the user options
|
||||||
GUIConfigDataUnion config = getConfigData();
|
GUIConfigDataUnion config = getConfigData();
|
||||||
@ -845,7 +845,7 @@ QString ConfigCcpmWidget::updateConfigObjects()
|
|||||||
|
|
||||||
setConfigData(config);
|
setConfigData(config);
|
||||||
|
|
||||||
updatingFromHardware = FALSE;
|
updatingFromHardware = false;
|
||||||
return airframeType;
|
return airframeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -888,7 +888,7 @@ void ConfigCcpmWidget::getMixer()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updatingFromHardware = TRUE;
|
updatingFromHardware = true;
|
||||||
|
|
||||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
Q_ASSERT(mixer);
|
Q_ASSERT(mixer);
|
||||||
@ -911,7 +911,7 @@ void ConfigCcpmWidget::getMixer()
|
|||||||
m_aircraft->PitchCurve->ResetCurve();
|
m_aircraft->PitchCurve->ResetCurve();
|
||||||
}
|
}
|
||||||
|
|
||||||
updatingFromHardware = FALSE;
|
updatingFromHardware = false;
|
||||||
|
|
||||||
ccpmSwashplateUpdate();
|
ccpmSwashplateUpdate();
|
||||||
}
|
}
|
||||||
@ -926,11 +926,11 @@ void ConfigCcpmWidget::setMixer()
|
|||||||
if (SwashLvlConfigurationInProgress) {
|
if (SwashLvlConfigurationInProgress) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (updatingToHardware == TRUE) {
|
if (updatingToHardware == true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
updatingToHardware = TRUE;
|
updatingToHardware = true;
|
||||||
|
|
||||||
MixerSettings *mixerSettings = MixerSettings::GetInstance(getObjectManager());
|
MixerSettings *mixerSettings = MixerSettings::GetInstance(getObjectManager());
|
||||||
Q_ASSERT(mixerSettings);
|
Q_ASSERT(mixerSettings);
|
||||||
@ -1004,7 +1004,7 @@ void ConfigCcpmWidget::setMixer()
|
|||||||
|
|
||||||
mixerSettings->setData(mixerSettingsData);
|
mixerSettings->setData(mixerSettingsData);
|
||||||
mixerSettings->updated();
|
mixerSettings->updated();
|
||||||
updatingToHardware = FALSE;
|
updatingToHardware = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include <QtSvg/QSvgRenderer>
|
#include <QtSvg/QSvgRenderer>
|
||||||
#include <QtSvg/QGraphicsSvgItem>
|
#include <QtSvg/QGraphicsSvgItem>
|
||||||
#include <QGraphicsEllipseItem>
|
#include <QGraphicsEllipseItem>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
#define CCPM_MAX_SWASH_SERVOS 4
|
#define CCPM_MAX_SWASH_SERVOS 4
|
||||||
|
@ -29,11 +29,11 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QtGui/QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
#include <QtGui/QComboBox>
|
#include <QComboBox>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include "uavtalk/telemetrymanager.h"
|
#include "uavtalk/telemetrymanager.h"
|
||||||
|
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QItemDelegate>
|
#include <QItemDelegate>
|
||||||
|
|
||||||
|
@ -32,10 +32,10 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QtGui/QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -34,8 +34,7 @@
|
|||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include "uavtalk/telemetrymanager.h"
|
#include "uavtalk/telemetrymanager.h"
|
||||||
|
#include <QWidget>
|
||||||
#include <QtGui/QWidget>
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QItemDelegate>
|
#include <QItemDelegate>
|
||||||
|
|
||||||
|
@ -32,10 +32,10 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QtGui/QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
@ -34,8 +34,7 @@
|
|||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include "uavtalk/telemetrymanager.h"
|
#include "uavtalk/telemetrymanager.h"
|
||||||
|
#include <QWidget>
|
||||||
#include <QtGui/QWidget>
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QItemDelegate>
|
#include <QItemDelegate>
|
||||||
|
|
||||||
|
@ -32,11 +32,11 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QtGui/QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
#include <QtGui/QComboBox>
|
#include <QComboBox>
|
||||||
#include <QBrush>
|
#include <QBrush>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
@ -217,7 +217,7 @@ void ConfigMultiRotorWidget::setupEnabledControls(QString frameType)
|
|||||||
// disable all motor channel boxes
|
// disable all motor channel boxes
|
||||||
for (int i = 1; i <= 8; i++) {
|
for (int i = 1; i <= 8; i++) {
|
||||||
// do it manually so we can turn off any error decorations
|
// do it manually so we can turn off any error decorations
|
||||||
QComboBox *combobox = qFindChild<QComboBox *>(this, "multiMotorChannelBox" + QString::number(i));
|
QComboBox *combobox = this->findChild<QComboBox *>("multiMotorChannelBox" + QString::number(i));
|
||||||
if (combobox) {
|
if (combobox) {
|
||||||
combobox->setEnabled(false);
|
combobox->setEnabled(false);
|
||||||
combobox->setItemData(0, 0, Qt::DecorationRole);
|
combobox->setItemData(0, 0, Qt::DecorationRole);
|
||||||
@ -1005,7 +1005,7 @@ bool ConfigMultiRotorWidget::throwConfigError(int numMotors)
|
|||||||
// Iterate through all instances of multiMotorChannelBox
|
// Iterate through all instances of multiMotorChannelBox
|
||||||
for (int i = 0; i < numMotors; i++) {
|
for (int i = 0; i < numMotors; i++) {
|
||||||
// Fine widgets with text "multiMotorChannelBox.x", where x is an integer
|
// Fine widgets with text "multiMotorChannelBox.x", where x is an integer
|
||||||
QComboBox *combobox = qFindChild<QComboBox *>(this, "multiMotorChannelBox" + QString::number(i + 1));
|
QComboBox *combobox = this->findChild<QComboBox *>("multiMotorChannelBox" + QString::number(i + 1));
|
||||||
if (combobox) {
|
if (combobox) {
|
||||||
if (combobox->currentText() == "None") {
|
if (combobox->currentText() == "None") {
|
||||||
int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize);
|
int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize);
|
||||||
|
@ -36,8 +36,8 @@
|
|||||||
#include "uavtalk/telemetrymanager.h"
|
#include "uavtalk/telemetrymanager.h"
|
||||||
|
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QtGui/QItemDelegate>
|
#include <QItemDelegate>
|
||||||
|
|
||||||
class Ui_Widget;
|
class Ui_Widget;
|
||||||
|
|
||||||
|
@ -165,7 +165,7 @@ void VehicleConfig::setComboCurrentIndex(QComboBox *box, int index)
|
|||||||
void VehicleConfig::enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable)
|
void VehicleConfig::enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable)
|
||||||
{
|
{
|
||||||
for (int i = 1; i <= boxCount; i++) {
|
for (int i = 1; i <= boxCount; i++) {
|
||||||
QComboBox *box = qFindChild<QComboBox *>(owner, QString("%0%1").arg(boxName).arg(i));
|
QComboBox *box = owner->findChild<QComboBox *>(QString("%0%1").arg(boxName).arg(i));
|
||||||
if (box) {
|
if (box) {
|
||||||
box->setEnabled(enable);
|
box->setEnabled(enable);
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,10 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QtGui/QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "extensionsystem/pluginmanager.h"
|
#include "extensionsystem/pluginmanager.h"
|
||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "smartsavebutton.h"
|
#include "smartsavebutton.h"
|
||||||
|
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtGui/QWidget>
|
#include <QtWidgets/QWidget>
|
||||||
#include <QtGui/QTextEdit>
|
#include <QtWidgets/QTextEdit>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QtWidgets/QVBoxLayout>
|
||||||
#include <QtGui/QPushButton>
|
#include <QtWidgets/QPushButton>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include "stabilizationsettings.h"
|
#include "stabilizationsettings.h"
|
||||||
#include "relaytuningsettings.h"
|
#include "relaytuningsettings.h"
|
||||||
#include "relaytuning.h"
|
#include "relaytuning.h"
|
||||||
#include <QtGui/QWidget>
|
#include <QtWidgets/QWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
class ConfigAutotuneWidget : public ConfigTaskWidget {
|
class ConfigAutotuneWidget : public ConfigTaskWidget {
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "extensionsystem/pluginmanager.h"
|
#include "extensionsystem/pluginmanager.h"
|
||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
class Ui_Widget;
|
class Ui_Widget;
|
||||||
|
@ -44,10 +44,10 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QtGui/QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
|
ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include "objectpersistence.h"
|
#include "objectpersistence.h"
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QTextBrowser>
|
#include <QTextBrowser>
|
||||||
#include "utils/pathutils.h"
|
#include "utils/pathutils.h"
|
||||||
|
@ -31,10 +31,10 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QtGui/QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "extensionsystem/pluginmanager.h"
|
#include "extensionsystem/pluginmanager.h"
|
||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "inputchannelform.h"
|
#include "inputchannelform.h"
|
||||||
#include "ui_inputchannelform.h"
|
#include "ui_inputchannelform.h"
|
||||||
|
@ -33,10 +33,10 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QtGui/QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include "uavobjectutilmanager.h"
|
#include "uavobjectutilmanager.h"
|
||||||
#include "cfg_vehicletypes/vehicleconfig.h"
|
#include "cfg_vehicletypes/vehicleconfig.h"
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
class Ui_OutputWidget;
|
class Ui_OutputWidget;
|
||||||
|
@ -183,14 +183,14 @@ void ConfigPipXtremeWidget::updateStatus(UAVObject *object)
|
|||||||
*/
|
*/
|
||||||
char buf[OPLinkStatus::DESCRIPTION_NUMELEM];
|
char buf[OPLinkStatus::DESCRIPTION_NUMELEM];
|
||||||
for (unsigned int i = 0; i < 26; ++i) {
|
for (unsigned int i = 0; i < 26; ++i) {
|
||||||
buf[i] = descField->getValue(i + 14).toChar().toAscii();
|
buf[i] = descField->getValue(i + 14).toChar().toLatin1();
|
||||||
}
|
}
|
||||||
buf[26] = '\0';
|
buf[26] = '\0';
|
||||||
QString descstr(buf);
|
QString descstr(buf);
|
||||||
quint32 gitDate = descField->getValue(11).toChar().toAscii() & 0xFF;
|
quint32 gitDate = descField->getValue(11).toChar().toLatin1() & 0xFF;
|
||||||
for (int i = 1; i < 4; i++) {
|
for (int i = 1; i < 4; i++) {
|
||||||
gitDate = gitDate << 8;
|
gitDate = gitDate << 8;
|
||||||
gitDate += descField->getValue(11 - i).toChar().toAscii() & 0xFF;
|
gitDate += descField->getValue(11 - i).toChar().toLatin1() & 0xFF;
|
||||||
}
|
}
|
||||||
QString date = QDateTime::fromTime_t(gitDate).toUTC().toString("yyyy-MM-dd HH:mm");
|
QString date = QDateTime::fromTime_t(gitDate).toUTC().toString("yyyy-MM-dd HH:mm");
|
||||||
m_oplink->FirmwareVersion->setText(descstr + " " + date);
|
m_oplink->FirmwareVersion->setText(descstr + " " + date);
|
||||||
|
@ -69,5 +69,3 @@ void ConfigPlugin::extensionsInitialized()
|
|||||||
|
|
||||||
void ConfigPlugin::shutdown()
|
void ConfigPlugin::shutdown()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN(ConfigPlugin)
|
|
||||||
|
@ -42,6 +42,7 @@ class ConfigGadgetFactory;
|
|||||||
|
|
||||||
class ConfigPlugin : public ExtensionSystem::IPlugin {
|
class ConfigPlugin : public ExtensionSystem::IPlugin {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "OpenPilot.Config")
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConfigPlugin();
|
ConfigPlugin();
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "extensionsystem/pluginmanager.h"
|
#include "extensionsystem/pluginmanager.h"
|
||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QtGui/QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QErrorMessage>
|
#include <QErrorMessage>
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include "extensionsystem/pluginmanager.h"
|
#include "extensionsystem/pluginmanager.h"
|
||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QtSvg/QSvgRenderer>
|
#include <QtSvg/QSvgRenderer>
|
||||||
#include <QtSvg/QGraphicsSvgItem>
|
#include <QtSvg/QGraphicsSvgItem>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
@ -28,10 +28,10 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QtGui/QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include "stabilizationsettings.h"
|
#include "stabilizationsettings.h"
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,7 +37,11 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
|
#include <QTextEdit>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <math.h>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
|
@ -38,6 +38,12 @@
|
|||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QList>
|
||||||
|
#include <QItemDelegate>
|
||||||
|
|
||||||
|
class Ui_Widget;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This class derives from ConfigTaskWidget and overrides its default "binding" mechanism.
|
* This class derives from ConfigTaskWidget and overrides its default "binding" mechanism.
|
||||||
* This widget bypasses automatic synchronization of UAVObjects and UI by providing its own implementations of
|
* This widget bypasses automatic synchronization of UAVObjects and UI by providing its own implementations of
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "extensionsystem/pluginmanager.h"
|
#include "extensionsystem/pluginmanager.h"
|
||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "extensionsystem/pluginmanager.h"
|
#include "extensionsystem/pluginmanager.h"
|
||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
|
|
||||||
|
@ -32,17 +32,17 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QtGui/QColorDialog>
|
#include <QColorDialog>
|
||||||
#include <QtGui/QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QtGui/QWindowsStyle>
|
// #include <QWindowsStyle>
|
||||||
#include <QtGui/QPainter>
|
#include <QPainter>
|
||||||
#include <QtGui/QSplitter>
|
#include <QSplitter>
|
||||||
#include <QtGui/QStackedLayout>
|
#include <QStackedLayout>
|
||||||
#include <QtGui/QStatusBar>
|
#include <QStatusBar>
|
||||||
#include <QtGui/QToolButton>
|
#include <QToolButton>
|
||||||
#include <QtGui/QToolTip>
|
#include <QToolTip>
|
||||||
|
|
||||||
const int FancyTabBar::m_rounding = 22;
|
const int FancyTabBar::m_rounding = 22;
|
||||||
const int FancyTabBar::m_textPadding = 4;
|
const int FancyTabBar::m_textPadding = 4;
|
||||||
@ -59,7 +59,7 @@ FancyTabBar::FancyTabBar(QWidget *parent, bool isVertical)
|
|||||||
} else {
|
} else {
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
}
|
}
|
||||||
setStyle(new QWindowsStyle);
|
// setStyle(new QWindowsStyle);
|
||||||
setMinimumWidth(qMax(2 * m_rounding, 40));
|
setMinimumWidth(qMax(2 * m_rounding, 40));
|
||||||
setAttribute(Qt::WA_Hover, true);
|
setAttribute(Qt::WA_Hover, true);
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
|
@ -29,9 +29,9 @@
|
|||||||
#ifndef FANCYTABWIDGET_H
|
#ifndef FANCYTABWIDGET_H
|
||||||
#define FANCYTABWIDGET_H
|
#define FANCYTABWIDGET_H
|
||||||
|
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
#include <QtGui/QTabBar>
|
#include <QTabBar>
|
||||||
#include <QtGui/QStyleOptionTabV2>
|
#include <QStyleOptionTabV2>
|
||||||
#include <QtCore/QTimeLine>
|
#include <QtCore/QTimeLine>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "mixercurve.h"
|
#include "mixercurve.h"
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#define MIXERCURVE_H
|
#define MIXERCURVE_H
|
||||||
|
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QTableWidget>
|
#include <QTableWidget>
|
||||||
|
|
||||||
|
@ -35,8 +35,8 @@
|
|||||||
#include "uniqueidmanager.h"
|
#include "uniqueidmanager.h"
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtGui/QAction>
|
#include <QAction>
|
||||||
#include <QtGui/QMenuBar>
|
#include <QMenuBar>
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Core::Internal::MenuActionContainer *)
|
Q_DECLARE_METATYPE(Core::Internal::MenuActionContainer *)
|
||||||
|
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
#define ACTIONCONTAINER_H
|
#define ACTIONCONTAINER_H
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtGui/QMenu>
|
#include <QMenu>
|
||||||
#include <QtGui/QMenuBar>
|
#include <QMenuBar>
|
||||||
#include <QtGui/QAction>
|
#include <QAction>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class Command;
|
class Command;
|
||||||
|
@ -36,10 +36,10 @@
|
|||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtGui/QMenu>
|
#include <QMenu>
|
||||||
#include <QtGui/QAction>
|
#include <QAction>
|
||||||
#include <QtGui/QShortcut>
|
#include <QShortcut>
|
||||||
#include <QtGui/QMenuBar>
|
#include <QMenuBar>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
enum { warnAboutFindFailures = 0 };
|
enum { warnAboutFindFailures = 0 };
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtGui/QAction>
|
#include <QAction>
|
||||||
#include <QtGui/QShortcut>
|
#include <QShortcut>
|
||||||
|
|
||||||
#include "command_p.h"
|
#include "command_p.h"
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
#include <QtCore/QMultiMap>
|
#include <QtCore/QMultiMap>
|
||||||
#include <QtCore/QPointer>
|
#include <QtCore/QPointer>
|
||||||
#include <QtGui/QKeySequence>
|
#include <QKeySequence>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include <QtCore/QString>
|
#include <QtCore/QString>
|
||||||
#include <QtCore/QMap>
|
#include <QtCore/QMap>
|
||||||
#include <QtCore/QList>
|
#include <QtCore/QList>
|
||||||
#include <QtGui/QKeySequence>
|
#include <QKeySequence>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
@ -38,11 +38,11 @@
|
|||||||
#include <QtCore/QFile>
|
#include <QtCore/QFile>
|
||||||
#include <QtCore/QSysInfo>
|
#include <QtCore/QSysInfo>
|
||||||
|
|
||||||
#include <QtGui/QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QtGui/QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QtGui/QLabel>
|
#include <QLabel>
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
#include <QtGui/QTextBrowser>
|
#include <QTextBrowser>
|
||||||
|
|
||||||
#include <QtDeclarative/qdeclarative.h>
|
#include <QtDeclarative/qdeclarative.h>
|
||||||
#include <QtDeclarative/qdeclarativeview.h>
|
#include <QtDeclarative/qdeclarativeview.h>
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#ifndef AUTHORSDIALOG_H
|
#ifndef AUTHORSDIALOG_H
|
||||||
#define AUTHORSDIALOG_H
|
#define AUTHORSDIALOG_H
|
||||||
|
|
||||||
#include <QtGui/QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@
|
|||||||
#include "imode.h"
|
#include "imode.h"
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QtGui/QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class CORE_EXPORT BaseMode
|
class CORE_EXPORT BaseMode
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include "baseview.h"
|
#include "baseview.h"
|
||||||
|
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
#include <aggregation/aggregate.h>
|
#include <aggregation/aggregate.h>
|
||||||
#include <coreplugin/iconnection.h>
|
#include <coreplugin/iconnection.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include "qextserialport/src/qextserialenumerator.h"
|
#include <QtSerialPort/QSerialPort>
|
||||||
#include "qextserialport/src/qextserialport.h"
|
#include <QtSerialPort/QSerialPortInfo>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
|
@ -37,8 +37,8 @@
|
|||||||
#include <QtCore/QVector>
|
#include <QtCore/QVector>
|
||||||
#include <QtCore/QIODevice>
|
#include <QtCore/QIODevice>
|
||||||
#include <QtCore/QLinkedList>
|
#include <QtCore/QLinkedList>
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
#include <QtGui/QComboBox>
|
#include <QComboBox>
|
||||||
|
|
||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
@ -201,6 +201,7 @@ const char *const ICON_PREV = ":/core/images/prev.png";
|
|||||||
const char *const ICON_DIR = ":/core/images/dir.png";
|
const char *const ICON_DIR = ":/core/images/dir.png";
|
||||||
const char *const ICON_CLEAN_PANE = ":/core/images/clean_pane_small.png";
|
const char *const ICON_CLEAN_PANE = ":/core/images/clean_pane_small.png";
|
||||||
const char *const ICON_CLEAR = ":/core/images/clear.png";
|
const char *const ICON_CLEAR = ":/core/images/clear.png";
|
||||||
|
const char *const ICON_CLOSE = ":/core/images/closebutton.png";
|
||||||
const char *const ICON_FIND = ":/core/images/find.png";
|
const char *const ICON_FIND = ":/core/images/find.png";
|
||||||
const char *const ICON_FINDNEXT = ":/core/images/findnext.png";
|
const char *const ICON_FINDNEXT = ":/core/images/findnext.png";
|
||||||
const char *const ICON_REPLACE = ":/core/images/replace.png";
|
const char *const ICON_REPLACE = ":/core/images/replace.png";
|
||||||
|
@ -76,5 +76,3 @@ void CorePlugin::shutdown()
|
|||||||
{
|
{
|
||||||
m_mainWindow->shutdown();
|
m_mainWindow->shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN2(Core, CorePlugin)
|
|
||||||
|
@ -37,6 +37,7 @@ class MainWindow;
|
|||||||
|
|
||||||
class CorePlugin : public ExtensionSystem::IPlugin {
|
class CorePlugin : public ExtensionSystem::IPlugin {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "OpenPilot.Core")
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CorePlugin();
|
CorePlugin();
|
||||||
|
@ -1,4 +1,2 @@
|
|||||||
include(../../libs/extensionsystem/extensionsystem.pri)
|
include(../../libs/extensionsystem/extensionsystem.pri)
|
||||||
include(../../libs/utils/utils.pri)
|
include(../../libs/utils/utils.pri)
|
||||||
include(../../libs/libqxt/libqxt.pri)
|
|
||||||
include(../../libs/qextserialport/qextserialport.pri)
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include <coreplugin/core_global.h>
|
#include <coreplugin/core_global.h>
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtGui/QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
@ -35,9 +35,9 @@
|
|||||||
|
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtGui/QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QtGui/QLabel>
|
#include <QLabel>
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
|
@ -38,10 +38,10 @@
|
|||||||
#include <utils/treewidgetcolumnstretcher.h>
|
#include <utils/treewidgetcolumnstretcher.h>
|
||||||
|
|
||||||
|
|
||||||
#include <QtGui/QKeyEvent>
|
#include <QKeyEvent>
|
||||||
#include <QtGui/QShortcut>
|
#include <QShortcut>
|
||||||
#include <QtGui/QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QtGui/QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Core::Internal::ShortcutItem *)
|
Q_DECLARE_METATYPE(Core::Internal::ShortcutItem *)
|
||||||
@ -157,7 +157,7 @@ void ShortcutSettings::commandChanged(QTreeWidgetItem *current)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_page->seqGrp->setEnabled(true);
|
m_page->seqGrp->setEnabled(true);
|
||||||
ShortcutItem *scitem = qVariantValue<ShortcutItem *>(current->data(0, Qt::UserRole));
|
ShortcutItem *scitem = current->data(0, Qt::UserRole).value<ShortcutItem *>();
|
||||||
setKeySequence(scitem->m_key);
|
setKeySequence(scitem->m_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,9 +174,9 @@ void ShortcutSettings::keyChanged()
|
|||||||
QTreeWidgetItem *current = m_page->commandList->currentItem();
|
QTreeWidgetItem *current = m_page->commandList->currentItem();
|
||||||
|
|
||||||
if (current && current->data(0, Qt::UserRole).isValid()) {
|
if (current && current->data(0, Qt::UserRole).isValid()) {
|
||||||
ShortcutItem *scitem = qVariantValue<ShortcutItem *>(current->data(0, Qt::UserRole));
|
ShortcutItem *scitem = current->data(0, Qt::UserRole).value<ShortcutItem *>();
|
||||||
scitem->m_key = QKeySequence(m_key[0], m_key[1], m_key[2], m_key[3]);
|
scitem->m_key = QKeySequence(m_key[0], m_key[1], m_key[2], m_key[3]);
|
||||||
current->setText(2, scitem->m_key);
|
current->setText(2, scitem->m_key.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ void ShortcutSettings::setKeySequence(const QKeySequence &key)
|
|||||||
for (int i = 0; i < m_keyNum; ++i) {
|
for (int i = 0; i < m_keyNum; ++i) {
|
||||||
m_key[i] = key[i];
|
m_key[i] = key[i];
|
||||||
}
|
}
|
||||||
m_page->shortcutEdit->setText(key);
|
m_page->shortcutEdit->setText(key.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShortcutSettings::filter(const QString &f, const QTreeWidgetItem *item)
|
bool ShortcutSettings::filter(const QString &f, const QTreeWidgetItem *item)
|
||||||
@ -222,7 +222,7 @@ void ShortcutSettings::resetKeySequence()
|
|||||||
QTreeWidgetItem *current = m_page->commandList->currentItem();
|
QTreeWidgetItem *current = m_page->commandList->currentItem();
|
||||||
|
|
||||||
if (current && current->data(0, Qt::UserRole).isValid()) {
|
if (current && current->data(0, Qt::UserRole).isValid()) {
|
||||||
ShortcutItem *scitem = qVariantValue<ShortcutItem *>(current->data(0, Qt::UserRole));
|
ShortcutItem *scitem = current->data(0, Qt::UserRole).value<ShortcutItem *>();
|
||||||
setKeySequence(scitem->m_cmd->defaultKeySequence());
|
setKeySequence(scitem->m_cmd->defaultKeySequence());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -250,7 +250,7 @@ void ShortcutSettings::importAction()
|
|||||||
|
|
||||||
if (mapping.contains(sid)) {
|
if (mapping.contains(sid)) {
|
||||||
item->m_key = mapping.value(sid);
|
item->m_key = mapping.value(sid);
|
||||||
item->m_item->setText(2, item->m_key);
|
item->m_item->setText(2, item->m_key.toString());
|
||||||
if (item->m_item == m_page->commandList->currentItem()) {
|
if (item->m_item == m_page->commandList->currentItem()) {
|
||||||
commandChanged(item->m_item);
|
commandChanged(item->m_item);
|
||||||
}
|
}
|
||||||
@ -263,7 +263,7 @@ void ShortcutSettings::defaultAction()
|
|||||||
{
|
{
|
||||||
foreach(ShortcutItem * item, m_scitems) {
|
foreach(ShortcutItem * item, m_scitems) {
|
||||||
item->m_key = item->m_cmd->defaultKeySequence();
|
item->m_key = item->m_cmd->defaultKeySequence();
|
||||||
item->m_item->setText(2, item->m_key);
|
item->m_item->setText(2, item->m_key.toString());
|
||||||
if (item->m_item == m_page->commandList->currentItem()) {
|
if (item->m_item == m_page->commandList->currentItem()) {
|
||||||
commandChanged(item->m_item);
|
commandChanged(item->m_item);
|
||||||
}
|
}
|
||||||
@ -317,7 +317,7 @@ void ShortcutSettings::initialize()
|
|||||||
item->setText(1, c->shortcut()->whatsThis());
|
item->setText(1, c->shortcut()->whatsThis());
|
||||||
}
|
}
|
||||||
|
|
||||||
item->setText(2, s->m_key);
|
item->setText(2, s->m_key.toString());
|
||||||
item->setData(0, Qt::UserRole, qVariantFromValue(s));
|
item->setData(0, Qt::UserRole, qVariantFromValue(s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,7 +353,7 @@ void ShortcutSettings::handleKeyEvent(QKeyEvent *e)
|
|||||||
}
|
}
|
||||||
m_keyNum++;
|
m_keyNum++;
|
||||||
QKeySequence ks(m_key[0], m_key[1], m_key[2], m_key[3]);
|
QKeySequence ks(m_key[0], m_key[1], m_key[2], m_key[3]);
|
||||||
m_page->shortcutEdit->setText(ks);
|
m_page->shortcutEdit->setText(ks.toString());
|
||||||
e->accept();
|
e->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,9 +32,9 @@
|
|||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtGui/QKeySequence>
|
#include <QKeySequence>
|
||||||
#include <QtGui/QTreeWidgetItem>
|
#include <QTreeWidgetItem>
|
||||||
#include <QtGui/QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class Ui_ShortcutSettings;
|
class Ui_ShortcutSettings;
|
||||||
|
@ -40,8 +40,15 @@ EventFilteringMainWindow::EventFilteringMainWindow()
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
bool EventFilteringMainWindow::winEvent(MSG *msg, long *result)
|
bool EventFilteringMainWindow::winEvent(MSG *msg, long *result)
|
||||||
{
|
{
|
||||||
|
#else
|
||||||
|
bool EventFilteringMainWindow::nativeEvent(const QByteArray & /*eventType*/, void *message, long *result)
|
||||||
|
{
|
||||||
|
MSG *msg = static_cast<MSG *>(message);
|
||||||
|
|
||||||
|
#endif
|
||||||
if (msg->message == WM_DEVICECHANGE) {
|
if (msg->message == WM_DEVICECHANGE) {
|
||||||
emit deviceChange();
|
emit deviceChange();
|
||||||
*result = TRUE;
|
*result = TRUE;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#ifndef EVENTFILTERINGMAINWINDOW_H
|
#ifndef EVENTFILTERINGMAINWINDOW_H
|
||||||
#define EVENTFILTERINGMAINWINDOW_H
|
#define EVENTFILTERINGMAINWINDOW_H
|
||||||
|
|
||||||
#include <QtGui/QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@ -45,7 +45,11 @@ public:
|
|||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
protected:
|
protected:
|
||||||
|
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||||
bool winEvent(MSG *message, long *result);
|
bool winEvent(MSG *message, long *result);
|
||||||
|
#else
|
||||||
|
bool nativeEvent(const QByteArray & /*eventType*/, void *message, long *result);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -28,12 +28,12 @@
|
|||||||
|
|
||||||
#include "fancyactionbar.h"
|
#include "fancyactionbar.h"
|
||||||
|
|
||||||
#include <QtGui/QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QtGui/QPainter>
|
#include <QPainter>
|
||||||
#include <QtGui/QPicture>
|
#include <QPicture>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtSvg/QSvgRenderer>
|
#include <QtSvg/QSvgRenderer>
|
||||||
#include <QtGui/QAction>
|
#include <QAction>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Internal;
|
using namespace Internal;
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#define FANCYACTIONBAR_H
|
#define FANCYACTIONBAR_H
|
||||||
|
|
||||||
#include <QtCore/QMap>
|
#include <QtCore/QMap>
|
||||||
#include <QtGui/QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QMenu;
|
class QMenu;
|
||||||
|
@ -27,50 +27,65 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fancytabwidget.h"
|
#include "fancytabwidget.h"
|
||||||
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/stylehelper.h>
|
#include <utils/stylehelper.h>
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#include <QtGui/QColorDialog>
|
#include <QColorDialog>
|
||||||
#include <QtGui/QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QtGui/QWindowsStyle>
|
#include <QStyleFactory>
|
||||||
#include <QtGui/QPainter>
|
#include <QPainter>
|
||||||
#include <QtGui/QSplitter>
|
#include <QStackedLayout>
|
||||||
#include <QtGui/QStackedLayout>
|
#include <QStatusBar>
|
||||||
#include <QtGui/QStatusBar>
|
#include <QToolTip>
|
||||||
#include <QtGui/QToolButton>
|
|
||||||
#include <QtGui/QToolTip>
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Internal;
|
using namespace Internal;
|
||||||
|
|
||||||
const int FancyTabBar::m_rounding = 22;
|
const int FancyTabBar::m_rounding = 22;
|
||||||
const int FancyTabBar::m_textPadding = 4;
|
const int FancyTabBar::m_textPadding = 4;
|
||||||
|
|
||||||
FancyTabBar::FancyTabBar(QWidget *parent, bool isVertical)
|
void FancyTab::fadeIn()
|
||||||
|
{
|
||||||
|
animator.stop();
|
||||||
|
animator.setDuration(80);
|
||||||
|
animator.setEndValue(40);
|
||||||
|
animator.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FancyTab::fadeOut()
|
||||||
|
{
|
||||||
|
animator.stop();
|
||||||
|
animator.setDuration(160);
|
||||||
|
animator.setEndValue(0);
|
||||||
|
animator.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FancyTab::setFader(float value)
|
||||||
|
{
|
||||||
|
m_fader = value;
|
||||||
|
tabbar->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
FancyTabBar::FancyTabBar(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
verticalTabs = isVertical;
|
m_hoverIndex = -1;
|
||||||
setIconSize(16);
|
m_currentIndex = -1;
|
||||||
m_hoverIndex = -1;
|
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||||
m_currentIndex = 0;
|
setStyle(QStyleFactory::create(QLatin1String("windows")));
|
||||||
if (isVertical) {
|
|
||||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
|
||||||
} else {
|
|
||||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
|
||||||
}
|
|
||||||
setStyle(new QWindowsStyle);
|
|
||||||
setMinimumWidth(qMax(2 * m_rounding, 40));
|
setMinimumWidth(qMax(2 * m_rounding, 40));
|
||||||
setAttribute(Qt::WA_Hover, true);
|
setAttribute(Qt::WA_Hover, true);
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
m_hoverControl.setFrameRange(0, 20);
|
|
||||||
m_hoverControl.setDuration(130);
|
|
||||||
m_hoverControl.setCurveShape(QTimeLine::EaseInCurve);
|
|
||||||
connect(&m_hoverControl, SIGNAL(frameChanged(int)), this, SLOT(updateHover()));
|
|
||||||
setMouseTracking(true); // Needed for hover events
|
setMouseTracking(true); // Needed for hover events
|
||||||
|
m_triggerTimer.setSingleShot(true);
|
||||||
|
|
||||||
|
// We use a zerotimer to keep the sidebar responsive
|
||||||
|
connect(&m_triggerTimer, SIGNAL(timeout()), this, SLOT(emitCurrentIndex()));
|
||||||
}
|
}
|
||||||
|
|
||||||
FancyTabBar::~FancyTabBar()
|
FancyTabBar::~FancyTabBar()
|
||||||
@ -81,15 +96,19 @@ FancyTabBar::~FancyTabBar()
|
|||||||
QSize FancyTabBar::tabSizeHint(bool minimum) const
|
QSize FancyTabBar::tabSizeHint(bool minimum) const
|
||||||
{
|
{
|
||||||
QFont boldFont(font());
|
QFont boldFont(font());
|
||||||
|
|
||||||
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
|
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
|
||||||
boldFont.setBold(true);
|
boldFont.setBold(true);
|
||||||
QFontMetrics fm(boldFont);
|
QFontMetrics fm(boldFont);
|
||||||
int spacing = 6;
|
int spacing = 8;
|
||||||
int width = 90 + spacing + 2;
|
int width = 60 + spacing + 2;
|
||||||
|
int maxLabelwidth = 0;
|
||||||
int iconHeight = minimum ? 0 : iconSize;
|
for (int tab=0 ; tab<count() ;++tab) {
|
||||||
return QSize(width, iconHeight + spacing + fm.height());
|
int width = fm.width(tabText(tab));
|
||||||
|
if (width > maxLabelwidth)
|
||||||
|
maxLabelwidth = width;
|
||||||
|
}
|
||||||
|
int iconHeight = minimum ? 0 : 32;
|
||||||
|
return QSize(qMax(width, maxLabelwidth + 4), iconHeight + spacing + fm.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
void FancyTabBar::paintEvent(QPaintEvent *event)
|
void FancyTabBar::paintEvent(QPaintEvent *event)
|
||||||
@ -97,49 +116,47 @@ void FancyTabBar::paintEvent(QPaintEvent *event)
|
|||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
QPainter p(this);
|
QPainter p(this);
|
||||||
|
|
||||||
for (int i = 0; i < count(); ++i) {
|
for (int i = 0; i < count(); ++i)
|
||||||
if (i != currentIndex()) {
|
if (i != currentIndex())
|
||||||
paintTab(&p, i);
|
paintTab(&p, i);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// paint active tab last, since it overlaps the neighbors
|
// paint active tab last, since it overlaps the neighbors
|
||||||
paintTab(&p, currentIndex());
|
if (currentIndex() != -1)
|
||||||
|
paintTab(&p, currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle hover events for mouse fade ins
|
// Handle hover events for mouse fade ins
|
||||||
void FancyTabBar::mouseMoveEvent(QMouseEvent *e)
|
void FancyTabBar::mouseMoveEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
if (!m_hoverRect.contains(e->pos())) {
|
int newHover = -1;
|
||||||
int newHover = -1;
|
for (int i = 0; i < count(); ++i) {
|
||||||
for (int i = 0; i < count(); ++i) {
|
QRect area = tabRect(i);
|
||||||
QRect area = tabRect(i);
|
if (area.contains(e->pos())) {
|
||||||
if (area.contains(e->pos())) {
|
newHover = i;
|
||||||
newHover = i;
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (newHover == m_hoverIndex)
|
||||||
|
return;
|
||||||
|
|
||||||
m_hoverControl.stop();
|
if (validIndex(m_hoverIndex))
|
||||||
m_hoverIndex = newHover;
|
m_tabs[m_hoverIndex]->fadeOut();
|
||||||
update(m_hoverRect);
|
|
||||||
m_hoverRect = QRect();
|
|
||||||
|
|
||||||
if (m_hoverIndex >= 0) {
|
m_hoverIndex = newHover;
|
||||||
QRect oldHoverRect = m_hoverRect;
|
|
||||||
m_hoverRect = tabRect(m_hoverIndex);
|
if (validIndex(m_hoverIndex)) {
|
||||||
m_hoverControl.start();
|
m_tabs[m_hoverIndex]->fadeIn();
|
||||||
}
|
m_hoverRect = tabRect(m_hoverIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FancyTabBar::event(QEvent *event)
|
bool FancyTabBar::event(QEvent *event)
|
||||||
{
|
{
|
||||||
if (event->type() == QEvent::ToolTip) {
|
if (event->type() == QEvent::ToolTip) {
|
||||||
if (m_hoverIndex >= 0 && m_hoverIndex < m_tabs.count()) {
|
if (validIndex(m_hoverIndex)) {
|
||||||
QString tt = tabToolTip(m_hoverIndex);
|
QString tt = tabToolTip(m_hoverIndex);
|
||||||
if (!tt.isEmpty()) {
|
if (!tt.isEmpty()) {
|
||||||
QToolTip::showText(static_cast<QHelpEvent *>(event)->globalPos(), tt, this);
|
QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), tt, this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,16 +164,11 @@ bool FancyTabBar::event(QEvent *event)
|
|||||||
return QWidget::event(event);
|
return QWidget::event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FancyTabBar::updateHover()
|
|
||||||
{
|
|
||||||
update(m_hoverRect);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Resets hover animation on mouse enter
|
// Resets hover animation on mouse enter
|
||||||
void FancyTabBar::enterEvent(QEvent *e)
|
void FancyTabBar::enterEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
Q_UNUSED(e)
|
Q_UNUSED(e)
|
||||||
m_hoverRect = QRect();
|
m_hoverRect = QRect();
|
||||||
m_hoverIndex = -1;
|
m_hoverIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,64 +176,55 @@ void FancyTabBar::enterEvent(QEvent *e)
|
|||||||
void FancyTabBar::leaveEvent(QEvent *e)
|
void FancyTabBar::leaveEvent(QEvent *e)
|
||||||
{
|
{
|
||||||
Q_UNUSED(e)
|
Q_UNUSED(e)
|
||||||
if (m_hoverIndex >= 0) {
|
m_hoverIndex = -1;
|
||||||
m_hoverIndex = -1;
|
m_hoverRect = QRect();
|
||||||
update(m_hoverRect);
|
for (int i = 0 ; i < m_tabs.count() ; ++i) {
|
||||||
m_hoverRect = QRect();
|
m_tabs[i]->fadeOut();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FancyTabBar::updateTabNameIcon(int index, const QIcon &icon, const QString &label)
|
|
||||||
{
|
|
||||||
m_tabs[index].icon = icon;
|
|
||||||
m_tabs[index].text = label;
|
|
||||||
}
|
|
||||||
|
|
||||||
QSize FancyTabBar::sizeHint() const
|
QSize FancyTabBar::sizeHint() const
|
||||||
{
|
{
|
||||||
QSize sh = tabSizeHint();
|
QSize sh = tabSizeHint();
|
||||||
|
return QSize(sh.width(), sh.height() * m_tabs.count());
|
||||||
if (verticalTabs) {
|
|
||||||
return QSize(sh.width(), sh.height() * m_tabs.count());
|
|
||||||
}
|
|
||||||
return QSize(sh.width() * m_tabs.count(), sh.height());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize FancyTabBar::minimumSizeHint() const
|
QSize FancyTabBar::minimumSizeHint() const
|
||||||
{
|
{
|
||||||
QSize sh = tabSizeHint(true);
|
QSize sh = tabSizeHint(true);
|
||||||
|
return QSize(sh.width(), sh.height() * m_tabs.count());
|
||||||
if (verticalTabs) {
|
|
||||||
return QSize(sh.width(), sh.height() * m_tabs.count());
|
|
||||||
}
|
|
||||||
return QSize(sh.width() * m_tabs.count(), sh.height());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect FancyTabBar::tabRect(int index) const
|
QRect FancyTabBar::tabRect(int index) const
|
||||||
{
|
{
|
||||||
QSize sh = tabSizeHint();
|
QSize sh = tabSizeHint();
|
||||||
|
|
||||||
if (verticalTabs) {
|
if (sh.height() * m_tabs.count() > height())
|
||||||
if (sh.height() * m_tabs.count() > height()) {
|
sh.setHeight(height() / m_tabs.count());
|
||||||
sh.setHeight(height() / m_tabs.count());
|
|
||||||
}
|
|
||||||
|
|
||||||
return QRect(0, index * sh.height(), sh.width(), sh.height());
|
return QRect(0, index * sh.height(), sh.width(), sh.height());
|
||||||
}
|
|
||||||
|
|
||||||
if (sh.width() * m_tabs.count() > width()) {
|
}
|
||||||
sh.setWidth(width() / m_tabs.count());
|
|
||||||
}
|
|
||||||
|
|
||||||
return QRect(index * sh.width(), 0, sh.width(), sh.height());
|
// This keeps the sidebar responsive since
|
||||||
|
// we get a repaint before loading the
|
||||||
|
// mode itself
|
||||||
|
void FancyTabBar::emitCurrentIndex()
|
||||||
|
{
|
||||||
|
emit currentChanged(m_currentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FancyTabBar::mousePressEvent(QMouseEvent *e)
|
void FancyTabBar::mousePressEvent(QMouseEvent *e)
|
||||||
{
|
{
|
||||||
e->accept();
|
e->accept();
|
||||||
for (int i = 0; i < m_tabs.count(); ++i) {
|
for (int index = 0; index < m_tabs.count(); ++index) {
|
||||||
if (tabRect(i).contains(e->pos())) {
|
if (tabRect(index).contains(e->pos())) {
|
||||||
setCurrentIndex(i);
|
|
||||||
|
if (isTabEnabled(index)) {
|
||||||
|
m_currentIndex = index;
|
||||||
|
update();
|
||||||
|
m_triggerTimer.start(0);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,87 +232,127 @@ void FancyTabBar::mousePressEvent(QMouseEvent *e)
|
|||||||
|
|
||||||
void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
|
void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
|
||||||
{
|
{
|
||||||
|
if (!validIndex(tabIndex)) {
|
||||||
|
qWarning("invalid index");
|
||||||
|
return;
|
||||||
|
}
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
QRect rect = tabRect(tabIndex);
|
QRect rect = tabRect(tabIndex);
|
||||||
|
|
||||||
bool selected = (tabIndex == m_currentIndex);
|
bool selected = (tabIndex == m_currentIndex);
|
||||||
bool hover = (tabIndex == m_hoverIndex);
|
bool enabled = isTabEnabled(tabIndex);
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
|
||||||
hover = false; // Dont hover on Mac
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QColor background = QColor(0, 0, 0, 10);
|
|
||||||
QColor hoverColor;
|
|
||||||
|
|
||||||
if (hover) {
|
|
||||||
hoverColor = QColor(255, 255, 255, m_hoverControl.currentFrame());
|
|
||||||
}
|
|
||||||
|
|
||||||
QColor light = QColor(255, 255, 255, 40);
|
|
||||||
QColor dark = QColor(0, 0, 0, 60);
|
|
||||||
|
|
||||||
if (selected) {
|
if (selected) {
|
||||||
QLinearGradient selectedGradient(rect.bottomRight(), QPoint(rect.center().x(), rect.top()));
|
//background
|
||||||
selectedGradient.setColorAt(0, Qt::white);
|
painter->save();
|
||||||
selectedGradient.setColorAt(0.3, Qt::white);
|
QLinearGradient grad(rect.topLeft(), rect.topRight());
|
||||||
selectedGradient.setColorAt(0.7, QColor(210, 210, 220)); // give a blue-ish color
|
grad.setColorAt(0, QColor(255, 255, 255, 140));
|
||||||
|
grad.setColorAt(1, QColor(255, 255, 255, 210));
|
||||||
|
painter->fillRect(rect.adjusted(0, 0, 0, -1), grad);
|
||||||
|
painter->restore();
|
||||||
|
|
||||||
painter->fillRect(rect, selectedGradient);
|
//shadows
|
||||||
painter->setPen(QColor(200, 200, 200));
|
painter->setPen(QColor(0, 0, 0, 110));
|
||||||
|
painter->drawLine(rect.topLeft() + QPoint(1,-1), rect.topRight() - QPoint(0,1));
|
||||||
|
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||||
|
painter->setPen(QColor(0, 0, 0, 40));
|
||||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||||
painter->setPen(QColor(150, 160, 200));
|
|
||||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
//highlights
|
||||||
} else {
|
painter->setPen(QColor(255, 255, 255, 50));
|
||||||
painter->fillRect(rect, background);
|
painter->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0,2));
|
||||||
if (hover) {
|
painter->drawLine(rect.bottomLeft() + QPoint(0, 1), rect.bottomRight() + QPoint(0,1));
|
||||||
painter->fillRect(rect, hoverColor);
|
painter->setPen(QColor(255, 255, 255, 40));
|
||||||
}
|
painter->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight());
|
||||||
painter->setPen(QPen(light, 0));
|
painter->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1));
|
||||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
painter->drawLine(rect.bottomLeft() + QPoint(0,-1), rect.bottomRight()-QPoint(0,1));
|
||||||
painter->setPen(QPen(dark, 0));
|
|
||||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString tabText(this->tabText(tabIndex));
|
QString tabText(this->tabText(tabIndex));
|
||||||
QRect tabTextRect(tabRect(tabIndex));
|
QRect tabTextRect(rect);
|
||||||
|
const bool drawIcon = rect.height() > 36;
|
||||||
QRect tabIconRect(tabTextRect);
|
QRect tabIconRect(tabTextRect);
|
||||||
|
tabTextRect.translate(0, drawIcon ? -2 : 1);
|
||||||
QFont boldFont(painter->font());
|
QFont boldFont(painter->font());
|
||||||
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
|
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
|
||||||
boldFont.setBold(true);
|
boldFont.setBold(true);
|
||||||
painter->setFont(boldFont);
|
painter->setFont(boldFont);
|
||||||
painter->setPen(selected ? Utils::StyleHelper::panelTextColor() : QColor(30, 30, 30, 80));
|
painter->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110));
|
||||||
int textFlags = Qt::AlignCenter | Qt::AlignBottom | Qt::ElideRight | Qt::TextWordWrap;
|
const int textFlags = Qt::AlignCenter | (drawIcon ? Qt::AlignBottom : Qt::AlignVCenter) | Qt::TextWordWrap;
|
||||||
painter->drawText(tabTextRect, textFlags, tabText);
|
if (enabled) {
|
||||||
painter->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor());
|
painter->drawText(tabTextRect, textFlags, tabText);
|
||||||
int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
|
painter->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor());
|
||||||
tabIconRect.adjust(0, 4, 0, -textHeight);
|
} else {
|
||||||
int iconSize = qMin(tabIconRect.width(), tabIconRect.height());
|
painter->setPen(selected ? Utils::StyleHelper::panelTextColor() : QColor(255, 255, 255, 120));
|
||||||
if (iconSize > 4) {
|
|
||||||
style()->drawItemPixmap(painter, tabIconRect, Qt::AlignCenter | Qt::AlignVCenter,
|
|
||||||
tabIcon(tabIndex).pixmap(tabIconRect.size()));
|
|
||||||
}
|
}
|
||||||
|
if (!Utils::HostOsInfo::isMacHost() && !selected && enabled) {
|
||||||
|
painter->save();
|
||||||
|
int fader = int(m_tabs[tabIndex]->fader());
|
||||||
|
QLinearGradient grad(rect.topLeft(), rect.topRight());
|
||||||
|
grad.setColorAt(0, Qt::transparent);
|
||||||
|
grad.setColorAt(0.5, QColor(255, 255, 255, fader));
|
||||||
|
grad.setColorAt(1, Qt::transparent);
|
||||||
|
painter->fillRect(rect, grad);
|
||||||
|
painter->setPen(QPen(grad, 1.0));
|
||||||
|
painter->drawLine(rect.topLeft(), rect.topRight());
|
||||||
|
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||||
|
painter->restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!enabled)
|
||||||
|
painter->setOpacity(0.7);
|
||||||
|
|
||||||
|
if (drawIcon) {
|
||||||
|
int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
|
||||||
|
tabIconRect.adjust(0, 4, 0, -textHeight);
|
||||||
|
Utils::StyleHelper::drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled);
|
||||||
|
}
|
||||||
|
|
||||||
painter->translate(0, -1);
|
painter->translate(0, -1);
|
||||||
painter->drawText(tabTextRect, textFlags, tabText);
|
painter->drawText(tabTextRect, textFlags, tabText);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FancyTabBar::setCurrentIndex(int index)
|
void FancyTabBar::setCurrentIndex(int index) {
|
||||||
{
|
if (isTabEnabled(index)) {
|
||||||
m_currentIndex = index;
|
m_currentIndex = index;
|
||||||
update();
|
update();
|
||||||
emit currentChanged(index);
|
emit currentChanged(m_currentIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FancyTabBar::setTabEnabled(int index, bool enable)
|
||||||
|
{
|
||||||
|
Q_ASSERT(index < m_tabs.size());
|
||||||
|
Q_ASSERT(index >= 0);
|
||||||
|
|
||||||
|
if (index < m_tabs.size() && index >= 0) {
|
||||||
|
m_tabs[index]->enabled = enable;
|
||||||
|
update(tabRect(index));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FancyTabBar::isTabEnabled(int index) const
|
||||||
|
{
|
||||||
|
Q_ASSERT(index < m_tabs.size());
|
||||||
|
Q_ASSERT(index >= 0);
|
||||||
|
|
||||||
|
if (index < m_tabs.size() && index >= 0)
|
||||||
|
return m_tabs[index]->enabled;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////
|
//////
|
||||||
// FancyColorButton
|
// FancyColorButton
|
||||||
//////
|
//////
|
||||||
|
|
||||||
class FancyColorButton : public QWidget {
|
class FancyColorButton : public QWidget
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
FancyColorButton(QWidget *parent)
|
FancyColorButton(QWidget *parent)
|
||||||
: m_parent(parent)
|
: m_parent(parent)
|
||||||
{
|
{
|
||||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||||
}
|
}
|
||||||
@ -317,7 +360,9 @@ public:
|
|||||||
void mousePressEvent(QMouseEvent *ev)
|
void mousePressEvent(QMouseEvent *ev)
|
||||||
{
|
{
|
||||||
if (ev->modifiers() & Qt::ShiftModifier) {
|
if (ev->modifiers() & Qt::ShiftModifier) {
|
||||||
Utils::StyleHelper::setBaseColor(QColorDialog::getColor(Utils::StyleHelper::baseColor(), m_parent));
|
QColor color = QColorDialog::getColor(Utils::StyleHelper::requestedBaseColor(), m_parent);
|
||||||
|
if (color.isValid())
|
||||||
|
Utils::StyleHelper::setBaseColor(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
@ -328,28 +373,18 @@ private:
|
|||||||
// FancyTabWidget
|
// FancyTabWidget
|
||||||
//////
|
//////
|
||||||
|
|
||||||
FancyTabWidget::FancyTabWidget(QWidget *parent, bool isVertical)
|
FancyTabWidget::FancyTabWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
{
|
{
|
||||||
m_tabBar = new FancyTabBar(this, isVertical);
|
m_tabBar = new FancyTabBar(this);
|
||||||
|
|
||||||
m_selectionWidget = new QWidget(this);
|
m_selectionWidget = new QWidget(this);
|
||||||
QBoxLayout *selectionLayout;
|
QVBoxLayout *selectionLayout = new QVBoxLayout;
|
||||||
if (isVertical) {
|
|
||||||
selectionLayout = new QVBoxLayout;
|
|
||||||
} else {
|
|
||||||
selectionLayout = new QHBoxLayout;
|
|
||||||
}
|
|
||||||
selectionLayout->setSpacing(0);
|
selectionLayout->setSpacing(0);
|
||||||
selectionLayout->setMargin(0);
|
selectionLayout->setMargin(0);
|
||||||
|
|
||||||
Utils::StyledBar *bar = new Utils::StyledBar;
|
Utils::StyledBar *bar = new Utils::StyledBar;
|
||||||
QBoxLayout *layout;
|
QHBoxLayout *layout = new QHBoxLayout(bar);
|
||||||
if (isVertical) {
|
|
||||||
layout = new QHBoxLayout(bar);
|
|
||||||
} else {
|
|
||||||
layout = new QVBoxLayout(bar);
|
|
||||||
}
|
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
layout->setSpacing(0);
|
layout->setSpacing(0);
|
||||||
layout->addWidget(new FancyColorButton(this));
|
layout->addWidget(new FancyColorButton(this));
|
||||||
@ -357,26 +392,13 @@ FancyTabWidget::FancyTabWidget(QWidget *parent, bool isVertical)
|
|||||||
|
|
||||||
selectionLayout->addWidget(m_tabBar, 1);
|
selectionLayout->addWidget(m_tabBar, 1);
|
||||||
m_selectionWidget->setLayout(selectionLayout);
|
m_selectionWidget->setLayout(selectionLayout);
|
||||||
if (isVertical) {
|
m_selectionWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||||
m_selectionWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
|
||||||
} else {
|
|
||||||
m_selectionWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_cornerWidgetContainer = new QWidget(this);
|
m_cornerWidgetContainer = new QWidget(this);
|
||||||
if (isVertical) {
|
m_cornerWidgetContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||||
m_cornerWidgetContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
|
||||||
} else {
|
|
||||||
m_cornerWidgetContainer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
|
|
||||||
}
|
|
||||||
m_cornerWidgetContainer->setAutoFillBackground(false);
|
m_cornerWidgetContainer->setAutoFillBackground(false);
|
||||||
|
|
||||||
QBoxLayout *cornerWidgetLayout;
|
QVBoxLayout *cornerWidgetLayout = new QVBoxLayout;
|
||||||
if (isVertical) {
|
|
||||||
cornerWidgetLayout = new QVBoxLayout;
|
|
||||||
} else {
|
|
||||||
cornerWidgetLayout = new QHBoxLayout;
|
|
||||||
}
|
|
||||||
cornerWidgetLayout->setSpacing(0);
|
cornerWidgetLayout->setSpacing(0);
|
||||||
cornerWidgetLayout->setMargin(0);
|
cornerWidgetLayout->setMargin(0);
|
||||||
cornerWidgetLayout->addStretch();
|
cornerWidgetLayout->addStretch();
|
||||||
@ -385,30 +407,35 @@ FancyTabWidget::FancyTabWidget(QWidget *parent, bool isVertical)
|
|||||||
selectionLayout->addWidget(m_cornerWidgetContainer, 0);
|
selectionLayout->addWidget(m_cornerWidgetContainer, 0);
|
||||||
|
|
||||||
m_modesStack = new QStackedLayout;
|
m_modesStack = new QStackedLayout;
|
||||||
m_statusBar = new QStatusBar;
|
m_statusBar = new QStatusBar;
|
||||||
m_statusBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
m_statusBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||||
|
|
||||||
QVBoxLayout *vlayout = new QVBoxLayout;
|
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||||
vlayout->setMargin(0);
|
vlayout->setMargin(0);
|
||||||
vlayout->setSpacing(0);
|
vlayout->setSpacing(0);
|
||||||
vlayout->addLayout(m_modesStack);
|
vlayout->addLayout(m_modesStack);
|
||||||
if (!isVertical) {
|
vlayout->addWidget(m_statusBar);
|
||||||
vlayout->addWidget(m_selectionWidget);
|
|
||||||
}
|
|
||||||
// vlayout->addWidget(m_statusBar); //status bar is not used for now
|
|
||||||
|
|
||||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||||
mainLayout->setMargin(0);
|
mainLayout->setMargin(0);
|
||||||
mainLayout->setSpacing(1);
|
mainLayout->setSpacing(1);
|
||||||
if (isVertical) {
|
mainLayout->addWidget(m_selectionWidget);
|
||||||
mainLayout->addWidget(m_selectionWidget);
|
|
||||||
}
|
|
||||||
mainLayout->addLayout(vlayout);
|
mainLayout->addLayout(vlayout);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(showWidget(int)));
|
connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(showWidget(int)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FancyTabWidget::setSelectionWidgetVisible(bool visible)
|
||||||
|
{
|
||||||
|
m_selectionWidget->setVisible(visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FancyTabWidget::isSelectionWidgetVisible() const
|
||||||
|
{
|
||||||
|
return m_selectionWidget->isVisible();
|
||||||
|
}
|
||||||
|
|
||||||
void FancyTabWidget::insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label)
|
void FancyTabWidget::insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label)
|
||||||
{
|
{
|
||||||
m_modesStack->insertWidget(index, tab);
|
m_modesStack->insertWidget(index, tab);
|
||||||
@ -421,17 +448,9 @@ void FancyTabWidget::removeTab(int index)
|
|||||||
m_tabBar->removeTab(index);
|
m_tabBar->removeTab(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FancyTabWidget::updateTabNameIcon(int index, const QIcon &icon, const QString &label)
|
|
||||||
{
|
|
||||||
m_tabBar->updateTabNameIcon(index, icon, label);
|
|
||||||
m_tabBar->repaint();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void FancyTabWidget::setBackgroundBrush(const QBrush &brush)
|
void FancyTabWidget::setBackgroundBrush(const QBrush &brush)
|
||||||
{
|
{
|
||||||
QPalette pal = m_tabBar->palette();
|
QPalette pal = m_tabBar->palette();
|
||||||
|
|
||||||
pal.setBrush(QPalette::Mid, brush);
|
pal.setBrush(QPalette::Mid, brush);
|
||||||
m_tabBar->setPalette(pal);
|
m_tabBar->setPalette(pal);
|
||||||
pal = m_cornerWidgetContainer->palette();
|
pal = m_cornerWidgetContainer->palette();
|
||||||
@ -442,19 +461,24 @@ void FancyTabWidget::setBackgroundBrush(const QBrush &brush)
|
|||||||
void FancyTabWidget::paintEvent(QPaintEvent *event)
|
void FancyTabWidget::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
QPainter p(this);
|
if (m_selectionWidget->isVisible()) {
|
||||||
|
QPainter painter(this);
|
||||||
|
|
||||||
QRect rect = m_selectionWidget->geometry().adjusted(0, 0, 1, 0);
|
QRect rect = m_selectionWidget->rect().adjusted(0, 0, 1, 0);
|
||||||
rect = style()->visualRect(layoutDirection(), geometry(), rect);
|
rect = style()->visualRect(layoutDirection(), geometry(), rect);
|
||||||
Utils::StyleHelper::verticalGradient(&p, rect, rect);
|
Utils::StyleHelper::verticalGradient(&painter, rect, rect);
|
||||||
p.setPen(Utils::StyleHelper::borderColor());
|
painter.setPen(Utils::StyleHelper::borderColor());
|
||||||
p.drawLine(rect.topLeft(), rect.topRight());
|
painter.drawLine(rect.topRight(), rect.bottomRight());
|
||||||
|
|
||||||
|
QColor light = Utils::StyleHelper::sidebarHighlight();
|
||||||
|
painter.setPen(light);
|
||||||
|
painter.drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FancyTabWidget::insertCornerWidget(int pos, QWidget *widget)
|
void FancyTabWidget::insertCornerWidget(int pos, QWidget *widget)
|
||||||
{
|
{
|
||||||
QHBoxLayout *layout = static_cast<QHBoxLayout *>(m_cornerWidgetContainer->layout());
|
QVBoxLayout *layout = static_cast<QVBoxLayout *>(m_cornerWidgetContainer->layout());
|
||||||
|
|
||||||
layout->insertWidget(pos, widget);
|
layout->insertWidget(pos, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,13 +504,13 @@ QStatusBar *FancyTabWidget::statusBar() const
|
|||||||
|
|
||||||
void FancyTabWidget::setCurrentIndex(int index)
|
void FancyTabWidget::setCurrentIndex(int index)
|
||||||
{
|
{
|
||||||
m_tabBar->setCurrentIndex(index);
|
if (m_tabBar->isTabEnabled(index))
|
||||||
|
m_tabBar->setCurrentIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FancyTabWidget::showWidget(int index)
|
void FancyTabWidget::showWidget(int index)
|
||||||
{
|
{
|
||||||
emit currentAboutToShow(index);
|
emit currentAboutToShow(index);
|
||||||
|
|
||||||
m_modesStack->setCurrentIndex(index);
|
m_modesStack->setCurrentIndex(index);
|
||||||
emit currentChanged(index);
|
emit currentChanged(index);
|
||||||
}
|
}
|
||||||
@ -495,3 +519,13 @@ void FancyTabWidget::setTabToolTip(int index, const QString &toolTip)
|
|||||||
{
|
{
|
||||||
m_tabBar->setTabToolTip(index, toolTip);
|
m_tabBar->setTabToolTip(index, toolTip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FancyTabWidget::setTabEnabled(int index, bool enable)
|
||||||
|
{
|
||||||
|
m_tabBar->setTabEnabled(index, enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FancyTabWidget::isTabEnabled(int index) const
|
||||||
|
{
|
||||||
|
return m_tabBar->isTabEnabled(index);
|
||||||
|
}
|
||||||
|
@ -29,10 +29,11 @@
|
|||||||
#ifndef FANCYTABWIDGET_H
|
#ifndef FANCYTABWIDGET_H
|
||||||
#define FANCYTABWIDGET_H
|
#define FANCYTABWIDGET_H
|
||||||
|
|
||||||
#include <QtGui/QPushButton>
|
#include <QIcon>
|
||||||
#include <QtGui/QTabBar>
|
#include <QWidget>
|
||||||
#include <QtGui/QStyleOptionTabV2>
|
|
||||||
#include <QtCore/QTimeLine>
|
#include <QTimer>
|
||||||
|
#include <QPropertyAnimation>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QPainter;
|
class QPainter;
|
||||||
@ -42,17 +43,40 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
struct FancyTab {
|
|
||||||
QIcon icon;
|
class FancyTab : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PROPERTY(float fader READ fader WRITE setFader)
|
||||||
|
public:
|
||||||
|
FancyTab(QWidget *tabbar) : enabled(false), tabbar(tabbar), m_fader(0) {
|
||||||
|
animator.setPropertyName("fader");
|
||||||
|
animator.setTargetObject(this);
|
||||||
|
}
|
||||||
|
float fader() { return m_fader; }
|
||||||
|
void setFader(float value);
|
||||||
|
|
||||||
|
void fadeIn();
|
||||||
|
void fadeOut();
|
||||||
|
|
||||||
|
QIcon icon;
|
||||||
QString text;
|
QString text;
|
||||||
QString toolTip;
|
QString toolTip;
|
||||||
|
bool enabled;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPropertyAnimation animator;
|
||||||
|
QWidget *tabbar;
|
||||||
|
float m_fader;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FancyTabBar : public QWidget {
|
class FancyTabBar : public QWidget
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FancyTabBar(QWidget *parent = 0, bool isVertical = false);
|
FancyTabBar(QWidget *parent = 0);
|
||||||
~FancyTabBar();
|
~FancyTabBar();
|
||||||
|
|
||||||
bool event(QEvent *event);
|
bool event(QEvent *event);
|
||||||
@ -63,85 +87,62 @@ public:
|
|||||||
void mouseMoveEvent(QMouseEvent *);
|
void mouseMoveEvent(QMouseEvent *);
|
||||||
void enterEvent(QEvent *);
|
void enterEvent(QEvent *);
|
||||||
void leaveEvent(QEvent *);
|
void leaveEvent(QEvent *);
|
||||||
|
bool validIndex(int index) const { return index >= 0 && index < m_tabs.count(); }
|
||||||
|
|
||||||
QSize sizeHint() const;
|
QSize sizeHint() const;
|
||||||
QSize minimumSizeHint() const;
|
QSize minimumSizeHint() const;
|
||||||
|
|
||||||
void insertTab(int index, const QIcon &icon, const QString &label)
|
void setTabEnabled(int index, bool enable);
|
||||||
{
|
bool isTabEnabled(int index) const;
|
||||||
FancyTab tab;
|
|
||||||
|
|
||||||
tab.icon = icon;
|
void insertTab(int index, const QIcon &icon, const QString &label) {
|
||||||
tab.text = label;
|
FancyTab *tab = new FancyTab(this);
|
||||||
|
tab->icon = icon;
|
||||||
|
tab->text = label;
|
||||||
m_tabs.insert(index, tab);
|
m_tabs.insert(index, tab);
|
||||||
|
updateGeometry();
|
||||||
}
|
}
|
||||||
void removeTab(int index)
|
void setEnabled(int index, bool enabled);
|
||||||
{
|
void removeTab(int index) {
|
||||||
m_tabs.removeAt(index);
|
FancyTab *tab = m_tabs.takeAt(index);
|
||||||
if (m_currentIndex >= m_tabs.length()) {
|
delete tab;
|
||||||
m_currentIndex = m_tabs.length() - 1;
|
updateGeometry();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void updateTabNameIcon(int index, const QIcon &icon, const QString &label);
|
|
||||||
void setCurrentIndex(int index);
|
void setCurrentIndex(int index);
|
||||||
int currentIndex() const
|
int currentIndex() const { return m_currentIndex; }
|
||||||
{
|
|
||||||
return m_currentIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setTabToolTip(int index, QString toolTip)
|
void setTabToolTip(int index, QString toolTip) { m_tabs[index]->toolTip = toolTip; }
|
||||||
{
|
QString tabToolTip(int index) const { return m_tabs.at(index)->toolTip; }
|
||||||
m_tabs[index].toolTip = toolTip;
|
|
||||||
}
|
|
||||||
QString tabToolTip(int index) const
|
|
||||||
{
|
|
||||||
return m_tabs.at(index).toolTip;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setIconSize(int s)
|
QIcon tabIcon(int index) const { return m_tabs.at(index)->icon; }
|
||||||
{
|
QString tabText(int index) const { return m_tabs.at(index)->text; }
|
||||||
iconSize = s;
|
int count() const {return m_tabs.count(); }
|
||||||
}
|
|
||||||
QIcon tabIcon(int index) const
|
|
||||||
{
|
|
||||||
return m_tabs.at(index).icon;
|
|
||||||
}
|
|
||||||
QString tabText(int index) const
|
|
||||||
{
|
|
||||||
return m_tabs.at(index).text;
|
|
||||||
}
|
|
||||||
int count() const
|
|
||||||
{
|
|
||||||
return m_tabs.count();
|
|
||||||
}
|
|
||||||
QRect tabRect(int index) const;
|
QRect tabRect(int index) const;
|
||||||
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentChanged(int);
|
void currentChanged(int);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateHover();
|
void emitCurrentIndex();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const int m_rounding;
|
static const int m_rounding;
|
||||||
static const int m_textPadding;
|
static const int m_textPadding;
|
||||||
QTimeLine m_hoverControl;
|
|
||||||
QRect m_hoverRect;
|
QRect m_hoverRect;
|
||||||
int m_hoverIndex;
|
int m_hoverIndex;
|
||||||
int m_currentIndex;
|
int m_currentIndex;
|
||||||
int iconSize;
|
QList<FancyTab*> m_tabs;
|
||||||
QList<FancyTab> m_tabs;
|
QTimer m_triggerTimer;
|
||||||
bool verticalTabs;
|
|
||||||
|
|
||||||
QSize tabSizeHint(bool minimum = false) const;
|
QSize tabSizeHint(bool minimum = false) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FancyTabWidget : public QWidget {
|
class FancyTabWidget : public QWidget
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FancyTabWidget(QWidget *parent = 0, bool isVertical = false);
|
FancyTabWidget(QWidget *parent = 0);
|
||||||
|
|
||||||
void insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label);
|
void insertTab(int index, QWidget *tab, const QIcon &icon, const QString &label);
|
||||||
void removeTab(int index);
|
void removeTab(int index);
|
||||||
@ -150,23 +151,24 @@ public:
|
|||||||
void insertCornerWidget(int pos, QWidget *widget);
|
void insertCornerWidget(int pos, QWidget *widget);
|
||||||
int cornerWidgetCount() const;
|
int cornerWidgetCount() const;
|
||||||
void setTabToolTip(int index, const QString &toolTip);
|
void setTabToolTip(int index, const QString &toolTip);
|
||||||
void updateTabNameIcon(int index, const QIcon &icon, const QString &label);
|
|
||||||
void setIconSize(int s)
|
|
||||||
{
|
|
||||||
m_tabBar->setIconSize(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void paintEvent(QPaintEvent *event);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
|
||||||
int currentIndex() const;
|
int currentIndex() const;
|
||||||
QStatusBar *statusBar() const;
|
QStatusBar *statusBar() const;
|
||||||
|
|
||||||
|
void setTabEnabled(int index, bool enable);
|
||||||
|
bool isTabEnabled(int index) const;
|
||||||
|
|
||||||
|
bool isSelectionWidgetVisible() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentAboutToShow(int index);
|
void currentAboutToShow(int index);
|
||||||
void currentChanged(int index);
|
void currentChanged(int index);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setCurrentIndex(int index);
|
void setCurrentIndex(int index);
|
||||||
|
void setSelectionWidgetVisible(bool visible);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void showWidget(int index);
|
void showWidget(int index);
|
||||||
@ -178,6 +180,7 @@ private:
|
|||||||
QWidget *m_selectionWidget;
|
QWidget *m_selectionWidget;
|
||||||
QStatusBar *m_statusBar;
|
QStatusBar *m_statusBar;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include <utils/qtcolorbutton.h>
|
#include <utils/qtcolorbutton.h>
|
||||||
#include <utils/consoleprocess.h>
|
#include <utils/consoleprocess.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QtCore/QDir>
|
#include <QtCore/QDir>
|
||||||
|
|
||||||
#include <QtCore/QLibraryInfo>
|
#include <QtCore/QLibraryInfo>
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/dialogs/ioptionspage.h>
|
#include <coreplugin/dialogs/ioptionspage.h>
|
||||||
#include <QtCore/QPointer>
|
#include <QtCore/QPointer>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/icontext.h>
|
#include <coreplugin/icontext.h>
|
||||||
#include <coreplugin/core_global.h>
|
#include <coreplugin/core_global.h>
|
||||||
#include <QtGui/QComboBox>
|
#include <QComboBox>
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtGui/QIcon>
|
#include <QIcon>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include "uavconfiginfo.h"
|
#include "uavconfiginfo.h"
|
||||||
|
|
||||||
|
@ -40,8 +40,6 @@
|
|||||||
#include "mimedatabase.h"
|
#include "mimedatabase.h"
|
||||||
#include "outputpane.h"
|
#include "outputpane.h"
|
||||||
#include "plugindialog.h"
|
#include "plugindialog.h"
|
||||||
#include "qxtlogger.h"
|
|
||||||
#include "qxtbasicstdloggerengine.h"
|
|
||||||
#include "shortcutsettings.h"
|
#include "shortcutsettings.h"
|
||||||
#include "uavgadgetmanager.h"
|
#include "uavgadgetmanager.h"
|
||||||
#include "uavgadgetinstancemanager.h"
|
#include "uavgadgetinstancemanager.h"
|
||||||
@ -74,18 +72,19 @@
|
|||||||
#include <QtCore/QtPlugin>
|
#include <QtCore/QtPlugin>
|
||||||
#include <QtCore/QUrl>
|
#include <QtCore/QUrl>
|
||||||
|
|
||||||
#include <QtGui/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
#include <QtGui/QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <QtGui/QMenu>
|
#include <QMenu>
|
||||||
#include <QtGui/QPixmap>
|
#include <QPixmap>
|
||||||
#include <QtGui/QShortcut>
|
#include <QShortcut>
|
||||||
#include <QtGui/QStatusBar>
|
#include <QStatusBar>
|
||||||
#include <QtGui/QWizard>
|
#include <QWizard>
|
||||||
#include <QtGui/QToolButton>
|
#include <QToolButton>
|
||||||
#include <QtGui/QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QElapsedTimer>
|
#include <QElapsedTimer>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QMimeData>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
@ -190,11 +189,6 @@ MainWindow::MainWindow() :
|
|||||||
connect(m_modeManager, SIGNAL(newModeOrder(QVector<IMode *>)), m_workspaceSettings, SLOT(newModeOrder(QVector<IMode *>)));
|
connect(m_modeManager, SIGNAL(newModeOrder(QVector<IMode *>)), m_workspaceSettings, SLOT(newModeOrder(QVector<IMode *>)));
|
||||||
statusBar()->setProperty("p_styled", true);
|
statusBar()->setProperty("p_styled", true);
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
foreach(QString engine, qxtLog->allLoggerEngines())
|
|
||||||
qxtLog->removeLoggerEngine(engine);
|
|
||||||
qxtLog->addLoggerEngine("std", new QxtBasicSTDLoggerEngine());
|
|
||||||
qxtLog->installAsMessageHandler();
|
|
||||||
qxtLog->enableAllLogLevels();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -206,9 +200,6 @@ MainWindow::~MainWindow()
|
|||||||
|
|
||||||
hide();
|
hide();
|
||||||
|
|
||||||
qxtLog->removeAsMessageHandler();
|
|
||||||
foreach(QString engine, qxtLog->allLoggerEngines())
|
|
||||||
qxtLog->removeLoggerEngine(engine);
|
|
||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
if (m_uavGadgetManagers.count() > 0) {
|
if (m_uavGadgetManagers.count() > 0) {
|
||||||
foreach(UAVGadgetManager * mode, m_uavGadgetManagers) {
|
foreach(UAVGadgetManager * mode, m_uavGadgetManagers) {
|
||||||
|
@ -30,47 +30,39 @@
|
|||||||
|
|
||||||
#include "styleanimator.h"
|
#include "styleanimator.h"
|
||||||
|
|
||||||
#include <QtCore/QLibrary>
|
#include <coreplugin/coreconstants.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/stylehelper.h>
|
#include <utils/stylehelper.h>
|
||||||
|
|
||||||
#include <QtGui/QApplication>
|
#include <utils/fancymainwindow.h>
|
||||||
#include <QtGui/QComboBox>
|
|
||||||
#include <QtGui/QDialog>
|
#include <QApplication>
|
||||||
#include <QtGui/QDialogButtonBox>
|
#include <QComboBox>
|
||||||
#include <QtGui/QDockWidget>
|
#include <QDockWidget>
|
||||||
#include <QtGui/QLabel>
|
#include <QLabel>
|
||||||
#include <QtGui/QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QtGui/QMainWindow>
|
#include <QMenuBar>
|
||||||
#include <QtGui/QMenuBar>
|
#include <QPainter>
|
||||||
#include <QtGui/QPainter>
|
#include <QPixmap>
|
||||||
#include <QtGui/QPixmap>
|
#include <QStatusBar>
|
||||||
#include <QtGui/QPixmapCache>
|
#include <QStyleFactory>
|
||||||
#include <QtGui/QPushButton>
|
#include <QStyleOption>
|
||||||
#include <QtGui/QScrollArea>
|
#include <QToolBar>
|
||||||
#include <QtGui/QSplitter>
|
#include <QToolButton>
|
||||||
#include <QtGui/QStatusBar>
|
|
||||||
#include <QtGui/QStyleFactory>
|
|
||||||
#include <QtGui/QStyleOption>
|
|
||||||
#include <QtGui/QToolBar>
|
|
||||||
#include <QtGui/QToolButton>
|
|
||||||
#include <QtGui/QAbstractItemView>
|
|
||||||
|
|
||||||
// We define a currently unused state for indicating animations
|
// We define a currently unused state for indicating animations
|
||||||
#define State_Animating 0x00000040
|
const QStyle::State State_Animating = QStyle::State(0x00000040);
|
||||||
|
|
||||||
// Because designer needs to disable this for widget previews
|
// Because designer needs to disable this for widget previews
|
||||||
// we have a custom property that is inherited
|
// we have a custom property that is inherited
|
||||||
bool styleEnabled(const QWidget *widget)
|
bool styleEnabled(const QWidget *widget)
|
||||||
{
|
{
|
||||||
const QWidget *p = widget;
|
const QWidget *p = widget;
|
||||||
|
|
||||||
while (p) {
|
while (p) {
|
||||||
if (p->property("_q_custom_style_disabled").toBool()) {
|
if (p->property("_q_custom_style_disabled").toBool())
|
||||||
return false;
|
return false;
|
||||||
}
|
p = p->parentWidget();
|
||||||
p = p->parentWidget();
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -78,53 +70,77 @@ bool styleEnabled(const QWidget *widget)
|
|||||||
// Consider making this a QStyle state
|
// Consider making this a QStyle state
|
||||||
bool panelWidget(const QWidget *widget)
|
bool panelWidget(const QWidget *widget)
|
||||||
{
|
{
|
||||||
const QWidget *p = widget;
|
if (!widget)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Do not style dialogs or explicitly ignored widgets
|
||||||
|
if ((widget->window()->windowFlags() & Qt::WindowType_Mask) == Qt::Dialog)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (qobject_cast<const Utils::FancyMainWindow *>(widget))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (qobject_cast<const QTabBar *>(widget))
|
||||||
|
return styleEnabled(widget);
|
||||||
|
|
||||||
|
const QWidget *p = widget;
|
||||||
while (p) {
|
while (p) {
|
||||||
if (qobject_cast<const QToolBar *>(p) && styleEnabled(p)) {
|
if (qobject_cast<const QToolBar *>(p) ||
|
||||||
return true;
|
qobject_cast<const QStatusBar *>(p) ||
|
||||||
} else if (qobject_cast<const QStatusBar *>(p) && styleEnabled(p)) {
|
qobject_cast<const QMenuBar *>(p) ||
|
||||||
return true;
|
p->property("panelwidget").toBool())
|
||||||
} else if (qobject_cast<const QMenuBar *>(p) && styleEnabled(p)) {
|
return styleEnabled(widget);
|
||||||
return true;
|
|
||||||
} else if (p->property("panelwidget").toBool()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
p = p->parentWidget();
|
p = p->parentWidget();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ManhattanStylePrivate {
|
// Consider making this a QStyle state
|
||||||
|
bool lightColored(const QWidget *widget)
|
||||||
|
{
|
||||||
|
if (!widget)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Don't style dialogs or explicitly ignored widgets
|
||||||
|
if ((widget->window()->windowFlags() & Qt::WindowType_Mask) == Qt::Dialog)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const QWidget *p = widget;
|
||||||
|
while (p) {
|
||||||
|
if (p->property("lightColored").toBool())
|
||||||
|
return true;
|
||||||
|
p = p->parentWidget();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ManhattanStylePrivate
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
ManhattanStylePrivate(const QString &baseStyleName)
|
explicit ManhattanStylePrivate();
|
||||||
{
|
|
||||||
style = QStyleFactory::create(baseStyleName);
|
|
||||||
QTC_ASSERT(style, /**/);
|
|
||||||
|
|
||||||
lineeditImage = QImage(":/core/images/inputfield.png");
|
|
||||||
lineeditImage_disabled = QImage(":/core/images/inputfield_disabled.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
~ManhattanStylePrivate()
|
|
||||||
{
|
|
||||||
delete style;
|
|
||||||
style = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QStyle *style;
|
const QImage lineeditImage;
|
||||||
QImage lineeditImage;
|
const QImage lineeditImage_disabled;
|
||||||
QImage lineeditImage_disabled;
|
const QPixmap extButtonPixmap;
|
||||||
|
const QPixmap closeButtonPixmap;
|
||||||
StyleAnimator animator;
|
StyleAnimator animator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ManhattanStylePrivate::ManhattanStylePrivate() :
|
||||||
|
lineeditImage(QLatin1String(":/core/images/inputfield.png")),
|
||||||
|
lineeditImage_disabled(QLatin1String(":/core/images/inputfield_disabled.png")),
|
||||||
|
extButtonPixmap(QLatin1String(":/core/images/extension.png")),
|
||||||
|
closeButtonPixmap(QLatin1String(Core::Constants::ICON_CLOSE))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ManhattanStyle::ManhattanStyle(const QString &baseStyleName)
|
ManhattanStyle::ManhattanStyle(const QString &baseStyleName)
|
||||||
: QWindowsStyle(), d(new ManhattanStylePrivate(baseStyleName))
|
: QProxyStyle(QStyleFactory::create(baseStyleName)),
|
||||||
{}
|
d(new ManhattanStylePrivate())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
ManhattanStyle::~ManhattanStyle()
|
ManhattanStyle::~ManhattanStyle()
|
||||||
{
|
{
|
||||||
@ -132,175 +148,74 @@ ManhattanStyle::~ManhattanStyle()
|
|||||||
d = 0;
|
d = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStyle *ManhattanStyle::systemStyle() const
|
|
||||||
{
|
|
||||||
return d->style;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draws a CSS-like border image where the defined borders are not stretched
|
|
||||||
void drawCornerImage(const QImage &img, QPainter *painter, QRect rect,
|
|
||||||
int left = 0, int top = 0, int right = 0,
|
|
||||||
int bottom = 0)
|
|
||||||
{
|
|
||||||
QSize size = img.size();
|
|
||||||
|
|
||||||
if (top > 0) { // top
|
|
||||||
painter->drawImage(QRect(rect.left() + left, rect.top(), rect.width() - right - left, top), img,
|
|
||||||
QRect(left, 0, size.width() - right - left, top));
|
|
||||||
if (left > 0) { // top-left
|
|
||||||
painter->drawImage(QRect(rect.left(), rect.top(), left, top), img,
|
|
||||||
QRect(0, 0, left, top));
|
|
||||||
}
|
|
||||||
if (right > 0) { // top-right
|
|
||||||
painter->drawImage(QRect(rect.left() + rect.width() - right, rect.top(), right, top), img,
|
|
||||||
QRect(size.width() - right, 0, right, top));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// left
|
|
||||||
if (left > 0) {
|
|
||||||
painter->drawImage(QRect(rect.left(), rect.top() + top, left, rect.height() - top - bottom), img,
|
|
||||||
QRect(0, top, left, size.height() - bottom - top));
|
|
||||||
}
|
|
||||||
// center
|
|
||||||
painter->drawImage(QRect(rect.left() + left, rect.top() + top, rect.width() - right - left,
|
|
||||||
rect.height() - bottom - top), img,
|
|
||||||
QRect(left, top, size.width() - right - left,
|
|
||||||
size.height() - bottom - top));
|
|
||||||
if (right > 0) { // right
|
|
||||||
painter->drawImage(QRect(rect.left() + rect.width() - right, rect.top() + top, right, rect.height() - top - bottom), img,
|
|
||||||
QRect(size.width() - right, top, right, size.height() - bottom - top));
|
|
||||||
}
|
|
||||||
if (bottom > 0) { // bottom
|
|
||||||
painter->drawImage(QRect(rect.left() + left, rect.top() + rect.height() - bottom,
|
|
||||||
rect.width() - right - left, bottom), img,
|
|
||||||
QRect(left, size.height() - bottom,
|
|
||||||
size.width() - right - left, bottom));
|
|
||||||
if (left > 0) { // bottom-left
|
|
||||||
painter->drawImage(QRect(rect.left(), rect.top() + rect.height() - bottom, left, bottom), img,
|
|
||||||
QRect(0, size.height() - bottom, left, bottom));
|
|
||||||
}
|
|
||||||
if (right > 0) { // bottom-right
|
|
||||||
painter->drawImage(QRect(rect.left() + rect.width() - right, rect.top() + rect.height() - bottom, right, bottom), img,
|
|
||||||
QRect(size.width() - right, size.height() - bottom, right, bottom));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QPixmap ManhattanStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const
|
QPixmap ManhattanStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const
|
||||||
{
|
{
|
||||||
QPixmap result;
|
return QProxyStyle::generatedIconPixmap(iconMode, pixmap, opt);
|
||||||
|
|
||||||
result = d->style->generatedIconPixmap(iconMode, pixmap, opt);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ManhattanStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1,
|
|
||||||
QSizePolicy::ControlType control2,
|
|
||||||
Qt::Orientation orientation,
|
|
||||||
const QStyleOption *option,
|
|
||||||
const QWidget *widget) const
|
|
||||||
{
|
|
||||||
return d->style->layoutSpacing(control1, control2, orientation, option, widget);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSize ManhattanStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
|
QSize ManhattanStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
|
||||||
const QSize &size, const QWidget *widget) const
|
const QSize &size, const QWidget *widget) const
|
||||||
{
|
{
|
||||||
QSize newSize = d->style->sizeFromContents(type, option, size, widget);
|
QSize newSize = QProxyStyle::sizeFromContents(type, option, size, widget);
|
||||||
|
|
||||||
if (type == CT_Splitter && widget && widget->property("minisplitter").toBool()) {
|
if (type == CT_Splitter && widget && widget->property("minisplitter").toBool())
|
||||||
return QSize(1, 1);
|
return QSize(1, 1);
|
||||||
} else if (type == CT_ComboBox && panelWidget(widget)) {
|
else if (type == CT_ComboBox && panelWidget(widget))
|
||||||
newSize += QSize(14, 0);
|
newSize += QSize(14, 0);
|
||||||
}
|
|
||||||
return newSize;
|
return newSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect ManhattanStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
|
QRect ManhattanStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
|
||||||
{
|
{
|
||||||
QRect rect;
|
return QProxyStyle::subElementRect(element, option, widget);
|
||||||
|
|
||||||
rect = d->style->subElementRect(element, option, widget);
|
|
||||||
return rect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QRect ManhattanStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
|
QRect ManhattanStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
|
||||||
SubControl subControl, const QWidget *widget) const
|
SubControl subControl, const QWidget *widget) const
|
||||||
{
|
{
|
||||||
QRect rect;
|
return QProxyStyle::subControlRect(control, option, subControl, widget);
|
||||||
|
|
||||||
#ifndef Q_WS_MACX
|
|
||||||
// Not using OSX, size combo dropdown to fit contents
|
|
||||||
if (control == CC_ComboBox && subControl == SC_ComboBoxListBoxPopup) {
|
|
||||||
const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option);
|
|
||||||
const QComboBox *combo = qobject_cast<const QComboBox *>(widget);
|
|
||||||
QRect comboRect = cb->rect;
|
|
||||||
int newWidth = combo->view()->sizeHintForColumn(0);
|
|
||||||
if (newWidth > comboRect.width()) {
|
|
||||||
// Set new rectangle, only width matters, list height is set by
|
|
||||||
// combination of number of combo box items and setMaxVisibleItems
|
|
||||||
rect.setRect(comboRect.x(), comboRect.y(), newWidth, comboRect.height());
|
|
||||||
rect = visualRect(cb->direction, cb->rect, rect);
|
|
||||||
} else {
|
|
||||||
rect = d->style->subControlRect(control, option, subControl, widget);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
rect = d->style->subControlRect(control, option, subControl, widget);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// Using OSX, use default style behaviour as this already sizes the
|
|
||||||
// combo dropdown to fit
|
|
||||||
rect = d->style->subControlRect(control, option, subControl, widget);
|
|
||||||
#endif // ifndef Q_WS_MACX
|
|
||||||
return rect;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStyle::SubControl ManhattanStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
|
QStyle::SubControl ManhattanStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
|
||||||
const QPoint &pos, const QWidget *widget) const
|
const QPoint &pos, const QWidget *widget) const
|
||||||
{
|
{
|
||||||
SubControl result = QStyle::SC_None;
|
return QProxyStyle::hitTestComplexControl(control, option, pos, widget);
|
||||||
|
|
||||||
result = d->style->hitTestComplexControl(control, option, pos, widget);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ManhattanStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
|
int ManhattanStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
retval = QProxyStyle::pixelMetric(metric, option, widget);
|
||||||
retval = d->style->pixelMetric(metric, option, widget);
|
|
||||||
switch (metric) {
|
switch (metric) {
|
||||||
case PM_SplitterWidth:
|
case PM_SplitterWidth:
|
||||||
if (widget && widget->property("minisplitter").toBool()) {
|
if (widget && widget->property("minisplitter").toBool())
|
||||||
retval = 1;
|
retval = 1;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case PM_ToolBarIconSize:
|
case PM_ToolBarIconSize:
|
||||||
if (panelWidget(widget)) {
|
if (panelWidget(widget))
|
||||||
retval = 16;
|
retval = 16;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
case PM_DockWidgetHandleExtent:
|
||||||
|
case PM_DockWidgetSeparatorExtent:
|
||||||
|
return 1;
|
||||||
case PM_MenuPanelWidth:
|
case PM_MenuPanelWidth:
|
||||||
case PM_MenuBarHMargin:
|
case PM_MenuBarHMargin:
|
||||||
case PM_MenuBarVMargin:
|
case PM_MenuBarVMargin:
|
||||||
case PM_ToolBarFrameWidth:
|
case PM_ToolBarFrameWidth:
|
||||||
if (panelWidget(widget)) {
|
if (panelWidget(widget))
|
||||||
retval = 1;
|
retval = 1;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case PM_ButtonShiftVertical:
|
case PM_ButtonShiftVertical:
|
||||||
case PM_ButtonShiftHorizontal:
|
case PM_ButtonShiftHorizontal:
|
||||||
case PM_MenuBarPanelWidth:
|
case PM_MenuBarPanelWidth:
|
||||||
case PM_ToolBarItemMargin:
|
case PM_ToolBarItemMargin:
|
||||||
case PM_ToolBarItemSpacing:
|
case PM_ToolBarItemSpacing:
|
||||||
if (panelWidget(widget)) {
|
if (panelWidget(widget))
|
||||||
retval = 0;
|
retval = 0;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case PM_DefaultFrameWidth:
|
case PM_DefaultFrameWidth:
|
||||||
if (qobject_cast<const QLineEdit *>(widget) && panelWidget(widget)) {
|
if (qobject_cast<const QLineEdit*>(widget) && panelWidget(widget))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -310,27 +225,23 @@ int ManhattanStyle::pixelMetric(PixelMetric metric, const QStyleOption *option,
|
|||||||
|
|
||||||
QPalette ManhattanStyle::standardPalette() const
|
QPalette ManhattanStyle::standardPalette() const
|
||||||
{
|
{
|
||||||
QPalette result;
|
return QProxyStyle::standardPalette();
|
||||||
|
|
||||||
result = d->style->standardPalette();
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ManhattanStyle::polish(QApplication *app)
|
void ManhattanStyle::polish(QApplication *app)
|
||||||
{
|
{
|
||||||
d->style->polish(app);
|
return QProxyStyle::polish(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ManhattanStyle::unpolish(QApplication *app)
|
void ManhattanStyle::unpolish(QApplication *app)
|
||||||
{
|
{
|
||||||
d->style->unpolish(app);
|
return QProxyStyle::unpolish(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPalette panelPalette(const QPalette &oldPalette)
|
QPalette panelPalette(const QPalette &oldPalette, bool lightColored = false)
|
||||||
{
|
{
|
||||||
QColor color = Utils::StyleHelper::panelTextColor();
|
QColor color = Utils::StyleHelper::panelTextColor(lightColored);
|
||||||
QPalette pal = oldPalette;
|
QPalette pal = oldPalette;
|
||||||
|
|
||||||
pal.setBrush(QPalette::All, QPalette::WindowText, color);
|
pal.setBrush(QPalette::All, QPalette::WindowText, color);
|
||||||
pal.setBrush(QPalette::All, QPalette::ButtonText, color);
|
pal.setBrush(QPalette::All, QPalette::ButtonText, color);
|
||||||
pal.setBrush(QPalette::All, QPalette::Foreground, color);
|
pal.setBrush(QPalette::All, QPalette::Foreground, color);
|
||||||
@ -343,29 +254,37 @@ QPalette panelPalette(const QPalette &oldPalette)
|
|||||||
|
|
||||||
void ManhattanStyle::polish(QWidget *widget)
|
void ManhattanStyle::polish(QWidget *widget)
|
||||||
{
|
{
|
||||||
d->style->polish(widget);
|
QProxyStyle::polish(widget);
|
||||||
|
|
||||||
// OxygenStyle forces a rounded widget mask on toolbars
|
// OxygenStyle forces a rounded widget mask on toolbars and dock widgets
|
||||||
if (d->style->inherits("OxygenStyle")) {
|
if (baseStyle()->inherits("OxygenStyle") || baseStyle()->inherits("Oxygen::Style")) {
|
||||||
if (qobject_cast<QToolBar *>(widget)) {
|
if (qobject_cast<QToolBar*>(widget) || qobject_cast<QDockWidget*>(widget)) {
|
||||||
widget->removeEventFilter(d->style);
|
widget->removeEventFilter(baseStyle());
|
||||||
|
widget->setContentsMargins(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (panelWidget(widget)) {
|
if (panelWidget(widget)) {
|
||||||
|
|
||||||
|
// Oxygen and possibly other styles override this
|
||||||
|
if (qobject_cast<QDockWidget*>(widget))
|
||||||
|
widget->setContentsMargins(0, 0, 0, 0);
|
||||||
|
|
||||||
widget->setAttribute(Qt::WA_LayoutUsesWidgetRect, true);
|
widget->setAttribute(Qt::WA_LayoutUsesWidgetRect, true);
|
||||||
if (qobject_cast<QToolButton *>(widget)) {
|
if (qobject_cast<QToolButton*>(widget)) {
|
||||||
widget->setAttribute(Qt::WA_Hover);
|
widget->setAttribute(Qt::WA_Hover);
|
||||||
widget->setMaximumHeight(Utils::StyleHelper::navigationWidgetHeight() - 2);
|
widget->setMaximumHeight(Utils::StyleHelper::navigationWidgetHeight() - 2);
|
||||||
} else if (qobject_cast<QLineEdit *>(widget)) {
|
}
|
||||||
|
else if (qobject_cast<QLineEdit*>(widget)) {
|
||||||
widget->setAttribute(Qt::WA_Hover);
|
widget->setAttribute(Qt::WA_Hover);
|
||||||
widget->setMaximumHeight(Utils::StyleHelper::navigationWidgetHeight() - 2);
|
widget->setMaximumHeight(Utils::StyleHelper::navigationWidgetHeight() - 2);
|
||||||
} else if (qobject_cast<QLabel *>(widget)) {
|
}
|
||||||
|
else if (qobject_cast<QLabel*>(widget))
|
||||||
widget->setPalette(panelPalette(widget->palette()));
|
widget->setPalette(panelPalette(widget->palette()));
|
||||||
} else if (qobject_cast<QToolBar *>(widget) || widget->property("panelwidget_singlerow").toBool()) {
|
else if (widget->property("panelwidget_singlerow").toBool())
|
||||||
widget->setFixedHeight(Utils::StyleHelper::navigationWidgetHeight());
|
widget->setFixedHeight(Utils::StyleHelper::navigationWidgetHeight());
|
||||||
} else if (qobject_cast<QStatusBar *>(widget)) {
|
else if (qobject_cast<QStatusBar*>(widget))
|
||||||
widget->setFixedHeight(Utils::StyleHelper::navigationWidgetHeight() + 2);
|
widget->setFixedHeight(Utils::StyleHelper::navigationWidgetHeight() + 2);
|
||||||
} else if (qobject_cast<QComboBox *>(widget)) {
|
else if (qobject_cast<QComboBox*>(widget)) {
|
||||||
widget->setMaximumHeight(Utils::StyleHelper::navigationWidgetHeight() - 2);
|
widget->setMaximumHeight(Utils::StyleHelper::navigationWidgetHeight() - 2);
|
||||||
widget->setAttribute(Qt::WA_Hover);
|
widget->setAttribute(Qt::WA_Hover);
|
||||||
}
|
}
|
||||||
@ -374,36 +293,32 @@ void ManhattanStyle::polish(QWidget *widget)
|
|||||||
|
|
||||||
void ManhattanStyle::unpolish(QWidget *widget)
|
void ManhattanStyle::unpolish(QWidget *widget)
|
||||||
{
|
{
|
||||||
d->style->unpolish(widget);
|
QProxyStyle::unpolish(widget);
|
||||||
if (panelWidget(widget)) {
|
if (panelWidget(widget)) {
|
||||||
widget->setAttribute(Qt::WA_LayoutUsesWidgetRect, false);
|
widget->setAttribute(Qt::WA_LayoutUsesWidgetRect, false);
|
||||||
if (qobject_cast<QTabBar *>(widget)) {
|
if (qobject_cast<QTabBar*>(widget))
|
||||||
widget->setAttribute(Qt::WA_Hover, false);
|
widget->setAttribute(Qt::WA_Hover, false);
|
||||||
} else if (qobject_cast<QToolBar *>(widget)) {
|
else if (qobject_cast<QToolBar*>(widget))
|
||||||
widget->setAttribute(Qt::WA_Hover, false);
|
widget->setAttribute(Qt::WA_Hover, false);
|
||||||
} else if (qobject_cast<QComboBox *>(widget)) {
|
else if (qobject_cast<QComboBox*>(widget))
|
||||||
widget->setAttribute(Qt::WA_Hover, false);
|
widget->setAttribute(Qt::WA_Hover, false);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ManhattanStyle::polish(QPalette &pal)
|
void ManhattanStyle::polish(QPalette &pal)
|
||||||
{
|
{
|
||||||
d->style->polish(pal);
|
QProxyStyle::polish(pal);
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
|
QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const
|
||||||
const QWidget *widget) const
|
|
||||||
{
|
{
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
|
|
||||||
switch (standardIcon) {
|
switch (standardIcon) {
|
||||||
case QStyle::SP_TitleBarCloseButton:
|
case QStyle::SP_TitleBarCloseButton:
|
||||||
case QStyle::SP_ToolBarHorizontalExtensionButton:
|
case QStyle::SP_ToolBarHorizontalExtensionButton:
|
||||||
return QIcon(standardPixmap(standardIcon, option, widget));
|
return QIcon(standardPixmap(standardIcon, option, widget));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
icon = d->style->standardIcon(standardIcon, option, widget);
|
icon = baseStyle()->standardIcon(standardIcon, option, widget);
|
||||||
}
|
}
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
@ -411,47 +326,40 @@ QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, co
|
|||||||
QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
|
QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
|
||||||
const QWidget *widget) const
|
const QWidget *widget) const
|
||||||
{
|
{
|
||||||
if (widget && !panelWidget(widget)) {
|
if (widget && !panelWidget(widget))
|
||||||
return d->style->standardPixmap(standardPixmap, opt, widget);
|
return QProxyStyle::standardPixmap(standardPixmap, opt, widget);
|
||||||
}
|
|
||||||
|
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
switch (standardPixmap) {
|
switch (standardPixmap) {
|
||||||
case QStyle::SP_ToolBarHorizontalExtensionButton:
|
case QStyle::SP_ToolBarHorizontalExtensionButton:
|
||||||
{
|
pixmap = d->extButtonPixmap;
|
||||||
static const QPixmap extButton(":/core/images/extension.png");
|
break;
|
||||||
pixmap = extButton;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case QStyle::SP_TitleBarCloseButton:
|
case QStyle::SP_TitleBarCloseButton:
|
||||||
{
|
pixmap = d->closeButtonPixmap;
|
||||||
static const QPixmap closeButton(":/core/images/closebutton.png");
|
break;
|
||||||
pixmap = closeButton;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
pixmap = d->style->standardPixmap(standardPixmap, opt, widget);
|
pixmap = QProxyStyle::standardPixmap(standardPixmap, opt, widget);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return pixmap;
|
return pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
|
int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
|
||||||
QStyleHintReturn *returnData) const
|
QStyleHintReturn *returnData) const
|
||||||
{
|
{
|
||||||
int ret = d->style->styleHint(hint, option, widget, returnData);
|
int ret = QProxyStyle::styleHint(hint, option, widget, returnData);
|
||||||
|
|
||||||
switch (hint) {
|
switch (hint) {
|
||||||
// Make project explorer alternate rows all the way
|
// Make project explorer alternate rows all the way
|
||||||
case QStyle::SH_ItemView_PaintAlternatingRowColorsForEmptyArea:
|
case QStyle::SH_ItemView_PaintAlternatingRowColorsForEmptyArea:
|
||||||
if (widget && widget->property("AlternateEmpty").toBool()) {
|
if (widget && widget->property("AlternateEmpty").toBool())
|
||||||
ret = true;
|
ret = true;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case QStyle::SH_EtchDisabledText:
|
case QStyle::SH_EtchDisabledText:
|
||||||
if (panelWidget(widget)) {
|
if (panelWidget(widget))
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
break;
|
||||||
|
case QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren:
|
||||||
|
ret = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -462,17 +370,16 @@ int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const
|
|||||||
void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
|
void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
|
||||||
QPainter *painter, const QWidget *widget) const
|
QPainter *painter, const QWidget *widget) const
|
||||||
{
|
{
|
||||||
if (!panelWidget(widget)) {
|
if (!panelWidget(widget))
|
||||||
return d->style->drawPrimitive(element, option, painter, widget);
|
return QProxyStyle::drawPrimitive(element, option, painter, widget);
|
||||||
}
|
|
||||||
|
|
||||||
bool animating = (option->state & State_Animating);
|
bool animating = (option->state & State_Animating);
|
||||||
int state = option->state;
|
int state = option->state;
|
||||||
QRect rect = option->rect;
|
QRect rect = option->rect;
|
||||||
QRect oldRect;
|
QRect oldRect;
|
||||||
QRect newRect;
|
QRect newRect;
|
||||||
if (widget && (element == PE_PanelButtonTool) && !animating) {
|
if (widget && (element == PE_PanelButtonTool) && !animating) {
|
||||||
QWidget *w = const_cast<QWidget *> (widget);
|
QWidget *w = const_cast<QWidget *> (widget);
|
||||||
int oldState = w->property("_q_stylestate").toInt();
|
int oldState = w->property("_q_stylestate").toInt();
|
||||||
oldRect = w->property("_q_stylerect").toRect();
|
oldRect = w->property("_q_stylerect").toRect();
|
||||||
newRect = w->rect();
|
newRect = w->rect();
|
||||||
@ -480,9 +387,10 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
|
|||||||
w->setProperty("_q_stylerect", w->rect());
|
w->setProperty("_q_stylerect", w->rect());
|
||||||
|
|
||||||
// Determine the animated transition
|
// Determine the animated transition
|
||||||
bool doTransition = ((state & State_On) != (oldState & State_On) ||
|
bool doTransition = ((state & State_On) != (oldState & State_On) ||
|
||||||
(state & State_MouseOver) != (oldState & State_MouseOver));
|
(state & State_MouseOver) != (oldState & State_MouseOver));
|
||||||
if (oldRect != newRect) {
|
if (oldRect != newRect)
|
||||||
|
{
|
||||||
doTransition = false;
|
doTransition = false;
|
||||||
d->animator.stopAnimation(widget);
|
d->animator.stopAnimation(widget);
|
||||||
}
|
}
|
||||||
@ -490,10 +398,10 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
|
|||||||
if (doTransition) {
|
if (doTransition) {
|
||||||
QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
||||||
QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied);
|
||||||
Animation *anim = d->animator.widgetAnimation(widget);
|
Animation *anim = d->animator.widgetAnimation(widget);
|
||||||
QStyleOption opt = *option;
|
QStyleOption opt = *option;
|
||||||
opt.state = (QStyle::State)oldState;
|
opt.state = (QStyle::State)oldState;
|
||||||
opt.state |= (State)State_Animating;
|
opt.state |= State_Animating;
|
||||||
startImage.fill(0);
|
startImage.fill(0);
|
||||||
Transition *t = new Transition;
|
Transition *t = new Transition;
|
||||||
t->setWidget(w);
|
t->setWidget(w);
|
||||||
@ -505,253 +413,186 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
|
|||||||
d->animator.stopAnimation(widget);
|
d->animator.stopAnimation(widget);
|
||||||
}
|
}
|
||||||
QStyleOption endOpt = *option;
|
QStyleOption endOpt = *option;
|
||||||
endOpt.state |= (State)State_Animating;
|
endOpt.state |= State_Animating;
|
||||||
t->setStartImage(startImage);
|
t->setStartImage(startImage);
|
||||||
d->animator.startAnimation(t);
|
d->animator.startAnimation(t);
|
||||||
endImage.fill(0);
|
endImage.fill(0);
|
||||||
QPainter endPainter(&endImage);
|
QPainter endPainter(&endImage);
|
||||||
drawPrimitive(element, &endOpt, &endPainter, widget);
|
drawPrimitive(element, &endOpt, &endPainter, widget);
|
||||||
t->setEndImage(endImage);
|
t->setEndImage(endImage);
|
||||||
if (oldState & State_MouseOver) {
|
if (oldState & State_MouseOver)
|
||||||
t->setDuration(150);
|
t->setDuration(150);
|
||||||
} else {
|
else
|
||||||
t->setDuration(75);
|
t->setDuration(75);
|
||||||
}
|
|
||||||
t->setStartTime(QTime::currentTime());
|
t->setStartTime(QTime::currentTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (element) {
|
switch (element) {
|
||||||
|
case PE_IndicatorDockWidgetResizeHandle:
|
||||||
|
painter->fillRect(option->rect, Utils::StyleHelper::borderColor());
|
||||||
|
break;
|
||||||
|
case PE_FrameDockWidget:
|
||||||
|
QCommonStyle::drawPrimitive(element, option, painter, widget);
|
||||||
|
break;
|
||||||
case PE_PanelLineEdit:
|
case PE_PanelLineEdit:
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
|
|
||||||
// Fill the line edit background
|
// Fill the line edit background
|
||||||
QRect filledRect = option->rect.adjusted(1, 1, -1, -1);
|
QRect filledRect = option->rect.adjusted(1, 1, -1, -1);
|
||||||
painter->setBrushOrigin(filledRect.topLeft());
|
painter->setBrushOrigin(filledRect.topLeft());
|
||||||
painter->fillRect(filledRect, option->palette.base());
|
painter->fillRect(filledRect, option->palette.base());
|
||||||
|
|
||||||
if (option->state & State_Enabled) {
|
if (option->state & State_Enabled)
|
||||||
drawCornerImage(d->lineeditImage, painter, option->rect, 2, 2, 2, 2);
|
Utils::StyleHelper::drawCornerImage(d->lineeditImage, painter, option->rect, 5, 5, 5, 5);
|
||||||
} else {
|
else
|
||||||
drawCornerImage(d->lineeditImage_disabled, painter, option->rect, 2, 2, 2, 2);
|
Utils::StyleHelper::drawCornerImage(d->lineeditImage_disabled, painter, option->rect, 5, 5, 5, 5);
|
||||||
}
|
|
||||||
|
|
||||||
if (option->state & State_HasFocus || option->state & State_MouseOver) {
|
if (option->state & State_HasFocus || option->state & State_MouseOver) {
|
||||||
QColor hover = Utils::StyleHelper::baseColor();
|
QColor hover = Utils::StyleHelper::baseColor();
|
||||||
if (state & State_HasFocus) {
|
if (state & State_HasFocus)
|
||||||
hover.setAlpha(100);
|
hover.setAlpha(100);
|
||||||
} else {
|
else
|
||||||
hover.setAlpha(50);
|
hover.setAlpha(50);
|
||||||
|
|
||||||
|
painter->setPen(QPen(hover, 1));
|
||||||
|
painter->drawRect(option->rect.adjusted(1, 1, -2 ,-2));
|
||||||
}
|
}
|
||||||
|
painter->restore();
|
||||||
painter->setPen(QPen(hover, 1));
|
|
||||||
painter->drawRect(option->rect.adjusted(1, 1, -2, -2));
|
|
||||||
}
|
}
|
||||||
painter->restore();
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PE_FrameStatusBarItem:
|
case PE_FrameStatusBarItem:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PE_PanelButtonTool:
|
case PE_PanelButtonTool: {
|
||||||
{
|
Animation *anim = d->animator.widgetAnimation(widget);
|
||||||
Animation *anim = d->animator.widgetAnimation(widget);
|
if (!animating && anim) {
|
||||||
if (!animating && anim) {
|
anim->paint(painter, option);
|
||||||
anim->paint(painter, option);
|
} else {
|
||||||
} else {
|
bool pressed = option->state & State_Sunken || option->state & State_On;
|
||||||
bool pressed = option->state & State_Sunken || option->state & State_On;
|
QColor shadow(0, 0, 0, 30);
|
||||||
QColor shadow(0, 0, 0, 30);
|
painter->setPen(shadow);
|
||||||
painter->setPen(shadow);
|
if (pressed) {
|
||||||
if (pressed) {
|
QColor shade(0, 0, 0, 40);
|
||||||
QColor shade(0, 0, 0, 40);
|
painter->fillRect(rect, shade);
|
||||||
painter->fillRect(rect, shade);
|
painter->drawLine(rect.topLeft() + QPoint(1, 0), rect.topRight() - QPoint(1, 0));
|
||||||
painter->drawLine(rect.topLeft() + QPoint(1, 0), rect.topRight() - QPoint(1, 0));
|
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
// painter->drawLine(rect.bottomLeft() + QPoint(1, 0), rect.bottomRight() - QPoint(1, 0));
|
||||||
// painter->drawLine(rect.bottomLeft() + QPoint(1, 0), rect.bottomRight() - QPoint(1, 0));
|
QColor highlight(255, 255, 255, 30);
|
||||||
QColor highlight(255, 255, 255, 30);
|
painter->setPen(highlight);
|
||||||
painter->setPen(highlight);
|
}
|
||||||
} else if (option->state & State_Enabled &&
|
else if (option->state & State_Enabled &&
|
||||||
option->state & State_MouseOver) {
|
option->state & State_MouseOver) {
|
||||||
QColor lighter(255, 255, 255, 37);
|
QColor lighter(255, 255, 255, 37);
|
||||||
painter->fillRect(rect, lighter);
|
painter->fillRect(rect, lighter);
|
||||||
}
|
}
|
||||||
|
if (option->state & State_HasFocus && (option->state & State_KeyboardFocusChange)) {
|
||||||
|
QColor highlight = option->palette.highlight().color();
|
||||||
|
highlight.setAlphaF(0.4);
|
||||||
|
painter->setPen(QPen(highlight.lighter(), 1));
|
||||||
|
highlight.setAlphaF(0.3);
|
||||||
|
painter->setBrush(highlight);
|
||||||
|
painter->setRenderHint(QPainter::Antialiasing);
|
||||||
|
QRectF rect = option->rect;
|
||||||
|
rect.translate(0.5, 0.5);
|
||||||
|
painter->drawRoundedRect(rect.adjusted(2, 2, -3, -3), 2, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case PE_PanelStatusBar:
|
case PE_PanelStatusBar:
|
||||||
{
|
{
|
||||||
painter->save();
|
painter->save();
|
||||||
QLinearGradient grad(option->rect.topLeft(), QPoint(rect.center().x(), rect.bottom()));
|
QLinearGradient grad = Utils::StyleHelper::statusBarGradient(rect);
|
||||||
QColor startColor = Utils::StyleHelper::shadowColor().darker(164);
|
painter->fillRect(rect, grad);
|
||||||
QColor endColor = Utils::StyleHelper::baseColor().darker(130);
|
painter->setPen(QColor(255, 255, 255, 60));
|
||||||
grad.setColorAt(0, startColor);
|
painter->drawLine(rect.topLeft() + QPoint(0,1),
|
||||||
grad.setColorAt(1, endColor);
|
rect.topRight()+ QPoint(0,1));
|
||||||
painter->fillRect(option->rect, grad);
|
painter->setPen(Utils::StyleHelper::borderColor().darker(110));
|
||||||
painter->setPen(QColor(255, 255, 255, 60));
|
painter->drawLine(rect.topLeft(), rect.topRight());
|
||||||
painter->drawLine(rect.topLeft() + QPoint(0, 1),
|
painter->restore();
|
||||||
rect.topRight() + QPoint(0, 1));
|
}
|
||||||
painter->setPen(Utils::StyleHelper::borderColor().darker(110));
|
break;
|
||||||
painter->drawLine(rect.topLeft(), rect.topRight());
|
|
||||||
painter->restore();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PE_IndicatorToolBarSeparator:
|
case PE_IndicatorToolBarSeparator:
|
||||||
{
|
{
|
||||||
QColor separatorColor = Utils::StyleHelper::borderColor();
|
QColor separatorColor = Utils::StyleHelper::borderColor();
|
||||||
separatorColor.setAlpha(100);
|
separatorColor.setAlpha(100);
|
||||||
painter->setPen(separatorColor);
|
painter->setPen(separatorColor);
|
||||||
const int margin = 6;
|
const int margin = 6;
|
||||||
if (option->state & State_Horizontal) {
|
if (option->state & State_Horizontal) {
|
||||||
const int offset = rect.width() / 2;
|
const int offset = rect.width()/2;
|
||||||
painter->drawLine(rect.bottomLeft().x() + offset,
|
painter->drawLine(rect.bottomLeft().x() + offset,
|
||||||
rect.bottomLeft().y() - margin,
|
rect.bottomLeft().y() - margin,
|
||||||
rect.topLeft().x() + offset,
|
rect.topLeft().x() + offset,
|
||||||
rect.topLeft().y() + margin);
|
rect.topLeft().y() + margin);
|
||||||
} else { // Draw vertical separator
|
} else { //Draw vertical separator
|
||||||
const int offset = rect.height() / 2;
|
const int offset = rect.height()/2;
|
||||||
painter->setPen(QPen(option->palette.background().color().darker(110)));
|
painter->setPen(QPen(option->palette.background().color().darker(110)));
|
||||||
painter->drawLine(rect.topLeft().x() + margin,
|
painter->drawLine(rect.topLeft().x() + margin ,
|
||||||
rect.topLeft().y() + offset,
|
rect.topLeft().y() + offset,
|
||||||
rect.topRight().x() - margin,
|
rect.topRight().x() - margin,
|
||||||
rect.topRight().y() + offset);
|
rect.topRight().y() + offset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case PE_IndicatorToolBarHandle:
|
case PE_IndicatorToolBarHandle:
|
||||||
{
|
{
|
||||||
bool horizontal = option->state & State_Horizontal;
|
bool horizontal = option->state & State_Horizontal;
|
||||||
painter->save();
|
painter->save();
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
int x = option->rect.x() + horizontal ? 2 : 6;
|
int x = option->rect.x() + (horizontal ? 2 : 6);
|
||||||
int y = option->rect.y() + horizontal ? 6 : 2;
|
int y = option->rect.y() + (horizontal ? 6 : 2);
|
||||||
static const int RectHeight = 2;
|
static const int RectHeight = 2;
|
||||||
if (horizontal) {
|
if (horizontal) {
|
||||||
while (y < option->rect.height() - RectHeight - 6) {
|
while (y < option->rect.height() - RectHeight - 6) {
|
||||||
path.moveTo(x, y);
|
path.moveTo(x, y);
|
||||||
path.addRect(x, y, RectHeight, RectHeight);
|
path.addRect(x, y, RectHeight, RectHeight);
|
||||||
y += 6;
|
y += 6;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (x < option->rect.width() - RectHeight - 6) {
|
while (x < option->rect.width() - RectHeight - 6) {
|
||||||
path.moveTo(x, y);
|
path.moveTo(x, y);
|
||||||
path.addRect(x, y, RectHeight, RectHeight);
|
path.addRect(x, y, RectHeight, RectHeight);
|
||||||
x += 6;
|
x += 6;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
painter->setPen(Qt::NoPen);
|
||||||
|
QColor dark = Utils::StyleHelper::borderColor();
|
||||||
|
dark.setAlphaF(0.4);
|
||||||
|
|
||||||
|
QColor light = Utils::StyleHelper::baseColor();
|
||||||
|
light.setAlphaF(0.4);
|
||||||
|
|
||||||
|
painter->fillPath(path, light);
|
||||||
|
painter->save();
|
||||||
|
painter->translate(1, 1);
|
||||||
|
painter->fillPath(path, dark);
|
||||||
|
painter->restore();
|
||||||
|
painter->translate(3, 3);
|
||||||
|
painter->fillPath(path, light);
|
||||||
|
painter->translate(1, 1);
|
||||||
|
painter->fillPath(path, dark);
|
||||||
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
painter->setPen(Qt::NoPen);
|
|
||||||
QColor dark = Utils::StyleHelper::borderColor();
|
|
||||||
dark.setAlphaF(0.4);
|
|
||||||
|
|
||||||
QColor light = Utils::StyleHelper::baseColor();
|
|
||||||
light.setAlphaF(0.4);
|
|
||||||
|
|
||||||
painter->fillPath(path, light);
|
|
||||||
painter->save();
|
|
||||||
painter->translate(1, 1);
|
|
||||||
painter->fillPath(path, dark);
|
|
||||||
painter->restore();
|
|
||||||
painter->translate(3, 3);
|
|
||||||
painter->fillPath(path, light);
|
|
||||||
painter->translate(1, 1);
|
|
||||||
painter->fillPath(path, dark);
|
|
||||||
painter->restore();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PE_IndicatorArrowUp:
|
case PE_IndicatorArrowUp:
|
||||||
case PE_IndicatorArrowDown:
|
case PE_IndicatorArrowDown:
|
||||||
case PE_IndicatorArrowRight:
|
case PE_IndicatorArrowRight:
|
||||||
case PE_IndicatorArrowLeft:
|
case PE_IndicatorArrowLeft:
|
||||||
{
|
{
|
||||||
// From windowsstyle but modified to enable AA
|
Utils::StyleHelper::drawArrow(element, painter, option);
|
||||||
if (option->rect.width() <= 1 || option->rect.height() <= 1) {
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
QRect r = option->rect;
|
|
||||||
int size = qMin(r.height(), r.width());
|
|
||||||
QPixmap pixmap;
|
|
||||||
QString pixmapName;
|
|
||||||
QTextStream(&pixmapName) << "$qt_ia" << "-" << metaObject()->className() <<
|
|
||||||
"-" << uint(option->state) << "-" << element << "-" << size <<
|
|
||||||
"-" << option->palette.cacheKey();
|
|
||||||
// pixmapName.sprintf("%s-%s-%d-%d-%d-%lld",
|
|
||||||
// "$qt_ia", metaObject()->className(),
|
|
||||||
// uint(option->state), element,
|
|
||||||
// size, option->palette.cacheKey());
|
|
||||||
if (!QPixmapCache::find(pixmapName, pixmap)) {
|
|
||||||
int border = size / 5;
|
|
||||||
int sqsize = 2 * (size / 2);
|
|
||||||
QImage image(sqsize, sqsize, QImage::Format_ARGB32);
|
|
||||||
image.fill(Qt::transparent);
|
|
||||||
QPainter imagePainter(&image);
|
|
||||||
imagePainter.setRenderHint(QPainter::Antialiasing, true);
|
|
||||||
imagePainter.translate(0.5, 0.5);
|
|
||||||
QPolygon a;
|
|
||||||
switch (element) {
|
|
||||||
case PE_IndicatorArrowUp:
|
|
||||||
a.setPoints(3, border, sqsize / 2, sqsize / 2, border, sqsize - border, sqsize / 2);
|
|
||||||
break;
|
|
||||||
case PE_IndicatorArrowDown:
|
|
||||||
a.setPoints(3, border, sqsize / 2, sqsize / 2, sqsize - border, sqsize - border, sqsize / 2);
|
|
||||||
break;
|
|
||||||
case PE_IndicatorArrowRight:
|
|
||||||
a.setPoints(3, sqsize - border, sqsize / 2, sqsize / 2, border, sqsize / 2, sqsize - border);
|
|
||||||
break;
|
|
||||||
case PE_IndicatorArrowLeft:
|
|
||||||
a.setPoints(3, border, sqsize / 2, sqsize / 2, border, sqsize / 2, sqsize - border);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int bsx = 0;
|
|
||||||
int bsy = 0;
|
|
||||||
|
|
||||||
if (option->state & State_Sunken) {
|
|
||||||
bsx = pixelMetric(PM_ButtonShiftHorizontal);
|
|
||||||
bsy = pixelMetric(PM_ButtonShiftVertical);
|
|
||||||
}
|
|
||||||
|
|
||||||
QRect bounds = a.boundingRect();
|
|
||||||
int sx = sqsize / 2 - bounds.center().x() - 1;
|
|
||||||
int sy = sqsize / 2 - bounds.center().y() - 1;
|
|
||||||
imagePainter.translate(sx + bsx, sy + bsy);
|
|
||||||
|
|
||||||
if (!(option->state & State_Enabled)) {
|
|
||||||
QColor foreGround(150, 150, 150, 150);
|
|
||||||
imagePainter.setBrush(option->palette.mid().color());
|
|
||||||
imagePainter.setPen(option->palette.mid().color());
|
|
||||||
} else {
|
|
||||||
QColor shadow(0, 0, 0, 100);
|
|
||||||
imagePainter.translate(0, 1);
|
|
||||||
imagePainter.setPen(shadow);
|
|
||||||
imagePainter.setBrush(shadow);
|
|
||||||
QColor foreGround(255, 255, 255, 210);
|
|
||||||
imagePainter.drawPolygon(a);
|
|
||||||
imagePainter.translate(0, -1);
|
|
||||||
imagePainter.setPen(foreGround);
|
|
||||||
imagePainter.setBrush(foreGround);
|
|
||||||
}
|
|
||||||
imagePainter.drawPolygon(a);
|
|
||||||
imagePainter.end();
|
|
||||||
pixmap = QPixmap::fromImage(image);
|
|
||||||
QPixmapCache::insert(pixmapName, pixmap);
|
|
||||||
}
|
|
||||||
int xOffset = r.x() + (r.width() - size) / 2;
|
|
||||||
int yOffset = r.y() + (r.height() - size) / 2;
|
|
||||||
painter->drawPixmap(xOffset, yOffset, pixmap);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
d->style->drawPrimitive(element, option, painter, widget);
|
QProxyStyle::drawPrimitive(element, option, painter, widget);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -759,20 +600,43 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
|
|||||||
void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *option,
|
void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *option,
|
||||||
QPainter *painter, const QWidget *widget) const
|
QPainter *painter, const QWidget *widget) const
|
||||||
{
|
{
|
||||||
if (!panelWidget(widget)) {
|
if (!panelWidget(widget))
|
||||||
return d->style->drawControl(element, option, painter, widget);
|
return QProxyStyle::drawControl(element, option, painter, widget);
|
||||||
}
|
|
||||||
|
|
||||||
switch (element) {
|
switch (element) {
|
||||||
|
case CE_Splitter:
|
||||||
|
painter->fillRect(option->rect, Utils::StyleHelper::borderColor());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CE_TabBarTabShape:
|
||||||
|
// Most styles draw a single dark outline. This looks rather ugly when combined with our
|
||||||
|
// single pixel dark separator so we adjust the first tab to compensate for this
|
||||||
|
|
||||||
|
if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(option)) {
|
||||||
|
QStyleOptionTabV3 adjustedTab = *tab;
|
||||||
|
if (tab->cornerWidgets == QStyleOptionTab::NoCornerWidgets && (
|
||||||
|
tab->position == QStyleOptionTab::Beginning ||
|
||||||
|
tab->position == QStyleOptionTab::OnlyOneTab))
|
||||||
|
{
|
||||||
|
if (option->direction == Qt::LeftToRight)
|
||||||
|
adjustedTab.rect = adjustedTab.rect.adjusted(-1, 0, 0, 0);
|
||||||
|
else
|
||||||
|
adjustedTab.rect = adjustedTab.rect.adjusted(0, 0, 1 ,0);
|
||||||
|
}
|
||||||
|
QProxyStyle::drawControl(element, &adjustedTab, painter, widget);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case CE_MenuBarItem:
|
case CE_MenuBarItem:
|
||||||
painter->save();
|
painter->save();
|
||||||
if (const QStyleOptionMenuItem * mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
if (const QStyleOptionMenuItem *mbi = qstyleoption_cast<const QStyleOptionMenuItem *>(option)) {
|
||||||
QColor highlightOutline = Utils::StyleHelper::borderColor().lighter(120);
|
QColor highlightOutline = Utils::StyleHelper::borderColor().lighter(120);
|
||||||
bool act = mbi->state & State_Selected && mbi->state & State_Sunken;
|
bool act = mbi->state & State_Sunken;
|
||||||
bool dis = !(mbi->state & State_Enabled);
|
bool dis = !(mbi->state & State_Enabled);
|
||||||
Utils::StyleHelper::menuGradient(painter, option->rect, option->rect);
|
Utils::StyleHelper::menuGradient(painter, option->rect, option->rect);
|
||||||
QStyleOptionMenuItem item = *mbi;
|
QStyleOptionMenuItem item = *mbi;
|
||||||
item.rect = mbi->rect;
|
item.rect = mbi->rect;
|
||||||
QPalette pal = mbi->palette;
|
QPalette pal = mbi->palette;
|
||||||
pal.setBrush(QPalette::ButtonText, dis ? Qt::gray : Qt::black);
|
pal.setBrush(QPalette::ButtonText, dis ? Qt::gray : Qt::black);
|
||||||
item.palette = pal;
|
item.palette = pal;
|
||||||
@ -797,11 +661,10 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
|
|||||||
painter->drawPoint(r.topLeft());
|
painter->drawPoint(r.topLeft());
|
||||||
painter->drawPoint(r.topRight());
|
painter->drawPoint(r.topRight());
|
||||||
|
|
||||||
QPalette pal = mbi->palette;
|
QPalette pal = mbi->palette;
|
||||||
uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
|
uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
|
||||||
if (!styleHint(SH_UnderlineShortcut, mbi, widget)) {
|
if (!styleHint(SH_UnderlineShortcut, mbi, widget))
|
||||||
alignment |= Qt::TextHideMnemonic;
|
alignment |= Qt::TextHideMnemonic;
|
||||||
}
|
|
||||||
pal.setBrush(QPalette::Text, dis ? Qt::gray : QColor(0, 0, 0, 60));
|
pal.setBrush(QPalette::Text, dis ? Qt::gray : QColor(0, 0, 0, 60));
|
||||||
drawItemText(painter, item.rect.translated(0, 1), alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text);
|
drawItemText(painter, item.rect.translated(0, 1), alignment, pal, mbi->state & State_Enabled, mbi->text, QPalette::Text);
|
||||||
pal.setBrush(QPalette::Text, dis ? Qt::gray : Qt::white);
|
pal.setBrush(QPalette::Text, dis ? Qt::gray : Qt::white);
|
||||||
@ -812,156 +675,156 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CE_ComboBoxLabel:
|
case CE_ComboBoxLabel:
|
||||||
if (const QStyleOptionComboBox * cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
||||||
if (panelWidget(widget)) {
|
if (panelWidget(widget)) {
|
||||||
QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);
|
painter->save();
|
||||||
|
QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);
|
||||||
QPalette customPal = cb->palette;
|
QPalette customPal = cb->palette;
|
||||||
|
bool drawIcon = !(widget && widget->property("hideicon").toBool());
|
||||||
|
|
||||||
if (!cb->currentIcon.isNull()) {
|
if (!cb->currentIcon.isNull() && drawIcon) {
|
||||||
QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal
|
QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal
|
||||||
: QIcon::Disabled;
|
: QIcon::Disabled;
|
||||||
QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
|
QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
|
||||||
QRect iconRect(editRect);
|
QRect iconRect(editRect);
|
||||||
iconRect.setWidth(cb->iconSize.width() + 4);
|
iconRect.setWidth(cb->iconSize.width() + 4);
|
||||||
iconRect = alignedRect(cb->direction,
|
iconRect = alignedRect(cb->direction,
|
||||||
Qt::AlignLeft | Qt::AlignVCenter,
|
Qt::AlignLeft | Qt::AlignVCenter,
|
||||||
iconRect.size(), editRect);
|
iconRect.size(), editRect);
|
||||||
if (cb->editable) {
|
if (cb->editable)
|
||||||
painter->fillRect(iconRect, customPal.brush(QPalette::Base));
|
painter->fillRect(iconRect, customPal.brush(QPalette::Base));
|
||||||
}
|
|
||||||
drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);
|
drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);
|
||||||
|
|
||||||
if (cb->direction == Qt::RightToLeft) {
|
if (cb->direction == Qt::RightToLeft)
|
||||||
editRect.translate(-4 - cb->iconSize.width(), 0);
|
editRect.translate(-4 - cb->iconSize.width(), 0);
|
||||||
} else {
|
else
|
||||||
editRect.translate(cb->iconSize.width() + 4, 0);
|
editRect.translate(cb->iconSize.width() + 4, 0);
|
||||||
}
|
|
||||||
|
|
||||||
// Reserve some space for the down-arrow
|
// Reserve some space for the down-arrow
|
||||||
editRect.adjust(0, 0, -13, 0);
|
editRect.adjust(0, 0, -13, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
customPal.setBrush(QPalette::All, QPalette::ButtonText, QColor(0, 0, 0, 70));
|
QLatin1Char asterisk('*');
|
||||||
|
int elideWidth = editRect.width();
|
||||||
|
|
||||||
QString text = option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, editRect.width());
|
bool notElideAsterisk = widget && widget->property("notelideasterisk").toBool()
|
||||||
drawItemText(painter, editRect.translated(0, 1),
|
&& cb->currentText.endsWith(asterisk)
|
||||||
visualAlignment(option->direction, Qt::AlignLeft | Qt::AlignVCenter),
|
&& option->fontMetrics.width(cb->currentText) > elideWidth;
|
||||||
customPal, cb->state & State_Enabled, text, QPalette::ButtonText);
|
|
||||||
customPal.setBrush(QPalette::All, QPalette::ButtonText, Utils::StyleHelper::panelTextColor());
|
QString text;
|
||||||
drawItemText(painter, editRect,
|
if (notElideAsterisk) {
|
||||||
visualAlignment(option->direction, Qt::AlignLeft | Qt::AlignVCenter),
|
elideWidth -= option->fontMetrics.width(asterisk);
|
||||||
customPal, cb->state & State_Enabled, text, QPalette::ButtonText);
|
text = asterisk;
|
||||||
|
}
|
||||||
|
text.prepend(option->fontMetrics.elidedText(cb->currentText, Qt::ElideRight, elideWidth));
|
||||||
|
|
||||||
|
if ((option->state & State_Enabled)) {
|
||||||
|
painter->setPen(QColor(0, 0, 0, 70));
|
||||||
|
painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text);
|
||||||
|
} else {
|
||||||
|
painter->setOpacity(0.8);
|
||||||
|
}
|
||||||
|
painter->setPen(Utils::StyleHelper::panelTextColor());
|
||||||
|
painter->drawText(editRect.adjusted(1, 0, -1, 0), Qt::AlignLeft | Qt::AlignVCenter, text);
|
||||||
|
|
||||||
|
painter->restore();
|
||||||
} else {
|
} else {
|
||||||
d->style->drawControl(element, option, painter, widget);
|
QProxyStyle::drawControl(element, option, painter, widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CE_SizeGrip:
|
case CE_SizeGrip: {
|
||||||
{
|
painter->save();
|
||||||
painter->save();
|
QColor dark = Qt::white;
|
||||||
QColor dark = Qt::white;
|
dark.setAlphaF(0.1);
|
||||||
dark.setAlphaF(0.1);
|
int x, y, w, h;
|
||||||
int x, y, w, h;
|
option->rect.getRect(&x, &y, &w, &h);
|
||||||
option->rect.getRect(&x, &y, &w, &h);
|
int sw = qMin(h, w);
|
||||||
int sw = qMin(h, w);
|
if (h > w)
|
||||||
if (h > w) {
|
painter->translate(0, h - w);
|
||||||
painter->translate(0, h - w);
|
else
|
||||||
} else {
|
painter->translate(w - h, 0);
|
||||||
painter->translate(w - h, 0);
|
int sx = x;
|
||||||
}
|
int sy = y;
|
||||||
int sx = x;
|
int s = 4;
|
||||||
int sy = y;
|
painter->setPen(dark);
|
||||||
int s = 4;
|
if (option->direction == Qt::RightToLeft) {
|
||||||
painter->setPen(dark);
|
sx = x + sw;
|
||||||
if (option->direction == Qt::RightToLeft) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
sx = x + sw;
|
painter->drawLine(x, sy, sx, sw);
|
||||||
for (int i = 0; i < 4; ++i) {
|
sx -= s;
|
||||||
painter->drawLine(x, sy, sx, sw);
|
sy += s;
|
||||||
sx -= s;
|
}
|
||||||
sy += s;
|
} else {
|
||||||
}
|
for (int i = 0; i < 4; ++i) {
|
||||||
} else {
|
painter->drawLine(sx, sw, sw, sy);
|
||||||
for (int i = 0; i < 4; ++i) {
|
sx += s;
|
||||||
painter->drawLine(sx, sw, sw, sy);
|
sy += s;
|
||||||
sx += s;
|
}
|
||||||
sy += s;
|
|
||||||
}
|
}
|
||||||
|
painter->restore();
|
||||||
}
|
}
|
||||||
painter->restore();
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CE_MenuBarEmptyArea:
|
case CE_MenuBarEmptyArea: {
|
||||||
{
|
Utils::StyleHelper::menuGradient(painter, option->rect, option->rect);
|
||||||
Utils::StyleHelper::menuGradient(painter, option->rect, option->rect);
|
painter->save();
|
||||||
painter->save();
|
painter->setPen(Utils::StyleHelper::borderColor());
|
||||||
painter->setPen(Utils::StyleHelper::borderColor());
|
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
|
||||||
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
|
painter->restore();
|
||||||
painter->restore();
|
}
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case CE_ToolBar:
|
case CE_ToolBar:
|
||||||
{
|
{
|
||||||
QString key;
|
QRect rect = option->rect;
|
||||||
key.sprintf("mh_toolbar %d %d %d", option->rect.width(), option->rect.height(), Utils::StyleHelper::baseColor().rgb());;
|
bool horizontal = option->state & State_Horizontal;
|
||||||
|
rect = option->rect;
|
||||||
|
|
||||||
QPixmap pixmap;
|
// Map offset for global window gradient
|
||||||
QPainter *p = painter;
|
QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) -
|
||||||
QRect rect = option->rect;
|
widget->mapToGlobal(option->rect.topLeft());
|
||||||
if (Utils::StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
|
QRect gradientSpan;
|
||||||
pixmap = QPixmap(option->rect.size());
|
if (widget)
|
||||||
p = new QPainter(&pixmap);
|
gradientSpan = QRect(offset, widget->window()->size());
|
||||||
rect = QRect(0, 0, option->rect.width(), option->rect.height());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool horizontal = option->state & State_Horizontal;
|
bool drawLightColored = lightColored(widget);
|
||||||
// Map offset for global window gradient
|
if (horizontal)
|
||||||
QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) -
|
Utils::StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored);
|
||||||
widget->mapToGlobal(option->rect.topLeft());
|
else
|
||||||
QRect gradientSpan;
|
Utils::StyleHelper::verticalGradient(painter, gradientSpan, rect, drawLightColored);
|
||||||
if (widget) {
|
|
||||||
gradientSpan = QRect(offset, widget->window()->size());
|
|
||||||
}
|
|
||||||
if (horizontal) {
|
|
||||||
Utils::StyleHelper::horizontalGradient(p, gradientSpan, rect);
|
|
||||||
} else {
|
|
||||||
Utils::StyleHelper::verticalGradient(p, gradientSpan, rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
painter->setPen(Utils::StyleHelper::borderColor());
|
if (!drawLightColored)
|
||||||
|
painter->setPen(Utils::StyleHelper::borderColor());
|
||||||
|
else
|
||||||
|
painter->setPen(QColor(0x888888));
|
||||||
|
|
||||||
if (horizontal) {
|
if (horizontal) {
|
||||||
// Note: This is a hack to determine if the
|
// Note: This is a hack to determine if the
|
||||||
// toolbar should draw the top or bottom outline
|
// toolbar should draw the top or bottom outline
|
||||||
// (needed for the find toolbar for instance)
|
// (needed for the find toolbar for instance)
|
||||||
QColor lighter(255, 255, 255, 40);
|
QColor lighter(Utils::StyleHelper::sidebarHighlight());
|
||||||
if (widget && widget->property("topBorder").toBool()) {
|
if (drawLightColored)
|
||||||
p->drawLine(rect.topLeft(), rect.topRight());
|
lighter = QColor(255, 255, 255, 180);
|
||||||
p->setPen(lighter);
|
if (widget && widget->property("topBorder").toBool()) {
|
||||||
p->drawLine(rect.topLeft() + QPoint(0, 1), rect.topRight() + QPoint(0, 1));
|
painter->drawLine(rect.topLeft(), rect.topRight());
|
||||||
|
painter->setPen(lighter);
|
||||||
|
painter->drawLine(rect.topLeft() + QPoint(0, 1), rect.topRight() + QPoint(0, 1));
|
||||||
|
} else {
|
||||||
|
painter->drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||||
|
painter->setPen(lighter);
|
||||||
|
painter->drawLine(rect.topLeft(), rect.topRight());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
p->drawLine(rect.bottomLeft(), rect.bottomRight());
|
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||||
p->setPen(lighter);
|
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||||
p->drawLine(rect.topLeft(), rect.topRight());
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
p->drawLine(rect.topLeft(), rect.bottomLeft());
|
|
||||||
p->drawLine(rect.topRight(), rect.bottomRight());
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
if (Utils::StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
|
|
||||||
painter->drawPixmap(rect.topLeft(), pixmap);
|
|
||||||
p->end();
|
|
||||||
delete p;
|
|
||||||
QPixmapCache::insert(key, pixmap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
d->style->drawControl(element, option, painter, widget);
|
QProxyStyle::drawControl(element, option, painter, widget);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -969,146 +832,122 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
|
|||||||
void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
|
void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
|
||||||
QPainter *painter, const QWidget *widget) const
|
QPainter *painter, const QWidget *widget) const
|
||||||
{
|
{
|
||||||
if (!panelWidget(widget)) {
|
if (!panelWidget(widget))
|
||||||
return d->style->drawComplexControl(control, option, painter, widget);
|
return QProxyStyle::drawComplexControl(control, option, painter, widget);
|
||||||
}
|
|
||||||
|
|
||||||
QRect rect = option->rect;
|
QRect rect = option->rect;
|
||||||
switch (control) {
|
switch (control) {
|
||||||
case CC_ToolButton:
|
case CC_ToolButton:
|
||||||
if (const QStyleOptionToolButton * toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
|
if (const QStyleOptionToolButton *toolbutton = qstyleoption_cast<const QStyleOptionToolButton *>(option)) {
|
||||||
|
bool reverse = option->direction == Qt::RightToLeft;
|
||||||
|
bool drawborder = (widget && widget->property("showborder").toBool());
|
||||||
|
|
||||||
|
if (drawborder)
|
||||||
|
drawButtonSeparator(painter, rect, reverse);
|
||||||
|
|
||||||
QRect button, menuarea;
|
QRect button, menuarea;
|
||||||
button = subControlRect(control, toolbutton, SC_ToolButton, widget);
|
button = subControlRect(control, toolbutton, SC_ToolButton, widget);
|
||||||
menuarea = subControlRect(control, toolbutton, SC_ToolButtonMenu, widget);
|
menuarea = subControlRect(control, toolbutton, SC_ToolButtonMenu, widget);
|
||||||
|
|
||||||
State bflags = toolbutton->state;
|
State bflags = toolbutton->state;
|
||||||
if (bflags & State_AutoRaise) {
|
if (bflags & State_AutoRaise) {
|
||||||
if (!(bflags & State_MouseOver)) {
|
if (!(bflags & State_MouseOver))
|
||||||
bflags &= ~State_Raised;
|
bflags &= ~State_Raised;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
State mflags = bflags;
|
State mflags = bflags;
|
||||||
if (toolbutton->state & State_Sunken) {
|
if (toolbutton->state & State_Sunken) {
|
||||||
if (toolbutton->activeSubControls & SC_ToolButton) {
|
if (toolbutton->activeSubControls & SC_ToolButton)
|
||||||
bflags |= State_Sunken;
|
bflags |= State_Sunken;
|
||||||
}
|
if (toolbutton->activeSubControls & SC_ToolButtonMenu)
|
||||||
if (toolbutton->activeSubControls & SC_ToolButtonMenu) {
|
|
||||||
mflags |= State_Sunken;
|
mflags |= State_Sunken;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStyleOption tool(0);
|
QStyleOption tool(0);
|
||||||
tool.palette = toolbutton->palette;
|
tool.palette = toolbutton->palette;
|
||||||
if (toolbutton->subControls & SC_ToolButton) {
|
if (toolbutton->subControls & SC_ToolButton) {
|
||||||
tool.rect = button;
|
tool.rect = button;
|
||||||
tool.state = bflags;
|
tool.state = bflags;
|
||||||
drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
|
drawPrimitive(PE_PanelButtonTool, &tool, painter, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolbutton->state & State_HasFocus) {
|
|
||||||
QStyleOptionFocusRect fr;
|
|
||||||
fr.QStyleOption::operator=(*toolbutton);
|
|
||||||
fr.rect.adjust(3, 3, -3, -3);
|
|
||||||
if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup) {
|
|
||||||
fr.rect.adjust(0, 0, -pixelMetric(QStyle::PM_MenuButtonIndicator,
|
|
||||||
toolbutton, widget), 0);
|
|
||||||
}
|
|
||||||
QPen oldPen = painter->pen();
|
|
||||||
QColor focusColor = Utils::StyleHelper::panelTextColor();
|
|
||||||
focusColor.setAlpha(120);
|
|
||||||
QPen outline(focusColor, 1);
|
|
||||||
outline.setStyle(Qt::DotLine);
|
|
||||||
painter->setPen(outline);
|
|
||||||
QRect r = option->rect.adjusted(2, 2, -2, -2);
|
|
||||||
painter->drawRect(r);
|
|
||||||
painter->setPen(oldPen);
|
|
||||||
}
|
|
||||||
|
|
||||||
QStyleOptionToolButton label = *toolbutton;
|
QStyleOptionToolButton label = *toolbutton;
|
||||||
label.palette = panelPalette(option->palette);
|
|
||||||
|
label.palette = panelPalette(option->palette, lightColored(widget));
|
||||||
int fw = pixelMetric(PM_DefaultFrameWidth, option, widget);
|
int fw = pixelMetric(PM_DefaultFrameWidth, option, widget);
|
||||||
label.rect = button.adjusted(fw, fw, -fw, -fw);
|
label.rect = button.adjusted(fw, fw, -fw, -fw);
|
||||||
|
|
||||||
drawControl(CE_ToolButtonLabel, &label, painter, widget);
|
drawControl(CE_ToolButtonLabel, &label, painter, widget);
|
||||||
|
|
||||||
if (toolbutton->subControls & SC_ToolButtonMenu) {
|
if (toolbutton->subControls & SC_ToolButtonMenu) {
|
||||||
tool.state = mflags;
|
tool.state = mflags;
|
||||||
tool.rect = menuarea.adjusted(1, 1, -1, -1);
|
tool.rect = menuarea.adjusted(1, 1, -1, -1);
|
||||||
if (mflags & (State_Sunken | State_On | State_Raised)) {
|
if (mflags & (State_Sunken | State_On | State_Raised)) {
|
||||||
painter->setPen(Qt::gray);
|
painter->setPen(Qt::gray);
|
||||||
painter->drawLine(tool.rect.topLeft(), tool.rect.bottomLeft());
|
painter->drawLine(tool.rect.topLeft(), tool.rect.bottomLeft());
|
||||||
if (mflags & (State_Sunken)) {
|
if (mflags & (State_Sunken)) {
|
||||||
QColor shade(0, 0, 0, 50);
|
QColor shade(0, 0, 0, 50);
|
||||||
painter->fillRect(tool.rect.adjusted(0, -1, 1, 1), shade);
|
painter->fillRect(tool.rect.adjusted(0, -1, 1, 1), shade);
|
||||||
}
|
} else if (!Utils::HostOsInfo::isMacHost() && (mflags & State_MouseOver)) {
|
||||||
#ifndef Q_WS_MAC
|
|
||||||
else if (mflags & (State_MouseOver)) {
|
|
||||||
QColor shade(255, 255, 255, 50);
|
QColor shade(255, 255, 255, 50);
|
||||||
painter->fillRect(tool.rect.adjusted(0, -1, 1, 1), shade);
|
painter->fillRect(tool.rect.adjusted(0, -1, 1, 1), shade);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
tool.rect = tool.rect.adjusted(2, 2, -2, -2);
|
tool.rect = tool.rect.adjusted(2, 2, -2, -2);
|
||||||
drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget);
|
drawPrimitive(PE_IndicatorArrowDown, &tool, painter, widget);
|
||||||
} else if (toolbutton->features & QStyleOptionToolButton::HasMenu) {
|
} else if (toolbutton->features & QStyleOptionToolButton::HasMenu
|
||||||
|
&& !widget->property("noArrow").toBool()) {
|
||||||
int arrowSize = 6;
|
int arrowSize = 6;
|
||||||
QRect ir = toolbutton->rect.adjusted(1, 1, -1, -1);
|
QRect ir = toolbutton->rect.adjusted(1, 1, -1, -1);
|
||||||
QStyleOptionToolButton newBtn = *toolbutton;
|
QStyleOptionToolButton newBtn = *toolbutton;
|
||||||
newBtn.palette = panelPalette(option->palette);
|
newBtn.palette = panelPalette(option->palette);
|
||||||
newBtn.rect = QRect(ir.right() - arrowSize - 1,
|
newBtn.rect = QRect(ir.right() - arrowSize - 1,
|
||||||
ir.height() - arrowSize - 2, arrowSize, arrowSize);
|
ir.height() - arrowSize - 2, arrowSize, arrowSize);
|
||||||
drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
|
drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CC_ComboBox:
|
case CC_ComboBox:
|
||||||
if (const QStyleOptionComboBox * cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
||||||
painter->save();
|
painter->save();
|
||||||
bool isEmpty = cb->currentText.isEmpty() && cb->currentIcon.isNull();
|
bool isEmpty = cb->currentText.isEmpty() && cb->currentIcon.isNull();
|
||||||
bool reverse = option->direction == Qt::RightToLeft;
|
bool reverse = option->direction == Qt::RightToLeft;
|
||||||
|
bool drawborder = !(widget && widget->property("hideborder").toBool());
|
||||||
|
bool alignarrow = !(widget && widget->property("alignarrow").toBool());
|
||||||
|
|
||||||
|
if (drawborder)
|
||||||
|
drawButtonSeparator(painter, rect, reverse);
|
||||||
|
|
||||||
// Draw tool button
|
|
||||||
QLinearGradient grad(option->rect.topRight(), option->rect.bottomRight());
|
|
||||||
grad.setColorAt(0, QColor(255, 255, 255, 20));
|
|
||||||
grad.setColorAt(0.4, QColor(255, 255, 255, 60));
|
|
||||||
grad.setColorAt(0.7, QColor(255, 255, 255, 50));
|
|
||||||
grad.setColorAt(1, QColor(255, 255, 255, 40));
|
|
||||||
painter->setPen(QPen(grad, 0));
|
|
||||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
|
||||||
grad.setColorAt(0, QColor(0, 0, 0, 30));
|
|
||||||
grad.setColorAt(0.4, QColor(0, 0, 0, 70));
|
|
||||||
grad.setColorAt(0.7, QColor(0, 0, 0, 70));
|
|
||||||
grad.setColorAt(1, QColor(0, 0, 0, 40));
|
|
||||||
painter->setPen(QPen(grad, 0));
|
|
||||||
if (!reverse) {
|
|
||||||
painter->drawLine(rect.topRight() - QPoint(1, 0), rect.bottomRight() - QPoint(1, 0));
|
|
||||||
} else {
|
|
||||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
|
||||||
}
|
|
||||||
QStyleOption toolbutton = *option;
|
QStyleOption toolbutton = *option;
|
||||||
if (isEmpty) {
|
if (isEmpty)
|
||||||
toolbutton.state &= ~(State_Enabled | State_Sunken);
|
toolbutton.state &= ~(State_Enabled | State_Sunken);
|
||||||
}
|
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setClipRect(toolbutton.rect.adjusted(0, 0, -2, 0));
|
if (drawborder)
|
||||||
|
painter->setClipRect(toolbutton.rect.adjusted(0, 0, -2, 0));
|
||||||
drawPrimitive(PE_PanelButtonTool, &toolbutton, painter, widget);
|
drawPrimitive(PE_PanelButtonTool, &toolbutton, painter, widget);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
// Draw arrow
|
// Draw arrow
|
||||||
int menuButtonWidth = 12;
|
int menuButtonWidth = 12;
|
||||||
int left = !reverse ? rect.right() - menuButtonWidth : rect.left();
|
int left = !reverse ? rect.right() - menuButtonWidth : rect.left();
|
||||||
int right = !reverse ? rect.right() : rect.left() + menuButtonWidth;
|
int right = !reverse ? rect.right() : rect.left() + menuButtonWidth;
|
||||||
QRect arrowRect((left + right) / 2 + (reverse ? 6 : -6), rect.center().y() - 3, 9, 9);
|
QRect arrowRect((left + right) / 2 + (reverse ? 6 : -6), rect.center().y() - 3, 9, 9);
|
||||||
if (option->state & State_On) {
|
|
||||||
arrowRect.translate(d->style->pixelMetric(PM_ButtonShiftHorizontal, option, widget),
|
if (!alignarrow) {
|
||||||
d->style->pixelMetric(PM_ButtonShiftVertical, option, widget));
|
int labelwidth = option->fontMetrics.width(cb->currentText);
|
||||||
|
if (reverse)
|
||||||
|
arrowRect.moveLeft(qMax(rect.width() - labelwidth - menuButtonWidth - 2, 4));
|
||||||
|
else
|
||||||
|
arrowRect.moveLeft(qMin(labelwidth + menuButtonWidth - 2, rect.width() - menuButtonWidth - 4));
|
||||||
}
|
}
|
||||||
|
if (option->state & State_On)
|
||||||
|
arrowRect.translate(QProxyStyle::pixelMetric(PM_ButtonShiftHorizontal, option, widget),
|
||||||
|
QProxyStyle::pixelMetric(PM_ButtonShiftVertical, option, widget));
|
||||||
|
|
||||||
QStyleOption arrowOpt = *option;
|
QStyleOption arrowOpt = *option;
|
||||||
arrowOpt.rect = arrowRect;
|
arrowOpt.rect = arrowRect;
|
||||||
if (isEmpty) {
|
if (isEmpty)
|
||||||
arrowOpt.state &= ~(State_Enabled | State_Sunken);
|
arrowOpt.state &= ~(State_Enabled | State_Sunken);
|
||||||
}
|
|
||||||
|
|
||||||
if (styleHint(SH_ComboBox_Popup, option, widget)) {
|
if (styleHint(SH_ComboBox_Popup, option, widget)) {
|
||||||
arrowOpt.rect.translate(0, -3);
|
arrowOpt.rect.translate(0, -3);
|
||||||
@ -1118,19 +957,33 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
|||||||
} else {
|
} else {
|
||||||
drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
|
drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
d->style->drawComplexControl(control, option, painter, widget);
|
QProxyStyle::drawComplexControl(control, option, painter, widget);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mac style reimplements this to control the
|
void ManhattanStyle::drawButtonSeparator(QPainter *painter, const QRect &rect, bool reverse) const
|
||||||
// focus widget among other things
|
|
||||||
bool ManhattanStyle::event(QEvent *e)
|
|
||||||
{
|
{
|
||||||
Q_ASSERT(d->style);
|
QLinearGradient grad(rect.topRight(), rect.bottomRight());
|
||||||
return d->style->event(e);
|
grad.setColorAt(0, QColor(255, 255, 255, 20));
|
||||||
}
|
grad.setColorAt(0.4, QColor(255, 255, 255, 60));
|
||||||
|
grad.setColorAt(0.7, QColor(255, 255, 255, 50));
|
||||||
|
grad.setColorAt(1, QColor(255, 255, 255, 40));
|
||||||
|
painter->setPen(QPen(grad, 0));
|
||||||
|
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||||
|
grad.setColorAt(0, QColor(0, 0, 0, 30));
|
||||||
|
grad.setColorAt(0.4, QColor(0, 0, 0, 70));
|
||||||
|
grad.setColorAt(0.7, QColor(0, 0, 0, 70));
|
||||||
|
grad.setColorAt(1, QColor(0, 0, 0, 40));
|
||||||
|
painter->setPen(QPen(grad, 0));
|
||||||
|
if (!reverse)
|
||||||
|
painter->drawLine(rect.topRight() - QPoint(1,0), rect.bottomRight() - QPoint(1,0));
|
||||||
|
else
|
||||||
|
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||||
|
}
|
||||||
|
@ -31,25 +31,19 @@
|
|||||||
|
|
||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
|
|
||||||
#include <QtGui/QWindowsStyle>
|
#include <QProxyStyle>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QLinearGradient;
|
|
||||||
class QBrush;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
class ManhattanStylePrivate;
|
class ManhattanStylePrivate;
|
||||||
|
|
||||||
class CORE_EXPORT ManhattanStyle : public QWindowsStyle {
|
class CORE_EXPORT ManhattanStyle : public QProxyStyle
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ManhattanStyle(const QString &);
|
explicit ManhattanStyle(const QString &baseStyleName);
|
||||||
|
|
||||||
~ManhattanStyle();
|
~ManhattanStyle();
|
||||||
|
|
||||||
QStyle *systemStyle() const;
|
|
||||||
|
|
||||||
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
|
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
|
||||||
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
|
void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget = 0) const;
|
||||||
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const;
|
void drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const;
|
||||||
@ -75,20 +69,13 @@ public:
|
|||||||
void unpolish(QWidget *widget);
|
void unpolish(QWidget *widget);
|
||||||
void unpolish(QApplication *app);
|
void unpolish(QApplication *app);
|
||||||
|
|
||||||
protected:
|
protected slots:
|
||||||
bool event(QEvent *e);
|
|
||||||
|
|
||||||
protected Q_SLOTS:
|
|
||||||
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const;
|
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const;
|
||||||
int layoutSpacingImplementation(QSizePolicy::ControlType control1,
|
|
||||||
QSizePolicy::ControlType control2,
|
|
||||||
Qt::Orientation orientation,
|
|
||||||
const QStyleOption *option = 0,
|
|
||||||
const QWidget *widget = 0) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void drawButtonSeparator(QPainter *painter, const QRect &rect, bool reverse) const;
|
||||||
|
|
||||||
ManhattanStylePrivate *d;
|
ManhattanStylePrivate *d;
|
||||||
Q_DISABLE_COPY(ManhattanStyle)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MANHATTANSTYLE_H
|
#endif // MANHATTANSTYLE_H
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <QtGui/QStatusBar>
|
#include <QStatusBar>
|
||||||
#include <QtGui/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include "messageoutputwindow.h"
|
#include "messageoutputwindow.h"
|
||||||
|
|
||||||
#include <QtGui/QTextEdit>
|
#include <QTextEdit>
|
||||||
|
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
#include <QtCore/QTextStream>
|
#include <QtCore/QTextStream>
|
||||||
|
|
||||||
#include <QtXml/QXmlStreamReader>
|
#include <QtCore/QXmlStreamReader>
|
||||||
|
|
||||||
enum { debugMimeDB = 0 };
|
enum { debugMimeDB = 0 };
|
||||||
|
|
||||||
@ -768,7 +768,7 @@ bool BaseMimeTypeParser::parse(QIODevice *dev, const QString &fileName, QString
|
|||||||
{
|
{
|
||||||
// comments have locale attributes. We want the default, English one
|
// comments have locale attributes. We want the default, English one
|
||||||
QString locale = reader.attributes().value(QLatin1String(localeAttributeC)).toString();
|
QString locale = reader.attributes().value(QLatin1String(localeAttributeC)).toString();
|
||||||
const QString comment = QCoreApplication::translate("MimeType", reader.readElementText().toAscii());
|
const QString comment = QCoreApplication::translate("MimeType", reader.readElementText().toLatin1());
|
||||||
if (locale.isEmpty()) {
|
if (locale.isEmpty()) {
|
||||||
data.comment = comment;
|
data.comment = comment;
|
||||||
} else {
|
} else {
|
||||||
|
@ -30,9 +30,9 @@
|
|||||||
|
|
||||||
#include <utils/stylehelper.h>
|
#include <utils/stylehelper.h>
|
||||||
|
|
||||||
#include <QtGui/QPaintEvent>
|
#include <QPaintEvent>
|
||||||
#include <QtGui/QPainter>
|
#include <QPainter>
|
||||||
#include <QtGui/QSplitterHandle>
|
#include <QSplitterHandle>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
|
|
||||||
#include <QtGui/QSplitter>
|
#include <QSplitter>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QSplitterHandle;
|
class QSplitterHandle;
|
||||||
|
@ -49,11 +49,11 @@
|
|||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QSignalMapper>
|
#include <QtCore/QSignalMapper>
|
||||||
#include <QtGui/QShortcut>
|
#include <QShortcut>
|
||||||
|
|
||||||
#include <QtGui/QAction>
|
#include <QAction>
|
||||||
#include <QtGui/QTabWidget>
|
#include <QTabWidget>
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
|
|
||||||
#include <QtCore/QMap>
|
#include <QtCore/QMap>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QAction;
|
class QAction;
|
||||||
|
@ -34,11 +34,11 @@
|
|||||||
#include <extensionsystem/pluginerrorview.h>
|
#include <extensionsystem/pluginerrorview.h>
|
||||||
#include <extensionsystem/pluginspec.h>
|
#include <extensionsystem/pluginspec.h>
|
||||||
|
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QtGui/QDialog>
|
#include <QDialog>
|
||||||
#include <QtGui/QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QtGui/QPushButton>
|
#include <QPushButton>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#ifndef PLUGINDIALOG_H
|
#ifndef PLUGINDIALOG_H
|
||||||
#define PLUGINDIALOG_H
|
#define PLUGINDIALOG_H
|
||||||
|
|
||||||
#include <QtGui/QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
@ -33,10 +33,10 @@
|
|||||||
|
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
|
|
||||||
#include <QtGui/QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QtGui/QSplitter>
|
#include <QSplitter>
|
||||||
#include <QtGui/QResizeEvent>
|
#include <QResizeEvent>
|
||||||
#include <QtGui/QTextEdit>
|
#include <QTextEdit>
|
||||||
|
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
|
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QSettings;
|
class QSettings;
|
||||||
|
@ -35,10 +35,10 @@
|
|||||||
#include <QtCore/QDebug>
|
#include <QtCore/QDebug>
|
||||||
#include <QtCore/QEvent>
|
#include <QtCore/QEvent>
|
||||||
#include <QtCore/QSettings>
|
#include <QtCore/QSettings>
|
||||||
#include <QtGui/QLayout>
|
#include <QLayout>
|
||||||
#include <QtGui/QToolBar>
|
#include <QToolBar>
|
||||||
#include <QtGui/QAction>
|
#include <QAction>
|
||||||
#include <QtGui/QToolButton>
|
#include <QToolButton>
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
|
|
||||||
#include <QtCore/QMap>
|
#include <QtCore/QMap>
|
||||||
#include <QtCore/QPointer>
|
#include <QtCore/QPointer>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
#include <QtGui/QComboBox>
|
#include <QComboBox>
|
||||||
|
|
||||||
#include <coreplugin/minisplitter.h>
|
#include <coreplugin/minisplitter.h>
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include "styleanimator.h"
|
#include "styleanimator.h"
|
||||||
|
|
||||||
#include <QtGui/QStyleOption>
|
#include <QStyleOption>
|
||||||
|
|
||||||
Animation *StyleAnimator::widgetAnimation(const QWidget *widget) const
|
Animation *StyleAnimator::widgetAnimation(const QWidget *widget) const
|
||||||
{
|
{
|
||||||
|
@ -32,9 +32,9 @@
|
|||||||
#include <QtCore/QPointer>
|
#include <QtCore/QPointer>
|
||||||
#include <QtCore/QTime>
|
#include <QtCore/QTime>
|
||||||
#include <QtCore/QBasicTimer>
|
#include <QtCore/QBasicTimer>
|
||||||
#include <QtGui/QStyle>
|
#include <QStyle>
|
||||||
#include <QtGui/QPainter>
|
#include <QPainter>
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is a set of helper classes to allow for widget animations in
|
* This is a set of helper classes to allow for widget animations in
|
||||||
|
@ -28,10 +28,10 @@
|
|||||||
|
|
||||||
#include "tabpositionindicator.h"
|
#include "tabpositionindicator.h"
|
||||||
|
|
||||||
#include <QtGui/QPainter>
|
#include <QPainter>
|
||||||
#include <QtGui/QPaintEvent>
|
#include <QPaintEvent>
|
||||||
#include <QtGui/QBrush>
|
#include <QBrush>
|
||||||
#include <QtGui/QPalette>
|
#include <QPalette>
|
||||||
|
|
||||||
using namespace Core::Internal;
|
using namespace Core::Internal;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#ifndef TABPOSITIONINDICATOR_H
|
#ifndef TABPOSITIONINDICATOR_H
|
||||||
#define TABPOSITIONINDICATOR_H
|
#define TABPOSITIONINDICATOR_H
|
||||||
|
|
||||||
#include <QtGui/QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user