mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-22 06:33:46 +00:00
Create unique project name (#134)
- new helper function - initialize members - removed unused functions - cleanup
This commit is contained in:
parent
3ac59f02f5
commit
d29625a8cb
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include <QPlainTextEdit>
|
#include <QPlainTextEdit>
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
#include <QFileInfo>
|
||||||
|
#include <QCryptographicHash>
|
||||||
|
|
||||||
namespace qhelpers
|
namespace qhelpers
|
||||||
{
|
{
|
||||||
@ -26,4 +28,10 @@ namespace qhelpers
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString uniqueProjectName(const QString &filename)
|
||||||
|
{
|
||||||
|
const QByteArray fullHash(QCryptographicHash::hash(filename.toUtf8(), QCryptographicHash::Sha1));
|
||||||
|
return QFileInfo(filename).fileName() + "_" + fullHash.toHex().left(10);
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace
|
} // end namespace
|
||||||
|
@ -3,11 +3,14 @@
|
|||||||
|
|
||||||
class QPlainTextEdit;
|
class QPlainTextEdit;
|
||||||
class QTextEdit;
|
class QTextEdit;
|
||||||
|
class QString;
|
||||||
|
|
||||||
namespace qhelpers
|
namespace qhelpers
|
||||||
{
|
{
|
||||||
void normalizeFont(QPlainTextEdit *edit);
|
void normalizeFont(QPlainTextEdit *edit);
|
||||||
void normalizeEditFont(QTextEdit *edit);
|
void normalizeEditFont(QTextEdit *edit);
|
||||||
|
|
||||||
|
QString uniqueProjectName(const QString &filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HELPERS_H
|
#endif // HELPERS_H
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "dialogs/commentsdialog.h"
|
#include "dialogs/commentsdialog.h"
|
||||||
#include "dialogs/aboutdialog.h"
|
#include "dialogs/aboutdialog.h"
|
||||||
#include "dialogs/renamedialog.h"
|
#include "dialogs/renamedialog.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
#include <qfont.h>
|
#include <qfont.h>
|
||||||
#include <qsettings.h>
|
#include <qsettings.h>
|
||||||
@ -337,7 +338,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||||||
settings.setValue("size", size());
|
settings.setValue("size", size());
|
||||||
settings.setValue("pos", pos());
|
settings.setValue("pos", pos());
|
||||||
settings.setValue("state", saveState());
|
settings.setValue("state", saveState());
|
||||||
core->cmd("Ps " + QFileInfo(this->filename).fileName());
|
core->cmd("Ps " + qhelpers::uniqueProjectName(filename));
|
||||||
QString notes = this->notepadDock->notesTextEdit->toPlainText().toUtf8().toBase64();
|
QString notes = this->notepadDock->notesTextEdit->toPlainText().toUtf8().toBase64();
|
||||||
//this->add_debug_output(notes);
|
//this->add_debug_output(notes);
|
||||||
this->core->cmd("Pnj " + notes);
|
this->core->cmd("Pnj " + notes);
|
||||||
@ -1076,7 +1077,7 @@ void MainWindow::on_actionNew_triggered()
|
|||||||
|
|
||||||
void MainWindow::on_actionSave_triggered()
|
void MainWindow::on_actionSave_triggered()
|
||||||
{
|
{
|
||||||
core->cmd("Ps " + QFileInfo(this->filename).fileName());
|
core->cmd("Ps " + qhelpers::uniqueProjectName(filename));
|
||||||
QString notes = this->notepadDock->notesTextEdit->toPlainText().toUtf8().toBase64();
|
QString notes = this->notepadDock->notesTextEdit->toPlainText().toUtf8().toBase64();
|
||||||
//this->add_debug_output(notes);
|
//this->add_debug_output(notes);
|
||||||
this->core->cmd("Pnj " + notes);
|
this->core->cmd("Pnj " + notes);
|
||||||
|
@ -2,17 +2,20 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_optionsdialog.h"
|
#include "ui_optionsdialog.h"
|
||||||
#include "newfiledialog.h"
|
#include "newfiledialog.h"
|
||||||
|
#include "helpers.h"
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QFileInfo>
|
|
||||||
|
|
||||||
OptionsDialog::OptionsDialog(QString filename, QWidget *parent):
|
|
||||||
|
OptionsDialog::OptionsDialog(const QString &filename, QWidget *parent):
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::OptionsDialog),
|
ui(new Ui::OptionsDialog),
|
||||||
analThread(this)
|
core(new QRCore()),
|
||||||
|
analThread(this),
|
||||||
|
w(nullptr),
|
||||||
|
filename(filename),
|
||||||
|
defaultAnalLevel(3)
|
||||||
{
|
{
|
||||||
this->core = new QRCore();
|
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||||
ui->progressBar->setVisible(0);
|
ui->progressBar->setVisible(0);
|
||||||
@ -45,7 +48,8 @@ OptionsDialog::OptionsDialog(QString filename, QWidget *parent):
|
|||||||
|
|
||||||
connect(&analThread, SIGNAL(finished()), this, SLOT(anal_finished()));
|
connect(&analThread, SIGNAL(finished()), this, SLOT(anal_finished()));
|
||||||
|
|
||||||
setFilename(filename);
|
ui->programLineEdit->setText(filename);
|
||||||
|
this->core->tryFile(filename, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
OptionsDialog::~OptionsDialog()
|
OptionsDialog::~OptionsDialog()
|
||||||
@ -53,20 +57,6 @@ OptionsDialog::~OptionsDialog()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsDialog::setFilename(QString fn, QString shortfn)
|
|
||||||
{
|
|
||||||
this->filename = fn;
|
|
||||||
this->shortfn = shortfn;
|
|
||||||
//qDebug() << QFileInfo(fn).fileName();
|
|
||||||
ui->programLineEdit->setText(fn);
|
|
||||||
this->core->tryFile(fn, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OptionsDialog::setFilename(QString fn)
|
|
||||||
{
|
|
||||||
setFilename(fn, QFileInfo(fn).fileName());
|
|
||||||
}
|
|
||||||
|
|
||||||
void OptionsDialog::on_closeButton_clicked()
|
void OptionsDialog::on_closeButton_clicked()
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
@ -215,7 +205,10 @@ void OptionsDialog::anal_finished()
|
|||||||
|
|
||||||
//fprintf(stderr, "anal done");
|
//fprintf(stderr, "anal done");
|
||||||
//ui->progressBar->setValue(70);
|
//ui->progressBar->setValue(70);
|
||||||
this->w->core->cmd("Po " + this->shortfn);
|
|
||||||
|
const QString uniqueName(qhelpers::uniqueProjectName(filename));
|
||||||
|
|
||||||
|
this->w->core->cmd("Po " + uniqueName);
|
||||||
// Set settings to override any incorrect saved in the project
|
// Set settings to override any incorrect saved in the project
|
||||||
this->core->setSettings();
|
this->core->setSettings();
|
||||||
ui->statusLabel->setText("Loading interface");
|
ui->statusLabel->setText("Loading interface");
|
||||||
|
@ -19,8 +19,7 @@ class OptionsDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QRCore *core;
|
explicit OptionsDialog(const QString &filename, QWidget *parent = 0);
|
||||||
explicit OptionsDialog(QString filename, QWidget *parent = 0);
|
|
||||||
~OptionsDialog();
|
~OptionsDialog();
|
||||||
RAnalFunction functionAt(ut64 addr);
|
RAnalFunction functionAt(ut64 addr);
|
||||||
QStringList asm_plugins;
|
QStringList asm_plugins;
|
||||||
@ -41,15 +40,13 @@ private slots:
|
|||||||
void on_analCheckBox_clicked(bool checked);
|
void on_analCheckBox_clicked(bool checked);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int defaultAnalLevel = 3;
|
|
||||||
QString filename;
|
|
||||||
QString shortfn;
|
|
||||||
Ui::OptionsDialog *ui;
|
Ui::OptionsDialog *ui;
|
||||||
|
QRCore *core;
|
||||||
AnalThread analThread;
|
AnalThread analThread;
|
||||||
MainWindow *w;
|
MainWindow *w;
|
||||||
|
QString filename;
|
||||||
|
int defaultAnalLevel;
|
||||||
|
|
||||||
void setFilename(QString fn, QString shortfn);
|
|
||||||
void setFilename(QString fn);
|
|
||||||
QString analysisDescription(int level);
|
QString analysisDescription(int level);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user