Commit 0a4276b2 authored by Ming Rui Zhang's avatar Ming Rui Zhang

qml: add keyboard shortcuts table on system menu

Change-Id: Ie5cc1d351672a86164fb203d6b86afd3ea92fed4
parent bc02dc37
......@@ -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
}
}
}
This diff is collapsed.
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment