Skip to content

Commit

Permalink
Add support for placing OSes into groups
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnet committed Jun 26, 2014
1 parent 2be69ac commit ddeff50
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 14 deletions.
43 changes: 40 additions & 3 deletions BerrybootGUI2.0/adddialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void AddDialog::processData()
_ini = new QSettings("/tmp/distro.ini", QSettings::IniFormat, this);
QStringList sections = _ini->childGroups();
ui->buttonBox->button(ui->buttonBox->Ok)->setEnabled(false);
ui->osList->clear();
ui->groupTabs->clear();

foreach (QString section, sections)
{
Expand All @@ -312,6 +312,7 @@ void AddDialog::processData()
continue;
}

QString group = _ini->value("group", "Others").toString();
QString name = _ini->value("name").toString();
QString description = _ini->value("description").toString();
QString sizeinmb = QString::number(_ini->value("size", 0).toLongLong()/1024/1024);
Expand All @@ -328,7 +329,32 @@ void AddDialog::processData()
}
_ini->endGroup();

QListWidgetItem *item = new QListWidgetItem(icon, name+" ("+sizeinmb+" MB)\n"+description, ui->osList);
/* Search tab corresponding to group */
QListWidget *osList = NULL;

for (int i = 0; i < ui->groupTabs->count(); i++)
{
if (ui->groupTabs->tabText(i) == group)
{
osList = qobject_cast<QListWidget *>(ui->groupTabs->widget(i));
break;
}
}
if (!osList)
{
/* No tab for group yet, create one */
osList = new QListWidget();
osList->setIconSize(QSize(128,128));
osList->setSpacing(2);
QFont f = osList->font();
f.setPointSize(16);
osList->setFont(f);
connect(osList, SIGNAL(currentRowChanged(int)), this, SLOT(on_osList_currentRowChanged(int)));

ui->groupTabs->addTab(osList, group);
}

QListWidgetItem *item = new QListWidgetItem(icon, name+" ("+sizeinmb+" MB)\n"+description, osList);
item->setData(Qt::UserRole, section);
}

Expand Down Expand Up @@ -449,9 +475,19 @@ void AddDialog::on_osList_currentRowChanged(int)
ui->buttonBox->button(ui->buttonBox->Ok)->setEnabled(true);
}

void AddDialog::on_groupTabs_currentChanged(int)
{
ui->buttonBox->button(ui->buttonBox->Ok)->setEnabled(false);
}

void AddDialog::accept()
{
QString imagesection = ui->osList->currentItem()->data(Qt::UserRole).toString();
if (ui->groupTabs->currentIndex() == -1)
return;
QListWidget *osList = qobject_cast<QListWidget *>(ui->groupTabs->currentWidget());
if (!osList->currentItem())
return;
QString imagesection = osList->currentItem()->data(Qt::UserRole).toString();
_ini->beginGroup(imagesection);
QString url = _ini->value("url").toString();
QString alternateUrl;
Expand Down Expand Up @@ -526,3 +562,4 @@ void AddDialog::setProxy()
}
s->endGroup();
}

1 change: 1 addition & 0 deletions BerrybootGUI2.0/adddialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ protected slots:
private slots:
void on_osList_currentRowChanged(int currentRow);
void onProxySettings();
void on_groupTabs_currentChanged(int index);
};

#endif // ADDDIALOG_H
18 changes: 7 additions & 11 deletions BerrybootGUI2.0/adddialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,17 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QListWidget" name="osList">
<widget class="QTabWidget" name="groupTabs">
<property name="font">
<font>
<pointsize>16</pointsize>
<pointsize>12</pointsize>
</font>
</property>
<property name="iconSize">
<size>
<width>128</width>
<height>128</height>
</size>
</property>
<property name="spacing">
<number>2</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
<string>Loading...</string>
</attribute>
</widget>
</widget>
</item>
</layout>
Expand Down

0 comments on commit ddeff50

Please sign in to comment.