mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 03:46:11 +00:00
Default Layout (#84)
* Basic default layout * Workaround to set default widths for QDockWidgets * AStyle
This commit is contained in:
parent
bfed7d43ed
commit
0b5a351d5f
@ -257,9 +257,7 @@ void MainWindow::initUI()
|
||||
dockWidgets.push_back(dashboardDock);
|
||||
|
||||
// Set up dock widgets default layout
|
||||
restoreDocks();
|
||||
hideAllDocks();
|
||||
showDefaultDocks();
|
||||
resetToDefaultLayout();
|
||||
|
||||
// Restore saved settings
|
||||
this->readSettings();
|
||||
@ -499,7 +497,8 @@ void MainWindow::updateFrames()
|
||||
{
|
||||
// Temporary hack
|
||||
DockWidget *w = dynamic_cast<DockWidget *>(W);
|
||||
if (w) {
|
||||
if (w)
|
||||
{
|
||||
w->setup();
|
||||
}
|
||||
}
|
||||
@ -512,7 +511,8 @@ void MainWindow::updateFrames()
|
||||
{
|
||||
// Temporary hack
|
||||
DockWidget *w = dynamic_cast<DockWidget *>(W);
|
||||
if (w) {
|
||||
if (w)
|
||||
{
|
||||
w->refresh();
|
||||
}
|
||||
}
|
||||
@ -730,36 +730,39 @@ void MainWindow::on_actionDisasAdd_comment_triggered()
|
||||
|
||||
void MainWindow::restoreDocks()
|
||||
{
|
||||
addDockWidget(Qt::RightDockWidgetArea, this->sectionsDock);
|
||||
addDockWidget(Qt::TopDockWidgetArea, this->dashboardDock);
|
||||
this->tabifyDockWidget(this->sectionsDock, this->commentsDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->disassemblyDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->graphDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->hexdumpDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->previewDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->sidebarDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->functionsDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->entrypointDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->flagsDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->stringsDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->relocsDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->importsDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->exportsDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->symbolsDock);
|
||||
this->tabifyDockWidget(this->dashboardDock, this->notepadDock);
|
||||
this->dashboardDock->raise();
|
||||
this->sectionsDock->raise();
|
||||
}
|
||||
// bottom right
|
||||
addDockWidget(Qt::RightDockWidgetArea, sectionsDock);
|
||||
|
||||
// left
|
||||
addDockWidget(Qt::TopDockWidgetArea, functionsDock);
|
||||
|
||||
// center
|
||||
splitDockWidget(functionsDock, dashboardDock, Qt::Horizontal);
|
||||
|
||||
// right (sidebar)
|
||||
splitDockWidget(dashboardDock, sidebarDock, Qt::Horizontal);
|
||||
|
||||
|
||||
void MainWindow::on_actionDefaut_triggered()
|
||||
{
|
||||
hideAllDocks();
|
||||
restoreDocks();
|
||||
showDefaultDocks();
|
||||
this->dashboardDock->raise();
|
||||
// tabs for center (must be applied after splitDockWidget())
|
||||
tabifyDockWidget(sectionsDock, commentsDock);
|
||||
tabifyDockWidget(dashboardDock, disassemblyDock);
|
||||
tabifyDockWidget(dashboardDock, graphDock);
|
||||
tabifyDockWidget(dashboardDock, hexdumpDock);
|
||||
tabifyDockWidget(dashboardDock, previewDock);
|
||||
tabifyDockWidget(dashboardDock, entrypointDock);
|
||||
tabifyDockWidget(dashboardDock, flagsDock);
|
||||
tabifyDockWidget(dashboardDock, stringsDock);
|
||||
tabifyDockWidget(dashboardDock, relocsDock);
|
||||
tabifyDockWidget(dashboardDock, importsDock);
|
||||
tabifyDockWidget(dashboardDock, exportsDock);
|
||||
tabifyDockWidget(dashboardDock, symbolsDock);
|
||||
tabifyDockWidget(dashboardDock, notepadDock);
|
||||
|
||||
dashboardDock->raise();
|
||||
sectionsDock->raise();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::hideAllDocks()
|
||||
{
|
||||
for (auto w : dockWidgets)
|
||||
@ -795,6 +798,30 @@ void MainWindow::showDefaultDocks()
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::resetToDefaultLayout()
|
||||
{
|
||||
restoreDocks();
|
||||
hideAllDocks();
|
||||
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());
|
||||
}
|
||||
|
||||
void MainWindow::on_actionDefaut_triggered()
|
||||
{
|
||||
resetToDefaultLayout();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionhide_bottomPannel_triggered()
|
||||
{
|
||||
if (ui->centralWidget->isVisible())
|
||||
@ -959,7 +986,8 @@ void MainWindow::refreshVisibleDockWidgets()
|
||||
{
|
||||
// Temporary hack
|
||||
DockWidget *w = dynamic_cast<DockWidget *>(W);
|
||||
if (w) {
|
||||
if (w)
|
||||
{
|
||||
w->setup();
|
||||
}
|
||||
}
|
||||
|
@ -147,14 +147,8 @@ private slots:
|
||||
|
||||
void on_actionDisasAdd_comment_triggered();
|
||||
|
||||
void restoreDocks();
|
||||
|
||||
void on_actionDefaut_triggered();
|
||||
|
||||
void hideAllDocks();
|
||||
|
||||
void showDefaultDocks();
|
||||
|
||||
void on_actionFunctionsRename_triggered();
|
||||
|
||||
void on_actionNew_triggered();
|
||||
@ -228,6 +222,12 @@ private:
|
||||
|
||||
void toggleDockWidget(QDockWidget *dock_widget);
|
||||
|
||||
void resetToDefaultLayout();
|
||||
|
||||
void restoreDocks();
|
||||
void hideAllDocks();
|
||||
void showDefaultDocks();
|
||||
|
||||
public:
|
||||
RVA getCursorAddress() const { return cursorAddress; }
|
||||
QString getFilename() const { return filename; }
|
||||
|
@ -189,7 +189,8 @@ QString CutterCore::cmd(const QString &str)
|
||||
char *res = r_core_cmd_str(this->core_, cmd.constData());
|
||||
QString o = QString(res ? res : "");
|
||||
r_mem_free(res);
|
||||
if (offset != core_->offset) {
|
||||
if (offset != core_->offset)
|
||||
{
|
||||
emit seekChanged(core_->offset);
|
||||
}
|
||||
return o;
|
||||
|
@ -21,7 +21,8 @@ void set_appimage_symlink()
|
||||
*(i + 1) = '\0';
|
||||
char *dest = strcat(path, "../");
|
||||
struct stat buf;
|
||||
if (lstat(PREFIX, &buf) == 0 && S_ISLNK(buf.st_mode)) {
|
||||
if (lstat(PREFIX, &buf) == 0 && S_ISLNK(buf.st_mode))
|
||||
{
|
||||
remove(PREFIX);
|
||||
}
|
||||
symlink(dest, PREFIX);
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <QString>
|
||||
#include <QAbstractItemView>
|
||||
#include <QAbstractButton>
|
||||
#include <QDockWidget>
|
||||
#include <QtGui/QtGui>
|
||||
|
||||
|
||||
static QAbstractItemView::ScrollMode scrollMode()
|
||||
@ -87,4 +89,52 @@ namespace qhelpers
|
||||
button->blockSignals(blocked);
|
||||
}
|
||||
|
||||
|
||||
SizePolicyMinMax forceWidth(QWidget *widget, int width)
|
||||
{
|
||||
SizePolicyMinMax r;
|
||||
r.sizePolicy = widget->sizePolicy();
|
||||
r.min = widget->minimumWidth();
|
||||
r.max = widget->maximumWidth();
|
||||
|
||||
QSizePolicy sizePolicy = r.sizePolicy;
|
||||
sizePolicy.setHorizontalPolicy(QSizePolicy::Fixed);
|
||||
widget->setSizePolicy(sizePolicy);
|
||||
widget->setMinimumWidth(width);
|
||||
widget->setMaximumWidth(width);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
SizePolicyMinMax forceHeight(QWidget *widget, int height)
|
||||
{
|
||||
SizePolicyMinMax r;
|
||||
r.sizePolicy = widget->sizePolicy();
|
||||
r.min = widget->minimumHeight();
|
||||
r.max = widget->maximumHeight();
|
||||
|
||||
QSizePolicy sizePolicy = r.sizePolicy;
|
||||
sizePolicy.setVerticalPolicy(QSizePolicy::Fixed);
|
||||
widget->setSizePolicy(sizePolicy);
|
||||
widget->setMinimumHeight(height);
|
||||
widget->setMaximumHeight(height);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
void SizePolicyMinMax::restoreWidth(QWidget *widget)
|
||||
{
|
||||
widget->setSizePolicy(sizePolicy);
|
||||
widget->setMinimumWidth(min);
|
||||
widget->setMaximumWidth(max);
|
||||
}
|
||||
|
||||
void SizePolicyMinMax::restoreHeight(QWidget *widget)
|
||||
{
|
||||
widget->setSizePolicy(sizePolicy);
|
||||
widget->setMinimumHeight(min);
|
||||
widget->setMaximumHeight(max);
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define QHELPERS_H
|
||||
|
||||
#include <QString>
|
||||
#include <QSizePolicy>
|
||||
|
||||
class QPlainTextEdit;
|
||||
class QTextEdit;
|
||||
@ -10,6 +11,7 @@ class QTreeWidget;
|
||||
class QTreeWidgetItem;
|
||||
class QAbstractItemView;
|
||||
class QAbstractButton;
|
||||
class QWidget;
|
||||
|
||||
namespace qhelpers
|
||||
{
|
||||
@ -24,6 +26,20 @@ namespace qhelpers
|
||||
void setVerticalScrollMode(QAbstractItemView *tw);
|
||||
|
||||
void setCheckedWithoutSignals(QAbstractButton *button, bool checked);
|
||||
|
||||
|
||||
struct SizePolicyMinMax
|
||||
{
|
||||
QSizePolicy sizePolicy;
|
||||
int min;
|
||||
int max;
|
||||
|
||||
void restoreWidth(QWidget *widget);
|
||||
void restoreHeight(QWidget *widget);
|
||||
};
|
||||
|
||||
SizePolicyMinMax forceWidth(QWidget *widget, int width);
|
||||
SizePolicyMinMax forceHeight(QWidget *widget, int height);
|
||||
}
|
||||
|
||||
#endif // HELPERS_H
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>603</width>
|
||||
<height>314</height>
|
||||
<width>289</width>
|
||||
<height>359</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
@ -17,6 +17,18 @@
|
||||
<string notr="true">Functions</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
@ -35,6 +47,12 @@
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">QTabWidget::pane { /* The tab widget frame */
|
||||
border-top: 0px;
|
||||
@ -47,6 +65,12 @@ border-top: 0px;
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>List</string>
|
||||
</attribute>
|
||||
@ -68,6 +92,12 @@ border-top: 0px;
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeView" name="functionsTreeView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
@ -120,6 +150,12 @@ QToolTip
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<attribute name="title">
|
||||
<string>Tree</string>
|
||||
</attribute>
|
||||
@ -141,6 +177,12 @@ QToolTip
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTreeView" name="nestedFunctionsTreeView">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
</property>
|
||||
@ -196,11 +238,20 @@ QToolTip {
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetNoConstraint</enum>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="filterLineEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>Quick Filter</string>
|
||||
</property>
|
||||
|
@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -20,6 +20,18 @@
|
||||
<string notr="true">Sidebar</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="dockWidgetContents">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
@ -560,7 +572,4 @@ QToolTip {
|
||||
<include location="../resources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
<buttongroups>
|
||||
<buttongroup name="buttonGroup_2"/>
|
||||
</buttongroups>
|
||||
</ui>
|
||||
|
Loading…
Reference in New Issue
Block a user