Esempio n. 1
0
BrandingButton::BrandingButton(QWidget *parent)
        : QToolButton(parent),
        m_svg(new Plasma::Svg(this))
{
    m_svg->setImagePath("widgets/branding");
    m_svg->resize();
    checkBranding();
    connect(m_svg, SIGNAL(repaintNeeded()), this, SLOT(checkBranding()));
    connect(this, SIGNAL(clicked()), SLOT(openHomepage()));
    setCursor(Qt::PointingHandCursor);
}
Esempio n. 2
0
QAction *BApplicationPrivate::createStandardAction(BGuiTools::StandardAction type, QObject *parent)
{
    if (!testInit("BApplicationPrivate"))
        return 0;
    QAction *act = 0;
    switch (type) {
    case BGuiTools::SettingsAction:
        act = new QAction(parent);
        act->setMenuRole(QAction::PreferencesRole);
        act->setObjectName("ActionSettings");
        act->setIcon(BApplication::icon("configure"));
        act->setShortcut(QKeySequence::Preferences);
        connect(act, SIGNAL(triggered()), qs_func(), SLOT(showSettingsDialog()));
        break;
    case BGuiTools::HomepageAction:
        act = new QAction(parent);
        act->setObjectName("ActionHomepage");
        act->setIcon(BApplication::icon("gohome"));
        connect(act, SIGNAL(triggered()), qs_func(), SLOT(openHomepage()));
        break;
    case BGuiTools::HelpContentsAction:
        act = new QAction(parent);
        act->setObjectName("ActionHelpContents");
        act->setIcon(BApplication::beqtIcon("help_contents"));
        connect(act, SIGNAL(triggered()), qs_func(), SLOT(showHelpContents()));
        break;
    case BGuiTools::ContextualHelpAction:
        act = new QAction(parent);
        act->setObjectName("ActionContextualHelp");
        act->setIcon(BApplication::icon("help_contextual"));
        connect(act, SIGNAL(triggered()), qs_func(), SLOT(showContextualHelp()));
        break;
    case BGuiTools::WhatsThisAction:
        act = QWhatsThis::createAction(parent);
        act->setObjectName("ActionWhatsThis");
        act->setIcon(BApplication::beqtIcon("help_hint"));
        break;
    case BGuiTools::AboutAction:
        act = new QAction(parent);
        act->setMenuRole(QAction::AboutRole);
        act->setObjectName("ActionAbout");
        act->setIcon(BApplication::icon("help_about"));
        connect(act, SIGNAL(triggered()), qs_func(), SLOT(showAboutDialog()));
        break;
    default:
        return 0;
    }
    act->setProperty("beqt/standard_action_type", type);
    qs_func()->ds_func()->actions.insert(act, act);
    connect(act, SIGNAL(destroyed(QObject *)), qs_func()->ds_func(), SLOT(actionDestroyed(QObject *)));
    retranslateStandardAction(act);
    return act;
}
Esempio n. 3
0
void NerdMain::setSignalSlot(){
    connect(ui->menuNextRecord,SIGNAL(triggered()),data,SLOT(setNextRecord()));
    connect(ui->menuPrevRecord,SIGNAL(triggered()),data,SLOT(setPrevRecord()));
    connect(ui->menuNextCell,SIGNAL(triggered()),data,SLOT(setNextCell()));
    connect(ui->menuPrevCell,SIGNAL(triggered()),data,SLOT(setPrevCell()));

    connect(ui->menuAbout,SIGNAL(triggered()),aboutWin,SLOT(show()));
    connect(ui->menuHomepage,SIGNAL(triggered()),this,SLOT(openHomepage()));
    connect(open,SIGNAL(fileOpen()),this,SLOT(openFile()));
    connect(ui->menuOpen,SIGNAL(triggered()),open,SLOT(btnClicked()));
    connect(ui->menuExit,SIGNAL(triggered()),this,SLOT(close()));
    connect(ui->menuStart,SIGNAL(triggered()),data,SLOT(toggleState()));
    connect(ui->menuStop,SIGNAL(triggered()),data,SLOT(toggleState()));
    connect(data,SIGNAL(stateChange()),this,SLOT(toggleState()));

    connect(data,SIGNAL(nextState(bool)),this,SLOT(toggleNext(bool)));
    connect(data,SIGNAL(nextCellState(bool)),this,SLOT(toggleNextCell(bool)));
    connect(data,SIGNAL(prevState(bool)),this,SLOT(togglePrev(bool)));
    connect(data,SIGNAL(prevCellState(bool)),this,SLOT(togglePrevCell(bool)));
}
Esempio n. 4
0
Player::Player(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Player)
{
    std::cout << "Initialize player..." << std::endl;
    ui->setupUi(this);

    //Add MPlayer frame
    mplayer = new MPlayer;
    ui->playerLayout->setMargin(0);
    ui->playerLayout->addWidget(mplayer, 1);
    //enable autohiding toolbar
    mplayer->installEventFilter(this);
    mplayer->setMouseTracking(true);
    mplayer->getLayer()->installEventFilter(this);
    mplayer->getLayer()->setMouseTracking(true);
    ui->toolBar->installEventFilter(this);

    //move window
    ui->titleBar->installEventFilter(this);

    //Add Playlist
    playlist = new Playlist;
    ui->playerLayout->addWidget(playlist);
    playlist->installEventFilter(this);

    //Add Border
    topLeftBorder = new Border(this, Border::LEFT);
    topLeftBorder->setObjectName("topLeftBorder");
    topRightBorder = new Border(this, Border::RIGHT);
    topRightBorder->setObjectName("topRightBorder");
    ui->titleBarLayout->insertWidget(0, topLeftBorder);
    ui->titleBarLayout->addWidget(topRightBorder);

    leftBorder = new Border(this, Border::LEFT);
    leftBorder->setObjectName("leftBorder");
    rightBorder = new Border(this, Border::RIGHT);
    rightBorder->setObjectName("rightBorder");
    bottomBorder = new Border(this, Border::BOTTOM);
    bottomBorder->setObjectName("bottomBorder");
    ui->playerLayout->insertWidget(0, leftBorder);
    ui->playerLayout->addWidget(rightBorder);
    ui->mainLayout->addWidget(bottomBorder);

    ui->pauseButton->hide();
    ui->progressBar->hide();
    playlist->hide();

    //Add Cutterbar
    cutterbar = new CutterBar;
    int insertPos = ui->mainLayout->indexOf(ui->toolBar);
    ui->mainLayout->insertWidget(insertPos, cutterbar);
    cutterbar->hide();
    mplayer->menu->addAction(tr("Cut video"), this, SLOT(showCutterbar()), QKeySequence("C"));

    //Add WebVideo
    webvideo = new WebVideo;
    reslibrary = new ResLibrary;
    webvideo->addTab(reslibrary, tr("Resources"));
    webvideo->setCurrentIndex(0);

    //add downloader
    downloader = new Downloader;
    webvideo->addTab(downloader, tr("Downloader"));

    //add transformer
    transformer = new Transformer;

    //Settings Dialog
    settingsDialog = new SettingsDialog(this);

    //Add menu
    menubar = new QMenuBar;
    menu = menubar->addMenu(tr("Player"));
    menu->addAction(tr("Online video"), webvideo, SLOT(show()));
    menu->addAction(tr("Transform video"), transformer, SLOT(show()));
    menu->addAction(tr("Settings"), this, SLOT(onSetButton()));
    menu->addSeparator();
    menu->addAction(tr("Homepage"), this, SLOT(openHomepage()));
    menu->addAction(tr("About"), this, SLOT(onAboutClicked()));
    ui->mainLayout->insertWidget(0, menubar);

    //Add time show
    timeShow = new QLabel(mplayer);
    timeShow->move(0, 0);
    timeShow->hide();

    //Connect
    connect(ui->playButton, SIGNAL(clicked()), mplayer, SLOT(changeState()));
    connect(ui->pauseButton, SIGNAL(clicked()), mplayer, SLOT(changeState()));
    connect(ui->stopButton, SIGNAL(clicked()), this, SLOT(onStopButton()));
    connect(ui->progressBar, SIGNAL(valueChanged(int)), this, SLOT(onPBarChanged(int)));
    connect(ui->progressBar, SIGNAL(sliderPressed()), this, SLOT(onPBarPressed()));
    connect(ui->progressBar, SIGNAL(sliderReleased()), this, SLOT(onPBarReleased()));
    connect(ui->volumeSlider, SIGNAL(valueChanged(int)), mplayer, SLOT(setVolume(int)));
    connect(ui->volumeSlider, SIGNAL(valueChanged(int)), this, SLOT(onSaveVolume(int)));
    connect(ui->netButton, SIGNAL(clicked()), webvideo, SLOT(show()));
    connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(close()));
    connect(ui->minButton, SIGNAL(clicked()), this, SLOT(showMinimized()));
    connect(ui->maxButton, SIGNAL(clicked()), this, SLOT(setMaxNormal()));
    connect(ui->menuButton, SIGNAL(clicked()), this, SLOT(showMenu()));

    connect(mplayer, SIGNAL(played()), this, SLOT(setIconToPause()));
    connect(mplayer, SIGNAL(paused()), this, SLOT(setIconToPlay()));
    connect(mplayer, SIGNAL(stopped()), this, SLOT(onStopped()));
    connect(mplayer, SIGNAL(timeChanged(int)), this, SLOT(onProgressChanged(int)));
    connect(mplayer, SIGNAL(lengthChanged(int)), this, SLOT(onLengthChanged(int)));
    connect(mplayer, SIGNAL(fullScreen()), this, SLOT(setFullScreen()));
    connect(mplayer, SIGNAL(sizeChanged(QSize&)), this, SLOT(onSizeChanged(QSize&)));

    connect(playlist, SIGNAL(fileSelected(const QString&)), mplayer, SLOT(openFile(const QString&)));
    connect(playlist, SIGNAL(needPause(bool)), this, SLOT(onNeedPause(bool)));

    connect(downloader, SIGNAL(newPlay(const QString&,const QString&)), playlist, SLOT(addFileAndPlay(const QString&,const QString&)));
    connect(downloader, SIGNAL(newFile(const QString&,const QString&)), playlist, SLOT(addFile(const QString&,const QString&)));

    connect(cutterbar, SIGNAL(newFrame(int)), mplayer, SLOT(jumpTo(int)));
    connect(cutterbar, SIGNAL(finished()), cutterbar, SLOT(hide()));
    connect(cutterbar, SIGNAL(finished()), ui->toolBar, SLOT(show()));

    //Set skin
    setSkin(Settings::skinList[Settings::currentSkin]);

    //Set default volume
    ui->volumeSlider->setValue(Settings::volume);

    no_play_next = false;
    is_fullscreen = false;
}
Esempio n. 5
0
MainWindow::MainWindow(QWidget *parent, Qt::WindowFlags wf) 
  : QMainWindow(parent, wf)
{
  //setMinimumSize(geometry().size());
  //setMaximumSize(geometry().size());

  contrdirs[Cell::U] = Cell::D;
  contrdirs[Cell::R] = Cell::L;
  contrdirs[Cell::D] = Cell::U;
  contrdirs[Cell::L] = Cell::R;

#ifndef QTOPIA_PHONE
  QString appdir = qApp->applicationDirPath();
  soundpath = appdir + "/sounds/";
  if(!QFile::exists(soundpath))
    soundpath = appdir + "/../share/qnetwalk/sounds/";
  winsound   = new QSound(soundpath + "win.wav");
  turnsound   = new QSound(soundpath + "turn.wav");
  clicksound   = new QSound(soundpath + "click.wav");
  startsound   = new QSound(soundpath + "start.wav");
  connectsound = new QSound(soundpath + "connect.wav");
#else
  QString appdir = qApp->applicationDirPath();
  soundpath = ":sound/qnetwalk/";

  winsound   = new QSound(soundpath + "win");
  turnsound   = new QSound(soundpath + "turn");
  clicksound   = new QSound(soundpath + "click");
  startsound   = new QSound(soundpath + "start");
  connectsound = new QSound(soundpath + "connect");
#endif

  QSettings settings("QNetEor", "QNetEor");
  settings.beginGroup("QNetEor");
  username = settings.value("Username", getenv("USER")).toString();
  bool issound = settings.value("Sound", true).toBool();

  highscores = settings.value("Highscores").toStringList();
  if(highscores.count() != NumHighscores * 8)
  {
    highscores.clear();
    for(int i = 1; i < 5; i++)
    {
      for(int scores = 20 * i; scores < 30 * i; scores += i)
      {
        highscores.append("...");
        highscores.append(QString::number(scores));
      }
    }
  }

  skill = settings.value("Skill", Novice).toInt();
  if(skill != Novice && skill != Normal && skill != Expert)
    skill = Master;
  settings.endGroup();

  for(int i = 1; i < qApp->argc(); i++)
  {
    QString argument = qApp->argv()[i];
    if(argument == "-novice")
      skill = Novice;
    else if(argument == "-amateur")
      skill = Normal;
    else if(argument == "-expert")
      skill = Expert;
    else if(argument == "-master")
      skill = Master;
    else if(argument == "-nosound")
      issound = false;
  }

  setWindowTitle(tr("QNeoroid"));
  setWindowIcon(QPixmap(":/computer2.png"));

#ifdef QTOPIA_PHONE
  QMenu *m = QSoftMenuBar::menuFor(this);
#else
  QMenu *m = menuBar()->addMenu(tr("Options"));
#endif  
  soundaction = new QAction(tr("&Sound"), this);
  soundaction->setCheckable(true);
  soundaction->setChecked(issound);

  gamemenu = m->addMenu(tr("&Game"));
  gamemenu->addAction(QPixmap(":/newgame.png"), tr("&New"), this, SLOT(newGame()));
  gamemenu->addAction(QPixmap(":/highscores.png"), tr("&Highscores"), this, SLOT(showHighscores()));
  gamemenu->addAction(soundaction);
#ifndef QTOPIA_PHONE
  gamemenu->addSeparator();
  gamemenu->addAction(QPixmap(":/quit.png"), tr("&Quit"), qApp, SLOT(closeAllWindows()));
#endif

  skillmenu = m->addMenu(tr("&Skill"));
  skillActionGroup = new QActionGroup(this);
  QAction* action;
  action = skillActionGroup->addAction(tr("&Novice"));
  action->setCheckable(true);
  if(skill == Novice)
    action->setChecked(true);
  connect(action, SIGNAL(triggered()), this, SLOT(setSkillNovice()));
  action = skillActionGroup->addAction(tr("&Amateur"));
  action->setCheckable(true);
  if(skill == Normal)
    action->setChecked(true);
  connect(action, SIGNAL(triggered()), this, SLOT(setSkillNormal()));
  action = skillActionGroup->addAction(tr("&Expert"));
  action->setCheckable(true);
  if(skill == Expert)
    action->setChecked(true);
  connect(action, SIGNAL(triggered()), this, SLOT(setSkillExpert()));
  action = skillActionGroup->addAction(tr("&Master"));
  action->setCheckable(true);
  if(skill == Master)
    action->setChecked(true);
  connect(action, SIGNAL(triggered()), this, SLOT(setSkillMaster()));
  skillmenu->addActions(skillActionGroup->actions());

  QMenu* helpmenu = m->addMenu(tr("&Help"));
  helpmenu->addAction(tr("&Rules of Play"), this, SLOT(help()));
  helpmenu->addAction(QPixmap(":/homepage.png"), tr("&Homepage"), this, SLOT(openHomepage()));
  helpmenu->addSeparator();
  helpmenu->addAction(QPixmap(":/qnetwalk.png"), tr("&About QNeoroid"), this, SLOT(about()));
  helpmenu->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));

  QToolBar* toolbar = new QToolBar(this);
  toolbar->setFloatable(false);
  toolbar->setMovable(false);
  toolbar->addAction(QPixmap(":/newgame.png"), tr("New Game"), this, SLOT(newGame()));
  toolbar->addAction(QPixmap(":/highscores.png"), tr("Show Highscores"), this, SLOT(showHighscores()));
  //toolbar->addWidget(new QLabel(tr("Moves"),this));
  lcd = new QLCDNumber(toolbar);
  lcd->setFrameStyle(QFrame::Plain);
  toolbar->addWidget(lcd);
  //toolbar->addWidget(new QLabel(tr("Left:"),this));
  cellsLcd = new QLCDNumber(toolbar);
  cellsLcd->setFrameStyle(QFrame::Plain);
  toolbar->addWidget(cellsLcd);
  addToolBar(toolbar);

  Cell::initPixmaps();
  srand(time(0));
  setSkill(skill);
  installEventFilter(this);
  resize(240,320);
}
Esempio n. 6
0
MainWindow::MainWindow(Application *app)
    : QMainWindow(),
      m_application(app)
{
    app->setMainWindow(this);
    setUnifiedTitleAndToolBarOnMac(true);
    setDocumentMode(true);

    QCoreApplication::setOrganizationName("Dunnart");
    QCoreApplication::setOrganizationDomain("dunnart.org");
    QCoreApplication::setApplicationName("Dunnart");

    // Correct the look of the tab bar on OS X cocoa.
    app->setStyleSheet(
        "QGraphicsView {"
            "border: 0px;"
        "}"
#ifdef Q_WS_MAC
        "QTabBar::tab:top {"
            "font-family: \"Lucida Grande\";"
            "font-size: 11px;"
        "}"
#endif
    );

    // Set the window title.
    setWindowTitle("Dunnart");

    m_tab_widget = new CanvasTabWidget(this);    
    connect(m_tab_widget, SIGNAL(currentCanvasChanged(Canvas*)),
            this, SLOT(canvasChanged(Canvas*)));
    connect(m_tab_widget, SIGNAL(currentCanvasFileInfoChanged(QFileInfo)),
            this, SLOT(canvasFileInfoChanged(QFileInfo)));
    m_tab_widget->newTab();
    setCentralWidget(m_tab_widget);
    app->setCanvasTabWidget(m_tab_widget);

    // Inital window size.
    resize(1020, 743);

    m_new_action = new QAction("New", this);
    m_new_action->setShortcut(QKeySequence::New);
    connect(m_new_action, SIGNAL(triggered()), this, SLOT(documentNew()));

    m_open_action = new QAction("Open...", this);
    m_open_action->setShortcut(QKeySequence::Open);
    connect(m_open_action, SIGNAL(triggered()), this, SLOT(documentOpen()));

    for (int i = 0; i < MAX_RECENT_FILES; ++i)
    {
        m_action_open_recent_file[i] = new QAction(this);
        m_action_open_recent_file[i]->setVisible(false);
        connect(m_action_open_recent_file[i], SIGNAL(triggered()),
                this, SLOT(documentOpenRecent()));
    }

    m_close_action = new QAction("Close", this);
    m_close_action->setShortcut(QKeySequence::Close);
    connect(m_close_action, SIGNAL(triggered()),
            m_tab_widget, SLOT(currentCanvasClose()));

    m_save_action = new QAction("Save", this);
    m_save_action->setShortcut(QKeySequence::Save);
    connect(m_save_action, SIGNAL(triggered()),
            m_tab_widget, SLOT(currentCanvasSave()));

    m_save_as_action = new QAction("Save As...", this);
    m_save_as_action->setShortcut(QKeySequence::SaveAs);
    connect(m_save_as_action, SIGNAL(triggered()),
            m_tab_widget, SLOT(currentCanvasSaveAs()));

    m_export_action = new QAction("Export...", this);
    connect(m_export_action, SIGNAL(triggered()), this, SLOT(documentExport()));

    m_print_action = new QAction("Print...", this);
    m_print_action->setShortcut(QKeySequence::Print);
    connect(m_print_action, SIGNAL(triggered()), this, SLOT(documentPrint()));

    m_quit_action = new QAction(tr("Quit"), this);
    m_quit_action->setShortcut(QKeySequence::Quit);
    connect(m_quit_action, SIGNAL(triggered()),
            this, SLOT(close()));

    m_about_action = new QAction(tr("About"), this);
    connect(m_about_action, SIGNAL(triggered()), this, SLOT(about()));

    m_homepage_action = new QAction(tr("Dunnart homepage"), this);
    connect(m_homepage_action, SIGNAL(triggered()), this, SLOT(openHomepage()));

    m_action_show_zoom_level_dialog = new QAction(
            tr("Zoom Level"), this);
    m_action_show_zoom_level_dialog->setCheckable(true);

    m_action_show_properties_editor_dialog = new QAction(
            tr("Properties Editor"), this);
    m_action_show_properties_editor_dialog->setCheckable(true);

    m_action_show_layout_properties_dialog = new QAction(
            tr("Layout Properties"), this);
    m_action_show_layout_properties_dialog->setCheckable(true);

    m_action_show_connector_properties_dialog = new QAction(
            tr("Connector Properties"), this);
    m_action_show_connector_properties_dialog->setCheckable(true);

    m_action_show_create_alignment_dialog = new QAction(
            tr("Create Alignments"), this);
    m_action_show_create_alignment_dialog->setCheckable(true);

    m_action_show_create_distribution_dialog = new QAction(
            tr("Create Distributions"), this);
    m_action_show_create_distribution_dialog->setCheckable(true);

    m_action_show_create_separation_dialog = new QAction(
            tr("Create Separations"), this);
    m_action_show_create_separation_dialog->setCheckable(true);

    m_action_show_create_template_dialog = new QAction(
            tr("Create Templates"), this);
    m_action_show_create_template_dialog->setShortcut(tr("Ctrl+T"));
    m_action_show_create_template_dialog->setCheckable(true);

    m_action_show_shape_picker_dialog = new QAction(
            tr("Shape Picker"), this);
    m_action_show_shape_picker_dialog->setCheckable(true);

    m_action_clear_recent_files = new QAction(tr("Clear Menu"), this);
    connect(m_action_clear_recent_files, SIGNAL(triggered()),
            this, SLOT(clearRecentFileMenu()));

    m_action_show_undo_history_dialog = new QAction(
            tr("Undo History"), this);
    m_action_show_undo_history_dialog->setCheckable(true);

    m_action_show_canvas_overview_dialog = new QAction(
            tr("Canvas Overview"), this);
    m_action_show_canvas_overview_dialog->setCheckable(true);

    CanvasView *canvasview = m_tab_widget->currentCanvasView();
    Canvas *canvas = m_tab_widget->currentCanvas();

    m_action_auto_align_selection = new QAction(tr("Auto-align Selection"), this);
    connect(m_action_auto_align_selection, SIGNAL(triggered()),
            m_tab_widget, SLOT(alignSelection()));

    // Create statusBar, and assign it to the canvas.
    canvas->setStatusBar(statusBar());

#ifdef Q_WS_MAC
    // Make the status bar font size slightly smaller.
    QFont statusBarFont = statusBar()->font();
    statusBarFont.setPointSize(statusBarFont.pointSize() - 2);
    statusBar()->setFont(statusBarFont);
#endif

    m_file_menu = menuBar()->addMenu("File");
    m_file_menu->addAction(m_new_action);
    m_file_menu->addAction(m_open_action);
    QMenu *recentsMenu = m_file_menu->addMenu(tr("Open Recent"));
    for (int i = 0; i < MAX_RECENT_FILES; ++i)
    {
        recentsMenu->addAction(m_action_open_recent_file[i]);
    }
    m_action_recent_file_separator = recentsMenu->addSeparator();
    recentsMenu->addAction(m_action_clear_recent_files);
    updateRecentFileActions();

    m_file_menu->addSeparator();
    m_file_menu->addAction(m_close_action);
    m_file_menu->addAction(m_save_action);
    m_file_menu->addAction(m_save_as_action);
    m_file_menu->addSeparator();
    m_file_menu->addAction(m_export_action);
    m_file_menu->addSeparator();
    m_file_menu->addAction(m_print_action);
    m_file_menu->addSeparator();
    m_file_menu->addAction(m_quit_action);

    m_edit_menu = menuBar()->addMenu(tr("Edit"));
    m_tab_widget->addEditMenuActions(m_edit_menu);

    m_view_menu = menuBar()->addMenu(tr("View"));
    QMenu *dialogs_menu = m_view_menu->addMenu(tr("Show Dialogs"));
    dialogs_menu->addAction(m_action_show_canvas_overview_dialog);
    dialogs_menu->addAction(m_action_show_zoom_level_dialog);
    dialogs_menu->addSeparator();
    dialogs_menu->addAction(m_action_show_shape_picker_dialog);
    dialogs_menu->addAction(m_action_show_undo_history_dialog);
    dialogs_menu->addAction(m_action_show_properties_editor_dialog);
    dialogs_menu->addSeparator();
    dialogs_menu->addAction(m_action_show_create_alignment_dialog);
    dialogs_menu->addAction(m_action_show_create_distribution_dialog);
    dialogs_menu->addAction(m_action_show_create_separation_dialog);
    dialogs_menu->addAction(m_action_show_create_template_dialog);
    dialogs_menu->addSeparator();
    dialogs_menu->addAction(m_action_show_layout_properties_dialog);
    dialogs_menu->addAction(m_action_show_connector_properties_dialog);
    QMenu *overlays_menu = m_view_menu->addMenu(tr("Canvas Debug Layers"));
    m_tab_widget->addDebugOverlayMenuActions(overlays_menu);

    m_layout_menu = menuBar()->addMenu("Layout");
    m_tab_widget->addLayoutMenuActions(m_layout_menu);
    m_layout_menu->addAction(m_action_auto_align_selection);
    
    m_edit_toolbar = addToolBar(tr("Edit toolbar"));
    m_edit_toolbar->setIconSize(QSize(24, 24));
    m_edit_toolbar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    m_tab_widget->addEditToolBarActions(m_edit_toolbar);

    m_dialog_zoomLevel = new ZoomLevel(canvasview);
    connect(m_tab_widget, SIGNAL(currentCanvasViewChanged(CanvasView*)),
            m_dialog_zoomLevel, SLOT(changeCanvasView(CanvasView*)));
    connect(m_action_show_zoom_level_dialog,  SIGNAL(triggered(bool)),
            m_dialog_zoomLevel, SLOT(setVisible(bool)));
    connect(m_dialog_zoomLevel, SIGNAL(visibilityChanged(bool)),
            m_action_show_zoom_level_dialog,  SLOT(setChecked(bool)));
    addDockWidget(Qt::RightDockWidgetArea, m_dialog_zoomLevel);
    m_dialog_zoomLevel->show();

    m_dialog_properties_editor = new PropertiesEditorDialog(canvas);
    connect(m_tab_widget, SIGNAL(currentCanvasChanged(Canvas*)),
            m_dialog_properties_editor, SLOT(changeCanvas(Canvas*)));
    connect(m_action_show_properties_editor_dialog, SIGNAL(triggered(bool)),
            m_dialog_properties_editor, SLOT(setVisible(bool)));
    connect(m_dialog_properties_editor, SIGNAL(visibilityChanged(bool)),
            m_action_show_properties_editor_dialog,  SLOT(setChecked(bool)));
    addDockWidget(Qt::BottomDockWidgetArea, m_dialog_properties_editor);
    m_dialog_properties_editor->hide();

    m_dialog_shape_picker = new ShapePickerDialog(canvas);
    connect(m_tab_widget, SIGNAL(currentCanvasChanged(Canvas*)),
            m_dialog_shape_picker, SLOT(changeCanvas(Canvas*)));
    connect(m_action_show_shape_picker_dialog,  SIGNAL(triggered(bool)),
            m_dialog_shape_picker, SLOT(setVisible(bool)));
    connect(m_dialog_shape_picker, SIGNAL(visibilityChanged(bool)),
            m_action_show_shape_picker_dialog,  SLOT(setChecked(bool)));
    addDockWidget(Qt::LeftDockWidgetArea, m_dialog_shape_picker);
    m_dialog_shape_picker->show();

    m_dialog_layoutProps = new LayoutPropertiesDialog(canvas);
    connect(m_tab_widget, SIGNAL(currentCanvasChanged(Canvas*)),
            m_dialog_layoutProps, SLOT(changeCanvas(Canvas*)));
    connect(m_action_show_layout_properties_dialog,  SIGNAL(triggered(bool)),
            m_dialog_layoutProps, SLOT(setVisible(bool)));
    connect(m_dialog_layoutProps, SIGNAL(visibilityChanged(bool)),
            m_action_show_layout_properties_dialog,  SLOT(setChecked(bool)));
    addDockWidget(Qt::LeftDockWidgetArea, m_dialog_layoutProps);
    m_dialog_layoutProps->show();

    m_dialog_connectorProps = new ConnectorPropertiesDialog(canvas);
    connect(m_tab_widget, SIGNAL(currentCanvasChanged(Canvas*)),
            m_dialog_connectorProps, SLOT(changeCanvas(Canvas*)));
    connect(m_action_show_connector_properties_dialog,  SIGNAL(triggered(bool)),
            m_dialog_connectorProps, SLOT(setVisible(bool)));
    connect(m_dialog_connectorProps, SIGNAL(visibilityChanged(bool)),
            m_action_show_connector_properties_dialog,  SLOT(setChecked(bool)));
    addDockWidget(Qt::LeftDockWidgetArea, m_dialog_connectorProps);
    m_dialog_connectorProps->hide();

    m_dialog_alignment = new CreateAlignmentDialog(canvas);
    connect(m_tab_widget, SIGNAL(currentCanvasChanged(Canvas*)),
            m_dialog_alignment, SLOT(changeCanvas(Canvas*)));
    connect(m_action_show_create_alignment_dialog,  SIGNAL(triggered(bool)),
            m_dialog_alignment, SLOT(setVisible(bool)));
    connect(m_dialog_alignment, SIGNAL(visibilityChanged(bool)),
            m_action_show_create_alignment_dialog,  SLOT(setChecked(bool)));
    addDockWidget(Qt::RightDockWidgetArea, m_dialog_alignment);
    m_dialog_alignment->show();

    m_dialog_distribution = new  CreateDistributionDialog(canvas, this);
    connect(m_tab_widget, SIGNAL(currentCanvasChanged(Canvas*)),
            m_dialog_distribution, SLOT(changeCanvas(Canvas*)));
    connect(m_action_show_create_distribution_dialog,  SIGNAL(triggered(bool)),
            m_dialog_distribution, SLOT(setVisible(bool)));
    connect(m_dialog_distribution, SIGNAL(visibilityChanged(bool)),
            m_action_show_create_distribution_dialog,  SLOT(setChecked(bool)));
    addDockWidget(Qt::RightDockWidgetArea, m_dialog_distribution);
    m_dialog_distribution->show();

    m_dialog_separation = new CreateSeparationDialog(canvas, this);
    connect(m_tab_widget, SIGNAL(currentCanvasChanged(Canvas*)),
            m_dialog_separation, SLOT(changeCanvas(Canvas*)));
    connect(m_action_show_create_separation_dialog,  SIGNAL(triggered(bool)),
            m_dialog_separation, SLOT(setVisible(bool)));
    connect(m_dialog_separation, SIGNAL(visibilityChanged(bool)),
            m_action_show_create_separation_dialog,  SLOT(setChecked(bool)));
    addDockWidget(Qt::RightDockWidgetArea, m_dialog_separation);
    m_dialog_separation->show();

    m_dialog_template = new CreateTemplateDialog(canvas, this);
    connect(m_tab_widget, SIGNAL(currentCanvasChanged(Canvas*)),
            m_dialog_template, SLOT(changeCanvas(Canvas*)));
    connect(m_action_show_create_template_dialog,  SIGNAL(triggered(bool)),
            m_dialog_template, SLOT(setVisible(bool)));
    connect(m_dialog_template, SIGNAL(visibilityChanged(bool)),
            m_action_show_create_template_dialog,  SLOT(setChecked(bool)));
    m_dialog_template->hide();

    m_dialog_undo_history = new UndoHistoryDialog(
            m_tab_widget->undoGroup(), this);
    connect(m_action_show_undo_history_dialog,  SIGNAL(triggered(bool)),
            m_dialog_undo_history, SLOT(setVisible(bool)));
    connect(m_dialog_undo_history, SIGNAL(visibilityChanged(bool)),
            m_action_show_undo_history_dialog,  SLOT(setChecked(bool)));
    addDockWidget(Qt::LeftDockWidgetArea, m_dialog_undo_history);
    m_dialog_undo_history->hide();

    m_dialog_canvas_overview = new CanvasOverviewDialog(canvasview, this);
    connect(m_tab_widget, SIGNAL(currentCanvasViewChanged(CanvasView*)),
            m_dialog_canvas_overview, SLOT(changeCanvasView(CanvasView*)));
    connect(m_action_show_canvas_overview_dialog,  SIGNAL(triggered(bool)),
            m_dialog_canvas_overview, SLOT(setVisible(bool)));
    connect(m_dialog_canvas_overview, SIGNAL(visibilityChanged(bool)),
            m_action_show_canvas_overview_dialog,  SLOT(setChecked(bool)));
    addDockWidget(Qt::LeftDockWidgetArea, m_dialog_canvas_overview);
    m_dialog_canvas_overview->hide();

    // Allow plugins to initialise themselves and add things like
    // menu items and dock widgets to the main window.
    PluginApplicationManager *appPluginManager =
            sharedPluginApplicationManager();
    appPluginManager->applicationMainWindowInitialised(app);

    // Add help menu after everything else (if should be rightmost).
    m_help_menu = menuBar()->addMenu(tr("Help"));
    m_help_menu->addAction(m_homepage_action);
    m_help_menu->addSeparator();
    m_help_menu->addAction(m_about_action);

    // Restore window geometry and Dock Widget geometry.
    QSettings settings;
    restoreGeometry(settings.value("geometry").toByteArray());
    restoreState(settings.value("windowState").toByteArray());
}