Skip to content
Snippets Groups Projects
Commit 0a4276b2 authored by Ming Rui Zhang's avatar Ming Rui Zhang
Browse files

qml: add keyboard shortcuts table on system menu

Change-Id: Ie5cc1d351672a86164fb203d6b86afd3ea92fed4
parent bc02dc37
Branches
No related tags found
No related merge requests found
......@@ -39,18 +39,18 @@ $FilesToCopy = @(
"$daemonDir\contrib\build\openssl\out32dll\libeay32.dll",
"$daemonDir\contrib\build\openssl\out32dll\ssleay32.dll",
"$ClientDir\qt.conf",
"$ClientDir\images\jami.ico"
"$ClientDir\images\jami.ico",
"$ClientDir\License.rtf"
)
foreach ($i in $FilesToCopy) {
write-host "copying: " $i " => " $OutDir -ForegroundColor Cyan
Copy-Item -Path $i -Destination $OutDir -Force
Copy-Item -Path $i -Recurse -Destination $OutDir -Force -Container
}
############
# qt
############
$windeployqt = "$QtDir\bin\windeployqt.exe $OutDir\Jami.exe"
$windeployqt = "$QtDir\bin\windeployqt.exe --qmldir $ClientDir\src --release $OutDir\Jami.exe"
iex $windeployqt
# ringtones
......
......@@ -66,6 +66,9 @@ win32-msvc {
QMAKE_LIBDIR=$(QTDIR)\lib
QMAKE_MOC=$(QTDIR)\bin\moc.exe
QMAKE_QMAKE=$(QTDIR)\bin\qmake.exe
# exe icons
Release: RC_FILE = ico.rc
}
unix {
......@@ -264,4 +267,5 @@ FORMS += ./src/aboutdialog.ui \
./src/popupdialog.ui \
./src/recordoverlay.ui \
./src/recordwidget.ui
RESOURCES += ressources.qrc
RESOURCES += ./ressources.qrc \
./qml.qrc
<RCC>
<qresource prefix="/">
<file>src/KeyBoardShortcutTable.qml</file>
<file>src/KeyBoardShortcutKey.qml</file>
</qresource>
</RCC>
import QtQuick 2.9
import QtQuick.Controls 2.2
Item {
property alias text: shortcutText.text
Rectangle{
id: keyRect
width: t_metrics.tightBoundingRect.width + 10
height: t_metrics.tightBoundingRect.height + 10
color: "#525252"
radius: 5
anchors.centerIn: parent
Text {
id : shortcutText
anchors.centerIn: parent
anchors.leftMargin: 10
font.family: "Arial"
font.pixelSize: 20
color: "white"
}
TextMetrics {
id: t_metrics
font: shortcutText.font
text: shortcutText.text
}
}
}
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.4
import QtQuick.Layouts 1.3
Rectangle {
id: rectangle
property int minWidth: 1002
property int minHeight: 500
implicitWidth: minWidth
implicitHeight: minHeight
color: "white"
radius: 30
Rectangle {
width: 500
height: t_metrics_title.tightBoundingRect.height + 15
color: "#e0e0e0"
radius: 8
anchors.top: parent.top
anchors.topMargin: 10
anchors.horizontalCenter: parent.horizontalCenter
Text {
id : titleText
anchors.centerIn: parent
anchors.leftMargin: 10
font.family: "Arial"
font.pixelSize: 20
font.bold: true
text: "Shortcuts"
color: "black"
}
TextMetrics {
id: t_metrics_title
font: titleText.font
text: titleText.text
}
}
ListModel {
id: keyboardGeneralShortcutsModel
ListElement {
Shortcut: "Ctrl+J"
Description: "Open account list"
KeyLength: 2
}
ListElement {
Shortcut: "Ctrl+L"
Description: "Focus on the smart list"
KeyLength: 2
}
ListElement {
Shortcut: "Ctrl+↑"
Description: "Focus the previous element on smart list"
KeyLength: 2
}
ListElement {
Shortcut: "Ctrl+↓"
Description: "Focus the next element on smart list"
KeyLength: 2
}
ListElement {
Shortcut: "Ctrl+F"
Description: "Focus on contact search bar"
KeyLength: 2
}
ListElement {
Shortcut: "F10"
Description: "Open keyboard shortcuts table"
KeyLength: 1
}
ListElement {
Shortcut: "F11"
Description: "Maximize Screen"
KeyLength: 1
}
}
ListModel {
id: keyboardConversationShortcutsModel;
ListElement {
Shortcut: "Shift+Ctrl+C";
Description: "Start an audio call";
KeyLength: 3
}
ListElement {
Shortcut: "Shift+Ctrl+X";
Description: "Start an video call";
KeyLength: 3
}
ListElement {
Shortcut: "Shift+Ctrl+L";
Description: "Clear history";
KeyLength: 3
}
ListElement {
Shortcut: "Shift+Ctrl+B";
Description: "Block contact";
KeyLength: 3
}
ListElement {
Shortcut: "Shift+Ctrl+J";
Description: "Copy contact name";
KeyLength: 3
}
}
ListModel {
id: keyboardSettingsShortcutsModel;
ListElement {
Shortcut: "Ctrl+M";
Description: "Toggle media settings";
KeyLength: 2
}
ListElement {
Shortcut: "Ctrl+G";
Description: "Toggle general settings";
KeyLength: 2
}
ListElement {
Shortcut: "Ctrl+I";
Description: "Toggle account settings";
KeyLength: 2
}
}
ListModel {
id: keyboardCallsShortcutsModel
ListElement {
Shortcut: "Ctrl+Y"
Description: "Answer an incoming call"
KeyLength: 2
}
ListElement {
Shortcut: "Ctrl+D"
Description: "Decline the call"
KeyLength: 2
}
}
Component {
/*trike: each table should have there own delegate, in order to make sure that
* the model parameter is used correctly, but since other three table are
* generally the same, so we used the same one
*/
id: shortcutDelegate
Rectangle {
id: cellRect
implicitWidth: minWidth /2
implicitHeight: 50
anchors.left: parent.left
anchors.leftMargin: 50
color: "white"
border.color: "white"
Rectangle {
id: containerRect
implicitWidth: parent.width / 2
implicitHeight: 50
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
Component.onCompleted: {
// Create components at run time using javascript
var componentKeyOne = Qt.createComponent("KeyBoardShortcutKey.qml")
if (componentKeyOne.status === Component.Ready) {
var objectKeyOne = componentKeyOne.createObject(containerRect)
objectKeyOne.anchors.verticalCenter = containerRect.verticalCenter
objectKeyOne.anchors.left = containerRect.left
objectKeyOne.text = Qt.binding(function() { return styleData.value.split("+")[0] })
}
if (generalTableView.model.get(styleData.row).KeyLength === 2){
var componentPlusSign = Qt.createQmlObject('import QtQuick 2.0;' +
'Text {anchors.verticalCenter: containerRect.verticalCenter;' +
'anchors.verticalCenterOffset: -2;' +
'anchors.left: containerRect.left;' +
'anchors.leftMargin: 30;' +
'color: "#525252";' +
'font.bold: true;' +
'font.pixelSize : 20;' +
'text: "+"}',
containerRect)
var componentKeyTwo = Qt.createComponent("KeyBoardShortcutKey.qml")
if (componentKeyTwo.status === Component.Ready) {
var objectKeyTwo = componentKeyTwo.createObject(containerRect)
objectKeyTwo.anchors.verticalCenter = containerRect.verticalCenter
objectKeyTwo.anchors.left = containerRect.left
objectKeyTwo.anchors.leftMargin = componentPlusSign.anchors.leftMargin + 40
objectKeyTwo.text = Qt.binding(function() { return styleData.value.split("+")[1] })
}
}
}
}
}
}
Component {
id: shortcutDelegateWithThreeKeys
Rectangle {
id: cellRectWithThreeKeys
implicitWidth: minWidth /2
implicitHeight: 50
anchors.left: parent.left
anchors.leftMargin: 50
color: "white"
border.color: "white"
Rectangle {
id: containerRectWithThreeKeys
implicitWidth: parent.width - 10
implicitHeight: 50
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
Component.onCompleted: {
var componentKeyOne = Qt.createComponent("KeyBoardShortcutKey.qml")
if (componentKeyOne.status === Component.Ready) {
var objectKeyOne = componentKeyOne.createObject(containerRectWithThreeKeys)
objectKeyOne.anchors.verticalCenter = containerRectWithThreeKeys.verticalCenter
objectKeyOne.anchors.left = containerRectWithThreeKeys.left
objectKeyOne.text = Qt.binding(function() { return modelData.Shortcut.split("+")[0] })
}
var componentPlusSign = Qt.createQmlObject('import QtQuick 2.0;' +
'Text {anchors.verticalCenter: containerRectWithThreeKeys.verticalCenter;' +
'anchors.verticalCenterOffset: -2;' +
'anchors.left: containerRectWithThreeKeys.left;' +
'anchors.leftMargin: 30;' +
'color: "#525252";' +
'font.bold: true;' +
'font.pixelSize : 20;' +
'text: "+"}',
containerRectWithThreeKeys)
var componentKeyTwo = Qt.createComponent("KeyBoardShortcutKey.qml")
if (componentKeyTwo.status === Component.Ready) {
var objectKeyTwo = componentKeyTwo.createObject(containerRectWithThreeKeys)
objectKeyTwo.anchors.verticalCenter = containerRectWithThreeKeys.verticalCenter
objectKeyTwo.anchors.left = containerRectWithThreeKeys.left
objectKeyTwo.anchors.leftMargin = componentPlusSign.anchors.leftMargin + 42
objectKeyTwo.text = Qt.binding(function() { return modelData.Shortcut.split("+")[1] })
}
var componentPlusSignTwo = Qt.createQmlObject('import QtQuick 2.0;' +
'Text {anchors.verticalCenter: containerRectWithThreeKeys.verticalCenter;' +
'anchors.verticalCenterOffset: -2;' +
'anchors.left: containerRectWithThreeKeys.left;' +
'anchors.leftMargin: 97;' +
'color: "#525252";' +
'font.bold: true;' +
'font.pixelSize : 20;' +
'text: "+"}',
containerRectWithThreeKeys)
var componentKeyThree = Qt.createComponent("KeyBoardShortcutKey.qml")
if (componentKeyThree.status === Component.Ready) {
var objectKeyThree = componentKeyThree.createObject(containerRectWithThreeKeys)
objectKeyThree.anchors.verticalCenter = containerRectWithThreeKeys.verticalCenter
objectKeyThree.anchors.left = containerRectWithThreeKeys.left
objectKeyThree.anchors.leftMargin = componentPlusSignTwo.anchors.leftMargin + 35
objectKeyThree.text = Qt.binding(function() { return modelData.Shortcut.split("+")[2] })
}
}
}
}
}
Component {
id: descriptionDelegate;
Rectangle {
implicitWidth: minWidth /2;
implicitHeight: 50;
color: "white";
border.color: "white";
Text {
id : descriptionText;
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 10;
font.family: "Arial";
font.pixelSize: 15;
text: styleData.value;
}
}
}
Column {
spacing: 2
id: columnAll
anchors.rightMargin: 20
anchors.leftMargin: 20
anchors.bottomMargin: 20
anchors.topMargin: 50
width: minWidth
height: minHeight - 100
anchors.fill: parent
StackLayout {
// pages
implicitWidth: parent.width
implicitHeight: parent.height - tabBar.height
currentIndex: tabBar.currentIndex
Item {
id: tabOne
Rectangle {
implicitWidth: parent.width / 2
implicitHeight: parent.height
anchors.left: parent.left
TableView {
id: generalTableView
anchors.fill: parent
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
TableViewColumn {
role: "Description"
width: generalTableView.width / 2
delegate: descriptionDelegate
}
TableViewColumn {
role: "Shortcut"
width: generalTableView.width / 2
delegate: shortcutDelegate
}
model: keyboardGeneralShortcutsModel
rowDelegate: Rectangle {
height: 50
color: "white"
}
style: TableViewStyle {
alternateBackgroundColor: "white"
frame: Rectangle {
border{
color: "transparent" // color of the border
}
}
headerDelegate: Rectangle {
// Only first column's header is shown
height: [t_metrics_general.tightBoundingRect.height + 10, 0][styleData.column % 2]
width: [parent.width, 0][styleData.column % 2]
color: "white"
radius: 10
anchors.top: parent.top
anchors.topMargin: 5
Text {
id : generalShortcutText
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 10
font.family: "Arial"
font.pixelSize: 20
text: styleData.column % 2 ? "" : "General"
color: "black"
}
TextMetrics {
id: t_metrics_general
font: generalShortcutText.font
text: generalShortcutText.text
}
}
}
}
}
Rectangle {
implicitWidth: parent.width / 2
implicitHeight: parent.height
anchors.right: parent.right
TableView {
id: conversationsTableView
anchors.fill: parent
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
TableViewColumn {
role: "Description"
width: conversationsTableView.width / 2
delegate: descriptionDelegate
}
TableViewColumn {
role: "Shortcut"
width: conversationsTableView.width / 2
delegate: Component{
Loader {
property variant modelData: model
sourceComponent: shortcutDelegateWithThreeKeys
}
}
}
model: keyboardConversationShortcutsModel
rowDelegate: Rectangle {
height: 50
color: "white"
}
style: TableViewStyle {
alternateBackgroundColor: "white"
frame: Rectangle {
border{
color: "transparent" // color of the border
}
}
headerDelegate: Rectangle {
// Only first column's header is shown
height: [t_metrics_conversations.tightBoundingRect.height + 10, 0][styleData.column % 2]
width: [parent.width, 0][styleData.column % 2]
color: "white"
radius: 10
anchors.top: parent.top
anchors.topMargin: 5
Text {
id : conversationsShortcutText
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 10
font.family: "Arial"
font.pixelSize: 20
text: styleData.column % 2 ? "" : "Conversations"
color: "black"
}
TextMetrics {
id: t_metrics_conversations
font: conversationsShortcutText.font
text: conversationsShortcutText.text
}
}
}
}
}
}
Item {
id: tabTwo
Rectangle {
implicitWidth: parent.width / 2
implicitHeight: parent.height
anchors.left: parent.left
TableView {
id: callsTableView
anchors.fill: parent
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
TableViewColumn {
role: "Description"
width: callsTableView.width / 2
delegate: descriptionDelegate
}
TableViewColumn {
role: "Shortcut"
width: callsTableView.width / 2
delegate: shortcutDelegate
}
model: keyboardCallsShortcutsModel
rowDelegate: Rectangle {
height: 50
color: "white"
}
style: TableViewStyle {
alternateBackgroundColor: "white"
frame: Rectangle {
border{
color: "transparent" // color of the border
}
}
headerDelegate: Rectangle {
// Only first column's header is shown
height: [t_metrics_calls.tightBoundingRect.height + 10, 0][styleData.column % 2]
width: [parent.width, 0][styleData.column % 2]
color: "white"
radius: 10
anchors.top: parent.top
anchors.topMargin: 5
Text {
id : callsShortcutText
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 10
font.family: "Arial"
font.pixelSize: 20
text: styleData.column % 2 ? "" : "Calls"
color: "black"
}
TextMetrics {
id: t_metrics_calls
font: callsShortcutText.font
text: callsShortcutText.text
}
}
}
}
}
Rectangle {
implicitWidth: parent.width / 2
implicitHeight: parent.height
anchors.right: parent.right
TableView {
id: settingsTableView
anchors.fill: parent
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
TableViewColumn {
role: "Description"
width: settingsTableView.width / 2
delegate: descriptionDelegate
}
TableViewColumn {
role: "Shortcut"
width: settingsTableView.width / 2
delegate: shortcutDelegate
}
model: keyboardSettingsShortcutsModel
rowDelegate: Rectangle {
height: 50
color: "white"
}
style: TableViewStyle {
alternateBackgroundColor: "white"
frame: Rectangle {
border{
color: "transparent" // color of the border
}
}
headerDelegate: Rectangle {
// Only first column's header is shown
height: [t_metrics_settings.tightBoundingRect.height + 10, 0][styleData.column % 2]
width: [parent.width, 0][styleData.column % 2]
color: "white"
radius: 10
anchors.top: parent.top
anchors.topMargin: 5
Text {
id : settingsShortcutText
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 10
font.family: "Arial"
font.pixelSize: 20
text: styleData.column % 2 ? "" : "Settings"
color: "black"
}
TextMetrics {
id: t_metrics_settings
font: settingsShortcutText.font
text: settingsShortcutText.text
}
}
}
}
}
}
}
}
TabBar {
id: tabBar
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: 15
width: 240
currentIndex: 0
TabButton {
id: pageOne
width: tabBar.width / 2
text: qsTr("1")
down: true
// customize tab button
contentItem: Text {
text: pageOne.text
font: pageOne.font
opacity: enabled ? 1.0 : 0.3
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
// customize tab button
background: Rectangle {
id: buttonRectOne
implicitWidth: tabBar.width / 2
implicitHeight: tabBar.height
radius: 10
color: pageOne.down ? "#e0e0e0" :"#fdfdfd"
MouseArea {
anchors.fill: parent;
hoverEnabled: true;
onPressed: { buttonRectOne.color = "#c0c0c0"; tabBar.currentIndex = 0; pageOne.down = true; pageTwo.down = false;}
onReleased: { buttonRectOne.color = "#e0e0e0"; }
onEntered: { buttonRectOne.color = "#c7c7c7"; }
onExited: { buttonRectOne.color = Qt.binding(function() { return pageOne.down ? "#e0e0e0" :"#fdfdfd" }); }
}
}
}
TabButton {
id: pageTwo
text: qsTr("2")
width: tabBar.width / 2
contentItem: Text {
text: pageTwo.text
font: pageTwo.font
opacity: enabled ? 1.0 : 0.3
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
background: Rectangle {
id: buttonRectTwo
implicitWidth: tabBar.width / 2
implicitHeight: tabBar.height
radius: 10
color: pageTwo.down ? "#e0e0e0" :"#fdfdfd"
MouseArea {
anchors.fill: parent;
hoverEnabled: true;
onPressed: { buttonRectTwo.color = "#c0c0c0"; tabBar.currentIndex = 1; pageTwo.down = true; pageOne.down = false;}
onReleased: { buttonRectTwo.color = "#e0e0e0"; }
onEntered: { buttonRectTwo.color = "#c7c7c7"; }
onExited: { buttonRectTwo.color = Qt.binding(function() { return pageTwo.down ? "#e0e0e0" :"#fdfdfd" }); }
}
}
}
}
}
......@@ -1509,6 +1509,7 @@ CallWidget::registerShortCuts()
auto focusOnContactSearchBarSC = new QShortcut(QKeySequence(tr("Ctrl+F", "Focus on contact search bar")), this);
auto answerCallSC = new QShortcut(QKeySequence(tr("Ctrl+Y", "Answer an incoming call")), this);
auto declineCallSC = new QShortcut(QKeySequence(tr("Ctrl+D", "Decline the call")), this);
auto shortcutsTableSC = new QShortcut(QKeySequence(tr("F10", "Show keyboard shortcuts table")), this);
auto maximizeScreenSC = new QShortcut(QKeySequence(tr("F11", "Maximize Screen")), this);
auto navigateToMediaSettingsSC = new QShortcut(QKeySequence(tr("Ctrl+M", "Navigate to media setting")), this);
......@@ -1633,6 +1634,18 @@ CallWidget::registerShortCuts()
}
});
connect(shortcutsTableSC, &QShortcut::activated,
[this] {
QUrl qmlSource{ QStringLiteral("qrc:/src/KeyBoardShortcutTable.qml") };
QmlPopupWidget* qmlKeyboardShortcuts = new QmlPopupWidget(qmlSource, qobject_cast<MainWindow*>(parent()->parent()->parent()));
qmlKeyboardShortcuts->setWindowFlags(Qt::Widget | Qt::FramelessWindowHint);
qmlKeyboardShortcuts->setAttribute(Qt::WA_AlwaysStackOnTop);
qmlKeyboardShortcuts->setClearColor(Qt::transparent);
qmlKeyboardShortcuts->setMinimumWidth(qmlKeyboardShortcuts->rootObject()->property("minWidth").toInt());
qmlKeyboardShortcuts->setMinimumHeight(qmlKeyboardShortcuts->rootObject()->property("minHeight").toInt());
qmlKeyboardShortcuts->getContainer()->exec();
});
connect(navigateToMediaSettingsSC, &QShortcut::activated,
[this] {
emit NavigationSettingsPageRequested(SettingsMenu::Media);
......
......@@ -296,6 +296,10 @@ main(int argc, char* argv[])
QObject::connect(&a, &QApplication::aboutToQuit, [&guard] { exitApp(guard); });
// for deployment only
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/src/KeyBoardShortcutTable.qml")));
auto ret = a.exec();
#ifdef Q_OS_WIN
......
......@@ -123,6 +123,17 @@ MainWindow::MainWindow(QWidget* parent)
}
});
keyboardShortcutsAction_ = new QAction(tr("Shortcuts"), this);
connect(keyboardShortcutsAction_, &QAction::triggered,
[this]() {
showWindow();
// has to put a single shot here, otherwise, the dialog will not show
QTimer::singleShot(0,
[this]{
generateQmlDialog(qmlKeyBoardShortcutTable_);
});
});
exitAction_ = new QAction(tr("Exit"), this);
connect(exitAction_, &QAction::triggered,
[this]() { QCoreApplication::exit(); });
......@@ -146,6 +157,8 @@ MainWindow::MainWindow(QWidget* parent)
::AppendMenuA(sysMenu, MF_SEPARATOR, 0, 0);
QString aboutTitle = tr("About");
::AppendMenuW(sysMenu, MF_STRING, IDM_ABOUTBOX, aboutTitle.toStdWString().c_str());
QString keyboardShortcutTitle = tr("Shortcuts");
::AppendMenuW(sysMenu, MF_STRING, IDM_SHORTCUTSBOX, keyboardShortcutTitle.toStdWString().c_str());
}
// check for updates and start automatic update check if needed
......@@ -226,12 +239,16 @@ bool MainWindow::nativeEvent(const QByteArray& eventType, void* message, long* r
MSG* msg = (MSG*)message;
if (msg->message == WM_SYSCOMMAND) {
if ((msg->wParam & 0xfff0) == IDM_ABOUTBOX) {
if (msg->wParam == IDM_ABOUTBOX) {
*result = 0;
AboutDialog aboutDialog(this);
aboutDialog.getContainer()->exec();
return true;
}
if (msg->wParam == IDM_SHORTCUTSBOX) {
generateQmlDialog(qmlKeyBoardShortcutTable_);
return true;
}
}
#else
Q_UNUSED(message)
......@@ -413,6 +430,7 @@ void MainWindow::slotAccountListChanged()
systrayMenu->clear();
if (LRCInstance::accountModel().getAccountList().size()) {
systrayMenu->addAction(settingsAction_);
systrayMenu->addAction(keyboardShortcutsAction_);
systrayMenu->addAction(exitAction_);
} else {
systrayMenu->addAction(exitAction_);
......@@ -423,3 +441,17 @@ void MainWindow::slotAccountListChanged()
}
}
}
void
MainWindow::generateQmlDialog(const QUrl& qmlSource)
{
QScopedPointer<QmlPopupWidget> qmlKeyboardShortcuts (new QmlPopupWidget(qmlSource, this));
qmlKeyboardShortcuts->setWindowFlags(Qt::Widget | Qt::FramelessWindowHint);
qmlKeyboardShortcuts->setAttribute(Qt::WA_AlwaysStackOnTop);
qmlKeyboardShortcuts->setClearColor(Qt::transparent);
qmlKeyboardShortcuts->setMinimumWidth(qmlKeyboardShortcuts->rootObject()->property("minWidth").toInt());
qmlKeyboardShortcuts->setMinimumHeight(qmlKeyboardShortcuts->rootObject()->property("minHeight").toInt());
qmlKeyboardShortcuts->getContainer()->exec();
}
\ No newline at end of file
......@@ -29,6 +29,7 @@
#include <QMouseEvent>
static constexpr char IDM_ABOUTBOX = 0x0010;
static constexpr char IDM_SHORTCUTSBOX = 0x0011;
static constexpr uint32_t QtMaxDimension = 16777215;
static constexpr uint32_t mainWindowMinWidth = 1088;
......@@ -66,12 +67,16 @@ protected:
signals:
void keyReleased(QKeyEvent*ke);
protected:
const QUrl qmlKeyBoardShortcutTable_ { QStringLiteral("qrc:/src/KeyBoardShortcutTable.qml") };
private slots:
void slotCurrentChanged(int index);
void trayActivated(QSystemTrayIcon::ActivationReason reason);
void notificationClicked();
void slotScreenChanged(QScreen* screen);
void slotAccountListChanged();
void generateQmlDialog(const QUrl& qmlSource);
private:
explicit MainWindow(QWidget* parent = 0);
......@@ -90,6 +95,7 @@ private:
QAction* settingsAction_;
QAction* exitAction_;
QAction* keyboardShortcutsAction_;
#ifdef Q_OS_WIN
std::unique_ptr<ConnectivityMonitor> connectivityMonitor_;
#endif // Q_OS_WIN
......
......@@ -18,6 +18,8 @@
#include "widgethelpers.h"
#include "mainwindow.h"
FadeOutable::FadeOutable(QWidget* parent)
: QWidget(parent)
{
......@@ -196,3 +198,23 @@ VignetteWidget::fillRoundRectPath(QPainter& painter, const QLinearGradient & gra
painter.fillRect(rect(), gradient);
}
}
void
QmlPopupWidget::showEvent(QShowEvent* event)
{
QWidget::showEvent(event);
auto cp = getContainer()->parentWidget();
if (auto mainWindow = qobject_cast<MainWindow*>(cp)) {
mainWindow->darken();
}
}
void
QmlPopupWidget::hideEvent(QHideEvent* event)
{
QWidget::hideEvent(event);
auto cp = getContainer()->parentWidget();
if (auto mainWindow = qobject_cast<MainWindow*>(cp)) {
mainWindow->lighten();
}
}
\ No newline at end of file
......@@ -28,6 +28,15 @@
#include <QPainter>
#include <QPixmap>
#include <QtQML>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQmlComponent>
#include <QtQuick/QtQuick>
#include <QQuickItem>
#include <QQuickWidget>
class FadeOutable : public QWidget
{
Q_OBJECT
......@@ -141,6 +150,34 @@ protected:
};
class QmlPopupWidget : public QQuickWidget
{
Q_OBJECT
public:
// insider content of PopupDialog
explicit QmlPopupWidget(const QUrl& source,
QWidget* parent = nullptr,
QColor spikeColor = Qt::white,
PopupDialog::SpikeLabelAlignment spikeAlignment = PopupDialog::SpikeLabelAlignment::None)
: QQuickWidget(source, parent) {
widgetContainer_ = new PopupDialog(parent, spikeColor, spikeAlignment);
setMouseTracking(true);
setParent(widgetContainer_);
widgetContainer_->insertWidget(this);
}
virtual ~QmlPopupWidget() {}
PopupDialog* getContainer() { return widgetContainer_; }
protected:
void showEvent(QShowEvent* event) override;
void hideEvent(QHideEvent* event) override;
PopupDialog* widgetContainer_;
};
class Darkenable : public QWidget
{
Q_OBJECT
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment