1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
|
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "designmodewidget.h"
#include "styledoutputpaneplaceholder.h"
#include "qmldesignerplugin.h"
#include "crumblebar.h"
#include <rewriterview.h>
#include <nodeinstanceview.h>
#include <itemlibrarywidget.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/designmode.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/minisplitter.h>
#include <coreplugin/sidebar.h>
#include <coreplugin/editortoolbar.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/idocument.h>
#include <coreplugin/inavigationwidgetfactory.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/fileutils.h>
#include <QSettings>
#include <QVBoxLayout>
#include <QToolButton>
#include <QLabel>
#include <QTabWidget>
#include <QToolBar>
using Core::MiniSplitter;
using Core::IEditor;
using Core::EditorManager;
using namespace QmlDesigner;
enum {
debug = false
};
const char SB_PROJECTS[] = "Projects";
const char SB_FILESYSTEM[] = "FileSystem";
const char SB_OPENDOCUMENTS[] = "OpenDocuments";
namespace QmlDesigner {
namespace Internal {
DocumentWarningWidget::DocumentWarningWidget(DesignModeWidget *parent) :
Utils::FakeToolTip(parent),
m_errorMessage(new QLabel(tr("Placeholder"), this)),
m_goToError(new QLabel(this)),
m_designModeWidget(parent)
{
setWindowFlags(Qt::Widget); //We only want the visual style from a ToolTip
setForegroundRole(QPalette::ToolTipText);
setBackgroundRole(QPalette::ToolTipBase);
setAutoFillBackground(true);
m_errorMessage->setForegroundRole(QPalette::ToolTipText);
m_goToError->setText(tr("<a href=\"goToError\">Go to error</a>"));
m_goToError->setForegroundRole(QPalette::Link);
connect(m_goToError, &QLabel::linkActivated, this, &DocumentWarningWidget::goToError);
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setMargin(20);
layout->setSpacing(5);
layout->addWidget(m_errorMessage);
layout->addWidget(m_goToError, 1, Qt::AlignRight);
}
void DocumentWarningWidget::setError(const RewriterError &error)
{
m_error = error;
QString str;
if (error.type() == RewriterError::ParseError) {
str = tr("%3 (%1:%2)").arg(QString::number(error.line()), QString::number(error.column()), error.description());
m_goToError->show();
} else if (error.type() == RewriterError::InternalError) {
str = tr("Internal error (%1)").arg(error.description());
m_goToError->hide();
}
str.prepend(tr("Cannot open this QML document because of an error in the QML file:\n\n"));
m_errorMessage->setText(str);
resize(layout()->totalSizeHint());
}
class ItemLibrarySideBarItem : public Core::SideBarItem
{
public:
explicit ItemLibrarySideBarItem(QWidget *widget, const QString &id);
virtual ~ItemLibrarySideBarItem();
virtual QList<QToolButton *> createToolBarWidgets();
};
ItemLibrarySideBarItem::ItemLibrarySideBarItem(QWidget *widget, const QString &id) : Core::SideBarItem(widget, id) {}
ItemLibrarySideBarItem::~ItemLibrarySideBarItem()
{
}
QList<QToolButton *> ItemLibrarySideBarItem::createToolBarWidgets()
{
return qobject_cast<ItemLibraryWidget*>(widget())->createToolBarWidgets();
}
class DesignerSideBarItem : public Core::SideBarItem
{
public:
explicit DesignerSideBarItem(QWidget *widget, WidgetInfo::ToolBarWidgetFactoryInterface *createToolBarWidgets, const QString &id);
virtual ~DesignerSideBarItem();
virtual QList<QToolButton *> createToolBarWidgets();
private:
WidgetInfo::ToolBarWidgetFactoryInterface *m_toolBarWidgetFactory;
};
DesignerSideBarItem::DesignerSideBarItem(QWidget *widget, WidgetInfo::ToolBarWidgetFactoryInterface *toolBarWidgetFactory, const QString &id)
: Core::SideBarItem(widget, id) , m_toolBarWidgetFactory(toolBarWidgetFactory)
{
}
DesignerSideBarItem::~DesignerSideBarItem()
{
delete m_toolBarWidgetFactory;
}
QList<QToolButton *> DesignerSideBarItem::createToolBarWidgets()
{
if (m_toolBarWidgetFactory)
return m_toolBarWidgetFactory->createToolBarWidgets();
return QList<QToolButton *>();
}
void DocumentWarningWidget::goToError()
{
m_designModeWidget->textEditor()->gotoLine(m_error.line(), m_error.column() - 1);
Core::ModeManager::activateMode(Core::Constants::MODE_EDIT);
}
// ---------- DesignModeWidget
DesignModeWidget::DesignModeWidget(QWidget *parent) :
QWidget(parent),
m_mainSplitter(0),
m_toolBar(new Core::EditorToolBar(this)),
m_crumbleBar(new CrumbleBar(this)),
m_isDisabled(false),
m_showSidebars(true),
m_initStatus(NotInitialized),
m_warningWidget(0),
m_navigatorHistoryCounter(-1),
m_keepNavigatorHistory(false)
{
QObject::connect(viewManager().nodeInstanceView(), SIGNAL(qmlPuppetCrashed()), this, SLOT(showQmlPuppetCrashedError()));
}
DesignModeWidget::~DesignModeWidget()
{
m_leftSideBar.reset();
m_rightSideBar.reset();
foreach (QPointer<QWidget> widget, m_viewWidgets) {
if (widget)
widget.clear();
}
}
void DesignModeWidget::restoreDefaultView()
{
QSettings *settings = Core::ICore::settings();
m_leftSideBar->closeAllWidgets();
m_rightSideBar->closeAllWidgets();
m_leftSideBar->readSettings(settings, "none.LeftSideBar");
m_rightSideBar->readSettings(settings, "none.RightSideBar");
m_leftSideBar->show();
m_rightSideBar->show();
}
void DesignModeWidget::toggleLeftSidebar()
{
if (m_leftSideBar)
m_leftSideBar->setVisible(!m_leftSideBar->isVisible());
}
void DesignModeWidget::toggleRightSidebar()
{
if (m_rightSideBar)
m_rightSideBar->setVisible(!m_rightSideBar->isVisible());
}
void DesignModeWidget::toggleSidebars()
{
if (m_initStatus == Initializing)
return;
m_showSidebars = !m_showSidebars;
if (m_leftSideBar)
m_leftSideBar->setVisible(m_showSidebars);
if (m_rightSideBar)
m_rightSideBar->setVisible(m_showSidebars);
if (m_topSideBar)
m_topSideBar->setVisible(m_showSidebars);
}
void DesignModeWidget::readSettings()
{
QSettings *settings = Core::ICore::settings();
settings->beginGroup("Bauhaus");
m_leftSideBar->readSettings(settings, QStringLiteral("LeftSideBar"));
m_rightSideBar->readSettings(settings, QStringLiteral("RightSideBar"));
if (settings->contains("MainSplitter")) {
const QByteArray splitterState = settings->value("MainSplitter").toByteArray();
m_mainSplitter->restoreState(splitterState);
m_mainSplitter->setOpaqueResize(); // force opaque resize since it used to be off
}
settings->endGroup();
}
void DesignModeWidget::saveSettings()
{
QSettings *settings = Core::ICore::settings();
settings->beginGroup("Bauhaus");
m_leftSideBar->saveSettings(settings, QStringLiteral("LeftSideBar"));
m_rightSideBar->saveSettings(settings, QStringLiteral("RightSideBar"));
settings->setValue("MainSplitter", m_mainSplitter->saveState());
settings->endGroup();
}
void DesignModeWidget::enableWidgets()
{
if (debug)
qDebug() << Q_FUNC_INFO;
m_warningWidget->setVisible(false);
viewManager().enableWidgets();
m_leftSideBar->setEnabled(true);
m_rightSideBar->setEnabled(true);
m_isDisabled = false;
}
void DesignModeWidget::disableWidgets()
{
if (debug)
qDebug() << Q_FUNC_INFO;
viewManager().disableWidgets();
m_leftSideBar->setEnabled(false);
m_rightSideBar->setEnabled(false);
m_isDisabled = true;
}
void DesignModeWidget::updateErrorStatus(const QList<RewriterError> &errors)
{
if (debug)
qDebug() << Q_FUNC_INFO << errors.count();
if (m_isDisabled && errors.isEmpty()) {
enableWidgets();
} else if (!errors.isEmpty()) {
disableWidgets();
showErrorMessage(errors);
}
}
TextEditor::BaseTextEditor *DesignModeWidget::textEditor() const
{
return currentDesignDocument()->textEditor();
}
void DesignModeWidget::setCurrentDesignDocument(DesignDocument *newDesignDocument)
{
if (debug)
qDebug() << Q_FUNC_INFO << newDesignDocument;
//viewManager().setDesignDocument(newDesignDocument);
}
static void hideToolButtons(QList<QToolButton*> &buttons)
{
foreach (QToolButton *button, buttons)
button->hide();
}
void DesignModeWidget::setup()
{
QList<Core::INavigationWidgetFactory *> factories =
ExtensionSystem::PluginManager::getObjects<Core::INavigationWidgetFactory>();
QWidget *openDocumentsWidget = 0;
QWidget *projectsExplorer = 0;
QWidget *fileSystemExplorer = 0;
foreach (Core::INavigationWidgetFactory *factory, factories) {
Core::NavigationView navigationView;
navigationView.widget = 0;
if (factory->id() == "Projects") {
navigationView = factory->createWidget();
projectsExplorer = navigationView.widget;
hideToolButtons(navigationView.dockToolBarWidgets);
projectsExplorer->setWindowTitle(tr("Projects"));
} else if (factory->id() == "File System") {
navigationView = factory->createWidget();
fileSystemExplorer = navigationView.widget;
hideToolButtons(navigationView.dockToolBarWidgets);
fileSystemExplorer->setWindowTitle(tr("File System"));
} else if (factory->id() == "Open Documents") {
navigationView = factory->createWidget();
openDocumentsWidget = navigationView.widget;
hideToolButtons(navigationView.dockToolBarWidgets);
openDocumentsWidget->setWindowTitle(tr("Open Documents"));
}
if (navigationView.widget) {
QByteArray sheet = Utils::FileReader::fetchQrc(":/qmldesigner/stylesheet.css");
sheet += Utils::FileReader::fetchQrc(":/qmldesigner/scrollbar.css");
sheet += "QLabel { background-color: #4f4f4f; }";
navigationView.widget->setStyleSheet(QString::fromUtf8(sheet));
}
}
QToolBar *toolBar = new QToolBar;
toolBar->addAction(viewManager().componentViewAction());
toolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
m_toolBar->addCenterToolBar(toolBar);
m_mainSplitter = new MiniSplitter(this);
m_mainSplitter->setObjectName("mainSplitter");
// warning frame should be not in layout, but still child of the widget
m_warningWidget = new DocumentWarningWidget(this);
m_warningWidget->setVisible(false);
QList<Core::SideBarItem*> sideBarItems;
QList<Core::SideBarItem*> leftSideBarItems;
QList<Core::SideBarItem*> rightSideBarItems;
foreach (const WidgetInfo &widgetInfo, viewManager().widgetInfos()) {
if (widgetInfo.placementHint == widgetInfo.LeftPane) {
Core::SideBarItem *sideBarItem = new DesignerSideBarItem(widgetInfo.widget, widgetInfo.toolBarWidgetFactory, widgetInfo.uniqueId);
sideBarItems.append(sideBarItem);
leftSideBarItems.append(sideBarItem);
}
if (widgetInfo.placementHint == widgetInfo.RightPane) {
Core::SideBarItem *sideBarItem = new DesignerSideBarItem(widgetInfo.widget, widgetInfo.toolBarWidgetFactory, widgetInfo.uniqueId);
sideBarItems.append(sideBarItem);
rightSideBarItems.append(sideBarItem);
}
m_viewWidgets.append(widgetInfo.widget);
}
if (projectsExplorer) {
Core::SideBarItem *projectExplorerItem = new Core::SideBarItem(projectsExplorer, QLatin1String(SB_PROJECTS));
sideBarItems.append(projectExplorerItem);
}
if (fileSystemExplorer) {
Core::SideBarItem *fileSystemExplorerItem = new Core::SideBarItem(fileSystemExplorer, QLatin1String(SB_FILESYSTEM));
sideBarItems.append(fileSystemExplorerItem);
}
if (openDocumentsWidget) {
Core::SideBarItem *openDocumentsItem = new Core::SideBarItem(openDocumentsWidget, QLatin1String(SB_OPENDOCUMENTS));
sideBarItems.append(openDocumentsItem);
}
m_leftSideBar.reset(new Core::SideBar(sideBarItems, leftSideBarItems));
m_rightSideBar.reset(new Core::SideBar(sideBarItems, rightSideBarItems));
connect(m_leftSideBar.data(), SIGNAL(availableItemsChanged()), SLOT(updateAvailableSidebarItemsRight()));
connect(m_rightSideBar.data(), SIGNAL(availableItemsChanged()), SLOT(updateAvailableSidebarItemsLeft()));
connect(Core::ICore::instance(), SIGNAL(coreAboutToClose()),
this, SLOT(deleteSidebarWidgets()));
m_toolBar->setToolbarCreationFlags(Core::EditorToolBar::FlagsStandalone);
m_toolBar->setNavigationVisible(true);
connect(m_toolBar, &Core::EditorToolBar::goForwardClicked, this, &DesignModeWidget::toolBarOnGoForwardClicked);
connect(m_toolBar, &Core::EditorToolBar::goBackClicked, this, &DesignModeWidget::toolBarOnGoBackClicked);
if (currentDesignDocument())
setupNavigatorHistory(currentDesignDocument()->textEditor());
// m_mainSplitter area:
m_mainSplitter->addWidget(m_leftSideBar.data());
m_mainSplitter->addWidget(createCenterWidget());
m_mainSplitter->addWidget(m_rightSideBar.data());
// Finishing touches:
m_mainSplitter->setStretchFactor(1, 1);
m_mainSplitter->setSizes(QList<int>() << 150 << 300 << 150);
QLayout *mainLayout = new QBoxLayout(QBoxLayout::RightToLeft, this);
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
mainLayout->addWidget(m_mainSplitter);
m_warningWidget->setVisible(false);
viewManager().enableWidgets();
m_leftSideBar->setEnabled(true);
m_rightSideBar->setEnabled(true);
m_leftSideBar->setCloseWhenEmpty(false);
m_rightSideBar->setCloseWhenEmpty(false);
readSettings();
show();
}
void DesignModeWidget::updateAvailableSidebarItemsRight()
{
// event comes from m_leftSidebar, so update right side.
m_rightSideBar->setUnavailableItemIds(m_leftSideBar->unavailableItemIds());
}
void DesignModeWidget::updateAvailableSidebarItemsLeft()
{
// event comes from m_rightSidebar, so update left side.
m_leftSideBar->setUnavailableItemIds(m_rightSideBar->unavailableItemIds());
}
void DesignModeWidget::deleteSidebarWidgets()
{
m_leftSideBar.reset();
m_rightSideBar.reset();
}
void DesignModeWidget::showQmlPuppetCrashedError()
{
QList<RewriterError> errorList;
RewriterError error(tr("Qt Quick emulation layer crashed"));
errorList.append(error);
disableWidgets();
showErrorMessage(errorList);
}
void DesignModeWidget::toolBarOnGoBackClicked()
{
if (m_navigatorHistoryCounter > 0) {
--m_navigatorHistoryCounter;
m_keepNavigatorHistory = true;
Core::EditorManager::openEditor(m_navigatorHistory.at(m_navigatorHistoryCounter),
Core::Id(), Core::EditorManager::DoNotMakeVisible);
m_keepNavigatorHistory = false;
}
}
void DesignModeWidget::toolBarOnGoForwardClicked()
{
if (m_navigatorHistoryCounter < (m_navigatorHistory.size() - 1)) {
++m_navigatorHistoryCounter;
m_keepNavigatorHistory = true;
Core::EditorManager::openEditor(m_navigatorHistory.at(m_navigatorHistoryCounter),
Core::Id(), Core::EditorManager::DoNotMakeVisible);
m_keepNavigatorHistory = false;
}
}
DesignDocument *DesignModeWidget::currentDesignDocument() const
{
return QmlDesignerPlugin::instance()->documentManager().currentDesignDocument();
}
ViewManager &DesignModeWidget::viewManager()
{
return QmlDesignerPlugin::instance()->viewManager();
}
void DesignModeWidget::resizeEvent(QResizeEvent *event)
{
if (m_warningWidget) {
QPoint warningWidgetCenterPoint = m_warningWidget->rect().center();
m_warningWidget->move(QPoint(event->size().width() / 2, event->size().height() / 2) - warningWidgetCenterPoint);
}
QWidget::resizeEvent(event);
}
void DesignModeWidget::setupNavigatorHistory(Core::IEditor *editor)
{
if (!m_keepNavigatorHistory)
addNavigatorHistoryEntry(editor->document()->filePath().toString());
const bool canGoBack = m_navigatorHistoryCounter > 0;
const bool canGoForward = m_navigatorHistoryCounter < (m_navigatorHistory.size() - 1);
m_toolBar->setCanGoBack(canGoBack);
m_toolBar->setCanGoForward(canGoForward);
m_toolBar->setCurrentEditor(editor);
}
void DesignModeWidget::addNavigatorHistoryEntry(const QString &fileName)
{
if (m_navigatorHistoryCounter > 0)
m_navigatorHistory.insert(m_navigatorHistoryCounter + 1, fileName);
else
m_navigatorHistory.append(fileName);
++m_navigatorHistoryCounter;
}
static QWidget *createWidgetsInTabWidget(const QList<WidgetInfo> &widgetInfos)
{
QTabWidget *tabWidget = new QTabWidget;
foreach (const WidgetInfo &widgetInfo, widgetInfos)
tabWidget->addTab(widgetInfo.widget, widgetInfo.tabName);
return tabWidget;
}
static QWidget *createTopSideBarWidget(const QList<WidgetInfo> &widgetInfos)
{
//### we now own these here
QList<WidgetInfo> topWidgetInfos;
foreach (const WidgetInfo &widgetInfo, widgetInfos) {
if (widgetInfo.placementHint == widgetInfo.TopPane)
topWidgetInfos.append(widgetInfo);
}
if (topWidgetInfos.count() == 1)
return topWidgetInfos.first().widget;
else
return createWidgetsInTabWidget(topWidgetInfos);
}
static Core::MiniSplitter *createCentralSplitter(const QList<WidgetInfo> &widgetInfos)
{
QList<WidgetInfo> centralWidgetInfos;
foreach (const WidgetInfo &widgetInfo, widgetInfos) {
if (widgetInfo.placementHint == widgetInfo.CentralPane)
centralWidgetInfos.append(widgetInfo);
}
// editor and output panes
Core::MiniSplitter *outputPlaceholderSplitter = new Core::MiniSplitter;
outputPlaceholderSplitter->setStretchFactor(0, 10);
outputPlaceholderSplitter->setStretchFactor(1, 0);
outputPlaceholderSplitter->setOrientation(Qt::Vertical);
StyledOutputpanePlaceHolder *outputPanePlaceholder = new StyledOutputpanePlaceHolder(Core::DesignMode::instance(), outputPlaceholderSplitter);
if (centralWidgetInfos.count() == 1)
outputPlaceholderSplitter->addWidget(centralWidgetInfos.first().widget);
else
outputPlaceholderSplitter->addWidget(createWidgetsInTabWidget(centralWidgetInfos));
outputPlaceholderSplitter->addWidget(outputPanePlaceholder);
return outputPlaceholderSplitter;
}
QWidget *DesignModeWidget::createCenterWidget()
{
QWidget *centerWidget = new QWidget;
QVBoxLayout *horizontalLayout = new QVBoxLayout(centerWidget);
horizontalLayout->setMargin(0);
horizontalLayout->setSpacing(0);
horizontalLayout->addWidget(m_toolBar);
horizontalLayout->addWidget(createCrumbleBarFrame());
m_topSideBar = createTopSideBarWidget(viewManager().widgetInfos());
horizontalLayout->addWidget(m_topSideBar.data());
horizontalLayout->addWidget(createCentralSplitter(viewManager().widgetInfos()));
return centerWidget;
}
QWidget *DesignModeWidget::createCrumbleBarFrame()
{
QFrame *frame = new QFrame(this);
frame->setStyleSheet("background-color: #4e4e4e;");
frame->setFrameShape(QFrame::NoFrame);
QHBoxLayout *layout = new QHBoxLayout(frame);
layout->setMargin(0);
layout->setSpacing(0);
frame->setLayout(layout);
layout->addWidget(m_crumbleBar->crumblePath());
frame->setProperty("panelwidget", true);
frame->setProperty("panelwidget_singlerow", false);
return frame;
}
void DesignModeWidget::showErrorMessage(const QList<RewriterError> &errors)
{
Q_ASSERT(!errors.isEmpty());
m_warningWidget->setError(errors.first());
m_warningWidget->setVisible(true);
m_warningWidget->move(width() / 2, height() / 2);
}
CrumbleBar *DesignModeWidget::crumbleBar() const
{
return m_crumbleBar;
}
QString DesignModeWidget::contextHelpId() const
{
if (currentDesignDocument())
return currentDesignDocument()->contextHelpId();
return QString();
}
void DesignModeWidget::initialize()
{
if (m_initStatus == NotInitialized) {
m_initStatus = Initializing;
setup();
}
m_initStatus = Initialized;
}
} // namespace Internal
} // namespace Designer
|