void tst_QToolBar::visibilityChanged()
{
    QMainWindow mw;
    QToolBar tb;
    QSignalSpy spy(&tb, SIGNAL(visibilityChanged(bool)));

    mw.addToolBar(&tb);
    mw.show();

    QCOMPARE(spy.count(), 1);
    QCOMPARE(spy.at(0).at(0).toBool(), true);
    spy.clear();

    tb.hide();
    QCOMPARE(spy.count(), 1);
    QCOMPARE(spy.at(0).at(0).toBool(), false);
    spy.clear();

    tb.hide();
    QCOMPARE(spy.count(), 0);

    tb.show();
    QCOMPARE(spy.count(), 1);
    QCOMPARE(spy.at(0).at(0).toBool(), true);
    spy.clear();

    tb.show();
    QCOMPARE(spy.count(), 0);
}
Пример #2
0
void FullscreenSpacerLabel::mouseMoveEvent (QMouseEvent *event)
{
	MainWindow *wnd = Core::Instance ().GetReallyMainWindow ();
	if (wnd && (wnd->windowState () == Qt::WindowFullScreen))
	{
		QMenuBar *menu = wnd->findChild<QMenuBar*> ("MenuBar_");
		if (!menu)
		{
			qWarning () << Q_FUNC_INFO
						<< "menu is null";
			return;
		}
		QToolBar *toolbar = wnd->findChild<QToolBar*> ("MainToolbar_");
		if (!toolbar)
		{
			qWarning () << Q_FUNC_INFO
						<< "toolbar is null";
			return;
		}
		LeechCraft::TabWidget *tabwidget = wnd->GetTabWidget ();
		if (!tabwidget)
		{
			qWarning () << Q_FUNC_INFO
						<< "tabwidget is null";
			return;
		}
		QToolBar *bar = Core::Instance ().GetToolBar (tabwidget->currentIndex ());
		if (!bar)
		{
			qWarning () << Q_FUNC_INFO
						<< "bar is null";
			return;
		}

		const bool asButton = XmlSettingsManager::Instance ()->property ("ShowMenuBarAsButton").toBool ();

		if (event->y () < 5)
		{
			if (asButton)
				menu->hide ();
			else if (menu->isHidden ())
				menu->show ();

			if (toolbar->isHidden ())
				toolbar->show ();
			if (bar && bar->isHidden ())
				bar->show ();
		}
		else
		{
			if (!menu->isHidden ())
				menu->hide ();
			if (!toolbar->isHidden ())
				toolbar->hide ();
			if (bar && !bar->isHidden ())
				bar->hide ();
		}
	}
}
Пример #3
0
//==============================================================
void TulipApp::clearInterface() {
  //Dock widgets
  QObjectList objectList=this->children();

  for(QObjectList::iterator it=objectList.begin(); it!=objectList.end(); ++it) {
    QDockWidget *widget=dynamic_cast<QDockWidget *>(*it);

    if(widget) {
      removeDockWidget(widget);
      widget->hide();
    }

    QToolBar *tb = dynamic_cast<QToolBar *>(*it);

    if (tb && tb != toolBar && tb != graphToolBar) {
      removeToolBar(tb);
      tb->hide();
      tb->setParent(0);
    }
  }

  menuBar()->clear();
  toolBar->clear();
  graphToolBar->clear();
}
Пример #4
0
bool MWToolBarManagerImpl::eventFilter(QObject *obj, QEvent *event) {
	QEvent::Type t = event->type();
	if (t == QEvent::ActionAdded || t == QEvent::ActionRemoved) { 
#ifdef Q_OS_WIN
        // mega-hack -> update all the area below toolbar by extra show()/hide() for .NET style 
        // if OpenGL widget present (-> WA_NativeWindow is set)
        // if not done .NET style will leave artifacts on toolbar
        QToolBar* tb = qobject_cast<QToolBar*>(obj);
        tb->hide();
#endif
        updateToolbarVisibilty();
	}
	return QObject::eventFilter(obj, event);
}
Пример #5
0
void
ViewerTab::removeRotoInterface(NodeGui* n,
                               bool permanently,
                               bool removeAndDontSetAnother)
{
    std::map<NodeGui*,RotoGui*>::iterator it = _imp->rotoNodes.find(n);

    if ( it != _imp->rotoNodes.end() ) {
        if (_imp->currentRoto.first == n) {
            QObject::disconnect( _imp->currentRoto.second,SIGNAL(roleChanged(int,int)),this,SLOT(onRotoRoleChanged(int,int)) );
            ///Remove the widgets of the current roto node
            assert(_imp->viewerLayout->count() > 1);
            QLayoutItem* currentToolBarItem = _imp->viewerLayout->itemAt(0);
            QToolBar* currentToolBar = qobject_cast<QToolBar*>( currentToolBarItem->widget() );
            currentToolBar->hide();
            assert( currentToolBar == _imp->currentRoto.second->getToolBar() );
            _imp->viewerLayout->removeItem(currentToolBarItem);
            int buttonsBarIndex = _imp->mainLayout->indexOf( _imp->currentRoto.second->getCurrentButtonsBar() );
            assert(buttonsBarIndex >= 0);
            QLayoutItem* buttonsBar = _imp->mainLayout->itemAt(buttonsBarIndex);
            assert(buttonsBar);
            _imp->mainLayout->removeItem(buttonsBar);
            buttonsBar->widget()->hide();

            if (!removeAndDontSetAnother) {
                ///If theres another roto node, set it as the current roto interface
                std::map<NodeGui*,RotoGui*>::iterator newRoto = _imp->rotoNodes.end();
                for (std::map<NodeGui*,RotoGui*>::iterator it2 = _imp->rotoNodes.begin(); it2 != _imp->rotoNodes.end(); ++it2) {
                    if ( (it2->second != it->second) && it2->first->isSettingsPanelVisible() ) {
                        newRoto = it2;
                        break;
                    }
                }

                _imp->currentRoto.first = 0;
                _imp->currentRoto.second = 0;

                if ( newRoto != _imp->rotoNodes.end() ) {
                    setRotoInterface(newRoto->first);
                }
            }
        }

        if (permanently) {
            delete it->second;
            _imp->rotoNodes.erase(it);
        }
    }
Пример #6
0
WebViewWindow::WebViewWindow(QWidget *parent) :
    QMainWindow(parent)
{
    QAction* reloadAction = new QAction(QApplication::style()->standardIcon(QStyle::SP_BrowserReload), tr("Reload"), this);
    reloadAction->setShortcut(QKeySequence(QKeySequence::Refresh));

    QToolBar* toolBar = new QToolBar(tr("ToolBar"), this);
    mAddressBar = new QLineEdit(toolBar);
    mAddressBar->setReadOnly(true);
    toolBar->addWidget(mAddressBar);
    toolBar->addAction(reloadAction);
    toolBar->setMovable(false);
    toolBar->hide();
    toolBar->installEventFilter(this);
    mToolBar = toolBar;
    addToolBar(toolBar);

    QMenuBar* menuBar = this->menuBar();
    QMenu* fileMenu = menuBar->addMenu(tr("&File"));
    fileMenu->addAction(reloadAction);
    QAction* quitAction = fileMenu->addAction(QIcon(":/media/application_exit.png"), tr("Quit"));
    connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
    QMenu* viewMenu = menuBar->addMenu(tr("&View"));
    viewMenu->addAction(toolBar->toggleViewAction());
    QMenu* debugMenu = menuBar->addMenu(tr("&Debug"));
    QAction* inspectAction = debugMenu->addAction(tr("Inspect"));
    connect(inspectAction, SIGNAL(triggered()), this, SLOT(showWebInspector()));

    mWebView = new QWebView(this);
    mWebInspector = 0;
    QWebSettings* webSettings = mWebView->settings();
    webSettings->setAttribute(QWebSettings::LocalStorageEnabled, true);
    webSettings->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);

    QWidget* centralWidget = new QWidget(this);
    QVBoxLayout* layout = new QVBoxLayout(centralWidget);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->addWidget(mWebView);
    layout->setAlignment(mWebView, Qt::AlignCenter);
    setCentralWidget(centralWidget);
    setWindowModality(Qt::WindowModal);

    connect(reloadAction, SIGNAL(triggered()), mWebView, SLOT(reload()));

    loadWebInspector();
}
Пример #7
0
QT_BEGIN_NAMESPACE

MainWindow::MainWindow(CmdLineParser *cmdLine, QWidget *parent)
    : QMainWindow(parent)
    , m_bookmarkWidget(0)
    , m_filterCombo(0)
    , m_toolBarMenu(0)
    , m_cmdLine(cmdLine)
    , m_progressWidget(0)
    , m_qtDocInstaller(0)
    , m_connectedInitSignals(false)
{
    TRACE_OBJ

    setToolButtonStyle(Qt::ToolButtonFollowStyle);
    setDockOptions(dockOptions() | AllowNestedDocks);

    QString collectionFile;
    if (usesDefaultCollection()) {
        MainWindow::collectionFileDirectory(true);
        collectionFile = MainWindow::defaultHelpCollectionFileName();
    } else {
        collectionFile = cmdLine->collectionFile();
    }
    HelpEngineWrapper &helpEngineWrapper =
        HelpEngineWrapper::instance(collectionFile);
    BookmarkManager *bookMarkManager = BookmarkManager::instance();

    if (!initHelpDB(!cmdLine->collectionFileGiven())) {
        qDebug("Fatal error: Help engine initialization failed. "
            "Error message was: %s\nAssistant will now exit.",
            qPrintable(HelpEngineWrapper::instance().error()));
        std::exit(1);
    }

    m_centralWidget = new CentralWidget(this);
    setCentralWidget(m_centralWidget);

    m_indexWindow = new IndexWindow(this);
    QDockWidget *indexDock = new QDockWidget(tr("Index"), this);
    indexDock->setObjectName(QLatin1String("IndexWindow"));
    indexDock->setWidget(m_indexWindow);
    addDockWidget(Qt::LeftDockWidgetArea, indexDock);

    m_contentWindow = new ContentWindow;
    QDockWidget *contentDock = new QDockWidget(tr("Contents"), this);
    contentDock->setObjectName(QLatin1String("ContentWindow"));
    contentDock->setWidget(m_contentWindow);
    addDockWidget(Qt::LeftDockWidgetArea, contentDock);

    m_searchWindow = new SearchWidget(helpEngineWrapper.searchEngine());
    m_searchWindow->setFont(!helpEngineWrapper.usesBrowserFont() ? qApp->font()
        : helpEngineWrapper.browserFont());
    QDockWidget *searchDock = new QDockWidget(tr("Search"), this);
    searchDock->setObjectName(QLatin1String("SearchWindow"));
    searchDock->setWidget(m_searchWindow);
    addDockWidget(Qt::LeftDockWidgetArea, searchDock);

    QDockWidget *bookmarkDock = new QDockWidget(tr("Bookmarks"), this);
    bookmarkDock->setObjectName(QLatin1String("BookmarkWindow"));
    bookmarkDock->setWidget(m_bookmarkWidget
        = bookMarkManager->bookmarkDockWidget());
    addDockWidget(Qt::LeftDockWidgetArea, bookmarkDock);

    QDockWidget *openPagesDock = new QDockWidget(tr("Open Pages"), this);
    openPagesDock->setObjectName(QLatin1String("Open Pages"));
    OpenPagesManager *openPagesManager
        = OpenPagesManager::createInstance(this, usesDefaultCollection(), m_cmdLine->url());
    openPagesDock->setWidget(openPagesManager->openPagesWidget());
    addDockWidget(Qt::LeftDockWidgetArea, openPagesDock);

    connect(m_centralWidget, SIGNAL(addBookmark(QString, QString)),
        bookMarkManager, SLOT(addBookmark(QString, QString)));
    connect(bookMarkManager, SIGNAL(escapePressed()), this,
            SLOT(activateCurrentCentralWidgetTab()));
    connect(bookMarkManager, SIGNAL(setSource(QUrl)), m_centralWidget,
            SLOT(setSource(QUrl)));
    connect(bookMarkManager, SIGNAL(setSourceInNewTab(QUrl)),
        openPagesManager, SLOT(createPage(QUrl)));

    QHelpSearchEngine *searchEngine = helpEngineWrapper.searchEngine();
    connect(searchEngine, SIGNAL(indexingStarted()), this, SLOT(indexingStarted()));
    connect(searchEngine, SIGNAL(indexingFinished()), this, SLOT(indexingFinished()));

    QString defWindowTitle = tr("Qt Assistant");
    setWindowTitle(defWindowTitle);

    setupActions();
    statusBar()->show();
    m_centralWidget->connectTabBar();

    setupFilterToolbar();
    setupAddressToolbar();

    const QString windowTitle = helpEngineWrapper.windowTitle();
    setWindowTitle(windowTitle.isEmpty() ? defWindowTitle : windowTitle);
    QByteArray iconArray = helpEngineWrapper.applicationIcon();
    if (iconArray.size() > 0) {
        QPixmap pix;
        pix.loadFromData(iconArray);
        QIcon appIcon(pix);
        qApp->setWindowIcon(appIcon);
    } else {
        QIcon appIcon(QLatin1String(":/trolltech/assistant/images/assistant-128.png"));
        qApp->setWindowIcon(appIcon);
    }

    QToolBar *toolBar = addToolBar(tr("Bookmark Toolbar"));
    toolBar->setObjectName(QLatin1String("Bookmark Toolbar"));
    bookMarkManager->setBookmarksToolbar(toolBar);

    // Show the widget here, otherwise the restore geometry and state won't work
    // on x11.
    show();

    toolBar->hide();
    toolBarMenu()->addAction(toolBar->toggleViewAction());

    QByteArray ba(helpEngineWrapper.mainWindow());
    if (!ba.isEmpty())
        restoreState(ba);

    ba = helpEngineWrapper.mainWindowGeometry();
    if (!ba.isEmpty()) {
        restoreGeometry(ba);
    } else {
        tabifyDockWidget(contentDock, indexDock);
        tabifyDockWidget(indexDock, bookmarkDock);
        tabifyDockWidget(bookmarkDock, searchDock);
        contentDock->raise();
        const QRect screen = QApplication::desktop()->screenGeometry();
        resize(4*screen.width()/5, 4*screen.height()/5);
    }

    if (!helpEngineWrapper.hasFontSettings()) {
        helpEngineWrapper.setUseAppFont(false);
        helpEngineWrapper.setUseBrowserFont(false);
        helpEngineWrapper.setAppFont(qApp->font());
        helpEngineWrapper.setAppWritingSystem(QFontDatabase::Latin);
        helpEngineWrapper.setBrowserFont(qApp->font());
        helpEngineWrapper.setBrowserWritingSystem(QFontDatabase::Latin);
    } else {
        updateApplicationFont();
    }

    updateAboutMenuText();

    QTimer::singleShot(0, this, SLOT(insertLastPages()));
    if (m_cmdLine->enableRemoteControl())
        (void)new RemoteControl(this);

    if (m_cmdLine->contents() == CmdLineParser::Show)
        showContents();
    else if (m_cmdLine->contents() == CmdLineParser::Hide)
        hideContents();

    if (m_cmdLine->index() == CmdLineParser::Show)
        showIndex();
    else if (m_cmdLine->index() == CmdLineParser::Hide)
        hideIndex();

    if (m_cmdLine->bookmarks() == CmdLineParser::Show)
        showBookmarksDockWidget();
    else if (m_cmdLine->bookmarks() == CmdLineParser::Hide)
        hideBookmarksDockWidget();

    if (m_cmdLine->search() == CmdLineParser::Show)
        showSearch();
    else if (m_cmdLine->search() == CmdLineParser::Hide)
        hideSearch();

    if (m_cmdLine->contents() == CmdLineParser::Activate)
        showContents();
    else if (m_cmdLine->index() == CmdLineParser::Activate)
        showIndex();
    else if (m_cmdLine->bookmarks() == CmdLineParser::Activate)
        showBookmarksDockWidget();

    if (!m_cmdLine->currentFilter().isEmpty()) {
        const QString &curFilter = m_cmdLine->currentFilter();
        if (helpEngineWrapper.customFilters().contains(curFilter))
            helpEngineWrapper.setCurrentFilter(curFilter);
    }

    if (usesDefaultCollection())
        QTimer::singleShot(0, this, SLOT(lookForNewQtDocumentation()));
    else
        checkInitState();

    connect(&helpEngineWrapper, SIGNAL(documentationRemoved(QString)),
            this, SLOT(documentationRemoved(QString)));
    connect(&helpEngineWrapper, SIGNAL(documentationUpdated(QString)),
            this, SLOT(documentationUpdated(QString)));

    setTabPosition(Qt::AllDockWidgetAreas, QTabWidget::North);
    GlobalActions::instance()->updateActions();
    if (helpEngineWrapper.addressBarEnabled())
        showNewAddress();
}
/*!

*/
void
DebugMessageWindow::createToolBar()
{
    {
        QToolBar * tbar = new QToolBar( tr( "Control" ), this );
        tbar->setIconSize( QSize( 16, 16 ) );

        tbar->addAction( M_open_debug_log_dir_act );
        tbar->addAction( M_clear_data_act );

        tbar->addSeparator();

        tbar->addAction( M_sync_act );
        tbar->addAction( M_decrement_act );
        tbar->addAction( M_increment_act );

        tbar->addSeparator();

        QLabel * find_label = new QLabel( tr( "Find: " ) );
        M_find_box = new QLineEdit();
        M_find_box->setMaximumSize( 100, 48 );
        connect( M_find_box,  SIGNAL( returnPressed() ),
                 this, SLOT( findExistString() ) );
        connect( M_find_box, SIGNAL( textChanged( const QString & ) ),
                 this, SLOT( findString( const QString & ) ) );
        // invisible action
        {
            QAction * act = new QAction( tr( "Focus Find Box" ), this );
#ifdef Q_WS_MAC
            act->setShortcut( Qt::META + Qt::Key_F );
#else
            act->setShortcut( Qt::CTRL + Qt::Key_F );
#endif
            connect( act, SIGNAL( triggered() ),
                     M_find_box, SLOT( setFocus() ) );
        }

        M_find_forward_rb = new QRadioButton( tr( "Down" ) );
        connect( M_find_forward_rb, SIGNAL( clicked() ),
                 this, SLOT( findExistString() ) );
        M_find_backward_rb = new QRadioButton( tr( "Up" ) );
        connect( M_find_backward_rb, SIGNAL( clicked() ),
                 this, SLOT( findExistString() ) );

        M_find_forward_rb->setChecked( true );

        tbar->addWidget( find_label );
        tbar->addWidget( M_find_box );
        tbar->addWidget( M_find_forward_rb );
        tbar->addWidget( M_find_backward_rb );

        {
            QFrame * dummy_frame = new QFrame;
            QHBoxLayout * layout = new QHBoxLayout;
            layout->addSpacing( 10 );
            layout->addStretch( 1 );
            dummy_frame->setLayout( layout );
            tbar->addWidget( dummy_frame );
        }

        this->addToolBar( Qt::TopToolBarArea, tbar );
    }

    {
        QToolBar * tbar = new QToolBar( tr( "Debug view" ), this );
        tbar->setIconSize( QSize( 16, 16 ) );

        tbar->addAction( M_show_debug_view_all_act );
        tbar->addAction( M_show_debug_view_self_act );
        tbar->addAction( M_show_debug_view_ball_act );
        tbar->addAction( M_show_debug_view_teammates_act );
        tbar->addAction( M_show_debug_view_opponents_act );
        tbar->addAction( M_show_debug_view_comment_act );
        tbar->addAction( M_show_debug_view_shape_act );
        tbar->addAction( M_show_debug_view_target_act );
        tbar->addAction( M_show_debug_view_message_act );

        tbar->addSeparator();

        tbar->addAction( M_show_debug_log_objects_act );

        this->addToolBar( Qt::TopToolBarArea, tbar );
    }

    // left tool bar
    {
        QToolBar * tbar = new QToolBar( tr( "Debug Level" ), this );
        tbar->setIconSize( QSize( 16, 16 ) );

        QToolBar * hbar = new QToolBar( tr( "Debug Level Hidden" ), this );
        hbar->setIconSize( QSize( 16, 16 ) );

        for ( int i = 0; i < 32; ++i )
        {
             if ( ! M_debug_text[i].isEmpty() )
            {
                tbar->addAction( M_debug_level_act[i] );
            }
            else
            {
                hbar->addAction( M_debug_level_act[i] );
            }
        }

        this->addToolBar( Qt::LeftToolBarArea, tbar );
        this->addToolBar( Qt::LeftToolBarArea, hbar );
        hbar->hide();
    }
}
Пример #9
0
GoplayBrowser::GoplayBrowser(LiteApi::IApplication *app, QObject *parent)
    : LiteApi::IBrowserEditor(parent),
      m_liteApp(app)
{
    QDir dir(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
    dir.mkpath("liteide/goplay");

    dir.cd("liteide");
    m_dataPath = dir.path()+"/goplay";

    m_playFile = QFileInfo(dir,"goplay.go").filePath();
    QFile file(m_playFile);
    if (file.open(QFile::WriteOnly|QIODevice::Text)) {
        file.write(data.toUtf8());
        file.close();
    }

    m_widget = new QWidget;

    m_editor = m_liteApp->fileManager()->createEditor(data,"text/x-gosrc");
    m_editor->open(m_playFile,"text/x-gosrc");

    QToolBar *toolBar = LiteApi::findExtensionObject<QToolBar*>(m_editor,"LiteApi.QToolBar");
    if (toolBar) {
        toolBar->hide();
    }

    m_output = new TextOutput;

    QVBoxLayout *layout = new QVBoxLayout;
    QHBoxLayout *head = new QHBoxLayout;
    QSplitter *spliter = new QSplitter(Qt::Vertical);

    QLabel *label = new QLabel("<h2>Go Playground</h2>");
    QPushButton *run = new QPushButton("Run");
    QPushButton *stop = new QPushButton("Stop");
    QPushButton *_new = new QPushButton("New");
    QPushButton *load = new QPushButton("Load");
    QPushButton *save = new QPushButton("Save");
    QPushButton *shell = new QPushButton("Explorer");
    m_editLabel  = new QLabel;

    head->addWidget(label);
    head->addWidget(run);
    head->addWidget(stop);
    head->addWidget(_new);
    head->addWidget(load);
    head->addWidget(save);
    head->addWidget(shell);
    head->addWidget(m_editLabel);
    head->addStretch();

    layout->addLayout(head);

    spliter->addWidget(m_editor->widget());
    spliter->addWidget(m_output);
    spliter->setStretchFactor(0,2);
    spliter->setStretchFactor(1,1);
    layout->addWidget(spliter);

    m_widget->setLayout(layout);

    m_process = new ProcessEx(this);
    m_process->setWorkingDirectory(dir.path());
    m_codec = QTextCodec::codecForName("utf-8");


    connect(run,SIGNAL(clicked()),this,SLOT(run()));
    connect(stop,SIGNAL(clicked()),this,SLOT(stop()));
    connect(_new,SIGNAL(clicked()),this,SLOT(newPlay()));
    connect(load,SIGNAL(clicked()),this,SLOT(loadPlay()));
    connect(save,SIGNAL(clicked()),this,SLOT(savePlay()));
    connect(shell,SIGNAL(clicked()),this,SLOT(shell()));
    connect(m_process,SIGNAL(started()),this,SLOT(runStarted()));
    connect(m_process,SIGNAL(extOutput(QByteArray,bool)),this,SLOT(runOutput(QByteArray,bool)));
    connect(m_process,SIGNAL(extFinish(bool,int,QString)),this,SLOT(runFinish(bool,int,QString)));

    m_liteApp->extension()->addObject("LiteApi.Goplay",this);
    m_liteApp->extension()->addObject("LiteApi.Goplay.IEditor",m_editor);
}
void RackWindow::createPluginHost(int position)
{
    //layout settings widget:
    QWidget *settingsWidget = new QWidget;
    settingsWidget->setPalette(QPalette(QColor(0,0,0,160)));
    settingsWidget->setAutoFillBackground(true);

    RPushButton *leftButton = new RPushButton;
    leftButton->setObjectName("rackSettingsLeftArrowButton");
    RPushButton *rightButton = new RPushButton;
    rightButton->setObjectName("rackSettingsRightArrowButton");
    RPushButton *topButton = new RPushButton;
    topButton->setObjectName("rackSettingsTopArrowButton");
    RPushButton *bottomButton = new RPushButton;
    bottomButton->setObjectName("rackSettingsBottomArrowButton");
    RPushButton *closeButton = new RPushButton;
    closeButton->setObjectName("rackSettingsCloseButton");

    //vertical toolbar for plugin buttons:
    QToolBar *pluginHostToolBar = new QToolBar;
    pluginHostToolBar->setObjectName("rackPluginHostToolBar");
    pluginHostToolBar->setOrientation(Qt::Vertical);
    //actiongroup for exclusive handling of buttons:
    QActionGroup *ag = new QActionGroup(pluginHostToolBar);
    ag->setExclusive(true);

    RPushButton *addPluginWidgetButton = new RPushButton(tr("Add Widget ..."));
    addPluginWidgetButton->setObjectName("rackAddPluginWidgetButton");

    QWidget *middleWidget = new QWidget;
    QVBoxLayout *middleLayout = new QVBoxLayout(middleWidget);
    middleLayout->setSpacing(0);
    middleLayout->setContentsMargins(0,0,0,0);
    middleLayout->addWidget(pluginHostToolBar, 0, Qt::AlignHCenter);
    middleLayout->addWidget(addPluginWidgetButton, 0, Qt::AlignHCenter);

    QGridLayout *settingsLayout = new QGridLayout(settingsWidget);
    settingsLayout->setSpacing(0);
    settingsLayout->setContentsMargins(0,0,0,0);
    settingsLayout->addWidget(topButton,0,1, Qt::AlignTop | Qt::AlignHCenter);
    settingsLayout->addWidget(closeButton,0,2, Qt::AlignTop | Qt::AlignRight);
    settingsLayout->addWidget(leftButton,1,0, Qt::AlignLeft);
    settingsLayout->addWidget(rightButton,1,2, Qt::AlignRight);
    settingsLayout->addWidget(bottomButton,2,1, Qt::AlignBottom| Qt::AlignHCenter);
    settingsLayout->addWidget(middleWidget,1,1);

    QStackedWidget *pluginStack = new QStackedWidget;
    pluginStack->setObjectName("rackPluginStack");
    pluginStack->setAutoFillBackground(true);

    QWidget *pluginHost = new QWidget;
    pluginHost->setMinimumSize(200,80);

    QStackedLayout *overlayLayout = new QStackedLayout(pluginHost);
    overlayLayout->setStackingMode(QStackedLayout::StackAll);
    overlayLayout->addWidget(pluginStack);
    overlayLayout->addWidget(settingsWidget);
    overlayLayout->setCurrentIndex(1);

    //enter/leave settings signals:
    QSignalMapper *mapperShowSettingsMode = new QSignalMapper(pluginHost);
    QObject::connect(this, SIGNAL(enterSettingsMode()), mapperShowSettingsMode, SLOT(map()));
    mapperShowSettingsMode->setMapping(this, 1);
    QSignalMapper *mapperHideSettingsMode = new QSignalMapper(pluginHost);
    QObject::connect(this, SIGNAL(leaveSettingsMode()), mapperHideSettingsMode, SLOT(map()));
    mapperHideSettingsMode->setMapping(this, 0);
    QObject::connect(mapperShowSettingsMode, SIGNAL(mapped(int)), overlayLayout, SLOT(setCurrentIndex(int)));
    QObject::connect(mapperHideSettingsMode, SIGNAL(mapped(int)), overlayLayout, SLOT(setCurrentIndex(int)));

    //create plugin host widget signals:
    QSignalMapper *mapperCreatePluginHost = new QSignalMapper(pluginHost);
    QObject::connect(leftButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    QObject::connect(rightButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    QObject::connect(topButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    QObject::connect(bottomButton, SIGNAL(clicked()), mapperCreatePluginHost, SLOT(map()));
    mapperCreatePluginHost->setMapping(leftButton, NewSplitterLeft);
    mapperCreatePluginHost->setMapping(rightButton, NewSplitterRight);
    mapperCreatePluginHost->setMapping(topButton, NewSplitterTop);
    mapperCreatePluginHost->setMapping(bottomButton, NewSplitterBottom);
    QObject::connect(mapperCreatePluginHost, SIGNAL(mapped(int)), SLOT(createPluginHost(int)));

    //load plugin signal:
    QObject::connect(addPluginWidgetButton, SIGNAL(clicked()), m_mapperLoadNewPlugin, SLOT(map()));
    m_mapperLoadNewPlugin->setMapping(addPluginWidgetButton, pluginHost);

    //close plugin host signal:
    QObject::connect(closeButton, SIGNAL(clicked()), m_mapperClosePluginHost, SLOT(map()));
    m_mapperClosePluginHost->setMapping(closeButton, pluginHost);

    //create plugin switch signalmapper
    QSignalMapper *mapperSwitchPlugin = new QSignalMapper(pluginHost);
    mapperSwitchPlugin->setObjectName("rackPluginSwitchMapper");
    QObject::connect(mapperSwitchPlugin, SIGNAL(mapped(QWidget *)), pluginStack, SLOT(setCurrentWidget(QWidget *)));


    ////test show/hide plugin widget

    ////QObject::connect(mapperSwitchPlugin, SIGNAL(mapped(QWidget *)), this, SLOT(showHidePluginWidget(QWidget*)));


    //////


    //create plugin toolbar for mainwindow
    QToolBar *pluginToolBar = new QToolBar;
    pluginToolBar->setObjectName("rackPluginToolBar");
    pluginToolBar->setMovable(false);
    pluginToolBar->hide();
    addToolBar(Qt::BottomToolBarArea, pluginToolBar);

    //store the toolbar pointer as dynamic property to access later when creating plugin toolbar buttons
    pluginHost->setProperty("pluginToolBar", qVariantFromValue((QWidget *)pluginToolBar));

    //plugin bar signals & slots:
    QObject::connect(this, SIGNAL(enterSettingsMode()), pluginToolBar, SLOT(hide()));
    QObject::connect(this, SIGNAL(leaveSettingsMode()), pluginToolBar, SLOT(show()));







    //insert new pluginhost widget in splitter, create new splitter if necessary
    if (position == 0)
    {
        m_mainSplitter->addWidget(pluginHost);
        return;
    }
    QSignalMapper *sm = qobject_cast<QSignalMapper *>(sender());
    QWidget *senderPluginHost = qobject_cast<QWidget *>(sm->mapping(position)->parent()->parent());
    RSplitter *parentSplitter = qobject_cast<RSplitter *>(senderPluginHost->parent());
    QList<int> widgetsizes;
    int senderpos = parentSplitter->indexOf(senderPluginHost);
    int newposition;
    if ((position == NewSplitterLeft) or (position == NewSplitterTop)) newposition = senderpos;
    else newposition = senderpos + 1;
    switch (position + parentSplitter->orientation()) {             //horizontal=1 vertical=2
    case 0:                                                         //left   horizontal / top vertical
    case 2:                                                         //right  horizontal
    case 4:                                                         //bottom vertical
        widgetsizes = parentSplitter->sizes();
        widgetsizes.replace(senderpos, int(widgetsizes.at(senderpos)/2));
        widgetsizes.insert(senderpos + 1, widgetsizes.at(senderpos));
        parentSplitter->insertWidget(newposition, pluginHost);
        parentSplitter->setSizes(widgetsizes);
        break;
    case  1:                                                        //left  vertical
    case  3:                                                        //right vertical / bottom horizontal
    case -1:                                                        //top   horizontal
        if (parentSplitter->count() == 1)
        {
            parentSplitter->setOrientation(Qt::Orientation(abs(position)));
            widgetsizes = parentSplitter->sizes();
            widgetsizes.replace(0, int(widgetsizes.at(0)/2));
            widgetsizes.append(widgetsizes.at(0));
            parentSplitter->insertWidget(newposition, pluginHost);
            parentSplitter->setSizes(widgetsizes);
        }
        else if (parentSplitter->count() > 1)
        {
            RSplitter *newSplitter = new RSplitter(Qt::Orientation(abs(position)));
            QObject::connect(this, SIGNAL(enterSettingsMode()), newSplitter, SIGNAL(enterSettingsMode()));
            QObject::connect(this, SIGNAL(leaveSettingsMode()), newSplitter, SIGNAL(leaveSettingsMode()));
            widgetsizes = parentSplitter->sizes();
            parentSplitter->insertWidget(parentSplitter->indexOf(senderPluginHost), newSplitter);
            newSplitter->addWidget(senderPluginHost);
            QList<int> newsizes = newSplitter->sizes();
            newsizes.replace(0, int(newsizes.at(0)/2));
            newsizes.append(newsizes.at(0));
            if ((position == NewSplitterLeft) or (position == NewSplitterTop)) newSplitter->insertWidget(0, pluginHost);
            else newSplitter->addWidget(pluginHost);
            newSplitter->setSizes(newsizes);
            parentSplitter->setSizes(widgetsizes);
        }
        break;
    }
}