Skip to content

Commit

Permalink
Merge branch 'v1.5-development'
Browse files Browse the repository at this point in the history
UI corrections:
	- messages
	- tray icon
	- events connection
Change wake up command for device
  • Loading branch information
szszszsz committed Aug 14, 2021
2 parents f493f85 + 63e1b03 commit 00b97f7
Show file tree
Hide file tree
Showing 11 changed files with 236 additions and 44 deletions.
16 changes: 16 additions & 0 deletions i18n/nitrokey_arabic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,22 @@ Select &quot;Initialize device&quot; option from context menu.</source>
<source>Old libnitrokey library detected. Some features may not work. Minimal supported version is %1, but the current one is %2.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The selected OTP slot is already used. Are you sure you want to overwrite it?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Would you like to revert the changes?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Tray icon color:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Change color</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PinDialog</name>
Expand Down
16 changes: 16 additions & 0 deletions i18n/nitrokey_de_DE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,22 @@ Wählen Sie im Kontextmenü &quot;Gerät initialisieren&quot;.</translation>
<source>Old libnitrokey library detected. Some features may not work. Minimal supported version is %1, but the current one is %2.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The selected OTP slot is already used. Are you sure you want to overwrite it?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Would you like to revert the changes?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Tray icon color:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Change color</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PinDialog</name>
Expand Down
16 changes: 16 additions & 0 deletions i18n/nitrokey_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,22 @@ Select &quot;Initialize device&quot; option from context menu.</translation>
<source>Old libnitrokey library detected. Some features may not work. Minimal supported version is %1, but the current one is %2.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The selected OTP slot is already used. Are you sure you want to overwrite it?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Would you like to revert the changes?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Tray icon color:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Change color</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PinDialog</name>
Expand Down
16 changes: 16 additions & 0 deletions i18n/nitrokey_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,22 @@ Veuillez sélectionner l&apos;option &quot;Initialiser la clef&quot; dans le men
<source>Old libnitrokey library detected. Some features may not work. Minimal supported version is %1, but the current one is %2.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The selected OTP slot is already used. Are you sure you want to overwrite it?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Would you like to revert the changes?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Tray icon color:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Change color</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PinDialog</name>
Expand Down
16 changes: 16 additions & 0 deletions i18n/nitrokey_it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,22 @@ Seleziona l&apos;opzione &quot;Inizializza dispositivo&quot; dal menu contestual
<source>Old libnitrokey library detected. Some features may not work. Minimal supported version is %1, but the current one is %2.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The selected OTP slot is already used. Are you sure you want to overwrite it?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Would you like to revert the changes?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Tray icon color:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Change color</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PinDialog</name>
Expand Down
16 changes: 16 additions & 0 deletions i18n/nitrokey_pl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,22 @@ wybierz &quot;Zainicjalizuj urządzenie&quot; z menu kontekstowego.</translation
<source>Old libnitrokey library detected. Some features may not work. Minimal supported version is %1, but the current one is %2.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>The selected OTP slot is already used. Are you sure you want to overwrite it?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Would you like to revert the changes?</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Tray icon color:</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Change color</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PinDialog</name>
Expand Down
11 changes: 9 additions & 2 deletions src/GUI/StorageActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,8 +439,15 @@ void StorageActions::startStick20DestroyCryptedVolume(int fillSDWithRandomChars)
bool user_entered_PIN;
bool answer;

answer = (fillSDWithRandomChars == 1) || csApplet()->yesOrNoBox(tr("WARNING: Generating new AES keys will destroy the encrypted volumes, "
"hidden volumes, and password safe! Continue?"), false);
const QString &storage_string = tr("WARNING: Generating new AES keys will destroy the encrypted volumes, "
"hidden volumes, and password safe! Continue?");
const QString &pro_string = tr("WARNING: Generating new AES keys will destroy the password safe! Continue?");

QString device_string = pro_string;
if (libada::i()->isStorageDeviceConnected()) {
device_string = storage_string;
}
answer = (fillSDWithRandomChars == 1) || csApplet()->yesOrNoBox(device_string, false);
if (answer) {
PinDialog dialog(PinType::ADMIN_PIN);
user_entered_PIN = QDialog::Accepted == dialog.exec();
Expand Down
5 changes: 4 additions & 1 deletion src/GUI/graphicstools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <QStyle>
#include <QProcess>
#include <QApplication>
#include <QSettings>

bool test_if_gnome(){
#ifdef Q_OS_LINUX
Expand All @@ -26,7 +27,9 @@ QPixmap GraphicsTools::loadColorize(const QString& path, bool loadForTray, bool
QColor text_color;

if (mainTrayIcon){
text_color.setRgb(255, 0, 0);
QSettings settings;
auto color = settings.value("main/tray_icon_color", "#FF0000").toString();
text_color.setNamedColor(color);
} else {
text_color = QGuiApplication::palette().color(QPalette::WindowText);
}
Expand Down
62 changes: 51 additions & 11 deletions src/ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ void MainWindow::load_settings_page(){
emit ui->cb_debug_enabled->toggled(settings_debug_enabled);
ui->spin_PWS_time->setValue(settings.value("clipboard/PWS_time", 60).toInt());
ui->spin_OTP_time->setValue(settings.value("clipboard/OTP_time", 120).toInt());
ui->trayIconColorEdit->setText(settings.value("main/tray_icon_color", "#FF0000").toString());

ui->cb_device_connection_message->setChecked(settings.value("main/connection_message", true).toBool());
ui->cb_show_main_window_on_connection->setChecked(settings.value("main/show_main_on_connection", true).toBool());
ui->cb_hide_main_window_on_connection->setChecked(settings.value("main/close_main_on_connection", false).toBool());
Expand Down Expand Up @@ -703,6 +705,9 @@ void MainWindow::displayCurrentSlotConfig() {
ui->slotComboBox->repaint();

uint8_t slotNo = ui->slotComboBox->currentIndex();
const auto isHOTP = slotNo > TOTP_SlotCount;
ui->hotpRadioButton->setChecked(isHOTP);
ui->totpRadioButton->setChecked(!isHOTP);

if (slotNo == 255)
return;
Expand Down Expand Up @@ -842,6 +847,22 @@ void MainWindow::on_writeButton_clicked() {
const auto isHOTP = slotNo > TOTP_SlotCount;
slotNo = isHOTP? slotNo - TOTP_SlotCount -1:slotNo;

// check if this slot is already used
auto name = isHOTP? libada::i()->getHOTPSlotName(slotNo) : libada::i()->getTOTPSlotName(slotNo);
if (!name.empty() && !ui->secretEdit->text().isEmpty()) {
auto confirmation_string = tr("The selected OTP slot is already used. Are you sure you want to overwrite it?");
auto user_confirms = csApplet()->yesOrNoBox(confirmation_string, false);
if (!user_confirms) {
auto confirmation_string = tr("Would you like to revert the changes?");
auto user_wants_revert = csApplet()->yesOrNoBox(confirmation_string, false);
if (user_wants_revert) {
// repopulate the OTP slots
emit OTP_slot_write(slotNo, isHOTP);
}
return;
}
}


if (ui->nameEdit->text().isEmpty()) {
csApplet()->warningBox(tr("Please enter a slotname."));
Expand Down Expand Up @@ -1582,16 +1603,6 @@ int MainWindow::factoryResetAction() {
return 0;
}

void MainWindow::on_radioButton_2_toggled(bool checked) {
if (checked)
ui->slotComboBox->setCurrentIndex(0);
}

void MainWindow::on_radioButton_toggled(bool checked) {
if (checked)
ui->slotComboBox->setCurrentIndex(TOTP_SlotCount + 1);
}

void setCounter(int size, const QString &arg1, QLabel *counter) {
int chars_left = size - arg1.toUtf8().size();
QString t = QString::number(chars_left);
Expand Down Expand Up @@ -1761,7 +1772,7 @@ void MainWindow::on_KeepDeviceOnline() {
});

try{
nm::instance()->get_status();
nm::instance()->get_password_safe_slot_status();
//if long operation in progress jump to catch,
// clear the flag otherwise
if (long_operation_in_progress) {
Expand All @@ -1783,6 +1794,9 @@ void MainWindow::on_KeepDeviceOnline() {
}
emit OperationInProgress(e.progress_bar_value);
}
catch (CommandFailedException &e) {
// do not handle errors here
}
}

void MainWindow::show_progress_window() {
Expand Down Expand Up @@ -1864,6 +1878,9 @@ void MainWindow::on_btn_writeSettings_clicked()
settings.setValue("main/hide_on_close", ui->cb_hide_main_window_on_close->isChecked());
settings.setValue("main/show_on_start", ui->cb_show_window_on_start->isChecked());

restart_required |= ui->trayIconColorEdit->text() != settings.value("main/tray_icon_color").toString();
settings.setValue("main/tray_icon_color", ui->trayIconColorEdit->text());

settings.setValue("storage/check_symlink", ui->cb_check_symlink->isChecked());

// inform user and quit if asked
Expand Down Expand Up @@ -1906,3 +1923,26 @@ void MainWindow::on_btn_select_debug_console_clicked()
{
ui->edit_debug_file_path->setText("console");
}


void MainWindow::on_totpRadioButton_clicked(bool checked)
{
if (checked)
ui->slotComboBox->setCurrentIndex(0);
}

void MainWindow::on_hotpRadioButton_clicked(bool checked)
{
if (checked)
ui->slotComboBox->setCurrentIndex(TOTP_SlotCount + 1);
}

void MainWindow::on_btn_trayColorChange_clicked()
{
QColorDialog d;
d.setCurrentColor(ui->trayIconColorEdit->text());
auto res = d.exec();
if (res == QDialog::Accepted) {
ui->trayIconColorEdit->setText(d.currentColor().name());
}
}
8 changes: 6 additions & 2 deletions src/ui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ private slots:
void on_PWS_ButtonSaveSlot_clicked();
void on_PWS_ButtonEnable_clicked();
void on_counterEdit_editingFinished();
void on_radioButton_2_toggled(bool checked);
void on_radioButton_toggled(bool checked);
void on_PWS_EditSlotName_textChanged(const QString &arg1);
void on_PWS_EditLoginName_textChanged(const QString &arg1);
void on_PWS_EditPassword_textChanged(const QString &arg1);
Expand All @@ -199,6 +197,12 @@ private slots:

void on_btn_select_debug_console_clicked();

void on_totpRadioButton_clicked(bool checked);

void on_hotpRadioButton_clicked(bool checked);

void on_btn_trayColorChange_clicked();

public:
void generateOTPConfig(OTPSlot *slot);
unsigned int get_supported_secret_length_base32() const;
Expand Down
Loading

0 comments on commit 00b97f7

Please sign in to comment.