Merge branch '3.1.x-stable'

This commit is contained in:
Adriaan de Groot 2017-12-20 08:13:55 -05:00
commit c582ff0d6b
14 changed files with 475 additions and 69 deletions

View File

@ -199,7 +199,7 @@ set( CALAMARES_TRANSLATION_LANGUAGES ar ast bg ca cs_CZ da de el en en_GB es_MX
set( CALAMARES_VERSION_MAJOR 3 )
set( CALAMARES_VERSION_MINOR 2 )
set( CALAMARES_VERSION_PATCH 0 )
set( CALAMARES_VERSION_RC 1 )
set( CALAMARES_VERSION_RC 2 )
set( CALAMARES_VERSION ${CALAMARES_VERSION_MAJOR}.${CALAMARES_VERSION_MINOR}.${CALAMARES_VERSION_PATCH} )
set( CALAMARES_VERSION_SHORT "${CALAMARES_VERSION}" )

View File

@ -5,7 +5,8 @@
#
# Copyright 2014 - 2015, Philip Müller <philm@manjaro.org>
# Copyright 2014, Teo Mrnjavac <teo@kde.org>
# Copyright 2017. Alf Gaida <agaida@siduction.org>
# Copyright 2017, Alf Gaida <agaida@siduction.org>
# Copyright 2017, Gabriel Craciunescu <crazy@frugalware.org>
#
# Calamares is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -20,26 +21,33 @@
# You should have received a copy of the GNU General Public License
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
import subprocess
import shutil
import libcalamares
def run():
"""
Set hardware clock.
"""
hwclock_rtc = ["hwclock", "--systohc", "--utc"]
hwclock_isa = ["hwclock", "--systohc", "--utc", "--directisa"]
is_broken_rtc = False
is_broken_isa = False
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
try:
subprocess.check_call(["hwclock", "--systohc", "--utc"])
except subprocess.CalledProcessError as e:
return (
"Cannot set hardware clock.",
"hwclock terminated with exit code {}.".format(e.returncode)
)
shutil.copy2("/etc/adjtime", "{!s}/etc/".format(root_mount_point))
ret = libcalamares.utils.target_env_call(hwclock_rtc)
if ret != 0:
is_broken_rtc = True
libcalamares.utils.debug("Hwclock returned error code {}".format(ret))
libcalamares.utils.debug(" .. RTC method failed, trying ISA bus method.")
else:
libcalamares.utils.debug("Hwclock set using RTC method.")
if is_broken_rtc:
ret = libcalamares.utils.target_env_call(hwclock_isa)
if ret != 0:
is_broken_isa = True
libcalamares.utils.debug("Hwclock returned error code {}".format(ret))
libcalamares.utils.debug(" .. ISA bus method failed.")
else:
libcalamares.utils.debug("Hwclock set using ISA bus methode.")
if is_broken_rtc and is_broken_isa:
libcalamares.utils.debug("BIOS or Kernel BUG: Setting hwclock failed.")
return None

View File

@ -9,6 +9,9 @@ calamares_add_plugin( plasmalnf
PlasmaLnfViewStep.cpp
PlasmaLnfPage.cpp
PlasmaLnfJob.cpp
ThemeWidget.cpp
RESOURCES
page_plasmalnf.qrc
UI
page_plasmalnf.ui
LINK_PRIVATE_LIBRARIES

View File

@ -26,19 +26,26 @@
#include <KPackage/Package>
#include <KPackage/PackageLoader>
static PlasmaLnfList plasma_themes()
ThemeInfo::ThemeInfo( const KPluginMetaData& data )
: id( data.pluginId() )
, name( data.name() )
, description( data.description() )
, widget( nullptr )
{
PlasmaLnfList packages;
}
static ThemeInfoList plasma_themes()
{
ThemeInfoList packages;
QList<KPluginMetaData> pkgs = KPackage::PackageLoader::self()->listPackages( "Plasma/LookAndFeel" );
for ( const KPluginMetaData& data : pkgs )
{
packages << PlasmaLnfDescriptor{ data.pluginId(), data.name() };
cDebug() << "LNF Package" << data.pluginId();
cDebug() << " .." << data.name();
cDebug() << " .." << data.description();
cDebug() << " .." << 'V' << data.isValid() << 'H' << data.isHidden() << 'D' << data.isEnabledByDefault();
if ( data.isValid() && !data.isHidden() && !data.name().isEmpty() )
{
packages << ThemeInfo{ data };
}
}
return packages;
@ -48,34 +55,17 @@ static PlasmaLnfList plasma_themes()
PlasmaLnfPage::PlasmaLnfPage( QWidget* parent )
: QWidget( parent )
, ui( new Ui::PlasmaLnfPage )
, m_buttonGroup( nullptr )
{
ui->setupUi( this );
CALAMARES_RETRANSLATE(
{
ui->retranslateUi( this );
ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop, below." ) );
m_availableLnf = plasma_themes();
ui->lnfCombo->clear();
for ( const auto& p : m_availableLnf )
ui->lnfCombo->addItem( p.name );
ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop. You can also skip this step and configure the look-and-feel once the system is installed." ) );
updateThemeNames();
fillUi();
}
)
QObject::connect<void( QComboBox::* )( int )>( ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated );
}
void
PlasmaLnfPage::activated( int index )
{
if ( ( index < 0 ) || ( index > m_availableLnf.length() ) )
{
cDebug() << "Plasma LNF index" << index << "out of range.";
return;
}
const PlasmaLnfDescriptor& lnf = m_availableLnf.at( index );
cDebug() << "Changed to" << index << lnf.id << lnf.name;
emit plasmaThemeSelected( lnf.id );
}
void
@ -83,3 +73,95 @@ PlasmaLnfPage::setLnfPath( const QString& path )
{
m_lnfPath = path;
}
void
PlasmaLnfPage::setEnabledThemes(const ThemeInfoList& themes)
{
m_enabledThemes = themes;
updateThemeNames();
winnowThemes();
fillUi();
}
void
PlasmaLnfPage::setEnabledThemesAll()
{
setEnabledThemes( plasma_themes() );
}
void PlasmaLnfPage::updateThemeNames()
{
auto plasmaThemes = plasma_themes();
for ( auto& enabled_theme : m_enabledThemes )
{
ThemeInfo* t = plasmaThemes.findById( enabled_theme.id );
if ( t != nullptr )
{
enabled_theme.name = t->name;
enabled_theme.description = t->description;
}
}
}
void PlasmaLnfPage::winnowThemes()
{
auto plasmaThemes = plasma_themes();
bool winnowed = true;
int winnow_index = 0;
while ( winnowed )
{
winnowed = false;
winnow_index = 0;
for ( auto& enabled_theme : m_enabledThemes )
{
ThemeInfo* t = plasmaThemes.findById( enabled_theme.id );
if ( t == nullptr )
{
cDebug() << "Removing" << enabled_theme.id;
winnowed = true;
break;
}
++winnow_index;
}
if ( winnowed )
{
m_enabledThemes.removeAt( winnow_index );
}
}
}
void PlasmaLnfPage::fillUi()
{
if ( m_enabledThemes.isEmpty() )
{
return;
}
if ( !m_buttonGroup )
{
m_buttonGroup = new QButtonGroup( this );
m_buttonGroup->setExclusive( true );
}
int c = 1; // After the general explanation
for ( auto& theme : m_enabledThemes )
{
if ( !theme.widget )
{
ThemeWidget* w = new ThemeWidget( theme );
m_buttonGroup->addButton( w->button() );
ui->verticalLayout->insertWidget( c, w );
connect( w, &ThemeWidget::themeSelected, this, &PlasmaLnfPage::plasmaThemeSelected);
theme.widget = w;
}
else
{
theme.widget->updateThemeName( theme );
}
++c;
}
}

View File

@ -19,23 +19,26 @@
#ifndef PLASMALNFPAGE_H
#define PLASMALNFPAGE_H
#include <QButtonGroup>
#include <QList>
#include <QString>
#include <QStringList>
#include <QWidget>
#include "ThemeInfo.h"
#include "ThemeWidget.h"
namespace Ui
{
class PlasmaLnfPage;
}
struct PlasmaLnfDescriptor
{
QString id;
QString name;
} ;
using PlasmaLnfList = QList<PlasmaLnfDescriptor>;
/** @brief Page for selecting a Plasma Look-and-Feel theme.
*
* You must call setEnabledThemes -- either overload -- once
* to get the selection widgets. Note that calling that with
* an empty list will result in zero (0) selectable themes.
*/
class PlasmaLnfPage : public QWidget
{
Q_OBJECT
@ -43,17 +46,28 @@ public:
explicit PlasmaLnfPage( QWidget* parent = nullptr );
void setLnfPath( const QString& path );
public slots:
void activated( int index );
/** @brief enable only the listed themes. */
void setEnabledThemes( const ThemeInfoList& themes );
/** @brief enable all installed plasma themes. */
void setEnabledThemesAll();
signals:
void plasmaThemeSelected( const QString& id );
private:
/** @brief Intersect the list of enabled themes with the installed ones. */
void winnowThemes();
/** @brief Get the translated names for all enabled themes. */
void updateThemeNames();
/** @brief show enabled themes in the UI. */
void fillUi();
Ui::PlasmaLnfPage* ui;
QString m_lnfPath;
PlasmaLnfList m_availableLnf;
ThemeInfoList m_enabledThemes;
QButtonGroup *m_buttonGroup;
QList< ThemeWidget* > m_widgets;
};
#endif //PLASMALNFPAGE_H

View File

@ -19,6 +19,7 @@
#include "PlasmaLnfJob.h"
#include "PlasmaLnfPage.h"
#include "ThemeInfo.h"
#include "utils/CalamaresUtils.h"
#include "utils/Logger.h"
@ -109,8 +110,13 @@ PlasmaLnfViewStep::jobs() const
Calamares::JobList l;
cDebug() << "Creating Plasma LNF jobs ..";
if ( !m_themeId.isEmpty() && !m_lnfPath.isEmpty() )
if ( !m_themeId.isEmpty() )
{
if ( !m_lnfPath.isEmpty() )
l.append( Calamares::job_ptr( new PlasmaLnfJob( m_lnfPath, m_themeId ) ) );
else
cDebug() << "WARNING: no lnftool given for plasmalnf module.";
}
return l;
}
@ -125,12 +131,41 @@ PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap )
cDebug() << "WARNING: no lnftool given for plasmalnf module.";
m_liveUser = CalamaresUtils::getString( configurationMap, "liveuser" );
if ( configurationMap.contains( "themes" ) &&
configurationMap.value( "themes" ).type() == QVariant::List )
{
ThemeInfoList allThemes;
auto themeList = configurationMap.value( "themes" ).toList();
// Create the ThemInfo objects for the listed themes; information
// about the themes from Plasma (e.g. human-readable name and description)
// are filled in by update_names() in PlasmaLnfPage.
for ( const auto& i : themeList )
if ( i.type() == QVariant::Map )
{
auto iv = i.toMap();
allThemes.append( ThemeInfo( iv.value( "theme" ).toString(), iv.value( "image" ).toString() ) );
}
else if ( i.type() == QVariant::String )
allThemes.append( ThemeInfo( i.toString() ) );
if ( allThemes.length() == 1 )
cDebug() << "WARNING: only one theme enabled in plasmalnf";
m_widget->setEnabledThemes( allThemes );
}
else
m_widget->setEnabledThemesAll(); // All of them
}
void
PlasmaLnfViewStep::themeSelected( const QString& id )
{
m_themeId = id;
if ( m_lnfPath.isEmpty() )
{
cDebug() << "WARNING: no lnftool given for plasmalnf module.";
return;
}
QProcess lnftool;
if ( !m_liveUser.isEmpty() )

View File

@ -0,0 +1,97 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Calamares 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.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMALNF_THEMEINFO_H
#define PLASMALNF_THEMEINFO_H
#include <QList>
#include <QString>
class KPluginMetaData;
class ThemeWidget;
/** @brief describes a single plasma LnF theme.
*
* A theme description has an id, which is really the name of the desktop
* file (e.g. org.kde.breeze.desktop), a name which is human-readable and
* translated, and an optional image Page, which points to a local screenshot
* of that theme.
*/
struct ThemeInfo
{
QString id;
QString name;
QString description;
QString imagePath;
ThemeWidget* widget;
ThemeInfo()
: widget( nullptr )
{}
explicit ThemeInfo( const QString& _id )
: id( _id )
, widget( nullptr )
{
}
explicit ThemeInfo( const QString& _id, const QString& image )
: id( _id )
, imagePath( image )
, widget( nullptr )
{}
// Defined in PlasmaLnfPage.cpp
explicit ThemeInfo( const KPluginMetaData& );
bool isValid() const { return !id.isEmpty(); }
} ;
class ThemeInfoList : public QList< ThemeInfo >
{
public:
/** @brief Looks for a given @p id in the list of themes, returns nullptr if not found. */
ThemeInfo* findById( const QString& id )
{
for ( ThemeInfo& i : *this )
{
if ( i.id == id )
return &i;
}
return nullptr;
}
/** @brief Looks for a given @p id in the list of themes, returns nullptr if not found. */
const ThemeInfo* findById( const QString& id ) const
{
for ( const ThemeInfo& i : *this )
{
if ( i.id == id )
return &i;
}
return nullptr;
}
/** @brief Checks if a given @p id is in the list of themes. */
bool contains( const QString& id ) const
{
return findById( id ) != nullptr;
}
} ;
#endif

View File

@ -0,0 +1,85 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Calamares 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.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ThemeWidget.h"
#include "ThemeInfo.h"
#include "utils/Logger.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QRadioButton>
ThemeWidget::ThemeWidget(const ThemeInfo& info, QWidget* parent)
: QWidget( parent )
, m_check( new QRadioButton( info.name.isEmpty() ? info.id : info.name, parent ) )
, m_description( new QLabel( info.description, parent ) )
, m_id( info.id )
{
QHBoxLayout* layout = new QHBoxLayout( this );
this->setLayout( layout );
layout->addWidget( m_check, 1 );
constexpr QSize image_size{120, 80};
QPixmap image( info.imagePath );
if ( info.imagePath.isEmpty() )
{
// Image can't possibly be valid
image = QPixmap( ":/view-preview.png" );
}
else if ( image.isNull() )
{
// Not found or not specified, so convert the name into some (horrible, likely)
// color instead.
image = QPixmap( image_size );
uint hash_color = qHash( info.imagePath.isEmpty() ? info.id : info.imagePath );
cDebug() << "Theme image" << info.imagePath << "not found, hash" << hash_color;
image.fill( QColor( QRgb( hash_color ) ) );
}
else
image.scaled( image_size );
QLabel* image_label = new QLabel( this );
image_label->setPixmap( image );
layout->addWidget( image_label, 1 );
layout->addWidget( m_description, 3 );
connect( m_check, &QRadioButton::clicked, this, &ThemeWidget::clicked );
}
void
ThemeWidget::clicked( bool checked )
{
if ( checked )
emit themeSelected( m_id );
}
QAbstractButton*
ThemeWidget::button() const
{
return m_check;
}
void ThemeWidget::updateThemeName(const ThemeInfo& info)
{
m_check->setText( info.name );
m_description->setText( info.description );
}

View File

@ -0,0 +1,53 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Calamares 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.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMALNF_THEMEWIDGET_H
#define PLASMALNF_THEMEWIDGET_H
#include <QWidget>
class QAbstractButton;
class QLabel;
class QRadioButton;
struct ThemeInfo;
class ThemeWidget : public QWidget
{
Q_OBJECT
public:
explicit ThemeWidget( const ThemeInfo& info, QWidget* parent = nullptr );
QAbstractButton* button() const;
void updateThemeName( const ThemeInfo& info );
signals:
void themeSelected( const QString& id );
public slots:
void clicked( bool );
private:
QString m_id;
QRadioButton* m_check;
QLabel* m_description;
} ;
#endif

View File

@ -1 +1,5 @@
<RCC/>
<RCC>
<qresource>
<file>view-preview.png</file>
</qresource>
</RCC>

View File

@ -13,13 +13,9 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0">
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
<item>
<widget class="QLabel" name="generalExplanation">
<property name="styleSheet">
<string notr="true">margin-bottom: 1ex;
margin-left: 2em;</string>
</property>
<property name="text">
<string>Placeholder</string>
</property>
@ -28,9 +24,6 @@ margin-left: 2em;</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="lnfCombo"/>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">

View File

@ -10,11 +10,30 @@
# in exec, so that the target user has been created alrady.
---
# Full path to the Plasma look-and-feel tool (CLI program
# for querying and applying Plasma themes).
# for querying and applying Plasma themes). If this is not
# set, no LNF setting will happen.
lnftool: "/usr/bin/lookandfeeltool"
# For systems where the user Calamares runs as (usually root,
# via either sudo or pkexec) has a clean environment, set this
# to the originating username; the lnftool will be run through
# "sudo -H -u <liveuser>" instead of directly.
liveuser: "live"
#
# liveuser: "live"
# You can limit the list of Plasma look-and-feel themes by listing ids
# here. If this key is not present, all of the installed themes are listed.
# If the key is present, only installed themes that are *also* included
# in the list are shown (could be none!).
#
# Themes may be listed by id, (e.g. fluffy-bunny, below) or as a theme
# and an image (e.g. breeze) which will be used to show a screenshot.
# Themes with no image get a "missing screenshot" image; if the
# image file is not found, they get a color swatch based on the image name.
themes:
- org.kde.fuzzy-pig.desktop
- theme: org.kde.breeze.desktop
image: "breeze.png"
- theme: org.kde.breezedark.desktop
image: "breeze-dark.png"
- org.kde.fluffy-bunny.desktop

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 B

View File

@ -0,0 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#4d4d4d;
}
</style>
</defs>
<path style="fill:currentColor;fill-opacity:1;stroke:none"
d="m4 4v24h24v-24zm1 1h22v22h-22zm6 2a4 4 0 0 0 -4 4 4 4 0 0 0 4 4 4 4 0 0 0 4 -4 4 4 0 0 0 -4 -4m0 1a3 3 0 0 1 3 3 3 3 0 0 1 -3 3 3 3 0 0 1 -3 -3 3 3 0 0 1 3 -3m9.5 6.793l-5 5-2-2-6.5 6.5.707.707 5.793-5.793 2 2 5-5 3.793 3.793.707-.707z"
class="ColorScheme-Text"
/>
</svg>

After

Width:  |  Height:  |  Size: 570 B