rusificationwidget.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #include "gui\rusificationwidget.h"
  2. #include "ui_rusificationwidget.h"
  3. #include "legacyapp.h"
  4. void doStuffWithEveryItemInMyTree( QTreeWidgetItem *item )
  5. {
  6. item->setCheckState(0, Qt::Checked);
  7. for( int i = 0; i < item->childCount(); ++i )
  8. doStuffWithEveryItemInMyTree( item->child(i) );
  9. }
  10. RusificationWidget::RusificationWidget(LegacyApp *_app, QWidget *parent) :
  11. QWidget(parent),
  12. ui(new Ui::RusificationWidget),
  13. app(_app)
  14. {
  15. ui->setupUi(this);
  16. ui->treeWidget_title->expandAll();
  17. hideAllImportWidgets();
  18. ui->database_import_widget->show();
  19. doStuffWithEveryItemInMyTree(ui->treeWidget_title->invisibleRootItem());
  20. ui_update_timer.setInterval(500);
  21. connect(&ui_update_timer, &QTimer::timeout, this, &RusificationWidget::updateUI);
  22. ui_update_timer.start();
  23. }
  24. RusificationWidget::~RusificationWidget()
  25. {
  26. delete ui;
  27. }
  28. void RusificationWidget::hideAllImportWidgets()
  29. {
  30. ui->database_import_widget->hide();
  31. ui->file_import_widget->hide();
  32. ui->textfragment_import_widget->hide();
  33. }
  34. void RusificationWidget::on_database_import_radiobutton_common_clicked()
  35. {
  36. hideAllImportWidgets();
  37. ui->database_import_widget->show();
  38. }
  39. void RusificationWidget::on_file_import_radiobutton_common_clicked()
  40. {
  41. hideAllImportWidgets();
  42. ui->file_import_widget->show();
  43. }
  44. void RusificationWidget::on_textfragment_import_radiobutton_common_clicked()
  45. {
  46. hideAllImportWidgets();
  47. ui->textfragment_import_widget->show();
  48. }
  49. void RusificationWidget::updateUI()
  50. {
  51. if (app->properties.value("settings/expert_mode", 0).toBool()) {
  52. ui->tabWidget_common->tabBar()->show();
  53. } else {
  54. if (ui->tabWidget_common->currentIndex() != 0)
  55. ui->tabWidget_common->setCurrentIndex(0);
  56. ui->tabWidget_common->tabBar()->hide();
  57. }
  58. }