designmodewidget.cpp 18.9 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** 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 Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
23
24
25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
29
30
31

#include "designmodewidget.h"
#include "qmldesignerconstants.h"
32
#include "styledoutputpaneplaceholder.h"
Marco Bubke's avatar
Marco Bubke committed
33
#include "qmldesignerplugin.h"
34
35
36

#include <model.h>
#include <rewriterview.h>
37
38
#include <componentaction.h>
#include <toolbox.h>
Marco Bubke's avatar
Marco Bubke committed
39
#include <itemlibrarywidget.h>
40

41
#include <coreplugin/coreconstants.h>
42
#include <coreplugin/designmode.h>
43
44
#include <coreplugin/modemanager.h>
#include <coreplugin/outputpane.h>
45
46
47
48
49
50
#include <coreplugin/icore.h>
#include <coreplugin/minisplitter.h>
#include <coreplugin/sidebar.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/openeditorsmodel.h>
#include <coreplugin/editormanager/ieditor.h>
51
#include <coreplugin/editortoolbar.h>
52
53
#include <coreplugin/inavigationwidgetfactory.h>
#include <extensionsystem/pluginmanager.h>
54
55

#include <utils/parameteraction.h>
56
#include <utils/fileutils.h>
57
#include <utils/qtcassert.h>
58
#include <utils/crumblepath.h>
59

60
61
62
63
64
65
66
67
68
69
70
71
72
#include <QSettings>
#include <QEvent>
#include <QDir>
#include <QApplication>
#include <QPlainTextEdit>
#include <QVBoxLayout>
#include <QScrollArea>
#include <QTabWidget>
#include <QToolButton>
#include <QMenu>
#include <QClipboard>
#include <QLabel>
#include <QProgressDialog>
73
#include <QTabWidget>
74
75
76
77
78
79
80
81
82
83
84

using Core::MiniSplitter;
using Core::IEditor;
using Core::EditorManager;

using namespace QmlDesigner;

enum {
    debug = false
};

85
86
87
const char SB_PROJECTS[] = "Projects";
const char SB_FILESYSTEM[] = "FileSystem";
const char SB_OPENDOCUMENTS[] = "OpenDocuments";
88

89
90
91
namespace QmlDesigner {
namespace Internal {

92
DocumentWarningWidget::DocumentWarningWidget(DesignModeWidget *parent) :
93
        Utils::FakeToolTip(parent),
94
        m_errorMessage(new QLabel(tr("Placeholder"), this)),
95
        m_goToError(new QLabel(this)),
96
        m_designModeWidget(parent)
97
{
98
    setWindowFlags(Qt::Widget); //We only want the visual style from a ToolTip
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
    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, SIGNAL(linkActivated(QString)), this, SLOT(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 RewriterView::Error &error)
{
    m_error = error;
118
119
120
    QString str;
    if (error.type() == RewriterView::Error::ParseError) {
        str = tr("%3 (%1:%2)").arg(QString::number(error.line()), QString::number(error.column()), error.description());
121
        m_goToError->show();
122
    }  else if (error.type() == RewriterView::Error::InternalError) {
123
124
        str = tr("Internal error (%1)").arg(error.description());
        m_goToError->hide();
125
    }
126
127
128
129
130

    m_errorMessage->setText(str);
    resize(layout()->totalSizeHint());
}

131
132
133
class ItemLibrarySideBarItem : public Core::SideBarItem
{
public:
Marco Bubke's avatar
Marco Bubke committed
134
    explicit ItemLibrarySideBarItem(QWidget *widget, const QString &id);
135
136
137
138
139
    virtual ~ItemLibrarySideBarItem();

    virtual QList<QToolButton *> createToolBarWidgets();
};

Marco Bubke's avatar
Marco Bubke committed
140
ItemLibrarySideBarItem::ItemLibrarySideBarItem(QWidget *widget, const QString &id) : Core::SideBarItem(widget, id) {}
141
142
143
144
145
146
147
148
149
150
151

ItemLibrarySideBarItem::~ItemLibrarySideBarItem()
{

}

QList<QToolButton *> ItemLibrarySideBarItem::createToolBarWidgets()
{
    return qobject_cast<ItemLibraryWidget*>(widget())->createToolBarWidgets();
}

152
153
154
class NavigatorSideBarItem : public Core::SideBarItem
{
public:
Marco Bubke's avatar
Marco Bubke committed
155
    explicit NavigatorSideBarItem(QWidget *widget, const QString &id);
156
157
158
159
160
    virtual ~NavigatorSideBarItem();

    virtual QList<QToolButton *> createToolBarWidgets();
};

Marco Bubke's avatar
Marco Bubke committed
161
NavigatorSideBarItem::NavigatorSideBarItem(QWidget *widget, const QString &id) : Core::SideBarItem(widget, id) {}
162
163
164
165
166
167
168
169
170
171
172

NavigatorSideBarItem::~NavigatorSideBarItem()
{

}

QList<QToolButton *> NavigatorSideBarItem::createToolBarWidgets()
{
    return qobject_cast<NavigatorWidget*>(widget())->createToolBarWidgets();
}

173
174
void DocumentWarningWidget::goToError()
{
175
    m_designModeWidget->textEditor()->gotoLine(m_error.line(), m_error.column() - 1);
176
    Core::ModeManager::activateMode(Core::Constants::MODE_EDIT);
177
178
179
}

// ---------- DesignModeWidget
Lasse Holmstedt's avatar
Lasse Holmstedt committed
180
DesignModeWidget::DesignModeWidget(QWidget *parent) :
181
    QWidget(parent),
182
    m_mainSplitter(0),
183
184
    m_isDisabled(false),
    m_showSidebars(true),
Kai Koehne's avatar
Kai Koehne committed
185
    m_initStatus(NotInitialized),
186
187
188
    m_warningWidget(0),
    m_navigatorHistoryCounter(-1),
    m_keepNavigatorHistory(false)
189
{
190
    m_outputPlaceholderSplitter = new Core::MiniSplitter;
191
    m_outputPanePlaceholder = new StyledOutputpanePlaceHolder(Core::DesignMode::instance(), m_outputPlaceholderSplitter);
192
193
}

194
195
196
197
DesignModeWidget::~DesignModeWidget()
{
}

198
199
void DesignModeWidget::restoreDefaultView()
{
hjk's avatar
hjk committed
200
    QSettings *settings = Core::ICore::settings();
201
202
203
204
205
206
207
208
    m_leftSideBar->closeAllWidgets();
    m_rightSideBar->closeAllWidgets();
    m_leftSideBar->readSettings(settings,  "none.LeftSideBar");
    m_rightSideBar->readSettings(settings, "none.RightSideBar");
    m_leftSideBar->show();
    m_rightSideBar->show();
}

209
210
211
212
213
214
215
216
217
218
219
220
void DesignModeWidget::toggleLeftSidebar()
{
    if (m_leftSideBar)
        m_leftSideBar->setVisible(!m_leftSideBar->isVisible());
}

void DesignModeWidget::toggleRightSidebar()
{
    if (m_rightSideBar)
        m_rightSideBar->setVisible(!m_rightSideBar->isVisible());
}

221
222
223
224
225
226
227
228
229
230
231
232
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);
}
233

234
235
void DesignModeWidget::readSettings()
{
hjk's avatar
hjk committed
236
    QSettings *settings = Core::ICore::settings();
237
238
239
240
241
242
243

    settings->beginGroup("Bauhaus");
    m_leftSideBar->readSettings(settings, QLatin1String("LeftSideBar"));
    m_rightSideBar->readSettings(settings, QLatin1String("RightSideBar"));
    if (settings->contains("MainSplitter")) {
        const QByteArray splitterState = settings->value("MainSplitter").toByteArray();
        m_mainSplitter->restoreState(splitterState);
244
        m_mainSplitter->setOpaqueResize(); // force opaque resize since it used to be off
245
246
247
248
249
250
    }
    settings->endGroup();
}

void DesignModeWidget::saveSettings()
{
hjk's avatar
hjk committed
251
    QSettings *settings = Core::ICore::settings();
252
253
254
255
256
257
258
259

    settings->beginGroup("Bauhaus");
    m_leftSideBar->saveSettings(settings, QLatin1String("LeftSideBar"));
    m_rightSideBar->saveSettings(settings, QLatin1String("RightSideBar"));
    settings->setValue("MainSplitter", m_mainSplitter->saveState());
    settings->endGroup();
}

Marco Bubke's avatar
Marco Bubke committed
260
void DesignModeWidget::enableWidgets()
261
262
{
    if (debug)
263
264
        qDebug() << Q_FUNC_INFO;
    m_warningWidget->setVisible(false);
265
    viewManager().enableWidgets();
266
267
268
269
    m_leftSideBar->setEnabled(true);
    m_rightSideBar->setEnabled(true);
    m_isDisabled = false;
}
270

Marco Bubke's avatar
Marco Bubke committed
271
void DesignModeWidget::disableWidgets()
272
273
274
{
    if (debug)
        qDebug() << Q_FUNC_INFO;
Marco Bubke's avatar
Marco Bubke committed
275

276
    viewManager().disableWidgets();
277
278
279
280
    m_leftSideBar->setEnabled(false);
    m_rightSideBar->setEnabled(false);
    m_isDisabled = true;
}
281

282
283
284
285
286
void DesignModeWidget::updateErrorStatus(const QList<RewriterView::Error> &errors)
{
    if (debug)
        qDebug() << Q_FUNC_INFO << errors.count();

Marco Bubke's avatar
Marco Bubke committed
287
288
289
290
291
292
    if (m_isDisabled && errors.isEmpty()) {
        enableWidgets();
     } else if (!errors.isEmpty()) {
        disableWidgets();
        showErrorMessage(errors);
    }
293
}
294

Marco Bubke's avatar
Marco Bubke committed
295
TextEditor::ITextEditor *DesignModeWidget::textEditor() const
296
{
Marco Bubke's avatar
Marco Bubke committed
297
    return currentDesignDocument()->textEditor();
298
299
}

Marco Bubke's avatar
Marco Bubke committed
300
void DesignModeWidget::setCurrentDesignDocument(DesignDocument *newDesignDocument)
301
302
{
    if (debug)
Marco Bubke's avatar
Marco Bubke committed
303
        qDebug() << Q_FUNC_INFO << newDesignDocument;
304

Marco Bubke's avatar
Marco Bubke committed
305
    //viewManager().setDesignDocument(newDesignDocument);
306
307


308
309
}

310
311
void DesignModeWidget::setup()
{
312
313
    QList<Core::INavigationWidgetFactory *> factories =
            ExtensionSystem::PluginManager::getObjects<Core::INavigationWidgetFactory>();
314
315
316
317
318

    QWidget *openDocumentsWidget = 0;
    QWidget *projectsExplorer = 0;
    QWidget *fileSystemExplorer = 0;

319
    foreach (Core::INavigationWidgetFactory *factory, factories) {
320
321
        Core::NavigationView navigationView;
        navigationView.widget = 0;
322
        if (factory->id() == "Projects") {
323
324
325
            navigationView = factory->createWidget();
            projectsExplorer = navigationView.widget;
            projectsExplorer->setWindowTitle(tr("Projects"));
326
        } else if (factory->id() == "File System") {
327
328
329
            navigationView = factory->createWidget();
            fileSystemExplorer = navigationView.widget;
            fileSystemExplorer->setWindowTitle(tr("File System"));
330
        } else if (factory->id() == "Open Documents") {
331
332
333
334
335
            navigationView = factory->createWidget();
            openDocumentsWidget = navigationView.widget;
            openDocumentsWidget->setWindowTitle(tr("Open Documents"));
        }

336
337
338
339
        if (navigationView.widget) {
            QByteArray sheet = Utils::FileReader::fetchQrc(":/qmldesigner/stylesheet.css");
            sheet += Utils::FileReader::fetchQrc(":/qmldesigner/scrollbar.css");
            sheet += "QLabel { background-color: #4f4f4f; }";
340
            navigationView.widget->setStyleSheet(QString::fromUtf8(sheet));
341
        }
342
343
    }

344

Marco Bubke's avatar
Marco Bubke committed
345
    m_toolBar = Core::EditorManager::createToolBar(this);
346
347
348
349
350
351
352
353

    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);

354
355
356
    QList<Core::SideBarItem*> sideBarItems;
    QList<Core::SideBarItem*> leftSideBarItems;
    QList<Core::SideBarItem*> rightSideBarItems;
357

358
359
360
361
362
363
364
365
366
367
368
369
370
    foreach (const WidgetInfo &widgetInfo, viewManager().widgetInfos()) {
        if (widgetInfo.placementHint == widgetInfo.LeftPane) {
            Core::SideBarItem *sideBarItem = new NavigatorSideBarItem(widgetInfo.widget, widgetInfo.uniqueId);
            sideBarItems.append(sideBarItem);
            leftSideBarItems.append(sideBarItem);
        }

        if (widgetInfo.placementHint == widgetInfo.RightPane) {
            Core::SideBarItem *sideBarItem = new NavigatorSideBarItem(widgetInfo.widget, widgetInfo.uniqueId);
            sideBarItems.append(sideBarItem);
            rightSideBarItems.append(sideBarItem);
        }
    }
371
372

    if (projectsExplorer) {
373
        Core::SideBarItem *projectExplorerItem = new Core::SideBarItem(projectsExplorer, QLatin1String(SB_PROJECTS));
374
        sideBarItems.append(projectExplorerItem);
375
376
377
    }

    if (fileSystemExplorer) {
378
        Core::SideBarItem *fileSystemExplorerItem = new Core::SideBarItem(fileSystemExplorer, QLatin1String(SB_FILESYSTEM));
379
        sideBarItems.append(fileSystemExplorerItem);
380
381
    }

382
    if (openDocumentsWidget) {
383
        Core::SideBarItem *openDocumentsItem = new Core::SideBarItem(openDocumentsWidget, QLatin1String(SB_OPENDOCUMENTS));
384
        sideBarItems.append(openDocumentsItem);
385
386
    }

387
388
    m_leftSideBar.reset(new Core::SideBar(sideBarItems, leftSideBarItems));
    m_rightSideBar.reset(new Core::SideBar(sideBarItems, rightSideBarItems));
389

390
391
    connect(m_leftSideBar.data(), SIGNAL(availableItemsChanged()), SLOT(updateAvailableSidebarItemsRight()));
    connect(m_rightSideBar.data(), SIGNAL(availableItemsChanged()), SLOT(updateAvailableSidebarItemsLeft()));
392

Kai Koehne's avatar
Kai Koehne committed
393
394
395
    connect(Core::ICore::instance(), SIGNAL(coreAboutToClose()),
            this, SLOT(deleteSidebarWidgets()));

Marco Bubke's avatar
Marco Bubke committed
396
397
    m_toolBar->setToolbarCreationFlags(Core::EditorToolBar::FlagsStandalone);
    m_toolBar->setNavigationVisible(true);
398

Marco Bubke's avatar
Marco Bubke committed
399
400
    connect(m_toolBar, SIGNAL(goForwardClicked()), this, SLOT(toolBarOnGoForwardClicked()));
    connect(m_toolBar, SIGNAL(goBackClicked()), this, SLOT(toolBarOnGoBackClicked()));
Marco Bubke's avatar
Marco Bubke committed
401
402
403

    if (currentDesignDocument())
        setupNavigatorHistory(currentDesignDocument()->textEditor());
404
405

    // m_mainSplitter area:
406
    m_mainSplitter->addWidget(m_leftSideBar.data());
407
    m_mainSplitter->addWidget(createCenterWidget());
408
    m_mainSplitter->addWidget(m_rightSideBar.data());
409
410
411
412
413
414
415
416
417
418
419

    // 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);
420
    viewManager().enableWidgets();
421
422
    m_leftSideBar->setEnabled(true);
    m_rightSideBar->setEnabled(true);
423
424
    m_leftSideBar->setCloseWhenEmpty(true);
    m_rightSideBar->setCloseWhenEmpty(true);
425
426
427
428
429
430

    readSettings();

    show();
}

431
432
433
void DesignModeWidget::updateAvailableSidebarItemsRight()
{
    // event comes from m_leftSidebar, so update right side.
434
    m_rightSideBar->setUnavailableItemIds(m_leftSideBar->unavailableItemIds());
435
436
437
438
439
}

void DesignModeWidget::updateAvailableSidebarItemsLeft()
{
    // event comes from m_rightSidebar, so update left side.
440
    m_leftSideBar->setUnavailableItemIds(m_rightSideBar->unavailableItemIds());
441
442
}

Kai Koehne's avatar
Kai Koehne committed
443
444
void DesignModeWidget::deleteSidebarWidgets()
{
445
446
    m_leftSideBar.reset();
    m_rightSideBar.reset();
Kai Koehne's avatar
Kai Koehne committed
447
448
}

449
450
451
452
void DesignModeWidget::qmlPuppetCrashed()
{
    QList<RewriterView::Error> errorList;
    RewriterView::Error error(tr("Qt Quick emulation layer crashed"));
Marco Bubke's avatar
Marco Bubke committed
453
454
455
456
    errorList.append(error);

    disableWidgets();
    showErrorMessage(errorList);
457
458
}

Marco Bubke's avatar
Marco Bubke committed
459
void DesignModeWidget::toolBarOnGoBackClicked()
460
461
462
463
{
    if (m_navigatorHistoryCounter > 0) {
        --m_navigatorHistoryCounter;
        m_keepNavigatorHistory = true;
hjk's avatar
hjk committed
464
        Core::EditorManager::openEditor(m_navigatorHistory.at(m_navigatorHistoryCounter));
465
466
467
468
        m_keepNavigatorHistory = false;
    }
}

Marco Bubke's avatar
Marco Bubke committed
469
void DesignModeWidget::toolBarOnGoForwardClicked()
470
471
472
473
{
    if (m_navigatorHistoryCounter < (m_navigatorHistory.size() - 1)) {
        ++m_navigatorHistoryCounter;
        m_keepNavigatorHistory = true;
hjk's avatar
hjk committed
474
        Core::EditorManager::openEditor(m_navigatorHistory.at(m_navigatorHistoryCounter));
475
476
477
478
        m_keepNavigatorHistory = false;
    }
}

Marco Bubke's avatar
Marco Bubke committed
479
DesignDocument *DesignModeWidget::currentDesignDocument() const
480
{
Marco Bubke's avatar
Marco Bubke committed
481
    return QmlDesignerPlugin::instance()->documentManager().currentDesignDocument();
482
483
}

Marco Bubke's avatar
Marco Bubke committed
484
ViewManager &DesignModeWidget::viewManager()
485
{
Marco Bubke's avatar
Marco Bubke committed
486
    return QmlDesignerPlugin::instance()->viewManager();
487
488
}

489
490
491
492
493
494
495
void DesignModeWidget::resizeEvent(QResizeEvent *event)
{
    if (m_warningWidget)
        m_warningWidget->move(QPoint(event->size().width() / 2, event->size().height() / 2));
    QWidget::resizeEvent(event);
}

Marco Bubke's avatar
Marco Bubke committed
496
void DesignModeWidget::setupNavigatorHistory(Core::IEditor *editor)
497
{
Marco Bubke's avatar
Marco Bubke committed
498
499
    if (!m_keepNavigatorHistory)
        addNavigatorHistoryEntry(editor->document()->fileName());
500

501
502
    const bool canGoBack = m_navigatorHistoryCounter > 0;
    const bool canGoForward = m_navigatorHistoryCounter < (m_navigatorHistory.size() - 1);
Marco Bubke's avatar
Marco Bubke committed
503
504
505
    m_toolBar->setCanGoBack(canGoBack);
    m_toolBar->setCanGoForward(canGoForward);
    m_toolBar->setCurrentEditor(editor);
506
507
508
509
510
511
512
513
514
515
516
517
}

void DesignModeWidget::addNavigatorHistoryEntry(const QString &fileName)
{
    if (m_navigatorHistoryCounter > 0)
        m_navigatorHistory.insert(m_navigatorHistoryCounter + 1, fileName);
    else
        m_navigatorHistory.append(fileName);

    ++m_navigatorHistoryCounter;
}

518
519
520
521
522
523
524
525
526
527
static QWidget *createWidgetsInTabWidget(const QList<WidgetInfo> &widgetInfos)
{
    QTabWidget *tabWidget = new QTabWidget;

    foreach (const WidgetInfo &widgetInfo, widgetInfos)
        tabWidget->addTab(widgetInfo.widget, widgetInfo.tabName);

    return tabWidget;
}

Thomas Hartmann's avatar
Thomas Hartmann committed
528
QWidget *DesignModeWidget::createCenterWidget()
529
530
531
532
533
534
{
    QWidget *centerWidget = new QWidget;

    QVBoxLayout *rightLayout = new QVBoxLayout(centerWidget);
    rightLayout->setMargin(0);
    rightLayout->setSpacing(0);
Marco Bubke's avatar
Marco Bubke committed
535
    rightLayout->addWidget(m_toolBar);
536
537


538
    //### we now own these here
539
540
541
542
543
    QList<WidgetInfo> topWidgetInfos;
    foreach (const WidgetInfo &widgetInfo, viewManager().widgetInfos()) {
        if (widgetInfo.placementHint == widgetInfo.TopPane)
            topWidgetInfos.append(widgetInfo);
    }
544

545
546
547
548
    if (topWidgetInfos.count() == 1)
        rightLayout->addWidget(topWidgetInfos.first().widget);
    else
        rightLayout->addWidget(createWidgetsInTabWidget(topWidgetInfos));
549

550
551
552
553
554
    QList<WidgetInfo> centralWidgetInfos;
    foreach (const WidgetInfo &widgetInfo, viewManager().widgetInfos()) {
        if (widgetInfo.placementHint == widgetInfo.CentralPane)
            centralWidgetInfos.append(widgetInfo);
    }
555
556

    // editor and output panes
557
558
559
560
561
    if (centralWidgetInfos.count() == 1)
        m_outputPlaceholderSplitter->addWidget(centralWidgetInfos.first().widget);
    else
         m_outputPlaceholderSplitter->addWidget(createWidgetsInTabWidget(centralWidgetInfos));

562
563
564
565
566
567
568
569
570
571
    m_outputPlaceholderSplitter->addWidget(m_outputPanePlaceholder);
    m_outputPlaceholderSplitter->setStretchFactor(0, 10);
    m_outputPlaceholderSplitter->setStretchFactor(1, 0);
    m_outputPlaceholderSplitter->setOrientation(Qt::Vertical);

    rightLayout->addWidget(m_outputPlaceholderSplitter);

    return centerWidget;
}

Marco Bubke's avatar
Marco Bubke committed
572
573
574
575
576
577
578
void DesignModeWidget::showErrorMessage(const QList<RewriterView::Error> &errors)
{
    Q_ASSERT(!errors.isEmpty());
    m_warningWidget->setError(errors.first());
    m_warningWidget->setVisible(true);
    m_warningWidget->move(width() / 2, height() / 2);
}
579

580
581
QString DesignModeWidget::contextHelpId() const
{
Marco Bubke's avatar
Marco Bubke committed
582
583
    if (currentDesignDocument())
        return currentDesignDocument()->contextHelpId();
584
585
586
    return QString();
}

Marco Bubke's avatar
Marco Bubke committed
587
588
589
590
591
592
593
594
595
596
void DesignModeWidget::initialize()
{
    if (m_initStatus == NotInitialized) {
        m_initStatus = Initializing;
        setup();
    }

    m_initStatus = Initialized;
}

597
598
} // namespace Internal
} // namespace Designer