Esempio n. 1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent), ui(new Ui::MainWindow), conf(), dbm(this, &conf), m_shouldExit(false)
{
    ui->setupUi(this);

    // Set size and position
    int dWidth = QApplication::desktop()->availableGeometry().width();
    int dHeight = QApplication::desktop()->availableGeometry().height();
    resize(dWidth * 75/100, dHeight * 75/100);

    QRect geom = geometry();
    geom.moveCenter(QApplication::desktop()->availableGeometry().center());
    this->setGeometry(geom);

    // Set additional UI sizes
    QList<int> hsizes, vsizes;
    hsizes << this->width() / 3 << this->width() * 2 / 3;
    ui->splitter->setSizes(hsizes);
    vsizes << this->height() * 2 / 3 << this->height() / 3;
    ui->splitterFT->setSizes(vsizes);

    // Add additional UI controls
    ui->action_importFirefoxBookmarks->setEnabled(false); //Not implemented yet.
    QMenu* menuFile = new QMenu("    &File    ");
    menuFile->addAction(ui->actionImportUrlsAsBookmarks);
    menuFile->addSeparator();
    menuFile->addAction(ui->action_importFirefoxBookmarks);
    menuFile->addAction(ui->actionImportFirefoxBookmarksJSONfile);
    menuFile->addSeparator();
    menuFile->addAction(ui->actionSettings);

    QMenu* menuDebug = new QMenu("    &Debug    ");
    menuDebug->addAction(ui->actionGetMHT);

    QList<QMenu*> menus = QList<QMenu*>() << menuFile << menuDebug;
    foreach (QMenu* menu, menus)
    {
        QToolButton* btn = new QToolButton();
        btn->setText(menu->title());
        btn->setMenu(menu);
        btn->setPopupMode(QToolButton::InstantPopup);
        //btn->setArrowType(Qt::LeftArrow);
        btn->setToolButtonStyle(Qt::ToolButtonTextOnly);
        ui->mainToolBar->addWidget(btn);
    }
Esempio n. 2
0
void DlgCustomToolbarsImp::setActionGroup(QAction* action, const QList<QAction*>& group)
{
    // See also ActionGroup::addTo()
    QList<QWidget*> widgets = action->associatedWidgets();
    for (QList<QWidget*>::iterator it = widgets.begin(); it != widgets.end(); ++it) {
        QToolButton* tb = qobject_cast<QToolButton*>(*it);
        if (tb) {
            QMenu* menu = tb->menu();
            if (!menu) {
                tb->setPopupMode(QToolButton::MenuButtonPopup);
                tb->setObjectName(QString::fromLatin1("qt_toolbutton_menubutton"));
                QMenu* menu = new QMenu(tb);
                menu->addActions(group);
                tb->setMenu(menu);
            }
        }
    }
}
Esempio n. 3
0
void BookmarksToolBar::build()
{
    clear();

    for (int i = 0; i < m_bookmarksModel->rowCount(m_root); ++i) {
        QModelIndex idx = m_bookmarksModel->index(i, 0, m_root);
        QVariant variant;
        variant.setValue(idx);

        QString title = idx.data().toString();
        bool folder = m_bookmarksModel->hasChildren(idx);

        QToolButton *button = 0;
        if (folder)
            button = new QToolButton(this);
        else
            button = new BookmarkToolButton(this);

        button->setPopupMode(QToolButton::InstantPopup);
        button->setToolButtonStyle(Qt::ToolButtonTextOnly);

        QAction *action = addWidget(button);
        action->setData(variant);
        action->setText(title);
        button->setDefaultAction(action);

        if (folder) {
            button->setArrowType(Qt::DownArrow);

            ModelMenu *menu = new BookmarksMenu(this);
            menu->setModel(m_bookmarksModel);
            menu->setRootIndex(idx);
            menu->addAction(new QAction(menu));
            action->setMenu(menu);

            connect(menu, SIGNAL(openUrl(const QUrl &, const QString &)),
                    this, SIGNAL(openUrl(const QUrl &, const QString &)));
            connect(menu, SIGNAL(openUrl(const QUrl &, TabWidget::OpenUrlIn, const QString &)),
                    this, SIGNAL(openUrl(const QUrl &, TabWidget::OpenUrlIn, const QString &)));
        } else {
            connect(action, SIGNAL(triggered()),
                    this, SLOT(openBookmark()));
        }
    }
Esempio n. 4
0
FilterWidget::FilterWidget(QWidget *parent)
    : QLineEdit(parent)
    , m_patternGroup(new QActionGroup(this))
{
    setClearButtonEnabled(true);
    connect(this, SIGNAL(textChanged(QString)), this, SIGNAL(filterChanged()));

    QMenu *menu = new QMenu(this);
    m_caseSensitivityAction = menu->addAction(tr("Case Sensitive"));
    m_caseSensitivityAction->setCheckable(true);
    connect(m_caseSensitivityAction, SIGNAL(toggled(bool)), this, SIGNAL(filterChanged()));

    menu->addSeparator();
    m_patternGroup->setExclusive(true);
    QAction *patternAction = menu->addAction("Fixed String");
    patternAction->setData(QVariant(int(QRegExp::FixedString)));
    patternAction->setCheckable(true);
    patternAction->setChecked(true);
    m_patternGroup->addAction(patternAction);
    patternAction = menu->addAction("Regular Expression");
    patternAction->setCheckable(true);
    patternAction->setData(QVariant(int(QRegExp::RegExp2)));
    m_patternGroup->addAction(patternAction);
    patternAction = menu->addAction("Wildcard");
    patternAction->setCheckable(true);
    patternAction->setData(QVariant(int(QRegExp::Wildcard)));
    m_patternGroup->addAction(patternAction);
    connect(m_patternGroup, SIGNAL(triggered(QAction*)), this, SIGNAL(filterChanged()));

    const QIcon icon = QIcon(QPixmap(":/images/find.png"));
    QToolButton *optionsButton = new QToolButton;
#ifndef QT_NO_CURSOR
    optionsButton->setCursor(Qt::ArrowCursor);
#endif
    optionsButton->setFocusPolicy(Qt::NoFocus);
    optionsButton->setStyleSheet("* { border: none; }");
    optionsButton->setIcon(icon);
    optionsButton->setMenu(menu);
    optionsButton->setPopupMode(QToolButton::InstantPopup);

    QWidgetAction *optionsAction = new QWidgetAction(this);
    optionsAction->setDefaultWidget(optionsButton);
    addAction(optionsAction, QLineEdit::LeadingPosition);
}
void ZLQtApplicationWindow::addToolbarItem(ZLToolbar::ItemPtr item) {
	QToolBar *tb = toolbar(type(*item));
	QAction *action = 0;

	switch (item->type()) {
		case ZLToolbar::Item::PLAIN_BUTTON:
		case ZLToolbar::Item::TOGGLE_BUTTON:
			action = new ZLQtToolBarAction(this, (ZLToolbar::AbstractButtonItem&)*item);
			tb->addAction(action);
			break;
		case ZLToolbar::Item::MENU_BUTTON:
		{
			ZLToolbar::MenuButtonItem &buttonItem = (ZLToolbar::MenuButtonItem&)*item;
			QToolButton *button = new QToolButton(tb);
			button->setFocusPolicy(Qt::NoFocus);
			button->setDefaultAction(new ZLQtToolBarAction(this, buttonItem));
			button->setMenu(new QMenu(button));
			button->setPopupMode(QToolButton::MenuButtonPopup);
			action = tb->addWidget(button);
			myMenuButtons[&buttonItem] = button;
			shared_ptr<ZLPopupData> popupData = buttonItem.popupData();
			myPopupIdMap[&buttonItem] =
				popupData.isNull() ? (size_t)-1 : (popupData->id() - 1);
			break;
		}
		case ZLToolbar::Item::TEXT_FIELD:
		case ZLToolbar::Item::SEARCH_FIELD:
		{
			ZLToolbar::ParameterItem &textFieldItem =
				(ZLToolbar::ParameterItem&)*item;
			LineEditParameter *para = new LineEditParameter(tb, *this, textFieldItem);
			addVisualParameter(textFieldItem.parameterId(), para);
			action = para->action();
			break;
		}
		case ZLToolbar::Item::SEPARATOR:
			action = tb->addSeparator();
			break;
	}

	if (action != 0) {
		myActions[&*item] = action;
	}
}
Esempio n. 6
0
void GTMainWindow::createToolBars(){	
	fileToolBar = addToolBar(tr("File"));
	fileToolBar->setFloatable(false);
	fileToolBar->setMovable(false);
	fileToolBar->setIconSize(QSize(25, 25));

	fileMenu =  new QMenu();
	fileMenu->addAction(newAct);

	fileMenu->addAction(openAct);

	fileMenu->addAction(saveAct);

	fileMenu->addAction(closeAct);
	fileMenu->addSeparator();
	fileMenu->addAction(exitAct);

	QToolButton* toolButton = new QToolButton();
	toolButton->setIcon(QIcon(":/Resources/gt_icon.png"));
	toolButton->setMenu(fileMenu);
	toolButton->setPopupMode(QToolButton::InstantPopup);
	fileToolBar->addWidget(toolButton);

	fileToolBar->addSeparator();
	fileToolBar->addAction(newAct);

	fileToolBar->addAction(openAct);

	fileToolBar->addAction(saveAct);

	fileToolBar->addAction(closeAct);

	fileToolBar->addSeparator();

	//ui->gtStatusWidget->setParent(fileToolBar);
	//ui->gtStatusWidget->setVisible(false);
	//fileToolBar->addWidget(ui->gtStatusWidget);

	/*editToolBar = addToolBar(tr("Edit"));
	editToolBar->addAction(cutAct);
	editToolBar->addAction(copyAct);
	editToolBar->addAction(pasteAct);*/
}
Esempio n. 7
0
void SideDockWidget::createMenu(Qt::DockWidgetArea /*area*/)
{
//    QMenu *moveMenu = new QMenu(tr("Move To"),this);
//    QAction *act = new QAction(tr("OutputBar"),this);
//    act->setData(area);
//    moveMenu->addAction(act);
//    connect(act,SIGNAL(triggered()),this,SLOT(moveAction()));

    m_menu = new QMenu(this);

    QToolButton *btn = new QToolButton(m_toolBar);
    btn->setPopupMode(QToolButton::InstantPopup);
    btn->setIcon(QIcon("icon:images/movemenu.png"));
    btn->setMenu(m_menu);
    btn->setText(tr("SideBar"));
    btn->setToolTip(tr("Show SideBar"));
    btn->setStyleSheet("QToolButton::menu-indicator {image: none;}");
    m_toolBar->insertWidget(m_closeAct,btn);
}
Esempio n. 8
0
static void
replaceButtons (QToolBar* dest, QWidget* src) {
   if (src == NULL || dest == NULL)
     FAILED ("replaceButtons expects valid objects");
  dest->setUpdatesEnabled (false);
  bool visible = dest->isVisible();
  if (visible) dest->hide(); //TRICK: to avoid flicker of the dest widget
  replaceActions (dest, src);
  QList<QObject*> list = dest->children();
  for (int i = 0; i < list.count(); ++i) {
    QToolButton* button = qobject_cast<QToolButton*> (list[i]);
    if (button) {
      button->setPopupMode (QToolButton::InstantPopup);
      button->setStyle (qtmstyle());
    }
  }
  if (visible) dest->show(); //TRICK: see above
  dest->setUpdatesEnabled (true);
}
Esempio n. 9
0
GuiFindToolBar::GuiFindToolBar(GuiMainWindow *p)
    : QToolBar(p),
      mainWnd(p)
{
    searchedText = new QLineEdit();
    findTextFlag = false;
    currentRow = -1;
    currentCol = -1;
    pageStartPosition = 0;
    QToolButton *b;
    currentSearchedText = "";
    addWidget(searchedText);

    searchedText->installEventFilter(this);

    b = new QToolButton(this);
    b->setText("Up");
    connect(b, SIGNAL(clicked()), this, SLOT(on_findUp()));
    addWidget(b);

    b = new QToolButton(this);
    b->setText("Down");
    connect(b, SIGNAL(clicked()), this, SLOT(on_findDown()));
    addWidget(b);

    b = new QToolButton(this);
    b->setIcon(QIcon(":/images/cog_alt_16x16.png"));
    b->setMenu(p->menuGetMenuById(MENU_FIND_OPTIONS));
    b->setPopupMode(QToolButton::InstantPopup);
    addWidget(b);

    b = new QToolButton(this);
    b->setIcon(QIcon(":/images/x_14x14.png"));
    connect(b, SIGNAL(clicked()), this, SLOT(on_findClose()));
    addWidget(b);

    setIconSize(QSize(16, 16));
    setMovable(false);
    setAutoFillBackground(true);
    adjustSize();

    searchedText->setFocus();
}
Esempio n. 10
0
void BibleTime::initToolbars() {
    QToolButton *openWorkButton = new QToolButton(this);
    openWorkButton->setDefaultAction(m_openWorkAction);
    openWorkButton->setPopupMode(QToolButton::InstantPopup);
    m_mainToolBar->addWidget(openWorkButton);

    m_mainToolBar->addAction(m_windowFullscreenAction);
    QAction *a = m_actionCollection->action("showBookshelf");
    Q_ASSERT(a != 0);
    m_mainToolBar->addAction(a);
    a = m_actionCollection->action("showBookmarks");
    Q_ASSERT(a != 0);
    m_mainToolBar->addAction(a);
    a = m_actionCollection->action("showMag");
    Q_ASSERT(a != 0);
    m_mainToolBar->addAction(a);
    m_mainToolBar->addAction(m_searchOpenWorksAction);
    m_mainToolBar->addAction(m_openHandbookAction);
}
Esempio n. 11
0
void MainWindow::updateModulesenus(QList<QMenu *> list)
{
    if (list.count() > 0)
    {
        for (int i = 0; i < list.count(); ++i)
        {
            QMenu *menu = list.at(i);
            if (menu != 0)
            {
                QToolButton* btn = new QToolButton(this);
                btn->setText(menu->title());
                btn->setPopupMode(QToolButton::InstantPopup);
                btn->setToolTip(menu->title());
                btn->setMenu(list.at(i));
                _ui->toolBar->insertWidget(actOptions, btn);
            }
        }
        _ui->toolBar->insertSeparator(actOptions);
    }
}
Esempio n. 12
0
MainTab::MainTab(QWidget* parent) : QTabWidget(parent), m_lastIndex(0), m_lastIndexCur(0)
{
    m_toolTabClose = new QToolButton(this);
    m_toolTabClose->setIcon(QIcon(":/menu/tab_remove.png"));
    m_toolTabClose->setEnabled(false);
    setCornerWidget(m_toolTabClose);

    connect(m_toolTabClose, SIGNAL(clicked()), this, SLOT(closeTabBtn()));
    connect(this, SIGNAL(currentChanged(int)), this, SLOT(currentTabChanged(int)));

    QToolButton* btn = new QToolButton(this);
    QMenu* tabOpenMenu = new QMenu(btn);

    initAppTools(tabOpenMenu);

    btn->setIcon(QIcon(":/menu/tab_new.png"));
    btn->setPopupMode(QToolButton::InstantPopup);
    btn->setMenu(tabOpenMenu);
    setCornerWidget(btn, Qt::TopLeftCorner);
}
Esempio n. 13
0
QWidget* PropertyEditor::createWidgetForFlags(const QString& name, const QVariant& value, QMetaEnum me, const QString &detail, QWidget* parent)
{
    mProperties[name] = value;
    QToolButton *btn = new QToolButton(parent);
    if (!detail.isEmpty())
        btn->setToolTip(detail);
    btn->setObjectName(name);
    btn->setText(QObject::tr(name.toUtf8().constData()));
    btn->setPopupMode(QToolButton::InstantPopup);
    ClickableMenu *menu = new ClickableMenu(btn);
    menu->setObjectName(name);
    btn->setMenu(menu);
    for (int i = 0; i < me.keyCount(); ++i) {
        QAction * a = menu->addAction(QString::fromLatin1(me.key(i)));
        a->setCheckable(true);
        a->setData(me.value(i));
        a->setChecked(value.toInt() & me.value(i));
    }
    connect(menu, SIGNAL(triggered(QAction*)), SLOT(onFlagChange(QAction*)));
    return btn;
}
Esempio n. 14
0
void BookmarksToolBar::build()
{
    clear();
    for (int i = 0; i < m_bookmarksModel->rowCount(m_root); ++i) {
        QModelIndex idx = m_bookmarksModel->index(i, 0, m_root);
        if (m_bookmarksModel->hasChildren(idx)) {
            QToolButton *button = new QToolButton(this);
            button->setPopupMode(QToolButton::InstantPopup);
            button->setArrowType(Qt::DownArrow);
            button->setText(idx.data().toString());
            ModelMenu *menu = new ModelMenu(this);
            connect(menu, SIGNAL(activated(const QModelIndex &)),
                    this, SLOT(activated(const QModelIndex &)));
            menu->setModel(m_bookmarksModel);
            menu->setRootIndex(idx);
            menu->addAction(new QAction(menu));
            button->setMenu(menu);
            button->setToolButtonStyle(Qt::ToolButtonTextOnly);
            QAction *a = addWidget(button);
            a->setText(idx.data().toString());
        } else {
Esempio n. 15
0
void LiveWidget::setupMenus()
{
    this->contextMenuLiveDropdown = new QMenu(this);
    this->contextMenuLiveDropdown->setTitle("Dropdown");

    this->audioTrackMenu = new QMenu(this);
    this->audioTrackMenu->setTitle("Audio Track");

    this->audioMenu = new QMenu(this);
    this->audioMenu->setTitle("Audio");
    this->audioTrackMenuAction = this->audioMenu->addMenu(this->audioTrackMenu);
    this->audioMenu->addSeparator();
    this->muteAction = this->audioMenu->addAction(/*QIcon(":/Graphics/Images/MuteSound.png"),*/ "Mute");
    this->muteAction->setCheckable(true);

    this->streamMenu = new QMenu(this);
    this->streamMenu->setTitle("Connect to");
    this->streamMenuAction = this->contextMenuLiveDropdown->addMenu(this->streamMenu);
    this->contextMenuLiveDropdown->addSeparator();
    this->contextMenuLiveDropdown->addMenu(this->audioMenu);
    this->contextMenuLiveDropdown->addSeparator();
    this->windowModeAction = this->contextMenuLiveDropdown->addAction(/*QIcon(":/Graphics/Images/WindowMode.png"),*/ "Window Mode", this, SLOT(toggleWindowMode()));
    this->windowModeAction->setCheckable(true);
    this->contextMenuLiveDropdown->addSeparator();
    this->expandCollapseAction = this->contextMenuLiveDropdown->addAction(/*QIcon(":/Graphics/Images/Collapse.png"),*/ "Collapse", this, SLOT(toggleExpandCollapse()));

    QObject::connect(this->streamMenuAction, SIGNAL(hovered()), this, SLOT(streamMenuHovered()));
    QObject::connect(this->audioTrackMenuAction, SIGNAL(hovered()), this, SLOT(audioTrackMenuHovered()));
    QObject::connect(this->streamMenu, SIGNAL(triggered(QAction*)), this, SLOT(streamMenuActionTriggered(QAction*)));
    QObject::connect(this->audioTrackMenu, SIGNAL(triggered(QAction*)), this, SLOT(audioMenuActionTriggered(QAction*)));
    QObject::connect(this->muteAction, SIGNAL(toggled(bool)), this, SLOT(muteAudio(bool)));

    QToolButton* toolButtonLiveDropdown = new QToolButton(this);
    toolButtonLiveDropdown->setObjectName("toolButtonLiveDropdown");
    toolButtonLiveDropdown->setMenu(this->contextMenuLiveDropdown);
    toolButtonLiveDropdown->setPopupMode(QToolButton::InstantPopup);

    this->tabWidgetLive->setCornerWidget(toolButtonLiveDropdown);
    //this->tabWidgetPreview->setTabIcon(0, QIcon(":/Graphics/Images/TabSplitter.png"));
}
Esempio n. 16
0
QWidget *QgsAttributeTableView::createActionWidget( QgsFeatureId fid )
{
  QgsAttributeTableConfig attributeTableConfig = mFilterModel->layer()->attributeTableConfig();

  QToolButton *toolButton = nullptr;
  QWidget *container = nullptr;

  if ( attributeTableConfig.actionWidgetStyle() == QgsAttributeTableConfig::DropDown )
  {
    toolButton  = new QToolButton();
    toolButton->setToolButtonStyle( Qt::ToolButtonTextBesideIcon );
    toolButton->setPopupMode( QToolButton::MenuButtonPopup );
    container = toolButton;
  }
  else
  {
    container = new QWidget();
    container->setLayout( new QHBoxLayout() );
    container->layout()->setMargin( 0 );
  }

  QList< QAction * > actionList;
  QAction *defaultAction = nullptr;

  // first add user created layer actions
  QList<QgsAction> actions = mFilterModel->layer()->actions()->actions( QStringLiteral( "Feature" ) );
  Q_FOREACH ( const QgsAction &action, actions )
  {
    QString actionTitle = !action.shortTitle().isEmpty() ? action.shortTitle() : action.icon().isNull() ? action.name() : QLatin1String( "" );
    QAction *act = new QAction( action.icon(), actionTitle, container );
    act->setToolTip( action.name() );
    act->setData( "user_action" );
    act->setProperty( "fid", fid );
    act->setProperty( "action_id", action.id() );
    connect( act, &QAction::triggered, this, &QgsAttributeTableView::actionTriggered );
    actionList << act;

    if ( mFilterModel->layer()->actions()->defaultAction( QStringLiteral( "AttributeTableRow" ) ).id() == action.id() )
      defaultAction = act;
  }
Esempio n. 17
0
MainWin::MainWin(CoreI *core, QWidget *parent)
	: QMainWindow(parent), core_i(core), mousePressed(false),
		closeToTray(false), hideFrame(false), toolWindow(false), roundCorners(false), onTop(false)
{
	ui.setupUi(this);

	icons_i = (IconsI *)core_i->get_interface(INAME_ICONS);
	if(icons_i) setWindowIcon(icons_i->get_icon("generic"));
	menus_i = (MenusI *)core_i->get_interface(INAME_MENUS);

	QAction *exitAct;
	if(menus_i) {
		exitAct = menus_i->add_menu_action("Main Menu", tr("E&xit"), "quit");
		sepAction = menus_i->add_menu_separator("Main Menu", exitAct);
		winMenu = menus_i->get_menu("Main Menu");
	} else {
		winMenu = new QMenu("Main Menu", this);
		sepAction = winMenu->addSeparator();
		exitAct = new QAction(QApplication::style()->standardIcon(QStyle::SP_TitleBarCloseButton), tr("E&xit"), this);
		winMenu->addAction(exitAct);
	}
	exitAct->setShortcut(tr("Ctrl+Q"));
	connect(exitAct, SIGNAL(triggered()), this, SLOT(quit()));

	QToolButton *mainMenuButton = new QToolButton(this);
	mainMenuButton->setMenu(winMenu);
	mainMenuButton->setIcon(winMenu->icon());
	mainMenuButton->setPopupMode(QToolButton::InstantPopup);
	ui.toolBar->addWidget(mainMenuButton);
	ui.toolBar->addAction(exitAct);

	systray = new QSystemTrayIcon(this);
	if(icons_i) systray->setIcon(icons_i->get_icon("generic"));
	connect(systray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(systrayActivated(QSystemTrayIcon::ActivationReason)));
	systray->setToolTip("saje");
	systray->setContextMenu(winMenu);
	systray->show();

	connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), this, SLOT(ensureOnScreen(int)));
}
Esempio n. 18
0
void ToolbarEditor::load(QWidget *w, QStringList l, QList<QAction *> actions_list)
{
    qDebug("ToolbarEditor::load: '%s'", w->objectName().toUtf8().data());

    QAction *action;

    for (int n = 0; n < l.count(); n++) {
        qDebug("ToolbarEditor::load: loading action %s", l[n].toUtf8().data());

        if (l[n] == "separator") {
            qDebug("ToolbarEditor::load: adding separator");
            QAction *sep = new QAction(w);
            sep->setSeparator(true);
            w->addAction(sep);
        } else {
            action = findAction(l[n], actions_list);

            if (action) {
                w->addAction(action);

                if (action->objectName().endsWith("_menu")) {
                    // If the action is a menu and is in a toolbar, as a toolbutton, change some of its properties
                    QToolBar *toolbar = qobject_cast<QToolBar *>(w);

                    if (toolbar) {
                        QToolButton *button = qobject_cast<QToolButton *>(toolbar->widgetForAction(action));

                        if (button) {
                            //qDebug("ToolbarEditor::load: action %s is a toolbutton", action->objectName().toUtf8().constData());
                            button->setPopupMode(QToolButton::InstantPopup);
                            //button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
                        }
                    }
                }
            } else {
                qWarning("ToolbarEditor::load: action %s not found", l[n].toUtf8().data());
            }
        }
    }
}
Esempio n. 19
0
KonqHistoryDialog::KonqHistoryDialog(KonqMainWindow *parent)
    : KDialog(parent), m_mainWindow(parent)
{
    setCaption(i18nc("@title:window", "History"));
    setButtons(KDialog::Close);

    QVBoxLayout *mainLayout = new QVBoxLayout(mainWidget());
    mainLayout->setMargin(0);

    m_historyView = new KonqHistoryView(mainWidget());
    connect(m_historyView->treeView(), SIGNAL(doubleClicked(QModelIndex)), this, SLOT(slotOpenWindowForIndex(QModelIndex)));
    connect(m_historyView, &KonqHistoryView::openUrlInNewWindow, this, &KonqHistoryDialog::slotOpenWindow);
    connect(m_historyView, &KonqHistoryView::openUrlInNewTab, this, &KonqHistoryDialog::slotOpenTab);

    KActionCollection *collection = m_historyView->actionCollection();

    QToolBar *toolBar = new QToolBar(mainWidget());
    toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    QToolButton *sortButton = new QToolButton(toolBar);
    sortButton->setText(i18nc("@action:inmenu Parent of 'By Name' and 'By Date'", "Sort"));
    sortButton->setIcon(QIcon::fromTheme(QStringLiteral("view-sort-ascending")));
    sortButton->setPopupMode(QToolButton::InstantPopup);
    sortButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    QMenu *sortMenu = new QMenu(sortButton);
    sortMenu->addAction(collection->action(QStringLiteral("byName")));
    sortMenu->addAction(collection->action(QStringLiteral("byDate")));
    sortButton->setMenu(sortMenu);
    toolBar->addWidget(sortButton);
    toolBar->addSeparator();
    toolBar->addAction(collection->action(QStringLiteral("preferences")));

    mainLayout->addWidget(toolBar);
    mainLayout->addWidget(m_historyView);

    restoreDialogSize(KSharedConfig::openConfig()->group("History Dialog"));

    // give focus to the search line edit when opening the dialog (#240513)
    m_historyView->lineEdit()->setFocus();
}
Esempio n. 20
0
QToolButton * ToolBar::createPushButton(QAction *before, ToolBarAction &action)
{
	if (!Actions::instance()->contains(action.actionName))
		return nullptr;

	MainWindow *kaduMainWindow = qobject_cast<MainWindow *>(parentWidget());
	if (!kaduMainWindow)
		return nullptr;

	auto actionByName = Actions::instance()->value(action.actionName);
	if (!actionByName)
		return nullptr;

	if (!kaduMainWindow->supportsActionType(actionByName->type()))
		return nullptr;

	action.action = Actions::instance()->createAction(action.actionName, kaduMainWindow->actionContext(), kaduMainWindow);
	insertAction(before, action.action);

	QToolButton *button = qobject_cast<QToolButton *>(widgetForAction(action.action));

	action.widget = button;
	if (button)
	{
		connect(button, SIGNAL(pressed()), this, SLOT(widgetPressed()));
		button->installEventFilter(watcher);
		button->setToolButtonStyle(action.style);

		if (action.action->menu() && Actions::instance()->contains(action.actionName))
		{
			ActionDescription *actionDescription = Actions::instance()->value(action.actionName);
			if (actionDescription)
				button->setPopupMode(actionDescription->buttonPopupMode());
		}
	}

	return button;
}
StateMachineToolBar::StateMachineToolBar(StateMachineView* view, QWidget* parent)
    : QToolBar(parent)
    , d(new Private(this))
{
    d->m_view = view;

    setWindowTitle(tr("State Machine Tool Bar"));
    d->m_exportAction = new QAction(tr("Export to File..."), this);
    d->m_exportAction->setStatusTip("Export current state machine to a file.");
    connect(d->m_exportAction, SIGNAL(triggered()), this, SLOT(handleExport()));
    addAction(d->m_exportAction);

    QToolButton* themeSelectionButton = new QToolButton(this);
    themeSelectionButton->setText(tr("Theme"));
    themeSelectionButton->setPopupMode(QToolButton::InstantPopup);
    QMenu* themeSelectionMenu = new QMenu(themeSelectionButton);
    foreach (const QString& themeName, availableThemeNames()) {
        auto action = new QAction(themeName, this);
        connect(action, &QAction::triggered, this, [this, themeName]() {
            d->m_view->setThemeName(themeName);
        });
        themeSelectionMenu->addAction(action);
    }
Esempio n. 22
0
RundownWidget::RundownWidget(QWidget* parent)
    : QWidget(parent)
{
    setupUi(this);

    setupMenus();

    QToolButton* toolButtonRundownDropdown = new QToolButton(this);
    toolButtonRundownDropdown->setObjectName("toolButtonRundownDropdown");
    toolButtonRundownDropdown->setMenu(this->contextMenuRundownDropdown);
    toolButtonRundownDropdown->setPopupMode(QToolButton::InstantPopup);
    this->tabWidgetRundown->setCornerWidget(toolButtonRundownDropdown);
    //this->tabWidgetRundown->setTabIcon(0, QIcon(":/Graphics/Images/TabSplitter.png"));

    RundownTreeWidget* widget = new RundownTreeWidget(this);
    int index = this->tabWidgetRundown->addTab(widget/*, QIcon(":/Graphics/Images/TabSplitter.png")*/, Rundown::DEFAULT_NAME);
    this->tabWidgetRundown->setTabToolTip(index, Rundown::DEFAULT_NAME);
    this->tabWidgetRundown->setCurrentIndex(index);

    QObject::connect(&EventManager::getInstance(), SIGNAL(newRundownMenu(const NewRundownMenuEvent&)), this, SLOT(newRundownMenu(const NewRundownMenuEvent&)));
    QObject::connect(&EventManager::getInstance(), SIGNAL(openRundownMenu(const OpenRundownMenuEvent&)), this, SLOT(openRundownMenu(const OpenRundownMenuEvent&)));
    QObject::connect(&EventManager::getInstance(), SIGNAL(openRundownFromUrlMenu(const OpenRundownFromUrlMenuEvent&)), this, SLOT(openRundownFromUrlMenu(const OpenRundownFromUrlMenuEvent&)));
    QObject::connect(&EventManager::getInstance(), SIGNAL(newRundown(const NewRundownEvent&)), this, SLOT(newRundown(const NewRundownEvent&)));
    QObject::connect(&EventManager::getInstance(), SIGNAL(allowRemoteTriggeringMenu(const AllowRemoteTriggeringMenuEvent&)), this, SLOT(allowRemoteTriggeringMenu(const AllowRemoteTriggeringMenuEvent&)));
    QObject::connect(&EventManager::getInstance(), SIGNAL(closeRundown(const CloseRundownEvent&)), this, SLOT(closeRundown(const CloseRundownEvent&)));
    QObject::connect(&EventManager::getInstance(), SIGNAL(deleteRundown(const DeleteRundownEvent&)), this, SLOT(deleteRundown(const DeleteRundownEvent&)));
    QObject::connect(&EventManager::getInstance(), SIGNAL(openRundown(const OpenRundownEvent&)), this, SLOT(openRundown(const OpenRundownEvent&)));
    QObject::connect(&EventManager::getInstance(), SIGNAL(openRundownFromUrl(const OpenRundownFromUrlEvent&)), this, SLOT(openRundownFromUrl(const OpenRundownFromUrlEvent&)));
    QObject::connect(&EventManager::getInstance(), SIGNAL(saveRundown(const SaveRundownEvent&)), this, SLOT(saveRundown(const SaveRundownEvent&)));
    QObject::connect(&EventManager::getInstance(), SIGNAL(activeRundownChanged(const ActiveRundownChangedEvent&)), this, SLOT(activeRundownChanged(const ActiveRundownChangedEvent&)));
    QObject::connect(&EventManager::getInstance(), SIGNAL(reloadRundown(const ReloadRundownEvent&)), this, SLOT(reloadRundown(const ReloadRundownEvent&)));
    QObject::connect(&EventManager::getInstance(), SIGNAL(markItemAsUsed(const MarkItemAsUsedEvent&)), this, SLOT(markItemAsUsed(const MarkItemAsUsedEvent&)));
    QObject::connect(&EventManager::getInstance(), SIGNAL(markItemAsUnused(const MarkItemAsUnusedEvent&)), this, SLOT(markItemAsUnused(const MarkItemAsUnusedEvent&)));
    QObject::connect(&EventManager::getInstance(), SIGNAL(markAllItemsAsUsed(const MarkAllItemsAsUsedEvent&)), this, SLOT(markAllItemsAsUsed(const MarkAllItemsAsUsedEvent&)));
    QObject::connect(&EventManager::getInstance(), SIGNAL(markAllItemsAsUnused(const MarkAllItemsAsUnusedEvent&)), this, SLOT(markAllItemsAsUnused(const MarkAllItemsAsUnusedEvent&)));
}
ObjectsController::ObjectsController( Record::Server& server, ObjectsComponent& component )
    : server( server )
    , component( component )
    , view( new ObjectsView( server ) )
    , objectReleasing( new QAction( QIcon( ":/icons/trash.png" ) , "&Release", this ) )
    , objectRenaming ( new QAction( QIcon( ":/icons/pencil.png" ), "Rena&me" , this ) )
    , editorDetaching( new QAction( QIcon( ":/icons/pin.png" )   , "&Detach", this ) )
    , pointCreation  ( new QAction( "Create &Point", this ) )
    , pointerCreation( new QAction( "Create Pointe&r", this ) )
    , polylineImport ( new QAction( "Import Poly&line", this ) )
    , tempPointCreation( new QAction( "Create Temporary Seed", this ) )
    , editorContainer( new QFrame() )
    , currentObjectEditor( nullptr )
{
    editorContainer->setLayout( new QVBoxLayout() );
    editorContainer->setContentsMargins( 0, 0, 0, 0 );
    editorContainer->setMinimumWidth( 200 );
    editorContainer->hide();

    QToolBar* const toolBar = new QToolBar();
    toolBar->setIconSize( QSize( 24, 24 ) );
    toolBar->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );

    QToolButton* acquireButton = new QToolButton( toolBar );
    QMenu* acquireMenu = new QMenu( acquireButton );
    acquireButton->setMenu( acquireMenu );
    acquireButton->setPopupMode( QToolButton::InstantPopup );
    acquireButton->setToolButtonStyle( Qt::ToolButtonTextUnderIcon );
    acquireButton->setText( "Cre&ate" );
    acquireButton->setIcon( QIcon( ":/icons/add.png" ) );

    acquireMenu->addAction( pointCreation );
    acquireMenu->addAction( pointerCreation );
    acquireMenu->addSeparator();
    acquireMenu->addAction( tempPointCreation );
    acquireMenu->addSeparator();
    acquireMenu->addAction( polylineImport );

    toolBar->addWidget( acquireButton );
    toolBar->addAction( objectReleasing );
    toolBar->addAction( objectRenaming );
    toolBar->addSeparator();
    toolBar->addAction( editorDetaching );

    connect( pointCreation, SIGNAL( triggered() ), this, SLOT( createPoint3D() ) );
    connect( polylineImport, SIGNAL( triggered() ), this, SLOT( importPolyline() ) );
    connect( tempPointCreation, SIGNAL( triggered() ), this, SLOT( createTempPoint1() ) );

#ifndef NO_CRA
    connect( pointerCreation, SIGNAL( triggered() ), this, SLOT( createPointer3D() ) );
#endif

    this->setMinimumWidth( toolBar->sizeHint().width() );
    this->setLayout( new QVBoxLayout() );
    this->layout()->addWidget( view );
    this->layout()->addWidget( toolBar );
    this->layout()->addWidget( editorContainer );

    connect( objectReleasing, SIGNAL( triggered() ), this, SLOT( releaseObjects() ) );
    connect( objectRenaming , SIGNAL( triggered() ), this, SLOT(   renameObject() ) );
    connect( editorDetaching, SIGNAL( triggered() ), this, SLOT(   detachEditor() ) );

    editorDetaching->setEnabled( false );

    connect( view, SIGNAL( selectionChanged() ), this, SLOT( objectsSelectionChanged() ) );
    connect( view, SIGNAL( objectDoubleClicked( Carna::base::model::Object3D& ) ), this, SLOT( renameObject( Carna::base::model::Object3D& ) ) );

    objectsSelectionChanged();
}
Esempio n. 24
0
FindDocWidget::FindDocWidget(LiteApi::IApplication *app, QWidget *parent) :
    QWidget(parent), m_liteApp(app)
{
    m_findEdit = new SearchEdit;
    m_findEdit->setPlaceholderText(tr("Search"));

    m_chaseWidget = new ChaseWidget;
    m_chaseWidget->setMinimumSize(QSize(16,16));
    m_chaseWidget->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);

    QToolButton *findBtn = new QToolButton;
    findBtn->setPopupMode(QToolButton::InstantPopup);
    findBtn->setText(tr("Find"));

    QHBoxLayout *findLayout = new QHBoxLayout;
    findLayout->setMargin(2);
    findLayout->addWidget(m_findEdit);
    findLayout->addWidget(findBtn);
    findLayout->addWidget(m_chaseWidget);

    m_browser = m_liteApp->htmlWidgetManager()->createByName(this,"QTextBrowser");
    QStringList paths;
    paths << m_liteApp->resourcePath()+"/packages/go/godoc";
    m_browser->setSearchPaths(paths);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->setMargin(1);
    mainLayout->setSpacing(1);
    mainLayout->addLayout(findLayout);
    mainLayout->addWidget(m_browser->widget());

    QAction *findAll = new QAction(tr("Find All"),this);
    QAction *findConst = new QAction(tr("Find const"),this);
    findConst->setData("const");
    QAction *findFunc = new QAction(tr("Find func"),this);
    findFunc->setData("func");
    QAction *findInterface = new QAction(tr("Find interface"),this);
    findInterface->setData("interface");
    QAction *findPkg = new QAction(tr("Find pkg"),this);
    findPkg->setData("pkg");
    QAction *findStruct = new QAction(tr("Find struct"),this);
    findStruct->setData("struct");
    QAction *findType = new QAction(tr("Find type"),this);
    findType->setData("type");
    QAction *findVar = new QAction(tr("Find var"),this);
    findVar->setData("var");
    m_useRegexpCheckAct = new QAction(tr("Use Regexp"),this);
    m_useRegexpCheckAct->setCheckable(true);
    m_matchCaseCheckAct = new QAction(tr("Match Case"),this);
    m_matchCaseCheckAct->setCheckable(true);
    m_matchWordCheckAct = new QAction(tr("Match Word"),this);
    m_matchWordCheckAct->setCheckable(true);

    m_useRegexpCheckAct->setChecked(m_liteApp->settings()->value(GODOCFIND_USEREGEXP,false).toBool());
    m_matchCaseCheckAct->setChecked(m_liteApp->settings()->value(GODOCFIND_MATCHCASE,true).toBool());
    m_matchWordCheckAct->setChecked(m_liteApp->settings()->value(GODOCFIND_MATCHWORD,false).toBool());

    QMenu *menu = new QMenu(findBtn);
    menu->addActions(QList<QAction*>()
                     << findAll
                     //<< findPkg
                     );
    menu->addSeparator();
    menu->addActions(QList<QAction*>()
                     << findInterface
                     << findStruct
                     << findType
                     << findFunc
                     << findConst
                     << findVar
                     );
    menu->addSeparator();
    menu->addAction(m_matchWordCheckAct);
    menu->addAction(m_matchCaseCheckAct);
    menu->addAction(m_useRegexpCheckAct);
    findBtn->setMenu(menu);

    QAction *helpAct = new QAction(tr("Help"),this);
    menu->addSeparator();
    menu->addAction(helpAct);
    connect(helpAct,SIGNAL(triggered()),this,SLOT(showHelp()));

    this->setLayout(mainLayout);    


    connect(findAll,SIGNAL(triggered()),this,SLOT(findDoc()));
    connect(findConst,SIGNAL(triggered()),this,SLOT(findDoc()));
    connect(findFunc,SIGNAL(triggered()),this,SLOT(findDoc()));
    connect(findInterface,SIGNAL(triggered()),this,SLOT(findDoc()));
    connect(findPkg,SIGNAL(triggered()),this,SLOT(findDoc()));
    connect(findStruct,SIGNAL(triggered()),this,SLOT(findDoc()));
    connect(findType,SIGNAL(triggered()),this,SLOT(findDoc()));
    connect(findVar,SIGNAL(triggered()),this,SLOT(findDoc()));

    m_process = new ProcessEx(this);
    connect(m_process,SIGNAL(stateChanged(QProcess::ProcessState)),this,SLOT(stateChanged(QProcess::ProcessState)));
    connect(m_process,SIGNAL(extOutput(QByteArray,bool)),this,SLOT(extOutput(QByteArray,bool)));
    connect(m_process,SIGNAL(extFinish(bool,int,QString)),this,SLOT(extFinish(bool,int,QString)));
    connect(m_findEdit,SIGNAL(returnPressed()),findAll,SIGNAL(triggered()));
    connect(m_findEdit,SIGNAL(rightButtonClicked()),this,SLOT(abortFind()));
    connect(m_browser,SIGNAL(linkClicked(QUrl)),this,SLOT(openUrl(QUrl)));


    QString path = m_liteApp->resourcePath()+"/packages/go/godoc/finddoc.html";
    QFile file(path);
    if (file.open(QIODevice::ReadOnly)) {
        m_templateData = file.readAll();
        file.close();
    }

    //QFont font = m_browser->widget()->font();
    //font.setPointSize(12);
    //m_browser->widget()->setFont(font);

    showHelp();
}
QWidget* MusicVideoControl::createBarrageWidget()
{
    QWidget *barrageWidget = new QWidget(this);
    m_pushBarrageOn = false;

    ///////////////////////////////////////////
    QWidgetAction *widgetAction = new QWidgetAction(barrageWidget);
    QWidget *barrageSettingWidget = new QWidget(barrageWidget);
    QVBoxLayout *settingLayout = new QVBoxLayout(barrageSettingWidget);

    QWidget *fontSizeWidget = new QWidget(barrageSettingWidget);
    QHBoxLayout *fontSizeLayout = new QHBoxLayout(fontSizeWidget);
    fontSizeLayout->setContentsMargins(0, 0, 0, 0);
    QLabel *fontSizeLabel = new QLabel(tr("Size"), this);

    QButtonGroup *fontSizeButtonGroup = new QButtonGroup(fontSizeWidget);
    fontSizeLayout->addWidget(fontSizeLabel);
    for(int i=1; i<=3; ++i)
    {
        QPushButton *button = createBarrageSizeButton(i);
        fontSizeButtonGroup->addButton(button, i);
        fontSizeLayout->addStretch(1);
        fontSizeLayout->addWidget(button);
    }
    fontSizeLayout->addStretch(1);
    fontSizeWidget->setLayout(fontSizeLayout);
    connect(fontSizeButtonGroup, SIGNAL(buttonClicked(int)), SLOT(barrageSizeButtonClicked(int)));

    QWidget *backgroundWidget = new QWidget(barrageSettingWidget);
    QHBoxLayout *backgroundLayout = new QHBoxLayout(backgroundWidget);
    backgroundLayout->setContentsMargins(0, 0, 0, 0);
    backgroundLayout->setSpacing(5);
    QLabel *backgroundLabel = new QLabel(tr("BgColor"), this);

    QButtonGroup *backgroundButtonGroup = new QButtonGroup(backgroundWidget);
    backgroundLayout->addWidget(backgroundLabel);
    for(int i=1; i<=8; ++i)
    {
        QPushButton *button = createBarrageColorButton(i);
        backgroundButtonGroup->addButton(button, i);
        backgroundLayout->addWidget(button);
    }
    backgroundWidget->setLayout(backgroundLayout);
    connect(backgroundButtonGroup, SIGNAL(buttonClicked(int)), SLOT(barrageColorButtonClicked(int)));

    settingLayout->addWidget(fontSizeWidget);
    settingLayout->addWidget(backgroundWidget);
    barrageSettingWidget->setLayout(settingLayout);

    widgetAction->setDefaultWidget(barrageSettingWidget);
    m_popupBarrage.addAction(widgetAction);
    ///////////////////////////////////////////

    QHBoxLayout *barrageLayout = new QHBoxLayout(barrageWidget);
    barrageLayout->setContentsMargins(0, 0, 0, 0);

    QToolButton *menuBarrage = new QToolButton(barrageWidget);
    menuBarrage->setStyleSheet(MusicUIObject::MToolButtonStyle04);
    menuBarrage->setIcon(QIcon(":/video/barrageStyle"));
    menuBarrage->setMenu(&m_popupBarrage);
    menuBarrage->setPopupMode(QToolButton::InstantPopup);
    MusicLocalSongSearchEdit *lineEditBarrage = new MusicLocalSongSearchEdit(barrageWidget);
    lineEditBarrage->addFilterText(tr("just one barrage!"));
    lineEditBarrage->setStyleSheet(MusicUIObject::MLineEditStyle01 + \
                                   "QLineEdit{color:white;}");
    connect(lineEditBarrage, SIGNAL(enterFinished(QString)), SIGNAL(addBarrageChanged(QString)));

    QLabel *labelBarrage = new QLabel(barrageWidget);
    labelBarrage->setStyleSheet("color:white;");
    labelBarrage->setText(tr("openBarrage"));
    m_pushBarrage = new QPushButton(barrageWidget);
    m_pushBarrage->setIconSize(QSize(40, 25));
    pushBarrageClicked();
    connect(m_pushBarrage, SIGNAL(clicked()), SLOT(pushBarrageClicked()));

    barrageLayout->addWidget(menuBarrage);
    barrageLayout->addWidget(lineEditBarrage);
    barrageLayout->addWidget(labelBarrage);
    barrageLayout->addWidget(m_pushBarrage);
    barrageWidget->setLayout(barrageLayout);

    return barrageWidget;
}
VectorizerPopup::VectorizerPopup(QWidget *parent, Qt::WFlags flags)
#endif
	: Dialog(TApp::instance()->getMainWindow(), true, false, "Vectorizer"), m_sceneHandle(TApp::instance()->getCurrentScene())
{
	struct Locals {
		int m_bit;

		Locals() : m_bit() {}

		static void addParameterGroup(
			std::vector<ParamGroup> &paramGroups,
			int group, int startRow, int separatorRow = -1)
		{
			assert(group <= paramGroups.size());

			if (group == paramGroups.size())
				paramGroups.push_back(ParamGroup(startRow, separatorRow));
		}

		void addParameter(
			std::vector<ParamGroup> &paramGroups,
			const QString &paramName)
		{
			paramGroups.back().m_params.push_back(Param(paramName, m_bit++));
		}

	} locals;

	// Su MAC i dialog modali non hanno bottoni di chiusura nella titleBar
	setModal(false);
	setWindowTitle(tr("Convert-to-Vector Settings"));

	setLabelWidth(125);

	setTopMargin(0);
	setTopSpacing(0);

	// Build vertical layout
	beginVLayout();

	QSplitter *splitter = new QSplitter(Qt::Vertical, this);
	splitter->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
	addWidget(splitter);

	QToolBar *leftToolBar = new QToolBar,
			 *rightToolBar = new QToolBar;
	{
		QWidget *toolbarsContainer = new QWidget(this);
		toolbarsContainer->setFixedHeight(22);
		addWidget(toolbarsContainer);

		QHBoxLayout *toolbarsLayout = new QHBoxLayout(toolbarsContainer);
		toolbarsContainer->setLayout(toolbarsLayout);

		toolbarsLayout->setMargin(0);
		toolbarsLayout->setSpacing(0);

		QToolBar *spacingToolBar = new QToolBar(toolbarsContainer); // The spacer object must be a toolbar.
		spacingToolBar->setFixedHeight(22);							// It's related to qss choices... I know it's stinky

		toolbarsLayout->addWidget(leftToolBar, 0, Qt::AlignLeft);
		toolbarsLayout->addWidget(spacingToolBar, 1);
		toolbarsLayout->addWidget(rightToolBar, 0, Qt::AlignRight);
	}

	endVLayout();

	// Build parameters area
	QScrollArea *paramsArea = new QScrollArea(splitter);
	paramsArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	paramsArea->setWidgetResizable(true);
	splitter->addWidget(paramsArea);
	splitter->setStretchFactor(0, 1);

	m_paramsWidget = new QFrame(paramsArea);
	paramsArea->setWidget(m_paramsWidget);

	m_paramsLayout = new QGridLayout;
	m_paramsWidget->setLayout(m_paramsLayout);

	int group = 0, row = 0;

	locals.addParameterGroup(::l_centerlineParamGroups, group, row);
	locals.addParameterGroup(::l_outlineParamGroups, group++, row);

	// Vectorization mode
	m_typeMenu = new QComboBox(this);
	m_typeMenu->setFixedSize(245, WidgetHeight);
	QStringList formats;
	formats << tr("Centerline") << tr("Outline");
	m_typeMenu->addItems(formats);
	m_typeMenu->setMinimumHeight(WidgetHeight);
	bool isOutline = m_sceneHandle->getScene()->getProperties()->getVectorizerParameters()->m_isOutline;
	m_typeMenu->setCurrentIndex(isOutline ? 1 : 0);
	connect(m_typeMenu, SIGNAL(currentIndexChanged(int)), this, SLOT(onTypeChange(int)));

	m_paramsLayout->addWidget(new QLabel(tr("Mode")), row, 0, Qt::AlignRight);
	m_paramsLayout->addWidget(m_typeMenu, row++, 1);

	locals.addParameter(l_centerlineParamGroups, tr("Mode"));
	locals.addParameter(l_outlineParamGroups, tr("Mode"));

	//-------------------- Parameters area - Centerline ------------------------

	locals.addParameterGroup(l_centerlineParamGroups, group++, row);

	// Threshold
	m_cThresholdLabel = new QLabel(tr("Threshold"));
	m_cThreshold = new IntField(this);

	m_paramsLayout->addWidget(m_cThresholdLabel, row, 0, Qt::AlignRight);
	m_paramsLayout->addWidget(m_cThreshold, row++, 1);

	locals.addParameter(l_centerlineParamGroups, tr("Threshold"));

	// Accuracy
	m_cAccuracyLabel = new QLabel(tr("Accuracy"));
	m_cAccuracy = new IntField(this);

	m_paramsLayout->addWidget(m_cAccuracyLabel, row, 0, Qt::AlignRight);
	m_paramsLayout->addWidget(m_cAccuracy, row++, 1);

	locals.addParameter(l_centerlineParamGroups, tr("Accuracy"));

	// Despeckling
	m_cDespecklingLabel = new QLabel(tr("Despeckling"));
	m_cDespeckling = new IntField(this);

	m_paramsLayout->addWidget(m_cDespecklingLabel, row, 0, Qt::AlignRight);
	m_paramsLayout->addWidget(m_cDespeckling, row++, 1);

	locals.addParameter(l_centerlineParamGroups, tr("Despeckling"));

	// Max Thickness
	m_cMaxThicknessLabel = new QLabel(tr("Max Thickness"));
	m_paramsLayout->addWidget(m_cMaxThicknessLabel, row, 0, Qt::AlignRight);

	m_cMaxThickness = new IntField(this);
	m_cMaxThickness->enableSlider(false);
	m_paramsLayout->addWidget(m_cMaxThickness, row++, 1, Qt::AlignLeft);

	locals.addParameter(l_centerlineParamGroups, tr("Max Thickness"));

	// Thickness Calibration
	m_cThicknessRatioLabel = new QLabel(tr("Thickness Calibration"));
	m_paramsLayout->addWidget(m_cThicknessRatioLabel, row, 0, Qt::AlignRight);

	/*m_cThicknessRatio = new IntField(this);
  paramsLayout->addWidget(m_cThicknessRatio, row++, 1);*/

	QHBoxLayout *cThicknessRatioLayout = new QHBoxLayout;

	cThicknessRatioLayout->addSpacing(20);

	m_cThicknessRatioFirstLabel = new QLabel(tr("Start:"));
	cThicknessRatioLayout->addWidget(m_cThicknessRatioFirstLabel);

	m_cThicknessRatioFirst = new MeasuredDoubleLineEdit(this);
	m_cThicknessRatioFirst->setMeasure("percentage");
	cThicknessRatioLayout->addWidget(m_cThicknessRatioFirst);

	m_cThicknessRatioLastLabel = new QLabel(tr("End:"));
	cThicknessRatioLayout->addWidget(m_cThicknessRatioLastLabel);

	m_cThicknessRatioLast = new MeasuredDoubleLineEdit(this);
	m_cThicknessRatioLast->setMeasure("percentage");
	cThicknessRatioLayout->addWidget(m_cThicknessRatioLast);

	cThicknessRatioLayout->addStretch(1);

	m_paramsLayout->addLayout(cThicknessRatioLayout, row++, 1);

	locals.addParameter(l_centerlineParamGroups, tr("Thickness Calibration"));

	// Checkboxes
	{
		static const QString name = tr("Preserve Painted Areas");
		locals.addParameter(l_centerlineParamGroups, name);

		m_cPaintFill = new CheckBox(name, this);
		m_cPaintFill->setFixedHeight(WidgetHeight);
		m_paramsLayout->addWidget(m_cPaintFill, row++, 1);
	}

	{
		static const QString name = tr("Add Border");
		locals.addParameter(l_centerlineParamGroups, name);

		m_cMakeFrame = new CheckBox(name, this);
		m_cMakeFrame->setFixedHeight(WidgetHeight);
		m_paramsLayout->addWidget(m_cMakeFrame, row++, 1);
	}

	locals.addParameterGroup(l_centerlineParamGroups, group++, row + 1, row);

	m_cNaaSourceSeparator = new Separator(tr("Full color non-AA images"));
	m_paramsLayout->addWidget(m_cNaaSourceSeparator, row++, 0, 1, 2);

	{
		static const QString name = tr("Enhanced ink recognition");
		locals.addParameter(l_centerlineParamGroups, name);

		m_cNaaSource = new CheckBox(name, this);
		m_cNaaSource->setFixedHeight(WidgetHeight);
		m_paramsLayout->addWidget(m_cNaaSource, row++, 1);
	}

	//-------------------- Parameters area - Outline ------------------------

	group = 1;
	locals.addParameterGroup(l_outlineParamGroups, group++, row);

	//Accuracy
	m_oAccuracyLabel = new QLabel(tr("Accuracy"));
	m_oAccuracy = new IntField(this);

	m_paramsLayout->addWidget(m_oAccuracyLabel, row, 0, Qt::AlignRight);
	m_paramsLayout->addWidget(m_oAccuracy, row++, 1);

	locals.addParameter(l_outlineParamGroups, tr("Accuracy"));

	//Despeckling
	m_oDespecklingLabel = new QLabel(tr("Despeckling"));
	m_oDespeckling = new IntField(this);

	m_paramsLayout->addWidget(m_oDespecklingLabel, row, 0, Qt::AlignRight);
	m_paramsLayout->addWidget(m_oDespeckling, row++, 1);

	locals.addParameter(l_outlineParamGroups, tr("Despeckling"));

	//Paint Fill
	{
		static const QString name = tr("Preserve Painted Areas");
		locals.addParameter(l_outlineParamGroups, name);

		m_oPaintFill = new CheckBox(name, this);
		m_oPaintFill->setFixedHeight(WidgetHeight);
		m_paramsLayout->addWidget(m_oPaintFill, row++, 1);
	}

	locals.addParameterGroup(l_outlineParamGroups, group++, row + 1, row);

	m_oCornersSeparator = new Separator(tr("Corners"));
	m_paramsLayout->addWidget(m_oCornersSeparator, row++, 0, 1, 2);

	//Adherence
	m_oAdherenceLabel = new QLabel(tr("Adherence"));
	m_oAdherence = new IntField(this);

	m_paramsLayout->addWidget(m_oAdherenceLabel, row, 0, Qt::AlignRight);
	m_paramsLayout->addWidget(m_oAdherence, row++, 1);

	locals.addParameter(l_outlineParamGroups, tr("Adherence"));

	//Angle
	m_oAngleLabel = new QLabel(tr("Angle"));
	m_oAngle = new IntField(this);

	m_paramsLayout->addWidget(m_oAngleLabel, row, 0, Qt::AlignRight);
	m_paramsLayout->addWidget(m_oAngle, row++, 1);

	locals.addParameter(l_outlineParamGroups, tr("Angle"));

	//Relative
	m_oRelativeLabel = new QLabel(tr("Curve Radius"));
	m_oRelative = new IntField(this);

	m_paramsLayout->addWidget(m_oRelativeLabel, row, 0, Qt::AlignRight);
	m_paramsLayout->addWidget(m_oRelative, row++, 1);

	locals.addParameter(l_outlineParamGroups, tr("Curve Radius"));

	locals.addParameterGroup(l_outlineParamGroups, group++, row + 1, row);

	m_oFullColorSeparator = new Separator(tr("Raster Levels"));
	m_paramsLayout->addWidget(m_oFullColorSeparator, row++, 0, 1, 2);

	//Max Colors
	m_oMaxColorsLabel = new QLabel(tr("Max Colors"));
	m_oMaxColors = new IntField(this);

	m_paramsLayout->addWidget(m_oMaxColorsLabel, row, 0, Qt::AlignRight);
	m_paramsLayout->addWidget(m_oMaxColors, row++, 1);

	locals.addParameter(l_outlineParamGroups, tr("Max Colors"));

	//Transparent Color
	m_oTransparentColorLabel = new QLabel(tr("Transparent Color"), this);
	m_oTransparentColor = new ColorField(this, true, TPixel32::Transparent, 48);
	m_paramsLayout->addWidget(m_oTransparentColorLabel, row, 0, Qt::AlignRight);
	m_paramsLayout->addWidget(m_oTransparentColor, row++, 1);

	locals.addParameter(l_outlineParamGroups, tr("Transparent Color"));

	locals.addParameterGroup(l_outlineParamGroups, group++, row + 1, row);

	m_oTlvSeparator = new Separator(tr("TLV Levels"));
	m_paramsLayout->addWidget(m_oTlvSeparator, row++, 0, 1, 2);

	//Tone Threshold
	m_oToneThresholdLabel = new QLabel(tr("Tone Threshold"));
	m_oToneThreshold = new IntField(this);

	m_paramsLayout->addWidget(m_oToneThresholdLabel, row, 0, Qt::AlignRight);
	m_paramsLayout->addWidget(m_oToneThreshold, row++, 1);

	locals.addParameter(l_outlineParamGroups, tr("Tone Threshold"));

	m_paramsLayout->setRowStretch(row, 1);

	//-------------------- Swatch area ------------------------

	m_swatchArea = new VectorizerSwatchArea(this);
	splitter->addWidget(m_swatchArea);
	m_swatchArea->setEnabled(false); //Initally not enabled

	connect(this, SIGNAL(valuesChanged()), m_swatchArea, SLOT(invalidateContents()));

	//---------------------- Toolbar --------------------------

	QAction *swatchAct = new QAction(createQIconOnOffPNG("preview", true), tr("Toggle Swatch Preview"), this);
	swatchAct->setCheckable(true);
	leftToolBar->addAction(swatchAct);

	QAction *centerlineAct = new QAction(createQIconOnOffPNG("opacitycheck", true), tr("Toggle Centerlines Check"), this);
	centerlineAct->setCheckable(true);
	leftToolBar->addAction(centerlineAct);

	QToolButton *visibilityButton = new QToolButton(this);
	visibilityButton->setIcon(createQIconPNG("options"));
	visibilityButton->setPopupMode(QToolButton::InstantPopup);

	QMenu *visibilityMenu = new QMenu(visibilityButton);
	visibilityButton->setMenu(visibilityMenu);

	rightToolBar->addWidget(visibilityButton);
	rightToolBar->addSeparator();

	QAction *saveAct = new QAction(createQIconOnOffPNG("save", false), tr("Save Settings"), this);
	rightToolBar->addAction(saveAct);
	QAction *loadAct = new QAction(createQIconOnOffPNG("load", false), tr("Load Settings"), this);
	rightToolBar->addAction(loadAct);
	rightToolBar->addSeparator();

	QAction *resetAct = new QAction(createQIconOnOffPNG("resetsize", false), tr("Reset Settings"), this);
	rightToolBar->addAction(resetAct);

	connect(swatchAct, SIGNAL(triggered(bool)), m_swatchArea, SLOT(enablePreview(bool)));
	connect(centerlineAct, SIGNAL(triggered(bool)), m_swatchArea, SLOT(enableDrawCenterlines(bool)));
	connect(visibilityMenu, SIGNAL(aboutToShow()), this, SLOT(populateVisibilityMenu()));
	connect(saveAct, SIGNAL(triggered()), this, SLOT(saveParameters()));
	connect(loadAct, SIGNAL(triggered()), this, SLOT(loadParameters()));
	connect(resetAct, SIGNAL(triggered()), this, SLOT(resetParameters()));

	//------------------- Convert Button ----------------------

	//Convert Button
	m_okBtn = new QPushButton(QString(tr("Convert")), this);
	connect(m_okBtn, SIGNAL(clicked()), this, SLOT(onOk()));

	addButtonBarWidget(m_okBtn);

	//All detailed signals convey to the unique valuesChanged() signal. That makes it easier
	//to disconnect update notifications whenever we loadConfiguration(..).
	connect(this, SIGNAL(valuesChanged()), this, SLOT(updateSceneSettings()));

	//Connect value changes to update the global VectorizerPopUpSettingsContainer.
	//connect(m_typeMenu,SIGNAL(currentIndexChanged(const QString &)),this,SLOT(updateSceneSettings()));
	connect(m_cThreshold, SIGNAL(valueChanged(bool)), this, SLOT(onValueEdited(bool)));
	connect(m_cAccuracy, SIGNAL(valueChanged(bool)), this, SLOT(onValueEdited(bool)));
	connect(m_cDespeckling, SIGNAL(valueChanged(bool)), this, SLOT(onValueEdited(bool)));
	connect(m_cMaxThickness, SIGNAL(valueChanged(bool)), this, SLOT(onValueEdited(bool)));
	//connect(m_cThicknessRatio,SIGNAL(valueChanged(bool)),this,SLOT(onValueEdited(bool)));
	connect(m_cThicknessRatioFirst, SIGNAL(valueChanged()), this, SLOT(onValueEdited()));
	connect(m_cThicknessRatioLast, SIGNAL(valueChanged()), this, SLOT(onValueEdited()));
	connect(m_cMakeFrame, SIGNAL(stateChanged(int)), this, SLOT(onValueEdited()));
	connect(m_cPaintFill, SIGNAL(stateChanged(int)), this, SLOT(onValueEdited()));
	connect(m_cNaaSource, SIGNAL(stateChanged(int)), this, SLOT(onValueEdited()));

	connect(m_oAccuracy, SIGNAL(valueChanged(bool)), this, SLOT(onValueEdited(bool)));
	connect(m_oDespeckling, SIGNAL(valueChanged(bool)), this, SLOT(onValueEdited(bool)));
	connect(m_oPaintFill, SIGNAL(stateChanged(int)), this, SLOT(onValueEdited()));
	connect(m_oAdherence, SIGNAL(valueChanged(bool)), this, SLOT(onValueEdited(bool)));
	connect(m_oAngle, SIGNAL(valueChanged(bool)), this, SLOT(onValueEdited(bool)));
	connect(m_oRelative, SIGNAL(valueChanged(bool)), this, SLOT(onValueEdited(bool)));
	connect(m_oDespeckling, SIGNAL(valueChanged(bool)), this, SLOT(onValueEdited(bool)));
	connect(m_oMaxColors, SIGNAL(valueChanged(bool)), this, SLOT(onValueEdited(bool)));
	connect(m_oTransparentColor, SIGNAL(colorChanged(const TPixel32 &, bool)),
			this, SLOT(onValueEdited(const TPixel32 &, bool)));
	connect(m_oToneThreshold, SIGNAL(valueChanged(bool)), this, SLOT(onValueEdited(bool)));

	refreshPopup();

	//Non e' corretto: manca la possibilita' di aggiornare la selezione del livello corrente
	//  connect(TApp::instance()->getCurrentLevel(), SIGNAL(xshLevelChanged()),
	//                                         this, SLOT(updateValues()));
}
Esempio n. 27
0
QgsBookmarks::QgsBookmarks( QWidget *parent )
    : QgsDockWidget( parent )
    , mQgisModel( nullptr )
    , mProjectModel( nullptr )
{
  setupUi( this );
  restorePosition();

  bookmarksDockContents->layout()->setMargin( 0 );
  bookmarksDockContents->layout()->setContentsMargins( 0, 0, 0, 0 );
  static_cast< QGridLayout* >( bookmarksDockContents->layout() )->setVerticalSpacing( 0 );

  QToolButton* btnImpExp = new QToolButton;
  btnImpExp->setAutoRaise( true );
  btnImpExp->setToolTip( tr( "Import/Export Bookmarks" ) );
  btnImpExp->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSharing.svg" ) ) );
  btnImpExp->setPopupMode( QToolButton::InstantPopup );

  QMenu *share = new QMenu( this );
  QAction *btnExport = share->addAction( tr( "&Export" ) );
  QAction *btnImport = share->addAction( tr( "&Import" ) );
  btnExport->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSharingExport.svg" ) ) );
  btnImport->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSharingImport.svg" ) ) );
  connect( btnExport, SIGNAL( triggered() ), this, SLOT( exportToXml() ) );
  connect( btnImport, SIGNAL( triggered() ), this, SLOT( importFromXml() ) );
  btnImpExp->setMenu( share );

  connect( actionAdd, SIGNAL( triggered() ), this, SLOT( addClicked() ) );
  connect( actionDelete, SIGNAL( triggered() ), this, SLOT( deleteClicked() ) );
  connect( actionZoomTo, SIGNAL( triggered() ), this, SLOT( zoomToBookmark() ) );

  mBookmarkToolbar->addWidget( btnImpExp );

  // open the database
  QSqlDatabase db = QSqlDatabase::addDatabase( QStringLiteral( "QSQLITE" ), QStringLiteral( "bookmarks" ) );
  db.setDatabaseName( QgsApplication::qgisUserDbFilePath() );
  if ( !db.open() )
  {
    QMessageBox::warning( this, tr( "Error" ),
                          tr( "Unable to open bookmarks database.\nDatabase: %1\nDriver: %2\nDatabase: %3" )
                          .arg( QgsApplication::qgisUserDbFilePath(),
                                db.lastError().driverText(),
                                db.lastError().databaseText() )
                        );
    deleteLater();
    return;
  }

  mQgisModel = new QSqlTableModel( this, db );
  mQgisModel->setTable( QStringLiteral( "tbl_bookmarks" ) );
  mQgisModel->setSort( 0, Qt::AscendingOrder );
  mQgisModel->select();
  mQgisModel->setEditStrategy( QSqlTableModel::OnFieldChange );

  // set better headers then column names from table
  mQgisModel->setHeaderData( 0, Qt::Horizontal, tr( "ID" ) );
  mQgisModel->setHeaderData( 1, Qt::Horizontal, tr( "Name" ) );
  mQgisModel->setHeaderData( 2, Qt::Horizontal, tr( "Project" ) );
  mQgisModel->setHeaderData( 3, Qt::Horizontal, tr( "xMin" ) );
  mQgisModel->setHeaderData( 4, Qt::Horizontal, tr( "yMin" ) );
  mQgisModel->setHeaderData( 5, Qt::Horizontal, tr( "xMax" ) );
  mQgisModel->setHeaderData( 6, Qt::Horizontal, tr( "yMax" ) );
  mQgisModel->setHeaderData( 7, Qt::Horizontal, tr( "SRID" ) );

  mProjectModel = new QgsProjectBookmarksTableModel();
  mModel.reset( new QgsMergedBookmarksTableModel( *mQgisModel, *mProjectModel, lstBookmarks ) );

  lstBookmarks->setModel( mModel.data() );

  QSettings settings;
  lstBookmarks->header()->restoreState( settings.value( QStringLiteral( "/Windows/Bookmarks/headerstate" ) ).toByteArray() );

#ifndef QGISDEBUG
  lstBookmarks->setColumnHidden( 0, true );
#endif
}
Esempio n. 28
0
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    ui->textBrowser->setText("Bienvenue dans MediaInfo");
    C = new Core();

    settings = new QSettings("MediaArea.net","MediaInfo");
    defaultSettings();
    applySettings();

    view = (ViewMode)settings->value("defaultView",VIEW_EASY).toInt();
    // View menu:
    QActionGroup* menuItemGroup = new QActionGroup(this);
    for(int v=VIEW_EASY;v<NB_VIEW;v++) {
        QAction* action = new QAction(nameView((ViewMode)v),ui->menuView);
        action->setCheckable(true);
        if(view==v)
            action->setChecked(true);
        action->setProperty("view",v);
        ui->menuView->addAction(action);
        menuItemGroup->addAction(action);
    }
    connect(menuItemGroup,SIGNAL(selected(QAction*)),SLOT(actionView_toggled(QAction*)));
    menuItemGroup->setParent(ui->menuView);

    QToolButton* tb = new QToolButton(ui->toolBar);
    tb->setMenu(ui->menuView);
    tb->setText("view");
    tb->setPopupMode(QToolButton::InstantPopup);
    tb->setIcon(QIcon(":/icon/view.svg"));
    connect(ui->toolBar,SIGNAL(toolButtonStyleChanged(Qt::ToolButtonStyle)),tb,SLOT(setToolButtonStyle(Qt::ToolButtonStyle)));
    ui->toolBar->addWidget(tb);

    ui->toolBar->setContextMenuPolicy(Qt::CustomContextMenu);
    this->connect(ui->toolBar,SIGNAL(customContextMenuRequested(QPoint)),SLOT(toolBarOptions(QPoint)));

    /* TODO
	QIcon::setThemeName("gnome-dust");
    ui->actionQuit->setIcon(QIcon::fromTheme("application-exit"));
    ui->actionOpen->setIcon(QIcon::fromTheme("document-open",QIcon(":/icon/openfile.svg")));
    ui->actionExport->setIcon(QIcon::fromTheme("document-save",QIcon(":/icon/export.svg")));
    ui->actionAbout->setIcon(QIcon::fromTheme("help-about",QIcon(":/icon/about.svg")));
    */

    timer=NULL;
    progressDialog=NULL;

    refreshDisplay();

    if(QCoreApplication::arguments().count()>1) {
        QStringList files = QCoreApplication::arguments();
        files.removeAt(0);
        openFiles(files);
    }

    /*
    qDebug() << "0.7 " << "0.7.5 " << isNewer("0.7","0.7.5");
    qDebug() << "0.7.4 " << "0.7.5 " << isNewer("0.7.4","0.7.5");
    qDebug() << "0.7.5 " << "0.7.4 " << isNewer("0.7.5","0.7.4");
    qDebug() << "0.7.4 " << "0.7 " << isNewer("0.7.4","0.7");
    qDebug() << "0.7.5 " << "0.7.5 " << isNewer("0.7.5","0.7.5");
    */

#ifdef NEW_VERSION
    if(settings->value("checkForNewVersion",true).toBool()) {
        checkForNewVersion();
    }
#endif

}
Esempio n. 29
0
void EFFEditorScenePanel::createToolbar()
{
	m_pToolbar = new QToolBar(NULL);
	m_pToolbar->setObjectName("toolbar");
	m_pToolbar->setMinimumHeight(TOOLBAR_MIN_HEIGHT);

	m_pToolbar->addWidget(new QLabel());
	m_pToolbar->addSeparator();

	QToolButton * drawMode = new QToolButton();
	drawMode->setToolButtonStyle(Qt::ToolButtonTextOnly);
	drawMode->setPopupMode(QToolButton::InstantPopup);
	drawMode->setObjectName(tr("drawMode"));
	QMenu * drawModeMenu = new QMenu(drawMode);
	drawModeMenu->addAction(new QAction(tr("Textured"), drawModeMenu));
	drawModeMenu->addAction(new QAction(tr("Wireframe"), drawModeMenu));
	drawModeMenu->addAction(new QAction(tr("Tex-Wire"), drawModeMenu));
	connect(drawModeMenu, SIGNAL(triggered(QAction *)), this, SLOT(drawModeMenuPressed(QAction *)));
	drawMode->setMenu(drawModeMenu);
	m_pToolbar->addWidget(drawMode);
	QMetaObject::invokeMethod(drawModeMenu, "triggered", Q_ARG(QAction *, *drawModeMenu->actions().begin()));

	m_pToolbar->addSeparator();
	m_pToolbar->addWidget(new QLabel());
	m_pToolbar->addSeparator();

	QToolButton * renderMode = new QToolButton();
	renderMode->setToolButtonStyle(Qt::ToolButtonTextOnly);
	renderMode->setPopupMode(QToolButton::InstantPopup);
	renderMode->setObjectName(tr("renderMode"));
	QMenu * renderModeMenu = new QMenu(renderMode);
	renderModeMenu->addAction(new QAction(tr("RGB"), renderModeMenu));
	renderModeMenu->addAction(new QAction(tr("Alpha"), renderModeMenu));
	renderModeMenu->addAction(new QAction(tr("OverDraw"), renderModeMenu));
	renderModeMenu->addAction(new QAction(tr("Mipmaps"), renderModeMenu));
	connect(renderModeMenu, SIGNAL(triggered(QAction *)), this, SLOT(renderModeMenuPressed(QAction *)));
	renderMode->setMenu(renderModeMenu);
	m_pToolbar->addWidget(renderMode);
	QMetaObject::invokeMethod(renderModeMenu, "triggered", Q_ARG(QAction *, *renderModeMenu->actions().begin()));

	m_pToolbar->addSeparator();
	m_pToolbar->addWidget(new QLabel());
	m_pToolbar->addSeparator();

	QPushButton * pLightingButton = new QPushButton();
	pLightingButton->setCheckable(true);
	//pLightingButton->setText(tr("Lighting"));
	pLightingButton->setIcon(QIcon("Aqua100.png"));
	m_pToolbar->addWidget(pLightingButton);
	m_pToolbar->addSeparator();

	QPushButton * pGameOverlayButton = new QPushButton();
	pGameOverlayButton->setCheckable(true);
	pGameOverlayButton->setIcon(QIcon("Aqua100.png"));
	//pGameOverlayButton->setMinimumHeight(TOOLBAR_MIN_HEIGHT);
	m_pToolbar->addWidget(pGameOverlayButton);
	m_pToolbar->addSeparator();

	QPushButton * pAuditionButton = new QPushButton();
	pAuditionButton->setCheckable(true);
	pAuditionButton->setIcon(QIcon("Aqua100.png"));
	//pAuditionButton->setMinimumHeight(TOOLBAR_MIN_HEIGHT);
	m_pToolbar->addWidget(pAuditionButton);
	m_pToolbar->addSeparator();

	//╟я©ь╪Ч╪╥╣╫ср╠ъ
	QWidget * space = new QWidget();
	space->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	m_pToolbar->addWidget(space);

	m_pToolbar->addSeparator();
	QPushButton * gizmos = new QPushButton();
	gizmos->setText(tr("Gizmos"));
	m_pToolbar->addWidget(gizmos);
	m_pToolbar->addSeparator();

	QLineEdit * searchEdit = new QLineEdit();
	m_pToolbar->addWidget(searchEdit);



}
Esempio n. 30
0
MainWindow::MainWindow(QWidget* parent)
    : QMainWindow(parent)
{
    const int screenWidth = QApplication::desktop()->width();
    const int screenHeight = QApplication::desktop()->height();
    const int appWidth = 500;
    const int appHeight = 300;

    setGeometry((screenWidth - appWidth) / 2, (screenHeight - appHeight) / 2, appWidth, appHeight);

    setObjectName("mainwindow");
    setWindowTitle("developers' test version, not for public use");
    setWindowIcon(QIcon(":/icons/icon64.png"));
    setContextMenuPolicy(Qt::PreventContextMenu);

    QDockWidget* friendDock = new QDockWidget(this);
    friendDock->setObjectName("FriendDock");
    friendDock->setFeatures(QDockWidget::NoDockWidgetFeatures);
    friendDock->setTitleBarWidget(new QWidget(friendDock));
    friendDock->setContextMenuPolicy(Qt::PreventContextMenu);
    addDockWidget(Qt::LeftDockWidgetArea, friendDock);

    QWidget* friendDockWidget = new QWidget(friendDock);
    QVBoxLayout* layout = new QVBoxLayout(friendDockWidget);
    layout->setMargin(0);
    layout->setSpacing(0);
    friendDock->setWidget(friendDockWidget);

    ourUserItem = new OurUserItemWidget(this);
    friendsWidget = new FriendsWidget(friendDockWidget);

    // Create toolbar
    QToolBar *toolBar = new QToolBar(this);
    toolBar->setToolButtonStyle(Qt::ToolButtonIconOnly);
    toolBar->setIconSize(QSize(16, 16));
    toolBar->setFocusPolicy(Qt::ClickFocus);

    QToolButton *addFriendButton = new QToolButton(toolBar);
    addFriendButton->setIcon(QIcon("://icons/user_add.png"));
    addFriendButton->setToolTip(tr("Add friend"));
    connect(addFriendButton, &QToolButton::clicked, friendsWidget, &FriendsWidget::onAddFriendButtonClicked);

    QWidget *spacer = new QWidget(toolBar);
    spacer->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Preferred);

    QToolButton *menuButton = new QToolButton(toolBar);
    menuButton->setIcon(QIcon("://icons/cog.png"));
    menuButton->setToolTip(tr("Mainmenu"));
    menuButton->setPopupMode(QToolButton::InstantPopup);
    QMenu *mainmenu = new QMenu(menuButton);
    mainmenu->addAction(QIcon(":/icons/setting_tools.png"), tr("Settings"), this, SLOT(onSettingsActionTriggered()));
    mainmenu->addSeparator();
    mainmenu->addAction(tr("About %1").arg(AppInfo::name), this, SLOT(onAboutAppActionTriggered()));
    mainmenu->addAction(tr("About Qt"), qApp, SLOT(aboutQt()));
    mainmenu->addSeparator();
    mainmenu->addAction(tr("Quit"), this, SLOT(onQuitApplicationTriggered()), QKeySequence::Quit);
    menuButton->setMenu(mainmenu);

    toolBar->addWidget(addFriendButton);
    toolBar->addWidget(spacer);
    toolBar->addWidget(menuButton);
    // Create toolbar end

    layout->addWidget(ourUserItem);
    layout->addWidget(friendsWidget);
    layout->addWidget(toolBar);

    PagesWidget* pages = new PagesWidget(this);
    connect(friendsWidget, &FriendsWidget::friendAdded, pages, &PagesWidget::addPage);
    connect(friendsWidget, &FriendsWidget::friendSelectionChanged, pages, &PagesWidget::activatePage);
    connect(friendsWidget, &FriendsWidget::friendStatusChanged, pages, &PagesWidget::statusChanged);

    //FIXME: start core in a separate function
    //all connections to `core` should be done after its creation because it registers some types
    core = new Core();

    coreThread = new QThread(this);
    core->moveToThread(coreThread);
    connect(coreThread, &QThread::started, core, &Core::start);

    qRegisterMetaType<Status>("Status");

    connect(core, &Core::connected, this, &MainWindow::onConnected);
    connect(core, &Core::disconnected, this, &MainWindow::onDisconnected);
    connect(core, &Core::friendRequestRecieved, this, &MainWindow::onFriendRequestRecieved);
    connect(core, SIGNAL(friendStatusChanged(int, Status)), friendsWidget, SLOT(setStatus(int, Status)));
    connect(core, &Core::friendAddressGenerated, ourUserItem, &OurUserItemWidget::setFriendAddress);
    connect(core, &Core::friendAdded, friendsWidget, &FriendsWidget::addFriend);
    connect(core, &Core::friendMessageRecieved, pages, &PagesWidget::messageReceived);
    connect(core, &Core::actionReceived, pages, &PagesWidget::actionReceived);
    connect(core, &Core::friendUsernameChanged, friendsWidget, &FriendsWidget::setUsername);
    connect(core, &Core::friendUsernameChanged, pages, &PagesWidget::usernameChanged);
    connect(core, &Core::friendRemoved, friendsWidget, &FriendsWidget::removeFriend);
    connect(core, &Core::friendRemoved, pages, &PagesWidget::removePage);
    connect(core, &Core::failedToRemoveFriend, this, &MainWindow::onFailedToRemoveFriend);
    connect(core, &Core::failedToAddFriend, this, &MainWindow::onFailedToAddFriend);
    connect(core, &Core::messageSentResult, pages, &PagesWidget::messageSentResult);
    connect(core, &Core::actionSentResult, pages, &PagesWidget::actionResult);

    coreThread->start(/*QThread::IdlePriority*/);

    connect(this, &MainWindow::friendRequestAccepted, core, &Core::acceptFriendRequest);

    connect(ourUserItem, &OurUserItemWidget::usernameChanged, core, &Core::setUsername);
    connect(core, &Core::usernameSet, ourUserItem, &OurUserItemWidget::setUsername);

    connect(ourUserItem, &OurUserItemWidget::statusMessageChanged, core, &Core::setStatusMessage);
    connect(core, &Core::statusMessageSet, ourUserItem, &OurUserItemWidget::setStatusMessage);

    connect(ourUserItem, &OurUserItemWidget::statusSelected, core, &Core::setStatus);

    connect(pages, &PagesWidget::sendMessage, core, &Core::sendMessage);
    connect(pages, &PagesWidget::sendAction,  core, &Core::sendAction);

    connect(friendsWidget, &FriendsWidget::friendRequested, core, &Core::requestFriendship);
    connect(friendsWidget, &FriendsWidget::friendRemoved, core, &Core::removeFriend);

    setCentralWidget(pages);

    Settings::getInstance().loadWindow(this);
}