- fix: left and bottom panel size not correct when DPI changed
This commit is contained in:
parent
7cc5cf4f45
commit
63b277d843
1
NEWS.md
1
NEWS.md
|
@ -19,6 +19,7 @@ Red Panda C++ Version 0.14.3
|
|||
- enhancement: when add files to project, auto add it to git (if the project has a git repository)
|
||||
- enhancement: when save a file, and it's under files view's current folder, auto add it to git (if it has a git repository)
|
||||
- enhancement: new file icons for high contrast icon set
|
||||
- fix: left and bottom panel size not correct when DPI changed
|
||||
|
||||
|
||||
Red Panda C++ Version 0.14.2
|
||||
|
|
|
@ -61,10 +61,15 @@ bool WindowLogoutEventFilter::nativeEventFilter(const QByteArray & /*eventType*/
|
|||
return true;
|
||||
}
|
||||
break;
|
||||
case WM_DPICHANGED:
|
||||
case WM_DPICHANGED:{
|
||||
int oldDPI = screenDPI();
|
||||
QEvent * dpiEvent = new QEvent(DPI_CHANGED_EVENT);
|
||||
qApp->postEvent(pMainWindow,dpiEvent);
|
||||
setScreenDPI(HIWORD(pMsg->wParam));
|
||||
pMainWindow->updateDPI();
|
||||
int newDPI = screenDPI();
|
||||
pMainWindow->updateDPI(oldDPI,newDPI);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -742,9 +742,13 @@ void MainWindow::setActiveBreakpoint(QString FileName, int Line, bool setFocus)
|
|||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateDPI()
|
||||
void MainWindow::updateDPI(int oldDPI, int newDPI)
|
||||
{
|
||||
applySettings();
|
||||
if (oldDPI<1)
|
||||
oldDPI = 1;
|
||||
mBottomPanelHeight = mBottomPanelHeight * newDPI / oldDPI ;
|
||||
mLeftPanelWidth = mLeftPanelWidth * newDPI / oldDPI ;
|
||||
}
|
||||
|
||||
void MainWindow::onFileSaved(const QString &path, bool inProject)
|
||||
|
@ -1837,6 +1841,8 @@ void MainWindow::openCloseBottomPanel(bool open)
|
|||
QList<int> sizes = ui->splitterMessages->sizes();
|
||||
int tabHeight = ui->tabMessages->tabBar()->height();
|
||||
ui->tabMessages->setMinimumHeight(tabHeight+5);
|
||||
if ( mBottomPanelHeight < ui->tabMessages->tabBar()->height() + 5)
|
||||
mBottomPanelHeight = ui->tabMessages->tabBar()->height() + 5;
|
||||
int totalSize = sizes[0] + sizes[1];
|
||||
sizes[1] = mBottomPanelHeight;
|
||||
sizes[0] = std::max(1,totalSize - sizes[1]);
|
||||
|
@ -1853,7 +1859,7 @@ void MainWindow::openCloseBottomPanel(bool open)
|
|||
}
|
||||
mBottomPanelOpenned = open;
|
||||
QSplitterHandle* handle = ui->splitterMessages->handle(1);
|
||||
handle->setEnabled(open);
|
||||
handle->setEnabled(mBottomPanelOpenned);
|
||||
}
|
||||
|
||||
void MainWindow::openCloseLeftPanel(bool open)
|
||||
|
@ -1865,10 +1871,12 @@ void MainWindow::openCloseLeftPanel(bool open)
|
|||
mOpenClosingLeftPanel = false;
|
||||
});
|
||||
// Switch between open and close
|
||||
if (open) {
|
||||
if (open ) {
|
||||
QList<int> sizes = ui->splitterInfos->sizes();
|
||||
int tabWidth = ui->tabInfos->tabBar()->width();
|
||||
ui->tabInfos->setMinimumWidth(tabWidth+5);
|
||||
if (mLeftPanelWidth < ui->tabInfos->tabBar()->width() + 5)
|
||||
mLeftPanelWidth = ui->tabInfos->tabBar()->width() + 5;
|
||||
int totalSize = sizes[0] + sizes[1];
|
||||
sizes[0] = mLeftPanelWidth;
|
||||
sizes[1] = std::max(1,totalSize - sizes[0]);
|
||||
|
@ -1885,7 +1893,7 @@ void MainWindow::openCloseLeftPanel(bool open)
|
|||
}
|
||||
mLeftPanelOpenned = open;
|
||||
QSplitterHandle* handle = ui->splitterInfos->handle(1);
|
||||
handle->setEnabled(open);
|
||||
handle->setEnabled(mLeftPanelOpenned);
|
||||
}
|
||||
|
||||
void MainWindow::prepareDebugger()
|
||||
|
@ -4080,6 +4088,21 @@ void MainWindow::hideEvent(QHideEvent *)
|
|||
settings.setLeftPanelWidth(mLeftPanelWidth);
|
||||
}
|
||||
|
||||
bool MainWindow::event(QEvent *event)
|
||||
{
|
||||
if (event->type()==DPI_CHANGED_EVENT) {
|
||||
int saveHeight = mBottomPanelHeight ;
|
||||
int saveWidth = mLeftPanelWidth;
|
||||
openCloseBottomPanel(mBottomPanelOpenned);
|
||||
openCloseLeftPanel(mLeftPanelOpenned);
|
||||
mBottomPanelHeight = saveHeight;
|
||||
mLeftPanelWidth = saveWidth;
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
return QMainWindow::event(event);
|
||||
}
|
||||
|
||||
//void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
||||
//{
|
||||
// if (event->mimeData()->hasUrls()){
|
||||
|
|
|
@ -68,6 +68,8 @@ class SearchDialog;
|
|||
class Project;
|
||||
class ColorSchemeItem;
|
||||
|
||||
#define DPI_CHANGED_EVENT ((QEvent::Type)(QEvent::User+1))
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -217,7 +219,7 @@ public slots:
|
|||
void onTodoParsing(const QString& filename, int lineNo, int ch, const QString& line);
|
||||
void onTodoParseFinished();
|
||||
void setActiveBreakpoint(QString FileName, int Line, bool setFocus);
|
||||
void updateDPI();
|
||||
void updateDPI(int oldDPI, int newDPI);
|
||||
void onFileSaved(const QString& path, bool inProject);
|
||||
|
||||
private:
|
||||
|
@ -727,6 +729,10 @@ protected:
|
|||
void showEvent(QShowEvent* event) override;
|
||||
void hideEvent(QHideEvent *event) override;
|
||||
|
||||
|
||||
// QObject interface
|
||||
public:
|
||||
bool event(QEvent *event) override;
|
||||
};
|
||||
|
||||
extern MainWindow* pMainWindow;
|
||||
|
|
Loading…
Reference in New Issue