Commit 382fe330 authored by Ingemar Ceicer's avatar Ingemar Ceicer

Save dialog


Former-commit-id: f800299a
parent 565623e9
......@@ -466,7 +466,7 @@ void Hash::createDebianMd5sumsAuto()
QTextStream out(&file);
QString alltihopa;
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
QMessageBox::critical(this, APPLICATION_NAME " " VERSION,tr("Could not save a file to store hash sums in. Check your file permissions."));
QMessageBox::critical(this, APPLICATION_NAME " " VERSION,tr("Could not save a file to store hash sums in. Check your file permissions. ")+file.errorString());
for (int i=0; i< allt.count(); i++)
{
alltihopa = allt[i];
......@@ -1348,7 +1348,7 @@ void Hash::checksum()
if (fileNames.size() > 1)
{
d = new QDialog;
Ui::Lic *ui2 = new Ui::Lic;
ui2 = new Ui::Lic;
ui2->setupUi(d);
const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
ui2->textBrowser->setFont(fixedFont);
......@@ -1368,7 +1368,7 @@ void Hash::checksum()
ui2->textBrowser->append(lista->at(i)+" "+spath);
// ui2->textBrowser->moveCursor (QTextCursor::End);
}
ui2->pbOpenFile->hide();
//ui2->pbOpenFile->hide();
// ui2->pbClose->setGeometry(450,570,100,24);
// d->setWindowFlags(Qt::CustomizeWindowHint);
d->setWindowFlags(Qt::WindowSystemMenuHint);
......@@ -1378,6 +1378,7 @@ void Hash::checksum()
connect(ui2->pbClose, SIGNAL(clicked()), this, SLOT(stang()));
// d->setWindowModality(Qt::NonModal);
d->show();
connect(ui2->pbOpenFile, SIGNAL(pressed()), this, SLOT(save()));
}
}
......@@ -1815,7 +1816,7 @@ bool Hash::createDeb(QString sokvag2,QStringList fileNames)
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
delete k;
QMessageBox::critical(this, APPLICATION_NAME " " VERSION,tr("Could not save a file to store hash sums in. Check your file permissions."));
QMessageBox::critical(this, APPLICATION_NAME " " VERSION,tr("Could not save a file to store hash sums in. Check your file permissions. ")+file.errorString());
return false;
}
for (int i=0; i< fileNames.count(); i++)
......@@ -2189,7 +2190,7 @@ bool Hash::askForFileNameCheck(QString sokvag2,std::string algoritm,QStringList
if (!fil3.open(QIODevice::WriteOnly | QIODevice::Text))
{
delete k;
QMessageBox::critical(this, APPLICATION_NAME " " VERSION,tr("Could not save a file to store hash sums in. Check your file permissions."));
QMessageBox::critical(this, APPLICATION_NAME " " VERSION,tr("Could not save a file to store hash sums in. Check your file permissions. ")+fil3.errorString());
return false;
}
in << "# " << tr("Unchanged files") << "\n";
......@@ -2271,12 +2272,10 @@ bool Hash::askForFileName(QString sokvag2,std::string algoritm,QStringList fileN
const QString tempfil = tempfilList[0];
QFile file(tempfil);
QTextStream out(&file);
// if (filetype == "txt" || filetype=="txtpdf")
//{
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
delete k;
QMessageBox::critical(this, APPLICATION_NAME " " VERSION,tr("Could not save a file to store hash sums in. Check your file permissions."));
QMessageBox::critical(this, APPLICATION_NAME " " VERSION,tr("Could not save a file to store hash sums in. Check your file permissions. ")+file.errorString());
return false;
}
out << "# " << tr("Algorithm: ") << QString::fromStdString(algoritm) << "\n";
......@@ -2303,7 +2302,6 @@ bool Hash::askForFileName(QString sokvag2,std::string algoritm,QStringList fileN
if (writedatetime == "1")
out << "# " << tr("Created: ") << datumtid() << "\n";
file.close();
// }
// PDF
// SLUT PDF
QDir dir;
......@@ -2346,7 +2344,7 @@ bool Hash::dontAskForFileName(std::string algoritm,QStringList fileNames)
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
delete k;
QMessageBox::critical(this, APPLICATION_NAME " " VERSION,tr("Could not save a file to store hash sums in. Check your file permissions."));
QMessageBox::critical(this, APPLICATION_NAME " " VERSION,tr("Could not save a file to store hash sums in. Check your file permissions. ")+file.errorString());
return false;
}
out << "# " << tr("Algorithm: ") << QString::fromStdString(algoritm) << "\n";
......@@ -3015,7 +3013,7 @@ void Hash::setEndConfig()
const QString RECENT_FILE_FILE = QDir::toNativeSeparators(QDir::homePath()+"/."+ APPLICATION_NAME +"/recentfiles.conf");
QFile file(RECENT_FILE_FILE);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
QMessageBox::critical(this, APPLICATION_NAME " " VERSION,tr("Could not save a file to store Recent File list. Check your file permissions."));
QMessageBox::critical(this, APPLICATION_NAME " " VERSION,tr("Could not save a file to store hash sums in. Check your file permissions. ")+file.errorString());
for (int i = 0; i < recentFiles.size(); ++i)
{
QTextStream out(&file);
......@@ -3216,7 +3214,6 @@ void Hash::dropEvent(QDropEvent *ev)
QString qsalgorithm = QString::fromStdString(algorithm);
delete k;
d = new QDialog;
// Ui::Lic *ui2 = new Ui::Lic;
ui2 = new Ui::Lic;
ui2->setupUi(d);
const QFont fixedFont = QFontDatabase::systemFont(QFontDatabase::FixedFont);
......@@ -3224,32 +3221,16 @@ void Hash::dropEvent(QDropEvent *ev)
ui2->textBrowser->append(tr("Path: ")+spath);
ui2->textBrowser->append(tr("Algorithm: ")+qsalgorithm);
for (int i=0; i<lista->size(); i++)
{
ui2->textBrowser->append(lista->at(i)+" "+fillista.at(i));
// ui2->textBrowser->moveCursor (QTextCursor::End);
}
// ui2->pbOpenFile->hide();
// ui2->pbClose->setGeometry(450,570,100,24);
// d->setWindowFlags(Qt::CustomizeWindowHint);
ui2->textBrowser->append(lista->at(i)+" "+fillista.at(i));
d->setWindowFlags(Qt::WindowSystemMenuHint);
d->setWindowTitle(APPLICATION_NAME " " VERSION);
// QIcon ikon("/images/hashsum.ico");
// d->setWindowIcon(ikon);
connect(ui2->pbClose, SIGNAL(clicked()), this, SLOT(stang()));
// d->setWindowModality(Qt::NonModal);
d->show();
// QString s = ui2->textBrowser->toPlainText();
connect(ui2->pbOpenFile, SIGNAL(pressed()), this, SLOT(save2()));
// QMessageBox::information(this,"TEST",s);
connect(ui2->pbOpenFile, SIGNAL(pressed()), this, SLOT(save()));
}
}
void Hash::save()
{
QFileDialog *dialog = new QFileDialog(this, tr("Save the hash summary list as a text file"), QDir::homePath(), tr("Any file (*)"));
}
void Hash::save2()
{
QString conf_file_name = QDir::toNativeSeparators("/" APPLICATION_NAME ".conf");
k = new Config(conf_file_name);
......@@ -3264,44 +3245,46 @@ void Hash::save2()
std::string usenativedialogs = k->getConf("usenativedialogs");
QString textBrowserText = ui2->textBrowser->toPlainText();
QFileDialog *dialog = new QFileDialog(this, tr("Save the hash summary list as a text file"), sokvag, tr("Any file (*)"));
/* dialog->setAcceptMode(QFileDialog::AcceptSave);
dialog->setFileMode(QFileDialog::AnyFile);
dialog->setViewMode(QFileDialog::Detail);
dialog->setWindowTitle("PRUTT");
qDebug() << "usenativedialogs: " << QString::fromStdString(usenativedialogs);
if (usenativedialogs == "0")
dialog->setOption(QFileDialog::DontUseNativeDialog,true);
else if (usenativedialogs == "1")
dialog->setOption(QFileDialog::DontUseNativeDialog,false);*/
//dialog->setWindowTitle(APPLICATION_NAME " " VERSION);
QString fileName;
// if (dialog->exec())
// {
fileName = dialog->getSaveFileName(); // HÄR?
dialog->selectFile(fileName);
dialog->setAcceptMode(QFileDialog::AcceptSave);
dialog->setFileMode(QFileDialog::AnyFile);
dialog->setViewMode(QFileDialog::Detail);
dialog->setWindowTitle("PRUTT");
qDebug() << "usenativedialogs: " << QString::fromStdString(usenativedialogs);
if (usenativedialogs == "0")
dialog->setOption(QFileDialog::DontUseNativeDialog,true);
else if (usenativedialogs == "1")
dialog->setOption(QFileDialog::DontUseNativeDialog,false);
qDebug() << "filename: " << fileName;
QFile file( fileName );
if ( file.open(QIODevice::WriteOnly ) )
{
QTextStream stream( &file );
stream << textBrowserText << endl;
}
QDir dir;
dir = dialog->directory();
QString directoryName = dir.path();
k->setConf("save_path",directoryName.toStdString());
// }
if (dialog->exec())
{
QString qsdatetime = QDateTime::currentDateTime().toString(Qt::ISODate)+"\n";
QStringList sl = dialog->selectedFiles();
QString fileName = sl.at(0);
if (fileName.isEmpty())
return;
else
{
QFile file(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
{
QMessageBox::critical(this, APPLICATION_NAME " " VERSION,tr("Could not save a file to store hash sums in. Check your file permissions. ")+file.errorString());
delete k;
return;
}
else
{
QTextStream out(&file);
out << qsdatetime;
out << textBrowserText << endl;
QDir dir;
dir = dialog->directory();
QString directoryName = dir.path();
k->setConf("save_path",directoryName.toStdString());
}
}
}
delete k;
}
void Hash::dragEnterEvent(QDragEnterEvent *ev)
{
ev->accept();
......
......@@ -179,7 +179,7 @@ private slots:
void openFile();
void save();
void save2();
public slots:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment