int Dialog::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QDialog::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: setInteger(); break; case 1: setDouble(); break; case 2: setItem(); break; case 3: setText(); break; case 4: setColor(); break; case 5: setFont(); break; case 6: setExistingDirectory(); break; case 7: setOpenFileName(); break; case 8: setOpenFileNames(); break; case 9: setSaveFileName(); break; case 10: criticalMessage(); break; case 11: informationMessage(); break; case 12: questionMessage(); break; case 13: warningMessage(); break; case 14: errorMessage(); break; default: ; } _id -= 15; } return _id; }
int DialogClone::do_image_partition() { MWindow window; QString befehl; QString _Datum_clone = window.Zeit_auslesen(); Qt::CheckState state; lbl_save->setText (tr("already saved", "bereits gesichert")); state = chk_zip->checkState(); flag_clone =3; if (img_partition_clone == "" ){ QMessageBox::about(this, tr("Note", "Hinweis"), tr("You must select a partition.", "Sie müssen eine Partition auswählen.\n")); return 0; } if (folder_clone == "" ){ QMessageBox::about(this, tr("Note", "Hinweis"), tr("You must select a folder.", "Sie müssen ein Verzeichnis auswählen.\n")); return 0; } partition_exist_size_int = img_partition_size.toInt(); // Überprüfen, ob System oder Home-Partition auf der Festplatte vorhanden ist int part_art_clone = mountpoint(img_partition_clone); if (part_art_clone == 1){ QMessageBox::about(this, tr("Note", "Hinweis"), tr("On the hard drive exist a root or a home partition. You must need a live-CD.", "Auf der Festplatte ist eine root- oder home Partition. Sie müssen eine Live-CD benutzen.\n")); return 0; } if (state == Qt::Checked) befehl = "dd if=/dev/" + img_partition_clone + " | gzip --best > " + folder_clone + "/" + img_partition_clone + "-" + _Datum_clone + "-gz.part.fsa"; else befehl = "dd if=/dev/" + img_partition_clone + " of=" + folder_clone + "/" + img_partition_clone + "-" + _Datum_clone + "-part.fsa bs=1M 2>" + homepath + "/.config/qt5-fsarchiver/disk.txt"; thread1.setValues( 0,befehl); int ret = questionMessage(tr(" Do you want really built a image from a partition? ", " Wollen Sie wirklich ein Abbild einer Partition erstellen? ") ); if (ret == 2) return 0; if (ret == 1){ bt_end->setEnabled(false); bt_save->setEnabled(false); ViewProzent(); this->setCursor(Qt::WaitCursor); if (state == Qt::Checked){ read_write_hd(); startThread1(1); } else startThread1(0); qDebug() << "The image is created"; } return 0; }
int NetEin:: go() { extern int dialog_auswertung; QString key; Qt::CheckState state; state = chk_datesave->checkState(); QSettings setting("qt5-fsarchiver", "qt5-fsarchiver"); setting.beginGroup(comNet_name); user = txt_user->text(); key = txt_key->text(); if (comNet == "" && dialog_auswertung == 6) { QMessageBox::about(this, tr("Note", "Hinweis"), tr("You must select the computer on which the backup data to be written\n", "Sie müssen den Rechner auswählen, auf den die Sicherungsdaten geschrieben werden sollen\n")); return 1 ; } if (comNet == "" && dialog_auswertung == 7) { QMessageBox::about(this, tr("Note", "Hinweis"), tr("You must select your computer from which the backup data to be written back\n", "Sie müssen den Rechner auswählen, von dem die Sicherungsdaten zurück geschrieben werden sollen\n")); return 1 ; } if (user == "" ) { QMessageBox::about(this, tr("Note","Hinweis"), tr("You must enter the user name. Can not otherwise be accessible to network computers\n", "Sie müssen den Benutzernamen eingeben. Sonst kann nicht auf Netzrechner zugegriffen werden\n")); return 1 ; } if (key == "" ) { int ret = questionMessage(tr("Is it true that you have entered a key? (NFS dont need a key)", "Ist das richtig, dass Sie keinen Schlüssel eingegeben haben? (NFS benötigt keinen Schlüssel)")); if (ret == 2) return 1; } if (state == Qt::Checked ) { setting.setValue("Name",user); setting.setValue("key",crypt(key)); } setting.endGroup(); int i = setting_save(); if (dialog_auswertung == 6 && i == 0) save_net(); if (dialog_auswertung == 7 && i == 0) restore_net(); return 0; }
void DialogDIR::esc_end() { MWindow window; QString befehl; if (thread_run_dir > 0) { int ret = questionMessage(tr("Do you want really break the save or restore from the folder?", "Wollen Sie wirklich die Sicherung oder Wiederherstellung der Verzeichnisse beenden?")); if (thread_run_dir == 1 && ret == 1) { flag_end_dir= 1; befehl = "rm " + SicherungsFolderFileName_dir; system (befehl.toLatin1().data()); if (window.bit_version() == "64") { thread1.terminate(); thread1.wait(); close(); } if (window.bit_version() == "32") { befehl = "kill -15 " + pid1_dir; //fsarchiver abbrechen system (befehl.toLatin1().data()); befehl = "kill -15 " + pid_dir; //fsarchiver abbrechen system (befehl.toLatin1().data()); close(); } } if (thread_run_dir == 2 && ret == 1 ) { flag_end_dir= 1; if (window.bit_version() == "64") { thread1.terminate(); thread1.wait(); close(); } if (window.bit_version() == "32") { befehl = "kill -15 " + pid1_dir; //fsarchiver abbrechen system (befehl.toLatin1().data()); befehl = "kill -15 " + pid_dir; //fsarchiver abbrechen system (befehl.toLatin1().data()); close(); } } } }
void DialogClone::esc_end() { QString befehl; pid_2_ermitteln("dd"); if (thread_run_clone > 0) { int ret = questionMessage(tr("Do you want really break clone, save or restore an image from the partition?", "Wollen Sie wirklich das Klonen der Festplatte, die Erstellung oder die Wiederherstellung eines Images der Festplatte beenden?")); if (thread_run_clone == 1 && ret == 1 or thread_run_clone == 2 && ret == 1) { befehl = "rm " + folder_clone + partition_name + ".gz.fsa"; QFile file(folder_clone + partition_name + ".gz.fsa"); if (file.exists()) system (befehl.toAscii().data()); befehl = "kill -15 " + pid_2_dd[0]; //dd abbrechen system (befehl.toAscii().data()); befehl = "kill -15 " + pid_2_dd[1]; //dd abbrechen system (befehl.toAscii().data()); // qApp->quit(); flag_clone =0; close(); }} }
Dialogs::Dialogs(QWidget *parent) : QWidget(parent), ui(new Ui::Dialogs) { ui->setupUi(this); setWindowTitle(tr("Standard Dialogs")); ui->native_checkBox->setChecked(true); // signals connect(ui->integer_pushButton, SIGNAL(clicked()), this, SLOT(setInteger())); connect(ui->double_pushButton, SIGNAL(clicked()), this, SLOT(setDouble())); connect(ui->getItem_pushButton, SIGNAL(clicked()), this, SLOT(setItem())); connect(ui->getText_pushButton, SIGNAL(clicked()), this, SLOT(setText())); connect(ui->dir_pushButton, SIGNAL(clicked()), this, SLOT(setExistingDirectory())); connect(ui->openFile_pushButton, SIGNAL(clicked()), this, SLOT(setOpenFileName())); connect(ui->openFiles_pushButton, SIGNAL(clicked()), this, SLOT(setOpenFileNames())); connect(ui->critical_pushButton, SIGNAL(clicked()), this, SLOT(criticalMessage())); connect(ui->info_pushButton, SIGNAL(clicked()), this, SLOT(informationMessage())); connect(ui->quest_pushButton, SIGNAL(clicked()), this, SLOT(questionMessage())); connect(ui->warn_pushButton, SIGNAL(clicked()), this, SLOT(warningMessage())); connect(ui->error_pushButton, SIGNAL(clicked()), this, SLOT(errorMessage())); }
int DialogClone::restore_image() { QString befehl; int row; int pos; QString partition_exist; QString partition_exist_size; Qt::CheckState state; lbl_save->setText (tr("already restored", "bereits zurückgeschrieben")); state = chk_zip->checkState(); flag_clone =2; row = listWidget_exist->currentRow(); if (row > -1){ partition_exist = part_clone[row][0] ; partition_exist_size = part_clone[row][1]; pos = partition_exist_size.indexOf("."); if (pos > 0) partition_exist_size = partition_exist_size.left(partition_exist_size.size() -2); partition_exist_size_int = partition_exist_size.toInt(); } partition_exist = partition_exist.left(partition_exist.size() -1); if (partition_exist == "" ){ QMessageBox::about(this, tr("Note", "Hinweis"), tr("You must select a hard drive.", "Sie müssen eine Festplatte auswählen.\n")); return 0; } if (folder_clone == "" ){ QMessageBox::about(this, tr("Note", "Hinweis"), tr("You must select a gz.fsa file or an img.fsa file.", "Sie müssen eine gz.fsa- oder eine img.fsa-Datei auswählen.\n")); return 0; } if (file_check() == 1) return 0; // Prüfen, ob gesicherte und wiederherzustellende Partition übereinstimmt. // Festplatte aus folder_clone extrahieren QString disk_name; pos = folder_clone.indexOf(".gz.fsa"); if (pos > -1) disk_name = folder_clone.mid(pos-14,3); pos = folder_clone.indexOf(".img.fsa"); if (pos > -1) disk_name = folder_clone.mid(pos-14,3); disk_name = partition_exist.right(partition_exist.size() -4); if (folder_clone.indexOf(disk_name) == -1) pos = questionMessage(tr("Partition to restore ", "Die wiederherzustellende Partition ") + disk_name + tr(" does not coincide with the saved ", " stimmt nicht mit der gesicherten ") + img_partition_clone + tr(" Do you want to continue restore?", " überein. Wollen Sie trotzdem die Wiederherstellung durchführen?")); if (pos == 2) //nicht wiederherstellen return 0; // Überprüfen, ob System oder Home-Partition auf der Festplatte vorhanden ist int part_art_clone = mountpoint(partition_exist); if (part_art_clone == 1){ QMessageBox::about(this, tr("Note", "Hinweis"), tr("On the hard drive exist a root or a home partition. You must need a live-CD.", "Auf der Festplatte ist eine root- oder home Partition. Sie müssen eine Live-CD benutzen.\n")); return 0; } partition_name = partition_exist.right(partition_exist.size() -4); //Prüfen ob img.fsa oder gz.fsa Datei if (folder_clone.indexOf("gz.fsa") > 0) befehl = "gunzip -c " + folder_clone + " | sudo dd of=" + partition_exist; if (folder_clone.indexOf("img.fsa") > 0) befehl = "dd if=" + folder_clone + " of=" + partition_exist + " bs=1M 2>" + homepath + "/.config/qt5-fsarchiver/disk.txt"; int ret = questionMessage(tr(" Do you want really restore the image of the hard drive? ", " Wollen Sie wirklich ein Abbild der Festplatte zurückschreiben? ") ); if (ret == 2) return 0; if (ret == 1){ bt_end->setEnabled(false); bt_save->setEnabled(false); thread2.setValues( 0,befehl); ViewProzent(); this->setCursor(Qt::WaitCursor); pos = folder_clone.indexOf("gz.fsa"); if (pos > 0){ read_write_hd(); startThread2(1); } else startThread2(0); qDebug() << "The image is written back"; } return 0; }
int DialogClone::do_image() { MWindow window; QString _Datum_clone = window.Zeit_auslesen(); QString befehl; int row; int pos; QString partition_exist; QString partition_exist_size; Qt::CheckState state; lbl_save->setText (tr("already saved", "bereits gesichert")); state = chk_zip->checkState(); flag_clone =2; row = listWidget_exist->currentRow(); if (row > -1){ partition_exist = part_clone[row][0] ; partition_exist_size = part_clone[row][1]; pos = partition_exist_size.indexOf("."); if (pos > 0) partition_exist_size = partition_exist_size.left(partition_exist_size.size() -2); partition_exist_size_int = partition_exist_size.toInt(); } partition_exist = partition_exist.left(partition_exist.size() -1); //qDebug() << "partition_exist_size_int" << partition_exist_size_int; //return 0; if (partition_exist == "" ){ QMessageBox::about(this, tr("Note", "Hinweis"), tr("You must select a partition.", "Sie müssen eine Partition auswählen.\n")); return 0; } if (folder_clone == "" ){ QMessageBox::about(this, tr("Note", "Hinweis"), tr("You must select a folder.", "Sie müssen ein Verzeichnis auswählen.\n")); return 0; } // Überprüfen, ob System oder Home-Partition auf der Festplatte vorhanden ist int part_art_clone = mountpoint(partition_exist); if (part_art_clone == 1){ QMessageBox::about(this, tr("Note", "Hinweis"), tr("On the hard drive exist a root or a home partition. You must need a live-CD.", "Auf der Festplatte ist eine root- oder home Partition. Sie müssen eine Live-CD benutzen.\n")); return 0; } partition_name = partition_exist.right(partition_exist.size() -4); if (state == Qt::Checked) befehl = "dd if=" + partition_exist + " | gzip --best > " + folder_clone + partition_name + "-" + _Datum_clone + ".gz.fsa"; else befehl = "dd if=" + partition_exist + " of=" + folder_clone + partition_name + "-" + _Datum_clone + ".img.fsa bs=1M 2>" + homepath + "/.config/qt5-fsarchiver/disk.txt"; thread1.setValues( 0,befehl); int ret = questionMessage(tr(" Do you want really built a image from the hard drive? ", " Wollen Sie wirklich ein Abbild der Festplatte erstellen? ") ); if (ret == 2) return 0; if (ret == 1){ bt_end->setEnabled(false); bt_save->setEnabled(false); ViewProzent(); this->setCursor(Qt::WaitCursor); if (state == Qt::Checked){ read_write_hd(); startThread1(1);} else startThread1(0); qDebug() << "The image is created"; } return 0; }
int DialogClone::do_clone() { QString befehl; int row; int pos; QString partition_exist; QString partition_exist_size; QString partition_clone; QString partition_clone_size; int partition_clone_size_int; lbl_save->setText (tr("already saved", "bereits gesichert")); QFile file(homepath + "/.config/qt5-fsarchiver/disk.txt"); befehl = "rm " + homepath + "/.config/qt5-fsarchiver/disk.txt"; if (file.exists()) system (befehl.toAscii().data()); flag_clone =1; row = listWidget_exist->currentRow(); if (row > -1){ partition_exist = part_clone[row][0] ; partition_exist_size = part_clone[row][1]; pos = partition_exist_size.indexOf("."); if (pos > 0) partition_exist_size = partition_exist_size.left(partition_exist_size.size() -2); partition_exist_size_int = partition_exist_size.toInt(); } row = listWidget_clone->currentRow(); if (row > -1){ partition_clone = part_clone[row][0] ; partition_clone_size = part_clone[row][1]; pos = partition_clone_size.indexOf("."); if (pos > 0) partition_clone_size = partition_clone_size.left(partition_clone_size.size() -2); partition_clone_size_int = partition_clone_size.toInt(); } partition_exist = partition_exist.left(partition_exist.size() -1); partition_clone = partition_clone.left(partition_clone.size() -1); if (partition_exist == "" or partition_clone == ""){ QMessageBox::about(this, tr("Note", "Hinweis"), tr("You must select a hard drive.", "Sie müssen eine Festplatte auswählen.\n")); return 0; } // Überprüfen, ob Festplatte groß genug ist if (partition_exist_size_int > partition_clone_size_int){ QMessageBox::about(this, tr("Note", "Hinweis"), tr("The selected hard drive is too small.", "Die gewählte Festplatte ist zu klein.\n")); return 0; } // Überprüfen, ob System oder Home-Partition auf der Festplatte vorhanden ist int part_art_clone = mountpoint(partition_exist); if (part_art_clone == 1){ QMessageBox::about(this, tr("Note", "Hinweis"), tr("On the hard drive exist a root or a home partition. You must need a live-CD.", "Auf der Festplatte ist eine root- oder home Partition. Sie müssen eine Live-CD benutzen.\n")); return 0; } befehl = "dd if=" + partition_exist + " of=" + partition_clone + " bs=1M 2>" + homepath + "/.config/qt5-fsarchiver/disk.txt"; int ret = questionMessage(tr(" Do you want really clone the hard drive? All dates on ", " Wollen Sie wirklich die Festplatte klonen? Alle Daten auf der Festplatte ") + partition_clone + tr(" are deleted!", " werden gelöscht!") ); if (ret == 2) return 0; thread1.setValues( 0,befehl); ViewProzent(); this->setCursor(Qt::WaitCursor); startThread1(0); return 0; }
Dialog::Dialog(QWidget *parent) : QWidget(parent) { QVBoxLayout *mainLayout = new QVBoxLayout(this); QToolBox *toolbox = new QToolBox; mainLayout->addWidget(toolbox); errorMessageDialog = new QErrorMessage(this); int frameStyle = QFrame::Sunken | QFrame::Panel; integerLabel = new QLabel; integerLabel->setFrameStyle(frameStyle); QPushButton *integerButton = new QPushButton(tr("QInputDialog::get&Int()")); doubleLabel = new QLabel; doubleLabel->setFrameStyle(frameStyle); QPushButton *doubleButton = new QPushButton(tr("QInputDialog::get&Double()")); itemLabel = new QLabel; itemLabel->setFrameStyle(frameStyle); QPushButton *itemButton = new QPushButton(tr("QInputDialog::getIte&m()")); textLabel = new QLabel; textLabel->setFrameStyle(frameStyle); QPushButton *textButton = new QPushButton(tr("QInputDialog::get&Text()")); multiLineTextLabel = new QLabel; multiLineTextLabel->setFrameStyle(frameStyle); QPushButton *multiLineTextButton = new QPushButton(tr("QInputDialog::get&MultiLineText()")); colorLabel = new QLabel; colorLabel->setFrameStyle(frameStyle); QPushButton *colorButton = new QPushButton(tr("QColorDialog::get&Color()")); fontLabel = new QLabel; fontLabel->setFrameStyle(frameStyle); QPushButton *fontButton = new QPushButton(tr("QFontDialog::get&Font()")); directoryLabel = new QLabel; directoryLabel->setFrameStyle(frameStyle); QPushButton *directoryButton = new QPushButton(tr("QFileDialog::getE&xistingDirectory()")); openFileNameLabel = new QLabel; openFileNameLabel->setFrameStyle(frameStyle); QPushButton *openFileNameButton = new QPushButton(tr("QFileDialog::get&OpenFileName()")); openFileNamesLabel = new QLabel; openFileNamesLabel->setFrameStyle(frameStyle); QPushButton *openFileNamesButton = new QPushButton(tr("QFileDialog::&getOpenFileNames()")); saveFileNameLabel = new QLabel; saveFileNameLabel->setFrameStyle(frameStyle); QPushButton *saveFileNameButton = new QPushButton(tr("QFileDialog::get&SaveFileName()")); criticalLabel = new QLabel; criticalLabel->setFrameStyle(frameStyle); QPushButton *criticalButton = new QPushButton(tr("QMessageBox::critica&l()")); informationLabel = new QLabel; informationLabel->setFrameStyle(frameStyle); QPushButton *informationButton = new QPushButton(tr("QMessageBox::i&nformation()")); questionLabel = new QLabel; questionLabel->setFrameStyle(frameStyle); QPushButton *questionButton = new QPushButton(tr("QMessageBox::&question()")); warningLabel = new QLabel; warningLabel->setFrameStyle(frameStyle); QPushButton *warningButton = new QPushButton(tr("QMessageBox::&warning()")); errorLabel = new QLabel; errorLabel->setFrameStyle(frameStyle); QPushButton *errorButton = new QPushButton(tr("QErrorMessage::showM&essage()")); connect(integerButton, SIGNAL(clicked()), this, SLOT(setInteger())); connect(doubleButton, SIGNAL(clicked()), this, SLOT(setDouble())); connect(itemButton, SIGNAL(clicked()), this, SLOT(setItem())); connect(textButton, SIGNAL(clicked()), this, SLOT(setText())); connect(multiLineTextButton, SIGNAL(clicked()), this, SLOT(setMultiLineText())); connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor())); connect(fontButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(directoryButton, SIGNAL(clicked()), this, SLOT(setExistingDirectory())); connect(openFileNameButton, SIGNAL(clicked()), this, SLOT(setOpenFileName())); connect(openFileNamesButton, SIGNAL(clicked()), this, SLOT(setOpenFileNames())); connect(saveFileNameButton, SIGNAL(clicked()), this, SLOT(setSaveFileName())); connect(criticalButton, SIGNAL(clicked()), this, SLOT(criticalMessage())); connect(informationButton, SIGNAL(clicked()), this, SLOT(informationMessage())); connect(questionButton, SIGNAL(clicked()), this, SLOT(questionMessage())); connect(warningButton, SIGNAL(clicked()), this, SLOT(warningMessage())); connect(errorButton, SIGNAL(clicked()), this, SLOT(errorMessage())); QWidget *page = new QWidget; QGridLayout *layout = new QGridLayout(page); layout->setColumnStretch(1, 1); layout->setColumnMinimumWidth(1, 250); layout->addWidget(integerButton, 0, 0); layout->addWidget(integerLabel, 0, 1); layout->addWidget(doubleButton, 1, 0); layout->addWidget(doubleLabel, 1, 1); layout->addWidget(itemButton, 2, 0); layout->addWidget(itemLabel, 2, 1); layout->addWidget(textButton, 3, 0); layout->addWidget(textLabel, 3, 1); layout->addWidget(multiLineTextButton, 4, 0); layout->addWidget(multiLineTextLabel, 4, 1); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 5, 0); toolbox->addItem(page, tr("Input Dialogs")); const QString doNotUseNativeDialog = tr("Do not use native dialog"); page = new QWidget; layout = new QGridLayout(page); layout->setColumnStretch(1, 1); layout->addWidget(colorButton, 0, 0); layout->addWidget(colorLabel, 0, 1); colorDialogOptionsWidget = new DialogOptionsWidget; colorDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QColorDialog::DontUseNativeDialog); colorDialogOptionsWidget->addCheckBox(tr("Show alpha channel") , QColorDialog::ShowAlphaChannel); colorDialogOptionsWidget->addCheckBox(tr("No buttons") , QColorDialog::NoButtons); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 1, 0); layout->addWidget(colorDialogOptionsWidget, 2, 0, 1 ,2); toolbox->addItem(page, tr("Color Dialog")); page = new QWidget; layout = new QGridLayout(page); layout->setColumnStretch(1, 1); layout->addWidget(fontButton, 0, 0); layout->addWidget(fontLabel, 0, 1); fontDialogOptionsWidget = new DialogOptionsWidget; fontDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QFontDialog::DontUseNativeDialog); fontDialogOptionsWidget->addCheckBox(tr("No buttons") , QFontDialog::NoButtons); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 1, 0); layout->addWidget(fontDialogOptionsWidget, 2, 0, 1 ,2); toolbox->addItem(page, tr("Font Dialog")); page = new QWidget; layout = new QGridLayout(page); layout->setColumnStretch(1, 1); layout->addWidget(directoryButton, 0, 0); layout->addWidget(directoryLabel, 0, 1); layout->addWidget(openFileNameButton, 1, 0); layout->addWidget(openFileNameLabel, 1, 1); layout->addWidget(openFileNamesButton, 2, 0); layout->addWidget(openFileNamesLabel, 2, 1); layout->addWidget(saveFileNameButton, 3, 0); layout->addWidget(saveFileNameLabel, 3, 1); fileDialogOptionsWidget = new DialogOptionsWidget; fileDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QFileDialog::DontUseNativeDialog); fileDialogOptionsWidget->addCheckBox(tr("Show directories only"), QFileDialog::ShowDirsOnly); fileDialogOptionsWidget->addCheckBox(tr("Do not resolve symlinks"), QFileDialog::DontResolveSymlinks); fileDialogOptionsWidget->addCheckBox(tr("Do not confirm overwrite"), QFileDialog::DontConfirmOverwrite); fileDialogOptionsWidget->addCheckBox(tr("Do not use sheet"), QFileDialog::DontUseSheet); fileDialogOptionsWidget->addCheckBox(tr("Readonly"), QFileDialog::ReadOnly); fileDialogOptionsWidget->addCheckBox(tr("Hide name filter details"), QFileDialog::HideNameFilterDetails); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 4, 0); layout->addWidget(fileDialogOptionsWidget, 5, 0, 1 ,2); toolbox->addItem(page, tr("File Dialogs")); page = new QWidget; layout = new QGridLayout(page); layout->setColumnStretch(1, 1); layout->addWidget(criticalButton, 0, 0); layout->addWidget(criticalLabel, 0, 1); layout->addWidget(informationButton, 1, 0); layout->addWidget(informationLabel, 1, 1); layout->addWidget(questionButton, 2, 0); layout->addWidget(questionLabel, 2, 1); layout->addWidget(warningButton, 3, 0); layout->addWidget(warningLabel, 3, 1); layout->addWidget(errorButton, 4, 0); layout->addWidget(errorLabel, 4, 1); layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 5, 0); toolbox->addItem(page, tr("Message Boxes")); setWindowTitle(tr("Standard Dialogs")); }
Dialog::Dialog(QWidget *parent) : QDialog(parent) { errorMessageDialog = new QErrorMessage(this); int frameStyle = QFrame::Sunken | QFrame::Panel; integerLabel = new QLabel; integerLabel->setFrameStyle(frameStyle); QPushButton *integerButton = new QPushButton(tr("QInputDialog::get&Integer()")); doubleLabel = new QLabel; doubleLabel->setFrameStyle(frameStyle); QPushButton *doubleButton = new QPushButton(tr("QInputDialog::get&Double()")); itemLabel = new QLabel; itemLabel->setFrameStyle(frameStyle); QPushButton *itemButton = new QPushButton(tr("QInputDialog::getIte&m()")); textLabel = new QLabel; textLabel->setFrameStyle(frameStyle); QPushButton *textButton = new QPushButton(tr("QInputDialog::get&Text()")); colorLabel= new QLabel; colorLabel->setFrameStyle(frameStyle); QPushButton *colorButton = new QPushButton(tr("QColorDialog::get&Color()")); fontLabel = new QLabel; fontLabel->setFrameStyle(frameStyle); QPushButton *fontButton = new QPushButton(tr("QFontDialog::get&Font()")); directoryLabel = new QLabel; directoryLabel->setFrameStyle(frameStyle); QPushButton *directoryButton = new QPushButton(tr("QFileDialog::getE&xistingDirectory()")); openFileNameLabel = new QLabel; openFileNameLabel->setFrameStyle(frameStyle); QPushButton *openFileNameButton = new QPushButton(tr("QFileDialog::get&OpenFileName()")); openFileNamesLabel = new QLabel; openFileNamesLabel->setFrameStyle(frameStyle); QPushButton *openFileNamesButton = new QPushButton(tr("QFileDialog::&getOpenFileNames()")); saveFileNameLabel = new QLabel; saveFileNameLabel->setFrameStyle(frameStyle); QPushButton *saveFileNameButton = new QPushButton(tr("QFileDialog::get&SaveFileName()")); criticalLabel = new QLabel; criticalLabel->setFrameStyle(frameStyle); QPushButton *criticalButton = new QPushButton(tr("QMessageBox::critica&l()")); informationLabel = new QLabel; informationLabel->setFrameStyle(frameStyle); QPushButton *informationButton = new QPushButton(tr("QMessageBox::i&nformation()")); questionLabel = new QLabel; questionLabel->setFrameStyle(frameStyle); QPushButton *questionButton = new QPushButton(tr("QMessageBox::&question()")); warningLabel = new QLabel; warningLabel->setFrameStyle(frameStyle); QPushButton *warningButton = new QPushButton(tr("QMessageBox::&warning()")); errorLabel = new QLabel; errorLabel->setFrameStyle(frameStyle); QPushButton *errorButton = new QPushButton(tr("QMessageBox::&error()")); connect(integerButton, SIGNAL(clicked()), this, SLOT(setInteger())); connect(doubleButton, SIGNAL(clicked()), this, SLOT(setDouble())); connect(itemButton, SIGNAL(clicked()), this, SLOT(setItem())); connect(textButton, SIGNAL(clicked()), this, SLOT(setText())); connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor())); connect(fontButton, SIGNAL(clicked()), this, SLOT(setFont())); connect(directoryButton, SIGNAL(clicked()), this, SLOT(setExistingDirectory())); connect(openFileNameButton, SIGNAL(clicked()), this, SLOT(setOpenFileName())); connect(openFileNamesButton, SIGNAL(clicked()), this, SLOT(setOpenFileNames())); connect(saveFileNameButton, SIGNAL(clicked()), this, SLOT(setSaveFileName())); connect(criticalButton, SIGNAL(clicked()), this, SLOT(criticalMessage())); connect(informationButton, SIGNAL(clicked()), this, SLOT(informationMessage())); connect(questionButton, SIGNAL(clicked()), this, SLOT(questionMessage())); connect(warningButton, SIGNAL(clicked()), this, SLOT(warningMessage())); connect(errorButton, SIGNAL(clicked()), this, SLOT(errorMessage())); native = new QCheckBox(this); native->setText("Use native file dialog"); native->setChecked(true); #ifndef Q_WS_WIN #ifndef Q_OS_MAC native->hide(); #endif #endif QGridLayout *layout = new QGridLayout; layout->setColumnStretch(1, 1); layout->setColumnMinimumWidth(1, 250); layout->addWidget(integerButton, 0, 0); layout->addWidget(integerLabel, 0, 1); layout->addWidget(doubleButton, 1, 0); layout->addWidget(doubleLabel, 1, 1); layout->addWidget(itemButton, 2, 0); layout->addWidget(itemLabel, 2, 1); layout->addWidget(textButton, 3, 0); layout->addWidget(textLabel, 3, 1); layout->addWidget(colorButton, 4, 0); layout->addWidget(colorLabel, 4, 1); layout->addWidget(fontButton, 5, 0); layout->addWidget(fontLabel, 5, 1); layout->addWidget(directoryButton, 6, 0); layout->addWidget(directoryLabel, 6, 1); layout->addWidget(openFileNameButton, 7, 0); layout->addWidget(openFileNameLabel, 7, 1); layout->addWidget(openFileNamesButton, 8, 0); layout->addWidget(openFileNamesLabel, 8, 1); layout->addWidget(saveFileNameButton, 9, 0); layout->addWidget(saveFileNameLabel, 9, 1); layout->addWidget(criticalButton, 10, 0); layout->addWidget(criticalLabel, 10, 1); layout->addWidget(informationButton, 11, 0); layout->addWidget(informationLabel, 11, 1); layout->addWidget(questionButton, 12, 0); layout->addWidget(questionLabel, 12, 1); layout->addWidget(warningButton, 13, 0); layout->addWidget(warningLabel, 13, 1); layout->addWidget(errorButton, 14, 0); layout->addWidget(errorLabel, 14, 1); layout->addWidget(native, 15, 0); setLayout(layout); setWindowTitle("Standard Dialogs"); }
int DialogMBR::folder_einlesen() { QString partition; QString Festplatte; int ret = 1; int pos = 0; int pos1 = -1; int pos2; int i = 0; QModelIndex index = treeView->currentIndex(); QModelIndexList indexes = selModel->selectedIndexes(); folder_.append (dirModel->filePath(index)); folder_ = (dirModel->filePath(index)); if (dialog_auswertung == 5) Festplatte = folder_.right(3); QFileInfo info(folder_); size_ = info.size(); pos = folder_.indexOf("mbr_sd"); pos2 = folder_.indexOf("gpt_sd"); if (folder_ == "" && (dialog_auswertung == 4)) { QMessageBox::about(this, tr("Note", "Hinweis"), tr("You must select a directory", "Sie müssen ein Verzeichnis auswählen\n")); return 1 ; } if (info.isFile() && (dialog_auswertung == 4)) { QMessageBox::about(this, tr("Note", "Hinweis"), tr("You have selected a file. You must select a directory.\n", "Sie haben eine Datei ausgewählt. Sie müssen ein Verzeichnis auswählen\n")); return 1 ; } if (folder_ == "" && (dialog_auswertung == 5)) { QMessageBox::about(this, tr("Note", "Hinweis"), tr("You must choose the MBR/GPT file\n","Sie müssen die MBR/GPT Sicherungsdatei auswählen.\n")); return 1 ; } if (info.isDir() && (dialog_auswertung == 5)) { QMessageBox::about(this, tr("Note", "Hinweis"), tr("You have selected a directory. You must select the MBR/GPT backup file\n", "Sie haben ein Verzeichnis ausgewählt. Sie müssen die MBR/GPT Sicherungsdatei auswählen\n")); return 1 ; } i = cmb_disk->currentIndex(); partition = disk_name[i]; if (dialog_auswertung == 5 ) pos1 = folder_.indexOf("_" + partition); if (pos1 == -1 && dialog_auswertung == 5){ //Partitionen stimmen nicht überein QString text = tr("You may have the wrong disk is selected. The restore disk is ", "Sie haben eventuell eine falsche Festplatte ausgewählt. Die wiederherzustellende Festplatte ist ") + partition + tr(", the saved hard drive is ", ", die gesicherte Festplatte ist aber ") + Festplatte + tr(" Are you sure?", " Wollen Sie fortfahren?"); ret = questionMessage(text); if (ret == 2) return 1; } QString sA = QString::number(size_); if (efiflag == 0) { QString text = tr("You may have a wrong file selected. Restore the hidden field has a size of ", "Sie haben eventuell eine falsche Datei ausgewählt. Der wiederherzustellende verborgene Bereich hat eine Größe von") + sA + tr(" bytes. The hidden area of the disk ", " Byte. Der verborgene Bereich von der Festplatte ") + partition + tr(" has a size of ", " hat eine Größe von ") + Sektor_byte + tr(" bytes. Are you sure?", " Byte. Wollen Sie fortfahren?"); if (size_ != sektor_byte && dialog_auswertung == 5 && cmb_mbr->currentIndex() == 3) { ret = questionMessage(text); if (ret == 2) return 1; if (ret == 1) return 0; } } return 0; }
int DialogMBR::mbr() { QString befehl; int i; int success = 0; int pos=0; int pos2=0; QString partition; QString homepath = QDir::homePath(); QModelIndex index = treeView->currentIndex(); QModelIndexList indexes = selModel->selectedIndexes(); //Ubuntu Version einlesen, nur wenn Systempartition Ubuntuversion_auslesen(); i = cmb_disk->currentIndex(); partition = disk_name[i]; efiflag = is_gpt("/dev/" + partition); folder_ = (dirModel->filePath(index)); pos = folder_.indexOf("mbr_sd"); pos2 = folder_.indexOf("gpt_sd"); if (efiflag == 0 && (pos == -1) && (dialog_auswertung == 5)){ QMessageBox::about(this, tr("Note", "Hinweis"), tr("You must choose the MBR file\n","Sie müssen eine MBR Sicherungsdatei auswählen.\n")); return 1 ; } if (efiflag == 1 && (pos2 == -1) && (dialog_auswertung == 5)) { QMessageBox::about(this, tr("Note", "Hinweis"), tr("You must choose the GPT file\n","Sie müssen eine GPT Sicherungsdatei auswählen.\n")); return 1 ; } if (efiflag == 0){ success = sektor_auslesen(); if (success == 1) return 1; } if (efiflag == 1 && (dialog_auswertung == 5)) cmb_mbr->setEnabled(false); if (efiflag == 0 && (dialog_auswertung == 5)) cmb_mbr->setEnabled(true); if (dialog_auswertung == 4) { i = folder_einlesen(); if (i ==0) { QFile file(folder_); this->setCursor(Qt::WaitCursor); if (efiflag == 0) befehl = ("dd if=/dev/" + partition + " of='" + folder_ + "'/" + Ubuntuversion + "_mbr_" + partition + " bs=" + Sektor_byte + " " + "count=1"); this->setCursor(Qt::ArrowCursor); if (efiflag == 1) befehl = ("sgdisk -b '" + folder_ + "'/" + Ubuntuversion + "_gpt_" + partition + " /dev/" + partition); i = system (befehl.toLatin1().data()); this->setCursor(Qt::ArrowCursor); if (i == 0 && efiflag == 0) QMessageBox::about(this,tr("Note", "Hinweis"), tr("MBR was successfully backed up.\n", "MBR wurde erfolgreich gesichert.\n")); if (i != 0 && efiflag == 0) QMessageBox::about(this, tr("Note", "Hinweis"), tr("MBR has not been backeed.\n", "MBR wurde nicht gesichert.\n")); if (i == 0 && efiflag == 1) QMessageBox::about(this,tr("Note", "Hinweis"), tr("GPT was successfully backed up.\n", "GPT wurde erfolgreich gesichert.\n")); if (i != 0 && efiflag == 1) QMessageBox::about(this, tr("Note", "Hinweis"), tr("GPT has not been backeed.\n", "GPT wurde nicht gesichert.\n")); } } if (dialog_auswertung == 5 && efiflag == 1) { i = folder_einlesen(); if (i ==1) return 0; int auswertung = questionMessage(tr("Caution: If you really want to to write back the GUID partition table?\n", "Vorsicht: Wollen Sie wirklich die GUID Partitionstabelle zurückschreiben?\n")); if (auswertung == 2) return 1; if (i ==0) { this->setCursor(Qt::WaitCursor); if (cmb_mbr->currentIndex() == 0) { befehl = ("sgdisk -l '" + folder_ + "' /dev/" + partition); i = system (befehl.toLatin1().data()); this->setCursor(Qt::ArrowCursor); if (i == 0) QMessageBox::about(this, tr("Note", "Hinweis"), tr("The GUID partition table is successful return.\n", "Die GUID Partitionstabelle wurde erfolgreich wieder hergestellt.\n")); else QMessageBox::about(this, tr("Note", "Hinweis"), tr("The GUID partition table was not restored.\n", "Die GUID Partitionstabelle wurde nicht wieder hergestellt.\n")); } } } if (dialog_auswertung == 5 && cmb_mbr->currentIndex() != 3 && efiflag == 0) { i = folder_einlesen(); if (i ==1) return 0; if (efiflag == 0) { int auswertung = questionMessage(tr("Caution: If you really want to to write back the MBR completely or partially?\n", "Vorsicht: Wollen Sie wirklich den MBR komplett beziehungsweise teilweise zurückschreiben?\n")); if (auswertung == 2) return 1; if (i ==0) { this->setCursor(Qt::WaitCursor); if (cmb_mbr->currentIndex() == 0) { befehl = ("dd if='"+ folder_ + "' of=/dev/" + partition + " bs=1 count=446"); i = system (befehl.toLatin1().data()); this->setCursor(Qt::ArrowCursor); if (i == 0) QMessageBox::about(this, tr("Note", "Hinweis"), tr("The Boot Loader section is successful return.\n", "Der Bootloaderbereich wurde erfolgreich wieder hergestellt.\n")); else QMessageBox::about(this, tr("Note", "Hinweis"), tr("The boot loader area was not restored.\n", "Der Bootloaderbereich wurde nicht wieder hergestellt.\n")); } if (cmb_mbr->currentIndex() == 2) { //Partitionstabelle extrahieren befehl = ("dd if='"+ folder_ + "' of=" + homepath + "/.mbr.txt bs=1 skip=446 count=66"); i = system (befehl.toLatin1().data()); //Partitionstabelle wiederherstellen befehl = ("dd if=" + homepath + "/.mbr.txt of=/dev/" + partition + " bs=1 seek=446 count=66"); i = i + system (befehl.toLatin1().data()); //Datei löschen befehl = "rm " + homepath + "/.mbr.txt"; system (befehl.toLatin1().data()); this->setCursor(Qt::ArrowCursor); if (i == 0) QMessageBox::about(this, tr("Note", "Hinweis"), tr("The partition table is successful return.", "Die Partitionstabelle wurde erfolgreich wieder hergestellt.\n")); else QMessageBox::about(this, tr("Note", "Hinweis"), tr("The partition table was not restored.\n", "Die Partitionstabelle wurde nicht wieder hergestellt.\n")); } if (cmb_mbr->currentIndex() == 1) { // MBR und Pasrtitionstabelle wieder herstellen befehl = ("dd if='"+ folder_ + "' of=/dev/" + partition + " bs=1 count=512"); i = system (befehl.toLatin1().data()); this->setCursor(Qt::ArrowCursor); if (i == 0) QMessageBox::about(this, tr("Note","Hinweis"), tr("The MBR is successful return.\n", "Der MBR wurde erfolgreich wieder hergestellt.\n")); else QMessageBox::about(this, tr("Note", "Hinweis"), tr("The MBR is not restored.\n", "Der MBR wurde nicht wieder hergestellt.\n")); } } } } if (dialog_auswertung == 5 && cmb_mbr->currentIndex() == 3) { i = folder_einlesen(); if (i ==1) return 0; int auswertung = questionMessage(tr("Caution: If you really want to to write back the secret field?\n", "Vorsicht: Wollen Sie wirklich den verborgenen Bereich zurückschreiben? \n")); if (auswertung == 2) return 1; //i = folder_einlesen(); this->setCursor(Qt::WaitCursor); if (i ==0) { //verborgenen Bereich extrahieren befehl = ("dd if='"+ folder_ + "' of=" + homepath + "/.mbr.txt bs=1 skip=512 count=" + Sektor_byte_1); i = system (befehl.toLatin1().data()); //verborgenen Bereich wiederherstellen befehl = ("dd if=" + homepath + "/.mbr.txt of=/dev/" + partition + " bs=1 seek=512 count=" + Sektor_byte_1); i = i + system (befehl.toLatin1().data()); //Datei löschen befehl = "rm " + homepath + "/.mbr.txt"; i = system (befehl.toLatin1().data()); this->setCursor(Qt::ArrowCursor); if (i == 0) QMessageBox::about(this, tr("Note", "Hinweis"), tr("The hidden area is successful return.\n", "Der verborgene Bereich wurde erfolgreich wieder hergestellt.\n")); else QMessageBox::about(this, tr("Note", "Hinweis"), tr("The hidden area was not restored.\n", "Der verborgene Bereich wurde nicht wieder hergestellt.\n")); } } return 0; }