|
@@ -11,6 +11,7 @@
|
|
|
#include <QUrl>
|
|
|
#include <QDebug>
|
|
|
#include <QMessageBox>
|
|
|
+#include <QRandomGenerator>
|
|
|
|
|
|
StatusWidget::StatusWidget(PatchList *legacy_patches, QWidget *parent)
|
|
|
: QWidget(parent)
|
|
@@ -19,6 +20,7 @@ StatusWidget::StatusWidget(PatchList *legacy_patches, QWidget *parent)
|
|
|
{
|
|
|
ui->setupUi(this);
|
|
|
last_statusbar_update_time_.start();
|
|
|
+ ui->galadriel_tooltip_example->hide();
|
|
|
|
|
|
connect(ui->weekly_code_widget, &WeeklyCodeWidget::showCompletedTooltip, this, [this](){setToolTipMessage("ЕЖЕНЕДЕЛЬНЫЙ КОД СКОПИРОВАН В БУФЕР ОБМЕНА", E_INFO);});
|
|
|
connect(ui->weekly_code_widget, &WeeklyCodeWidget::showHelpTooltip, this, [this](){setToolTipMessage("КЛИКНИТЕ ПО ЕЖЕНЕДЕЛЬНОМУ КОДУ, ЧТОБЫ СКОПИРОВАТЬ ЕГО", E_INFO);});
|
|
@@ -30,26 +32,6 @@ StatusWidget::StatusWidget(PatchList *legacy_patches, QWidget *parent)
|
|
|
connect(ui->server_status_widget, &ServerStatusWidget::showServersTooltip, this, [this](QString message){setToolTipMessage(message, E_INFO);});
|
|
|
connect(ui->server_status_widget, &ServerStatusWidget::showNoTooltip, this, [this](){unsetToolTipMessage(E_INFO);});
|
|
|
|
|
|
- tooltip_effects[ui->galadriel_tooltip_1->objectName()] = new QGraphicsOpacityEffect(ui->galadriel_tooltip_1);
|
|
|
- tooltip_effects[ui->galadriel_tooltip_2->objectName()] = new QGraphicsOpacityEffect(ui->galadriel_tooltip_2);
|
|
|
-
|
|
|
- tooltip_animations[ui->galadriel_tooltip_1->objectName()] = new QPropertyAnimation(tooltip_effects[ui->galadriel_tooltip_1->objectName()], "opacity");
|
|
|
- tooltip_animations[ui->galadriel_tooltip_2->objectName()] = new QPropertyAnimation(tooltip_effects[ui->galadriel_tooltip_2->objectName()], "opacity");
|
|
|
-
|
|
|
- ui->galadriel_tooltip_1->setGraphicsEffect(tooltip_effects[ui->galadriel_tooltip_1->objectName()]);
|
|
|
- ui->galadriel_tooltip_2->setGraphicsEffect(tooltip_effects[ui->galadriel_tooltip_2->objectName()]);
|
|
|
-
|
|
|
- foreach (QPropertyAnimation* animation, tooltip_animations) {
|
|
|
- animation->setDuration(350);
|
|
|
- animation->setStartValue(0);
|
|
|
- animation->setEndValue(1);
|
|
|
- animation->setDirection(QAbstractAnimation::Forward);
|
|
|
- }
|
|
|
-
|
|
|
- foreach (QGraphicsOpacityEffect* effect, tooltip_effects) {
|
|
|
- effect->setOpacity(0);
|
|
|
- }
|
|
|
-
|
|
|
connect(legacy_patches_, &PatchList::patchOperationsStarted, this, &StatusWidget::onPatchTotalOperationsStarted);
|
|
|
connect(legacy_patches_, &PatchList::patchOperationsFinished, this, &StatusWidget::onPatchTotalOperationsFinished);
|
|
|
connect(legacy_patches_, &PatchList::progressChanged, this, &StatusWidget::onPatchTotalProgressChanged);
|
|
@@ -59,6 +41,11 @@ StatusWidget::StatusWidget(PatchList *legacy_patches, QWidget *parent)
|
|
|
connect(patch, &Patch::operationStarted, this, &StatusWidget::onPatchOperationStarted);
|
|
|
connect(patch, &Patch::operationFinished, this, &StatusWidget::onPatchOperationFinished);
|
|
|
}
|
|
|
+
|
|
|
+ generateRandomTooltipMessage();
|
|
|
+ random_tooltip_generator_timer_.setInterval(5 * 1000);
|
|
|
+ connect(&random_tooltip_generator_timer_, &QTimer::timeout, this, &StatusWidget::generateRandomTooltipMessage);
|
|
|
+ random_tooltip_generator_timer_.start();
|
|
|
}
|
|
|
|
|
|
StatusWidget::~StatusWidget()
|
|
@@ -76,7 +63,10 @@ void StatusWidget::setToolTipMessage(QString message, StatusWidget::ToolTipState
|
|
|
{
|
|
|
tooltip_messages_[state] = message;
|
|
|
tooltip_state_ = ToolTipState(int(tooltip_state_) | int(state));
|
|
|
+ qDebug() << "New tooltip state: " << int(tooltip_state_);
|
|
|
+
|
|
|
if (tooltip_state_ < state * 2) {
|
|
|
+ qDebug() << "Fading between tooltips";
|
|
|
fadeBetweenToolTips(message);
|
|
|
}
|
|
|
}
|
|
@@ -84,6 +74,7 @@ void StatusWidget::setToolTipMessage(QString message, StatusWidget::ToolTipState
|
|
|
void StatusWidget::unsetToolTipMessage(StatusWidget::ToolTipState state)
|
|
|
{
|
|
|
tooltip_state_ = ToolTipState(int(tooltip_state_) & (~int(state)));
|
|
|
+ qDebug() << "New tooltip state: " << int(tooltip_state_);
|
|
|
|
|
|
if (tooltip_state_ & E_INFO) {
|
|
|
fadeBetweenToolTips(tooltip_messages_[E_INFO]);
|
|
@@ -131,47 +122,45 @@ void StatusWidget::resizeEvent(QResizeEvent *)
|
|
|
updateFontsSizes();
|
|
|
}
|
|
|
|
|
|
-void StatusWidget::fadeBetweenToolTips(QString next_tooltip_message)
|
|
|
+void StatusWidget::generateRandomTooltipMessage()
|
|
|
{
|
|
|
- if (!galadriel_tooltip_1_type) {
|
|
|
-
|
|
|
-
|
|
|
- galadriel_tooltip_1_type = true;
|
|
|
-
|
|
|
- ui->galadriel_tooltip_1->setText(next_tooltip_message);
|
|
|
-
|
|
|
- qDebug() << "StatusWidget: Showing message: " << ui->galadriel_tooltip_1->text();
|
|
|
- qDebug() << "StatusWidget: Hiding message: " << ui->galadriel_tooltip_2->text();
|
|
|
-
|
|
|
- QPropertyAnimation* showing_anim = tooltip_animations[ui->galadriel_tooltip_1->objectName()];
|
|
|
- showing_anim->setDirection(QAbstractAnimation::Forward);
|
|
|
- if (showing_anim->state() == QAbstractAnimation::Stopped)
|
|
|
- showing_anim->start();
|
|
|
-
|
|
|
- QPropertyAnimation* hiding_anim = tooltip_animations[ui->galadriel_tooltip_2->objectName()];
|
|
|
- hiding_anim->setDirection(QAbstractAnimation::Backward);
|
|
|
- if (hiding_anim->state() == QAbstractAnimation::Stopped)
|
|
|
- hiding_anim->start();
|
|
|
- } else {
|
|
|
-
|
|
|
-
|
|
|
- galadriel_tooltip_1_type = false;
|
|
|
-
|
|
|
- ui->galadriel_tooltip_2->setText(next_tooltip_message);
|
|
|
+ quint32 number = QRandomGenerator::system()->generate();
|
|
|
+ setToolTipMessage("СЛУЧАЙНОЕ СООБЩЕНИЕ №" + QString::number(number), E_RANDOM);
|
|
|
+}
|
|
|
|
|
|
- qDebug() << "StatusWidget: Showing message: " << ui->galadriel_tooltip_2->text();
|
|
|
- qDebug() << "StatusWidget: Hiding message: " << ui->galadriel_tooltip_1->text();
|
|
|
+void StatusWidget::fadeBetweenToolTips(QString next_tooltip_message)
|
|
|
+{
|
|
|
+ if (next_tooltip_message == current_tooltip_message_) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- QPropertyAnimation* showing_anim = tooltip_animations[ui->galadriel_tooltip_2->objectName()];
|
|
|
- showing_anim->setDirection(QAbstractAnimation::Forward);
|
|
|
- if (showing_anim->state() == QAbstractAnimation::Stopped)
|
|
|
- showing_anim->start();
|
|
|
+ if (!tooltip_widgets_.contains(next_tooltip_message)) {
|
|
|
+ createTooltipMessageWidget(next_tooltip_message);
|
|
|
+ }
|
|
|
|
|
|
- QPropertyAnimation* hiding_anim = tooltip_animations[ui->galadriel_tooltip_1->objectName()];
|
|
|
+ QPropertyAnimation* showing_anim = tooltip_animations_[next_tooltip_message];
|
|
|
+ showing_anim->setDirection(QAbstractAnimation::Forward);
|
|
|
+ if (showing_anim->state() == QAbstractAnimation::Stopped)
|
|
|
+ showing_anim->start();
|
|
|
+
|
|
|
+ if (tooltip_widgets_.contains(current_tooltip_message_)) {
|
|
|
+ QString msg = current_tooltip_message_;
|
|
|
+ connect(tooltip_animations_[current_tooltip_message_], &QPropertyAnimation::finished, this, [&, msg](){
|
|
|
+ if (tooltip_effects_.contains(msg) && tooltip_effects_[msg]->opacity() == 0) {
|
|
|
+ qDebug() << "Deleting " << msg;
|
|
|
+ tooltip_widgets_.take(msg)->deleteLater();
|
|
|
+ tooltip_effects_.take(msg)->deleteLater();
|
|
|
+ tooltip_animations_.take(msg)->deleteLater();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ QPropertyAnimation* hiding_anim = tooltip_animations_[current_tooltip_message_];
|
|
|
hiding_anim->setDirection(QAbstractAnimation::Backward);
|
|
|
if (hiding_anim->state() == QAbstractAnimation::Stopped)
|
|
|
hiding_anim->start();
|
|
|
}
|
|
|
+
|
|
|
+ current_tooltip_message_ = next_tooltip_message;
|
|
|
}
|
|
|
|
|
|
void StatusWidget::onPatchTotalOperationsStarted()
|
|
@@ -301,7 +290,6 @@ void StatusWidget::onPatchProgressChanged(Patch::OperationProgress progress, Pat
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
void StatusWidget::updateStatusBar(Patch::OperationProgress progress)
|
|
|
{
|
|
|
|
|
@@ -321,10 +309,32 @@ void StatusWidget::updateStatusBar(Patch::OperationProgress progress)
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+void StatusWidget::createTooltipMessageWidget(QString tooltip_message)
|
|
|
+{
|
|
|
+ qDebug() << "Creating:" << tooltip_message;
|
|
|
+ tooltip_widgets_[tooltip_message] = new QLabel(ui->galadriel_widget);
|
|
|
+ tooltip_widgets_[tooltip_message]->setText(tooltip_message);
|
|
|
+ tooltip_widgets_[tooltip_message]->setGeometry(ui->galadriel_tooltip_example->geometry());
|
|
|
+ tooltip_widgets_[tooltip_message]->setStyleSheet(ui->galadriel_tooltip_example->styleSheet());
|
|
|
+ tooltip_widgets_[tooltip_message]->setFont(ui->galadriel_tooltip_example->font());
|
|
|
+ tooltip_widgets_[tooltip_message]->setWordWrap(true);
|
|
|
+ tooltip_widgets_[tooltip_message]->setAlignment(Qt::AlignCenter);
|
|
|
+ tooltip_widgets_[tooltip_message]->show();
|
|
|
+
|
|
|
+ tooltip_effects_[tooltip_message] = new QGraphicsOpacityEffect(tooltip_widgets_[tooltip_message]);
|
|
|
+ tooltip_effects_[tooltip_message]->setOpacity(0);
|
|
|
+
|
|
|
+ tooltip_animations_[tooltip_message] = new QPropertyAnimation(tooltip_effects_[tooltip_message], "opacity");
|
|
|
+ tooltip_animations_[tooltip_message]->setDuration(350);
|
|
|
+ tooltip_animations_[tooltip_message]->setStartValue(0);
|
|
|
+ tooltip_animations_[tooltip_message]->setEndValue(1);
|
|
|
+ tooltip_animations_[tooltip_message]->setDirection(QAbstractAnimation::Forward);
|
|
|
+
|
|
|
+ tooltip_widgets_[tooltip_message]->setGraphicsEffect(tooltip_effects_[tooltip_message]);
|
|
|
+}
|
|
|
|
|
|
void StatusWidget::on_check_for_updates_button_clicked()
|
|
|
{
|