forked from qt-creator/qt-creator
Add global notification area and use for UI Tour info
Adds a global info bar display above the main window's status bar that can be accessed via ICore::infoBar(). Replace the blocking "Take UI Tour" dialog by a notification there. Fixes: QTCREATORBUG-22819 Change-Id: I733f1bfd2d1db0295754ed2e28bb202f927d0edb Reviewed-by: hjk <hjk@qt.io> Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
@@ -149,6 +149,7 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|||||||
Theme *themeFromArg = ThemeEntry::createTheme(args.themeId);
|
Theme *themeFromArg = ThemeEntry::createTheme(args.themeId);
|
||||||
setCreatorTheme(themeFromArg ? themeFromArg
|
setCreatorTheme(themeFromArg ? themeFromArg
|
||||||
: ThemeEntry::createTheme(ThemeEntry::themeSetting()));
|
: ThemeEntry::createTheme(ThemeEntry::themeSetting()));
|
||||||
|
InfoBar::initialize(ICore::settings(), creatorTheme());
|
||||||
new ActionManager(this);
|
new ActionManager(this);
|
||||||
ActionManager::setPresentationModeEnabled(args.presentationMode);
|
ActionManager::setPresentationModeEnabled(args.presentationMode);
|
||||||
m_mainWindow = new MainWindow;
|
m_mainWindow = new MainWindow;
|
||||||
@@ -159,7 +160,6 @@ bool CorePlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
|||||||
m_mainWindow->init();
|
m_mainWindow->init();
|
||||||
m_editMode = new EditMode;
|
m_editMode = new EditMode;
|
||||||
ModeManager::activateMode(m_editMode->id());
|
ModeManager::activateMode(m_editMode->id());
|
||||||
InfoBar::initialize(ICore::settings(), creatorTheme());
|
|
||||||
|
|
||||||
IWizardFactory::initialize();
|
IWizardFactory::initialize();
|
||||||
|
|
||||||
|
@@ -517,6 +517,9 @@ FancyTabWidget::FancyTabWidget(QWidget *parent)
|
|||||||
vlayout->addLayout(m_modesStack);
|
vlayout->addLayout(m_modesStack);
|
||||||
vlayout->addWidget(m_statusBar);
|
vlayout->addWidget(m_statusBar);
|
||||||
|
|
||||||
|
m_infoBarDisplay.setTarget(vlayout, 1);
|
||||||
|
m_infoBarDisplay.setStyle(QFrame::Sunken);
|
||||||
|
|
||||||
auto mainLayout = new QHBoxLayout;
|
auto mainLayout = new QHBoxLayout;
|
||||||
mainLayout->setMargin(0);
|
mainLayout->setMargin(0);
|
||||||
mainLayout->setSpacing(1);
|
mainLayout->setSpacing(1);
|
||||||
@@ -611,6 +614,13 @@ QStatusBar *FancyTabWidget::statusBar() const
|
|||||||
return m_statusBar;
|
return m_statusBar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InfoBar *FancyTabWidget::infoBar()
|
||||||
|
{
|
||||||
|
if (!m_infoBarDisplay.infoBar())
|
||||||
|
m_infoBarDisplay.setInfoBar(&m_infoBar);
|
||||||
|
return &m_infoBar;
|
||||||
|
}
|
||||||
|
|
||||||
void FancyTabWidget::setCurrentIndex(int index)
|
void FancyTabWidget::setCurrentIndex(int index)
|
||||||
{
|
{
|
||||||
m_tabBar->setCurrentIndex(index);
|
m_tabBar->setCurrentIndex(index);
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "infobar.h"
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
@@ -157,6 +159,7 @@ public:
|
|||||||
|
|
||||||
int currentIndex() const;
|
int currentIndex() const;
|
||||||
QStatusBar *statusBar() const;
|
QStatusBar *statusBar() const;
|
||||||
|
InfoBar *infoBar();
|
||||||
|
|
||||||
void setTabEnabled(int index, bool enable);
|
void setTabEnabled(int index, bool enable);
|
||||||
bool isTabEnabled(int index) const;
|
bool isTabEnabled(int index) const;
|
||||||
@@ -183,6 +186,8 @@ private:
|
|||||||
QStackedLayout *m_modesStack;
|
QStackedLayout *m_modesStack;
|
||||||
QWidget *m_selectionWidget;
|
QWidget *m_selectionWidget;
|
||||||
QStatusBar *m_statusBar;
|
QStatusBar *m_statusBar;
|
||||||
|
InfoBarDisplay m_infoBarDisplay;
|
||||||
|
InfoBar m_infoBar;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -561,6 +561,11 @@ QStatusBar *ICore::statusBar()
|
|||||||
return m_mainwindow->statusBar();
|
return m_mainwindow->statusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InfoBar *ICore::infoBar()
|
||||||
|
{
|
||||||
|
return m_mainwindow->infoBar();
|
||||||
|
}
|
||||||
|
|
||||||
void ICore::raiseWindow(QWidget *widget)
|
void ICore::raiseWindow(QWidget *widget)
|
||||||
{
|
{
|
||||||
if (!widget)
|
if (!widget)
|
||||||
|
@@ -43,9 +43,10 @@ template <typename T> class QList;
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class IWizardFactory;
|
|
||||||
class Context;
|
class Context;
|
||||||
class IContext;
|
class IContext;
|
||||||
|
class InfoBar;
|
||||||
|
class IWizardFactory;
|
||||||
class SettingsDatabase;
|
class SettingsDatabase;
|
||||||
|
|
||||||
namespace Internal { class MainWindow; }
|
namespace Internal { class MainWindow; }
|
||||||
@@ -107,6 +108,8 @@ public:
|
|||||||
static QMainWindow *mainWindow();
|
static QMainWindow *mainWindow();
|
||||||
static QWidget *dialogParent();
|
static QWidget *dialogParent();
|
||||||
static QStatusBar *statusBar();
|
static QStatusBar *statusBar();
|
||||||
|
static InfoBar *infoBar();
|
||||||
|
|
||||||
/* Raises and activates the window for the widget. This contains workarounds for X11. */
|
/* Raises and activates the window for the widget. This contains workarounds for X11. */
|
||||||
static void raiseWindow(QWidget *widget);
|
static void raiseWindow(QWidget *widget);
|
||||||
|
|
||||||
|
@@ -30,7 +30,6 @@
|
|||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
#include <QFrame>
|
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
@@ -207,6 +206,17 @@ void InfoBarDisplay::setInfoBar(InfoBar *infoBar)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InfoBarDisplay::setStyle(QFrame::Shadow style)
|
||||||
|
{
|
||||||
|
m_style = style;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
InfoBar *InfoBarDisplay::infoBar() const
|
||||||
|
{
|
||||||
|
return m_infoBar;
|
||||||
|
}
|
||||||
|
|
||||||
void InfoBarDisplay::infoBarDestroyed()
|
void InfoBarDisplay::infoBarDestroyed()
|
||||||
{
|
{
|
||||||
m_infoBar = nullptr;
|
m_infoBar = nullptr;
|
||||||
@@ -236,7 +246,7 @@ void InfoBarDisplay::update()
|
|||||||
}
|
}
|
||||||
|
|
||||||
infoWidget->setPalette(pal);
|
infoWidget->setPalette(pal);
|
||||||
infoWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);
|
infoWidget->setFrameStyle(QFrame::Panel | m_style);
|
||||||
infoWidget->setLineWidth(1);
|
infoWidget->setLineWidth(1);
|
||||||
infoWidget->setAutoFillBackground(true);
|
infoWidget->setAutoFillBackground(true);
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "core_global.h"
|
#include "core_global.h"
|
||||||
#include <coreplugin/id.h>
|
#include <coreplugin/id.h>
|
||||||
|
|
||||||
|
#include <QFrame>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
|
|
||||||
@@ -127,6 +128,9 @@ public:
|
|||||||
InfoBarDisplay(QObject *parent = nullptr);
|
InfoBarDisplay(QObject *parent = nullptr);
|
||||||
void setTarget(QBoxLayout *layout, int index);
|
void setTarget(QBoxLayout *layout, int index);
|
||||||
void setInfoBar(InfoBar *infoBar);
|
void setInfoBar(InfoBar *infoBar);
|
||||||
|
void setStyle(QFrame::Shadow style);
|
||||||
|
|
||||||
|
InfoBar *infoBar() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void update();
|
void update();
|
||||||
@@ -136,6 +140,7 @@ private:
|
|||||||
QList<QWidget *> m_infoWidgets;
|
QList<QWidget *> m_infoWidgets;
|
||||||
InfoBar *m_infoBar = nullptr;
|
InfoBar *m_infoBar = nullptr;
|
||||||
QBoxLayout *m_boxLayout = nullptr;
|
QBoxLayout *m_boxLayout = nullptr;
|
||||||
|
QFrame::Shadow m_style = QFrame::Raised;
|
||||||
int m_boxIndex = 0;
|
int m_boxIndex = 0;
|
||||||
bool m_isShowingDetailsWidget = false;
|
bool m_isShowingDetailsWidget = false;
|
||||||
};
|
};
|
||||||
|
@@ -365,6 +365,11 @@ QStatusBar *MainWindow::statusBar() const
|
|||||||
return m_modeStack->statusBar();
|
return m_modeStack->statusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InfoBar *MainWindow::infoBar() const
|
||||||
|
{
|
||||||
|
return m_modeStack->infoBar();
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::registerDefaultContainers()
|
void MainWindow::registerDefaultContainers()
|
||||||
{
|
{
|
||||||
ActionContainer *menubar = ActionManager::createMenuBar(Constants::MENU_BAR);
|
ActionContainer *menubar = ActionManager::createMenuBar(Constants::MENU_BAR);
|
||||||
|
@@ -46,6 +46,7 @@ namespace Core {
|
|||||||
class EditorManager;
|
class EditorManager;
|
||||||
class ExternalToolManager;
|
class ExternalToolManager;
|
||||||
class IDocument;
|
class IDocument;
|
||||||
|
class InfoBar;
|
||||||
class JsExpander;
|
class JsExpander;
|
||||||
class MessageManager;
|
class MessageManager;
|
||||||
class ModeManager;
|
class ModeManager;
|
||||||
@@ -93,6 +94,7 @@ public:
|
|||||||
virtual QPrinter *printer() const;
|
virtual QPrinter *printer() const;
|
||||||
IContext * currentContextObject() const;
|
IContext * currentContextObject() const;
|
||||||
QStatusBar *statusBar() const;
|
QStatusBar *statusBar() const;
|
||||||
|
InfoBar *infoBar() const;
|
||||||
|
|
||||||
void updateAdditionalContexts(const Context &remove, const Context &add,
|
void updateAdditionalContexts(const Context &remove, const Context &add,
|
||||||
ICore::ContextPriority priority);
|
ICore::ContextPriority priority);
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#include "introductionwidget.h"
|
#include "introductionwidget.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/infobar.h>
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/checkablemessagebox.h>
|
#include <utils/checkablemessagebox.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -47,29 +49,24 @@ namespace Internal {
|
|||||||
|
|
||||||
void IntroductionWidget::askUserAboutIntroduction(QWidget *parent, QSettings *settings)
|
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;
|
return;
|
||||||
auto messageBox = new CheckableMessageBox(parent);
|
|
||||||
messageBox->setWindowTitle(tr("Take a UI Tour"));
|
Core::InfoBarEntry
|
||||||
messageBox->setText(
|
info(kTakeTourSetting,
|
||||||
tr("Would you like to take a quick UI tour? This tour highlights important user "
|
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, "
|
"interface elements and shows how they are used. To take the tour later, "
|
||||||
"select Help > UI Tour."));
|
"select Help > UI Tour."),
|
||||||
messageBox->setCheckBoxVisible(true);
|
Core::InfoBarEntry::GlobalSuppressionEnabled);
|
||||||
messageBox->setCheckBoxText(CheckableMessageBox::msgDoNotAskAgain());
|
info.setCustomButtonInfo(tr("Take UI Tour"), [parent] {
|
||||||
messageBox->setChecked(true);
|
Core::ICore::infoBar()->removeInfo(kTakeTourSetting);
|
||||||
messageBox->setStandardButtons(QDialogButtonBox::Cancel);
|
Core::ICore::infoBar()->globallySuppressInfo(kTakeTourSetting);
|
||||||
QPushButton *tourButton = messageBox->addButton(tr("Take UI Tour"), QDialogButtonBox::AcceptRole);
|
auto intro = new IntroductionWidget(parent);
|
||||||
connect(messageBox, &QDialog::finished, parent, [parent, settings, messageBox, tourButton]() {
|
intro->show();
|
||||||
if (messageBox->isChecked())
|
|
||||||
CheckableMessageBox::doNotAskAgain(settings, kTakeTourSetting);
|
|
||||||
if (messageBox->clickedButton() == tourButton) {
|
|
||||||
auto intro = new IntroductionWidget(parent);
|
|
||||||
intro->show();
|
|
||||||
}
|
|
||||||
messageBox->deleteLater();
|
|
||||||
});
|
});
|
||||||
messageBox->show();
|
Core::ICore::infoBar()->addInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
IntroductionWidget::IntroductionWidget(QWidget *parent)
|
IntroductionWidget::IntroductionWidget(QWidget *parent)
|
||||||
|
Reference in New Issue
Block a user