Commit 9d370ee1 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Ming Rui Zhang

mainwindow: make mainwindow darken behind about dialog

- Adds the hasRun regkey on startup to conditionally show
  the about dialog.

- Fades in black overlay on mainwindow when dialog shows.

Change-Id: I8daf98c52b6fe420cc2a55675e2d615f872cfb9c
parent 8e955b44
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
<ComponentGroupRef Id="HeatGenerated" /> <ComponentGroupRef Id="HeatGenerated" />
<ComponentRef Id="ApplicationShortcutDesktop" /> <ComponentRef Id="ApplicationShortcutDesktop" />
<ComponentRef Id="ApplicationShortcutStartMenu" /> <ComponentRef Id="ApplicationShortcutStartMenu" />
<ComponentRef Id="RegistryEntries" />
</Feature> </Feature>
<!--Visual C++ Redist merge module--> <!--Visual C++ Redist merge module-->
...@@ -67,8 +68,18 @@ ...@@ -67,8 +68,18 @@
<Shortcut Id="ApplicationShortcutStartMenu" Name="$(var.Name)" Description="Launch $(var.Name)" Target="[#fileMain.exe]" WorkingDirectory="INSTALLFOLDER" /> <Shortcut Id="ApplicationShortcutStartMenu" Name="$(var.Name)" Description="Launch $(var.Name)" Target="[#fileMain.exe]" WorkingDirectory="INSTALLFOLDER" />
<RemoveFolder Id="StartMenuFolder" On="uninstall" /> <RemoveFolder Id="StartMenuFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\jami.net\$(var.Name)" Name="startmenu" Type="integer" Value="1" KeyPath="yes" /> <RegistryValue Root="HKCU" Key="Software\jami.net\$(var.Name)" Name="startmenu" Type="integer" Value="1" KeyPath="yes" />
<RemoveRegistryKey Id='removeBadShortcutRegKey' Root='HKLM' Key='Software/$(var.Name)' Action='removeOnInstall'/> </Component>
<RemoveRegistryKey Id='removeOldUninstRegKey' Root='HKLM' Key='SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$(var.Manufacturer) $(var.Name)' Action='removeOnInstall'/> </DirectoryRef>
</Fragment>
<Fragment Id="OtherRegistryEntries">
<DirectoryRef Id="TARGETDIR">
<Component Id="RegistryEntries" Guid="*" Win64="yes">
<RegistryKey Root="HKCU"
Key="Software\jami.net\$(var.Name)"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="integer" Name="hasRun" Value="0" KeyPath="yes" Action='write'/>
</RegistryKey>
</Component> </Component>
</DirectoryRef> </DirectoryRef>
</Fragment> </Fragment>
......
...@@ -22,11 +22,12 @@ ...@@ -22,11 +22,12 @@
#include "utils.h" #include "utils.h"
#include "version.h" #include "version.h"
#include "mainwindow.h"
AboutDialog::AboutDialog(QWidget *parent) : AboutDialog::AboutDialog(QWidget *parent) :
PopupWidget( PopupWidget(
parent, parent,
RingTheme::lightGrey_, Qt::white,
PopupDialog::SpikeLabelAlignment::None), PopupDialog::SpikeLabelAlignment::None),
ui(new Ui::AboutDialog) ui(new Ui::AboutDialog)
{ {
...@@ -45,6 +46,26 @@ AboutDialog::~AboutDialog() ...@@ -45,6 +46,26 @@ AboutDialog::~AboutDialog()
delete ui; delete ui;
} }
void
AboutDialog::showEvent(QShowEvent* event)
{
QWidget::showEvent(event);
auto cp = getContainer()->parentWidget();
if (auto mainWindow = qobject_cast<MainWindow*>(cp)) {
mainWindow->darken();
}
}
void
AboutDialog::hideEvent(QHideEvent* event)
{
QWidget::hideEvent(event);
auto cp = getContainer()->parentWidget();
if (auto mainWindow = qobject_cast<MainWindow*>(cp)) {
mainWindow->lighten();
}
}
void void
AboutDialog::on_changelogButton_clicked() AboutDialog::on_changelogButton_clicked()
{ {
...@@ -56,12 +77,8 @@ void ...@@ -56,12 +77,8 @@ void
AboutDialog::on_creditsButton_clicked() AboutDialog::on_creditsButton_clicked()
{ {
ui->logTextEdit->clear(); ui->logTextEdit->clear();
ui->logTextEdit->insertHtml("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">" ui->logTextEdit->insertHtml("<h3 align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">" + tr("Created by:") + "</span></h3>"
"p, li { white-space: pre-wrap; }"
"</style></head><body style=\" font-family:'Cantarell'; font-size:11pt; font-weight:400; font-style:normal;\">"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">"
+ tr("Created by:") + "</span></p>"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Adrien Béraud</p>" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Adrien Béraud</p>"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Alexandr Sergheev</p>" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Alexandr Sergheev</p>"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Alexandre Lision</p>" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Alexandre Lision</p>"
...@@ -100,11 +117,10 @@ AboutDialog::on_creditsButton_clicked() ...@@ -100,11 +117,10 @@ AboutDialog::on_creditsButton_clicked()
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Thibault Wittemberg</p>" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Thibault Wittemberg</p>"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Vsevolod Ivanov</p>" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Vsevolod Ivanov</p>"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Yang Wang</p>" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Yang Wang</p>"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">" "<h3 align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><span style=\" font-weight:600;\">"
+ tr("Artwork by:") + "</span></p>" + tr("Artwork by:") + "</span></h3>"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Marianne Forget</p>" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Marianne Forget</p>"
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>" "<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p>"
"<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">" "<p align=\"center\" style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">"
+ tr("Based on the SFLPhone project") + "</p>" + tr("Based on the SFLPhone project") + "</p>");
"<p align=\"center\" style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>");
} }
...@@ -33,6 +33,10 @@ public: ...@@ -33,6 +33,10 @@ public:
explicit AboutDialog(QWidget *parent = 0); explicit AboutDialog(QWidget *parent = 0);
~AboutDialog(); ~AboutDialog();
protected:
void showEvent(QShowEvent* event) override;
void hideEvent(QHideEvent* event) override;
private slots: private slots:
void on_changelogButton_clicked(); void on_changelogButton_clicked();
void on_creditsButton_clicked(); void on_creditsButton_clicked();
......
...@@ -33,9 +33,21 @@ void ...@@ -33,9 +33,21 @@ void
OpacityAnimation::reset() OpacityAnimation::reset()
{ {
stop(); stop();
setToStartValue();
}
void
OpacityAnimation::setToStartValue()
{
targetObject()->setProperty(propertyName(), startValue()); targetObject()->setProperty(propertyName(), startValue());
} }
void
OpacityAnimation::setToEndValue()
{
targetObject()->setProperty(propertyName(), endValue());
}
OpacityAnimation::~OpacityAnimation() OpacityAnimation::~OpacityAnimation()
{} {}
......
...@@ -37,6 +37,8 @@ public: ...@@ -37,6 +37,8 @@ public:
virtual ~OpacityAnimation(); virtual ~OpacityAnimation();
void reset(); void reset();
void setToStartValue();
void setToEndValue();
}; };
class FadeAnimation : public OpacityAnimation class FadeAnimation : public OpacityAnimation
......
...@@ -222,8 +222,8 @@ CallWidget::CallWidget(QWidget* parent) : ...@@ -222,8 +222,8 @@ CallWidget::CallWidget(QWidget* parent) :
connect(ui->changelogButton, &QAbstractButton::clicked, connect(ui->changelogButton, &QAbstractButton::clicked,
[this] { [this] {
AboutDialog aboutDialog(this); auto aboutDialog = std::make_unique<AboutDialog>(&MainWindow::instance());
aboutDialog.getContainer()->exec(); aboutDialog->getContainer()->exec();
}); });
// set first view to welcome view // set first view to welcome view
......
...@@ -277,19 +277,25 @@ main(int argc, char* argv[]) ...@@ -277,19 +277,25 @@ main(int argc, char* argv[])
MainWindow::instance().createThumbBar(); MainWindow::instance().createThumbBar();
if (not startMinimized) QSettings settings("jami.net", "Jami");
MainWindow::instance().showWindow(); if (not startMinimized) {
else { if (settings.value(SettingsKey::hasRun) == 0) {
MainWindow::instance().showMaximized();
QTimer::singleShot(100,
[] {
QSettings settings("jami.net", "Jami");
settings.setValue(SettingsKey::hasRun, 1);
auto aboutDialog = std::make_unique<AboutDialog>(&MainWindow::instance());
aboutDialog->getContainer()->exec();
});
} else {
MainWindow::instance().showWindow();
}
} else {
MainWindow::instance().showMinimized(); MainWindow::instance().showMinimized();
MainWindow::instance().hide(); MainWindow::instance().hide();
} }
QSettings settings("jami.net", "Jami");
if (!settings.contains(SettingsKey::changeLogShownOnce)) {
std::unique_ptr<AboutDialog> aboutDialog = std::make_unique<AboutDialog>(&MainWindow::instance());
aboutDialog->getContainer()->exec();
}
QObject::connect(&a, &QApplication::aboutToQuit, [&guard] { exitApp(guard); }); QObject::connect(&a, &QApplication::aboutToQuit, [&guard] { exitApp(guard); });
auto ret = a.exec(); auto ret = a.exec();
......
...@@ -184,6 +184,8 @@ MainWindow::MainWindow(QWidget* parent) ...@@ -184,6 +184,8 @@ MainWindow::MainWindow(QWidget* parent)
Q_UNUSED(accountId); Q_UNUSED(accountId);
emit LRCInstance::instance().accountListChanged(); emit LRCInstance::instance().accountListChanged();
}); });
overlay_ = new Darkenable(this);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
...@@ -217,10 +219,8 @@ bool MainWindow::nativeEvent(const QByteArray& eventType, void* message, long* r ...@@ -217,10 +219,8 @@ bool MainWindow::nativeEvent(const QByteArray& eventType, void* message, long* r
if (msg->message == WM_SYSCOMMAND) { if (msg->message == WM_SYSCOMMAND) {
if ((msg->wParam & 0xfff0) == IDM_ABOUTBOX) { if ((msg->wParam & 0xfff0) == IDM_ABOUTBOX) {
*result = 0; *result = 0;
AboutDialog aboutDialog(this); AboutDialog aboutDialog(this);
aboutDialog.getContainer()->exec(); aboutDialog.getContainer()->exec();
return true; return true;
} }
} }
...@@ -248,6 +248,18 @@ void MainWindow::showWindow() ...@@ -248,6 +248,18 @@ void MainWindow::showWindow()
raise(); raise();
} }
void
MainWindow::darken()
{
overlay_->darken();
}
void
MainWindow::lighten()
{
overlay_->lighten();
}
void MainWindow::notificationClicked() void MainWindow::notificationClicked()
{ {
if (auto currentWidget = dynamic_cast<NavWidget*>(ui->navStack->currentWidget())) { if (auto currentWidget = dynamic_cast<NavWidget*>(ui->navStack->currentWidget())) {
...@@ -342,15 +354,16 @@ void MainWindow::setWindowSize(ScreenEnum scr, bool firstUse) ...@@ -342,15 +354,16 @@ void MainWindow::setWindowSize(ScreenEnum scr, bool firstUse)
setMinimumSize(mainWindowMinWidth, mainWindowMinHeight); setMinimumSize(mainWindowMinWidth, mainWindowMinHeight);
setMaximumSize(QtMaxDimension, QtMaxDimension); setMaximumSize(QtMaxDimension, QtMaxDimension);
} }
if (firstUse || !accountList.size()) { if (firstUse || !accountList.size()) {
auto screenNumber = qApp->desktop()->screenNumber(); auto screenNumber = qApp->desktop()->screenNumber();
setGeometry(
QStyle::alignedRect(
Qt::LeftToRight,
Qt::AlignCenter,
size(),
qApp->desktop()->screenGeometry(screenNumber)));
if (scr == ScreenEnum::WizardScreen) { if (scr == ScreenEnum::WizardScreen) {
setGeometry(
QStyle::alignedRect(
Qt::LeftToRight,
Qt::AlignCenter,
size(),
qApp->desktop()->screenGeometry(screenNumber)));
setWindowFlags(Qt::Dialog); setWindowFlags(Qt::Dialog);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
adjustSize(); adjustSize();
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "utils.h" #include "utils.h"
#include "connectivitymonitor.h" #include "connectivitymonitor.h"
#include "globalsystemtray.h" #include "globalsystemtray.h"
#include "widgethelpers.h"
#include <QMainWindow> #include <QMainWindow>
#include <QMouseEvent> #include <QMouseEvent>
...@@ -53,13 +54,15 @@ public: ...@@ -53,13 +54,15 @@ public:
void show(); void show();
float getCurrentScalingRatio(); float getCurrentScalingRatio();
void showWindow(); void showWindow();
void darken();
void lighten();
protected: protected:
bool nativeEvent(const QByteArray& eventType, void* message, long* result); bool nativeEvent(const QByteArray& eventType, void* message, long* result) override;
void closeEvent(QCloseEvent* event); void closeEvent(QCloseEvent* event) override;
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event) override;
void keyReleaseEvent(QKeyEvent* ke); void keyReleaseEvent(QKeyEvent* ke) override;
void changeEvent(QEvent* e); void changeEvent(QEvent* e) override;
signals: signals:
void keyReleased(QKeyEvent*ke); void keyReleased(QKeyEvent*ke);
...@@ -93,5 +96,7 @@ private: ...@@ -93,5 +96,7 @@ private:
QMetaObject::Connection screenChangedConnection_; QMetaObject::Connection screenChangedConnection_;
QTimer *updateTimer_; QTimer* updateTimer_;
Darkenable* overlay_;
}; };
...@@ -29,5 +29,5 @@ constexpr static char mainSplitterState[] = "mainSplitterState"; ...@@ -29,5 +29,5 @@ constexpr static char mainSplitterState[] = "mainSplitterState";
constexpr static char windowState[] = "windowState"; constexpr static char windowState[] = "windowState";
constexpr static char autoUpdate[] = "autoUpdate"; constexpr static char autoUpdate[] = "autoUpdate";
constexpr static char neverShowMeAgain[] = "neverShowMeAgain"; constexpr static char neverShowMeAgain[] = "neverShowMeAgain";
constexpr static char changeLogShownOnce[] = "changeLogShownOnce"; constexpr static char hasRun[] = "hasRun";
} }
...@@ -123,7 +123,8 @@ public: ...@@ -123,7 +123,8 @@ public:
// insider content of PopupDialog // insider content of PopupDialog
explicit PopupWidget(QWidget* parent = nullptr, explicit PopupWidget(QWidget* parent = nullptr,
QColor spikeColor = Qt::white, QColor spikeColor = Qt::white,
PopupDialog::SpikeLabelAlignment spikeAlignment = PopupDialog::SpikeLabelAlignment::AlignLeft) { PopupDialog::SpikeLabelAlignment spikeAlignment = PopupDialog::SpikeLabelAlignment::AlignLeft)
: QWidget(parent) {
widgetContainer_ = new PopupDialog(parent, spikeColor, spikeAlignment); widgetContainer_ = new PopupDialog(parent, spikeColor, spikeAlignment);
setParent(widgetContainer_); setParent(widgetContainer_);
widgetContainer_->insertWidget(this); widgetContainer_->insertWidget(this);
...@@ -136,3 +137,50 @@ protected: ...@@ -136,3 +137,50 @@ protected:
PopupDialog *widgetContainer_; PopupDialog *widgetContainer_;
}; };
class Darkenable : public QWidget
{
Q_OBJECT
public:
explicit Darkenable(QWidget* parent = nullptr)
: QWidget(parent)
{
setAttribute(Qt::WA_NoSystemBackground);
animation_ = new FadeAnimation(this, 400, 0, .33);
this->hide();
};
~Darkenable() {};
void darken() {
disconnect(connection_);
this->show();
animation_->setDirection(QAbstractAnimation::Backward);
animation_->start();
}
void lighten() {
animation_->setDirection(QAbstractAnimation::Forward);
disconnect(connection_);
connection_ = connect(animation_, &QPropertyAnimation::finished,
[this] {
this->hide();
});
animation_->start();
}
void setAnimationTime(const quint64 ms) { animation_->setDuration(ms); }
protected:
void paintEvent(QPaintEvent *event) override {
Q_UNUSED(event);
QPainter painter(this);
painter.setBrush(Qt::black);
auto rect = qobject_cast<QWidget*>(parent())->rect();
setGeometry(rect);
painter.drawRect(rect);
};
private:
FadeAnimation* animation_;
QMetaObject::Connection connection_;
};
\ No newline at end of file
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