Added label with executed installation command.

new_installer
ivan 14 years ago
parent 25ba331c98
commit e70c063b3f

@ -7,15 +7,19 @@ class InstallerPage : public QWidget
{
Q_OBJECT
public:
InstallerPage( QWidget* parent = 0, const QString& title = QString() ) : QWidget(parent), m_Title(title) {}
InstallerPage( QWidget* parent = 0, const QString& title = QString() ) : QWidget(parent), m_Active(false),
m_Title(title) {}
virtual ~InstallerPage() {}
protected:
virtual void setupUi() = 0;
public:
QString getTitle() const { return m_Title; }
void setTitle(const QString& title ) { m_Title = title; }
void setActive() { m_Active = true; };
void clearActive() { m_Active = false; };
virtual bool validate() { return true; }
virtual void retranslateUi() = 0;
@ -28,5 +32,6 @@ public slots:
virtual void show() {}
protected:
bool m_Active;
QString m_Title;
};

@ -22,21 +22,6 @@ void PageConfiguration::setupUi()
//
m_labelHelp = new QLabel;
// mode
QHBoxLayout* hbox_builder = new QHBoxLayout;
m_labelBuilder = new QLabel;
m_chkboxBuilder = new QCheckBox;
m_chkboxBuilder->setLayoutDirection( Qt::RightToLeft );
hbox_builder->addWidget(m_labelBuilder);
hbox_builder->addWidget(m_chkboxBuilder);
QHBoxLayout* hbox_force = new QHBoxLayout;
m_labelForce = new QLabel;
m_chkboxForce = new QCheckBox;
m_chkboxForce->setLayoutDirection( Qt::RightToLeft );
hbox_force->addWidget(m_labelForce);
hbox_force->addWidget(m_chkboxForce);
// hostname
QHBoxLayout* hbox_hostname = new QHBoxLayout;
m_labelHostName = new QLabel;
@ -75,6 +60,29 @@ void PageConfiguration::setupUi()
hbox_fsformat->addWidget(m_labelFormat);
hbox_fsformat->addWidget(m_cmbboxFormat);
// composite
QHBoxLayout* hbox_composite = new QHBoxLayout;
m_labelComposite = new QLabel;
m_chkboxComposite = new QCheckBox;
m_chkboxComposite->setLayoutDirection( Qt::RightToLeft );
m_chkboxComposite->setChecked(true);
hbox_composite->addWidget(m_labelComposite);
hbox_composite->addWidget(m_chkboxComposite);
// extended parameters
m_chkboxExtParameters = new QCheckBox;
m_widgetExtParameters = new QWidget;
QVBoxLayout* vbox_extparam = new QVBoxLayout;
// mode
QHBoxLayout* hbox_builder = new QHBoxLayout;
m_labelBuilder = new QLabel;
m_chkboxBuilder = new QCheckBox;
m_chkboxBuilder->setLayoutDirection( Qt::RightToLeft );
hbox_builder->addWidget(m_labelBuilder);
hbox_builder->addWidget(m_chkboxBuilder);
// #-mbr-# [w] "on"
QHBoxLayout* hbox_writembr = new QHBoxLayout;
m_labelWriteMbr = new QLabel;
@ -92,21 +100,6 @@ void PageConfiguration::setupUi()
hbox_useuuid->addWidget(m_labelUseUUID);
hbox_useuuid->addWidget(m_chkboxUseUUID);
// composite
QHBoxLayout* hbox_composite = new QHBoxLayout;
m_labelComposite = new QLabel;
m_chkboxComposite = new QCheckBox;
m_chkboxComposite->setLayoutDirection( Qt::RightToLeft );
m_chkboxComposite->setChecked(true);
hbox_composite->addWidget(m_labelComposite);
hbox_composite->addWidget(m_chkboxComposite);
// extended parameters
m_chkboxExtParameters = new QCheckBox;
m_widgetExtParameters = new QWidget;
QVBoxLayout* vbox_extparam = new QVBoxLayout;
// #-type-# [w] ["hdd", "flash", "usb-hdd"]
QHBoxLayout* hbox_disktype = new QHBoxLayout;
m_labelDiskType = new QLabel;
@ -136,6 +129,9 @@ void PageConfiguration::setupUi()
hbox_cpushed->addWidget(m_labelIOShed);
hbox_cpushed->addWidget(m_cmbboxIOShed);
vbox_extparam->addLayout(hbox_builder);
vbox_extparam->addLayout(hbox_writembr);
vbox_extparam->addLayout(hbox_useuuid);
vbox_extparam->addLayout(hbox_disktype);
vbox_extparam->addLayout(hbox_videodrv);
vbox_extparam->addLayout(hbox_videores);
@ -144,34 +140,25 @@ void PageConfiguration::setupUi()
m_widgetExtParameters->setVisible(false);
connect(m_chkboxExtParameters, SIGNAL(toggled(bool)), m_widgetExtParameters, SLOT(setVisible(bool)) );
// command
m_labelDescCommand = new QLabel;
m_labelCommand = new QLabel;
QFont fontCmd = QApplication::font();
fontCmd.setFamily("Droid Sans Mono");
m_labelCommand->setFont( fontCmd );
m_labelCommand->setWordWrap(true);
//
QVBoxLayout* vbox_pageconf = new QVBoxLayout;
vbox_pageconf->addWidget( m_labelHelp );
vbox_pageconf->addLayout(hbox_builder);
vbox_pageconf->addLayout(hbox_force);
vbox_pageconf->addLayout(hbox_hostname);
vbox_pageconf->addLayout(hbox_language);
vbox_pageconf->addLayout(hbox_timezone);
vbox_pageconf->addLayout(hbox_erase);
vbox_pageconf->addLayout(hbox_fsformat);
vbox_pageconf->addLayout(hbox_writembr);
vbox_pageconf->addLayout(hbox_useuuid);
vbox_pageconf->addLayout(hbox_composite);
QFrame* hline = new QFrame;
hline->setFrameShape(QFrame::HLine);
hline->setFrameShadow(QFrame::Sunken);
vbox_pageconf->addWidget(hline);
vbox_pageconf->addWidget(m_chkboxExtParameters);
vbox_pageconf->addWidget(m_widgetExtParameters);
vbox_pageconf->addStretch();
vbox_pageconf->addWidget(m_labelDescCommand);
vbox_pageconf->addWidget(m_labelCommand);
//
setLayout( vbox_pageconf );
@ -183,7 +170,6 @@ void PageConfiguration::setupUi()
void PageConfiguration::mapSignals()
{
connect(m_chkboxBuilder, SIGNAL(toggled(bool)), this, SLOT(generateCommand()));
connect(m_chkboxForce, SIGNAL(toggled(bool)), this, SLOT(generateCommand()));
connect(m_editHostname, SIGNAL(textChanged(QString)), this, SLOT(generateCommand()));
connect(m_cmbboxLanguage, SIGNAL(currentIndexChanged(int)), this, SLOT(generateCommand()));
connect(m_cmbboxTimezone, SIGNAL(currentIndexChanged(int)), this, SLOT(generateCommand()));
@ -206,7 +192,6 @@ void PageConfiguration::retranslateUi()
m_labelHelp->setText( tr("Select parameters: ") );
m_labelBuilder->setText( tr("Installation for assembling") );
m_labelForce->setText( tr("Do not prompt before overwriting") );
m_labelHostName->setText( tr("Hostname: ") );
m_editHostname->setText( "calculate" );
@ -832,7 +817,7 @@ void PageConfiguration::retranslateUi()
m_cmbboxVideoDrv->addItem("vmware");
m_labelComposite->setText( tr("Use composite") );
m_labelComposite->setText( tr("Use desktop effects") );
m_chkboxExtParameters->setText( tr("Expert settings") );
@ -845,11 +830,8 @@ void PageConfiguration::retranslateUi()
m_cmbboxIOShed->addItem("noop");
m_cmbboxIOShed->addItem("deadline");
m_labelDescCommand->setText( tr("Command for install:") );
}
bool PageConfiguration::validate()
{
if ( !m_editHostname->text().isEmpty() )
@ -857,7 +839,6 @@ bool PageConfiguration::validate()
InstallerSettings settings;
settings.builder = m_chkboxBuilder->isChecked();
settings.force = m_chkboxForce->isChecked();
settings.host = m_editHostname->text();
settings.language = m_cmbboxLanguage->itemData( m_cmbboxLanguage->currentIndex() ).toString();
settings.timezone = m_cmbboxTimezone->currentText();
@ -878,28 +859,32 @@ bool PageConfiguration::validate()
void PageConfiguration::generateCommand()
{
if (!m_Active)
return;
QString cmd = "calculate ";
cmd += m_chkboxBuilder->isChecked() ? "--build " : "";
cmd += m_chkboxForce->isChecked() ? "--force " : "";
cmd += QString("--disk=%1 ").arg( *m_Disk );
cmd += QString("--set-hostname=%1 ").arg( m_editHostname->text() );
cmd += QString("--set-lang=%1 ").arg( m_cmbboxLanguage->itemData(m_cmbboxLanguage->currentIndex()).toString() );
cmd += QString("--set-timezone=%1 ").arg( m_cmbboxTimezone->currentText() );
cmd += QString("--set-format=%1 ").arg( m_cmbboxFormat->currentText() );
cmd += m_chkboxErase->isChecked() ? "--set-erase=yes " : "";
cmd += m_chkboxWriteMbr->isChecked() ? "--set-mbr=yes " : "";
cmd += m_chkboxUseUUID->isChecked() ? "--set-uuid=yes " : "";
cmd += m_chkboxComposite->isChecked() ? "--set-composite=yes " : "";
if (m_chkboxExtParameters->isChecked())
{
cmd += m_chkboxBuilder->isChecked() ? "--build " : "";
cmd += m_chkboxWriteMbr->isChecked() ? "--set-mbr=yes " : "";
cmd += m_chkboxUseUUID->isChecked() ? "--set-uuid=yes " : "";
cmd += QString("--set-type=%1 ").arg( m_cmbboxDiskType->currentText() );
cmd += QString("--set-video_drv=%1 ").arg( m_cmbboxVideoDrv->currentText() );
cmd += QString("--set-video_resolution=%1 ").arg( m_editVideoRes->text() );
cmd += QString("--set-scheduler=%1 ").arg( m_cmbboxIOShed->currentText() );
}
m_labelCommand->setText(cmd);
emit updatedCommand(cmd);
}
void PageConfiguration::show()
{

@ -31,6 +31,7 @@ private slots:
signals:
void selectedSettings(InstallerSettings);
void updatedCommand(QString);
private:
const QString* m_Disk;
@ -40,8 +41,6 @@ private:
QLabel* m_labelBuilder;
QCheckBox* m_chkboxBuilder;
QLabel* m_labelForce;
QCheckBox* m_chkboxForce;
QLabel* m_labelHostName;
QLineEdit* m_editHostname;
@ -75,9 +74,5 @@ private:
QLineEdit* m_editVideoRes;
QLabel* m_labelIOShed;
QComboBox* m_cmbboxIOShed;
QLabel* m_labelDescCommand;
QLabel* m_labelCommand;
};

@ -64,10 +64,10 @@ void PageInstall::show()
QStringList args;
args << "--force";
if (m_Settings->builder)
args << "--build";
if (m_Settings->force)
args << "--force";
args << QString("--disk=%1").arg(m_Settings->disk);
args << QString("--set-hostname=%1").arg(m_Settings->host);
@ -82,7 +82,6 @@ void PageInstall::show()
args << QString("--set-type=%1").arg( m_Settings->disktype );
args << QString("--set-video_drv=%1").arg( m_Settings->videodrv );
m_clProc->start("calculate", args);
}
}

@ -49,6 +49,7 @@ void PageManager::showOnce(InstallerPage* page)
{
Q_ASSERT_X( page != 0, "PageManager::showOnce", "page pointer is 0");
if (page)
{
removeStackedPage();
@ -106,10 +107,12 @@ void PageManager::pageUpdate()
foreach(InstallerPage* page, m_Pages)
{
QString title = page->getTitle();
page->clearActive();
if (title == (*m_CurPage)->getTitle())
{
title = "<b>" + title + "</b>";
page->setActive();
page->show();
}
title += "<br>";

@ -8,6 +8,8 @@
#include <QPushButton>
#include <QGroupBox>
#include <QLocale>
#include <QAction>
#include <QMenu>
#include "pagemanager.h"
@ -54,7 +56,7 @@ void SystemInstaller::setupUi()
hbox_buttons->addWidget( m_butNext );
hbox_buttons->addWidget( m_butFinish );
// right pannel = widget for pages + buttons
// right pannel = widget for pages
m_stackPages = new QStackedWidget;
QVBoxLayout* vbox_1( new QVBoxLayout );
@ -65,13 +67,13 @@ void SystemInstaller::setupUi()
group_box_page->setLayout( group_box_page_l );
vbox_1->addWidget( group_box_page );
vbox_1->addLayout( hbox_buttons );
// left pannel
// logo
m_labelImage = new QLabel;
m_labelImage->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter );
m_labelImage->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum );
m_labelImage->setMargin(10);
m_labelPages = new QLabel;
@ -83,12 +85,29 @@ void SystemInstaller::setupUi()
group_box_list->setLayout( group_box_list_l );
// cmd pannel
QGroupBox* cmd_grp = new QGroupBox;
m_labelInstCmd = new QLabel;
QFont fontCmd = QApplication::font();
fontCmd.setFamily("Droid Sans Mono");
m_labelInstCmd->setFont(fontCmd);
m_labelInstCmd->setWordWrap(true);
QHBoxLayout* cmd_layout = new QHBoxLayout;
cmd_layout->addWidget(m_labelInstCmd);
cmd_grp->setLayout(cmd_layout);
// left + right pannels
QHBoxLayout* hbox_2( new QHBoxLayout );
hbox_2->addWidget( group_box_list, 2 );
hbox_2->addLayout( vbox_1, 9);
centralWidget->setLayout(hbox_2);
QVBoxLayout* vbox_main( new QVBoxLayout );
vbox_main->addLayout( hbox_2 );
vbox_main->addWidget( cmd_grp );
vbox_main->addLayout( hbox_buttons );
centralWidget->setLayout(vbox_main);
setCentralWidget( centralWidget );
// set windows icon
@ -104,6 +123,16 @@ void SystemInstaller::setupUi()
QImage logo = QImage(":/img/calculate-logo.png").scaledToWidth( 120, Qt::SmoothTransformation);
m_labelImage->setPixmap( QPixmap::fromImage(logo) );
m_actCopy = new QAction( this );
//m_actCopy->setShortcut( QKeySequence("Ctrl+C") );
connect( m_actCopy, SIGNAL(triggered()), this, SLOT(copyCmd()) );
m_menuCopy = new QMenu(this);
m_menuCopy->addAction(m_actCopy);
m_labelInstCmd->setContextMenuPolicy(Qt::CustomContextMenu);
connect( m_labelInstCmd, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showCopyMenu(QPoint)) );
retranslateUi();
}
@ -131,6 +160,9 @@ void SystemInstaller::setupInstallerPages()
connect( pageConfiguration, SIGNAL(selectedSettings(InstallerSettings)),
this, SLOT(selectConfiguration(InstallerSettings))
);
connect( pageConfiguration, SIGNAL(updatedCommand(QString)),
m_labelInstCmd, SLOT(setText(QString))
);
m_PageManager->addPage(pageConfiguration);
PageInstall* pageInstall( new PageInstall( &m_InstallSettings ) );
@ -155,6 +187,8 @@ void SystemInstaller::retranslateUi()
m_butNext->setText( tr("Next") );
m_butFinish->setText( tr("Finish") );
m_actCopy->setText( tr("Copy") );
if (m_PageManager)
m_PageManager->retranslatePages();
}
@ -245,3 +279,14 @@ void SystemInstaller::selectConfiguration(InstallerSettings settings)
m_InstallSettings = settings;
}
void SystemInstaller::showCopyMenu(const QPoint& point)
{
m_menuCopy->popup( m_labelInstCmd->mapToGlobal(point) );
}
void SystemInstaller::copyCmd()
{
QClipboard* clipboard = QApplication::clipboard();
clipboard->setText( m_labelInstCmd->text() );
}

@ -9,6 +9,8 @@
class QPushButton;
class QLabel;
class QStackedWidget;
class QAction;
class QMenu;
class QTranslator;
@ -47,6 +49,9 @@ private slots:
void selectVolume(QString volume);
void selectConfiguration(InstallerSettings settings);
void showCopyMenu(const QPoint& point);
void copyCmd();
signals:
void selectedConfiguration(InstallerSettings settings);
@ -58,6 +63,10 @@ private:
QLabel* m_labelImage;
QLabel* m_labelPages;
QStackedWidget* m_stackPages;
QLabel* m_labelInstCmd;
QAction* m_actCopy;
QMenu* m_menuCopy;
//
QTranslator* m_Translator;

@ -4,19 +4,21 @@
struct InstallerSettings
{
bool builder;
bool force;
QString disk;
QString host;
QString language;
QString timezone;
bool erase;
QString fs;
bool composite;
bool expert;
bool builder;
bool mbr;
bool uuid;
QString disktype;
QString videodrv;
//QString videores;
QString videores;
};

Loading…
Cancel
Save