diff options
Diffstat (limited to 'src/plugins/welcome')
-rw-r--r-- | src/plugins/welcome/introductionwidget.cpp | 41 | ||||
-rw-r--r-- | src/plugins/welcome/welcomeplugin.cpp | 16 |
2 files changed, 30 insertions, 27 deletions
diff --git a/src/plugins/welcome/introductionwidget.cpp b/src/plugins/welcome/introductionwidget.cpp index 82539fd996..a29b5e4f57 100644 --- a/src/plugins/welcome/introductionwidget.cpp +++ b/src/plugins/welcome/introductionwidget.cpp @@ -25,6 +25,8 @@ #include "introductionwidget.h" +#include <coreplugin/icore.h> +#include <coreplugin/infobar.h> #include <utils/algorithm.h> #include <utils/checkablemessagebox.h> #include <utils/qtcassert.h> @@ -47,29 +49,24 @@ namespace Internal { void IntroductionWidget::askUserAboutIntroduction(QWidget *parent, QSettings *settings) { - if (!CheckableMessageBox::shouldAskAgain(settings, kTakeTourSetting)) + // CheckableMessageBox for compatibility with Qt Creator < 4.11 + if (!CheckableMessageBox::shouldAskAgain(settings, kTakeTourSetting) + || !Core::ICore::infoBar()->canInfoBeAdded(kTakeTourSetting)) return; - auto messageBox = new CheckableMessageBox(parent); - messageBox->setWindowTitle(tr("Take a UI Tour")); - messageBox->setText( - tr("Would you like to take a quick UI tour? This tour highlights important user " - "interface elements and shows how they are used. To take the tour later, " - "select Help > UI Tour.")); - messageBox->setCheckBoxVisible(true); - messageBox->setCheckBoxText(CheckableMessageBox::msgDoNotAskAgain()); - messageBox->setChecked(true); - messageBox->setStandardButtons(QDialogButtonBox::Cancel); - QPushButton *tourButton = messageBox->addButton(tr("Take UI Tour"), QDialogButtonBox::AcceptRole); - connect(messageBox, &QDialog::finished, parent, [parent, settings, messageBox, tourButton]() { - if (messageBox->isChecked()) - CheckableMessageBox::doNotAskAgain(settings, kTakeTourSetting); - if (messageBox->clickedButton() == tourButton) { - auto intro = new IntroductionWidget(parent); - intro->show(); - } - messageBox->deleteLater(); + + Core::InfoBarEntry + info(kTakeTourSetting, + tr("Would you like to take a quick UI tour? This tour highlights important user " + "interface elements and shows how they are used. To take the tour later, " + "select Help > UI Tour."), + Core::InfoBarEntry::GlobalSuppression::Enabled); + info.setCustomButtonInfo(tr("Take UI Tour"), [parent] { + Core::ICore::infoBar()->removeInfo(kTakeTourSetting); + Core::ICore::infoBar()->globallySuppressInfo(kTakeTourSetting); + auto intro = new IntroductionWidget(parent); + intro->show(); }); - messageBox->show(); + Core::ICore::infoBar()->addInfo(info); } IntroductionWidget::IntroductionWidget(QWidget *parent) @@ -81,7 +78,7 @@ IntroductionWidget::IntroductionWidget(QWidget *parent) parent->installEventFilter(this); QPalette p = palette(); - p.setColor(QPalette::Foreground, QColor(220, 220, 220)); + p.setColor(QPalette::WindowText, QColor(220, 220, 220)); setPalette(p); m_textWidget = new QWidget(this); diff --git a/src/plugins/welcome/welcomeplugin.cpp b/src/plugins/welcome/welcomeplugin.cpp index 0b54b19b46..93dcec3d0e 100644 --- a/src/plugins/welcome/welcomeplugin.cpp +++ b/src/plugins/welcome/welcomeplugin.cpp @@ -87,7 +87,6 @@ static QFont sizedFont(int size, const QWidget *widget, bool underline = false) static QPalette lightText() { QPalette pal; - pal.setColor(QPalette::Foreground, themeColor(Theme::Welcome_ForegroundPrimaryColor)); pal.setColor(QPalette::WindowText, themeColor(Theme::Welcome_ForegroundPrimaryColor)); return pal; } @@ -198,7 +197,7 @@ public: void enterEvent(QEvent *) override { QPalette pal; - pal.setColor(QPalette::Background, themeColor(Theme::Welcome_HoverColor)); + pal.setColor(QPalette::Window, themeColor(Theme::Welcome_HoverColor)); setPalette(pal); m_label->setFont(sizedFont(11, m_label, true)); update(); @@ -207,7 +206,7 @@ public: void leaveEvent(QEvent *) override { QPalette pal; - pal.setColor(QPalette::Background, themeColor(Theme::Welcome_BackgroundColor)); + pal.setColor(QPalette::Window, themeColor(Theme::Welcome_BackgroundColor)); setPalette(pal); m_label->setFont(sizedFont(11, m_label, false)); update(); @@ -318,7 +317,7 @@ WelcomeMode::WelcomeMode() setContext(Context(Constants::C_WELCOME_MODE)); QPalette palette = creatorTheme()->palette(); - palette.setColor(QPalette::Background, themeColor(Theme::Welcome_BackgroundColor)); + palette.setColor(QPalette::Window, themeColor(Theme::Welcome_BackgroundColor)); m_modeWidget = new QWidget; m_modeWidget->setPalette(palette); @@ -347,7 +346,7 @@ WelcomeMode::WelcomeMode() hbox->setStretchFactor(m_pageStack, 10); auto layout = new QVBoxLayout(m_modeWidget); - layout->setMargin(0); + layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); layout->addWidget(new StyledBar(m_modeWidget)); layout->addItem(hbox); @@ -423,6 +422,13 @@ void WelcomeMode::addPage(IWelcomePage *page) stackPage->setAutoFillBackground(true); m_pageStack->insertWidget(idx, stackPage); + connect(page, &QObject::destroyed, this, [this, page, stackPage, pageButton] { + m_pluginList.removeOne(page); + m_pageButtons.removeOne(pageButton); + delete pageButton; + delete stackPage; + }); + auto onClicked = [this, pageId, stackPage] { m_activePage = pageId; m_pageStack->setCurrentWidget(stackPage); |