- fix: width if menu items wrong in dark theme

This commit is contained in:
royqh1979 2021-08-31 11:13:12 +08:00
parent 63632b6012
commit 085f9c9baa
6 changed files with 91 additions and 28 deletions

View File

@ -257,18 +257,23 @@ void Debugger::refreshWatchVars()
}
}
void Debugger::deleteWatchVars(bool deleteparent)
void Debugger::removeWatchVars(bool deleteparent)
{
if (deleteparent) {
mWatchModel->clear();
} else {
for(PWatchVar var:mWatchModel->watchVars()) {
for(const PWatchVar& var:mWatchModel->watchVars()) {
sendRemoveWatchCommand(var);
invalidateWatchVar(var);
}
}
}
void Debugger::removeWatchVar(const QModelIndex &index)
{
mWatchModel->removeWatchVar(index);
}
void Debugger::invalidateAllVars()
{
mReader->setInvalidateAllVars(true);
@ -1067,7 +1072,7 @@ void DebugReader::processDebugOutput()
if (mInvalidateAllVars) {
//invalidate all vars when there's first output
mDebugger->deleteWatchVars(false);
mDebugger->removeWatchVars(false);
mInvalidateAllVars = false;
}
@ -1710,6 +1715,14 @@ void WatchModel::removeWatchVar(int gdbIndex)
}
}
void WatchModel::removeWatchVar(const QModelIndex &index)
{
int r=index.row();
this->beginRemoveRows(QModelIndex(),r,r);
mWatchVars.removeAt(r);
this->endRemoveRows();
}
void WatchModel::clear()
{
this->beginResetModel();

View File

@ -146,6 +146,7 @@ public:
void addWatchVar(PWatchVar watchVar);
void removeWatchVar(const QString& name);
void removeWatchVar(int gdbIndex);
void removeWatchVar(const QModelIndex& index);
void clear();
const QList<PWatchVar>& watchVars();
PWatchVar findWatchVar(const QString& name);
@ -191,7 +192,8 @@ public:
void renameWatchVar(const QString& oldname, const QString& newname);
void refreshWatchVars();
void deleteWatchVars(bool deleteparent);
void removeWatchVars(bool deleteparent);
void removeWatchVar(const QModelIndex& index);
void invalidateAllVars();
void sendAllWatchvarsToDebugger();
void invalidateWatchVar(const QString& name);

View File

@ -130,6 +130,8 @@ MainWindow::MainWindow(QWidget *parent)
connect(&mAutoSaveTimer, &QTimer::timeout,
this, &MainWindow::onAutoSaveTimeout);
resetAutoSaveTimer();
buildContextMenus();
}
MainWindow::~MainWindow()
@ -995,6 +997,15 @@ void MainWindow::doAutoSave(Editor *e)
e->saveFile(filename);
}
void MainWindow::buildContextMenus()
{
ui->watchView->setContextMenuPolicy(Qt::ActionsContextMenu);
ui->watchView->addAction(ui->actionAdd_Watch);
ui->watchView->addAction(ui->actionRemove_Watch);
ui->watchView->addAction(ui->actionRemove_All_Watches);
ui->watchView->addAction(ui->actionModify_Watch);
}
void MainWindow::onAutoSaveTimeout()
{
if (!pSettings->editor().enableAutoSave())
@ -1804,3 +1815,31 @@ void MainWindow::on_btnSearchAgin_clicked()
results->options);
}
}
void MainWindow::on_actionRemove_Watch_triggered()
{
QModelIndex index =ui->watchView->currentIndex();
QModelIndex parent;
while (true) {
parent = ui->watchView->model()->parent(index);
if (parent.isValid()) {
index=parent;
} else {
break;
}
}
mDebugger->removeWatchVar(index);
}
void MainWindow::on_actionRemove_All_Watches_triggered()
{
mDebugger->removeWatchVars(true);
}
void MainWindow::on_actionModify_Watch_triggered()
{
}

View File

@ -123,6 +123,7 @@ private:
void openCloseMessageSheet(bool open);
void prepareDebugger();
void doAutoSave(Editor *e);
void buildContextMenus();
private slots:
void onAutoSaveTimeout();
@ -223,6 +224,12 @@ private slots:
void on_cbSearchHistory_currentIndexChanged(int index);
void on_btnSearchAgin_clicked();
void on_actionRemove_Watch_triggered();
void on_actionRemove_All_Watches_triggered();
void on_actionModify_Watch_triggered();
private:
Ui::MainWindow *ui;
EditorList *mEditorList;

View File

@ -85,7 +85,7 @@
<enum>QTabWidget::West</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>2</number>
</property>
<property name="usesScrollButtons">
<bool>true</bool>
@ -1345,6 +1345,21 @@
<string>Shift+F3</string>
</property>
</action>
<action name="actionRemove_Watch">
<property name="text">
<string>Remove Watch</string>
</property>
</action>
<action name="actionRemove_All_Watches">
<property name="text">
<string>Remove All</string>
</property>
</action>
<action name="actionModify_Watch">
<property name="text">
<string>Modify Watch...</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -884,7 +884,7 @@ QLabel {
background-color: #19232D;
border: 0px solid #455364;
padding: 2px;
margin: 0px;
/* margin: 0px; */
color: #E0E1E3;
}
@ -1009,7 +1009,7 @@ QPushButton {
background-color: #455364;
color: #E0E1E3;
border-radius: 4px;
padding: 2px;
padding: 0.1em 0.5em 0.1em 0.5em;
outline: none;
border: none;
}
@ -1018,13 +1018,13 @@ QPushButton:disabled {
background-color: #455364;
color: #9DA9B5;
border-radius: 4px;
padding: 2px;
padding: 0.1em 0.5em 0.1em 0.5em;
}
QPushButton:checked {
background-color: #60798B;
border-radius: 4px;
padding: 2px;
padding: 0.1em 0.5em 0.1em 0.5em;
outline: none;
}
@ -1032,7 +1032,7 @@ QPushButton:checked:disabled {
background-color: #60798B;
color: #9DA9B5;
border-radius: 4px;
padding: 2px;
padding: 0.1em 0.5em 0.1em 0.5em;
outline: none;
}
@ -1479,11 +1479,10 @@ QTabBar, QDockWidget QTabBar {
qproperty-drawBase: 0;
border-radius: 4px;
margin: 0px;
padding: 2px;
border: 0;
/* left: 5px; move to the right by 5px - removed for fix */
}
QTabBar::close-button, QDockWidget QTabBar::close-button {
border: 0;
margin: 0;
@ -1575,10 +1574,7 @@ QTabBar::tab:right:!selected, QDockWidget QTabBar::tab:right:!selected {
QTabBar::tab:top, QDockWidget QTabBar::tab:top {
background-color: #455364;
margin-left: 2px;
padding-left: 4px;
padding-right: 4px;
padding-top: 2px;
padding-bottom: 2px;
padding: 0.1em 0.5em 0.1em 0.5em;
min-width: 5px;
border-bottom: 3px solid #455364;
border-top-left-radius: 4px;
@ -1604,10 +1600,7 @@ QTabBar::tab:bottom, QDockWidget QTabBar::tab:bottom {
border-top: 3px solid #455364;
background-color: #455364;
margin-left: 2px;
padding-left: 4px;
padding-right: 4px;
padding-top: 2px;
padding-bottom: 2px;
padding: 0.1em 0.5em 0.1em 0.5em;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
min-width: 5px;
@ -1631,10 +1624,7 @@ QTabBar::tab:bottom:!selected:hover, QDockWidget QTabBar::tab:bottom:!selected:h
QTabBar::tab:left, QDockWidget QTabBar::tab:left {
background-color: #455364;
margin-top: 2px;
padding-left: 2px;
padding-right: 2px;
padding-top: 4px;
padding-bottom: 4px;
padding: 0.5em 0.1em 0.5em 0.1em;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
min-height: 5px;
@ -1656,10 +1646,7 @@ QTabBar::tab:left:!selected:hover, QDockWidget QTabBar::tab:left:!selected:hover
QTabBar::tab:right, QDockWidget QTabBar::tab:right {
background-color: #455364;
margin-top: 2px;
padding-left: 2px;
padding-right: 2px;
padding-top: 4px;
padding-bottom: 4px;
padding: 0.5em 0.1em 0.5em 0.1em;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
min-height: 5px;