mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-19 19:36: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
@ -34,7 +34,7 @@ void AnalThread::start(MainWindow *main, int level, QList<QString> advanced)
|
||||
void AnalThread::run()
|
||||
{
|
||||
const auto optionsDialog = dynamic_cast<OptionsDialog *>(parent());
|
||||
const auto& ui = optionsDialog->ui;
|
||||
const auto &ui = optionsDialog->ui;
|
||||
int va = ui->vaCheckBox->isChecked();
|
||||
ut64 loadaddr = 0LL;
|
||||
ut64 mapaddr = 0LL;
|
||||
|
@ -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();
|
||||
@ -339,10 +337,10 @@ void MainWindow::finalizeOpen()
|
||||
core->cmd("fs sections");
|
||||
updateFrames();
|
||||
|
||||
if(core->getNotes().isEmpty())
|
||||
if (core->getNotes().isEmpty())
|
||||
{
|
||||
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
|
||||
@ -374,8 +372,8 @@ bool MainWindow::saveProject(bool quit)
|
||||
|
||||
bool MainWindow::saveProjectAs(bool quit)
|
||||
{
|
||||
SaveProjectDialog dialog(quit, this);
|
||||
int result = dialog.exec();
|
||||
SaveProjectDialog dialog(quit, this);
|
||||
int result = dialog.exec();
|
||||
|
||||
return !quit || result != SaveProjectDialog::Rejected;
|
||||
|
||||
@ -406,7 +404,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
||||
//qDebug() << ret;
|
||||
if (ret == QMessageBox::Save)
|
||||
{
|
||||
if(saveProject(true))
|
||||
if (saveProject(true))
|
||||
{
|
||||
QSettings settings;
|
||||
settings.setValue("geometry", saveGeometry());
|
||||
@ -498,8 +496,9 @@ void MainWindow::updateFrames()
|
||||
for (auto W : dockWidgets)
|
||||
{
|
||||
// Temporary hack
|
||||
DockWidget* w = dynamic_cast<DockWidget*>(W);
|
||||
if (w) {
|
||||
DockWidget *w = dynamic_cast<DockWidget *>(W);
|
||||
if (w)
|
||||
{
|
||||
w->setup();
|
||||
}
|
||||
}
|
||||
@ -511,8 +510,9 @@ void MainWindow::updateFrames()
|
||||
for (auto W : dockWidgets)
|
||||
{
|
||||
// Temporary hack
|
||||
DockWidget* w = dynamic_cast<DockWidget*>(W);
|
||||
if (w) {
|
||||
DockWidget *w = dynamic_cast<DockWidget *>(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)
|
||||
@ -771,20 +774,20 @@ void MainWindow::hideAllDocks()
|
||||
void MainWindow::showDefaultDocks()
|
||||
{
|
||||
const QList<QDockWidget *> defaultDocks = { sectionsDock,
|
||||
entrypointDock,
|
||||
functionsDock,
|
||||
previewDock,
|
||||
commentsDock,
|
||||
stringsDock,
|
||||
importsDock,
|
||||
symbolsDock,
|
||||
notepadDock,
|
||||
graphDock,
|
||||
disassemblyDock,
|
||||
sidebarDock,
|
||||
hexdumpDock,
|
||||
dashboardDock
|
||||
};
|
||||
entrypointDock,
|
||||
functionsDock,
|
||||
previewDock,
|
||||
commentsDock,
|
||||
stringsDock,
|
||||
importsDock,
|
||||
symbolsDock,
|
||||
notepadDock,
|
||||
graphDock,
|
||||
disassemblyDock,
|
||||
sidebarDock,
|
||||
hexdumpDock,
|
||||
dashboardDock
|
||||
};
|
||||
|
||||
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())
|
||||
@ -844,7 +871,7 @@ void MainWindow::on_actionSave_triggered()
|
||||
|
||||
void MainWindow::on_actionSaveAs_triggered()
|
||||
{
|
||||
saveProjectAs();
|
||||
saveProjectAs();
|
||||
}
|
||||
|
||||
void MainWindow::on_actionRun_Script_triggered()
|
||||
@ -958,8 +985,9 @@ void MainWindow::refreshVisibleDockWidgets()
|
||||
if (isDockVisible(W))
|
||||
{
|
||||
// Temporary hack
|
||||
DockWidget* w = dynamic_cast<DockWidget*>(W);
|
||||
if (w) {
|
||||
DockWidget *w = dynamic_cast<DockWidget *>(W);
|
||||
if (w)
|
||||
{
|
||||
w->setup();
|
||||
}
|
||||
}
|
||||
|
@ -57,8 +57,8 @@ public:
|
||||
explicit MainWindow(QWidget *parent = 0);
|
||||
~MainWindow();
|
||||
|
||||
void openNewFile(const QString &fn, int anal_level = -1, QList<QString> advanced = QList<QString>());
|
||||
void openProject(const QString &project_name);
|
||||
void openNewFile(const QString &fn, int anal_level = -1, QList<QString> advanced = QList<QString>());
|
||||
void openProject(const QString &project_name);
|
||||
|
||||
void initUI();
|
||||
void finalizeOpen();
|
||||
@ -73,7 +73,7 @@ public:
|
||||
* @param quit whether to show destructive button in dialog
|
||||
* @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 closeEvent(QCloseEvent *event) override;
|
||||
@ -147,20 +147,14 @@ 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();
|
||||
|
||||
void on_actionSave_triggered();
|
||||
void on_actionSaveAs_triggered();
|
||||
void on_actionSaveAs_triggered();
|
||||
|
||||
void on_actionWhite_Theme_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;
|
||||
|
@ -186,7 +186,7 @@ class CutterCore: public QObject
|
||||
public:
|
||||
explicit CutterCore(QObject *parent = 0);
|
||||
~CutterCore();
|
||||
static CutterCore* getInstance();
|
||||
static CutterCore *getInstance();
|
||||
|
||||
/* Getters */
|
||||
RVA getOffset() const { return core_->offset; }
|
||||
|
@ -59,8 +59,8 @@ static QString formatBytecount(const long bytecount)
|
||||
}
|
||||
|
||||
NewFileDialog::NewFileDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::NewFileDialog)
|
||||
QDialog(parent),
|
||||
ui(new Ui::NewFileDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
|
||||
@ -82,7 +82,7 @@ NewFileDialog::NewFileDialog(QWidget *parent) :
|
||||
// Hide "create" button until the dialog works
|
||||
ui->createButton->hide();
|
||||
|
||||
ui->loadProjectButton->setEnabled(ui->projectsListWidget->currentItem() != nullptr);
|
||||
ui->loadProjectButton->setEnabled(ui->projectsListWidget->currentItem() != nullptr);
|
||||
}
|
||||
|
||||
NewFileDialog::~NewFileDialog() {}
|
||||
@ -105,41 +105,41 @@ void NewFileDialog::on_selectFileButton_clicked()
|
||||
|
||||
void NewFileDialog::on_selectProjectsDirButton_clicked()
|
||||
{
|
||||
QFileDialog dialog(this);
|
||||
dialog.setFileMode(QFileDialog::DirectoryOnly);
|
||||
QFileDialog dialog(this);
|
||||
dialog.setFileMode(QFileDialog::DirectoryOnly);
|
||||
|
||||
QString currentDir = CutterCore::getInstance()->getConfig("dir.projects");
|
||||
if(currentDir.startsWith("~"))
|
||||
{
|
||||
currentDir = QDir::homePath() + currentDir.mid(1);
|
||||
}
|
||||
dialog.setDirectory(currentDir);
|
||||
dialog.setDirectory(currentDir);
|
||||
|
||||
dialog.setWindowTitle(tr("Select project path (dir.projects)"));
|
||||
|
||||
if(!dialog.exec())
|
||||
if(!dialog.exec())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QString dir = dialog.selectedFiles().first();
|
||||
if (!dir.isEmpty())
|
||||
{
|
||||
CutterCore::getInstance()->setConfig("dir.projects", dir);
|
||||
fillProjectsList();
|
||||
}
|
||||
QString dir = dialog.selectedFiles().first();
|
||||
if (!dir.isEmpty())
|
||||
{
|
||||
CutterCore::getInstance()->setConfig("dir.projects", dir);
|
||||
fillProjectsList();
|
||||
}
|
||||
}
|
||||
|
||||
void NewFileDialog::on_loadProjectButton_clicked()
|
||||
{
|
||||
QListWidgetItem *item = ui->projectsListWidget->currentItem();
|
||||
QListWidgetItem *item = ui->projectsListWidget->currentItem();
|
||||
|
||||
if (item == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (item == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
loadProject(item->data(Qt::UserRole).toString());
|
||||
loadProject(item->data(Qt::UserRole).toString());
|
||||
}
|
||||
|
||||
void NewFileDialog::on_recentsListWidget_itemClicked(QListWidgetItem *item)
|
||||
@ -156,7 +156,7 @@ void NewFileDialog::on_recentsListWidget_itemDoubleClicked(QListWidgetItem *item
|
||||
|
||||
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)
|
||||
@ -255,12 +255,12 @@ bool NewFileDialog::fillProjectsList()
|
||||
{
|
||||
CutterCore *core = CutterCore::getInstance();
|
||||
|
||||
ui->projectsDirEdit->setText(core->getConfig("dir.projects"));
|
||||
ui->projectsDirEdit->setText(core->getConfig("dir.projects"));
|
||||
|
||||
QStringList projects = core->getProjectNames();
|
||||
projects.sort(Qt::CaseInsensitive);
|
||||
|
||||
ui->projectsListWidget->clear();
|
||||
ui->projectsListWidget->clear();
|
||||
|
||||
int i=0;
|
||||
for(const QString &project : projects)
|
||||
|
@ -12,7 +12,7 @@ namespace Ui
|
||||
|
||||
class NewFileDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit NewFileDialog(QWidget *parent = 0);
|
||||
@ -21,18 +21,18 @@ public:
|
||||
private slots:
|
||||
void on_loadFileButton_clicked();
|
||||
void on_selectFileButton_clicked();
|
||||
void on_createButton_clicked();
|
||||
void on_createButton_clicked();
|
||||
|
||||
void on_selectProjectsDirButton_clicked();
|
||||
void on_loadProjectButton_clicked();
|
||||
void on_selectProjectsDirButton_clicked();
|
||||
void on_loadProjectButton_clicked();
|
||||
|
||||
void on_cancelButton_clicked();
|
||||
void on_cancelButton_clicked();
|
||||
|
||||
void on_recentsListWidget_itemClicked(QListWidgetItem *item);
|
||||
void on_recentsListWidget_itemDoubleClicked(QListWidgetItem *item);
|
||||
|
||||
void on_projectsListWidget_itemSelectionChanged();
|
||||
void on_projectsListWidget_itemDoubleClicked(QListWidgetItem *item);
|
||||
void on_projectsListWidget_itemSelectionChanged();
|
||||
void on_projectsListWidget_itemDoubleClicked(QListWidgetItem *item);
|
||||
|
||||
void on_actionRemove_item_triggered();
|
||||
void on_actionClear_all_triggered();
|
||||
@ -40,18 +40,18 @@ private slots:
|
||||
private:
|
||||
std::unique_ptr<Ui::NewFileDialog> ui;
|
||||
|
||||
/*!
|
||||
* @return true if list is not empty
|
||||
*/
|
||||
bool fillRecentFilesList();
|
||||
/*!
|
||||
* @return true if list is not empty
|
||||
*/
|
||||
bool fillRecentFilesList();
|
||||
|
||||
/*!
|
||||
* @return true if list is not empty
|
||||
*/
|
||||
bool fillProjectsList();
|
||||
/*!
|
||||
* @return true if list is not empty
|
||||
*/
|
||||
bool fillProjectsList();
|
||||
|
||||
void loadFile(const QString &filename);
|
||||
void loadProject(const QString &project);
|
||||
void loadFile(const QString &filename);
|
||||
void loadProject(const QString &project);
|
||||
|
||||
static const int MaxRecentFiles = 5;
|
||||
};
|
||||
|
@ -6,12 +6,12 @@
|
||||
#include "ui_SaveProjectDialog.h"
|
||||
|
||||
SaveProjectDialog::SaveProjectDialog(bool quit, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::SaveProjectDialog)
|
||||
QDialog(parent),
|
||||
ui(new Ui::SaveProjectDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
CutterCore *core = CutterCore::getInstance();
|
||||
CutterCore *core = CutterCore::getInstance();
|
||||
|
||||
if (quit)
|
||||
{
|
||||
@ -26,10 +26,10 @@ SaveProjectDialog::SaveProjectDialog(bool quit, QWidget *parent) :
|
||||
}
|
||||
|
||||
ui->nameEdit->setText(core->getConfig("prj.name"));
|
||||
ui->projectsDirEdit->setText(core->getConfig("dir.projects"));
|
||||
ui->filesCheckBox->setChecked(core->getConfigb("prj.files"));
|
||||
ui->gitCheckBox->setChecked(core->getConfigb("prj.git"));
|
||||
ui->zipCheckBox->setChecked(core->getConfigb("prj.zip"));
|
||||
ui->projectsDirEdit->setText(core->getConfig("dir.projects"));
|
||||
ui->filesCheckBox->setChecked(core->getConfigb("prj.files"));
|
||||
ui->gitCheckBox->setChecked(core->getConfigb("prj.git"));
|
||||
ui->zipCheckBox->setChecked(core->getConfigb("prj.zip"));
|
||||
}
|
||||
|
||||
SaveProjectDialog::~SaveProjectDialog()
|
||||
@ -64,19 +64,19 @@ void SaveProjectDialog::on_selectProjectsDirButton_clicked()
|
||||
|
||||
void SaveProjectDialog::on_buttonBox_clicked(QAbstractButton *button)
|
||||
{
|
||||
switch(ui->buttonBox->buttonRole(button))
|
||||
{
|
||||
case QDialogButtonBox::DestructiveRole:
|
||||
switch(ui->buttonBox->buttonRole(button))
|
||||
{
|
||||
case QDialogButtonBox::DestructiveRole:
|
||||
QDialog::done(Destructive);
|
||||
break;
|
||||
break;
|
||||
|
||||
case QDialogButtonBox::RejectRole:
|
||||
case QDialogButtonBox::RejectRole:
|
||||
QDialog::done(Rejected);
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void SaveProjectDialog::accept()
|
||||
|
@ -16,17 +16,17 @@ class SaveProjectDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Result { Saved, Rejected, Destructive };
|
||||
enum Result { Saved, Rejected, Destructive };
|
||||
|
||||
explicit SaveProjectDialog(bool quit, QWidget *parent = 0);
|
||||
~SaveProjectDialog();
|
||||
|
||||
virtual void accept() override;
|
||||
virtual void reject() override;
|
||||
virtual void reject() override;
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_clicked(QAbstractButton *button);
|
||||
void on_selectProjectsDirButton_clicked();
|
||||
void on_buttonBox_clicked(QAbstractButton *button);
|
||||
void on_selectProjectsDirButton_clicked();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui::SaveProjectDialog> ui;
|
||||
|
11
src/main.cpp
11
src/main.cpp
@ -16,12 +16,13 @@
|
||||
|
||||
void set_appimage_symlink()
|
||||
{
|
||||
char* path = realpath("/proc/self/exe", NULL);
|
||||
char* i = strrchr(path, '/');
|
||||
*(i+1) = '\0';
|
||||
char* dest = strcat(path, "../");
|
||||
char *path = realpath("/proc/self/exe", NULL);
|
||||
char *i = strrchr(path, '/');
|
||||
*(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