mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-20 13:46:06 +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 <QTextEdit>
|
||||
#include <QFileInfo>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
namespace qhelpers
|
||||
{
|
||||
@ -26,4 +28,10 @@ namespace qhelpers
|
||||
#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
|
||||
|
@ -3,11 +3,14 @@
|
||||
|
||||
class QPlainTextEdit;
|
||||
class QTextEdit;
|
||||
class QString;
|
||||
|
||||
namespace qhelpers
|
||||
{
|
||||
void normalizeFont(QPlainTextEdit *edit);
|
||||
void normalizeEditFont(QTextEdit *edit);
|
||||
|
||||
QString uniqueProjectName(const QString &filename);
|
||||
}
|
||||
|
||||
#endif // HELPERS_H
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "dialogs/commentsdialog.h"
|
||||
#include "dialogs/aboutdialog.h"
|
||||
#include "dialogs/renamedialog.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#include <qfont.h>
|
||||
#include <qsettings.h>
|
||||
@ -337,7 +338,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
settings.setValue("size", size());
|
||||
settings.setValue("pos", pos());
|
||||
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();
|
||||
//this->add_debug_output(notes);
|
||||
this->core->cmd("Pnj " + notes);
|
||||
@ -1076,7 +1077,7 @@ void MainWindow::on_actionNew_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();
|
||||
//this->add_debug_output(notes);
|
||||
this->core->cmd("Pnj " + notes);
|
||||
|
@ -2,17 +2,20 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_optionsdialog.h"
|
||||
#include "newfiledialog.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#include <QSettings>
|
||||
#include <QFileInfo>
|
||||
|
||||
OptionsDialog::OptionsDialog(QString filename, QWidget *parent):
|
||||
|
||||
OptionsDialog::OptionsDialog(const QString &filename, QWidget *parent):
|
||||
QDialog(parent),
|
||||
ui(new Ui::OptionsDialog),
|
||||
analThread(this)
|
||||
core(new QRCore()),
|
||||
analThread(this),
|
||||
w(nullptr),
|
||||
filename(filename),
|
||||
defaultAnalLevel(3)
|
||||
{
|
||||
this->core = new QRCore();
|
||||
|
||||
ui->setupUi(this);
|
||||
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
ui->progressBar->setVisible(0);
|
||||
@ -45,7 +48,8 @@ OptionsDialog::OptionsDialog(QString filename, QWidget *parent):
|
||||
|
||||
connect(&analThread, SIGNAL(finished()), this, SLOT(anal_finished()));
|
||||
|
||||
setFilename(filename);
|
||||
ui->programLineEdit->setText(filename);
|
||||
this->core->tryFile(filename, true);
|
||||
}
|
||||
|
||||
OptionsDialog::~OptionsDialog()
|
||||
@ -53,20 +57,6 @@ OptionsDialog::~OptionsDialog()
|
||||
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()
|
||||
{
|
||||
close();
|
||||
@ -215,7 +205,10 @@ void OptionsDialog::anal_finished()
|
||||
|
||||
//fprintf(stderr, "anal done");
|
||||
//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
|
||||
this->core->setSettings();
|
||||
ui->statusLabel->setText("Loading interface");
|
||||
|
@ -19,8 +19,7 @@ class OptionsDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QRCore *core;
|
||||
explicit OptionsDialog(QString filename, QWidget *parent = 0);
|
||||
explicit OptionsDialog(const QString &filename, QWidget *parent = 0);
|
||||
~OptionsDialog();
|
||||
RAnalFunction functionAt(ut64 addr);
|
||||
QStringList asm_plugins;
|
||||
@ -41,15 +40,13 @@ private slots:
|
||||
void on_analCheckBox_clicked(bool checked);
|
||||
|
||||
private:
|
||||
int defaultAnalLevel = 3;
|
||||
QString filename;
|
||||
QString shortfn;
|
||||
Ui::OptionsDialog *ui;
|
||||
QRCore *core;
|
||||
AnalThread analThread;
|
||||
MainWindow *w;
|
||||
QString filename;
|
||||
int defaultAnalLevel;
|
||||
|
||||
void setFilename(QString fn, QString shortfn);
|
||||
void setFilename(QString fn);
|
||||
QString analysisDescription(int level);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user