Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-client-windows
Commits
3a812d72
Commit
3a812d72
authored
Feb 28, 2020
by
Ming Rui Zhang
Browse files
callwidgets: ui high dpi adaptation
Change-Id: If298a3b9bcd0fd94e9b532e6a88c9486e60e79b5
parent
af00f1be
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
src/callwidget.cpp
View file @
3a812d72
...
...
@@ -103,6 +103,8 @@ CallWidget::CallWidget(QWidget* parent) :
if
(
settings
.
contains
(
SettingsKey
::
mainSplitterState
))
{
auto
splitterStates
=
settings
.
value
(
SettingsKey
::
mainSplitterState
).
toByteArray
();
ui
->
mainActivitySplitter
->
restoreState
(
splitterStates
);
splitterStates
=
settings
.
value
(
SettingsKey
::
smartListToWebviewSplitterState
).
toByteArray
();
ui
->
splitter
->
restoreState
(
splitterStates
);
}
ui
->
mainActivitySplitter
->
setCollapsible
(
0
,
false
);
...
...
@@ -139,6 +141,14 @@ CallWidget::CallWidget(QWidget* parent) :
settings
.
setValue
(
SettingsKey
::
mainSplitterState
,
ui
->
mainActivitySplitter
->
saveState
());
});
connect
(
ui
->
splitter
,
&
QSplitter
::
splitterMoved
,
[
this
](
int
pos
,
int
index
)
{
Q_UNUSED
(
index
);
Q_UNUSED
(
pos
);
QSettings
settings
(
"jami.net"
,
"Jami"
);
settings
.
setValue
(
SettingsKey
::
smartListToWebviewSplitterState
,
ui
->
splitter
->
saveState
());
});
connect
(
ui
->
btnConversations
,
&
QPushButton
::
clicked
,
this
,
&
CallWidget
::
conversationsButtonClicked
);
...
...
@@ -243,6 +253,9 @@ CallWidget::CallWidget(QWidget* parent) :
setVisible
(
false
);
ui
->
sipCallerBestIdLabel
->
setVisible
(
false
);
// set collapsible
ui
->
splitter
->
setCollapsible
(
ui
->
splitter
->
indexOf
(
ui
->
stackedWidget
),
false
);
}
CallWidget
::~
CallWidget
()
...
...
@@ -290,12 +303,6 @@ CallWidget::navigated(bool to)
void
CallWidget
::
updateCustomUI
()
{
auto
scalingRatio
=
Utils
::
getCurrentScalingRatio
();
if
(
scalingRatio
>
1.0
)
{
ui
->
messageView
->
setZoomFactor
(
1.15
);
}
else
{
ui
->
messageView
->
setZoomFactor
(
1.0
);
}
}
void
...
...
src/callwidget.ui
View file @
3a812d72
This diff is collapsed.
Click to expand it.
src/mainapplication.cpp
View file @
3a812d72
...
...
@@ -51,6 +51,9 @@ MainApplication::applicationInitialization()
QApplication
::
setOrganizationDomain
(
"jami.net"
);
QApplication
::
setAttribute
(
Qt
::
AA_EnableHighDpiScaling
,
true
);
QApplication
::
setAttribute
(
Qt
::
AA_UseHighDpiPixmaps
);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
QApplication
::
setHighDpiScaleFactorRoundingPolicy
(
Qt
::
HighDpiScaleFactorRoundingPolicy
::
RoundPreferFloor
);
#endif
}
void
...
...
src/mainwindow.cpp
View file @
3a812d72
...
...
@@ -49,6 +49,8 @@ MainWindow::MainWindow(QWidget* parent)
setWindowTitle
(
isBeta
?
"Jami (Beta)"
:
"Jami"
);
installEventFilter
(
this
);
for
(
int
i
=
0
;
i
<
ui
->
navStack
->
count
();
++
i
)
{
if
(
auto
navWidget
=
dynamic_cast
<
NavWidget
*>
(
ui
->
navStack
->
widget
(
i
)))
{
connect
(
navWidget
,
&
NavWidget
::
NavigationRequested
,
...
...
@@ -275,6 +277,11 @@ void MainWindow::showWindow()
activateWindow
();
}
raise
();
#if defined(Q_OS_WIN)
disconnect
(
screenChangedConnection_
);
screenChangedConnection_
=
connect
(
windowHandle
(),
&
QWindow
::
screenChanged
,
this
,
&
MainWindow
::
slotScreenChanged
);
#endif
}
void
...
...
@@ -359,14 +366,6 @@ void MainWindow::readSettingsFromRegistry()
void
MainWindow
::
setWindowSize
(
ScreenEnum
scr
,
bool
firstUse
)
{
auto
accountList
=
LRCInstance
::
accountModel
().
getAccountList
();
if
(
scr
==
ScreenEnum
::
WizardScreen
&&
!
accountList
.
size
())
{
hide
();
setFixedSize
(
wizardDialogWidth
,
wizardDialogHeight
);
}
else
{
setMinimumSize
(
mainWindowMinWidth
,
mainWindowMinHeight
);
setMaximumSize
(
QtMaxDimension
,
QtMaxDimension
);
}
if
(
firstUse
||
!
accountList
.
size
())
{
auto
screenNumber
=
qApp
->
desktop
()
->
screenNumber
();
if
(
scr
==
ScreenEnum
::
WizardScreen
)
{
...
...
@@ -388,30 +387,36 @@ void MainWindow::setWindowSize(ScreenEnum scr, bool firstUse)
}
}
void
MainWindow
::
show
()
{
QMainWindow
::
show
();
#if defined(Q_OS_WIN)
disconnect
(
screenChangedConnection_
);
screenChangedConnection_
=
connect
(
windowHandle
(),
&
QWindow
::
screenChanged
,
this
,
&
MainWindow
::
slotScreenChanged
);
#endif
}
void
MainWindow
::
slotScreenChanged
(
QScreen
*
screen
)
{
Utils
::
setCurrentScalingRatio
(
screen
->
logicalDotsPerInchX
()
/
96
);
qobject_cast
<
NavWidget
*>
(
ui
->
navStack
->
currentWidget
())
->
updateCustomUI
();
adjustSize
();
updateGeometry
();
if
(
Utils
::
getCurrentScalingRatio
()
>
1.0
)
{
isScreenChanged_
=
true
;
}
}
void
MainWindow
::
resizeEvent
(
QResizeEvent
*
event
)
{
Q_UNUSED
(
event
)
;
Q_UNUSED
(
event
)
qobject_cast
<
NavWidget
*>
(
ui
->
navStack
->
currentWidget
())
->
updateCustomUI
();
}
bool
MainWindow
::
eventFilter
(
QObject
*
watched
,
QEvent
*
event
)
{
Q_UNUSED
(
watched
)
if
(
event
->
type
()
==
QEvent
::
NonClientAreaMouseButtonRelease
)
{
if
(
isScreenChanged_
)
{
if
(
!
ui
->
callwidget
->
isVisible
())
resize
(
minimumSize
());
else
adjustSize
();
isScreenChanged_
=
false
;
}
}
return
false
;
}
void
MainWindow
::
keyReleaseEvent
(
QKeyEvent
*
ke
)
{
emit
keyReleased
(
ke
);
...
...
src/mainwindow.h
View file @
3a812d72
...
...
@@ -31,12 +31,6 @@
static
constexpr
char
IDM_ABOUTBOX
=
0x0010
;
static
constexpr
char
IDM_SHORTCUTSBOX
=
0x0011
;
static
constexpr
uint32_t
QtMaxDimension
=
16777215
;
static
constexpr
uint32_t
mainWindowMinWidth
=
1088
;
static
constexpr
uint32_t
mainWindowMinHeight
=
638
;
static
constexpr
uint32_t
wizardDialogWidth
=
512
;
static
constexpr
uint32_t
wizardDialogHeight
=
638
;
namespace
Ui
{
class
MainWindow
;
}
...
...
@@ -51,7 +45,6 @@ public:
return
*
instance
;
}
bool
init
();
void
show
();
void
showWindow
();
void
darken
();
void
lighten
();
...
...
@@ -59,6 +52,7 @@ public:
protected:
bool
nativeEvent
(
const
QByteArray
&
eventType
,
void
*
message
,
long
*
result
)
override
;
void
closeEvent
(
QCloseEvent
*
event
)
override
;
bool
eventFilter
(
QObject
*
watched
,
QEvent
*
event
);
void
resizeEvent
(
QResizeEvent
*
event
)
override
;
void
keyReleaseEvent
(
QKeyEvent
*
ke
)
override
;
void
changeEvent
(
QEvent
*
e
)
override
;
...
...
@@ -91,6 +85,8 @@ private:
void
readSettingsFromRegistry
();
bool
isScreenChanged_
{
false
};
QAction
*
settingsAction_
;
QAction
*
exitAction_
;
QAction
*
keyboardShortcutsAction_
;
...
...
src/mainwindow.ui
View file @
3a812d72
...
...
@@ -440,7 +440,7 @@
</property>
<widget
class=
"QWidget"
name=
"centralWidget"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"
MinimumExpanding"
vsizetype=
"MinimumExpanding
"
>
<sizepolicy
hsizetype=
"
Preferred"
vsizetype=
"Preferred
"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
...
...
@@ -467,7 +467,7 @@
<widget
class=
"CallWidget"
name=
"callwidget"
/>
<widget
class=
"SettingsWidget"
name=
"settingswidget"
>
<property
name=
"sizePolicy"
>
<sizepolicy
hsizetype=
"
MinimumExpanding"
vsizetype=
"MinimumExpanding
"
>
<sizepolicy
hsizetype=
"
Preferred"
vsizetype=
"Preferred
"
>
<horstretch>
0
</horstretch>
<verstretch>
0
</verstretch>
</sizepolicy>
...
...
src/settingskey.h
View file @
3a812d72
...
...
@@ -26,6 +26,7 @@ constexpr static char enableNotifications[] = "enableNotifications";
constexpr
static
char
geometry
[]
=
"geometry"
;
constexpr
static
char
selectedAccount
[]
=
"selectedAccount"
;
constexpr
static
char
mainSplitterState
[]
=
"mainSplitterState"
;
constexpr
static
char
smartListToWebviewSplitterState
[]
=
"smartListToWebviewSplitterState"
;
constexpr
static
char
windowState
[]
=
"windowState"
;
constexpr
static
char
autoUpdate
[]
=
"autoUpdate"
;
constexpr
static
char
neverShowMeAgain
[]
=
"neverShowMeAgain"
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment