Removed cafUiStyleSheet and all references to it.

This commit is contained in:
Ruben Manuel Thoms 2020-09-04 14:33:33 +02:00 committed by Magne Sjaastad
parent 9391453c2c
commit 85f2b3faf0
10 changed files with 0 additions and 477 deletions

View File

@ -18,8 +18,6 @@
#pragma once
#include "cafUiStyleSheet.h"
#include <QMainWindow>
class QMdiArea;

View File

@ -327,11 +327,6 @@ void RiuMultiPlotBook::scheduleReplotOfAllPlots()
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotBook::renderTo( QPaintDevice* paintDevice )
{
for ( auto page : m_pages )
{
page->stashWidgetStates();
}
int resolution = paintDevice->logicalDpiX();
double scaling = resolution / static_cast<double>( RiaGuiApplication::applicationResolution() );
@ -350,11 +345,6 @@ void RiuMultiPlotBook::renderTo( QPaintDevice* paintDevice )
page->renderTo( &painter, scaling );
firstPage = false;
}
for ( auto page : m_pages )
{
page->restoreWidgetStates();
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -19,7 +19,6 @@
#include "RiuInterfaceToViewWindow.h"
#include "RiuMultiPlotPage.h"
#include "cafUiStyleSheet.h"
#include "cafPdmPointer.h"
#include "cafSelectionChangedReceiver.h"

View File

@ -352,7 +352,6 @@ void RiuMultiPlotPage::renderTo( QPaintDevice* paintDevice )
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::renderTo( QPainter* painter, double scalingFactor )
{
stashWidgetStates();
painter->fillRect( painter->viewport(), Qt::white );
m_plotTitle->render( painter );
@ -386,8 +385,6 @@ void RiuMultiPlotPage::renderTo( QPainter* painter, double scalingFactor )
plotWidget->renderTo( painter, plotWidgetGeometry, scalingFactor );
}
restoreWidgetStates();
}
//--------------------------------------------------------------------------------------------------
@ -531,14 +528,6 @@ void RiuMultiPlotPage::onSelectionManagerSelectionChanged( const std::set<int>&
{
isSelected = isSelected || caf::SelectionManager::instance()->isSelected( plot, changedLevel );
}
if ( isSelected )
{
plotWidget->setWidgetState( "selected" );
}
else
{
caf::UiStyleSheet::clearWidgetStates( plotWidget );
}
}
}
@ -819,28 +808,6 @@ std::pair<int, int>
return std::make_pair( availableRow, availableColumn );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::stashWidgetStates()
{
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets )
{
plotWidget->stashWidgetStates();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuMultiPlotPage::restoreWidgetStates()
{
for ( RiuQwtPlotWidget* plotWidget : m_plotWidgets )
{
plotWidget->restoreWidgetStates();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -21,7 +21,6 @@
#include "cafPdmPointer.h"
#include "cafSelectionChangedReceiver.h"
#include "cafUiStyleSheet.h"
#include <QFrame>
#include <QGridLayout>
@ -124,8 +123,6 @@ protected:
std::pair<int, int> findAvailableRowAndColumn( int startRow, int startColumn, int columnSpan, int columnCount ) const;
void stashWidgetStates();
void restoreWidgetStates();
void applyLook();
private slots:
virtual void performUpdate();

View File

@ -546,31 +546,6 @@ void RiuQwtPlotWidget::scheduleReplot()
RiaPlotWindowRedrawScheduler::instance()->schedulePlotWidgetReplot( this );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::stashWidgetStates()
{
m_plotStyleSheet.stashWidgetStates();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::restoreWidgetStates()
{
m_plotStyleSheet.restoreWidgetStates();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::setWidgetState( const QString& widgetState )
{
caf::UiStyleSheet::clearWidgetStates( this );
m_plotStyleSheet.setWidgetState( this, widgetState );
}
//--------------------------------------------------------------------------------------------------
/// Adds an overlay frame. The overlay frame becomes the responsibility of the plot widget
//--------------------------------------------------------------------------------------------------
@ -685,12 +660,6 @@ void RiuQwtPlotWidget::hideEvent( QHideEvent* event )
//--------------------------------------------------------------------------------------------------
void RiuQwtPlotWidget::showEvent( QShowEvent* event )
{
m_plotStyleSheet = createPlotStyleSheet();
m_plotStyleSheet.applyToWidget( this );
m_canvasStyleSheet = createCanvasStyleSheet();
m_canvasStyleSheet.applyToWidget( canvas() );
QwtPlot::showEvent( event );
}
@ -878,34 +847,6 @@ void RiuQwtPlotWidget::recalculateAxisExtents( QwtPlot::Axis axis )
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::UiStyleSheet RiuQwtPlotWidget::createPlotStyleSheet() const
{
QColor backgroundColor = QColor( "white" );
QColor highlightColor = QApplication::palette().highlight().color();
caf::UiStyleSheet styleSheet;
styleSheet.set( "background-color", backgroundColor.name() );
styleSheet.set( "border", "1 px solid transparent" );
styleSheet.property( "selected" ).set( "border", QString( "1px solid %1" ).arg( highlightColor.name() ) );
return styleSheet;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::UiStyleSheet RiuQwtPlotWidget::createCanvasStyleSheet() const
{
caf::UiStyleSheet styleSheet;
styleSheet.set( "background-color", "#FAFAFA" );
styleSheet.set( "border", "1px solid LightGray" );
return styleSheet;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -23,7 +23,6 @@
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include "cafUiStyleSheet.h"
#include "qwt_plot.h"
@ -123,9 +122,6 @@ public:
QPoint dragStartPosition() const;
void scheduleReplot();
void stashWidgetStates();
void restoreWidgetStates();
void setWidgetState( const QString& widgetState );
void addOverlayFrame( RiuDraggableOverlayFrame* overlayWidget );
void removeOverlayFrame( RiuDraggableOverlayFrame* overlayWidget );
@ -176,9 +172,6 @@ private:
void onAxisSelected( QwtScaleWidget* scale, bool toggleItemInSelection );
void recalculateAxisExtents( QwtPlot::Axis axis );
caf::UiStyleSheet createPlotStyleSheet() const;
caf::UiStyleSheet createCanvasStyleSheet() const;
void updateOverlayFrameLayout();
private:
@ -203,8 +196,5 @@ private:
std::map<QwtPlotCurve*, CurveColors> m_originalCurveColors;
std::map<QwtPlotCurve*, double> m_originalZValues;
caf::UiStyleSheet m_plotStyleSheet;
caf::UiStyleSheet m_canvasStyleSheet;
friend class RiaPlotWindowRedrawScheduler;
};

View File

@ -166,8 +166,6 @@ set( PROJECT_FILES
cafStyleSheetTools.cpp
cafPdmUiTabbedPropertyViewDialog.h
cafPdmUiTabbedPropertyViewDialog.cpp
cafUiStyleSheet.h
cafUiStyleSheet.cpp
)
add_library( ${PROJECT_NAME}

View File

@ -1,257 +0,0 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2019- Ceetron Solutions AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cafUiStyleSheet.h"
#include <QStringList>
#include <QStyle>
#include <QVariant>
#include <QWidget>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::UiStyleSheet::State::State( const QString& stateTag, Type type )
: m_type( type )
{
if ( type == PseudoState )
{
if ( !stateTag.isEmpty() )
{
m_stateTag = ":" + stateTag;
}
}
else
{
m_stateTag = QString( "[%1=true]" ).arg( stateTag );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::UiStyleSheet::State::Type caf::UiStyleSheet::State::type() const
{
return m_type;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void caf::UiStyleSheet::State::set( const QString& key, const QString& value )
{
m_content[key] = value;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString caf::UiStyleSheet::State::get( const QString& key ) const
{
auto it = m_content.find( key );
if ( it != m_content.end() )
{
return it->second;
}
return "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString caf::UiStyleSheet::State::fullText( const QString& className,
const QString& objectName,
bool applyToSubClasses /*= true*/ ) const
{
QString classNameTag = applyToSubClasses ? className : QString( ".%1" ).arg( className );
QString objectNameTag = !objectName.isEmpty() ? QString( "#%1" ).arg( objectName ) : "";
QStringList content;
for ( auto keyValuePair : m_content )
{
content << QString( " %1: %2" ).arg( keyValuePair.first ).arg( keyValuePair.second );
}
QString format( "%1%2%3\n{\n%4}" );
QString stateStyleSheet =
format.arg( classNameTag ).arg( objectNameTag ).arg( m_stateTag ).arg( content.join( ";\n" ) );
return stateStyleSheet;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::UiStyleSheet::UiStyleSheet()
{
// Add a default state (blank tag)
m_states.insert( std::make_pair( "", State( "", State::PseudoState ) ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void caf::UiStyleSheet::set( const QString& key, const QString& value )
{
pseudoState( "" ).set( key, value );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString caf::UiStyleSheet::get( const QString& key ) const
{
auto it = m_states.find( "" );
if ( it != m_states.end() )
{
return it->second.get( key );
}
return "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::UiStyleSheet::State& caf::UiStyleSheet::property( QString stateTag )
{
auto itBoolResult = m_states.insert( std::make_pair( stateTag, State( stateTag, State::PropertyState ) ) );
return itBoolResult.first->second;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::UiStyleSheet::State& caf::UiStyleSheet::pseudoState( QString stateTag )
{
auto itBoolResult = m_states.insert( std::make_pair( stateTag, State( stateTag, State::PseudoState ) ) );
return itBoolResult.first->second;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void caf::UiStyleSheet::applyToWidget( QWidget* widget, bool applyToSubClasses /*= true*/ ) const
{
if ( widget->objectName().isEmpty() )
{
// If widget has no object name we use the pointer as a name.
widget->setObjectName( QString( "%1" ).arg( reinterpret_cast<std::uintptr_t>( widget ) ) );
}
QString completeStyleSheet =
fullText( QString( widget->metaObject()->className() ), widget->objectName(), applyToSubClasses );
widget->setStyleSheet( completeStyleSheet );
refreshWidget( widget );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void caf::UiStyleSheet::applyToWidgetAndChildren( QWidget* widget )
{
QString completeStyleSheet = fullText( "*", "", false );
widget->setStyleSheet( completeStyleSheet );
refreshWidget( widget );
}
//--------------------------------------------------------------------------------------------------
/// Clear all existing properties
//--------------------------------------------------------------------------------------------------
void caf::UiStyleSheet::clearWidgetStates( QWidget* widget )
{
for ( QByteArray existingProperty : widget->dynamicPropertyNames() )
{
widget->setProperty( existingProperty, QVariant() );
}
refreshWidget( widget );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void caf::UiStyleSheet::setWidgetState( QWidget* widget, QString stateTag, bool on /*= true*/ ) const
{
// Set current property state to true
if ( !stateTag.isEmpty() )
{
auto it = m_states.find( stateTag );
if ( it != m_states.end() && it->second.type() == State::PropertyState )
{
widget->setProperty( stateTag.toLatin1(), QVariant( on ) );
}
}
// Trigger style update
refreshWidget( widget );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void caf::UiStyleSheet::stashWidgetStates()
{
m_stashedStates.swap( m_states );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void caf::UiStyleSheet::restoreWidgetStates()
{
if ( !m_stashedStates.empty() )
{
m_stashedStates.swap( m_states );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString caf::UiStyleSheet::fullText( const QString& className, const QString& objectName, bool applyToSubClasses ) const
{
QStringList stateTexts;
for ( auto it = m_states.begin(); it != m_states.end(); ++it )
{
stateTexts << it->second.fullText( className, objectName, applyToSubClasses );
}
return stateTexts.join( "\n" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void caf::UiStyleSheet::refreshWidget( QWidget* widget )
{
widget->style()->unpolish( widget );
widget->style()->polish( widget );
}

View File

@ -1,100 +0,0 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2019- Ceetron Solutions AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include <QString>
#include <map>
class QWidget;
namespace caf
{
//==================================================================================================
// Class used to apply stylesheets to Qt widgets without "bleeding" into other widgets
//==================================================================================================
class UiStyleSheet
{
public:
class State
{
public:
enum Type
{
// Qt Pseudo-states applied automatically by Qt: https://doc.qt.io/qt-5/stylesheet-reference.html
PseudoState,
// State set by property syntax
PropertyState
};
State( const QString& stateTag, Type type );
Type type() const;
void set( const QString& key, const QString& value );
QString get( const QString& key ) const;
private:
friend class UiStyleSheet;
QString fullText( const QString& className, const QString& objectName, bool applyToSubClasses ) const;
private:
Type m_type;
QString m_stateTag;
std::map<QString, QString> m_content;
};
public:
UiStyleSheet();
void set( const QString& key, const QString& value );
QString get( const QString& key ) const;
State& property( QString stateTag );
State& pseudoState( QString stateTag );
void applyToWidget( QWidget* widget, bool applyToSubClasses = true ) const;
void applyToWidgetAndChildren( QWidget* widget );
static void clearWidgetStates( QWidget* widget );
void setWidgetState( QWidget* widget, QString stateTag, bool on = true ) const;
void stashWidgetStates();
void restoreWidgetStates();
private:
QString fullText( const QString& className, const QString& objectName, bool applyToSubClasses ) const;
static void refreshWidget( QWidget* widget );
private:
std::map<QString, State> m_states;
std::map<QString, State> m_stashedStates;
};
} // namespace caf