Ejemplo n.º 1
0
void TradeTable::mousePressEvent(QMouseEvent * event)
{  
	QModelIndex modelIndex = indexAt(event->pos());
	if (event->button() == Qt::RightButton)
	{
		QMenu * popupMenu = new QMenu(this);
		QString menuStyle = "QMenu { font-size:18px; color:blue; background-color:qlineargradient(x1:0, y1:0, x2:0, y2:1, stop: 0 #cccccc, stop: 1 #555555);}" ;
		popupMenu->setStyleSheet(menuStyle);
		m_SelectedIndex = modelIndex.row();
		if(modelIndex.isValid() && modelIndex.row()>=0)
		{
			this->setSelection(this->visualRect(modelIndex),QItemSelectionModel::SelectCurrent);
			popupMenu->addAction(tr("&Order"), this, SLOT(Order()),QKeySequence(Qt::CTRL + Qt::Key_O));
			popupMenu->addAction(tr("&Chart"),this,SLOT(Chart()),QKeySequence(Qt::CTRL + Qt::Key_C));
			popupMenu->addSeparator();
			popupMenu->addAction(tr("&Delete"),this,SLOT(Delete()),QKeySequence(Qt::CTRL + Qt::Key_D));
			popupMenu->addAction(tr("&Add"),this,SLOT(Add()),QKeySequence(Qt::CTRL + Qt::Key_A));
			popupMenu->addAction(tr("&Move&Up"),this,SLOT(MoveUp()),QKeySequence(Qt::CTRL + Qt::Key_M,Qt::CTRL + Qt::Key_U));
			popupMenu->addAction(tr("&UpTo&Top"),this,SLOT(UpToTop()),QKeySequence(Qt::CTRL + Qt::Key_U,Qt::CTRL + Qt::Key_T));
			popupMenu->addAction(tr("&Move&Down"),this,SLOT(MoveDown()),QKeySequence(Qt::CTRL + Qt::Key_M,Qt::CTRL + Qt::Key_D));
			popupMenu->addAction(tr("&DownTo&Bottom"),this,SLOT(DownToBottom()),QKeySequence(Qt::CTRL + Qt::Key_D,Qt::CTRL + Qt::Key_B));
		}
		else
		{
			popupMenu->addAction(tr("&Add"),this,SLOT(Add()),QKeySequence(Qt::CTRL + Qt::Key_A));
		}
		popupMenu->exec(event->globalPos());  
	}
	QTableView::mousePressEvent(event);
}
Ejemplo n.º 2
0
void CaptionGraphicsItem::selectPropertyButtonClicked() {
  if (_view->graph() == nullptr)
    return;

  QMenu menu;
  for (const string &piName : _view->graph()->getProperties()) {
    if (_view->graph()->getProperty(piName)->getTypename() != "double")
      continue;

    QAction *action = menu.addAction(piName.c_str(), this, SLOT(propertySelectedSlot()));

    if (_confPropertySelectionWidget->text() == QString(piName.c_str()))
      menu.setActiveAction(action);
  }
  // set a combo like stylesheet
  QPalette palette = QComboBox().palette();
  menu.setStyleSheet(QString("QMenu::item {color: %1; background-color: %2;} QMenu::item:selected "
                             "{color: %3; background-color: %4}")
                         .arg(palette.color(QPalette::Active, QPalette::Text).name())
                         .arg(palette.color(QPalette::Active, QPalette::Base).name())
                         .arg(palette.color(QPalette::Active, QPalette::HighlightedText).name())
                         .arg(palette.color(QPalette::Active, QPalette::Highlight).name()));

  // compute a combo like position
  // to popup the menu
  QWidget *pViewport = QApplication::widgetAt(QCursor::pos());
  QWidget *pView = pViewport->parentWidget();
  QGraphicsView *pGraphicsView = qobject_cast<QGraphicsView *>(pView);
  QPoint popupPos =
      pGraphicsView->mapToGlobal(pGraphicsView->mapFromScene(_confPropertySelectionItem->mapToScene(
          _confPropertySelectionItem->subWidgetRect(_confPropertySelectionWidget).bottomLeft())));

  menu.exec(popupPos);
}
void PriceDisplayBoardWindowBoxList::mousePressEvent(QMouseEvent * event)
{
	if (event->button() == Qt::RightButton)
	{
		QMenu * popupMenu = new QMenu(this);
		QString menuStyle = "QMenu { font-size:18px; color:white; background-color:qlineargradient(x1:0, y1:0, x2:0, y2:1, stop: 0 #cccccc, stop: 1 #333333);}" ;
		popupMenu->setStyleSheet(menuStyle);

		popupMenu->addAction(tr("&Add"),this,SLOT(Add()),QKeySequence(Qt::CTRL + Qt::Key_A));
		popupMenu->addSeparator();

		QAction* highestLowest = new QAction(tr("&HighestLowest"), this);
		connect(highestLowest,SIGNAL(triggered()), this, SLOT(HighestLowest()));
		QAction* preClose = new QAction(tr("&PreClose"), this);
		connect(preClose,SIGNAL(triggered()), this, SLOT(PreClose()));
		QAction* interestRate = new QAction(tr("&InterestRate"), this);
		connect(interestRate,SIGNAL(triggered()), this, SLOT(InterestRate()));

		QActionGroup* infoGroup = new QActionGroup(this);
		infoGroup->addAction(highestLowest);
		infoGroup->addAction(preClose);
		infoGroup->addAction(interestRate);

		QMenu* marketInfo = popupMenu->addMenu(tr("&MarketInformations"));
		marketInfo->addAction(highestLowest);
		marketInfo->addAction(preClose);
		marketInfo->addAction(interestRate);

		popupMenu->exec(event->globalPos());
	}
}
Ejemplo n.º 4
0
void TAction::expandToolbar( mudlet * pMainWindow, TEasyButtonBar * pT, QMenu * menu )
{
   typedef list<TAction *>::const_iterator I;
   for( I it = mpMyChildrenList->begin(); it != mpMyChildrenList->end(); it++)
   {
       TAction * pChild = *it;
       if( ! pChild->isActive() ) continue;
       QIcon icon( pChild->mIcon );
       QString name = pChild->getName();
       TFlipButton * button = new TFlipButton( pT,pChild, pChild->mID, mpHost );
       button->setIcon( icon );
       button->setText( name );
       button->setCheckable( pChild->mIsPushDownButton );
       button->setFlat( mButtonFlat );
       button->setStyleSheet( css );
       button->setChecked( (pChild->mButtonState==2) );
       if( mpHost->mIsProfileLoadingSequence && pChild->mButtonState == 2 )
       {
           qDebug()<<"name="<<pChild->mName<<" executing script";
           QStringList bla;
           pChild->_execute(bla);
       }

       pT->addButton( button );

       if( pChild->mIsFolder )
       {
           QMenu * newMenu = new QMenu( button );
           button->setMenu( newMenu );
           newMenu->setStyleSheet( css );
           pChild->fillMenu( pT, newMenu );
       }
   }
}
Ejemplo n.º 5
0
void TAction::fillMenu( TEasyButtonBar * pT, QMenu * menu )
{
    typedef list<TAction *>::const_iterator I;
    for( I it = mpMyChildrenList->begin(); it != mpMyChildrenList->end(); it++)
    {
        TAction * pChild = *it;
        if( ! pChild->isActive() ) continue;
        mpEasyButtonBar = pT;
        QIcon icon( mIcon );
        EAction * action = new EAction( icon, pChild->mName, mudlet::self() );
        action->setCheckable( pChild->mIsPushDownButton );
        action->mID = pChild->mID;
        action->mpHost = mpHost;
        action->setStatusTip( pChild->mName );
        action->setChecked((pChild->mButtonState==2));
        if( mpHost->mIsProfileLoadingSequence && pChild->mButtonState == 2 )
        {
            qDebug()<<"name="<<pChild->mName<<" executing script";
            QStringList bla;
            pChild->_execute(bla);
        }
        menu->addAction( action );
        if( pChild->mIsFolder )
        {
           QMenu * newMenu = new QMenu;
           action->setMenu( newMenu );
           newMenu->setStyleSheet( css );
           pChild->fillMenu( pT, newMenu );
           //mudlet::self()->bindMenu( menu, action );
        }
    }
}
Ejemplo n.º 6
0
void TAction::expandToolbar( mudlet * pMainWindow, TToolBar * pT, QMenu * menu )
{
   typedef list<TAction *>::const_iterator I;
   for( I it = mpMyChildrenList->begin(); it != mpMyChildrenList->end(); it++)
   {
       TAction * pChild = *it;

       QIcon icon( pChild->mIcon );
       QString name = pChild->getName();
       TFlipButton * button = new TFlipButton( pT,pChild, pChild->mID, mpHost );
       button->setIcon( icon );
       button->setText( name );
       button->setCheckable( pChild->mIsPushDownButton );
       button->setChecked( (pChild->mButtonState==2) );
qDebug()<<"button="<<pChild->mName<<" checked="<<(pChild->mButtonState==2);
       button->setFlat( mButtonFlat );
       button->setStyleSheet( css );

       pT->addButton( button );

       if( pChild->mIsFolder )
       {
           QMenu * newMenu = new QMenu( pT );
           button->setMenu( newMenu );
           newMenu->setStyleSheet( css );
           pChild->insertActions( pMainWindow, pT, newMenu );
       }
   }
}
Ejemplo n.º 7
0
void TAction::insertActions( mudlet * pMainWindow, TToolBar * pT, QMenu * menu )
{
    mpToolBar = pT;
    QIcon icon( mIcon );
    EAction * action = new EAction( icon, mName, pMainWindow );
    action->setCheckable( mIsPushDownButton );
    action->mID = mID;
    action->mpHost = mpHost;
    action->setStatusTip( mName );
    menu->addAction( action );
    //mudlet::self()->bindMenu( menu, action );


    if( mIsFolder )
    {
        QMenu * newMenu = new QMenu( pMainWindow );
        newMenu->setStyleSheet( css );
        action->setMenu( newMenu );

        typedef list<TAction *>::const_iterator I;
        for( I it = mpMyChildrenList->begin(); it != mpMyChildrenList->end(); it++)
        {
            TAction * pChild = *it;
            pChild->insertActions( pMainWindow, pT, newMenu );
        }
    }
}
Ejemplo n.º 8
0
void BitcoinGUI::createToolBars2()
{
    QLabel *mylabel = new QLabel (this);
   mylabel->setPixmap(QPixmap(":images/head"));
   mylabel->show();

    QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
    toolbar->setObjectName("toolbar");
    addToolBar(Qt::LeftToolBarArea,toolbar);
    toolbar->setOrientation(Qt::Vertical);
    toolbar->setMovable( false );
    toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
    toolbar->setIconSize(QSize(50,25));
    toolbar->addWidget(mylabel);
    toolbar->addAction(overviewAction);
    toolbar->addAction(sendCoinsAction);
    toolbar->addAction(receiveCoinsAction);
    toolbar->addAction(historyAction);
    toolbar->addAction(addressBookAction);
    toolbar->addAction(blockAction);
    toolbar->addAction(statisticsAction);
    toolbar->addAction(optionsAction);

    QWidget* spacer = new QWidget();
    spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    toolbar->addWidget(spacer);
    spacer->setObjectName("spacer");
    toolbar->setStyleSheet(
    "#toolbar { font-weight:600;border:none;height:100%;padding-top:20px; background: rgb(37,40,46); text-align: left; color: white;min-width:180px;max-width:180px;}"
    "QToolBar QToolButton:hover {background:rgb(28,29,33);}"
    "QToolBar QToolButton:checked {background:rgba(28,29,33,100);}"
    "QToolBar QToolButton { font-weight:600;font-size:10px;font-family:'Century Gothic';padding-left:20px;padding-right:181px;padding-top:5px;padding-bottom:5px; width:100%; color: white; text-align: left; background:transparent;text-transform:uppercase; }");

    wId = new QWidget(this);
    wId3 = new QWidget(this);
    QToolBar *toolbars = addToolBar(tr("Settings2"));
    addToolBar(Qt::RightToolBarArea,toolbars);
    toolbars->setOrientation(Qt::Horizontal);
    toolbars->setMovable( false );
    toolbars->setStyleSheet("QToolBar QToolButton {border:0px;margin-right:3px} QToolBar{ border:0px; }");
    toolbars->setIconSize(QSize(102,25));
    QHBoxLayout *vbox5 = new QHBoxLayout();
    vbox5->addWidget(toolbars);
    vbox5->setContentsMargins(0,0,0,0);
    wId3->setFixedSize(250,30);
    wId3->move(260,10);
    wId3->setLayout(vbox5);
    wId3->setFocus();
    wId3->raise();
    QMenu *menu = new QMenu(tr("Mini"));
    menu->setStyleSheet("border:none;background:none;");
    menu->addAction(toggleHideAction);
    menu->menuAction()->setIcon(QIcon(":/icons/mini"));
    QHBoxLayout *vbox3 = new QHBoxLayout();
    vbox3->setContentsMargins(0,0,0,0);
    wId->setFixedSize(120,40);
    wId->move(915,1);
    wId->setLayout(vbox3);
    wId->setFocus();
}
Ejemplo n.º 9
0
void Login::Status_init()
{
    QMenu * menu = ui->Status_pushButton->getmenu();
    QActionGroup *actionGroup = new QActionGroup(this);
    menu->setStyleSheet("QMenu {color: white;background-color:#E78261; border: 1px solid black;width:70px;}"
                        "QMenu::item {background-color: transparent; }"
                        "QMenu::item:selected { background-color: #FF781F;}");
    action[0] = new QAction(QIcon(":/images/images/imonline.png"), tr("在线"), this);
    action[1] = new QAction(QIcon(":/images/images/imhidden.png"), tr("隐身"), this);
    action[2] = new QAction(QIcon(":/images/images/imbusy.png"), tr("忙碌"), this);
    action[3] = new QAction(QIcon(":/images/images/imaway.png"), tr("离开"), this);
    action[4] = new QAction(QIcon(":/images/images/imcallme.png"), tr("求扰"), this);
    action[5] = new QAction(QIcon(":/images/images/imsilent.png"), tr("勿扰"), this);

    ImagesIcon[0] = ":/images/images/status-online-1.svg";
    ImagesIcon[1] = ":/images/images/status-hidden-1.svg";
    ImagesIcon[2] = ":/images/images/status-busy-1.svg";
    ImagesIcon[3] = ":/images/images/status-away-1.svg";
    ImagesIcon[4] = ":/images/images/status-callme-1.svg";
    ImagesIcon[5] = ":/images/images/status-silent-1.svg";
    for(int i =0;i<6;i++)
    {

        menu->addAction(actionGroup->addAction(action[i]));
        action[i]->setCheckable(true);
        connect(action[i], SIGNAL(triggered()), this, SLOT(Status_Changed()));
    }
    action[0]->setChecked(true);


}
Ejemplo n.º 10
0
void BitcoinGUI::createMenuBar()
{
#ifdef Q_OS_MAC
    // Create a decoupled menu bar on Mac which stays even if the window is closed
    appMenuBar = new QMenuBar();
#else
    // Get the main window's menu bar on other platforms
    appMenuBar = menuBar();
#endif

    // Configure the menus
    QMenu *file = appMenuBar->addMenu(tr("&File"));
    file->addAction(backupWalletAction);
    file->addAction(exportAction);
    file->addAction(signMessageAction);
    file->addAction(verifyMessageAction);
    file->addSeparator();
    file->addAction(quitAction);
    file->setObjectName("fileMenu");

    QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
    settings->addAction(encryptWalletAction);
    settings->addAction(changePassphraseAction);
    settings->addSeparator();
    settings->addAction(optionsAction);
    settings->setObjectName("settingsMenu");

    QMenu *help = appMenuBar->addMenu(tr("&Help"));
    help->addAction(openRPCConsoleAction);
    help->addSeparator();
    help->addAction(aboutAction);
    help->addAction(aboutQtAction);
    help->setObjectName("aboutMenu");

    file->setStyleSheet("QMenu#fileMenu { color: #ffffff; } QMenu::item#fileMenu { background-color: transparent;color:#ffffff; } QMenu::item:selected#fileMenu { background-color:#888888;color:#ffffff; }");
    settings->setStyleSheet("QMenu#settingsMenu { color: #ffffff; } QMenu::item#settingsMenu { background-color: transparent;color:#ffffff; } QMenu::item:selected#settingsMenu { background-color:#888888;color:#ffffff; }");
    help->setStyleSheet("QMenu#aboutMenu { color: #ffffff; } QMenu::item#aboutMenu { background-color: transparent;color:#ffffff; } QMenu::item:selected#aboutMenu { background-color:#888888;color:#ffffff; }");


    appMenuBar->setStyleSheet("border: 1px solid #202020; color: #000000; background-color: #eeeeee;");
}
void MusicQueryTableWidget::createContextMenu(QMenu &menu)
{
    menu.setStyleSheet(MusicUIObject::MMenuStyle02);
    m_actionGroup->addAction(menu.addAction(tr("musicDownload")));

    menu.addSeparator();

    QString songName = currentRow() != -1 && rowCount() > 0 ?
                item(currentRow(), 1)->text() : QString();
    QString artistName = currentRow() != -1 && rowCount() > 0 ?
                item(currentRow(), 2)->text() : QString();
    m_actionGroup->addAction(menu.addAction(tr("search '%1'").arg(songName)));
    m_actionGroup->addAction(menu.addAction(tr("search '%1'").arg(artistName)));
    m_actionGroup->addAction(menu.addAction(tr("search '%1 - %2'").arg(songName).arg(artistName)));
}
Ejemplo n.º 12
0
void MyPlaylist::contextMenuEvent(QContextMenuEvent *event)
{
    QMenu menu;

    menu.addAction(tr("添加歌曲"),this,SLOT(add_File_slot()));
    if(this->rowCount()!= 0)
    {
        menu.addAction(tr("清空列表"), this, SLOT(clear_play_list()));//可以直接在这里指定槽函数
    }

    menu.setStyleSheet("QMenu{padding:5px;background:white;border:1px solid gray;}"
                       "QMenu::item{padding:0px 40px 0px 30px;height:25px;}"
                       "QMenu::item:selected:!enabled{background:transparent;}"
                       "QMenu::item:selected:enabled{background:lightgray;color:white;}");
    menu.exec(event->globalPos());//返回鼠标指针的全局位置


}
Ejemplo n.º 13
0
void MainWindow::showTrayIcon() {

	if(variables->verbose)
		LOG << CURDATE << "showTrayIcon()" << NL;

	if(settingsPermanent->trayicon != 0) {

		if(!variables->trayiconSetup) {

			if(variables->verbose)
				LOG << CURDATE << "showTrayIcon(): Setting up" << NL;

			trayIcon = new QSystemTrayIcon(this);
			trayIcon->setIcon(QIcon(":/img/icon.png"));
			trayIcon->setToolTip("PhotoQt - " + tr("Image Viewer"));

			// A context menu for the tray icon
			QMenu *trayIconMenu = new QMenu;
			trayIconMenu->setStyleSheet("background-color: rgb(67,67,67); color: white; border-radius: 5px;");
			QAction *trayAcToggle = new QAction(QIcon(":/img/logo.png"),tr("Hide/Show PhotoQt"),this);
			trayIconMenu->addAction(trayAcToggle);
			connect(trayAcToggle, SIGNAL(triggered()), this, SLOT(show()));

			// Set the menu to the tray icon
			trayIcon->setContextMenu(trayIconMenu);
			connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayAction(QSystemTrayIcon::ActivationReason)));

			variables->trayiconSetup = true;

		}

		if(variables->verbose)
			LOG << CURDATE << "showTrayIcon(): Setting icon to visible" << NL;

		trayIcon->show();
		variables->trayiconVisible = true;

	}

}
Ejemplo n.º 14
0
QConsoleWidgetPrivate::QConsoleWidgetPrivate(
        QConsoleWidget *s,QWidget *p
        ):
    QConsoleWidgetPrivateParent(p)
{
    super = s;
    positionX = 0;
    positionY = 0;
    {//TODO: font menu
        QMenu * menu = new QMenu(this);
        this->setMenu(menu);
        menu->setStyleSheet( MenuStyleSheet );
        this->setPopupMode(QToolButton::InstantPopup);
        typedef void(QAction::*AT)(bool);
        {
            QAction * action =
                    new QAction( trUtf8(u8"选择字体"), this);
            action->connect(action, AT(&QAction::triggered ),
                            [this](bool) { 
				selectAndSetFont(); }
            );
            menu->addAction(action);
			actions[0] = action;
        }
		{
			QAction * action =
                new QAction( trUtf8(u8"选择字体颜色"), this);
			action->connect(action, AT(&QAction::triggered),
				[this](bool) {
				selectAndSetFontColor(); }
			);
			actions[1] = action;
			menu->addAction(action);
		}
    }
}
Ejemplo n.º 15
0
void CLoginButton::menuCreate() {
    QMenu* menu = new QMenu(this);

    QWidget *w = new QWidget(this);
    ui = new Ui::loginWidget;
    ui->setupUi(w);

    ui->toolButton->setEnabled(false);
    connect(ui->lineEdit, &QLineEdit::textChanged,
            this, &CLoginButton::usernameCheck);
    connect(ui->toolButton, &QToolButton::clicked,
            this, &CLoginButton::login);

    QVBoxLayout *vlayout = new QVBoxLayout;
    vlayout->addWidget(w);
    menu->setLayout(vlayout);

    QPixmap pixmap(":/back/ui/back/combox.png");
    menu->setMask(pixmap.mask());
    menu->setStyleSheet("color:white; background-color: rgb(85, 92, 120);");
    menu->installEventFilter(this);

    setMenu(menu);
}