Exemplo n.º 1
0
NavigationBar::NavigationBar(BrowserWindow* window)
    : QWidget(window)
    , m_window(window)
{
    setObjectName(QSL("navigationbar"));

    m_layout = new QHBoxLayout(this);
    m_layout->setMargin(style()->pixelMetric(QStyle::PM_ToolBarItemMargin, 0, this)
                          + style()->pixelMetric(QStyle::PM_ToolBarFrameWidth, 0, this));
    m_layout->setSpacing(style()->pixelMetric(QStyle::PM_ToolBarItemSpacing, 0, this));
    setLayout(m_layout);

    m_buttonBack = new ToolButton(this);
    m_buttonBack->setObjectName("navigation-button-back");
    m_buttonBack->setToolTip(tr("Back"));
    m_buttonBack->setToolButtonStyle(Qt::ToolButtonIconOnly);
    m_buttonBack->setToolbarButtonLook(true);
    m_buttonBack->setShowMenuOnRightClick(true);
    m_buttonBack->setAutoRaise(true);
    m_buttonBack->setEnabled(false);
    m_buttonBack->setFocusPolicy(Qt::NoFocus);

    m_buttonForward = new ToolButton(this);
    m_buttonForward->setObjectName("navigation-button-next");
    m_buttonForward->setToolTip(tr("Forward"));
    m_buttonForward->setToolButtonStyle(Qt::ToolButtonIconOnly);
    m_buttonForward->setToolbarButtonLook(true);
    m_buttonForward->setShowMenuOnRightClick(true);
    m_buttonForward->setAutoRaise(true);
    m_buttonForward->setEnabled(false);
    m_buttonForward->setFocusPolicy(Qt::NoFocus);

    QHBoxLayout* backNextLayout = new QHBoxLayout();
    backNextLayout->setContentsMargins(0, 0, 0, 0);
    backNextLayout->setSpacing(0);
    backNextLayout->addWidget(m_buttonBack);
    backNextLayout->addWidget(m_buttonForward);
    QWidget *backNextWidget = new QWidget(this);
    backNextWidget->setLayout(backNextLayout);

    m_reloadStop = new ReloadStopButton(this);

    ToolButton *buttonHome = new ToolButton(this);
    buttonHome->setObjectName("navigation-button-home");
    buttonHome->setToolTip(tr("Home"));
    buttonHome->setToolButtonStyle(Qt::ToolButtonIconOnly);
    buttonHome->setToolbarButtonLook(true);
    buttonHome->setAutoRaise(true);
    buttonHome->setFocusPolicy(Qt::NoFocus);

    ToolButton *buttonAddTab = new ToolButton(this);
    buttonAddTab->setObjectName("navigation-button-addtab");
    buttonAddTab->setToolTip(tr("New Tab"));
    buttonAddTab->setToolButtonStyle(Qt::ToolButtonIconOnly);
    buttonAddTab->setToolbarButtonLook(true);
    buttonAddTab->setAutoRaise(true);
    buttonAddTab->setFocusPolicy(Qt::NoFocus);

    m_menuBack = new Menu(this);
    m_menuBack->setCloseOnMiddleClick(true);
    m_buttonBack->setMenu(m_menuBack);
    connect(m_buttonBack, SIGNAL(aboutToShowMenu()), this, SLOT(aboutToShowHistoryBackMenu()));

    m_menuForward = new Menu(this);
    m_menuForward->setCloseOnMiddleClick(true);
    m_buttonForward->setMenu(m_menuForward);
    connect(m_buttonForward, SIGNAL(aboutToShowMenu()), this, SLOT(aboutToShowHistoryNextMenu()));

    ToolButton *buttonTools = new ToolButton(this);
    buttonTools->setObjectName("navigation-button-tools");
    buttonTools->setPopupMode(QToolButton::InstantPopup);
    buttonTools->setToolbarButtonLook(true);
    buttonTools->setToolTip(tr("Tools"));
    buttonTools->setAutoRaise(true);
    buttonTools->setFocusPolicy(Qt::NoFocus);
    buttonTools->setShowMenuInside(true);

    m_menuTools = new Menu(this);
    buttonTools->setMenu(m_menuTools);
    connect(buttonTools, &ToolButton::aboutToShowMenu, this, &NavigationBar::aboutToShowToolsMenu);

    m_supMenu = new ToolButton(this);
    m_supMenu->setObjectName("navigation-button-supermenu");
    m_supMenu->setPopupMode(QToolButton::InstantPopup);
    m_supMenu->setToolbarButtonLook(true);
    m_supMenu->setToolTip(tr("Main Menu"));
    m_supMenu->setAutoRaise(true);
    m_supMenu->setFocusPolicy(Qt::NoFocus);
    m_supMenu->setMenu(m_window->superMenu());
    m_supMenu->setShowMenuInside(true);

    m_searchLine = new WebSearchBar(m_window);

    m_navigationSplitter = new QSplitter(this);
    m_navigationSplitter->addWidget(m_window->tabWidget()->locationBars());
    m_navigationSplitter->addWidget(m_searchLine);

    m_navigationSplitter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
    m_navigationSplitter->setCollapsible(0, false);

    m_exitFullscreen = new ToolButton(this);
    m_exitFullscreen->setObjectName("navigation-button-exitfullscreen");
    m_exitFullscreen->setToolTip(tr("Exit Fullscreen"));
    m_exitFullscreen->setToolButtonStyle(Qt::ToolButtonIconOnly);
    m_exitFullscreen->setToolbarButtonLook(true);
    m_exitFullscreen->setFocusPolicy(Qt::NoFocus);
    m_exitFullscreen->setAutoRaise(true);
    m_exitFullscreen->setVisible(false);

    setContextMenuPolicy(Qt::CustomContextMenu);
    connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint)));

    connect(m_buttonBack, SIGNAL(clicked()), this, SLOT(goBack()));
    connect(m_buttonBack, SIGNAL(middleMouseClicked()), this, SLOT(goBackInNewTab()));
    connect(m_buttonBack, SIGNAL(controlClicked()), this, SLOT(goBackInNewTab()));
    connect(m_buttonForward, SIGNAL(clicked()), this, SLOT(goForward()));
    connect(m_buttonForward, SIGNAL(middleMouseClicked()), this, SLOT(goForwardInNewTab()));
    connect(m_buttonForward, SIGNAL(controlClicked()), this, SLOT(goForwardInNewTab()));

    connect(m_reloadStop, SIGNAL(stopClicked()), this, SLOT(stop()));
    connect(m_reloadStop, SIGNAL(reloadClicked()), this, SLOT(reload()));
    connect(buttonHome, SIGNAL(clicked()), m_window, SLOT(goHome()));
    connect(buttonHome, SIGNAL(middleMouseClicked()), m_window, SLOT(goHomeInNewTab()));
    connect(buttonHome, SIGNAL(controlClicked()), m_window, SLOT(goHomeInNewTab()));
    connect(buttonAddTab, SIGNAL(clicked()), m_window, SLOT(addTab()));
    connect(buttonAddTab, SIGNAL(middleMouseClicked()), m_window->tabWidget(), SLOT(addTabFromClipboard()));
    connect(m_exitFullscreen, SIGNAL(clicked(bool)), m_window, SLOT(toggleFullScreen()));

    addWidget(backNextWidget, QSL("button-backforward"), tr("Back and Forward buttons"));
    addWidget(m_reloadStop, QSL("button-reloadstop"), tr("Reload button"));
    addWidget(buttonHome, QSL("button-home"), tr("Home button"));
    addWidget(buttonAddTab, QSL("button-addtab"), tr("Add tab button"));
    addWidget(m_navigationSplitter, QSL("locationbar"), tr("Address and Search bar"));
    addWidget(buttonTools, QSL("button-tools"), tr("Tools button"));
    addWidget(m_exitFullscreen, QSL("button-exitfullscreen"), tr("Exit Fullscreen button"));

    loadSettings();
}
Exemplo n.º 2
0
//------------------------------------------------------------------------------
QWidget *FeedPropertiesDialog::createGeneralTab()
{
  QWidget *tab = new QWidget();

  QGridLayout *layoutGeneralGrid = new QGridLayout();
  QLabel *labelTitleCapt = new QLabel(tr("Title:"));
  QLabel *labelHomepageCapt = new QLabel(tr("Homepage:"));
  QLabel *labelURLCapt = new QLabel(tr("Feed URL:"));

  QHBoxLayout *layoutGeneralTitle = new QHBoxLayout();
  editTitle = new LineEdit();
  ToolButton *loadTitleButton = new ToolButton();
  loadTitleButton->setIcon(QIcon(":/images/updateFeed"));
  loadTitleButton->setIconSize(QSize(16, 16));
  loadTitleButton->setToolTip(tr("Load Title"));
  loadTitleButton->setFocusPolicy(Qt::NoFocus);

  QMenu *selectIconMenu = new QMenu();
  selectIconMenu->addAction(tr("Load Favicon"));
  selectIconMenu->addSeparator();
  selectIconMenu->addAction(tr("Select Icon..."));
  selectIconButton_ = new QToolButton(this);
  selectIconButton_->setIconSize(QSize(16, 16));
  selectIconButton_->setToolTip(tr("Select Icon"));
  selectIconButton_->setFocusPolicy(Qt::NoFocus);
  selectIconButton_->setPopupMode(QToolButton::MenuButtonPopup);
  selectIconButton_->setMenu(selectIconMenu);

  layoutGeneralTitle->addWidget(editTitle, 1);
  layoutGeneralTitle->addWidget(loadTitleButton);
  layoutGeneralTitle->addWidget(selectIconButton_);
  editURL = new LineEdit();

  disableUpdate_ = new QCheckBox(tr("Disable update"));
  disableUpdate_->setChecked(false);

  updateEnable_ = new QCheckBox(tr("Automatically update every"));
  updateInterval_ = new QSpinBox();
  updateInterval_->setEnabled(false);
  updateInterval_->setRange(1, 9999);
  connect(updateEnable_, SIGNAL(toggled(bool)),
          updateInterval_, SLOT(setEnabled(bool)));

  updateIntervalType_ = new QComboBox(this);
  updateIntervalType_->setEnabled(false);
  QStringList intervalTypeList;
  intervalTypeList << tr("seconds") << tr("minutes")  << tr("hours");
  updateIntervalType_->addItems(intervalTypeList);
  connect(updateEnable_, SIGNAL(toggled(bool)),
          updateIntervalType_, SLOT(setEnabled(bool)));

  QHBoxLayout *updateFeedsLayout = new QHBoxLayout();
  updateFeedsLayout->setMargin(0);
  updateFeedsLayout->addWidget(updateEnable_);
  updateFeedsLayout->addWidget(updateInterval_);
  updateFeedsLayout->addWidget(updateIntervalType_);
  updateFeedsLayout->addStretch();

  connect(disableUpdate_, SIGNAL(toggled(bool)),
          updateEnable_, SLOT(setDisabled(bool)));
  connect(disableUpdate_, SIGNAL(toggled(bool)),
          updateInterval_, SLOT(setDisabled(bool)));
  connect(disableUpdate_, SIGNAL(toggled(bool)),
          updateIntervalType_, SLOT(setDisabled(bool)));

  starredOn_ = new QCheckBox(tr("Starred"));
  displayOnStartup = new QCheckBox(tr("Display in new tab on startup"));
  duplicateNewsMode_ = new QCheckBox(tr("Automatically delete duplicate news"));

  QHBoxLayout *layoutGeneralHomepage = new QHBoxLayout();
  labelHomepage = new QLabel();
  labelHomepage->setOpenExternalLinks(true);
  layoutGeneralHomepage->addWidget(labelHomepageCapt);
  layoutGeneralHomepage->addWidget(labelHomepage, 1);

  layoutGeneralGrid->addWidget(labelTitleCapt, 0, 0);
  layoutGeneralGrid->addLayout(layoutGeneralTitle, 0 ,1);
  layoutGeneralGrid->addWidget(labelURLCapt, 1, 0);
  layoutGeneralGrid->addWidget(editURL, 1, 1);

  QVBoxLayout *tabLayout = new QVBoxLayout(tab);
  tabLayout->setMargin(10);
  tabLayout->setSpacing(5);
  tabLayout->addLayout(layoutGeneralGrid);
  tabLayout->addLayout(layoutGeneralHomepage);
  tabLayout->addSpacing(15);
  tabLayout->addWidget(disableUpdate_);
  tabLayout->addLayout(updateFeedsLayout);
  tabLayout->addSpacing(15);
  tabLayout->addWidget(starredOn_);
  tabLayout->addWidget(displayOnStartup);
  tabLayout->addWidget(duplicateNewsMode_);
  tabLayout->addStretch();

  connect(loadTitleButton, SIGNAL(clicked()), this, SLOT(setDefaultTitle()));
  connect(selectIconButton_, SIGNAL(clicked()),
          this, SLOT(selectIcon()));
  connect(selectIconMenu->actions().at(0), SIGNAL(triggered()),
          this, SLOT(loadDefaultIcon()));
  connect(selectIconMenu->actions().at(2), SIGNAL(triggered()),
          this, SLOT(selectIcon()));

  if (!isFeed_) {
    loadTitleButton->hide();
    selectIconButton_->hide();
    labelURLCapt->hide();
    editURL->hide();
    labelHomepageCapt->hide();
    labelHomepage->hide();
    starredOn_->hide();
    duplicateNewsMode_->hide();
  }

  return tab;
}