17 device(_device), hasShownNewFW(false),
79 ui->
profileBox->addItem((profile == hwProfile) ? QIcon(
":/img/icon_profile_hardware.png") : QIcon(
":/img/icon_profile.png"),
81 if(profile == currentProfile)
85 ui->
profileBox->addItem(QIcon(
":/img/icon_blank.png"),
"Manage profiles...");
99 item->setFlags(item->flags() | Qt::ItemIsEditable);
101 item->setSelected(
true);
131 return QIcon(
":/img/icon_mode.png");
133 return QIcon(QString(currentProfile == hwProfile ?
":/img/icon_mode%1_hardware.png" :
":/img/icon_mode%1.png").arg(i + 1));
138 QListWidgetItem* item =
new QListWidgetItem(
"New mode...",
ui->
modesList);
139 item->setFlags((item->flags() | Qt::ItemIsEditable) & ~Qt::ItemIsDragEnabled & ~Qt::ItemIsDropEnabled);
141 QFont font = item->font();
142 font.setItalic(
true);
144 item->setIcon(QIcon(
":/img/icon_plus.png"));
180 QList<KbMode*> newModes;
182 for(
int i = 0; i < count; i++){
185 if(mode && !newModes.contains(mode))
186 newModes.append(mode);
187 if(item->data(
NEW_FLAG).toInt() != 1)
189 item->setFlags(item->flags() | Qt::ItemIsEditable);
193 if(!newModes.contains(mode))
194 newModes.append(mode);
196 currentProfile->
modes(newModes);
208 QUuid guid = item->data(
GUID).toUuid();
209 if(guid.isNull() && item->data(
NEW_FLAG).toInt() == 1){
213 item->setFlags(item->flags() | Qt::ItemIsEditable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled);
214 QFont font = item->font();
215 font.setItalic(
false);
217 item->setIcon(QIcon(
":/img/icon_mode.png"));
237 QListWidgetItem* item =
ui->
modesList->itemAt(pos);
244 QAction* rename =
new QAction(
"Rename...",
this);
245 QAction* duplicate =
new QAction(
"Duplicate",
this);
246 QAction* del =
new QAction(
"Delete",
this);
250 del->setEnabled(
false);
251 QAction* moveup =
new QAction(
"Move Up",
this);
253 moveup->setEnabled(
false);
254 QAction* movedown =
new QAction(
"Move Down",
this);
255 if(index >= currentProfile->
modeCount() - 1)
256 movedown->setEnabled(
false);
257 menu.addAction(rename);
258 menu.addAction(duplicate);
261 menu.addAction(moveup);
262 menu.addAction(movedown);
263 QAction* result = menu.exec(QCursor::pos());
264 if(result == rename){
266 }
else if(result == duplicate){
269 currentProfile->
insert(index + 1, newMode);
273 }
else if(result == del){
281 if(index < currentProfile->modeCount())
285 }
else if(result == moveup){
291 }
else if(result == movedown){
332 if(newVersion <= 0.f || newVersion <= oldVersion)
335 ui->
fwUpdButton->setText(tr(
"Upgrade to v%1").arg(QString::number(newVersion,
'f', 2)));
341 if(!(qApp->keyboardModifiers() & Qt::AltModifier)){
351 if(newVersion == -1.f){
352 QMessageBox::information(
this,
"Firmware update",
"<center>There is a new firmware available for this device.<br />However, it requires a newer version of ckb.<br />Please upgrade ckb and try again.</center>");
354 }
else if(newVersion == 0.f){
355 if(QMessageBox::question(
this,
"Firmware update",
"<center>There was a problem getting the status for this device.<br />Would you like to select a file manually?</center>") != QMessageBox::Yes)
358 }
else if(newVersion <= oldVersion){
359 if(QMessageBox::question(
this,
"Firmware update",
"<center>Your firmware is already up to date.<br />Would you like to select a file manually?</center>") != QMessageBox::Yes)
371 QString path = QFileDialog::getOpenFileName(
this,
"Select firmware file", QStandardPaths::writableLocation(QStandardPaths::DownloadLocation),
"Firmware blobs (*.bin)");
375 if(!file.open(QIODevice::ReadOnly)){
376 QMessageBox::warning(parentWidget(),
"Error",
"<center>File could not be read.</center>");
379 QByteArray blob = file.readAll();
const ModeList & modes() const
void setCurrentMode(KbProfile *profile, KbMode *mode, bool spontaneous=true)
KbProfile * currentProfile()
KbMode * find(const QUuid &id)
void setCurrentProfile(KbProfile *profile, bool spontaneous=true)
void append(KbMode *newMode)
static bool hasDownloaded()
const QList< KbProfile * > & profiles() const
const QString & name() const
void removeAll(KbMode *mode)
int indexOf(KbMode *mode) const
void insert(int index, KbMode *newMode)
static float versionForBoard(const QString &features, bool waitForComplete=false)