Splitter fix

This commit is contained in:
Megamouse 2017-07-22 18:48:18 +02:00 committed by Ivan
parent 2b24635ef7
commit 96dfa9b526
4 changed files with 56 additions and 13 deletions

View File

@ -1,7 +1,6 @@
#include "debugger_frame.h"
#include <QScrollBar>
#include <QSplitter>
#include <QApplication>
#include <QFontDatabase>
#include <QCompleter>
@ -9,7 +8,8 @@
inline QString qstr(const std::string& _in) { return QString::fromUtf8(_in.data(), _in.size()); }
extern bool user_asked_for_frame_capture;
debugger_frame::debugger_frame(QWidget *parent) : QDockWidget(tr("Debugger"), parent)
debugger_frame::debugger_frame(std::shared_ptr<gui_settings> settings, QWidget *parent)
: QDockWidget(tr("Debugger"), parent), xgui_settings(settings)
{
pSize = 10;
@ -64,12 +64,12 @@ debugger_frame::debugger_frame(QWidget *parent) : QDockWidget(tr("Debugger"), pa
m_list->setFont(mono);
m_regs->setFont(mono);
QSplitter* splitter = new QSplitter(this);
splitter->addWidget(m_list);
splitter->addWidget(m_regs);
m_splitter = new QSplitter(this);
m_splitter->addWidget(m_list);
m_splitter->addWidget(m_regs);
QHBoxLayout* hbox_w_list = new QHBoxLayout();
hbox_w_list->addWidget(splitter);
hbox_w_list->addWidget(m_splitter);
vbox_p_main->addLayout(hbox_b_main);
vbox_p_main->addLayout(hbox_w_list);
@ -113,12 +113,42 @@ debugger_frame::debugger_frame(QWidget *parent) : QDockWidget(tr("Debugger"), pa
UpdateUnitList();
}
void debugger_frame::SaveSettings()
{
xgui_settings->SetValue(GUI::d_splitterState, m_splitter->saveState());
}
void debugger_frame::closeEvent(QCloseEvent *event)
{
QDockWidget::closeEvent(event);
DebugFrameClosed();
}
void debugger_frame::showEvent(QShowEvent * event)
{
// resize splitter widgets
QByteArray state = xgui_settings->GetValue(GUI::d_splitterState).toByteArray();
if (state.isEmpty()) // resize 2:1
{
const int width_right = width() / 3;
const int width_left = width() - width_right;
m_splitter->setSizes({ width_left, width_right });
}
else
{
m_splitter->restoreState(state);
}
QDockWidget::showEvent(event);
}
void debugger_frame::hideEvent(QHideEvent * event)
{
// save splitter state or it will resume its initial state on next show
xgui_settings->SetValue(GUI::d_splitterState, m_splitter->saveState());
QDockWidget::hideEvent(event);
}
#include <map>
std::map<u32, bool> g_breakpoints;

View File

@ -17,6 +17,7 @@
#include "instruction_editor_dialog.h"
#include "register_editor_dialog.h"
#include "gui_settings.h"
#include <QDockWidget>
#include <QListWidget>
@ -26,6 +27,7 @@
#include <QWheelEvent>
#include <QTimer>
#include <QTextEdit>
#include <QSplitter>
class debugger_list;
@ -53,17 +55,21 @@ class debugger_frame : public QDockWidget
u32 m_last_stat = 0;
QTimer* update;
QSplitter* m_splitter;
const QString NoThread = tr("No Thread");
const QString Run = tr("Run");
const QString Pause = tr("Pause");
std::shared_ptr<gui_settings> xgui_settings;
public:
std::unique_ptr<CPUDisAsm> m_disasm;
std::weak_ptr<cpu_thread> cpu;
public:
explicit debugger_frame(QWidget *parent = 0);
explicit debugger_frame(std::shared_ptr<gui_settings> settings, QWidget *parent = 0);
void SaveSettings();
void UpdateUI();
void UpdateUnitList();
@ -80,6 +86,8 @@ public:
protected:
/** Override inherited method from Qt to allow signalling when close happened.*/
void closeEvent(QCloseEvent* event);
void showEvent(QShowEvent* event);
void hideEvent(QHideEvent* event);
Q_SIGNALS:
void DebugFrameClosed();

View File

@ -50,6 +50,7 @@ namespace GUI
const QString main_window = "main_window";
const QString game_list = "GameList";
const QString logger = "Logger";
const QString debugger = "Debugger";
const QString meta = "Meta";
const QString fs = "FileSystem";
const QString gs_frame = "GSFrame";
@ -103,20 +104,22 @@ namespace GUI
const GUI_SAVE gl_toolIconColor = GUI_SAVE( game_list, "toolIconColor", gl_tool_icon_color);
const GUI_SAVE fs_emulator_dir_list = GUI_SAVE(fs, "emulator_dir_list", QStringList());
const GUI_SAVE fs_dev_hdd0_list = GUI_SAVE(fs, "dev_hdd0_list", QStringList());
const GUI_SAVE fs_dev_hdd1_list = GUI_SAVE(fs, "dev_hdd1_list", QStringList());
const GUI_SAVE fs_dev_flash_list = GUI_SAVE(fs, "dev_flash_list", QStringList());
const GUI_SAVE fs_dev_usb000_list = GUI_SAVE(fs, "dev_usb000_list", QStringList());
const GUI_SAVE fs_dev_hdd0_list = GUI_SAVE(fs, "dev_hdd0_list", QStringList());
const GUI_SAVE fs_dev_hdd1_list = GUI_SAVE(fs, "dev_hdd1_list", QStringList());
const GUI_SAVE fs_dev_flash_list = GUI_SAVE(fs, "dev_flash_list", QStringList());
const GUI_SAVE fs_dev_usb000_list = GUI_SAVE(fs, "dev_usb000_list", QStringList());
const GUI_SAVE l_tty = GUI_SAVE( logger, "TTY", true );
const GUI_SAVE l_level = GUI_SAVE( logger, "level", (uint)(logs::level::success) );
const GUI_SAVE l_stack = GUI_SAVE( logger, "stack", false );
const GUI_SAVE d_splitterState = GUI_SAVE( debugger, "splitterState", QByteArray());
const GUI_SAVE m_currentConfig = GUI_SAVE(meta, "currentConfig", QObject::tr("CurrentSettings"));
const GUI_SAVE m_currentStylesheet = GUI_SAVE(meta, "currentStylesheet", QObject::tr("default"));
const GUI_SAVE gs_resize = GUI_SAVE(gs_frame, "resize", false);
const GUI_SAVE gs_width = GUI_SAVE(gs_frame, "width", 1280);
const GUI_SAVE gs_width = GUI_SAVE(gs_frame, "width", 1280);
const GUI_SAVE gs_height = GUI_SAVE(gs_frame, "height", 720);
}

View File

@ -639,6 +639,8 @@ void main_window::SaveWindowState()
// Save column settings
gameListFrame->SaveSettings();
// Save splitter state
debuggerFrame->SaveSettings();
}
void main_window::RepaintToolBarIcons()
@ -1224,7 +1226,7 @@ void main_window::CreateDockWindows()
gameListFrame = new game_list_frame(guiSettings, m_Render_Creator, m_mw);
gameListFrame->setObjectName("gamelist");
debuggerFrame = new debugger_frame(m_mw);
debuggerFrame = new debugger_frame(guiSettings, m_mw);
debuggerFrame->setObjectName("debugger");
logFrame = new log_frame(guiSettings, m_mw);
logFrame->setObjectName("logger");