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 @@
<ComponentGroupRef Id="HeatGenerated" />
<ComponentRef Id="ApplicationShortcutDesktop" />
<ComponentRef Id="ApplicationShortcutStartMenu" />
<ComponentRef Id="RegistryEntries" />
</Feature>
<!--Visual C++ Redist merge module-->
......@@ -67,8 +68,18 @@
<Shortcut Id="ApplicationShortcutStartMenu" Name="$(var.Name)" Description="Launch $(var.Name)" Target="[#fileMain.exe]" WorkingDirectory="INSTALLFOLDER" />
<RemoveFolder Id="StartMenuFolder" On="uninstall" />
<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'/>
<RemoveRegistryKey Id='removeOldUninstRegKey' Root='HKLM' Key='SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\$(var.Manufacturer) $(var.Name)' Action='removeOnInstall'/>
</Component>
</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>
</DirectoryRef>
</Fragment>
......
......@@ -22,11 +22,12 @@
#include "utils.h"
#include "version.h"
#include "mainwindow.h"
AboutDialog::AboutDialog(QWidget *parent) :
PopupWidget(
parent,
RingTheme::lightGrey_,
Qt::white,
PopupDialog::SpikeLabelAlignment::None),
ui(new Ui::AboutDialog)
{
......@@ -45,6 +46,26 @@ AboutDialog::~AboutDialog()
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
AboutDialog::on_changelogButton_clicked()
{
......@@ -56,12 +77,8 @@ void
AboutDialog::on_creditsButton_clicked()
{
ui->logTextEdit->clear();
ui->logTextEdit->insertHtml("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">"
"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>"
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;\">"
+ tr("Created 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;\">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;\">Alexandre Lision</p>"
......@@ -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;\">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;\"><span style=\" font-weight:600;\">"
+ tr("Artwork by:") + "</span></p>"
"<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></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=\"-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;\">"
+ 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>");
+ tr("Based on the SFLPhone project") + "</p>");
}
......@@ -33,6 +33,10 @@ public:
explicit AboutDialog(QWidget *parent = 0);
~AboutDialog();
protected:
void showEvent(QShowEvent* event) override;
void hideEvent(QHideEvent* event) override;
private slots:
void on_changelogButton_clicked();
void on_creditsButton_clicked();
......
......@@ -33,9 +33,21 @@ void
OpacityAnimation::reset()
{
stop();
setToStartValue();
}
void
OpacityAnimation::setToStartValue()
{
targetObject()->setProperty(propertyName(), startValue());
}
void
OpacityAnimation::setToEndValue()
{
targetObject()->setProperty(propertyName(), endValue());
}
OpacityAnimation::~OpacityAnimation()
{}
......
......@@ -37,6 +37,8 @@ public:
virtual ~OpacityAnimation();
void reset();
void setToStartValue();
void setToEndValue();
};
class FadeAnimation : public OpacityAnimation
......
......@@ -222,8 +222,8 @@ CallWidget::CallWidget(QWidget* parent) :
connect(ui->changelogButton, &QAbstractButton::clicked,
[this] {
AboutDialog aboutDialog(this);
aboutDialog.getContainer()->exec();
auto aboutDialog = std::make_unique<AboutDialog>(&MainWindow::instance());
aboutDialog->getContainer()->exec();
});
// set first view to welcome view
......
......@@ -277,19 +277,25 @@ main(int argc, char* argv[])
MainWindow::instance().createThumbBar();
if (not startMinimized)
QSettings settings("jami.net", "Jami");
if (not startMinimized) {
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 {
}
} else {
MainWindow::instance().showMinimized();
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); });
auto ret = a.exec();
......
......@@ -184,6 +184,8 @@ MainWindow::MainWindow(QWidget* parent)
Q_UNUSED(accountId);
emit LRCInstance::instance().accountListChanged();
});
overlay_ = new Darkenable(this);
}
MainWindow::~MainWindow()
......@@ -217,10 +219,8 @@ bool MainWindow::nativeEvent(const QByteArray& eventType, void* message, long* r
if (msg->message == WM_SYSCOMMAND) {
if ((msg->wParam & 0xfff0) == IDM_ABOUTBOX) {
*result = 0;
AboutDialog aboutDialog(this);
aboutDialog.getContainer()->exec();
return true;
}
}
......@@ -248,6 +248,18 @@ void MainWindow::showWindow()
raise();
}
void
MainWindow::darken()
{
overlay_->darken();
}
void
MainWindow::lighten()
{
overlay_->lighten();
}
void MainWindow::notificationClicked()
{
if (auto currentWidget = dynamic_cast<NavWidget*>(ui->navStack->currentWidget())) {
......@@ -342,15 +354,16 @@ void MainWindow::setWindowSize(ScreenEnum scr, bool firstUse)
setMinimumSize(mainWindowMinWidth, mainWindowMinHeight);
setMaximumSize(QtMaxDimension, QtMaxDimension);
}
if (firstUse || !accountList.size()) {
auto screenNumber = qApp->desktop()->screenNumber();
if (scr == ScreenEnum::WizardScreen) {
setGeometry(
QStyle::alignedRect(
Qt::LeftToRight,
Qt::AlignCenter,
size(),
qApp->desktop()->screenGeometry(screenNumber)));
if (scr == ScreenEnum::WizardScreen) {
setWindowFlags(Qt::Dialog);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
adjustSize();
......
......@@ -23,6 +23,7 @@
#include "utils.h"
#include "connectivitymonitor.h"
#include "globalsystemtray.h"
#include "widgethelpers.h"
#include <QMainWindow>
#include <QMouseEvent>
......@@ -53,13 +54,15 @@ public:
void show();
float getCurrentScalingRatio();
void showWindow();
void darken();
void lighten();
protected:
bool nativeEvent(const QByteArray& eventType, void* message, long* result);
void closeEvent(QCloseEvent* event);
void resizeEvent(QResizeEvent *event);
void keyReleaseEvent(QKeyEvent* ke);
void changeEvent(QEvent* e);
bool nativeEvent(const QByteArray& eventType, void* message, long* result) override;
void closeEvent(QCloseEvent* event) override;
void resizeEvent(QResizeEvent *event) override;
void keyReleaseEvent(QKeyEvent* ke) override;
void changeEvent(QEvent* e) override;
signals:
void keyReleased(QKeyEvent*ke);
......@@ -93,5 +96,7 @@ private:
QMetaObject::Connection screenChangedConnection_;
QTimer *updateTimer_;
QTimer* updateTimer_;
Darkenable* overlay_;
};
......@@ -29,5 +29,5 @@ constexpr static char mainSplitterState[] = "mainSplitterState";
constexpr static char windowState[] = "windowState";
constexpr static char autoUpdate[] = "autoUpdate";
constexpr static char neverShowMeAgain[] = "neverShowMeAgain";
constexpr static char changeLogShownOnce[] = "changeLogShownOnce";
constexpr static char hasRun[] = "hasRun";
}
......@@ -123,7 +123,8 @@ public:
// insider content of PopupDialog
explicit PopupWidget(QWidget* parent = nullptr,
QColor spikeColor = Qt::white,
PopupDialog::SpikeLabelAlignment spikeAlignment = PopupDialog::SpikeLabelAlignment::AlignLeft) {
PopupDialog::SpikeLabelAlignment spikeAlignment = PopupDialog::SpikeLabelAlignment::AlignLeft)
: QWidget(parent) {
widgetContainer_ = new PopupDialog(parent, spikeColor, spikeAlignment);
setParent(widgetContainer_);
widgetContainer_->insertWidget(this);
......@@ -136,3 +137,50 @@ protected:
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