Default Layout (#84)

* Basic default layout
* Workaround to set default widths for QDockWidgets
* AStyle
This commit is contained in:
Florian Märkl 2017-11-03 18:22:54 +01:00 committed by xarkes
parent bfed7d43ed
commit 0b5a351d5f
14 changed files with 294 additions and 138 deletions

View File

@ -34,7 +34,7 @@ void AnalThread::start(MainWindow *main, int level, QList<QString> advanced)
void AnalThread::run() void AnalThread::run()
{ {
const auto optionsDialog = dynamic_cast<OptionsDialog *>(parent()); const auto optionsDialog = dynamic_cast<OptionsDialog *>(parent());
const auto& ui = optionsDialog->ui; const auto &ui = optionsDialog->ui;
int va = ui->vaCheckBox->isChecked(); int va = ui->vaCheckBox->isChecked();
ut64 loadaddr = 0LL; ut64 loadaddr = 0LL;
ut64 mapaddr = 0LL; ut64 mapaddr = 0LL;

View File

@ -257,9 +257,7 @@ void MainWindow::initUI()
dockWidgets.push_back(dashboardDock); dockWidgets.push_back(dashboardDock);
// Set up dock widgets default layout // Set up dock widgets default layout
restoreDocks(); resetToDefaultLayout();
hideAllDocks();
showDefaultDocks();
// Restore saved settings // Restore saved settings
this->readSettings(); this->readSettings();
@ -339,10 +337,10 @@ void MainWindow::finalizeOpen()
core->cmd("fs sections"); core->cmd("fs sections");
updateFrames(); updateFrames();
if(core->getNotes().isEmpty()) if (core->getNotes().isEmpty())
{ {
core->setNotes(tr("# Binary information\n\n") + core->cmd("i") + core->setNotes(tr("# Binary information\n\n") + core->cmd("i") +
"\n" + core->cmd("ie") + "\n" + core->cmd("iM") + "\n"); "\n" + core->cmd("ie") + "\n" + core->cmd("iM") + "\n");
} }
//Get binary beginning/end addresses //Get binary beginning/end addresses
@ -374,8 +372,8 @@ bool MainWindow::saveProject(bool quit)
bool MainWindow::saveProjectAs(bool quit) bool MainWindow::saveProjectAs(bool quit)
{ {
SaveProjectDialog dialog(quit, this); SaveProjectDialog dialog(quit, this);
int result = dialog.exec(); int result = dialog.exec();
return !quit || result != SaveProjectDialog::Rejected; return !quit || result != SaveProjectDialog::Rejected;
@ -406,7 +404,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
//qDebug() << ret; //qDebug() << ret;
if (ret == QMessageBox::Save) if (ret == QMessageBox::Save)
{ {
if(saveProject(true)) if (saveProject(true))
{ {
QSettings settings; QSettings settings;
settings.setValue("geometry", saveGeometry()); settings.setValue("geometry", saveGeometry());
@ -498,8 +496,9 @@ void MainWindow::updateFrames()
for (auto W : dockWidgets) for (auto W : dockWidgets)
{ {
// Temporary hack // Temporary hack
DockWidget* w = dynamic_cast<DockWidget*>(W); DockWidget *w = dynamic_cast<DockWidget *>(W);
if (w) { if (w)
{
w->setup(); w->setup();
} }
} }
@ -511,8 +510,9 @@ void MainWindow::updateFrames()
for (auto W : dockWidgets) for (auto W : dockWidgets)
{ {
// Temporary hack // Temporary hack
DockWidget* w = dynamic_cast<DockWidget*>(W); DockWidget *w = dynamic_cast<DockWidget *>(W);
if (w) { if (w)
{
w->refresh(); w->refresh();
} }
} }
@ -730,36 +730,39 @@ void MainWindow::on_actionDisasAdd_comment_triggered()
void MainWindow::restoreDocks() void MainWindow::restoreDocks()
{ {
addDockWidget(Qt::RightDockWidgetArea, this->sectionsDock); // bottom right
addDockWidget(Qt::TopDockWidgetArea, this->dashboardDock); addDockWidget(Qt::RightDockWidgetArea, sectionsDock);
this->tabifyDockWidget(this->sectionsDock, this->commentsDock);
this->tabifyDockWidget(this->dashboardDock, this->disassemblyDock); // left
this->tabifyDockWidget(this->dashboardDock, this->graphDock); addDockWidget(Qt::TopDockWidgetArea, functionsDock);
this->tabifyDockWidget(this->dashboardDock, this->hexdumpDock);
this->tabifyDockWidget(this->dashboardDock, this->previewDock); // center
this->tabifyDockWidget(this->dashboardDock, this->sidebarDock); splitDockWidget(functionsDock, dashboardDock, Qt::Horizontal);
this->tabifyDockWidget(this->dashboardDock, this->functionsDock);
this->tabifyDockWidget(this->dashboardDock, this->entrypointDock); // right (sidebar)
this->tabifyDockWidget(this->dashboardDock, this->flagsDock); splitDockWidget(dashboardDock, sidebarDock, Qt::Horizontal);
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();
}
void MainWindow::on_actionDefaut_triggered() // tabs for center (must be applied after splitDockWidget())
{ tabifyDockWidget(sectionsDock, commentsDock);
hideAllDocks(); tabifyDockWidget(dashboardDock, disassemblyDock);
restoreDocks(); tabifyDockWidget(dashboardDock, graphDock);
showDefaultDocks(); tabifyDockWidget(dashboardDock, hexdumpDock);
this->dashboardDock->raise(); 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() void MainWindow::hideAllDocks()
{ {
for (auto w : dockWidgets) for (auto w : dockWidgets)
@ -771,20 +774,20 @@ void MainWindow::hideAllDocks()
void MainWindow::showDefaultDocks() void MainWindow::showDefaultDocks()
{ {
const QList<QDockWidget *> defaultDocks = { sectionsDock, const QList<QDockWidget *> defaultDocks = { sectionsDock,
entrypointDock, entrypointDock,
functionsDock, functionsDock,
previewDock, previewDock,
commentsDock, commentsDock,
stringsDock, stringsDock,
importsDock, importsDock,
symbolsDock, symbolsDock,
notepadDock, notepadDock,
graphDock, graphDock,
disassemblyDock, disassemblyDock,
sidebarDock, sidebarDock,
hexdumpDock, hexdumpDock,
dashboardDock dashboardDock
}; };
for (auto w : dockWidgets) 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() void MainWindow::on_actionhide_bottomPannel_triggered()
{ {
if (ui->centralWidget->isVisible()) if (ui->centralWidget->isVisible())
@ -844,7 +871,7 @@ void MainWindow::on_actionSave_triggered()
void MainWindow::on_actionSaveAs_triggered() void MainWindow::on_actionSaveAs_triggered()
{ {
saveProjectAs(); saveProjectAs();
} }
void MainWindow::on_actionRun_Script_triggered() void MainWindow::on_actionRun_Script_triggered()
@ -958,8 +985,9 @@ void MainWindow::refreshVisibleDockWidgets()
if (isDockVisible(W)) if (isDockVisible(W))
{ {
// Temporary hack // Temporary hack
DockWidget* w = dynamic_cast<DockWidget*>(W); DockWidget *w = dynamic_cast<DockWidget *>(W);
if (w) { if (w)
{
w->setup(); w->setup();
} }
} }

View File

@ -57,8 +57,8 @@ public:
explicit MainWindow(QWidget *parent = 0); explicit MainWindow(QWidget *parent = 0);
~MainWindow(); ~MainWindow();
void openNewFile(const QString &fn, int anal_level = -1, QList<QString> advanced = QList<QString>()); void openNewFile(const QString &fn, int anal_level = -1, QList<QString> advanced = QList<QString>());
void openProject(const QString &project_name); void openProject(const QString &project_name);
void initUI(); void initUI();
void finalizeOpen(); void finalizeOpen();
@ -73,7 +73,7 @@ public:
* @param quit whether to show destructive button in dialog * @param quit whether to show destructive button in dialog
* @return if quit is true, false if the application should not close * @return if quit is true, false if the application should not close
*/ */
bool saveProjectAs(bool quit = false); bool saveProjectAs(bool quit = false);
void start_web_server(); void start_web_server();
void closeEvent(QCloseEvent *event) override; void closeEvent(QCloseEvent *event) override;
@ -147,20 +147,14 @@ private slots:
void on_actionDisasAdd_comment_triggered(); void on_actionDisasAdd_comment_triggered();
void restoreDocks();
void on_actionDefaut_triggered(); void on_actionDefaut_triggered();
void hideAllDocks();
void showDefaultDocks();
void on_actionFunctionsRename_triggered(); void on_actionFunctionsRename_triggered();
void on_actionNew_triggered(); void on_actionNew_triggered();
void on_actionSave_triggered(); void on_actionSave_triggered();
void on_actionSaveAs_triggered(); void on_actionSaveAs_triggered();
void on_actionWhite_Theme_triggered(); void on_actionWhite_Theme_triggered();
@ -228,6 +222,12 @@ private:
void toggleDockWidget(QDockWidget *dock_widget); void toggleDockWidget(QDockWidget *dock_widget);
void resetToDefaultLayout();
void restoreDocks();
void hideAllDocks();
void showDefaultDocks();
public: public:
RVA getCursorAddress() const { return cursorAddress; } RVA getCursorAddress() const { return cursorAddress; }
QString getFilename() const { return filename; } QString getFilename() const { return filename; }

View File

@ -189,7 +189,8 @@ QString CutterCore::cmd(const QString &str)
char *res = r_core_cmd_str(this->core_, cmd.constData()); char *res = r_core_cmd_str(this->core_, cmd.constData());
QString o = QString(res ? res : ""); QString o = QString(res ? res : "");
r_mem_free(res); r_mem_free(res);
if (offset != core_->offset) { if (offset != core_->offset)
{
emit seekChanged(core_->offset); emit seekChanged(core_->offset);
} }
return o; return o;

View File

@ -186,7 +186,7 @@ class CutterCore: public QObject
public: public:
explicit CutterCore(QObject *parent = 0); explicit CutterCore(QObject *parent = 0);
~CutterCore(); ~CutterCore();
static CutterCore* getInstance(); static CutterCore *getInstance();
/* Getters */ /* Getters */
RVA getOffset() const { return core_->offset; } RVA getOffset() const { return core_->offset; }

View File

@ -59,8 +59,8 @@ static QString formatBytecount(const long bytecount)
} }
NewFileDialog::NewFileDialog(QWidget *parent) : NewFileDialog::NewFileDialog(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::NewFileDialog) ui(new Ui::NewFileDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
@ -82,7 +82,7 @@ NewFileDialog::NewFileDialog(QWidget *parent) :
// Hide "create" button until the dialog works // Hide "create" button until the dialog works
ui->createButton->hide(); ui->createButton->hide();
ui->loadProjectButton->setEnabled(ui->projectsListWidget->currentItem() != nullptr); ui->loadProjectButton->setEnabled(ui->projectsListWidget->currentItem() != nullptr);
} }
NewFileDialog::~NewFileDialog() {} NewFileDialog::~NewFileDialog() {}
@ -105,41 +105,41 @@ void NewFileDialog::on_selectFileButton_clicked()
void NewFileDialog::on_selectProjectsDirButton_clicked() void NewFileDialog::on_selectProjectsDirButton_clicked()
{ {
QFileDialog dialog(this); QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::DirectoryOnly); dialog.setFileMode(QFileDialog::DirectoryOnly);
QString currentDir = CutterCore::getInstance()->getConfig("dir.projects"); QString currentDir = CutterCore::getInstance()->getConfig("dir.projects");
if(currentDir.startsWith("~")) if(currentDir.startsWith("~"))
{ {
currentDir = QDir::homePath() + currentDir.mid(1); currentDir = QDir::homePath() + currentDir.mid(1);
} }
dialog.setDirectory(currentDir); dialog.setDirectory(currentDir);
dialog.setWindowTitle(tr("Select project path (dir.projects)")); dialog.setWindowTitle(tr("Select project path (dir.projects)"));
if(!dialog.exec()) if(!dialog.exec())
{ {
return; return;
} }
QString dir = dialog.selectedFiles().first(); QString dir = dialog.selectedFiles().first();
if (!dir.isEmpty()) if (!dir.isEmpty())
{ {
CutterCore::getInstance()->setConfig("dir.projects", dir); CutterCore::getInstance()->setConfig("dir.projects", dir);
fillProjectsList(); fillProjectsList();
} }
} }
void NewFileDialog::on_loadProjectButton_clicked() void NewFileDialog::on_loadProjectButton_clicked()
{ {
QListWidgetItem *item = ui->projectsListWidget->currentItem(); QListWidgetItem *item = ui->projectsListWidget->currentItem();
if (item == nullptr) if (item == nullptr)
{ {
return; return;
} }
loadProject(item->data(Qt::UserRole).toString()); loadProject(item->data(Qt::UserRole).toString());
} }
void NewFileDialog::on_recentsListWidget_itemClicked(QListWidgetItem *item) void NewFileDialog::on_recentsListWidget_itemClicked(QListWidgetItem *item)
@ -156,7 +156,7 @@ void NewFileDialog::on_recentsListWidget_itemDoubleClicked(QListWidgetItem *item
void NewFileDialog::on_projectsListWidget_itemSelectionChanged() void NewFileDialog::on_projectsListWidget_itemSelectionChanged()
{ {
ui->loadProjectButton->setEnabled(ui->projectsListWidget->currentItem() != nullptr); ui->loadProjectButton->setEnabled(ui->projectsListWidget->currentItem() != nullptr);
} }
void NewFileDialog::on_projectsListWidget_itemDoubleClicked(QListWidgetItem *item) void NewFileDialog::on_projectsListWidget_itemDoubleClicked(QListWidgetItem *item)
@ -255,12 +255,12 @@ bool NewFileDialog::fillProjectsList()
{ {
CutterCore *core = CutterCore::getInstance(); CutterCore *core = CutterCore::getInstance();
ui->projectsDirEdit->setText(core->getConfig("dir.projects")); ui->projectsDirEdit->setText(core->getConfig("dir.projects"));
QStringList projects = core->getProjectNames(); QStringList projects = core->getProjectNames();
projects.sort(Qt::CaseInsensitive); projects.sort(Qt::CaseInsensitive);
ui->projectsListWidget->clear(); ui->projectsListWidget->clear();
int i=0; int i=0;
for(const QString &project : projects) for(const QString &project : projects)

View File

@ -12,7 +12,7 @@ namespace Ui
class NewFileDialog : public QDialog class NewFileDialog : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit NewFileDialog(QWidget *parent = 0); explicit NewFileDialog(QWidget *parent = 0);
@ -21,18 +21,18 @@ public:
private slots: private slots:
void on_loadFileButton_clicked(); void on_loadFileButton_clicked();
void on_selectFileButton_clicked(); void on_selectFileButton_clicked();
void on_createButton_clicked(); void on_createButton_clicked();
void on_selectProjectsDirButton_clicked(); void on_selectProjectsDirButton_clicked();
void on_loadProjectButton_clicked(); void on_loadProjectButton_clicked();
void on_cancelButton_clicked(); void on_cancelButton_clicked();
void on_recentsListWidget_itemClicked(QListWidgetItem *item); void on_recentsListWidget_itemClicked(QListWidgetItem *item);
void on_recentsListWidget_itemDoubleClicked(QListWidgetItem *item); void on_recentsListWidget_itemDoubleClicked(QListWidgetItem *item);
void on_projectsListWidget_itemSelectionChanged(); void on_projectsListWidget_itemSelectionChanged();
void on_projectsListWidget_itemDoubleClicked(QListWidgetItem *item); void on_projectsListWidget_itemDoubleClicked(QListWidgetItem *item);
void on_actionRemove_item_triggered(); void on_actionRemove_item_triggered();
void on_actionClear_all_triggered(); void on_actionClear_all_triggered();
@ -40,18 +40,18 @@ private slots:
private: private:
std::unique_ptr<Ui::NewFileDialog> ui; std::unique_ptr<Ui::NewFileDialog> ui;
/*! /*!
* @return true if list is not empty * @return true if list is not empty
*/ */
bool fillRecentFilesList(); bool fillRecentFilesList();
/*! /*!
* @return true if list is not empty * @return true if list is not empty
*/ */
bool fillProjectsList(); bool fillProjectsList();
void loadFile(const QString &filename); void loadFile(const QString &filename);
void loadProject(const QString &project); void loadProject(const QString &project);
static const int MaxRecentFiles = 5; static const int MaxRecentFiles = 5;
}; };

View File

@ -6,12 +6,12 @@
#include "ui_SaveProjectDialog.h" #include "ui_SaveProjectDialog.h"
SaveProjectDialog::SaveProjectDialog(bool quit, QWidget *parent) : SaveProjectDialog::SaveProjectDialog(bool quit, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::SaveProjectDialog) ui(new Ui::SaveProjectDialog)
{ {
ui->setupUi(this); ui->setupUi(this);
CutterCore *core = CutterCore::getInstance(); CutterCore *core = CutterCore::getInstance();
if (quit) if (quit)
{ {
@ -26,10 +26,10 @@ SaveProjectDialog::SaveProjectDialog(bool quit, QWidget *parent) :
} }
ui->nameEdit->setText(core->getConfig("prj.name")); ui->nameEdit->setText(core->getConfig("prj.name"));
ui->projectsDirEdit->setText(core->getConfig("dir.projects")); ui->projectsDirEdit->setText(core->getConfig("dir.projects"));
ui->filesCheckBox->setChecked(core->getConfigb("prj.files")); ui->filesCheckBox->setChecked(core->getConfigb("prj.files"));
ui->gitCheckBox->setChecked(core->getConfigb("prj.git")); ui->gitCheckBox->setChecked(core->getConfigb("prj.git"));
ui->zipCheckBox->setChecked(core->getConfigb("prj.zip")); ui->zipCheckBox->setChecked(core->getConfigb("prj.zip"));
} }
SaveProjectDialog::~SaveProjectDialog() SaveProjectDialog::~SaveProjectDialog()
@ -64,19 +64,19 @@ void SaveProjectDialog::on_selectProjectsDirButton_clicked()
void SaveProjectDialog::on_buttonBox_clicked(QAbstractButton *button) void SaveProjectDialog::on_buttonBox_clicked(QAbstractButton *button)
{ {
switch(ui->buttonBox->buttonRole(button)) switch(ui->buttonBox->buttonRole(button))
{ {
case QDialogButtonBox::DestructiveRole: case QDialogButtonBox::DestructiveRole:
QDialog::done(Destructive); QDialog::done(Destructive);
break; break;
case QDialogButtonBox::RejectRole: case QDialogButtonBox::RejectRole:
QDialog::done(Rejected); QDialog::done(Rejected);
break; break;
default: default:
break; break;
} }
} }
void SaveProjectDialog::accept() void SaveProjectDialog::accept()

View File

@ -16,17 +16,17 @@ class SaveProjectDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
enum Result { Saved, Rejected, Destructive }; enum Result { Saved, Rejected, Destructive };
explicit SaveProjectDialog(bool quit, QWidget *parent = 0); explicit SaveProjectDialog(bool quit, QWidget *parent = 0);
~SaveProjectDialog(); ~SaveProjectDialog();
virtual void accept() override; virtual void accept() override;
virtual void reject() override; virtual void reject() override;
private slots: private slots:
void on_buttonBox_clicked(QAbstractButton *button); void on_buttonBox_clicked(QAbstractButton *button);
void on_selectProjectsDirButton_clicked(); void on_selectProjectsDirButton_clicked();
private: private:
std::unique_ptr<Ui::SaveProjectDialog> ui; std::unique_ptr<Ui::SaveProjectDialog> ui;

View File

@ -16,12 +16,13 @@
void set_appimage_symlink() void set_appimage_symlink()
{ {
char* path = realpath("/proc/self/exe", NULL); char *path = realpath("/proc/self/exe", NULL);
char* i = strrchr(path, '/'); char *i = strrchr(path, '/');
*(i+1) = '\0'; *(i + 1) = '\0';
char* dest = strcat(path, "../"); char *dest = strcat(path, "../");
struct stat buf; 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); remove(PREFIX);
} }
symlink(dest, PREFIX); symlink(dest, PREFIX);

View File

@ -8,6 +8,8 @@
#include <QString> #include <QString>
#include <QAbstractItemView> #include <QAbstractItemView>
#include <QAbstractButton> #include <QAbstractButton>
#include <QDockWidget>
#include <QtGui/QtGui>
static QAbstractItemView::ScrollMode scrollMode() static QAbstractItemView::ScrollMode scrollMode()
@ -87,4 +89,52 @@ namespace qhelpers
button->blockSignals(blocked); 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 } // end namespace

View File

@ -2,6 +2,7 @@
#define QHELPERS_H #define QHELPERS_H
#include <QString> #include <QString>
#include <QSizePolicy>
class QPlainTextEdit; class QPlainTextEdit;
class QTextEdit; class QTextEdit;
@ -10,6 +11,7 @@ class QTreeWidget;
class QTreeWidgetItem; class QTreeWidgetItem;
class QAbstractItemView; class QAbstractItemView;
class QAbstractButton; class QAbstractButton;
class QWidget;
namespace qhelpers namespace qhelpers
{ {
@ -24,6 +26,20 @@ namespace qhelpers
void setVerticalScrollMode(QAbstractItemView *tw); void setVerticalScrollMode(QAbstractItemView *tw);
void setCheckedWithoutSignals(QAbstractButton *button, bool checked); 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 #endif // HELPERS_H

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>603</width> <width>289</width>
<height>314</height> <height>359</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
@ -17,6 +17,18 @@
<string notr="true">Functions</string> <string notr="true">Functions</string>
</property> </property>
<widget class="QWidget" name="dockWidgetContents"> <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"> <layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
@ -35,6 +47,12 @@
</property> </property>
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QTabWidget::pane { /* The tab widget frame */ <string notr="true">QTabWidget::pane { /* The tab widget frame */
border-top: 0px; border-top: 0px;
@ -47,6 +65,12 @@ border-top: 0px;
<number>0</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="tab"> <widget class="QWidget" name="tab">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<attribute name="title"> <attribute name="title">
<string>List</string> <string>List</string>
</attribute> </attribute>
@ -68,6 +92,12 @@ border-top: 0px;
</property> </property>
<item> <item>
<widget class="QTreeView" name="functionsTreeView"> <widget class="QTreeView" name="functionsTreeView">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum> <enum>Qt::CustomContextMenu</enum>
</property> </property>
@ -120,6 +150,12 @@ QToolTip
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab_2"> <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"> <attribute name="title">
<string>Tree</string> <string>Tree</string>
</attribute> </attribute>
@ -141,6 +177,12 @@ QToolTip
</property> </property>
<item> <item>
<widget class="QTreeView" name="nestedFunctionsTreeView"> <widget class="QTreeView" name="nestedFunctionsTreeView">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum> <enum>Qt::CustomContextMenu</enum>
</property> </property>
@ -196,11 +238,20 @@ QToolTip {
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
</property> </property>
<property name="sizeConstraint">
<enum>QLayout::SetNoConstraint</enum>
</property>
<property name="rightMargin"> <property name="rightMargin">
<number>2</number> <number>2</number>
</property> </property>
<item> <item>
<widget class="QLineEdit" name="filterLineEdit"> <widget class="QLineEdit" name="filterLineEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText"> <property name="placeholderText">
<string>Quick Filter</string> <string>Quick Filter</string>
</property> </property>

View File

@ -11,7 +11,7 @@
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding"> <sizepolicy hsizetype="Ignored" vsizetype="Expanding">
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -20,6 +20,18 @@
<string notr="true">Sidebar</string> <string notr="true">Sidebar</string>
</property> </property>
<widget class="QWidget" name="dockWidgetContents"> <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"> <layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing"> <property name="spacing">
<number>0</number> <number>0</number>
@ -560,7 +572,4 @@ QToolTip {
<include location="../resources.qrc"/> <include location="../resources.qrc"/>
</resources> </resources>
<connections/> <connections/>
<buttongroups>
<buttongroup name="buttonGroup_2"/>
</buttongroups>
</ui> </ui>