2017-10-01 19:09:42 +00:00
|
|
|
#include "MainWindow.h"
|
|
|
|
#include "ui_MainWindow.h"
|
|
|
|
#include "dialogs/CommentsDialog.h"
|
|
|
|
#include "dialogs/AboutDialog.h"
|
|
|
|
#include "dialogs/RenameDialog.h"
|
2017-12-14 13:42:24 +00:00
|
|
|
#include "dialogs/preferences/PreferencesDialog.h"
|
2017-10-01 19:09:42 +00:00
|
|
|
#include "utils/Helpers.h"
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2018-01-09 12:09:25 +00:00
|
|
|
#include <QApplication>
|
2017-05-14 16:21:54 +00:00
|
|
|
#include <QComboBox>
|
|
|
|
#include <QCompleter>
|
2017-03-29 10:18:37 +00:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QDesktopServices>
|
2017-05-14 16:21:54 +00:00
|
|
|
#include <QDir>
|
|
|
|
#include <QDockWidget>
|
|
|
|
#include <QFile>
|
2017-03-29 10:18:37 +00:00
|
|
|
#include <QFileDialog>
|
2017-05-14 16:21:54 +00:00
|
|
|
#include <QFont>
|
|
|
|
#include <QFontDialog>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QLineEdit>
|
|
|
|
#include <QList>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QProcess>
|
2017-03-29 10:18:37 +00:00
|
|
|
#include <QPropertyAnimation>
|
2017-05-14 16:21:54 +00:00
|
|
|
#include <QScrollBar>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QShortcut>
|
|
|
|
#include <QStringListModel>
|
2017-03-29 10:18:37 +00:00
|
|
|
#include <QStyledItemDelegate>
|
2017-05-14 16:21:54 +00:00
|
|
|
#include <QStyleFactory>
|
|
|
|
#include <QTextCursor>
|
2017-03-29 10:18:37 +00:00
|
|
|
#include <QtGlobal>
|
2017-05-14 16:21:54 +00:00
|
|
|
#include <QToolButton>
|
2017-03-29 10:18:37 +00:00
|
|
|
#include <QToolTip>
|
2017-04-13 15:36:20 +00:00
|
|
|
#include <QTreeWidgetItem>
|
2017-12-23 16:42:42 +00:00
|
|
|
#include <QSvgRenderer>
|
2017-05-14 16:21:54 +00:00
|
|
|
|
2017-10-01 19:09:42 +00:00
|
|
|
#include "utils/Highlighter.h"
|
|
|
|
#include "utils/HexAsciiHighlighter.h"
|
|
|
|
#include "utils/Helpers.h"
|
2017-12-23 16:42:42 +00:00
|
|
|
#include "utils/SvgIconEngine.h"
|
2017-04-13 15:36:20 +00:00
|
|
|
|
2017-12-23 16:42:42 +00:00
|
|
|
#include "dialogs/NewFileDialog.h"
|
2017-12-13 22:38:46 +00:00
|
|
|
#include "widgets/DisassemblerGraphView.h"
|
2017-10-02 16:18:40 +00:00
|
|
|
#include "widgets/FunctionsWidget.h"
|
|
|
|
#include "widgets/SectionsWidget.h"
|
|
|
|
#include "widgets/CommentsWidget.h"
|
|
|
|
#include "widgets/ImportsWidget.h"
|
|
|
|
#include "widgets/ExportsWidget.h"
|
2018-03-06 17:21:48 +00:00
|
|
|
#include "widgets/TypesWidget.h"
|
2017-10-02 16:18:40 +00:00
|
|
|
#include "widgets/SymbolsWidget.h"
|
|
|
|
#include "widgets/StringsWidget.h"
|
|
|
|
#include "widgets/SectionsDock.h"
|
|
|
|
#include "widgets/RelocsWidget.h"
|
|
|
|
#include "widgets/FlagsWidget.h"
|
2017-12-08 15:00:52 +00:00
|
|
|
#include "widgets/VisualNavbar.h"
|
2017-10-02 16:18:40 +00:00
|
|
|
#include "widgets/Dashboard.h"
|
|
|
|
#include "widgets/Sidebar.h"
|
|
|
|
#include "widgets/SdbDock.h"
|
|
|
|
#include "widgets/Omnibar.h"
|
|
|
|
#include "widgets/ConsoleWidget.h"
|
2017-10-01 19:09:42 +00:00
|
|
|
#include "dialogs/OptionsDialog.h"
|
2017-10-02 16:18:40 +00:00
|
|
|
#include "widgets/EntrypointWidget.h"
|
2017-10-21 19:20:10 +00:00
|
|
|
#include "dialogs/SaveProjectDialog.h"
|
2017-12-23 16:42:42 +00:00
|
|
|
#include "widgets/ClassesWidget.h"
|
2018-02-04 14:32:18 +00:00
|
|
|
#include "widgets/ResourcesWidget.h"
|
2018-02-26 22:26:18 +00:00
|
|
|
#include "widgets/VTablesWidget.h"
|
2017-12-13 17:36:00 +00:00
|
|
|
#include "widgets/JupyterWidget.h"
|
2017-04-13 15:36:20 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
// graphics
|
|
|
|
#include <QGraphicsEllipseItem>
|
|
|
|
#include <QGraphicsScene>
|
|
|
|
#include <QGraphicsView>
|
|
|
|
|
2017-04-05 08:56:59 +00:00
|
|
|
#include <cassert>
|
|
|
|
|
2017-04-09 17:09:35 +00:00
|
|
|
static void registerCustomFonts()
|
2017-04-05 08:56:59 +00:00
|
|
|
{
|
2017-06-15 09:53:10 +00:00
|
|
|
int ret = QFontDatabase::addApplicationFont(":/fonts/Anonymous Pro.ttf");
|
2017-04-09 17:09:35 +00:00
|
|
|
assert(-1 != ret && "unable to register Anonymous Pro.ttf");
|
2017-04-05 08:56:59 +00:00
|
|
|
|
2017-06-15 09:53:10 +00:00
|
|
|
ret = QFontDatabase::addApplicationFont(":/fonts/Inconsolata-Regular.ttf");
|
2017-04-09 17:09:35 +00:00
|
|
|
assert(-1 != ret && "unable to register Inconsolata-Regular.ttf");
|
2017-04-05 08:56:59 +00:00
|
|
|
|
2018-01-29 14:13:16 +00:00
|
|
|
// Do not issue a warning in release
|
2017-04-09 17:09:35 +00:00
|
|
|
Q_UNUSED(ret)
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-05-13 18:09:36 +00:00
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
2017-03-29 10:18:37 +00:00
|
|
|
QMainWindow(parent),
|
2018-02-26 22:25:23 +00:00
|
|
|
core(Core()),
|
2018-02-04 14:32:18 +00:00
|
|
|
ui(new Ui::MainWindow)
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
2017-12-17 13:49:03 +00:00
|
|
|
panelLock = false;
|
|
|
|
tabsOnTop = false;
|
2018-02-26 22:25:23 +00:00
|
|
|
configuration = Config();
|
2017-05-13 18:09:36 +00:00
|
|
|
}
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-05-13 18:09:36 +00:00
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::initUI()
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2017-04-05 08:56:59 +00:00
|
|
|
|
2017-05-13 18:09:36 +00:00
|
|
|
registerCustomFonts();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Toolbar
|
|
|
|
*/
|
|
|
|
// Hide central tab widget tabs
|
|
|
|
QTabBar *centralbar = ui->centralTabWidget->tabBar();
|
|
|
|
centralbar->setVisible(false);
|
|
|
|
|
|
|
|
// Sepparator between undo/redo and goto lineEdit
|
2017-04-09 19:55:06 +00:00
|
|
|
QWidget *spacer3 = new QWidget();
|
2017-03-29 10:18:37 +00:00
|
|
|
spacer3->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
|
spacer3->setMinimumSize(20, 20);
|
|
|
|
spacer3->setMaximumWidth(300);
|
2017-11-18 14:57:00 +00:00
|
|
|
ui->mainToolBar->addWidget(spacer3);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
// Omnibar LineEdit
|
|
|
|
this->omnibar = new Omnibar(this);
|
2017-11-18 14:57:00 +00:00
|
|
|
ui->mainToolBar->addWidget(this->omnibar);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-09-01 13:03:35 +00:00
|
|
|
// Add special separators to the toolbar that expand to separate groups of elements
|
2017-04-09 19:55:06 +00:00
|
|
|
QWidget *spacer2 = new QWidget();
|
2017-03-29 10:18:37 +00:00
|
|
|
spacer2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
|
spacer2->setMinimumSize(10, 10);
|
|
|
|
spacer2->setMaximumWidth(300);
|
2017-11-18 14:57:00 +00:00
|
|
|
ui->mainToolBar->addWidget(spacer2);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
2017-09-01 13:03:35 +00:00
|
|
|
// Separator between back/forward and undo/redo buttons
|
2017-04-09 19:55:06 +00:00
|
|
|
QWidget *spacer = new QWidget();
|
2017-03-29 10:18:37 +00:00
|
|
|
spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
|
|
|
spacer->setMinimumSize(20, 20);
|
|
|
|
ui->mainToolBar->addWidget(spacer);
|
|
|
|
|
2017-12-08 15:00:52 +00:00
|
|
|
// Visual navigation tool bar
|
|
|
|
this->visualNavbar = new VisualNavbar(this);
|
|
|
|
this->visualNavbar->setMovable(false);
|
2017-03-29 10:18:37 +00:00
|
|
|
addToolBarBreak(Qt::TopToolBarArea);
|
2017-12-08 15:00:52 +00:00
|
|
|
addToolBar(visualNavbar);
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Dock Widgets
|
|
|
|
*/
|
2018-02-04 14:32:18 +00:00
|
|
|
dockWidgets.reserve(20);
|
2017-10-11 11:22:30 +00:00
|
|
|
|
2017-12-21 15:47:36 +00:00
|
|
|
#define ADD_DOCK(cls, dockMember, action) \
|
|
|
|
{ \
|
|
|
|
(dockMember) = new cls(this); \
|
|
|
|
dockWidgets.push_back(dockMember); \
|
|
|
|
connect((action), &QAction::triggered, this, [this](bool checked) \
|
|
|
|
{ \
|
|
|
|
toggleDockWidget((dockMember), checked); \
|
|
|
|
}); \
|
|
|
|
dockWidgetActions[action] = (dockMember); \
|
|
|
|
}
|
|
|
|
ADD_DOCK(DisassemblyWidget, disassemblyDock, ui->actionDisassembly);
|
|
|
|
ADD_DOCK(SidebarWidget, sidebarDock, ui->actionSidebar);
|
|
|
|
ADD_DOCK(HexdumpWidget, hexdumpDock, ui->actionHexdump);
|
|
|
|
ADD_DOCK(PseudocodeWidget, pseudocodeDock, ui->actionPseudocode);
|
|
|
|
ADD_DOCK(ConsoleWidget, consoleDock, ui->actionConsole);
|
2017-12-10 16:55:42 +00:00
|
|
|
|
2017-10-11 21:07:32 +00:00
|
|
|
// Add graph view as dockable
|
|
|
|
graphDock = new QDockWidget(tr("Graph"), this);
|
2017-10-20 16:02:35 +00:00
|
|
|
graphDock->setObjectName("Graph");
|
2017-10-11 21:07:32 +00:00
|
|
|
graphDock->setAllowedAreas(Qt::AllDockWidgetAreas);
|
2017-10-22 10:21:44 +00:00
|
|
|
graphView = new DisassemblerGraphView(graphDock);
|
|
|
|
graphDock->setWidget(graphView);
|
2017-12-10 16:55:42 +00:00
|
|
|
|
|
|
|
// Hide centralWidget as we do not need it
|
|
|
|
ui->centralWidget->hide();
|
|
|
|
|
2017-11-18 15:01:06 +00:00
|
|
|
connect(graphDock, &QDockWidget::visibilityChanged, graphDock, [](bool visibility)
|
|
|
|
{
|
2017-11-04 11:46:29 +00:00
|
|
|
if (visibility)
|
|
|
|
{
|
|
|
|
Core()->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Graph);
|
|
|
|
}
|
|
|
|
});
|
2017-11-18 15:01:06 +00:00
|
|
|
connect(Core(), &CutterCore::raisePrioritizedMemoryWidget, graphDock, [ = ](CutterCore::MemoryWidgetType type)
|
|
|
|
{
|
2017-11-04 11:46:29 +00:00
|
|
|
if (type == CutterCore::MemoryWidgetType::Graph)
|
|
|
|
{
|
|
|
|
graphDock->raise();
|
|
|
|
graphView->setFocus();
|
|
|
|
}
|
|
|
|
});
|
2017-10-11 21:07:32 +00:00
|
|
|
dockWidgets.push_back(graphDock);
|
2017-12-21 15:47:36 +00:00
|
|
|
connect(ui->actionGraph, &QAction::triggered, this, [this](bool checked)
|
|
|
|
{
|
|
|
|
toggleDockWidget(graphDock, checked);
|
|
|
|
});
|
2017-10-11 21:07:32 +00:00
|
|
|
|
2017-12-21 15:47:36 +00:00
|
|
|
ADD_DOCK(SectionsDock, sectionsDock, ui->actionSections);
|
|
|
|
ADD_DOCK(EntrypointWidget, entrypointDock, ui->actionEntrypoints);
|
|
|
|
ADD_DOCK(FunctionsWidget, functionsDock, ui->actionFunctions);
|
|
|
|
ADD_DOCK(ImportsWidget, importsDock, ui->actionImports);
|
|
|
|
ADD_DOCK(ExportsWidget, exportsDock, ui->actionExports);
|
2018-03-06 17:21:48 +00:00
|
|
|
ADD_DOCK(TypesWidget, typesDock, ui->actionTypes);
|
2017-12-21 15:47:36 +00:00
|
|
|
ADD_DOCK(SymbolsWidget, symbolsDock, ui->actionSymbols);
|
|
|
|
ADD_DOCK(RelocsWidget, relocsDock, ui->actionRelocs);
|
|
|
|
ADD_DOCK(CommentsWidget, commentsDock, ui->actionComments);
|
|
|
|
ADD_DOCK(StringsWidget, stringsDock, ui->actionStrings);
|
|
|
|
ADD_DOCK(FlagsWidget, flagsDock, ui->actionFlags);
|
2018-03-02 13:15:53 +00:00
|
|
|
#ifdef CUTTER_ENABLE_JUPYTER
|
2017-12-13 17:36:00 +00:00
|
|
|
ADD_DOCK(JupyterWidget, jupyterDock, ui->actionJupyter);
|
2018-03-02 14:06:08 +00:00
|
|
|
#else
|
|
|
|
ui->actionJupyter->setEnabled(false);
|
|
|
|
ui->actionJupyter->setVisible(false);
|
2018-03-02 13:15:53 +00:00
|
|
|
#endif
|
2017-12-21 15:47:36 +00:00
|
|
|
ADD_DOCK(Dashboard, dashboardDock, ui->actionDashboard);
|
|
|
|
ADD_DOCK(SdbDock, sdbDock, ui->actionSDBBrowser);
|
2017-12-23 16:42:42 +00:00
|
|
|
ADD_DOCK(ClassesWidget, classesDock, ui->actionClasses);
|
2018-02-04 14:32:18 +00:00
|
|
|
ADD_DOCK(ResourcesWidget, resourcesDock, ui->actionResources);
|
2018-02-26 22:26:18 +00:00
|
|
|
ADD_DOCK(VTablesWidget, vTablesDock, ui->actionVTables);
|
2017-12-23 16:42:42 +00:00
|
|
|
|
2017-12-21 15:47:36 +00:00
|
|
|
#undef ADD_DOCK
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
// Restore saved settings
|
|
|
|
this->readSettings();
|
|
|
|
// TODO: Allow the user to select this option visually in the GUI settings
|
|
|
|
// Adjust the DockWidget areas
|
2017-04-09 19:55:06 +00:00
|
|
|
setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
|
2017-03-29 10:18:37 +00:00
|
|
|
//setCorner( Qt::TopRightCorner, Qt::RightDockWidgetArea );
|
2017-04-09 19:55:06 +00:00
|
|
|
setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
|
2017-03-29 10:18:37 +00:00
|
|
|
//setCorner( Qt::BottomRightCorner, Qt::RightDockWidgetArea );
|
|
|
|
|
2018-01-09 12:09:25 +00:00
|
|
|
// Set up dock widgets default layout
|
|
|
|
resetToDefaultLayout();
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Some global shortcuts
|
|
|
|
*/
|
|
|
|
// Period goes to command entry
|
2017-04-09 19:55:06 +00:00
|
|
|
QShortcut *cmd_shortcut = new QShortcut(QKeySequence(Qt::Key_Period), this);
|
2017-12-10 16:55:42 +00:00
|
|
|
connect(cmd_shortcut, SIGNAL(activated()), consoleDock, SLOT(focusInputLineEdit()));
|
2017-03-29 10:18:37 +00:00
|
|
|
|
|
|
|
// G and S goes to goto entry
|
2017-04-09 19:55:06 +00:00
|
|
|
QShortcut *goto_shortcut = new QShortcut(QKeySequence(Qt::Key_G), this);
|
2017-03-29 10:18:37 +00:00
|
|
|
connect(goto_shortcut, SIGNAL(activated()), this->omnibar, SLOT(setFocus()));
|
2017-04-09 19:55:06 +00:00
|
|
|
QShortcut *seek_shortcut = new QShortcut(QKeySequence(Qt::Key_S), this);
|
2017-03-29 10:18:37 +00:00
|
|
|
connect(seek_shortcut, SIGNAL(activated()), this->omnibar, SLOT(setFocus()));
|
|
|
|
|
2017-04-12 21:04:39 +00:00
|
|
|
QShortcut *refresh_shortcut = new QShortcut(QKeySequence(QKeySequence::Refresh), this);
|
2017-11-19 12:56:10 +00:00
|
|
|
connect(refresh_shortcut, SIGNAL(activated()), this, SLOT(refreshAll()));
|
2017-05-13 18:09:36 +00:00
|
|
|
|
2017-10-21 19:20:10 +00:00
|
|
|
connect(core, SIGNAL(projectSaved(const QString &)), this, SLOT(projectSaved(const QString &)));
|
2017-05-13 18:09:36 +00:00
|
|
|
}
|
|
|
|
|
2018-01-27 10:40:26 +00:00
|
|
|
void MainWindow::openNewFile(const QString &fn, int analLevel, QList<QString> advancedOptions)
|
2017-05-13 18:09:36 +00:00
|
|
|
{
|
|
|
|
setFilename(fn);
|
|
|
|
|
2017-12-14 12:45:03 +00:00
|
|
|
/* Reset config */
|
|
|
|
core->resetDefaultAsmOptions();
|
|
|
|
|
|
|
|
/* Prompt to load filename.r2 script */
|
|
|
|
QString script = QString("%1.r2").arg(this->filename);
|
|
|
|
if (r_file_exists(script.toStdString().data())) {
|
|
|
|
QMessageBox mb;
|
|
|
|
mb.setWindowTitle(tr("Script loading"));
|
|
|
|
mb.setText(tr("Do you want to load the '%1' script?").arg(script));
|
|
|
|
mb.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
|
|
|
if (mb.exec() == QMessageBox::Yes) {
|
|
|
|
core->loadScript(script);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Show analysis options dialog */
|
2018-01-27 10:40:26 +00:00
|
|
|
displayAnalysisOptionsDialog(analLevel, advancedOptions);
|
|
|
|
}
|
|
|
|
|
2018-02-06 18:23:01 +00:00
|
|
|
void MainWindow::displayNewFileDialog()
|
|
|
|
{
|
|
|
|
NewFileDialog *n = new NewFileDialog();
|
2018-02-10 18:04:31 +00:00
|
|
|
newFileDialog = n;
|
2018-02-06 18:23:01 +00:00
|
|
|
n->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
n->show();
|
|
|
|
}
|
|
|
|
|
2018-02-10 18:04:31 +00:00
|
|
|
void MainWindow::closeNewFileDialog()
|
|
|
|
{
|
|
|
|
if (newFileDialog) {
|
|
|
|
newFileDialog->close();
|
|
|
|
}
|
|
|
|
newFileDialog = nullptr;
|
|
|
|
}
|
|
|
|
|
2018-01-27 10:40:26 +00:00
|
|
|
void MainWindow::displayAnalysisOptionsDialog(int analLevel, QList<QString> advancedOptions)
|
|
|
|
{
|
2017-05-13 18:09:36 +00:00
|
|
|
OptionsDialog *o = new OptionsDialog(this);
|
|
|
|
o->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
o->show();
|
|
|
|
|
2018-01-27 10:40:26 +00:00
|
|
|
if (analLevel >= 0)
|
2017-12-06 12:32:35 +00:00
|
|
|
{
|
2018-01-27 10:40:26 +00:00
|
|
|
o->setupAndStartAnalysis(analLevel, advancedOptions);
|
2017-12-06 12:32:35 +00:00
|
|
|
}
|
2017-05-13 18:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::openProject(const QString &project_name)
|
|
|
|
{
|
|
|
|
QString filename = core->cmd("Pi " + project_name);
|
|
|
|
setFilename(filename.trimmed());
|
|
|
|
|
2017-10-21 19:20:10 +00:00
|
|
|
core->openProject(project_name);
|
2017-05-13 18:09:36 +00:00
|
|
|
|
|
|
|
initUI();
|
|
|
|
finalizeOpen();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::finalizeOpen()
|
|
|
|
{
|
|
|
|
core->getOpcodes();
|
|
|
|
|
|
|
|
// Set settings to override any incorrect saved in the project
|
|
|
|
core->setSettings();
|
|
|
|
|
|
|
|
|
2017-09-09 09:36:15 +00:00
|
|
|
addOutput(tr(" > Populating UI"));
|
2017-05-13 18:09:36 +00:00
|
|
|
// FIXME: initialization order frakup. the next line is needed so that the
|
|
|
|
// comments widget displays the function names.
|
|
|
|
core->cmd("fs sections");
|
2017-11-19 12:56:10 +00:00
|
|
|
refreshAll();
|
2017-05-13 18:09:36 +00:00
|
|
|
|
2017-09-09 09:36:15 +00:00
|
|
|
addOutput(tr(" > Finished, happy reversing :)"));
|
2017-05-13 18:09:36 +00:00
|
|
|
// Add fortune message
|
|
|
|
addOutput("\n" + core->cmd("fo"));
|
2017-10-12 19:55:15 +00:00
|
|
|
//previewDock->setWindowTitle("entry0");
|
2017-05-13 18:09:36 +00:00
|
|
|
showMaximized();
|
|
|
|
}
|
|
|
|
|
2017-10-21 19:20:10 +00:00
|
|
|
bool MainWindow::saveProject(bool quit)
|
2017-05-13 18:09:36 +00:00
|
|
|
{
|
2017-10-21 19:20:10 +00:00
|
|
|
QString projectName = core->getConfig("prj.name");
|
|
|
|
if (projectName.isEmpty())
|
|
|
|
{
|
|
|
|
return saveProjectAs(quit);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
core->saveProject(projectName);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MainWindow::saveProjectAs(bool quit)
|
|
|
|
{
|
2017-11-03 17:22:54 +00:00
|
|
|
SaveProjectDialog dialog(quit, this);
|
|
|
|
int result = dialog.exec();
|
2017-10-21 19:20:10 +00:00
|
|
|
|
|
|
|
return !quit || result != SaveProjectDialog::Rejected;
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-04-27 18:59:27 +00:00
|
|
|
void MainWindow::refreshOmniBar(const QStringList &flags)
|
|
|
|
{
|
|
|
|
omnibar->refresh(flags);
|
|
|
|
}
|
|
|
|
|
2017-04-28 13:38:01 +00:00
|
|
|
void MainWindow::setFilename(const QString &fn)
|
2017-04-13 15:36:20 +00:00
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
// Add file name to window title
|
|
|
|
this->filename = fn;
|
2017-09-25 12:55:41 +00:00
|
|
|
this->setWindowTitle(APPNAME" - " + fn);
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
2017-09-25 12:55:41 +00:00
|
|
|
QMessageBox::StandardButton ret = QMessageBox::question(this, APPNAME,
|
2017-09-09 09:36:15 +00:00
|
|
|
tr("Do you really want to exit?\nSave your project before closing!"),
|
2017-05-19 07:45:26 +00:00
|
|
|
(QMessageBox::StandardButtons)(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel));
|
2017-04-09 19:55:06 +00:00
|
|
|
if (ret == QMessageBox::Save)
|
|
|
|
{
|
2017-11-03 17:22:54 +00:00
|
|
|
if (saveProject(true))
|
2017-10-21 19:20:10 +00:00
|
|
|
{
|
2017-12-17 13:49:03 +00:00
|
|
|
saveSettings();
|
2017-10-21 19:20:10 +00:00
|
|
|
}
|
2018-01-29 14:13:16 +00:00
|
|
|
QMainWindow::closeEvent(event);
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else if (ret == QMessageBox::Discard)
|
|
|
|
{
|
2017-12-17 13:49:03 +00:00
|
|
|
saveSettings();
|
2018-01-29 14:13:16 +00:00
|
|
|
QMainWindow::closeEvent(event);
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
event->ignore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::readSettings()
|
|
|
|
{
|
2017-04-03 00:18:09 +00:00
|
|
|
QSettings settings;
|
2017-03-29 10:18:37 +00:00
|
|
|
QByteArray geo = settings.value("geometry", QByteArray()).toByteArray();
|
|
|
|
restoreGeometry(geo);
|
|
|
|
QByteArray state = settings.value("state", QByteArray()).toByteArray();
|
|
|
|
restoreState(state);
|
|
|
|
this->responsive = settings.value("responsive").toBool();
|
2017-12-17 13:49:03 +00:00
|
|
|
panelLock = settings.value("panelLock").toBool();
|
|
|
|
setPanelLock();
|
|
|
|
tabsOnTop = settings.value("tabsOnTop").toBool();
|
|
|
|
setTabLocation();
|
2017-12-21 15:47:36 +00:00
|
|
|
updateDockActionsChecked();
|
2017-12-17 13:49:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::saveSettings()
|
|
|
|
{
|
|
|
|
QSettings settings;
|
|
|
|
settings.setValue("geometry", saveGeometry());
|
|
|
|
settings.setValue("size", size());
|
|
|
|
settings.setValue("pos", pos());
|
|
|
|
settings.setValue("state", saveState());
|
|
|
|
settings.setValue("panelLock", panelLock);
|
|
|
|
settings.setValue("tabsOnTop", tabsOnTop);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::setPanelLock()
|
|
|
|
{
|
|
|
|
if (panelLock)
|
|
|
|
{
|
|
|
|
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
|
|
|
{
|
|
|
|
dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->actionLock->setChecked(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
|
|
|
{
|
|
|
|
dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->actionLock->setChecked(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::setTabLocation()
|
|
|
|
{
|
|
|
|
if (tabsOnTop)
|
|
|
|
{
|
|
|
|
ui->centralTabWidget->setTabPosition(QTabWidget::North);
|
|
|
|
this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
|
|
|
|
ui->actionTabs_on_Top->setChecked(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ui->centralTabWidget->setTabPosition(QTabWidget::South);
|
|
|
|
this->setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::South);
|
|
|
|
ui->actionTabs_on_Top->setChecked(false);
|
|
|
|
}
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-11-19 12:56:10 +00:00
|
|
|
void MainWindow::refreshAll()
|
2017-04-09 19:55:06 +00:00
|
|
|
{
|
2017-11-19 12:56:10 +00:00
|
|
|
Core()->triggerRefreshAll();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::lockUnlock_Docks(bool what)
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
if (what)
|
|
|
|
{
|
|
|
|
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
|
|
|
}
|
2017-04-09 19:55:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-12-21 15:47:36 +00:00
|
|
|
void MainWindow::toggleDockWidget(QDockWidget *dock_widget, bool show)
|
2017-05-19 07:45:26 +00:00
|
|
|
{
|
2017-12-21 15:47:36 +00:00
|
|
|
if (!show)
|
2017-05-19 07:45:26 +00:00
|
|
|
{
|
|
|
|
dock_widget->close();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
dock_widget->show();
|
|
|
|
dock_widget->raise();
|
|
|
|
}
|
|
|
|
}
|
2017-04-28 13:09:40 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
void MainWindow::restoreDocks()
|
|
|
|
{
|
2017-12-10 16:55:42 +00:00
|
|
|
// In the upper half the functions are the first widget
|
2017-11-03 17:22:54 +00:00
|
|
|
addDockWidget(Qt::TopDockWidgetArea, functionsDock);
|
2017-10-13 13:53:23 +00:00
|
|
|
|
2017-12-10 16:55:42 +00:00
|
|
|
// Function | Dashboard | Sidebar
|
2017-11-03 17:22:54 +00:00
|
|
|
splitDockWidget(functionsDock, dashboardDock, Qt::Horizontal);
|
|
|
|
splitDockWidget(dashboardDock, sidebarDock, Qt::Horizontal);
|
|
|
|
|
2017-12-10 16:55:42 +00:00
|
|
|
// In the lower half the console is the first widget
|
|
|
|
addDockWidget(Qt::BottomDockWidgetArea, consoleDock);
|
|
|
|
|
|
|
|
// Console | Sections
|
|
|
|
splitDockWidget(consoleDock, sectionsDock, Qt::Horizontal);
|
2017-11-03 17:22:54 +00:00
|
|
|
|
2018-01-09 12:09:25 +00:00
|
|
|
// Tabs for center (must be applied after splitDockWidget())
|
2017-11-03 17:22:54 +00:00
|
|
|
tabifyDockWidget(sectionsDock, commentsDock);
|
|
|
|
tabifyDockWidget(dashboardDock, disassemblyDock);
|
|
|
|
tabifyDockWidget(dashboardDock, graphDock);
|
|
|
|
tabifyDockWidget(dashboardDock, hexdumpDock);
|
2017-12-06 23:19:14 +00:00
|
|
|
tabifyDockWidget(dashboardDock, pseudocodeDock);
|
2017-11-03 17:22:54 +00:00
|
|
|
tabifyDockWidget(dashboardDock, entrypointDock);
|
|
|
|
tabifyDockWidget(dashboardDock, flagsDock);
|
|
|
|
tabifyDockWidget(dashboardDock, stringsDock);
|
|
|
|
tabifyDockWidget(dashboardDock, relocsDock);
|
|
|
|
tabifyDockWidget(dashboardDock, importsDock);
|
|
|
|
tabifyDockWidget(dashboardDock, exportsDock);
|
2018-03-06 17:21:48 +00:00
|
|
|
tabifyDockWidget(dashboardDock, typesDock);
|
2017-11-03 17:22:54 +00:00
|
|
|
tabifyDockWidget(dashboardDock, symbolsDock);
|
2017-12-23 16:42:42 +00:00
|
|
|
tabifyDockWidget(dashboardDock, classesDock);
|
2018-02-04 14:32:18 +00:00
|
|
|
tabifyDockWidget(dashboardDock, resourcesDock);
|
2018-02-26 22:26:18 +00:00
|
|
|
tabifyDockWidget(dashboardDock, vTablesDock);
|
2018-03-02 13:15:53 +00:00
|
|
|
#ifdef CUTTER_ENABLE_JUPYTER
|
2017-12-13 17:36:00 +00:00
|
|
|
tabifyDockWidget(dashboardDock, jupyterDock);
|
2018-03-02 13:15:53 +00:00
|
|
|
#endif
|
2017-11-03 17:22:54 +00:00
|
|
|
|
2017-12-21 15:47:36 +00:00
|
|
|
updateDockActionsChecked();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-11-03 17:22:54 +00:00
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
void MainWindow::hideAllDocks()
|
|
|
|
{
|
2017-04-13 15:36:20 +00:00
|
|
|
for (auto w : dockWidgets)
|
|
|
|
{
|
2018-01-09 12:09:25 +00:00
|
|
|
removeDockWidget(w);
|
2017-04-13 15:36:20 +00:00
|
|
|
}
|
2017-12-21 15:47:36 +00:00
|
|
|
|
|
|
|
updateDockActionsChecked();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::updateDockActionsChecked()
|
|
|
|
{
|
|
|
|
for(auto i=dockWidgetActions.constBegin(); i!=dockWidgetActions.constEnd(); i++)
|
|
|
|
{
|
|
|
|
i.key()->setChecked(!i.value()->isHidden());
|
|
|
|
}
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::showDefaultDocks()
|
|
|
|
{
|
2017-10-11 11:22:30 +00:00
|
|
|
const QList<QDockWidget *> defaultDocks = { sectionsDock,
|
2017-11-03 17:22:54 +00:00
|
|
|
entrypointDock,
|
|
|
|
functionsDock,
|
|
|
|
commentsDock,
|
|
|
|
stringsDock,
|
2017-12-10 16:55:42 +00:00
|
|
|
consoleDock,
|
2017-11-03 17:22:54 +00:00
|
|
|
importsDock,
|
|
|
|
symbolsDock,
|
|
|
|
graphDock,
|
|
|
|
disassemblyDock,
|
|
|
|
sidebarDock,
|
|
|
|
hexdumpDock,
|
2017-12-06 23:19:14 +00:00
|
|
|
pseudocodeDock,
|
2017-12-13 17:36:00 +00:00
|
|
|
dashboardDock,
|
2018-03-02 13:15:53 +00:00
|
|
|
#ifdef CUTTER_ENABLE_JUPYTER
|
2017-12-13 17:36:00 +00:00
|
|
|
jupyterDock
|
2018-03-02 13:15:53 +00:00
|
|
|
#endif
|
2017-11-03 17:22:54 +00:00
|
|
|
};
|
2017-04-13 15:36:20 +00:00
|
|
|
|
|
|
|
for (auto w : dockWidgets)
|
|
|
|
{
|
|
|
|
if (defaultDocks.contains(w))
|
|
|
|
{
|
|
|
|
w->show();
|
|
|
|
}
|
|
|
|
}
|
2017-12-21 15:47:36 +00:00
|
|
|
|
|
|
|
updateDockActionsChecked();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-11-03 17:22:54 +00:00
|
|
|
void MainWindow::resetToDefaultLayout()
|
|
|
|
{
|
|
|
|
hideAllDocks();
|
2018-01-09 12:09:25 +00:00
|
|
|
restoreDocks();
|
2017-11-03 17:22:54 +00:00
|
|
|
showDefaultDocks();
|
|
|
|
dashboardDock->raise();
|
|
|
|
|
|
|
|
// ugly workaround to set the default widths of functions and sidebar docks
|
|
|
|
// if anyone finds a way to do this cleaner that also works, feel free to change it!
|
|
|
|
auto restoreFunctionDock = qhelpers::forceWidth(functionsDock->widget(), 300);
|
|
|
|
auto restoreSidebarDock = qhelpers::forceWidth(sidebarDock->widget(), 300);
|
|
|
|
|
|
|
|
qApp->processEvents();
|
|
|
|
|
|
|
|
restoreFunctionDock.restoreWidth(functionsDock->widget());
|
|
|
|
restoreSidebarDock.restoreWidth(sidebarDock->widget());
|
2017-11-04 11:46:29 +00:00
|
|
|
|
|
|
|
Core()->setMemoryWidgetPriority(CutterCore::MemoryWidgetType::Disassembly);
|
2017-11-03 17:22:54 +00:00
|
|
|
}
|
|
|
|
|
2018-01-16 14:09:51 +00:00
|
|
|
void MainWindow::addOutput(const QString &msg)
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
2018-01-16 14:09:51 +00:00
|
|
|
consoleDock->addOutput(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::addDebugOutput(const QString &msg)
|
|
|
|
{
|
|
|
|
printf("debug output: %s\n", msg.toLocal8Bit().constData());
|
|
|
|
consoleDock->addDebugOutput(msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionLock_triggered()
|
|
|
|
{
|
|
|
|
panelLock = !panelLock;
|
|
|
|
setPanelLock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionLockUnlock_triggered()
|
|
|
|
{
|
|
|
|
if (ui->actionLockUnlock->isChecked())
|
|
|
|
{
|
|
|
|
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
|
|
|
{
|
|
|
|
dockWidget->setFeatures(QDockWidget::NoDockWidgetFeatures);
|
|
|
|
}
|
|
|
|
ui->actionLockUnlock->setIcon(QIcon(":/lock"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
foreach (QDockWidget *dockWidget, findChildren<QDockWidget *>())
|
|
|
|
{
|
|
|
|
dockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
|
|
|
|
}
|
|
|
|
ui->actionLockUnlock->setIcon(QIcon(":/unlock"));
|
|
|
|
}
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionFunctionsRename_triggered()
|
|
|
|
{
|
2017-04-09 19:55:06 +00:00
|
|
|
RenameDialog *r = new RenameDialog(this);
|
2017-03-29 10:18:37 +00:00
|
|
|
// Get function based on click position
|
|
|
|
//r->setFunctionName(fcn_name);
|
|
|
|
r->open();
|
|
|
|
}
|
|
|
|
|
2018-01-16 14:09:51 +00:00
|
|
|
void MainWindow::on_actionDefault_triggered()
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
2018-01-16 14:09:51 +00:00
|
|
|
resetToDefaultLayout();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionNew_triggered()
|
|
|
|
{
|
2018-01-16 14:09:51 +00:00
|
|
|
on_actionOpen_triggered();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionSave_triggered()
|
|
|
|
{
|
2017-05-13 18:09:36 +00:00
|
|
|
saveProject();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-10-21 19:20:10 +00:00
|
|
|
void MainWindow::on_actionSaveAs_triggered()
|
|
|
|
{
|
2017-11-03 17:22:54 +00:00
|
|
|
saveProjectAs();
|
2017-10-21 19:20:10 +00:00
|
|
|
}
|
|
|
|
|
2017-03-29 10:18:37 +00:00
|
|
|
void MainWindow::on_actionRun_Script_triggered()
|
|
|
|
{
|
|
|
|
QFileDialog dialog(this);
|
|
|
|
dialog.setFileMode(QFileDialog::ExistingFile);
|
|
|
|
dialog.setViewMode(QFileDialog::Detail);
|
|
|
|
dialog.setDirectory(QDir::home());
|
|
|
|
|
|
|
|
QString fileName;
|
2017-09-09 09:36:15 +00:00
|
|
|
fileName = dialog.getOpenFileName(this, tr("Select radare2 script"));
|
2017-04-13 15:51:58 +00:00
|
|
|
if (!fileName.length()) //cancel was pressed
|
2017-04-09 20:36:17 +00:00
|
|
|
return;
|
2017-03-29 10:18:37 +00:00
|
|
|
this->core->cmd(". " + fileName);
|
|
|
|
}
|
|
|
|
|
2018-01-16 14:09:51 +00:00
|
|
|
void MainWindow::on_actionOpen_triggered()
|
2017-03-29 10:18:37 +00:00
|
|
|
{
|
2017-04-01 01:56:35 +00:00
|
|
|
QProcess process(this);
|
|
|
|
process.setEnvironment(QProcess::systemEnvironment());
|
|
|
|
process.startDetached(qApp->applicationFilePath());
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
|
2017-04-09 19:55:06 +00:00
|
|
|
void MainWindow::toggleResponsive(bool maybe)
|
|
|
|
{
|
2017-03-29 10:18:37 +00:00
|
|
|
this->responsive = maybe;
|
|
|
|
// Save options in settings
|
2017-04-03 00:18:09 +00:00
|
|
|
QSettings settings;
|
2017-03-29 10:18:37 +00:00
|
|
|
settings.setValue("responsive", this->responsive);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionTabs_on_Top_triggered()
|
|
|
|
{
|
|
|
|
this->on_actionTabs_triggered();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionReset_settings_triggered()
|
|
|
|
{
|
2017-05-19 07:45:26 +00:00
|
|
|
QMessageBox::StandardButton ret =
|
2017-09-25 12:55:41 +00:00
|
|
|
(QMessageBox::StandardButton)QMessageBox::question(this, APPNAME,
|
2017-09-09 09:36:15 +00:00
|
|
|
tr("Do you really want to clear all settings?"),
|
2017-06-03 12:27:23 +00:00
|
|
|
QMessageBox::Ok | QMessageBox::Cancel);
|
2017-04-09 19:55:06 +00:00
|
|
|
if (ret == QMessageBox::Ok)
|
|
|
|
{
|
2017-12-03 12:10:09 +00:00
|
|
|
Config()->resetAll();
|
2017-03-29 10:18:37 +00:00
|
|
|
}
|
|
|
|
}
|
2017-03-31 21:54:06 +00:00
|
|
|
|
|
|
|
void MainWindow::on_actionQuit_triggered()
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
2017-04-12 21:04:39 +00:00
|
|
|
|
2018-03-08 09:11:19 +00:00
|
|
|
void MainWindow::on_actionBackward_triggered()
|
|
|
|
{
|
|
|
|
Core()->seekPrev();
|
|
|
|
}
|
|
|
|
|
2018-01-16 14:09:51 +00:00
|
|
|
void MainWindow::on_actionForward_triggered()
|
|
|
|
{
|
2018-03-08 09:11:19 +00:00
|
|
|
Core()->seekNext();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionUndoSeek_triggered()
|
|
|
|
{
|
|
|
|
Core()->seekPrev();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionRedoSeek_triggered()
|
|
|
|
{
|
|
|
|
Core()->seekNext();
|
2018-01-16 14:09:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionDisasAdd_comment_triggered()
|
|
|
|
{
|
|
|
|
CommentsDialog *c = new CommentsDialog(this);
|
|
|
|
c->exec();
|
|
|
|
delete c;
|
|
|
|
}
|
|
|
|
|
2017-05-26 08:52:17 +00:00
|
|
|
void MainWindow::on_actionRefresh_contents_triggered()
|
|
|
|
{
|
2017-11-19 12:56:10 +00:00
|
|
|
refreshAll();
|
2017-05-26 08:52:17 +00:00
|
|
|
}
|
2017-08-31 17:43:46 +00:00
|
|
|
|
2017-12-14 13:42:24 +00:00
|
|
|
void MainWindow::on_actionPreferences_triggered()
|
2017-08-31 17:43:46 +00:00
|
|
|
{
|
2017-12-14 13:42:24 +00:00
|
|
|
auto dialog = new PreferencesDialog(this);
|
2017-10-01 14:36:40 +00:00
|
|
|
dialog->show();
|
2017-09-02 08:17:48 +00:00
|
|
|
}
|
2017-10-21 19:20:10 +00:00
|
|
|
|
2018-01-16 14:09:51 +00:00
|
|
|
void MainWindow::on_actionTabs_triggered()
|
|
|
|
{
|
|
|
|
tabsOnTop = !tabsOnTop;
|
|
|
|
setTabLocation();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionAbout_triggered()
|
|
|
|
{
|
|
|
|
AboutDialog *a = new AboutDialog(this);
|
|
|
|
a->open();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::on_actionRefresh_Panels_triggered()
|
|
|
|
{
|
|
|
|
this->refreshAll();
|
|
|
|
}
|
|
|
|
|
2018-01-27 10:40:26 +00:00
|
|
|
void MainWindow::on_actionAnalyze_triggered()
|
|
|
|
{
|
|
|
|
displayAnalysisOptionsDialog(-1, QList<QString>());
|
|
|
|
}
|
|
|
|
|
2018-01-16 14:09:51 +00:00
|
|
|
void MainWindow::on_actionImportPDB_triggered()
|
|
|
|
{
|
|
|
|
QFileDialog dialog(this);
|
|
|
|
dialog.setWindowTitle(tr("Select PDB file"));
|
|
|
|
dialog.setNameFilters({ tr("PDB file (*.pdb)"), tr("All files (*)") });
|
|
|
|
|
|
|
|
if (!dialog.exec())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString pdbFile = dialog.selectedFiles().first();
|
|
|
|
|
|
|
|
if (!pdbFile.isEmpty())
|
|
|
|
{
|
|
|
|
Core()->loadPDB(pdbFile);
|
|
|
|
addOutput(tr("%1 loaded.").arg(pdbFile));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-21 19:20:10 +00:00
|
|
|
void MainWindow::projectSaved(const QString &name)
|
|
|
|
{
|
2018-01-16 14:09:51 +00:00
|
|
|
addOutput(tr("Project saved: ") + name);
|
2017-10-21 19:20:10 +00:00
|
|
|
}
|