Say hello to EncryptWidget.
This commit is contained in:
parent
e090463545
commit
6e92a04320
@ -31,11 +31,12 @@ calamares_add_plugin( partition
|
|||||||
core/PartitionIterator.cpp
|
core/PartitionIterator.cpp
|
||||||
core/PartitionModel.cpp
|
core/PartitionModel.cpp
|
||||||
core/PartUtils.cpp
|
core/PartUtils.cpp
|
||||||
|
gui/BootInfoWidget.cpp
|
||||||
gui/ChoicePage.cpp
|
gui/ChoicePage.cpp
|
||||||
gui/CreatePartitionDialog.cpp
|
gui/CreatePartitionDialog.cpp
|
||||||
gui/EditExistingPartitionDialog.cpp
|
|
||||||
gui/BootInfoWidget.cpp
|
|
||||||
gui/DeviceInfoWidget.cpp
|
gui/DeviceInfoWidget.cpp
|
||||||
|
gui/EditExistingPartitionDialog.cpp
|
||||||
|
gui/EncryptWidget.cpp
|
||||||
gui/PartitionPage.cpp
|
gui/PartitionPage.cpp
|
||||||
gui/PartitionBarsView.cpp
|
gui/PartitionBarsView.cpp
|
||||||
gui/PartitionLabelsView.cpp
|
gui/PartitionLabelsView.cpp
|
||||||
@ -62,6 +63,7 @@ calamares_add_plugin( partition
|
|||||||
gui/CreatePartitionDialog.ui
|
gui/CreatePartitionDialog.ui
|
||||||
gui/CreatePartitionTableDialog.ui
|
gui/CreatePartitionTableDialog.ui
|
||||||
gui/EditExistingPartitionDialog.ui
|
gui/EditExistingPartitionDialog.ui
|
||||||
|
gui/EncryptWidget.ui
|
||||||
gui/PartitionPage.ui
|
gui/PartitionPage.ui
|
||||||
gui/ReplaceWidget.ui
|
gui/ReplaceWidget.ui
|
||||||
LINK_LIBRARIES
|
LINK_LIBRARIES
|
||||||
|
150
src/modules/partition/gui/EncryptWidget.cpp
Normal file
150
src/modules/partition/gui/EncryptWidget.cpp
Normal file
@ -0,0 +1,150 @@
|
|||||||
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2016, Teo Mrnjavac <teo@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 "EncryptWidget.h"
|
||||||
|
|
||||||
|
#include <utils/CalamaresUtilsGui.h>
|
||||||
|
|
||||||
|
EncryptWidget::EncryptWidget( QWidget* parent )
|
||||||
|
: QWidget( parent )
|
||||||
|
{
|
||||||
|
setupUi( this );
|
||||||
|
|
||||||
|
m_iconLabel->setFixedWidth( m_iconLabel->height() );
|
||||||
|
m_passphraseLineEdit->hide();
|
||||||
|
m_confirmLineEdit->hide();
|
||||||
|
m_iconLabel->hide();
|
||||||
|
|
||||||
|
connect( m_encryptCheckBox, &QCheckBox::stateChanged,
|
||||||
|
this, &EncryptWidget::onCheckBoxStateChanged );
|
||||||
|
connect( m_passphraseLineEdit, &QLineEdit::textEdited,
|
||||||
|
this, &EncryptWidget::onPassphraseEdited );
|
||||||
|
connect( m_confirmLineEdit, &QLineEdit::textEdited,
|
||||||
|
this, &EncryptWidget::onPassphraseEdited );
|
||||||
|
|
||||||
|
updateState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EncryptWidget::State
|
||||||
|
EncryptWidget::state() const
|
||||||
|
{
|
||||||
|
return m_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
EncryptWidget::passphrase() const
|
||||||
|
{
|
||||||
|
if ( m_state == EncryptionConfirmed )
|
||||||
|
return m_passphraseLineEdit->text();
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
EncryptWidget::changeEvent( QEvent* e )
|
||||||
|
{
|
||||||
|
QWidget::changeEvent( e );
|
||||||
|
switch ( e->type() )
|
||||||
|
{
|
||||||
|
case QEvent::LanguageChange:
|
||||||
|
retranslateUi( this );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
EncryptWidget::updateState()
|
||||||
|
{
|
||||||
|
State newState;
|
||||||
|
if ( m_encryptCheckBox->isChecked() )
|
||||||
|
{
|
||||||
|
if ( !m_passphraseLineEdit->text().isEmpty() &&
|
||||||
|
m_passphraseLineEdit->text() == m_confirmLineEdit->text() )
|
||||||
|
{
|
||||||
|
newState = EncryptionConfirmed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newState = EncryptionUnconfirmed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newState = EncryptionDisabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( newState != m_state )
|
||||||
|
{
|
||||||
|
m_state = newState;
|
||||||
|
emit stateChanged( m_state );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
EncryptWidget::onPassphraseEdited()
|
||||||
|
{
|
||||||
|
if ( !m_iconLabel->isVisible() )
|
||||||
|
m_iconLabel->show();
|
||||||
|
|
||||||
|
QString p1 = m_passphraseLineEdit->text();
|
||||||
|
QString p2 = m_confirmLineEdit->text();
|
||||||
|
|
||||||
|
m_iconLabel->setToolTip( QString() );
|
||||||
|
if ( p1.isEmpty() && p2.isEmpty() )
|
||||||
|
{
|
||||||
|
m_iconLabel->clear();
|
||||||
|
}
|
||||||
|
else if ( p1 == p2 )
|
||||||
|
{
|
||||||
|
m_iconLabel->setFixedWidth( m_iconLabel->height() );
|
||||||
|
m_iconLabel->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Yes,
|
||||||
|
CalamaresUtils::Original,
|
||||||
|
m_iconLabel->size() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_iconLabel->setFixedWidth( m_iconLabel->height() );
|
||||||
|
m_iconLabel->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No,
|
||||||
|
CalamaresUtils::Original,
|
||||||
|
m_iconLabel->size() ) );
|
||||||
|
m_iconLabel->setToolTip( "Please enter the same passphrase in both boxes." );
|
||||||
|
}
|
||||||
|
|
||||||
|
updateState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
EncryptWidget::onCheckBoxStateChanged( int state )
|
||||||
|
{
|
||||||
|
m_passphraseLineEdit->setVisible( state );
|
||||||
|
m_confirmLineEdit->setVisible( state );
|
||||||
|
m_iconLabel->setVisible( state );
|
||||||
|
m_passphraseLineEdit->clear();
|
||||||
|
m_confirmLineEdit->clear();
|
||||||
|
m_iconLabel->clear();
|
||||||
|
|
||||||
|
updateState();
|
||||||
|
}
|
57
src/modules/partition/gui/EncryptWidget.h
Normal file
57
src/modules/partition/gui/EncryptWidget.h
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2016, Teo Mrnjavac <teo@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 ENCRYPTWIDGET_H
|
||||||
|
#define ENCRYPTWIDGET_H
|
||||||
|
|
||||||
|
#include "ui_EncryptWidget.h"
|
||||||
|
|
||||||
|
class EncryptWidget : public QWidget, private Ui::EncryptWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum State : unsigned short
|
||||||
|
{
|
||||||
|
EncryptionDisabled = 0,
|
||||||
|
EncryptionUnconfirmed,
|
||||||
|
EncryptionConfirmed
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit EncryptWidget( QWidget* parent = nullptr );
|
||||||
|
|
||||||
|
State state() const;
|
||||||
|
|
||||||
|
QString passphrase() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void stateChanged( State );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void changeEvent( QEvent* e );
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateState();
|
||||||
|
void onPassphraseEdited();
|
||||||
|
void onCheckBoxStateChanged( int state );
|
||||||
|
|
||||||
|
State m_state;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ENCRYPTWIDGET_H
|
58
src/modules/partition/gui/EncryptWidget.ui
Normal file
58
src/modules/partition/gui/EncryptWidget.ui
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>EncryptWidget</class>
|
||||||
|
<widget class="QWidget" name="EncryptWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>822</width>
|
||||||
|
<height>59</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="m_encryptCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>En&crypt system</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="m_passphraseLineEdit">
|
||||||
|
<property name="echoMode">
|
||||||
|
<enum>QLineEdit::Password</enum>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Passphrase</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="m_confirmLineEdit">
|
||||||
|
<property name="echoMode">
|
||||||
|
<enum>QLineEdit::Password</enum>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Confirm passphrase</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="m_iconLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
Loading…
Reference in New Issue
Block a user