diff --git a/JamiInstaller/Product.wxs b/JamiInstaller/Product.wxs index 2ea93e0476f2afa5d03151bf7201e8d76dc33bf0..ce4121ed5c6a715eb4b8965d20eda21eac2f336b 100644 --- a/JamiInstaller/Product.wxs +++ b/JamiInstaller/Product.wxs @@ -17,6 +17,7 @@ + @@ -67,8 +68,18 @@ - - + + + + + + + + + + diff --git a/aboutdialog.cpp b/aboutdialog.cpp index 125628a28a2ad53daf479492f74e2cf7892b46a5..1e02300d0004876bee14857a0a6457d0680db8f6 100644 --- a/aboutdialog.cpp +++ b/aboutdialog.cpp @@ -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(cp)) { + mainWindow->darken(); + } +} + +void +AboutDialog::hideEvent(QHideEvent* event) +{ + QWidget::hideEvent(event); + auto cp = getContainer()->parentWidget(); + if (auto mainWindow = qobject_cast(cp)) { + mainWindow->lighten(); + } +} + void AboutDialog::on_changelogButton_clicked() { @@ -56,12 +77,8 @@ void AboutDialog::on_creditsButton_clicked() { ui->logTextEdit->clear(); - ui->logTextEdit->insertHtml("" - "" - "

" - + tr("Created by:") + "

" + ui->logTextEdit->insertHtml("

" + + tr("Created by:") + "

" "

Adrien BĂ©raud

" "

Alexandr Sergheev

" "

Alexandre Lision

" @@ -100,11 +117,10 @@ AboutDialog::on_creditsButton_clicked() "

Thibault Wittemberg

" "

Vsevolod Ivanov

" "

Yang Wang

" - "

" - + tr("Artwork by:") + "

" + "

" + + tr("Artwork by:") + "

" "

Marianne Forget

" "


" "

" - + tr("Based on the SFLPhone project") + "

" - "


"); + + tr("Based on the SFLPhone project") + "

"); } diff --git a/aboutdialog.h b/aboutdialog.h index 5eabdff9d865f250cf31589578c6ef6405b2a746..51ae40b61e79e8f8ab147cb6230eda5b78839427 100644 --- a/aboutdialog.h +++ b/aboutdialog.h @@ -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(); diff --git a/animationhelpers.cpp b/animationhelpers.cpp index 36f015466f1dd0165193a09c30a7e21702a22760..73e4d9fac03c06d1a30b6f17cf09f41c713df61d 100644 --- a/animationhelpers.cpp +++ b/animationhelpers.cpp @@ -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() {} diff --git a/animationhelpers.h b/animationhelpers.h index e557a11a755c754982a8bb2bf9cc8d2926458c02..34218ce533a43b57108061154cc6914ac3909a2d 100644 --- a/animationhelpers.h +++ b/animationhelpers.h @@ -37,6 +37,8 @@ public: virtual ~OpacityAnimation(); void reset(); + void setToStartValue(); + void setToEndValue(); }; class FadeAnimation : public OpacityAnimation diff --git a/callwidget.cpp b/callwidget.cpp index 069d673973ebb7064d6ac0a19b9a642bbd3ee241..ddb01dbc9682513f92b5d9d735afefac2666c858 100644 --- a/callwidget.cpp +++ b/callwidget.cpp @@ -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(&MainWindow::instance()); + aboutDialog->getContainer()->exec(); }); // set first view to welcome view diff --git a/main.cpp b/main.cpp index 3ab61abde6048b8e6a0d2ad4f1c587b4f7cd968c..bd2e2ac02527e87a694b6a8679fe1c7b448e3764 100644 --- a/main.cpp +++ b/main.cpp @@ -277,19 +277,25 @@ main(int argc, char* argv[]) MainWindow::instance().createThumbBar(); - if (not startMinimized) - MainWindow::instance().showWindow(); - else { + 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(&MainWindow::instance()); + aboutDialog->getContainer()->exec(); + }); + } else { + MainWindow::instance().showWindow(); + } + } else { MainWindow::instance().showMinimized(); MainWindow::instance().hide(); } - QSettings settings("jami.net", "Jami"); - if (!settings.contains(SettingsKey::changeLogShownOnce)) { - std::unique_ptr aboutDialog = std::make_unique(&MainWindow::instance()); - aboutDialog->getContainer()->exec(); - } - QObject::connect(&a, &QApplication::aboutToQuit, [&guard] { exitApp(guard); }); auto ret = a.exec(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 3101eae3466d04d1263396c7f3207c4c2fc4a508..56762464b609695004cd8a4315556bec25861817 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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(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(); - setGeometry( - QStyle::alignedRect( - Qt::LeftToRight, - Qt::AlignCenter, - size(), - qApp->desktop()->screenGeometry(screenNumber))); if (scr == ScreenEnum::WizardScreen) { + setGeometry( + QStyle::alignedRect( + Qt::LeftToRight, + Qt::AlignCenter, + size(), + qApp->desktop()->screenGeometry(screenNumber))); setWindowFlags(Qt::Dialog); setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); adjustSize(); diff --git a/mainwindow.h b/mainwindow.h index e66f5b95645f49a9b6ebe9ed8660a3a141fac282..0202745d490fcf67d11d6e03551091bc98f1cad0 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -23,6 +23,7 @@ #include "utils.h" #include "connectivitymonitor.h" #include "globalsystemtray.h" +#include "widgethelpers.h" #include #include @@ -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_; }; diff --git a/settingskey.h b/settingskey.h index 90a15b31f150da6dba7481dc6932b16a48b75c78..57944a0d69ee7b4ecd7f84a8dfc59a32c676b6d2 100644 --- a/settingskey.h +++ b/settingskey.h @@ -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"; } diff --git a/widgethelpers.h b/widgethelpers.h index ba684e63771a6bc6521dadaf40b4c9b572aa454f..865858965075685a5215fe0700c8febef33f28f2 100644 --- a/widgethelpers.h +++ b/widgethelpers.h @@ -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(parent())->rect(); + setGeometry(rect); + painter.drawRect(rect); + }; + +private: + FadeAnimation* animation_; + QMetaObject::Connection connection_; + +}; \ No newline at end of file