Skip to content

Commit

Permalink
- enhancement: Auto scale the main ui & choose theme dialog at the fi…
Browse files Browse the repository at this point in the history
…rst run.
  • Loading branch information
royqh1979 committed Dec 1, 2024
1 parent 1fe0062 commit 770f048
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Red Panda C++ Version 3.3
- enhancement: Auto indent contents in parenthesis.
- fix: Use "/" instead of "\" in the path of compile target.
- fix: crash when debug.
- fix: Qt 6 version crashed when debug.
- enhancement: Auto scale the main ui & choose theme dialog at the first run.

Red Panda C++ Version 3.2

Expand Down
11 changes: 11 additions & 0 deletions RedPandaIDE/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,17 @@ void MainWindow::applyUISettings()
ui->tabMessages->setShrinkedFlag(true);
if (settings.shrinkExplorerTabs())
ui->tabExplorer->setShrinkedFlag(true);
#if defined(Q_OS_WIN) && QT_VERSION_MAJOR == 5
if (settings.mainWindowGeometry().isEmpty()) {
//first run, adjust size with dpi
int w = width()*screenDPI()/96;
int h = height()*screenDPI()/96;
resize(w,h);
ui->tabMessages->setBeforeShrinkSize(settings.messagesTabsSize()*screenDPI()/96);
ui->tabExplorer->setBeforeShrinkSize(settings.explorerTabsSize()*screenDPI()/96);
}

#endif
}

QFileSystemWatcher *MainWindow::fileSystemWatcher()
Expand Down
22 changes: 22 additions & 0 deletions RedPandaIDE/widgets/choosethemedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,33 @@
#include "choosethemedialog.h"
#include "ui_choosethemedialog.h"

#include <QFontMetrics>
#include <QScreen>

ChooseThemeDialog::ChooseThemeDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ChooseThemeDialog)
{
ui->setupUi(this);
#if defined(Q_OS_WIN) && QT_VERSION_MAJOR == 5
//first run, adjust size with dpi
int dpi = qApp->primaryScreen()->logicalDotsPerInch();
// int w = width()*dpi/96;
// int h = height()*dpi/96;
// ui->lblDark
double dpr = 96.0 / qApp->primaryScreen()->logicalDotsPerInch();
QPixmap p = ui->lblLight->pixmap(Qt::ReturnByValue);
p.setDevicePixelRatio(dpr);
ui->lblLight->setPixmap(p);
p = ui->lblDark->pixmap(Qt::ReturnByValue);
p.setDevicePixelRatio(dpr);
ui->lblDark->setPixmap(p);
QFontMetrics fm{font()};
QFont f{font()};

f.setPixelSize(fm.height()*dpi/96);
setFont(f);
#endif
#ifdef ENABLE_LUA_ADDON
ui->rbAuto->setVisible(true);
#else
Expand Down
4 changes: 2 additions & 2 deletions RedPandaIDE/widgets/choosethemedialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="1">
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="lblLight">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
Expand All @@ -37,7 +37,7 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<widget class="QLabel" name="lblDark">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
Expand Down

0 comments on commit 770f048

Please sign in to comment.