Merge branch '3.1.x-stable' of https://github.com/calamares/calamares into 3.1.x-stable

This commit is contained in:
Philip 2017-12-01 07:42:47 -05:00
commit b147e2f011
6 changed files with 99 additions and 32 deletions

View File

@ -166,7 +166,7 @@ set( CALAMARES_TRANSLATION_LANGUAGES ar ast bg ca cs_CZ da de el en en_GB es_MX
### Bump version here
set( CALAMARES_VERSION_MAJOR 3 )
set( CALAMARES_VERSION_MINOR 1 )
set( CALAMARES_VERSION_PATCH 8 )
set( CALAMARES_VERSION_PATCH 9 )
set( CALAMARES_VERSION_RC 0 )
set( CALAMARES_VERSION ${CALAMARES_VERSION_MAJOR}.${CALAMARES_VERSION_MINOR}.${CALAMARES_VERSION_PATCH} )

View File

@ -96,7 +96,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
logoLabel->setAlignment( Qt::AlignCenter );
logoLabel->setFixedSize( 80, 80 );
logoLabel->setPixmap( Calamares::Branding::instance()->
image( Calamares::Branding::ProductIcon,
image( Calamares::Branding::ProductLogo,
logoLabel->size() ) );
logoLayout->addWidget( logoLabel );
logoLayout->addStretch();

View File

@ -183,6 +183,16 @@ variantHashFromPyDict( const boost::python::dict& pyDict )
Helper* Helper::s_instance = nullptr;
static inline void add_if_lib_exists( const QDir& dir, const char* name, QStringList& list )
{
if ( ! ( dir.exists() && dir.isReadable() ) )
return;
QFileInfo fi( dir.absoluteFilePath( name ) );
if ( fi.exists() && fi.isReadable() )
list.append( fi.dir().absolutePath() );
}
Helper::Helper( QObject* parent )
: QObject( parent )
{
@ -196,20 +206,11 @@ Helper::Helper( QObject* parent )
m_mainNamespace = m_mainModule.attr( "__dict__" );
// If we're running from the build dir
QFileInfo fi( QDir::current().absoluteFilePath( "libcalamares.so" ) );
if ( fi.exists() && fi.isReadable() )
m_pythonPaths.append( fi.dir().absolutePath() );
add_if_lib_exists( QDir::current(), "libcalamares.so", m_pythonPaths );
QDir calaPythonPath( CalamaresUtils::systemLibDir().absolutePath() +
QDir::separator() + "calamares" );
if ( calaPythonPath.exists() &&
calaPythonPath.isReadable() )
{
QFileInfo fi( calaPythonPath.absoluteFilePath( "libcalamares.so" ) );
if ( fi.exists() && fi.isReadable() )
m_pythonPaths.append( fi.dir().absolutePath() );
}
add_if_lib_exists( calaPythonPath, "libcalamares.so", m_pythonPaths );
bp::object sys = bp::import( "sys" );

View File

@ -163,6 +163,7 @@ PackageModel::getPackages() const
{
QList<PackageTreeItem*> items = getItemPackages( m_rootItem );
for ( auto package : m_hiddenItems )
if ( package->hiddenSelected() )
items.append( getItemPackages( package ) );
QList<PackageTreeItem::ItemData> packages;
for ( auto item : items )

View File

@ -19,6 +19,8 @@
#include "PackageTreeItem.h"
#include "utils/Logger.h"
PackageTreeItem::PackageTreeItem( const ItemData& data, PackageTreeItem* parent )
: m_parentItem( parent )
, m_data( data )
@ -36,7 +38,15 @@ PackageTreeItem::PackageTreeItem( const QString packageName, PackageTreeItem* pa
PackageTreeItem::PackageTreeItem( PackageTreeItem* parent ) :
m_parentItem( parent )
{ }
{
}
PackageTreeItem::PackageTreeItem::PackageTreeItem() :
PackageTreeItem( QString(), nullptr )
{
m_data.selected = Qt::Checked;
m_data.name = QLatin1Literal( "<root>" );
}
PackageTreeItem::~PackageTreeItem()
{
@ -101,6 +111,13 @@ PackageTreeItem::parentItem()
return m_parentItem;
}
const PackageTreeItem*
PackageTreeItem::parentItem() const
{
return m_parentItem;
}
QString
PackageTreeItem::prettyName() const
{
@ -143,6 +160,26 @@ PackageTreeItem::setHidden( bool isHidden )
m_data.isHidden = isHidden;
}
bool
PackageTreeItem::hiddenSelected() const
{
Q_ASSERT( m_data.isHidden );
if (! m_data.selected )
return false;
const PackageTreeItem* currentItem = parentItem();
while ( currentItem != nullptr )
{
if ( !currentItem->isHidden() )
return currentItem->isSelected() != Qt::Unchecked;
currentItem = currentItem->parentItem();
}
/* Has no non-hiddent parents */
return m_data.selected;
}
bool
PackageTreeItem::isCritical() const
{
@ -164,34 +201,47 @@ PackageTreeItem::isSelected() const
void
PackageTreeItem::setSelected( Qt::CheckState isSelected )
{
if ( parentItem() == nullptr )
// This is the root, it is always checked so don't change state
return;
m_data.selected = isSelected;
setChildrenSelected( isSelected );
// Look for suitable parent item which may change checked-state
// when one of its children changes.
PackageTreeItem* currentItem = parentItem();
while ( currentItem != nullptr )
while ( ( currentItem != nullptr ) && ( currentItem->childCount() == 0 ) )
{
currentItem = currentItem->parentItem();
}
if ( currentItem == nullptr )
// Reached the root .. don't bother
return;
// Figure out checked-state based on the children
int childrenSelected = 0;
bool isChildPartiallySelected = false;
int childrenPartiallySelected = 0;
for ( int i = 0; i < currentItem->childCount(); i++ )
{
if ( currentItem->child( i )->isSelected() == Qt::Checked )
childrenSelected++;
if ( currentItem->child( i )->isSelected() == Qt::PartiallyChecked )
isChildPartiallySelected = true;
childrenPartiallySelected++;
}
if ( !childrenSelected && !isChildPartiallySelected )
currentItem->m_data.selected = Qt::Unchecked;
if ( !childrenSelected && !childrenPartiallySelected)
currentItem->setSelected( Qt::Unchecked );
else if ( childrenSelected == currentItem->childCount() )
currentItem->m_data.selected = Qt::Checked;
currentItem->setSelected( Qt::Checked );
else
currentItem->m_data.selected = Qt::PartiallyChecked;
currentItem = currentItem->parentItem();
}
currentItem->setSelected( Qt::PartiallyChecked );
}
void
PackageTreeItem::setChildrenSelected( Qt::CheckState isSelected )
{
if ( isSelected != Qt::PartiallyChecked )
// Children are never root; don't need to use setSelected on them.
for ( auto child : m_childItems )
{
child->m_data.selected = isSelected;

View File

@ -40,7 +40,8 @@ public:
};
explicit PackageTreeItem( const ItemData& data, PackageTreeItem* parent = nullptr );
explicit PackageTreeItem( const QString packageName, PackageTreeItem* parent = nullptr );
explicit PackageTreeItem( PackageTreeItem* parent = nullptr );
explicit PackageTreeItem( PackageTreeItem* parent );
explicit PackageTreeItem(); // The root of the tree; always selected, named <root>
~PackageTreeItem() override;
void appendChild( PackageTreeItem* child );
@ -49,16 +50,30 @@ public:
int columnCount() const;
QVariant data( int column ) const override;
int row() const;
PackageTreeItem* parentItem();
const PackageTreeItem* parentItem() const;
QString prettyName() const;
QString description() const;
QString preScript() const;
QString packageName() const;
QString postScript() const;
bool isHidden() const;
void setHidden( bool isHidden );
/**
* @brief Is this hidden item, considered "selected"?
*
* This asserts when called on a non-hidden item.
* A hidden item has its own selected state, but really
* falls under the selectedness of the parent item.
*/
bool hiddenSelected() const;
bool isCritical() const;
void setCritical( bool isCritical );
Qt::CheckState isSelected() const;
void setSelected( Qt::CheckState isSelected );
void setChildrenSelected( Qt::CheckState isSelected );