mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-18 08: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
|
||||
TARGET = AntennaTrack
|
||||
QT += serialport
|
||||
include(../../openpilotgcsplugin.pri)
|
||||
include(../../plugins/coreplugin/coreplugin.pri)
|
||||
include(antennatrack_dependencies.pri)
|
||||
|
@ -28,11 +28,12 @@
|
||||
#include "antennatrackgadget.h"
|
||||
#include "antennatrackwidget.h"
|
||||
#include "antennatrackgadgetconfiguration.h"
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
|
||||
AntennaTrackGadget::AntennaTrackGadget(QString classId, AntennaTrackWidget *widget, QWidget *parent) :
|
||||
IUAVGadget(classId, parent),
|
||||
m_widget(widget),
|
||||
connected(FALSE)
|
||||
connected(false)
|
||||
{
|
||||
connect(m_widget->connectButton, SIGNAL(clicked(bool)), this, SLOT(onConnect()));
|
||||
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);
|
||||
|
||||
PortSettings portsettings;
|
||||
portsettings.BaudRate = AntennaTrackConfig->speed();
|
||||
portsettings.DataBits = AntennaTrackConfig->dataBits();
|
||||
portsettings.FlowControl = AntennaTrackConfig->flow();
|
||||
portsettings.Parity = AntennaTrackConfig->parity();
|
||||
portsettings.StopBits = AntennaTrackConfig->stopBits();
|
||||
portsettings.Timeout_Millisec = AntennaTrackConfig->timeOut();
|
||||
m_portsettings.BaudRate = AntennaTrackConfig->speed();
|
||||
m_portsettings.DataBits = AntennaTrackConfig->dataBits();
|
||||
m_portsettings.FlowControl = AntennaTrackConfig->flow();
|
||||
m_portsettings.Parity = AntennaTrackConfig->parity();
|
||||
m_portsettings.StopBits = AntennaTrackConfig->stopBits();
|
||||
m_portsettings.Timeout_Millisec = AntennaTrackConfig->timeOut();
|
||||
|
||||
// In case we find no port, buttons disabled
|
||||
m_widget->connectButton->setEnabled(false);
|
||||
m_widget->disconnectButton->setEnabled(false);
|
||||
|
||||
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
|
||||
foreach(QextPortInfo nport, ports) {
|
||||
if (nport.friendName == AntennaTrackConfig->port()) {
|
||||
QList<QSerialPortInfo> ports = QSerialPortInfo::availablePorts();
|
||||
foreach(QSerialPortInfo nport, ports) {
|
||||
if (nport.portName() == AntennaTrackConfig->port()) {
|
||||
qDebug() << "Using Serial port";
|
||||
// parser = new NMEAParser();
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
port = new QextSerialPort(nport.portName, portsettings, QextSerialPort::EventDriven);
|
||||
#else
|
||||
port = new QextSerialPort(nport.physName, portsettings, QextSerialPort::EventDriven);
|
||||
#endif
|
||||
port = new QSerialPort(nport);
|
||||
m_widget->setPort(port);
|
||||
m_widget->connectButton->setEnabled(true);
|
||||
m_widget->disconnectButton->setEnabled(false);
|
||||
@ -112,8 +107,14 @@ void AntennaTrackGadget::onConnect()
|
||||
bool isOpen = port->open(QIODevice::ReadWrite);
|
||||
qDebug() << "Open: " << isOpen;
|
||||
if (isOpen) {
|
||||
m_widget->connectButton->setEnabled(false);
|
||||
m_widget->disconnectButton->setEnabled(true);
|
||||
if (port->setBaudRate(m_portsettings.BaudRate)
|
||||
&& 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 {
|
||||
qDebug() << "Port undefined or invalid.";
|
||||
|
@ -28,8 +28,7 @@
|
||||
#ifndef ANTENNATRACKGADGET_H_
|
||||
#define ANTENNATRACKGADGET_H_
|
||||
|
||||
#include <qextserialport/src/qextserialport.h>
|
||||
#include <qextserialport/src/qextserialenumerator.h>
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
#include <coreplugin/iuavgadget.h>
|
||||
#include "antennatrackwidget.h"
|
||||
#include "telemetryparser.h"
|
||||
@ -64,10 +63,11 @@ private slots:
|
||||
|
||||
private:
|
||||
QPointer<AntennaTrackWidget> m_widget;
|
||||
QPointer<QextSerialPort> port;
|
||||
QPointer<QSerialPort> port;
|
||||
QPointer<GPSParser> parser;
|
||||
bool connected;
|
||||
void processNewSerialData(QByteArray serialData);
|
||||
PortSettings m_portsettings;
|
||||
};
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
*/
|
||||
|
||||
#include "antennatrackgadgetconfiguration.h"
|
||||
#include <qextserialport/src/qextserialport.h>
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
|
||||
/**
|
||||
* Loads a saved configuration or defaults if non exist.
|
||||
@ -36,20 +36,20 @@ AntennaTrackGadgetConfiguration::AntennaTrackGadgetConfiguration(QString classId
|
||||
IUAVGadgetConfiguration(classId, parent),
|
||||
m_connectionMode("Serial"),
|
||||
m_defaultPort("Unknown"),
|
||||
m_defaultSpeed(BAUD4800),
|
||||
m_defaultDataBits(DATA_8),
|
||||
m_defaultFlow(FLOW_OFF),
|
||||
m_defaultParity(PAR_NONE),
|
||||
m_defaultStopBits(STOP_1),
|
||||
m_defaultSpeed(QSerialPort::UnknownBaud),
|
||||
m_defaultDataBits(QSerialPort::UnknownDataBits),
|
||||
m_defaultFlow(QSerialPort::UnknownFlowControl),
|
||||
m_defaultParity(QSerialPort::UnknownParity),
|
||||
m_defaultStopBits(QSerialPort::UnknownStopBits),
|
||||
m_defaultTimeOut(5000)
|
||||
{
|
||||
// if a saved configuration exists load it
|
||||
if (qSettings != 0) {
|
||||
BaudRateType speed;
|
||||
DataBitsType databits;
|
||||
FlowType flow;
|
||||
ParityType parity;
|
||||
StopBitsType stopbits;
|
||||
QSerialPort::BaudRate speed;
|
||||
QSerialPort::DataBits databits;
|
||||
QSerialPort::FlowControl flow;
|
||||
QSerialPort::Parity parity;
|
||||
QSerialPort::StopBits stopbits;
|
||||
|
||||
int ispeed = qSettings->value("defaultSpeed").toInt();
|
||||
int idatabits = qSettings->value("defaultDataBits").toInt();
|
||||
@ -59,11 +59,11 @@ AntennaTrackGadgetConfiguration::AntennaTrackGadgetConfiguration(QString classId
|
||||
QString port = qSettings->value("defaultPort").toString();
|
||||
QString conMode = qSettings->value("connectionMode").toString();
|
||||
|
||||
databits = (DataBitsType)idatabits;
|
||||
flow = (FlowType)iflow;
|
||||
parity = (ParityType)iparity;
|
||||
stopbits = (StopBitsType)istopbits;
|
||||
speed = (BaudRateType)ispeed;
|
||||
databits = (QSerialPort::DataBits)idatabits;
|
||||
flow = (QSerialPort::FlowControl)iflow;
|
||||
parity = (QSerialPort::Parity)iparity;
|
||||
stopbits = (QSerialPort::StopBits)istopbits;
|
||||
speed = (QSerialPort::BaudRate)ispeed;
|
||||
m_defaultPort = port;
|
||||
m_defaultSpeed = speed;
|
||||
m_defaultDataBits = databits;
|
||||
|
@ -29,10 +29,23 @@
|
||||
#define ANTENNATRACKGADGETCONFIGURATION_H
|
||||
|
||||
#include <coreplugin/iuavgadgetconfiguration.h>
|
||||
#include <qextserialport/src/qextserialport.h>
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
|
||||
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 {
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -48,23 +61,23 @@ public:
|
||||
}
|
||||
|
||||
// set port configuration functions
|
||||
void setSpeed(BaudRateType speed)
|
||||
void setSpeed(QSerialPort::BaudRate speed)
|
||||
{
|
||||
m_defaultSpeed = speed;
|
||||
}
|
||||
void setDataBits(DataBitsType databits)
|
||||
void setDataBits(QSerialPort::DataBits databits)
|
||||
{
|
||||
m_defaultDataBits = databits;
|
||||
}
|
||||
void setFlow(FlowType flow)
|
||||
void setFlow(QSerialPort::FlowControl flow)
|
||||
{
|
||||
m_defaultFlow = flow;
|
||||
}
|
||||
void setParity(ParityType parity)
|
||||
void setParity(QSerialPort::Parity parity)
|
||||
{
|
||||
m_defaultParity = parity;
|
||||
}
|
||||
void setStopBits(StopBitsType stopbits)
|
||||
void setStopBits(QSerialPort::StopBits stopbits)
|
||||
{
|
||||
m_defaultStopBits = stopbits;
|
||||
}
|
||||
@ -82,23 +95,23 @@ public:
|
||||
{
|
||||
return m_defaultPort;
|
||||
}
|
||||
BaudRateType speed()
|
||||
QSerialPort::BaudRate speed()
|
||||
{
|
||||
return m_defaultSpeed;
|
||||
}
|
||||
FlowType flow()
|
||||
QSerialPort::FlowControl flow()
|
||||
{
|
||||
return m_defaultFlow;
|
||||
}
|
||||
DataBitsType dataBits()
|
||||
QSerialPort::DataBits dataBits()
|
||||
{
|
||||
return m_defaultDataBits;
|
||||
}
|
||||
StopBitsType stopBits()
|
||||
QSerialPort::StopBits stopBits()
|
||||
{
|
||||
return m_defaultStopBits;
|
||||
}
|
||||
ParityType parity()
|
||||
QSerialPort::Parity parity()
|
||||
{
|
||||
return m_defaultParity;
|
||||
}
|
||||
@ -113,11 +126,11 @@ public:
|
||||
private:
|
||||
QString m_connectionMode;
|
||||
QString m_defaultPort;
|
||||
BaudRateType m_defaultSpeed;
|
||||
DataBitsType m_defaultDataBits;
|
||||
FlowType m_defaultFlow;
|
||||
ParityType m_defaultParity;
|
||||
StopBitsType m_defaultStopBits;
|
||||
QSerialPort::BaudRate m_defaultSpeed;
|
||||
QSerialPort::DataBits m_defaultDataBits;
|
||||
QSerialPort::FlowControl m_defaultFlow;
|
||||
QSerialPort::Parity m_defaultParity;
|
||||
QSerialPort::StopBits m_defaultStopBits;
|
||||
long m_defaultTimeOut;
|
||||
};
|
||||
|
||||
|
@ -32,135 +32,17 @@
|
||||
#include <QFileDialog>
|
||||
#include <QtAlgorithms>
|
||||
#include <QStringList>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
|
||||
AntennaTrackGadgetOptionsPage::AntennaTrackGadgetOptionsPage(AntennaTrackGadgetConfiguration *config, QObject *parent) :
|
||||
IOptionsPage(parent),
|
||||
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
|
||||
// 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";
|
||||
return s1.portName() < s2.portName();
|
||||
}
|
||||
bool sortPorts(QextPortInfo const & s1, QextPortInfo const & s2)
|
||||
{
|
||||
return s1.portName < s2.portName;
|
||||
}
|
||||
|
||||
|
||||
// creates options page widget (uses the UI file)
|
||||
QWidget *AntennaTrackGadgetOptionsPage::createPage(QWidget *parent)
|
||||
@ -171,11 +53,11 @@ QWidget *AntennaTrackGadgetOptionsPage::createPage(QWidget *parent)
|
||||
|
||||
|
||||
// PORTS
|
||||
QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
|
||||
QList<QSerialPortInfo> ports = QSerialPortInfo::availablePorts();
|
||||
qSort(ports.begin(), ports.end(), sortPorts);
|
||||
foreach(QextPortInfo port, ports) {
|
||||
qDebug() << "Adding port: " << port.friendName << " (" << port.portName << ")";
|
||||
options_page->portComboBox->addItem(port.friendName, port.friendName);
|
||||
foreach(QSerialPortInfo port, ports) {
|
||||
qDebug() << "Adding port: " << port.systemLocation() << " (" << port.portName() << ")";
|
||||
options_page->portComboBox->addItem(port.portName(), port.portName());
|
||||
}
|
||||
|
||||
int portIndex = options_page->portComboBox->findData(m_config->port());
|
||||
@ -185,41 +67,64 @@ QWidget *AntennaTrackGadgetOptionsPage::createPage(QWidget *parent)
|
||||
}
|
||||
|
||||
// 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) {
|
||||
options_page->portSpeedComboBox->setCurrentIndex(portSpeedIndex);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
options_page->flowControlComboBox->setCurrentIndex(flowControlIndex);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
options_page->dataBitsComboBox->setCurrentIndex(dataBitsIndex);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
options_page->stopBitsComboBox->setCurrentIndex(stopBitsIndex);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
options_page->parityComboBox->setCurrentIndex(parityIndex);
|
||||
}
|
||||
@ -252,11 +157,11 @@ void AntennaTrackGadgetOptionsPage::apply()
|
||||
m_config->setPort(options_page->portComboBox->itemData(portIndex).toString());
|
||||
qDebug() << "apply(): port is " << m_config->port();
|
||||
|
||||
m_config->setSpeed((BaudRateType)BaudRateTypeStringALL.indexOf(options_page->portSpeedComboBox->currentText()));
|
||||
m_config->setFlow((FlowType)FlowTypeString.indexOf(options_page->flowControlComboBox->currentText()));
|
||||
m_config->setDataBits((DataBitsType)DataBitsTypeStringALL.indexOf(options_page->dataBitsComboBox->currentText()));
|
||||
m_config->setStopBits((StopBitsType)StopBitsTypeStringALL.indexOf(options_page->stopBitsComboBox->currentText()));
|
||||
m_config->setParity((ParityType)ParityTypeStringALL.indexOf(options_page->parityComboBox->currentText()));
|
||||
m_config->setSpeed((QSerialPort::BaudRate)options_page->portSpeedComboBox->itemData(options_page->portSpeedComboBox->currentIndex()).toInt());
|
||||
m_config->setFlow((QSerialPort::FlowControl)options_page->flowControlComboBox->itemData(options_page->flowControlComboBox->currentIndex()).toInt());
|
||||
m_config->setDataBits((QSerialPort::DataBits)options_page->dataBitsComboBox->itemData(options_page->dataBitsComboBox->currentIndex()).toInt());
|
||||
m_config->setStopBits((QSerialPort::StopBits)options_page->stopBitsComboBox->itemData(options_page->stopBitsComboBox->currentIndex()).toInt());
|
||||
m_config->setParity((QSerialPort::Parity)options_page->parityComboBox->itemData(options_page->parityComboBox->currentIndex()).toInt());
|
||||
m_config->setTimeOut(options_page->timeoutSpinBox->value());
|
||||
m_config->setConnectionMode(options_page->connectionMode->currentText());
|
||||
}
|
||||
|
@ -28,7 +28,6 @@
|
||||
#ifndef ANTENNATRACKGADGETOPTIONSPAGE_H
|
||||
#define ANTENNATRACKGADGETOPTIONSPAGE_H
|
||||
|
||||
#include <qextserialport/src/qextserialenumerator.h>
|
||||
#include "coreplugin/dialogs/ioptionspage.h"
|
||||
#include "QString"
|
||||
#include <QStringList>
|
||||
@ -59,16 +58,6 @@ private:
|
||||
Ui::AntennaTrackGadgetOptionsPage *options_page;
|
||||
AntennaTrackGadgetConfiguration *m_config;
|
||||
|
||||
QStringList BaudRateTypeString;
|
||||
QStringList BaudRateTypeStringALL;
|
||||
QStringList DataBitsTypeStringALL;
|
||||
QStringList ParityTypeStringALL;
|
||||
QStringList StopBitsTypeStringALL;
|
||||
QStringList DataBitsTypeString;
|
||||
QStringList ParityTypeString;
|
||||
QStringList StopBitsTypeString;
|
||||
QStringList FlowTypeString;
|
||||
|
||||
private slots:
|
||||
};
|
||||
|
||||
|
@ -35,5 +35,3 @@ void AntennaTrackPlugin::shutdown()
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN(AntennaTrackPlugin)
|
||||
|
@ -6,6 +6,8 @@
|
||||
class AntennaTrackGadgetFactory;
|
||||
|
||||
class AntennaTrackPlugin : public ExtensionSystem::IPlugin {
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "OpenPilot.AntennaTrack")
|
||||
public:
|
||||
AntennaTrackPlugin();
|
||||
~AntennaTrackPlugin();
|
||||
|
@ -47,7 +47,7 @@ AntennaTrackWidget::AntennaTrackWidget(QWidget *parent) : QWidget(parent)
|
||||
|
||||
AntennaTrackWidget::~AntennaTrackWidget()
|
||||
{}
|
||||
void AntennaTrackWidget::setPort(QPointer<QextSerialPort> portx)
|
||||
void AntennaTrackWidget::setPort(QPointer<QSerialPort> portx)
|
||||
{
|
||||
port = portx;
|
||||
}
|
||||
@ -204,9 +204,9 @@ void AntennaTrackWidget::calcAntennaPosition(void)
|
||||
str3.sprintf("move %d 2000 2000 2000 %d\r", stepper, servo);
|
||||
if (port->isOpen()) {
|
||||
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 <QtSvg/QSvgRenderer>
|
||||
#include <QtSvg/QGraphicsSvgItem>
|
||||
#include <qextserialport/src/qextserialport.h>
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
#include <QPointer>
|
||||
|
||||
class Ui_AntennaTrackWidget;
|
||||
@ -55,7 +55,7 @@ public:
|
||||
AntennaTrackWidget(QWidget *parent = 0);
|
||||
~AntennaTrackWidget();
|
||||
TrackData_t TrackData;
|
||||
void setPort(QPointer<QextSerialPort> portx);
|
||||
void setPort(QPointer<QSerialPort> portx);
|
||||
|
||||
private slots:
|
||||
void setPosition(double, double, double);
|
||||
@ -65,7 +65,7 @@ private slots:
|
||||
private:
|
||||
void calcAntennaPosition(void);
|
||||
QGraphicsSvgItem *marker;
|
||||
QPointer<QextSerialPort> port;
|
||||
QPointer<QSerialPort> port;
|
||||
double azimuth_old;
|
||||
double elevation_old;
|
||||
};
|
||||
|
@ -31,16 +31,16 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QBrush>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#define Pi 3.14159265358979323846
|
||||
#define Pi 3.14159265358979323846
|
||||
|
||||
QStringList ConfigCcpmWidget::getChannelDescriptions()
|
||||
{
|
||||
@ -126,8 +126,8 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) :
|
||||
SwashLvlConfigurationInProgress = 0;
|
||||
SwashLvlState = 0;
|
||||
SwashLvlServoInterlock = 0;
|
||||
updatingFromHardware = FALSE;
|
||||
updatingToHardware = FALSE;
|
||||
updatingFromHardware = false;
|
||||
updatingToHardware = false;
|
||||
|
||||
// Initialization of the swashplaye widget
|
||||
m_aircraft->SwashplateImage->setScene(new QGraphicsScene(this));
|
||||
@ -687,7 +687,7 @@ void ConfigCcpmWidget::UpdateMixer()
|
||||
}
|
||||
|
||||
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[1] = m_aircraft->ccpmTailChannel->currentIndex();
|
||||
MixerChannelData[2] = m_aircraft->ccpmServoWChannel->currentIndex();
|
||||
@ -796,11 +796,11 @@ QString ConfigCcpmWidget::updateConfigObjects()
|
||||
bool useCCPM;
|
||||
bool useCyclic;
|
||||
|
||||
if (updatingFromHardware == TRUE) {
|
||||
if (updatingFromHardware == true) {
|
||||
return airframeType;
|
||||
}
|
||||
|
||||
updatingFromHardware = TRUE;
|
||||
updatingFromHardware = true;
|
||||
|
||||
// get the user options
|
||||
GUIConfigDataUnion config = getConfigData();
|
||||
@ -845,7 +845,7 @@ QString ConfigCcpmWidget::updateConfigObjects()
|
||||
|
||||
setConfigData(config);
|
||||
|
||||
updatingFromHardware = FALSE;
|
||||
updatingFromHardware = false;
|
||||
return airframeType;
|
||||
}
|
||||
|
||||
@ -888,7 +888,7 @@ void ConfigCcpmWidget::getMixer()
|
||||
return;
|
||||
}
|
||||
|
||||
updatingFromHardware = TRUE;
|
||||
updatingFromHardware = true;
|
||||
|
||||
UAVDataObject *mixer = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(mixer);
|
||||
@ -911,7 +911,7 @@ void ConfigCcpmWidget::getMixer()
|
||||
m_aircraft->PitchCurve->ResetCurve();
|
||||
}
|
||||
|
||||
updatingFromHardware = FALSE;
|
||||
updatingFromHardware = false;
|
||||
|
||||
ccpmSwashplateUpdate();
|
||||
}
|
||||
@ -926,11 +926,11 @@ void ConfigCcpmWidget::setMixer()
|
||||
if (SwashLvlConfigurationInProgress) {
|
||||
return;
|
||||
}
|
||||
if (updatingToHardware == TRUE) {
|
||||
if (updatingToHardware == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
updatingToHardware = TRUE;
|
||||
updatingToHardware = true;
|
||||
|
||||
MixerSettings *mixerSettings = MixerSettings::GetInstance(getObjectManager());
|
||||
Q_ASSERT(mixerSettings);
|
||||
@ -1004,7 +1004,7 @@ void ConfigCcpmWidget::setMixer()
|
||||
|
||||
mixerSettings->setData(mixerSettingsData);
|
||||
mixerSettings->updated();
|
||||
updatingToHardware = FALSE;
|
||||
updatingToHardware = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
#include <QtSvg/QGraphicsSvgItem>
|
||||
#include <QGraphicsEllipseItem>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
|
||||
#define CCPM_MAX_SWASH_SERVOS 4
|
||||
|
@ -29,11 +29,11 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QComboBox>
|
||||
#include <QBrush>
|
||||
#include <math.h>
|
||||
#include <QMessageBox>
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "uavobject.h"
|
||||
#include "uavtalk/telemetrymanager.h"
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
#include <QItemDelegate>
|
||||
|
||||
|
@ -32,10 +32,10 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QBrush>
|
||||
#include <math.h>
|
||||
#include <QMessageBox>
|
||||
|
@ -34,8 +34,7 @@
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include "uavtalk/telemetrymanager.h"
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
#include <QItemDelegate>
|
||||
|
||||
|
@ -32,10 +32,10 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QBrush>
|
||||
#include <QMessageBox>
|
||||
|
||||
|
@ -34,8 +34,7 @@
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include "uavtalk/telemetrymanager.h"
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
#include <QItemDelegate>
|
||||
|
||||
|
@ -32,11 +32,11 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QComboBox>
|
||||
#include <QBrush>
|
||||
#include <math.h>
|
||||
#include <QMessageBox>
|
||||
@ -217,7 +217,7 @@ void ConfigMultiRotorWidget::setupEnabledControls(QString frameType)
|
||||
// disable all motor channel boxes
|
||||
for (int i = 1; i <= 8; i++) {
|
||||
// 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) {
|
||||
combobox->setEnabled(false);
|
||||
combobox->setItemData(0, 0, Qt::DecorationRole);
|
||||
@ -1005,7 +1005,7 @@ bool ConfigMultiRotorWidget::throwConfigError(int numMotors)
|
||||
// Iterate through all instances of multiMotorChannelBox
|
||||
for (int i = 0; i < numMotors; i++) {
|
||||
// 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->currentText() == "None") {
|
||||
int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize);
|
||||
|
@ -36,8 +36,8 @@
|
||||
#include "uavtalk/telemetrymanager.h"
|
||||
|
||||
#include <QtCore/QList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QItemDelegate>
|
||||
#include <QWidget>
|
||||
#include <QItemDelegate>
|
||||
|
||||
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)
|
||||
{
|
||||
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) {
|
||||
box->setEnabled(enable);
|
||||
}
|
||||
|
@ -29,10 +29,10 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
#include "smartsavebutton.h"
|
||||
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QtWidgets/QTextEdit>
|
||||
#include <QtWidgets/QVBoxLayout>
|
||||
#include <QtWidgets/QPushButton>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QList>
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "stabilizationsettings.h"
|
||||
#include "relaytuningsettings.h"
|
||||
#include "relaytuning.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtWidgets/QWidget>
|
||||
#include <QTimer>
|
||||
|
||||
class ConfigAutotuneWidget : public ConfigTaskWidget {
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
|
||||
class Ui_Widget;
|
||||
|
@ -44,10 +44,10 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
|
||||
ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include "objectpersistence.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
#include <QTextBrowser>
|
||||
#include "utils/pathutils.h"
|
||||
|
@ -31,10 +31,10 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QMessageBox>
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
#include "inputchannelform.h"
|
||||
#include "ui_inputchannelform.h"
|
||||
|
@ -33,10 +33,10 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "uavobject.h"
|
||||
#include "uavobjectutilmanager.h"
|
||||
#include "cfg_vehicletypes/vehicleconfig.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
|
||||
class Ui_OutputWidget;
|
||||
|
@ -183,14 +183,14 @@ void ConfigPipXtremeWidget::updateStatus(UAVObject *object)
|
||||
*/
|
||||
char buf[OPLinkStatus::DESCRIPTION_NUMELEM];
|
||||
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';
|
||||
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++) {
|
||||
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");
|
||||
m_oplink->FirmwareVersion->setText(descstr + " " + date);
|
||||
|
@ -69,5 +69,3 @@ void ConfigPlugin::extensionsInitialized()
|
||||
|
||||
void ConfigPlugin::shutdown()
|
||||
{}
|
||||
|
||||
Q_EXPORT_PLUGIN(ConfigPlugin)
|
||||
|
@ -42,6 +42,7 @@ class ConfigGadgetFactory;
|
||||
|
||||
class ConfigPlugin : public ExtensionSystem::IPlugin {
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "OpenPilot.Config")
|
||||
|
||||
public:
|
||||
ConfigPlugin();
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
|
||||
|
||||
|
@ -30,10 +30,10 @@
|
||||
#include <QDebug>
|
||||
#include <QTimer>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
#include <QThread>
|
||||
#include <QErrorMessage>
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
#include <QtSvg/QGraphicsSvgItem>
|
||||
#include <QList>
|
||||
|
@ -28,10 +28,10 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
#include <QList>
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include "stabilizationsettings.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
|
||||
|
||||
|
@ -37,7 +37,11 @@
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
#include <QTimer>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <math.h>
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
|
@ -38,6 +38,12 @@
|
||||
#include <QStringList>
|
||||
#include <QWidget>
|
||||
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
#include <QItemDelegate>
|
||||
|
||||
class Ui_Widget;
|
||||
|
||||
/*
|
||||
* 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
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
#include <QMutex>
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "extensionsystem/pluginmanager.h"
|
||||
#include "uavobjectmanager.h"
|
||||
#include "uavobject.h"
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
#include <QMutex>
|
||||
|
||||
|
@ -32,17 +32,17 @@
|
||||
|
||||
#include <QDebug>
|
||||
#include <QtPlugin>
|
||||
#include <QtGui/QColorDialog>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtGui/QWindowsStyle>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QSplitter>
|
||||
#include <QtGui/QStackedLayout>
|
||||
#include <QtGui/QStatusBar>
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QtGui/QToolTip>
|
||||
#include <QColorDialog>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMouseEvent>
|
||||
// #include <QWindowsStyle>
|
||||
#include <QPainter>
|
||||
#include <QSplitter>
|
||||
#include <QStackedLayout>
|
||||
#include <QStatusBar>
|
||||
#include <QToolButton>
|
||||
#include <QToolTip>
|
||||
|
||||
const int FancyTabBar::m_rounding = 22;
|
||||
const int FancyTabBar::m_textPadding = 4;
|
||||
@ -59,7 +59,7 @@ FancyTabBar::FancyTabBar(QWidget *parent, bool isVertical)
|
||||
} else {
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
}
|
||||
setStyle(new QWindowsStyle);
|
||||
// setStyle(new QWindowsStyle);
|
||||
setMinimumWidth(qMax(2 * m_rounding, 40));
|
||||
setAttribute(Qt::WA_Hover, true);
|
||||
setFocusPolicy(Qt::NoFocus);
|
||||
|
@ -29,9 +29,9 @@
|
||||
#ifndef FANCYTABWIDGET_H
|
||||
#define FANCYTABWIDGET_H
|
||||
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QTabBar>
|
||||
#include <QtGui/QStyleOptionTabV2>
|
||||
#include <QPushButton>
|
||||
#include <QTabBar>
|
||||
#include <QStyleOptionTabV2>
|
||||
#include <QtCore/QTimeLine>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -25,7 +25,7 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QResizeEvent>
|
||||
#include <math.h>
|
||||
#include "mixercurve.h"
|
||||
|
@ -28,7 +28,7 @@
|
||||
#define MIXERCURVE_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
#include <QTableWidget>
|
||||
|
||||
|
@ -35,8 +35,8 @@
|
||||
#include "uniqueidmanager.h"
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QMenuBar>
|
||||
#include <QAction>
|
||||
#include <QMenuBar>
|
||||
|
||||
Q_DECLARE_METATYPE(Core::Internal::MenuActionContainer *)
|
||||
|
||||
|
@ -30,9 +30,9 @@
|
||||
#define ACTIONCONTAINER_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QMenuBar>
|
||||
#include <QtGui/QAction>
|
||||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
#include <QAction>
|
||||
|
||||
namespace Core {
|
||||
class Command;
|
||||
|
@ -36,10 +36,10 @@
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QShortcut>
|
||||
#include <QtGui/QMenuBar>
|
||||
#include <QMenu>
|
||||
#include <QAction>
|
||||
#include <QShortcut>
|
||||
#include <QMenuBar>
|
||||
|
||||
namespace {
|
||||
enum { warnAboutFindFailures = 0 };
|
||||
|
@ -27,8 +27,8 @@
|
||||
*/
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QShortcut>
|
||||
#include <QAction>
|
||||
#include <QShortcut>
|
||||
|
||||
#include "command_p.h"
|
||||
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QMultiMap>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QKeySequence>
|
||||
#include <QKeySequence>
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
@ -33,7 +33,7 @@
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QList>
|
||||
#include <QtGui/QKeySequence>
|
||||
#include <QKeySequence>
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
@ -38,11 +38,11 @@
|
||||
#include <QtCore/QFile>
|
||||
#include <QtCore/QSysInfo>
|
||||
|
||||
#include <QtGui/QDialogButtonBox>
|
||||
#include <QtGui/QGridLayout>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QTextBrowser>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QTextBrowser>
|
||||
|
||||
#include <QtDeclarative/qdeclarative.h>
|
||||
#include <QtDeclarative/qdeclarativeview.h>
|
||||
|
@ -29,7 +29,7 @@
|
||||
#ifndef AUTHORSDIALOG_H
|
||||
#define AUTHORSDIALOG_H
|
||||
|
||||
#include <QtGui/QDialog>
|
||||
#include <QDialog>
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
@ -30,7 +30,7 @@
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
|
@ -33,8 +33,8 @@
|
||||
#include "imode.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QWidget>
|
||||
#include <QIcon>
|
||||
|
||||
namespace Core {
|
||||
class CORE_EXPORT BaseMode
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "baseview.h"
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
|
@ -31,8 +31,8 @@
|
||||
#include <aggregation/aggregate.h>
|
||||
#include <coreplugin/iconnection.h>
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
#include "qextserialport/src/qextserialenumerator.h"
|
||||
#include "qextserialport/src/qextserialport.h"
|
||||
#include <QtSerialPort/QSerialPort>
|
||||
#include <QtSerialPort/QSerialPortInfo>
|
||||
#include <QDebug>
|
||||
#include <QLabel>
|
||||
#include <QHBoxLayout>
|
||||
|
@ -37,8 +37,8 @@
|
||||
#include <QtCore/QVector>
|
||||
#include <QtCore/QIODevice>
|
||||
#include <QtCore/QLinkedList>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QPushButton>
|
||||
#include <QComboBox>
|
||||
|
||||
#include "core_global.h"
|
||||
#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_CLEAN_PANE = ":/core/images/clean_pane_small.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_FINDNEXT = ":/core/images/findnext.png";
|
||||
const char *const ICON_REPLACE = ":/core/images/replace.png";
|
||||
|
@ -76,5 +76,3 @@ void CorePlugin::shutdown()
|
||||
{
|
||||
m_mainWindow->shutdown();
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN2(Core, CorePlugin)
|
||||
|
@ -37,6 +37,7 @@ class MainWindow;
|
||||
|
||||
class CorePlugin : public ExtensionSystem::IPlugin {
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "OpenPilot.Core")
|
||||
|
||||
public:
|
||||
CorePlugin();
|
||||
|
@ -1,4 +1,2 @@
|
||||
include(../../libs/extensionsystem/extensionsystem.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 <QtCore/QObject>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QIcon>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QWidget;
|
||||
|
@ -35,9 +35,9 @@
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QHeaderView>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QHeaderView>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
@ -38,10 +38,10 @@
|
||||
#include <utils/treewidgetcolumnstretcher.h>
|
||||
|
||||
|
||||
#include <QtGui/QKeyEvent>
|
||||
#include <QtGui/QShortcut>
|
||||
#include <QtGui/QHeaderView>
|
||||
#include <QtGui/QFileDialog>
|
||||
#include <QKeyEvent>
|
||||
#include <QShortcut>
|
||||
#include <QHeaderView>
|
||||
#include <QFileDialog>
|
||||
#include <QtDebug>
|
||||
|
||||
Q_DECLARE_METATYPE(Core::Internal::ShortcutItem *)
|
||||
@ -157,7 +157,7 @@ void ShortcutSettings::commandChanged(QTreeWidgetItem *current)
|
||||
return;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
@ -174,9 +174,9 @@ void ShortcutSettings::keyChanged()
|
||||
QTreeWidgetItem *current = m_page->commandList->currentItem();
|
||||
|
||||
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]);
|
||||
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) {
|
||||
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)
|
||||
@ -222,7 +222,7 @@ void ShortcutSettings::resetKeySequence()
|
||||
QTreeWidgetItem *current = m_page->commandList->currentItem();
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
@ -250,7 +250,7 @@ void ShortcutSettings::importAction()
|
||||
|
||||
if (mapping.contains(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()) {
|
||||
commandChanged(item->m_item);
|
||||
}
|
||||
@ -263,7 +263,7 @@ void ShortcutSettings::defaultAction()
|
||||
{
|
||||
foreach(ShortcutItem * item, m_scitems) {
|
||||
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()) {
|
||||
commandChanged(item->m_item);
|
||||
}
|
||||
@ -317,7 +317,7 @@ void ShortcutSettings::initialize()
|
||||
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));
|
||||
}
|
||||
}
|
||||
@ -353,7 +353,7 @@ void ShortcutSettings::handleKeyEvent(QKeyEvent *e)
|
||||
}
|
||||
m_keyNum++;
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -32,9 +32,9 @@
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QKeySequence>
|
||||
#include <QtGui/QTreeWidgetItem>
|
||||
#include <QtGui/QKeyEvent>
|
||||
#include <QKeySequence>
|
||||
#include <QTreeWidgetItem>
|
||||
#include <QKeyEvent>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class Ui_ShortcutSettings;
|
||||
|
@ -40,8 +40,15 @@ EventFilteringMainWindow::EventFilteringMainWindow()
|
||||
{}
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
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) {
|
||||
emit deviceChange();
|
||||
*result = TRUE;
|
||||
|
@ -29,7 +29,7 @@
|
||||
#ifndef EVENTFILTERINGMAINWINDOW_H
|
||||
#define EVENTFILTERINGMAINWINDOW_H
|
||||
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QMainWindow>
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
@ -45,7 +45,11 @@ public:
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
protected:
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
bool winEvent(MSG *message, long *result);
|
||||
#else
|
||||
bool nativeEvent(const QByteArray & /*eventType*/, void *message, long *result);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
signals:
|
||||
|
@ -28,12 +28,12 @@
|
||||
|
||||
#include "fancyactionbar.h"
|
||||
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QPicture>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QPainter>
|
||||
#include <QPicture>
|
||||
#include <QVBoxLayout>
|
||||
#include <QtSvg/QSvgRenderer>
|
||||
#include <QtGui/QAction>
|
||||
#include <QAction>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Internal;
|
||||
|
@ -31,7 +31,7 @@
|
||||
#define FANCYACTIONBAR_H
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QToolButton>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QMenu;
|
||||
|
@ -27,50 +27,65 @@
|
||||
*/
|
||||
|
||||
#include "fancytabwidget.h"
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/stylehelper.h>
|
||||
#include <utils/styledbar.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <QtGui/QColorDialog>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QMouseEvent>
|
||||
#include <QtGui/QWindowsStyle>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QSplitter>
|
||||
#include <QtGui/QStackedLayout>
|
||||
#include <QtGui/QStatusBar>
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QtGui/QToolTip>
|
||||
#include <QColorDialog>
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QMouseEvent>
|
||||
#include <QStyleFactory>
|
||||
#include <QPainter>
|
||||
#include <QStackedLayout>
|
||||
#include <QStatusBar>
|
||||
#include <QToolTip>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Internal;
|
||||
|
||||
const int FancyTabBar::m_rounding = 22;
|
||||
const int FancyTabBar::m_rounding = 22;
|
||||
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)
|
||||
{
|
||||
verticalTabs = isVertical;
|
||||
setIconSize(16);
|
||||
m_hoverIndex = -1;
|
||||
m_currentIndex = 0;
|
||||
if (isVertical) {
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||
} else {
|
||||
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
}
|
||||
setStyle(new QWindowsStyle);
|
||||
m_hoverIndex = -1;
|
||||
m_currentIndex = -1;
|
||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||
setStyle(QStyleFactory::create(QLatin1String("windows")));
|
||||
setMinimumWidth(qMax(2 * m_rounding, 40));
|
||||
setAttribute(Qt::WA_Hover, true);
|
||||
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
|
||||
m_triggerTimer.setSingleShot(true);
|
||||
|
||||
// We use a zerotimer to keep the sidebar responsive
|
||||
connect(&m_triggerTimer, SIGNAL(timeout()), this, SLOT(emitCurrentIndex()));
|
||||
}
|
||||
|
||||
FancyTabBar::~FancyTabBar()
|
||||
@ -81,15 +96,19 @@ FancyTabBar::~FancyTabBar()
|
||||
QSize FancyTabBar::tabSizeHint(bool minimum) const
|
||||
{
|
||||
QFont boldFont(font());
|
||||
|
||||
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
|
||||
boldFont.setBold(true);
|
||||
QFontMetrics fm(boldFont);
|
||||
int spacing = 6;
|
||||
int width = 90 + spacing + 2;
|
||||
|
||||
int iconHeight = minimum ? 0 : iconSize;
|
||||
return QSize(width, iconHeight + spacing + fm.height());
|
||||
int spacing = 8;
|
||||
int width = 60 + spacing + 2;
|
||||
int maxLabelwidth = 0;
|
||||
for (int tab=0 ; tab<count() ;++tab) {
|
||||
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)
|
||||
@ -97,49 +116,47 @@ void FancyTabBar::paintEvent(QPaintEvent *event)
|
||||
Q_UNUSED(event)
|
||||
QPainter p(this);
|
||||
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
if (i != currentIndex()) {
|
||||
for (int i = 0; i < count(); ++i)
|
||||
if (i != currentIndex())
|
||||
paintTab(&p, i);
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
void FancyTabBar::mouseMoveEvent(QMouseEvent *e)
|
||||
{
|
||||
if (!m_hoverRect.contains(e->pos())) {
|
||||
int newHover = -1;
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
QRect area = tabRect(i);
|
||||
if (area.contains(e->pos())) {
|
||||
newHover = i;
|
||||
break;
|
||||
}
|
||||
int newHover = -1;
|
||||
for (int i = 0; i < count(); ++i) {
|
||||
QRect area = tabRect(i);
|
||||
if (area.contains(e->pos())) {
|
||||
newHover = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (newHover == m_hoverIndex)
|
||||
return;
|
||||
|
||||
m_hoverControl.stop();
|
||||
m_hoverIndex = newHover;
|
||||
update(m_hoverRect);
|
||||
m_hoverRect = QRect();
|
||||
if (validIndex(m_hoverIndex))
|
||||
m_tabs[m_hoverIndex]->fadeOut();
|
||||
|
||||
if (m_hoverIndex >= 0) {
|
||||
QRect oldHoverRect = m_hoverRect;
|
||||
m_hoverRect = tabRect(m_hoverIndex);
|
||||
m_hoverControl.start();
|
||||
}
|
||||
m_hoverIndex = newHover;
|
||||
|
||||
if (validIndex(m_hoverIndex)) {
|
||||
m_tabs[m_hoverIndex]->fadeIn();
|
||||
m_hoverRect = tabRect(m_hoverIndex);
|
||||
}
|
||||
}
|
||||
|
||||
bool FancyTabBar::event(QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::ToolTip) {
|
||||
if (m_hoverIndex >= 0 && m_hoverIndex < m_tabs.count()) {
|
||||
if (validIndex(m_hoverIndex)) {
|
||||
QString tt = tabToolTip(m_hoverIndex);
|
||||
if (!tt.isEmpty()) {
|
||||
QToolTip::showText(static_cast<QHelpEvent *>(event)->globalPos(), tt, this);
|
||||
QToolTip::showText(static_cast<QHelpEvent*>(event)->globalPos(), tt, this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -147,16 +164,11 @@ bool FancyTabBar::event(QEvent *event)
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
void FancyTabBar::updateHover()
|
||||
{
|
||||
update(m_hoverRect);
|
||||
}
|
||||
|
||||
// Resets hover animation on mouse enter
|
||||
void FancyTabBar::enterEvent(QEvent *e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
m_hoverRect = QRect();
|
||||
m_hoverRect = QRect();
|
||||
m_hoverIndex = -1;
|
||||
}
|
||||
|
||||
@ -164,64 +176,55 @@ void FancyTabBar::enterEvent(QEvent *e)
|
||||
void FancyTabBar::leaveEvent(QEvent *e)
|
||||
{
|
||||
Q_UNUSED(e)
|
||||
if (m_hoverIndex >= 0) {
|
||||
m_hoverIndex = -1;
|
||||
update(m_hoverRect);
|
||||
m_hoverRect = QRect();
|
||||
m_hoverIndex = -1;
|
||||
m_hoverRect = QRect();
|
||||
for (int i = 0 ; i < m_tabs.count() ; ++i) {
|
||||
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 sh = tabSizeHint();
|
||||
|
||||
if (verticalTabs) {
|
||||
return QSize(sh.width(), sh.height() * m_tabs.count());
|
||||
}
|
||||
return QSize(sh.width() * m_tabs.count(), sh.height());
|
||||
return QSize(sh.width(), sh.height() * m_tabs.count());
|
||||
}
|
||||
|
||||
QSize FancyTabBar::minimumSizeHint() const
|
||||
{
|
||||
QSize sh = tabSizeHint(true);
|
||||
|
||||
if (verticalTabs) {
|
||||
return QSize(sh.width(), sh.height() * m_tabs.count());
|
||||
}
|
||||
return QSize(sh.width() * m_tabs.count(), sh.height());
|
||||
return QSize(sh.width(), sh.height() * m_tabs.count());
|
||||
}
|
||||
|
||||
QRect FancyTabBar::tabRect(int index) const
|
||||
{
|
||||
QSize sh = tabSizeHint();
|
||||
|
||||
if (verticalTabs) {
|
||||
if (sh.height() * m_tabs.count() > height()) {
|
||||
sh.setHeight(height() / m_tabs.count());
|
||||
}
|
||||
if (sh.height() * m_tabs.count() > height())
|
||||
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)
|
||||
{
|
||||
e->accept();
|
||||
for (int i = 0; i < m_tabs.count(); ++i) {
|
||||
if (tabRect(i).contains(e->pos())) {
|
||||
setCurrentIndex(i);
|
||||
for (int index = 0; index < m_tabs.count(); ++index) {
|
||||
if (tabRect(index).contains(e->pos())) {
|
||||
|
||||
if (isTabEnabled(index)) {
|
||||
m_currentIndex = index;
|
||||
update();
|
||||
m_triggerTimer.start(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -229,87 +232,127 @@ void FancyTabBar::mousePressEvent(QMouseEvent *e)
|
||||
|
||||
void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
|
||||
{
|
||||
if (!validIndex(tabIndex)) {
|
||||
qWarning("invalid index");
|
||||
return;
|
||||
}
|
||||
painter->save();
|
||||
|
||||
QRect rect = tabRect(tabIndex);
|
||||
|
||||
QRect rect = tabRect(tabIndex);
|
||||
bool selected = (tabIndex == m_currentIndex);
|
||||
bool hover = (tabIndex == m_hoverIndex);
|
||||
|
||||
#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);
|
||||
bool enabled = isTabEnabled(tabIndex);
|
||||
|
||||
if (selected) {
|
||||
QLinearGradient selectedGradient(rect.bottomRight(), QPoint(rect.center().x(), rect.top()));
|
||||
selectedGradient.setColorAt(0, Qt::white);
|
||||
selectedGradient.setColorAt(0.3, Qt::white);
|
||||
selectedGradient.setColorAt(0.7, QColor(210, 210, 220)); // give a blue-ish color
|
||||
//background
|
||||
painter->save();
|
||||
QLinearGradient grad(rect.topLeft(), rect.topRight());
|
||||
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);
|
||||
painter->setPen(QColor(200, 200, 200));
|
||||
//shadows
|
||||
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->setPen(QColor(150, 160, 200));
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
} else {
|
||||
painter->fillRect(rect, background);
|
||||
if (hover) {
|
||||
painter->fillRect(rect, hoverColor);
|
||||
}
|
||||
painter->setPen(QPen(light, 0));
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
painter->setPen(QPen(dark, 0));
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
|
||||
//highlights
|
||||
painter->setPen(QColor(255, 255, 255, 50));
|
||||
painter->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0,2));
|
||||
painter->drawLine(rect.bottomLeft() + QPoint(0, 1), rect.bottomRight() + QPoint(0,1));
|
||||
painter->setPen(QColor(255, 255, 255, 40));
|
||||
painter->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight());
|
||||
painter->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1));
|
||||
painter->drawLine(rect.bottomLeft() + QPoint(0,-1), rect.bottomRight()-QPoint(0,1));
|
||||
}
|
||||
|
||||
QString tabText(this->tabText(tabIndex));
|
||||
QRect tabTextRect(tabRect(tabIndex));
|
||||
QRect tabTextRect(rect);
|
||||
const bool drawIcon = rect.height() > 36;
|
||||
QRect tabIconRect(tabTextRect);
|
||||
tabTextRect.translate(0, drawIcon ? -2 : 1);
|
||||
QFont boldFont(painter->font());
|
||||
boldFont.setPointSizeF(Utils::StyleHelper::sidebarFontSize());
|
||||
boldFont.setBold(true);
|
||||
painter->setFont(boldFont);
|
||||
painter->setPen(selected ? Utils::StyleHelper::panelTextColor() : QColor(30, 30, 30, 80));
|
||||
int textFlags = Qt::AlignCenter | Qt::AlignBottom | Qt::ElideRight | Qt::TextWordWrap;
|
||||
painter->drawText(tabTextRect, textFlags, tabText);
|
||||
painter->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor());
|
||||
int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
|
||||
tabIconRect.adjust(0, 4, 0, -textHeight);
|
||||
int iconSize = qMin(tabIconRect.width(), tabIconRect.height());
|
||||
if (iconSize > 4) {
|
||||
style()->drawItemPixmap(painter, tabIconRect, Qt::AlignCenter | Qt::AlignVCenter,
|
||||
tabIcon(tabIndex).pixmap(tabIconRect.size()));
|
||||
painter->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110));
|
||||
const int textFlags = Qt::AlignCenter | (drawIcon ? Qt::AlignBottom : Qt::AlignVCenter) | Qt::TextWordWrap;
|
||||
if (enabled) {
|
||||
painter->drawText(tabTextRect, textFlags, tabText);
|
||||
painter->setPen(selected ? QColor(60, 60, 60) : Utils::StyleHelper::panelTextColor());
|
||||
} else {
|
||||
painter->setPen(selected ? Utils::StyleHelper::panelTextColor() : QColor(255, 255, 255, 120));
|
||||
}
|
||||
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->drawText(tabTextRect, textFlags, tabText);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
void FancyTabBar::setCurrentIndex(int index)
|
||||
{
|
||||
m_currentIndex = index;
|
||||
update();
|
||||
emit currentChanged(index);
|
||||
void FancyTabBar::setCurrentIndex(int index) {
|
||||
if (isTabEnabled(index)) {
|
||||
m_currentIndex = index;
|
||||
update();
|
||||
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
|
||||
//////
|
||||
|
||||
class FancyColorButton : public QWidget {
|
||||
class FancyColorButton : public QWidget
|
||||
{
|
||||
public:
|
||||
FancyColorButton(QWidget *parent)
|
||||
: m_parent(parent)
|
||||
: m_parent(parent)
|
||||
{
|
||||
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
|
||||
}
|
||||
@ -317,7 +360,9 @@ public:
|
||||
void mousePressEvent(QMouseEvent *ev)
|
||||
{
|
||||
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:
|
||||
@ -328,28 +373,18 @@ private:
|
||||
// FancyTabWidget
|
||||
//////
|
||||
|
||||
FancyTabWidget::FancyTabWidget(QWidget *parent, bool isVertical)
|
||||
FancyTabWidget::FancyTabWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
m_tabBar = new FancyTabBar(this, isVertical);
|
||||
m_tabBar = new FancyTabBar(this);
|
||||
|
||||
m_selectionWidget = new QWidget(this);
|
||||
QBoxLayout *selectionLayout;
|
||||
if (isVertical) {
|
||||
selectionLayout = new QVBoxLayout;
|
||||
} else {
|
||||
selectionLayout = new QHBoxLayout;
|
||||
}
|
||||
QVBoxLayout *selectionLayout = new QVBoxLayout;
|
||||
selectionLayout->setSpacing(0);
|
||||
selectionLayout->setMargin(0);
|
||||
|
||||
Utils::StyledBar *bar = new Utils::StyledBar;
|
||||
QBoxLayout *layout;
|
||||
if (isVertical) {
|
||||
layout = new QHBoxLayout(bar);
|
||||
} else {
|
||||
layout = new QVBoxLayout(bar);
|
||||
}
|
||||
QHBoxLayout *layout = new QHBoxLayout(bar);
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(0);
|
||||
layout->addWidget(new FancyColorButton(this));
|
||||
@ -357,26 +392,13 @@ FancyTabWidget::FancyTabWidget(QWidget *parent, bool isVertical)
|
||||
|
||||
selectionLayout->addWidget(m_tabBar, 1);
|
||||
m_selectionWidget->setLayout(selectionLayout);
|
||||
if (isVertical) {
|
||||
m_selectionWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
} else {
|
||||
m_selectionWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
||||
}
|
||||
m_selectionWidget->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
|
||||
m_cornerWidgetContainer = new QWidget(this);
|
||||
if (isVertical) {
|
||||
m_cornerWidgetContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
} else {
|
||||
m_cornerWidgetContainer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
|
||||
}
|
||||
m_cornerWidgetContainer->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
|
||||
m_cornerWidgetContainer->setAutoFillBackground(false);
|
||||
|
||||
QBoxLayout *cornerWidgetLayout;
|
||||
if (isVertical) {
|
||||
cornerWidgetLayout = new QVBoxLayout;
|
||||
} else {
|
||||
cornerWidgetLayout = new QHBoxLayout;
|
||||
}
|
||||
QVBoxLayout *cornerWidgetLayout = new QVBoxLayout;
|
||||
cornerWidgetLayout->setSpacing(0);
|
||||
cornerWidgetLayout->setMargin(0);
|
||||
cornerWidgetLayout->addStretch();
|
||||
@ -385,30 +407,35 @@ FancyTabWidget::FancyTabWidget(QWidget *parent, bool isVertical)
|
||||
selectionLayout->addWidget(m_cornerWidgetContainer, 0);
|
||||
|
||||
m_modesStack = new QStackedLayout;
|
||||
m_statusBar = new QStatusBar;
|
||||
m_statusBar = new QStatusBar;
|
||||
m_statusBar->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Fixed);
|
||||
|
||||
QVBoxLayout *vlayout = new QVBoxLayout;
|
||||
vlayout->setMargin(0);
|
||||
vlayout->setSpacing(0);
|
||||
vlayout->addLayout(m_modesStack);
|
||||
if (!isVertical) {
|
||||
vlayout->addWidget(m_selectionWidget);
|
||||
}
|
||||
// vlayout->addWidget(m_statusBar); //status bar is not used for now
|
||||
vlayout->addWidget(m_statusBar);
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->setMargin(0);
|
||||
mainLayout->setSpacing(1);
|
||||
if (isVertical) {
|
||||
mainLayout->addWidget(m_selectionWidget);
|
||||
}
|
||||
mainLayout->addWidget(m_selectionWidget);
|
||||
mainLayout->addLayout(vlayout);
|
||||
setLayout(mainLayout);
|
||||
|
||||
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)
|
||||
{
|
||||
m_modesStack->insertWidget(index, tab);
|
||||
@ -421,17 +448,9 @@ void FancyTabWidget::removeTab(int 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)
|
||||
{
|
||||
QPalette pal = m_tabBar->palette();
|
||||
|
||||
pal.setBrush(QPalette::Mid, brush);
|
||||
m_tabBar->setPalette(pal);
|
||||
pal = m_cornerWidgetContainer->palette();
|
||||
@ -442,19 +461,24 @@ void FancyTabWidget::setBackgroundBrush(const QBrush &brush)
|
||||
void FancyTabWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
Q_UNUSED(event)
|
||||
QPainter p(this);
|
||||
if (m_selectionWidget->isVisible()) {
|
||||
QPainter painter(this);
|
||||
|
||||
QRect rect = m_selectionWidget->geometry().adjusted(0, 0, 1, 0);
|
||||
rect = style()->visualRect(layoutDirection(), geometry(), rect);
|
||||
Utils::StyleHelper::verticalGradient(&p, rect, rect);
|
||||
p.setPen(Utils::StyleHelper::borderColor());
|
||||
p.drawLine(rect.topLeft(), rect.topRight());
|
||||
QRect rect = m_selectionWidget->rect().adjusted(0, 0, 1, 0);
|
||||
rect = style()->visualRect(layoutDirection(), geometry(), rect);
|
||||
Utils::StyleHelper::verticalGradient(&painter, rect, rect);
|
||||
painter.setPen(Utils::StyleHelper::borderColor());
|
||||
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)
|
||||
{
|
||||
QHBoxLayout *layout = static_cast<QHBoxLayout *>(m_cornerWidgetContainer->layout());
|
||||
|
||||
QVBoxLayout *layout = static_cast<QVBoxLayout *>(m_cornerWidgetContainer->layout());
|
||||
layout->insertWidget(pos, widget);
|
||||
}
|
||||
|
||||
@ -480,13 +504,13 @@ QStatusBar *FancyTabWidget::statusBar() const
|
||||
|
||||
void FancyTabWidget::setCurrentIndex(int index)
|
||||
{
|
||||
m_tabBar->setCurrentIndex(index);
|
||||
if (m_tabBar->isTabEnabled(index))
|
||||
m_tabBar->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
void FancyTabWidget::showWidget(int index)
|
||||
{
|
||||
emit currentAboutToShow(index);
|
||||
|
||||
m_modesStack->setCurrentIndex(index);
|
||||
emit currentChanged(index);
|
||||
}
|
||||
@ -495,3 +519,13 @@ void FancyTabWidget::setTabToolTip(int index, const QString &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
|
||||
#define FANCYTABWIDGET_H
|
||||
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QTabBar>
|
||||
#include <QtGui/QStyleOptionTabV2>
|
||||
#include <QtCore/QTimeLine>
|
||||
#include <QIcon>
|
||||
#include <QWidget>
|
||||
|
||||
#include <QTimer>
|
||||
#include <QPropertyAnimation>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPainter;
|
||||
@ -42,17 +43,40 @@ QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
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 toolTip;
|
||||
bool enabled;
|
||||
|
||||
private:
|
||||
QPropertyAnimation animator;
|
||||
QWidget *tabbar;
|
||||
float m_fader;
|
||||
};
|
||||
|
||||
class FancyTabBar : public QWidget {
|
||||
class FancyTabBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
FancyTabBar(QWidget *parent = 0, bool isVertical = false);
|
||||
FancyTabBar(QWidget *parent = 0);
|
||||
~FancyTabBar();
|
||||
|
||||
bool event(QEvent *event);
|
||||
@ -63,85 +87,62 @@ public:
|
||||
void mouseMoveEvent(QMouseEvent *);
|
||||
void enterEvent(QEvent *);
|
||||
void leaveEvent(QEvent *);
|
||||
bool validIndex(int index) const { return index >= 0 && index < m_tabs.count(); }
|
||||
|
||||
QSize sizeHint() const;
|
||||
QSize minimumSizeHint() const;
|
||||
|
||||
void insertTab(int index, const QIcon &icon, const QString &label)
|
||||
{
|
||||
FancyTab tab;
|
||||
void setTabEnabled(int index, bool enable);
|
||||
bool isTabEnabled(int index) const;
|
||||
|
||||
tab.icon = icon;
|
||||
tab.text = label;
|
||||
void insertTab(int index, const QIcon &icon, const QString &label) {
|
||||
FancyTab *tab = new FancyTab(this);
|
||||
tab->icon = icon;
|
||||
tab->text = label;
|
||||
m_tabs.insert(index, tab);
|
||||
updateGeometry();
|
||||
}
|
||||
void removeTab(int index)
|
||||
{
|
||||
m_tabs.removeAt(index);
|
||||
if (m_currentIndex >= m_tabs.length()) {
|
||||
m_currentIndex = m_tabs.length() - 1;
|
||||
}
|
||||
void setEnabled(int index, bool enabled);
|
||||
void removeTab(int index) {
|
||||
FancyTab *tab = m_tabs.takeAt(index);
|
||||
delete tab;
|
||||
updateGeometry();
|
||||
}
|
||||
void updateTabNameIcon(int index, const QIcon &icon, const QString &label);
|
||||
void setCurrentIndex(int index);
|
||||
int currentIndex() const
|
||||
{
|
||||
return m_currentIndex;
|
||||
}
|
||||
int currentIndex() const { return m_currentIndex; }
|
||||
|
||||
void setTabToolTip(int index, QString toolTip)
|
||||
{
|
||||
m_tabs[index].toolTip = toolTip;
|
||||
}
|
||||
QString tabToolTip(int index) const
|
||||
{
|
||||
return m_tabs.at(index).toolTip;
|
||||
}
|
||||
void setTabToolTip(int index, QString toolTip) { m_tabs[index]->toolTip = toolTip; }
|
||||
QString tabToolTip(int index) const { return m_tabs.at(index)->toolTip; }
|
||||
|
||||
void setIconSize(int s)
|
||||
{
|
||||
iconSize = s;
|
||||
}
|
||||
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();
|
||||
}
|
||||
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;
|
||||
|
||||
|
||||
signals:
|
||||
void currentChanged(int);
|
||||
|
||||
public slots:
|
||||
void updateHover();
|
||||
void emitCurrentIndex();
|
||||
|
||||
private:
|
||||
static const int m_rounding;
|
||||
static const int m_textPadding;
|
||||
QTimeLine m_hoverControl;
|
||||
QRect m_hoverRect;
|
||||
int m_hoverIndex;
|
||||
int m_currentIndex;
|
||||
int iconSize;
|
||||
QList<FancyTab> m_tabs;
|
||||
bool verticalTabs;
|
||||
|
||||
QList<FancyTab*> m_tabs;
|
||||
QTimer m_triggerTimer;
|
||||
QSize tabSizeHint(bool minimum = false) const;
|
||||
|
||||
};
|
||||
|
||||
class FancyTabWidget : public QWidget {
|
||||
class FancyTabWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
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 removeTab(int index);
|
||||
@ -150,23 +151,24 @@ public:
|
||||
void insertCornerWidget(int pos, QWidget *widget);
|
||||
int cornerWidgetCount() const;
|
||||
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);
|
||||
|
||||
int currentIndex() const;
|
||||
QStatusBar *statusBar() const;
|
||||
|
||||
void setTabEnabled(int index, bool enable);
|
||||
bool isTabEnabled(int index) const;
|
||||
|
||||
bool isSelectionWidgetVisible() const;
|
||||
|
||||
signals:
|
||||
void currentAboutToShow(int index);
|
||||
void currentChanged(int index);
|
||||
|
||||
public slots:
|
||||
void setCurrentIndex(int index);
|
||||
void setSelectionWidgetVisible(bool visible);
|
||||
|
||||
private slots:
|
||||
void showWidget(int index);
|
||||
@ -178,6 +180,7 @@ private:
|
||||
QWidget *m_selectionWidget;
|
||||
QStatusBar *m_statusBar;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Core
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include <utils/qtcolorbutton.h>
|
||||
#include <utils/consoleprocess.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QMessageBox>
|
||||
#include <QtCore/QDir>
|
||||
|
||||
#include <QtCore/QLibraryInfo>
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
#include <QSettings>
|
||||
|
||||
namespace Core {
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
#include <coreplugin/icontext.h>
|
||||
#include <coreplugin/core_global.h>
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QComboBox>
|
||||
#include <QtCore/QSettings>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "core_global.h"
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtGui/QIcon>
|
||||
#include <QIcon>
|
||||
#include <QSettings>
|
||||
#include "uavconfiginfo.h"
|
||||
|
||||
|
@ -40,8 +40,6 @@
|
||||
#include "mimedatabase.h"
|
||||
#include "outputpane.h"
|
||||
#include "plugindialog.h"
|
||||
#include "qxtlogger.h"
|
||||
#include "qxtbasicstdloggerengine.h"
|
||||
#include "shortcutsettings.h"
|
||||
#include "uavgadgetmanager.h"
|
||||
#include "uavgadgetinstancemanager.h"
|
||||
@ -74,18 +72,19 @@
|
||||
#include <QtCore/QtPlugin>
|
||||
#include <QtCore/QUrl>
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QCloseEvent>
|
||||
#include <QtGui/QMenu>
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QtGui/QShortcut>
|
||||
#include <QtGui/QStatusBar>
|
||||
#include <QtGui/QWizard>
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QtGui/QMessageBox>
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QCloseEvent>
|
||||
#include <QMenu>
|
||||
#include <QPixmap>
|
||||
#include <QShortcut>
|
||||
#include <QStatusBar>
|
||||
#include <QWizard>
|
||||
#include <QToolButton>
|
||||
#include <QMessageBox>
|
||||
#include <QDesktopServices>
|
||||
#include <QElapsedTimer>
|
||||
#include <QDir>
|
||||
#include <QMimeData>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
@ -190,11 +189,6 @@ MainWindow::MainWindow() :
|
||||
connect(m_modeManager, SIGNAL(newModeOrder(QVector<IMode *>)), m_workspaceSettings, SLOT(newModeOrder(QVector<IMode *>)));
|
||||
statusBar()->setProperty("p_styled", true);
|
||||
setAcceptDrops(true);
|
||||
foreach(QString engine, qxtLog->allLoggerEngines())
|
||||
qxtLog->removeLoggerEngine(engine);
|
||||
qxtLog->addLoggerEngine("std", new QxtBasicSTDLoggerEngine());
|
||||
qxtLog->installAsMessageHandler();
|
||||
qxtLog->enableAllLogLevels();
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
@ -206,9 +200,6 @@ MainWindow::~MainWindow()
|
||||
|
||||
hide();
|
||||
|
||||
qxtLog->removeAsMessageHandler();
|
||||
foreach(QString engine, qxtLog->allLoggerEngines())
|
||||
qxtLog->removeLoggerEngine(engine);
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
if (m_uavGadgetManagers.count() > 0) {
|
||||
foreach(UAVGadgetManager * mode, m_uavGadgetManagers) {
|
||||
|
@ -30,47 +30,39 @@
|
||||
|
||||
#include "styleanimator.h"
|
||||
|
||||
#include <QtCore/QLibrary>
|
||||
#include <coreplugin/coreconstants.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
#include <utils/stylehelper.h>
|
||||
|
||||
#include <QtGui/QApplication>
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QtGui/QDialog>
|
||||
#include <QtGui/QDialogButtonBox>
|
||||
#include <QtGui/QDockWidget>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QLineEdit>
|
||||
#include <QtGui/QMainWindow>
|
||||
#include <QtGui/QMenuBar>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QPixmap>
|
||||
#include <QtGui/QPixmapCache>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QtGui/QScrollArea>
|
||||
#include <QtGui/QSplitter>
|
||||
#include <QtGui/QStatusBar>
|
||||
#include <QtGui/QStyleFactory>
|
||||
#include <QtGui/QStyleOption>
|
||||
#include <QtGui/QToolBar>
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QtGui/QAbstractItemView>
|
||||
#include <utils/fancymainwindow.h>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QComboBox>
|
||||
#include <QDockWidget>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMenuBar>
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
#include <QStatusBar>
|
||||
#include <QStyleFactory>
|
||||
#include <QStyleOption>
|
||||
#include <QToolBar>
|
||||
#include <QToolButton>
|
||||
|
||||
// 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
|
||||
// we have a custom property that is inherited
|
||||
bool styleEnabled(const QWidget *widget)
|
||||
{
|
||||
const QWidget *p = widget;
|
||||
|
||||
while (p) {
|
||||
if (p->property("_q_custom_style_disabled").toBool()) {
|
||||
if (p->property("_q_custom_style_disabled").toBool())
|
||||
return false;
|
||||
}
|
||||
p = p->parentWidget();
|
||||
p = p->parentWidget();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -78,53 +70,77 @@ bool styleEnabled(const QWidget *widget)
|
||||
// Consider making this a QStyle state
|
||||
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) {
|
||||
if (qobject_cast<const QToolBar *>(p) && styleEnabled(p)) {
|
||||
return true;
|
||||
} else if (qobject_cast<const QStatusBar *>(p) && styleEnabled(p)) {
|
||||
return true;
|
||||
} else if (qobject_cast<const QMenuBar *>(p) && styleEnabled(p)) {
|
||||
return true;
|
||||
} else if (p->property("panelwidget").toBool()) {
|
||||
return true;
|
||||
}
|
||||
if (qobject_cast<const QToolBar *>(p) ||
|
||||
qobject_cast<const QStatusBar *>(p) ||
|
||||
qobject_cast<const QMenuBar *>(p) ||
|
||||
p->property("panelwidget").toBool())
|
||||
return styleEnabled(widget);
|
||||
p = p->parentWidget();
|
||||
}
|
||||
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:
|
||||
ManhattanStylePrivate(const QString &baseStyleName)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
explicit ManhattanStylePrivate();
|
||||
void init();
|
||||
|
||||
public:
|
||||
QStyle *style;
|
||||
QImage lineeditImage;
|
||||
QImage lineeditImage_disabled;
|
||||
|
||||
const QImage lineeditImage;
|
||||
const QImage lineeditImage_disabled;
|
||||
const QPixmap extButtonPixmap;
|
||||
const QPixmap closeButtonPixmap;
|
||||
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)
|
||||
: QWindowsStyle(), d(new ManhattanStylePrivate(baseStyleName))
|
||||
{}
|
||||
: QProxyStyle(QStyleFactory::create(baseStyleName)),
|
||||
d(new ManhattanStylePrivate())
|
||||
{
|
||||
}
|
||||
|
||||
ManhattanStyle::~ManhattanStyle()
|
||||
{
|
||||
@ -132,175 +148,74 @@ ManhattanStyle::~ManhattanStyle()
|
||||
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 result;
|
||||
|
||||
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);
|
||||
return QProxyStyle::generatedIconPixmap(iconMode, pixmap, opt);
|
||||
}
|
||||
|
||||
QSize ManhattanStyle::sizeFromContents(ContentsType type, const QStyleOption *option,
|
||||
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);
|
||||
} else if (type == CT_ComboBox && panelWidget(widget)) {
|
||||
else if (type == CT_ComboBox && panelWidget(widget))
|
||||
newSize += QSize(14, 0);
|
||||
}
|
||||
return newSize;
|
||||
}
|
||||
|
||||
QRect ManhattanStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
|
||||
{
|
||||
QRect rect;
|
||||
|
||||
rect = d->style->subElementRect(element, option, widget);
|
||||
return rect;
|
||||
return QProxyStyle::subElementRect(element, option, widget);
|
||||
}
|
||||
|
||||
QRect ManhattanStyle::subControlRect(ComplexControl control, const QStyleOptionComplex *option,
|
||||
SubControl subControl, const QWidget *widget) const
|
||||
{
|
||||
QRect rect;
|
||||
|
||||
#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;
|
||||
return QProxyStyle::subControlRect(control, option, subControl, widget);
|
||||
}
|
||||
|
||||
QStyle::SubControl ManhattanStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option,
|
||||
const QPoint &pos, const QWidget *widget) const
|
||||
{
|
||||
SubControl result = QStyle::SC_None;
|
||||
|
||||
result = d->style->hitTestComplexControl(control, option, pos, widget);
|
||||
return result;
|
||||
return QProxyStyle::hitTestComplexControl(control, option, pos, widget);
|
||||
}
|
||||
|
||||
int ManhattanStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
retval = d->style->pixelMetric(metric, option, widget);
|
||||
retval = QProxyStyle::pixelMetric(metric, option, widget);
|
||||
switch (metric) {
|
||||
case PM_SplitterWidth:
|
||||
if (widget && widget->property("minisplitter").toBool()) {
|
||||
if (widget && widget->property("minisplitter").toBool())
|
||||
retval = 1;
|
||||
}
|
||||
break;
|
||||
case PM_ToolBarIconSize:
|
||||
if (panelWidget(widget)) {
|
||||
if (panelWidget(widget))
|
||||
retval = 16;
|
||||
}
|
||||
break;
|
||||
case PM_DockWidgetHandleExtent:
|
||||
case PM_DockWidgetSeparatorExtent:
|
||||
return 1;
|
||||
case PM_MenuPanelWidth:
|
||||
case PM_MenuBarHMargin:
|
||||
case PM_MenuBarVMargin:
|
||||
case PM_ToolBarFrameWidth:
|
||||
if (panelWidget(widget)) {
|
||||
if (panelWidget(widget))
|
||||
retval = 1;
|
||||
}
|
||||
break;
|
||||
case PM_ButtonShiftVertical:
|
||||
case PM_ButtonShiftHorizontal:
|
||||
case PM_MenuBarPanelWidth:
|
||||
case PM_ToolBarItemMargin:
|
||||
case PM_ToolBarItemSpacing:
|
||||
if (panelWidget(widget)) {
|
||||
if (panelWidget(widget))
|
||||
retval = 0;
|
||||
}
|
||||
break;
|
||||
case PM_DefaultFrameWidth:
|
||||
if (qobject_cast<const QLineEdit *>(widget) && panelWidget(widget)) {
|
||||
if (qobject_cast<const QLineEdit*>(widget) && panelWidget(widget))
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -310,27 +225,23 @@ int ManhattanStyle::pixelMetric(PixelMetric metric, const QStyleOption *option,
|
||||
|
||||
QPalette ManhattanStyle::standardPalette() const
|
||||
{
|
||||
QPalette result;
|
||||
|
||||
result = d->style->standardPalette();
|
||||
return result;
|
||||
return QProxyStyle::standardPalette();
|
||||
}
|
||||
|
||||
void ManhattanStyle::polish(QApplication *app)
|
||||
{
|
||||
d->style->polish(app);
|
||||
return QProxyStyle::polish(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;
|
||||
|
||||
pal.setBrush(QPalette::All, QPalette::WindowText, color);
|
||||
pal.setBrush(QPalette::All, QPalette::ButtonText, color);
|
||||
pal.setBrush(QPalette::All, QPalette::Foreground, color);
|
||||
@ -343,29 +254,37 @@ QPalette panelPalette(const QPalette &oldPalette)
|
||||
|
||||
void ManhattanStyle::polish(QWidget *widget)
|
||||
{
|
||||
d->style->polish(widget);
|
||||
QProxyStyle::polish(widget);
|
||||
|
||||
// OxygenStyle forces a rounded widget mask on toolbars
|
||||
if (d->style->inherits("OxygenStyle")) {
|
||||
if (qobject_cast<QToolBar *>(widget)) {
|
||||
widget->removeEventFilter(d->style);
|
||||
// OxygenStyle forces a rounded widget mask on toolbars and dock widgets
|
||||
if (baseStyle()->inherits("OxygenStyle") || baseStyle()->inherits("Oxygen::Style")) {
|
||||
if (qobject_cast<QToolBar*>(widget) || qobject_cast<QDockWidget*>(widget)) {
|
||||
widget->removeEventFilter(baseStyle());
|
||||
widget->setContentsMargins(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
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);
|
||||
if (qobject_cast<QToolButton *>(widget)) {
|
||||
if (qobject_cast<QToolButton*>(widget)) {
|
||||
widget->setAttribute(Qt::WA_Hover);
|
||||
widget->setMaximumHeight(Utils::StyleHelper::navigationWidgetHeight() - 2);
|
||||
} else if (qobject_cast<QLineEdit *>(widget)) {
|
||||
}
|
||||
else if (qobject_cast<QLineEdit*>(widget)) {
|
||||
widget->setAttribute(Qt::WA_Hover);
|
||||
widget->setMaximumHeight(Utils::StyleHelper::navigationWidgetHeight() - 2);
|
||||
} else if (qobject_cast<QLabel *>(widget)) {
|
||||
}
|
||||
else if (qobject_cast<QLabel*>(widget))
|
||||
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());
|
||||
} else if (qobject_cast<QStatusBar *>(widget)) {
|
||||
else if (qobject_cast<QStatusBar*>(widget))
|
||||
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->setAttribute(Qt::WA_Hover);
|
||||
}
|
||||
@ -374,36 +293,32 @@ void ManhattanStyle::polish(QWidget *widget)
|
||||
|
||||
void ManhattanStyle::unpolish(QWidget *widget)
|
||||
{
|
||||
d->style->unpolish(widget);
|
||||
QProxyStyle::unpolish(widget);
|
||||
if (panelWidget(widget)) {
|
||||
widget->setAttribute(Qt::WA_LayoutUsesWidgetRect, false);
|
||||
if (qobject_cast<QTabBar *>(widget)) {
|
||||
if (qobject_cast<QTabBar*>(widget))
|
||||
widget->setAttribute(Qt::WA_Hover, false);
|
||||
} else if (qobject_cast<QToolBar *>(widget)) {
|
||||
else if (qobject_cast<QToolBar*>(widget))
|
||||
widget->setAttribute(Qt::WA_Hover, false);
|
||||
} else if (qobject_cast<QComboBox *>(widget)) {
|
||||
else if (qobject_cast<QComboBox*>(widget))
|
||||
widget->setAttribute(Qt::WA_Hover, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ManhattanStyle::polish(QPalette &pal)
|
||||
{
|
||||
d->style->polish(pal);
|
||||
QProxyStyle::polish(pal);
|
||||
}
|
||||
|
||||
QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
|
||||
const QWidget *widget) const
|
||||
QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const
|
||||
{
|
||||
QIcon icon;
|
||||
|
||||
switch (standardIcon) {
|
||||
case QStyle::SP_TitleBarCloseButton:
|
||||
case QStyle::SP_ToolBarHorizontalExtensionButton:
|
||||
return QIcon(standardPixmap(standardIcon, option, widget));
|
||||
|
||||
default:
|
||||
icon = d->style->standardIcon(standardIcon, option, widget);
|
||||
icon = baseStyle()->standardIcon(standardIcon, option, widget);
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
@ -411,47 +326,40 @@ QIcon ManhattanStyle::standardIconImplementation(StandardPixmap standardIcon, co
|
||||
QPixmap ManhattanStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
|
||||
const QWidget *widget) const
|
||||
{
|
||||
if (widget && !panelWidget(widget)) {
|
||||
return d->style->standardPixmap(standardPixmap, opt, widget);
|
||||
}
|
||||
if (widget && !panelWidget(widget))
|
||||
return QProxyStyle::standardPixmap(standardPixmap, opt, widget);
|
||||
|
||||
QPixmap pixmap;
|
||||
switch (standardPixmap) {
|
||||
case QStyle::SP_ToolBarHorizontalExtensionButton:
|
||||
{
|
||||
static const QPixmap extButton(":/core/images/extension.png");
|
||||
pixmap = extButton;
|
||||
}
|
||||
break;
|
||||
pixmap = d->extButtonPixmap;
|
||||
break;
|
||||
case QStyle::SP_TitleBarCloseButton:
|
||||
{
|
||||
static const QPixmap closeButton(":/core/images/closebutton.png");
|
||||
pixmap = closeButton;
|
||||
}
|
||||
break;
|
||||
pixmap = d->closeButtonPixmap;
|
||||
break;
|
||||
default:
|
||||
pixmap = d->style->standardPixmap(standardPixmap, opt, widget);
|
||||
pixmap = QProxyStyle::standardPixmap(standardPixmap, opt, widget);
|
||||
break;
|
||||
}
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
|
||||
int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget,
|
||||
QStyleHintReturn *returnData) const
|
||||
{
|
||||
int ret = d->style->styleHint(hint, option, widget, returnData);
|
||||
|
||||
int ret = QProxyStyle::styleHint(hint, option, widget, returnData);
|
||||
switch (hint) {
|
||||
// Make project explorer alternate rows all the way
|
||||
case QStyle::SH_ItemView_PaintAlternatingRowColorsForEmptyArea:
|
||||
if (widget && widget->property("AlternateEmpty").toBool()) {
|
||||
if (widget && widget->property("AlternateEmpty").toBool())
|
||||
ret = true;
|
||||
}
|
||||
break;
|
||||
case QStyle::SH_EtchDisabledText:
|
||||
if (panelWidget(widget)) {
|
||||
if (panelWidget(widget))
|
||||
ret = false;
|
||||
}
|
||||
break;
|
||||
case QStyle::SH_ItemView_ArrowKeysNavigateIntoChildren:
|
||||
ret = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -462,17 +370,16 @@ int ManhattanStyle::styleHint(StyleHint hint, const QStyleOption *option, const
|
||||
void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
|
||||
QPainter *painter, const QWidget *widget) const
|
||||
{
|
||||
if (!panelWidget(widget)) {
|
||||
return d->style->drawPrimitive(element, option, painter, widget);
|
||||
}
|
||||
if (!panelWidget(widget))
|
||||
return QProxyStyle::drawPrimitive(element, option, painter, widget);
|
||||
|
||||
bool animating = (option->state & State_Animating);
|
||||
int state = option->state;
|
||||
QRect rect = option->rect;
|
||||
QRect rect = option->rect;
|
||||
QRect oldRect;
|
||||
QRect newRect;
|
||||
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();
|
||||
oldRect = w->property("_q_stylerect").toRect();
|
||||
newRect = w->rect();
|
||||
@ -480,9 +387,10 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
|
||||
w->setProperty("_q_stylerect", w->rect());
|
||||
|
||||
// Determine the animated transition
|
||||
bool doTransition = ((state & State_On) != (oldState & State_On) ||
|
||||
(state & State_MouseOver) != (oldState & State_MouseOver));
|
||||
if (oldRect != newRect) {
|
||||
bool doTransition = ((state & State_On) != (oldState & State_On) ||
|
||||
(state & State_MouseOver) != (oldState & State_MouseOver));
|
||||
if (oldRect != newRect)
|
||||
{
|
||||
doTransition = false;
|
||||
d->animator.stopAnimation(widget);
|
||||
}
|
||||
@ -490,10 +398,10 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
|
||||
if (doTransition) {
|
||||
QImage startImage(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;
|
||||
opt.state = (QStyle::State)oldState;
|
||||
opt.state |= (State)State_Animating;
|
||||
opt.state = (QStyle::State)oldState;
|
||||
opt.state |= State_Animating;
|
||||
startImage.fill(0);
|
||||
Transition *t = new Transition;
|
||||
t->setWidget(w);
|
||||
@ -505,253 +413,186 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
|
||||
d->animator.stopAnimation(widget);
|
||||
}
|
||||
QStyleOption endOpt = *option;
|
||||
endOpt.state |= (State)State_Animating;
|
||||
endOpt.state |= State_Animating;
|
||||
t->setStartImage(startImage);
|
||||
d->animator.startAnimation(t);
|
||||
endImage.fill(0);
|
||||
QPainter endPainter(&endImage);
|
||||
drawPrimitive(element, &endOpt, &endPainter, widget);
|
||||
t->setEndImage(endImage);
|
||||
if (oldState & State_MouseOver) {
|
||||
if (oldState & State_MouseOver)
|
||||
t->setDuration(150);
|
||||
} else {
|
||||
else
|
||||
t->setDuration(75);
|
||||
}
|
||||
t->setStartTime(QTime::currentTime());
|
||||
}
|
||||
}
|
||||
|
||||
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:
|
||||
{
|
||||
painter->save();
|
||||
{
|
||||
painter->save();
|
||||
|
||||
// Fill the line edit background
|
||||
QRect filledRect = option->rect.adjusted(1, 1, -1, -1);
|
||||
painter->setBrushOrigin(filledRect.topLeft());
|
||||
painter->fillRect(filledRect, option->palette.base());
|
||||
// Fill the line edit background
|
||||
QRect filledRect = option->rect.adjusted(1, 1, -1, -1);
|
||||
painter->setBrushOrigin(filledRect.topLeft());
|
||||
painter->fillRect(filledRect, option->palette.base());
|
||||
|
||||
if (option->state & State_Enabled) {
|
||||
drawCornerImage(d->lineeditImage, painter, option->rect, 2, 2, 2, 2);
|
||||
} else {
|
||||
drawCornerImage(d->lineeditImage_disabled, painter, option->rect, 2, 2, 2, 2);
|
||||
}
|
||||
if (option->state & State_Enabled)
|
||||
Utils::StyleHelper::drawCornerImage(d->lineeditImage, painter, option->rect, 5, 5, 5, 5);
|
||||
else
|
||||
Utils::StyleHelper::drawCornerImage(d->lineeditImage_disabled, painter, option->rect, 5, 5, 5, 5);
|
||||
|
||||
if (option->state & State_HasFocus || option->state & State_MouseOver) {
|
||||
QColor hover = Utils::StyleHelper::baseColor();
|
||||
if (state & State_HasFocus) {
|
||||
hover.setAlpha(100);
|
||||
} else {
|
||||
hover.setAlpha(50);
|
||||
if (option->state & State_HasFocus || option->state & State_MouseOver) {
|
||||
QColor hover = Utils::StyleHelper::baseColor();
|
||||
if (state & State_HasFocus)
|
||||
hover.setAlpha(100);
|
||||
else
|
||||
hover.setAlpha(50);
|
||||
|
||||
painter->setPen(QPen(hover, 1));
|
||||
painter->drawRect(option->rect.adjusted(1, 1, -2 ,-2));
|
||||
}
|
||||
|
||||
painter->setPen(QPen(hover, 1));
|
||||
painter->drawRect(option->rect.adjusted(1, 1, -2, -2));
|
||||
painter->restore();
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case PE_FrameStatusBarItem:
|
||||
break;
|
||||
|
||||
case PE_PanelButtonTool:
|
||||
{
|
||||
Animation *anim = d->animator.widgetAnimation(widget);
|
||||
if (!animating && anim) {
|
||||
anim->paint(painter, option);
|
||||
} else {
|
||||
bool pressed = option->state & State_Sunken || option->state & State_On;
|
||||
QColor shadow(0, 0, 0, 30);
|
||||
painter->setPen(shadow);
|
||||
if (pressed) {
|
||||
QColor shade(0, 0, 0, 40);
|
||||
painter->fillRect(rect, shade);
|
||||
painter->drawLine(rect.topLeft() + QPoint(1, 0), rect.topRight() - QPoint(1, 0));
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
// painter->drawLine(rect.bottomLeft() + QPoint(1, 0), rect.bottomRight() - QPoint(1, 0));
|
||||
QColor highlight(255, 255, 255, 30);
|
||||
painter->setPen(highlight);
|
||||
} else if (option->state & State_Enabled &&
|
||||
option->state & State_MouseOver) {
|
||||
QColor lighter(255, 255, 255, 37);
|
||||
painter->fillRect(rect, lighter);
|
||||
}
|
||||
case PE_PanelButtonTool: {
|
||||
Animation *anim = d->animator.widgetAnimation(widget);
|
||||
if (!animating && anim) {
|
||||
anim->paint(painter, option);
|
||||
} else {
|
||||
bool pressed = option->state & State_Sunken || option->state & State_On;
|
||||
QColor shadow(0, 0, 0, 30);
|
||||
painter->setPen(shadow);
|
||||
if (pressed) {
|
||||
QColor shade(0, 0, 0, 40);
|
||||
painter->fillRect(rect, shade);
|
||||
painter->drawLine(rect.topLeft() + QPoint(1, 0), rect.topRight() - QPoint(1, 0));
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
// painter->drawLine(rect.bottomLeft() + QPoint(1, 0), rect.bottomRight() - QPoint(1, 0));
|
||||
QColor highlight(255, 255, 255, 30);
|
||||
painter->setPen(highlight);
|
||||
}
|
||||
else if (option->state & State_Enabled &&
|
||||
option->state & State_MouseOver) {
|
||||
QColor lighter(255, 255, 255, 37);
|
||||
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:
|
||||
{
|
||||
painter->save();
|
||||
QLinearGradient grad(option->rect.topLeft(), QPoint(rect.center().x(), rect.bottom()));
|
||||
QColor startColor = Utils::StyleHelper::shadowColor().darker(164);
|
||||
QColor endColor = Utils::StyleHelper::baseColor().darker(130);
|
||||
grad.setColorAt(0, startColor);
|
||||
grad.setColorAt(1, endColor);
|
||||
painter->fillRect(option->rect, grad);
|
||||
painter->setPen(QColor(255, 255, 255, 60));
|
||||
painter->drawLine(rect.topLeft() + QPoint(0, 1),
|
||||
rect.topRight() + QPoint(0, 1));
|
||||
painter->setPen(Utils::StyleHelper::borderColor().darker(110));
|
||||
painter->drawLine(rect.topLeft(), rect.topRight());
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
{
|
||||
painter->save();
|
||||
QLinearGradient grad = Utils::StyleHelper::statusBarGradient(rect);
|
||||
painter->fillRect(rect, grad);
|
||||
painter->setPen(QColor(255, 255, 255, 60));
|
||||
painter->drawLine(rect.topLeft() + QPoint(0,1),
|
||||
rect.topRight()+ QPoint(0,1));
|
||||
painter->setPen(Utils::StyleHelper::borderColor().darker(110));
|
||||
painter->drawLine(rect.topLeft(), rect.topRight());
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
|
||||
case PE_IndicatorToolBarSeparator:
|
||||
{
|
||||
QColor separatorColor = Utils::StyleHelper::borderColor();
|
||||
separatorColor.setAlpha(100);
|
||||
painter->setPen(separatorColor);
|
||||
const int margin = 6;
|
||||
if (option->state & State_Horizontal) {
|
||||
const int offset = rect.width() / 2;
|
||||
painter->drawLine(rect.bottomLeft().x() + offset,
|
||||
rect.bottomLeft().y() - margin,
|
||||
rect.topLeft().x() + offset,
|
||||
rect.topLeft().y() + margin);
|
||||
} else { // Draw vertical separator
|
||||
const int offset = rect.height() / 2;
|
||||
painter->setPen(QPen(option->palette.background().color().darker(110)));
|
||||
painter->drawLine(rect.topLeft().x() + margin,
|
||||
rect.topLeft().y() + offset,
|
||||
rect.topRight().x() - margin,
|
||||
rect.topRight().y() + offset);
|
||||
{
|
||||
QColor separatorColor = Utils::StyleHelper::borderColor();
|
||||
separatorColor.setAlpha(100);
|
||||
painter->setPen(separatorColor);
|
||||
const int margin = 6;
|
||||
if (option->state & State_Horizontal) {
|
||||
const int offset = rect.width()/2;
|
||||
painter->drawLine(rect.bottomLeft().x() + offset,
|
||||
rect.bottomLeft().y() - margin,
|
||||
rect.topLeft().x() + offset,
|
||||
rect.topLeft().y() + margin);
|
||||
} else { //Draw vertical separator
|
||||
const int offset = rect.height()/2;
|
||||
painter->setPen(QPen(option->palette.background().color().darker(110)));
|
||||
painter->drawLine(rect.topLeft().x() + margin ,
|
||||
rect.topLeft().y() + offset,
|
||||
rect.topRight().x() - margin,
|
||||
rect.topRight().y() + offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case PE_IndicatorToolBarHandle:
|
||||
{
|
||||
bool horizontal = option->state & State_Horizontal;
|
||||
painter->save();
|
||||
QPainterPath path;
|
||||
int x = option->rect.x() + horizontal ? 2 : 6;
|
||||
int y = option->rect.y() + horizontal ? 6 : 2;
|
||||
static const int RectHeight = 2;
|
||||
if (horizontal) {
|
||||
while (y < option->rect.height() - RectHeight - 6) {
|
||||
path.moveTo(x, y);
|
||||
path.addRect(x, y, RectHeight, RectHeight);
|
||||
y += 6;
|
||||
}
|
||||
} else {
|
||||
while (x < option->rect.width() - RectHeight - 6) {
|
||||
path.moveTo(x, y);
|
||||
path.addRect(x, y, RectHeight, RectHeight);
|
||||
x += 6;
|
||||
{
|
||||
bool horizontal = option->state & State_Horizontal;
|
||||
painter->save();
|
||||
QPainterPath path;
|
||||
int x = option->rect.x() + (horizontal ? 2 : 6);
|
||||
int y = option->rect.y() + (horizontal ? 6 : 2);
|
||||
static const int RectHeight = 2;
|
||||
if (horizontal) {
|
||||
while (y < option->rect.height() - RectHeight - 6) {
|
||||
path.moveTo(x, y);
|
||||
path.addRect(x, y, RectHeight, RectHeight);
|
||||
y += 6;
|
||||
}
|
||||
} else {
|
||||
while (x < option->rect.width() - RectHeight - 6) {
|
||||
path.moveTo(x, y);
|
||||
path.addRect(x, y, RectHeight, RectHeight);
|
||||
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();
|
||||
}
|
||||
|
||||
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;
|
||||
break;
|
||||
case PE_IndicatorArrowUp:
|
||||
case PE_IndicatorArrowDown:
|
||||
case PE_IndicatorArrowRight:
|
||||
case PE_IndicatorArrowLeft:
|
||||
{
|
||||
// From windowsstyle but modified to enable AA
|
||||
if (option->rect.width() <= 1 || option->rect.height() <= 1) {
|
||||
break;
|
||||
{
|
||||
Utils::StyleHelper::drawArrow(element, painter, option);
|
||||
}
|
||||
|
||||
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;
|
||||
break;
|
||||
|
||||
default:
|
||||
d->style->drawPrimitive(element, option, painter, widget);
|
||||
QProxyStyle::drawPrimitive(element, option, painter, widget);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -759,20 +600,43 @@ void ManhattanStyle::drawPrimitive(PrimitiveElement element, const QStyleOption
|
||||
void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *option,
|
||||
QPainter *painter, const QWidget *widget) const
|
||||
{
|
||||
if (!panelWidget(widget)) {
|
||||
return d->style->drawControl(element, option, painter, widget);
|
||||
}
|
||||
if (!panelWidget(widget))
|
||||
return QProxyStyle::drawControl(element, option, painter, widget);
|
||||
|
||||
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:
|
||||
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);
|
||||
bool act = mbi->state & State_Selected && mbi->state & State_Sunken;
|
||||
bool act = mbi->state & State_Sunken;
|
||||
bool dis = !(mbi->state & State_Enabled);
|
||||
Utils::StyleHelper::menuGradient(painter, option->rect, option->rect);
|
||||
QStyleOptionMenuItem item = *mbi;
|
||||
item.rect = mbi->rect;
|
||||
item.rect = mbi->rect;
|
||||
QPalette pal = mbi->palette;
|
||||
pal.setBrush(QPalette::ButtonText, dis ? Qt::gray : Qt::black);
|
||||
item.palette = pal;
|
||||
@ -797,11 +661,10 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
|
||||
painter->drawPoint(r.topLeft());
|
||||
painter->drawPoint(r.topRight());
|
||||
|
||||
QPalette pal = mbi->palette;
|
||||
QPalette pal = mbi->palette;
|
||||
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;
|
||||
}
|
||||
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);
|
||||
pal.setBrush(QPalette::Text, dis ? Qt::gray : Qt::white);
|
||||
@ -812,156 +675,156 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
|
||||
break;
|
||||
|
||||
case CE_ComboBoxLabel:
|
||||
if (const QStyleOptionComboBox * cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
||||
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
||||
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;
|
||||
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::Disabled;
|
||||
QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
|
||||
: QIcon::Disabled;
|
||||
QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode);
|
||||
QRect iconRect(editRect);
|
||||
iconRect.setWidth(cb->iconSize.width() + 4);
|
||||
iconRect = alignedRect(cb->direction,
|
||||
Qt::AlignLeft | Qt::AlignVCenter,
|
||||
iconRect.size(), editRect);
|
||||
if (cb->editable) {
|
||||
if (cb->editable)
|
||||
painter->fillRect(iconRect, customPal.brush(QPalette::Base));
|
||||
}
|
||||
drawItemPixmap(painter, iconRect, Qt::AlignCenter, pixmap);
|
||||
|
||||
if (cb->direction == Qt::RightToLeft) {
|
||||
if (cb->direction == Qt::RightToLeft)
|
||||
editRect.translate(-4 - cb->iconSize.width(), 0);
|
||||
} else {
|
||||
else
|
||||
editRect.translate(cb->iconSize.width() + 4, 0);
|
||||
}
|
||||
|
||||
// Reserve some space for the down-arrow
|
||||
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());
|
||||
drawItemText(painter, editRect.translated(0, 1),
|
||||
visualAlignment(option->direction, Qt::AlignLeft | Qt::AlignVCenter),
|
||||
customPal, cb->state & State_Enabled, text, QPalette::ButtonText);
|
||||
customPal.setBrush(QPalette::All, QPalette::ButtonText, Utils::StyleHelper::panelTextColor());
|
||||
drawItemText(painter, editRect,
|
||||
visualAlignment(option->direction, Qt::AlignLeft | Qt::AlignVCenter),
|
||||
customPal, cb->state & State_Enabled, text, QPalette::ButtonText);
|
||||
bool notElideAsterisk = widget && widget->property("notelideasterisk").toBool()
|
||||
&& cb->currentText.endsWith(asterisk)
|
||||
&& option->fontMetrics.width(cb->currentText) > elideWidth;
|
||||
|
||||
QString text;
|
||||
if (notElideAsterisk) {
|
||||
elideWidth -= option->fontMetrics.width(asterisk);
|
||||
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 {
|
||||
d->style->drawControl(element, option, painter, widget);
|
||||
QProxyStyle::drawControl(element, option, painter, widget);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CE_SizeGrip:
|
||||
{
|
||||
painter->save();
|
||||
QColor dark = Qt::white;
|
||||
dark.setAlphaF(0.1);
|
||||
int x, y, w, h;
|
||||
option->rect.getRect(&x, &y, &w, &h);
|
||||
int sw = qMin(h, w);
|
||||
if (h > w) {
|
||||
painter->translate(0, h - w);
|
||||
} else {
|
||||
painter->translate(w - h, 0);
|
||||
}
|
||||
int sx = x;
|
||||
int sy = y;
|
||||
int s = 4;
|
||||
painter->setPen(dark);
|
||||
if (option->direction == Qt::RightToLeft) {
|
||||
sx = x + sw;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
painter->drawLine(x, sy, sx, sw);
|
||||
sx -= s;
|
||||
sy += s;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
painter->drawLine(sx, sw, sw, sy);
|
||||
sx += s;
|
||||
sy += s;
|
||||
case CE_SizeGrip: {
|
||||
painter->save();
|
||||
QColor dark = Qt::white;
|
||||
dark.setAlphaF(0.1);
|
||||
int x, y, w, h;
|
||||
option->rect.getRect(&x, &y, &w, &h);
|
||||
int sw = qMin(h, w);
|
||||
if (h > w)
|
||||
painter->translate(0, h - w);
|
||||
else
|
||||
painter->translate(w - h, 0);
|
||||
int sx = x;
|
||||
int sy = y;
|
||||
int s = 4;
|
||||
painter->setPen(dark);
|
||||
if (option->direction == Qt::RightToLeft) {
|
||||
sx = x + sw;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
painter->drawLine(x, sy, sx, sw);
|
||||
sx -= s;
|
||||
sy += s;
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
painter->drawLine(sx, sw, sw, sy);
|
||||
sx += s;
|
||||
sy += s;
|
||||
}
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case CE_MenuBarEmptyArea:
|
||||
{
|
||||
Utils::StyleHelper::menuGradient(painter, option->rect, option->rect);
|
||||
painter->save();
|
||||
painter->setPen(Utils::StyleHelper::borderColor());
|
||||
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
case CE_MenuBarEmptyArea: {
|
||||
Utils::StyleHelper::menuGradient(painter, option->rect, option->rect);
|
||||
painter->save();
|
||||
painter->setPen(Utils::StyleHelper::borderColor());
|
||||
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
|
||||
case CE_ToolBar:
|
||||
{
|
||||
QString key;
|
||||
key.sprintf("mh_toolbar %d %d %d", option->rect.width(), option->rect.height(), Utils::StyleHelper::baseColor().rgb());;
|
||||
{
|
||||
QRect rect = option->rect;
|
||||
bool horizontal = option->state & State_Horizontal;
|
||||
rect = option->rect;
|
||||
|
||||
QPixmap pixmap;
|
||||
QPainter *p = painter;
|
||||
QRect rect = option->rect;
|
||||
if (Utils::StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
|
||||
pixmap = QPixmap(option->rect.size());
|
||||
p = new QPainter(&pixmap);
|
||||
rect = QRect(0, 0, option->rect.width(), option->rect.height());
|
||||
}
|
||||
// Map offset for global window gradient
|
||||
QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) -
|
||||
widget->mapToGlobal(option->rect.topLeft());
|
||||
QRect gradientSpan;
|
||||
if (widget)
|
||||
gradientSpan = QRect(offset, widget->window()->size());
|
||||
|
||||
bool horizontal = option->state & State_Horizontal;
|
||||
// Map offset for global window gradient
|
||||
QPoint offset = widget->window()->mapToGlobal(option->rect.topLeft()) -
|
||||
widget->mapToGlobal(option->rect.topLeft());
|
||||
QRect gradientSpan;
|
||||
if (widget) {
|
||||
gradientSpan = QRect(offset, widget->window()->size());
|
||||
}
|
||||
if (horizontal) {
|
||||
Utils::StyleHelper::horizontalGradient(p, gradientSpan, rect);
|
||||
} else {
|
||||
Utils::StyleHelper::verticalGradient(p, gradientSpan, rect);
|
||||
}
|
||||
bool drawLightColored = lightColored(widget);
|
||||
if (horizontal)
|
||||
Utils::StyleHelper::horizontalGradient(painter, gradientSpan, rect, drawLightColored);
|
||||
else
|
||||
Utils::StyleHelper::verticalGradient(painter, gradientSpan, rect, drawLightColored);
|
||||
|
||||
painter->setPen(Utils::StyleHelper::borderColor());
|
||||
if (!drawLightColored)
|
||||
painter->setPen(Utils::StyleHelper::borderColor());
|
||||
else
|
||||
painter->setPen(QColor(0x888888));
|
||||
|
||||
if (horizontal) {
|
||||
// Note: This is a hack to determine if the
|
||||
// toolbar should draw the top or bottom outline
|
||||
// (needed for the find toolbar for instance)
|
||||
QColor lighter(255, 255, 255, 40);
|
||||
if (widget && widget->property("topBorder").toBool()) {
|
||||
p->drawLine(rect.topLeft(), rect.topRight());
|
||||
p->setPen(lighter);
|
||||
p->drawLine(rect.topLeft() + QPoint(0, 1), rect.topRight() + QPoint(0, 1));
|
||||
if (horizontal) {
|
||||
// Note: This is a hack to determine if the
|
||||
// toolbar should draw the top or bottom outline
|
||||
// (needed for the find toolbar for instance)
|
||||
QColor lighter(Utils::StyleHelper::sidebarHighlight());
|
||||
if (drawLightColored)
|
||||
lighter = QColor(255, 255, 255, 180);
|
||||
if (widget && widget->property("topBorder").toBool()) {
|
||||
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 {
|
||||
p->drawLine(rect.bottomLeft(), rect.bottomRight());
|
||||
p->setPen(lighter);
|
||||
p->drawLine(rect.topLeft(), rect.topRight());
|
||||
painter->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
painter->drawLine(rect.topRight(), rect.bottomRight());
|
||||
}
|
||||
} else {
|
||||
p->drawLine(rect.topLeft(), rect.bottomLeft());
|
||||
p->drawLine(rect.topRight(), rect.bottomRight());
|
||||
}
|
||||
|
||||
if (Utils::StyleHelper::usePixmapCache() && !QPixmapCache::find(key, pixmap)) {
|
||||
painter->drawPixmap(rect.topLeft(), pixmap);
|
||||
p->end();
|
||||
delete p;
|
||||
QPixmapCache::insert(key, pixmap);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
d->style->drawControl(element, option, painter, widget);
|
||||
QProxyStyle::drawControl(element, option, painter, widget);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -969,146 +832,122 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
|
||||
void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option,
|
||||
QPainter *painter, const QWidget *widget) const
|
||||
{
|
||||
if (!panelWidget(widget)) {
|
||||
return d->style->drawComplexControl(control, option, painter, widget);
|
||||
}
|
||||
if (!panelWidget(widget))
|
||||
return QProxyStyle::drawComplexControl(control, option, painter, widget);
|
||||
|
||||
QRect rect = option->rect;
|
||||
switch (control) {
|
||||
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;
|
||||
button = subControlRect(control, toolbutton, SC_ToolButton, widget);
|
||||
button = subControlRect(control, toolbutton, SC_ToolButton, widget);
|
||||
menuarea = subControlRect(control, toolbutton, SC_ToolButtonMenu, widget);
|
||||
|
||||
State bflags = toolbutton->state;
|
||||
if (bflags & State_AutoRaise) {
|
||||
if (!(bflags & State_MouseOver)) {
|
||||
if (!(bflags & State_MouseOver))
|
||||
bflags &= ~State_Raised;
|
||||
}
|
||||
}
|
||||
|
||||
State mflags = bflags;
|
||||
if (toolbutton->state & State_Sunken) {
|
||||
if (toolbutton->activeSubControls & SC_ToolButton) {
|
||||
if (toolbutton->activeSubControls & SC_ToolButton)
|
||||
bflags |= State_Sunken;
|
||||
}
|
||||
if (toolbutton->activeSubControls & SC_ToolButtonMenu) {
|
||||
if (toolbutton->activeSubControls & SC_ToolButtonMenu)
|
||||
mflags |= State_Sunken;
|
||||
}
|
||||
}
|
||||
|
||||
QStyleOption tool(0);
|
||||
tool.palette = toolbutton->palette;
|
||||
if (toolbutton->subControls & SC_ToolButton) {
|
||||
tool.rect = button;
|
||||
tool.rect = button;
|
||||
tool.state = bflags;
|
||||
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;
|
||||
label.palette = panelPalette(option->palette);
|
||||
|
||||
label.palette = panelPalette(option->palette, lightColored(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);
|
||||
|
||||
if (toolbutton->subControls & SC_ToolButtonMenu) {
|
||||
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)) {
|
||||
painter->setPen(Qt::gray);
|
||||
painter->drawLine(tool.rect.topLeft(), tool.rect.bottomLeft());
|
||||
if (mflags & (State_Sunken)) {
|
||||
QColor shade(0, 0, 0, 50);
|
||||
painter->fillRect(tool.rect.adjusted(0, -1, 1, 1), shade);
|
||||
}
|
||||
#ifndef Q_WS_MAC
|
||||
else if (mflags & (State_MouseOver)) {
|
||||
} else if (!Utils::HostOsInfo::isMacHost() && (mflags & State_MouseOver)) {
|
||||
QColor shade(255, 255, 255, 50);
|
||||
painter->fillRect(tool.rect.adjusted(0, -1, 1, 1), shade);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
tool.rect = tool.rect.adjusted(2, 2, -2, -2);
|
||||
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;
|
||||
QRect ir = toolbutton->rect.adjusted(1, 1, -1, -1);
|
||||
QStyleOptionToolButton newBtn = *toolbutton;
|
||||
newBtn.palette = panelPalette(option->palette);
|
||||
newBtn.rect = QRect(ir.right() - arrowSize - 1,
|
||||
ir.height() - arrowSize - 2, arrowSize, arrowSize);
|
||||
newBtn.rect = QRect(ir.right() - arrowSize - 1,
|
||||
ir.height() - arrowSize - 2, arrowSize, arrowSize);
|
||||
drawPrimitive(PE_IndicatorArrowDown, &newBtn, painter, widget);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case CC_ComboBox:
|
||||
if (const QStyleOptionComboBox * cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
||||
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
|
||||
painter->save();
|
||||
bool isEmpty = cb->currentText.isEmpty() && cb->currentIcon.isNull();
|
||||
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;
|
||||
if (isEmpty) {
|
||||
if (isEmpty)
|
||||
toolbutton.state &= ~(State_Enabled | State_Sunken);
|
||||
}
|
||||
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);
|
||||
painter->restore();
|
||||
// Draw arrow
|
||||
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;
|
||||
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),
|
||||
d->style->pixelMetric(PM_ButtonShiftVertical, option, widget));
|
||||
|
||||
if (!alignarrow) {
|
||||
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;
|
||||
arrowOpt.rect = arrowRect;
|
||||
if (isEmpty) {
|
||||
if (isEmpty)
|
||||
arrowOpt.state &= ~(State_Enabled | State_Sunken);
|
||||
}
|
||||
|
||||
if (styleHint(SH_ComboBox_Popup, option, widget)) {
|
||||
arrowOpt.rect.translate(0, -3);
|
||||
@ -1118,19 +957,33 @@ void ManhattanStyle::drawComplexControl(ComplexControl control, const QStyleOpti
|
||||
} else {
|
||||
drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, painter, widget);
|
||||
}
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
d->style->drawComplexControl(control, option, painter, widget);
|
||||
QProxyStyle::drawComplexControl(control, option, painter, widget);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Mac style reimplements this to control the
|
||||
// focus widget among other things
|
||||
bool ManhattanStyle::event(QEvent *e)
|
||||
void ManhattanStyle::drawButtonSeparator(QPainter *painter, const QRect &rect, bool reverse) const
|
||||
{
|
||||
Q_ASSERT(d->style);
|
||||
return d->style->event(e);
|
||||
}
|
||||
QLinearGradient grad(rect.topRight(), 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());
|
||||
}
|
||||
|
@ -31,25 +31,19 @@
|
||||
|
||||
#include "core_global.h"
|
||||
|
||||
#include <QtGui/QWindowsStyle>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QLinearGradient;
|
||||
class QBrush;
|
||||
QT_END_NAMESPACE
|
||||
#include <QProxyStyle>
|
||||
|
||||
class ManhattanStylePrivate;
|
||||
|
||||
class CORE_EXPORT ManhattanStyle : public QWindowsStyle {
|
||||
class CORE_EXPORT ManhattanStyle : public QProxyStyle
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ManhattanStyle(const QString &);
|
||||
explicit ManhattanStyle(const QString &baseStyleName);
|
||||
|
||||
~ManhattanStyle();
|
||||
|
||||
QStyle *systemStyle() 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 drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget = 0) const;
|
||||
@ -75,20 +69,13 @@ public:
|
||||
void unpolish(QWidget *widget);
|
||||
void unpolish(QApplication *app);
|
||||
|
||||
protected:
|
||||
bool event(QEvent *e);
|
||||
|
||||
protected Q_SLOTS:
|
||||
protected slots:
|
||||
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:
|
||||
void drawButtonSeparator(QPainter *painter, const QRect &rect, bool reverse) const;
|
||||
|
||||
ManhattanStylePrivate *d;
|
||||
Q_DISABLE_COPY(ManhattanStyle)
|
||||
};
|
||||
|
||||
#endif // MANHATTANSTYLE_H
|
||||
|
@ -31,8 +31,8 @@
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
#include <QtGui/QStatusBar>
|
||||
#include <QtGui/QApplication>
|
||||
#include <QStatusBar>
|
||||
#include <QtWidgets/QApplication>
|
||||
|
||||
using namespace Core;
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "messageoutputwindow.h"
|
||||
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QTextEdit>
|
||||
|
||||
using namespace Core::Internal;
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QTextStream>
|
||||
|
||||
#include <QtXml/QXmlStreamReader>
|
||||
#include <QtCore/QXmlStreamReader>
|
||||
|
||||
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
|
||||
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()) {
|
||||
data.comment = comment;
|
||||
} else {
|
||||
|
@ -30,9 +30,9 @@
|
||||
|
||||
#include <utils/stylehelper.h>
|
||||
|
||||
#include <QtGui/QPaintEvent>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QSplitterHandle>
|
||||
#include <QPaintEvent>
|
||||
#include <QPainter>
|
||||
#include <QSplitterHandle>
|
||||
|
||||
namespace Core {
|
||||
namespace Internal {
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
#include "core_global.h"
|
||||
|
||||
#include <QtGui/QSplitter>
|
||||
#include <QSplitter>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSplitterHandle;
|
||||
|
@ -49,11 +49,11 @@
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QSignalMapper>
|
||||
#include <QtGui/QShortcut>
|
||||
#include <QShortcut>
|
||||
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QTabWidget>
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QAction>
|
||||
#include <QTabWidget>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "core_global.h"
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAction;
|
||||
|
@ -34,11 +34,11 @@
|
||||
#include <extensionsystem/pluginerrorview.h>
|
||||
#include <extensionsystem/pluginspec.h>
|
||||
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QHBoxLayout>
|
||||
#include <QtGui/QDialog>
|
||||
#include <QtGui/QDialogButtonBox>
|
||||
#include <QtGui/QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QtDebug>
|
||||
|
||||
using namespace Core::Internal;
|
||||
|
@ -29,7 +29,7 @@
|
||||
#ifndef PLUGINDIALOG_H
|
||||
#define PLUGINDIALOG_H
|
||||
|
||||
#include <QtGui/QDialog>
|
||||
#include <QDialog>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QPushButton;
|
||||
|
@ -33,10 +33,10 @@
|
||||
|
||||
#include <QtCore/QSettings>
|
||||
|
||||
#include <QtGui/QVBoxLayout>
|
||||
#include <QtGui/QSplitter>
|
||||
#include <QtGui/QResizeEvent>
|
||||
#include <QtGui/QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QSplitter>
|
||||
#include <QResizeEvent>
|
||||
#include <QTextEdit>
|
||||
|
||||
|
||||
using namespace Core;
|
||||
|
@ -31,7 +31,7 @@
|
||||
|
||||
#include "core_global.h"
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QSettings;
|
||||
|
@ -35,10 +35,10 @@
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QEvent>
|
||||
#include <QtCore/QSettings>
|
||||
#include <QtGui/QLayout>
|
||||
#include <QtGui/QToolBar>
|
||||
#include <QtGui/QAction>
|
||||
#include <QtGui/QToolButton>
|
||||
#include <QLayout>
|
||||
#include <QToolBar>
|
||||
#include <QAction>
|
||||
#include <QToolButton>
|
||||
|
||||
using namespace Core;
|
||||
using namespace Core::Internal;
|
||||
|
@ -31,8 +31,8 @@
|
||||
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QtGui/QComboBox>
|
||||
#include <QWidget>
|
||||
#include <QComboBox>
|
||||
|
||||
#include <coreplugin/minisplitter.h>
|
||||
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
#include "styleanimator.h"
|
||||
|
||||
#include <QtGui/QStyleOption>
|
||||
#include <QStyleOption>
|
||||
|
||||
Animation *StyleAnimator::widgetAnimation(const QWidget *widget) const
|
||||
{
|
||||
|
@ -32,9 +32,9 @@
|
||||
#include <QtCore/QPointer>
|
||||
#include <QtCore/QTime>
|
||||
#include <QtCore/QBasicTimer>
|
||||
#include <QtGui/QStyle>
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QStyle>
|
||||
#include <QPainter>
|
||||
#include <QWidget>
|
||||
|
||||
/*
|
||||
* This is a set of helper classes to allow for widget animations in
|
||||
|
@ -28,10 +28,10 @@
|
||||
|
||||
#include "tabpositionindicator.h"
|
||||
|
||||
#include <QtGui/QPainter>
|
||||
#include <QtGui/QPaintEvent>
|
||||
#include <QtGui/QBrush>
|
||||
#include <QtGui/QPalette>
|
||||
#include <QPainter>
|
||||
#include <QPaintEvent>
|
||||
#include <QBrush>
|
||||
#include <QPalette>
|
||||
|
||||
using namespace Core::Internal;
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#ifndef TABPOSITIONINDICATOR_H
|
||||
#define TABPOSITIONINDICATOR_H
|
||||
|
||||
#include <QtGui/QWidget>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Core {
|
||||
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