예제 #1
0
CoverFoundDialog::CoverFoundDialog( const CoverFetchUnit::Ptr unit,
                                    const CoverFetch::Metadata &data,
                                    QWidget *parent )
    : KDialog( parent )
    , m_album( unit->album() )
    , m_isSorted( false )
    , m_sortEnabled( false )
    , m_unit( unit )
    , m_queryPage( 0 )
{
    DEBUG_BLOCK
    setButtons( KDialog::Ok | KDialog::Cancel |
                KDialog::User1 ); // User1: clear icon view

    setButtonGuiItem( KDialog::User1, KStandardGuiItem::clear() );
    connect( button( KDialog::User1 ), SIGNAL(clicked()), SLOT(clearView()) );

    m_save = button( KDialog::Ok );

    QSplitter *splitter = new QSplitter( this );
    m_sideBar = new CoverFoundSideBar( m_album, splitter );

    KVBox *vbox = new KVBox( splitter );
    vbox->setSpacing( 4 );

    KHBox *breadcrumbBox = new KHBox( vbox );
    QLabel *breadcrumbLabel = new QLabel( i18n( "Finding cover for" ), breadcrumbBox );
    AlbumBreadcrumbWidget *breadcrumb = new AlbumBreadcrumbWidget( m_album, breadcrumbBox );

    QFont breadcrumbLabelFont;
    breadcrumbLabelFont.setBold( true );
    breadcrumbLabel->setFont( breadcrumbLabelFont );
    breadcrumbLabel->setIndent( 4 );

    connect( breadcrumb, SIGNAL(artistClicked(QString)), SLOT(addToCustomSearch(QString)) );
    connect( breadcrumb, SIGNAL(albumClicked(QString)), SLOT(addToCustomSearch(QString)) );

    KHBox *searchBox = new KHBox( vbox );
    vbox->setSpacing( 4 );

    QStringList completionNames;
    QString firstRunQuery( m_album->name() );
    completionNames << firstRunQuery;
    if( m_album->hasAlbumArtist() )
    {
        const QString &name = m_album->albumArtist()->name();
        completionNames << name;
        firstRunQuery += ' ' + name;
    }
    m_query = firstRunQuery;
    m_album->setSuppressImageAutoFetch( true );

    m_search = new KComboBox( searchBox );
    m_search->setEditable( true ); // creates a KLineEdit for the combobox
    m_search->setTrapReturnKey( true );
    m_search->setInsertPolicy( QComboBox::NoInsert ); // insertion is handled by us
    m_search->setCompletionMode( KGlobalSettings::CompletionPopup );
    m_search->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
    qobject_cast<KLineEdit*>( m_search->lineEdit() )->setClickMessage( i18n( "Enter Custom Search" ) );
    m_search->completionObject()->setOrder( KCompletion::Insertion );
    m_search->completionObject()->setIgnoreCase( true );
    m_search->completionObject()->setItems( completionNames );
    m_search->insertItem( 0, KStandardGuiItem::find().icon(), QString() );
    m_search->insertSeparator( 1 );
    m_search->insertItem( 2, KIcon("filename-album-amarok"), m_album->name() );
    if( m_album->hasAlbumArtist() )
        m_search->insertItem( 3, KIcon("filename-artist-amarok"), m_album->albumArtist()->name() );

    m_searchButton = new KPushButton( KStandardGuiItem::find(), searchBox );
    KPushButton *sourceButton = new KPushButton( KStandardGuiItem::configure(), searchBox );
    updateSearchButton( firstRunQuery );

    QMenu *sourceMenu = new QMenu( sourceButton );
    QAction *lastFmAct = new QAction( i18n( "Last.fm" ), sourceMenu );
    QAction *googleAct = new QAction( i18n( "Google" ), sourceMenu );
    QAction *discogsAct = new QAction( i18n( "Discogs" ), sourceMenu );
    lastFmAct->setCheckable( true );
    googleAct->setCheckable( true );
    discogsAct->setCheckable( true );
    connect( lastFmAct, SIGNAL(triggered()), this, SLOT(selectLastFm()) );
    connect( googleAct, SIGNAL(triggered()), this, SLOT(selectGoogle()) );
    connect( discogsAct, SIGNAL(triggered()), this, SLOT(selectDiscogs()) );

    m_sortAction = new QAction( i18n( "Sort by size" ), sourceMenu );
    m_sortAction->setCheckable( true );
    connect( m_sortAction, SIGNAL(triggered(bool)), this, SLOT(sortingTriggered(bool)) );

    QActionGroup *ag = new QActionGroup( sourceButton );
    ag->addAction( lastFmAct );
    ag->addAction( googleAct );
    ag->addAction( discogsAct );
    sourceMenu->addActions( ag->actions() );
    sourceMenu->addSeparator();
    sourceMenu->addAction( m_sortAction );
    sourceButton->setMenu( sourceMenu );

    connect( m_search, SIGNAL(returnPressed(QString)), SLOT(insertComboText(QString)) );
    connect( m_search, SIGNAL(returnPressed(QString)), SLOT(processQuery(QString)) );
    connect( m_search, SIGNAL(returnPressed(QString)), SLOT(updateSearchButton(QString)) );
    connect( m_search, SIGNAL(editTextChanged(QString)), SLOT(updateSearchButton(QString)) );
    connect( m_search->lineEdit(), SIGNAL(clearButtonClicked()), SLOT(clearQueryButtonClicked()));
    connect( m_searchButton, SIGNAL(clicked()), SLOT(processQuery()) );

    m_view = new KListWidget( vbox );
    m_view->setAcceptDrops( false );
    m_view->setContextMenuPolicy( Qt::CustomContextMenu );
    m_view->setDragDropMode( QAbstractItemView::NoDragDrop );
    m_view->setDragEnabled( false );
    m_view->setDropIndicatorShown( false );
    m_view->setMovement( QListView::Static );
    m_view->setGridSize( QSize( 140, 150 ) );
    m_view->setIconSize( QSize( 120, 120 ) );
    m_view->setSpacing( 4 );
    m_view->setViewMode( QListView::IconMode );
    m_view->setResizeMode( QListView::Adjust );

    connect( m_view, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),
             this,   SLOT(currentItemChanged(QListWidgetItem*,QListWidgetItem*)) );
    connect( m_view, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
             this,   SLOT(itemDoubleClicked(QListWidgetItem*)) );
    connect( m_view, SIGNAL(customContextMenuRequested(QPoint)),
             this,   SLOT(itemMenuRequested(QPoint)) );

    splitter->addWidget( m_sideBar );
    splitter->addWidget( vbox );
    setMainWidget( splitter );

    const KConfigGroup config = Amarok::config( "Cover Fetcher" );
    const QString source = config.readEntry( "Interactive Image Source", "LastFm" );
    m_sortEnabled = config.readEntry( "Sort by Size", false );
    m_sortAction->setChecked( m_sortEnabled );
    m_isSorted = m_sortEnabled;
    restoreDialogSize( config ); // call this after setMainWidget()

    if( source == "LastFm" )
        lastFmAct->setChecked( true );
    else if( source == "Discogs" )
        discogsAct->setChecked( true );
    else
        googleAct->setChecked( true );

    typedef CoverFetchArtPayload CFAP;
    const CFAP *payload = dynamic_cast< const CFAP* >( unit->payload() );
    if( !m_album->hasImage() )
        m_sideBar->setPixmap( QPixmap::fromImage( m_album->image(190 ) ) );
    else if( payload )
        add( m_album->image(), data, payload->imageSize() );
    else
        add( m_album->image(), data );
    m_view->setCurrentItem( m_view->item( 0 ) );
    updateGui();
    
    connect( The::networkAccessManager(), SIGNAL(requestRedirected(QNetworkReply*,QNetworkReply*)),
             this, SLOT(fetchRequestRedirected(QNetworkReply*,QNetworkReply*)) );
}
예제 #2
0
파일: playlist.cpp 프로젝트: ryanli/vlc
PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i, QWidget *_par )
               : QWidget( _par ), p_intf ( _p_i )
{

    setContentsMargins( 0, 3, 0, 3 );

    QGridLayout *layout = new QGridLayout( this );
    layout->setMargin( 0 ); layout->setSpacing( 0 );

    /*******************
     * Left            *
     *******************/
    /* We use a QSplitter for the left part */
    leftSplitter = new QSplitter( Qt::Vertical, this );

    /* Source Selector */
    selector = new PLSelector( this, p_intf );
    leftSplitter->addWidget( selector );

    /* Create a Container for the Art Label
       in order to have a beautiful resizing for the selector above it */
    artContainer = new QStackedWidget;
    artContainer->setMaximumHeight( 128 );

    /* Art label */
    CoverArtLabel *art = new CoverArtLabel( artContainer, p_intf );
    art->setToolTip( qtr( "Double click to get media information" ) );
    artContainer->addWidget( art );

    CONNECT( THEMIM->getIM(), artChanged( QString ),
             art, showArtUpdate( const QString& ) );

    leftSplitter->addWidget( artContainer );

    /*******************
     * Right           *
     *******************/
    /* Initialisation of the playlist */
    playlist_t * p_playlist = THEPL;
    PL_LOCK;
    playlist_item_t *p_root = p_playlist->p_playing;
    PL_UNLOCK;

    setMinimumWidth( 400 );

    PLModel *model = PLModel::getPLModel( p_intf );
#ifdef MEDIA_LIBRARY
    MLModel *mlmodel = new MLModel( p_intf, this );
    mainView = new StandardPLPanel( this, p_intf, p_root, selector, model, mlmodel );
#else
    mainView = new StandardPLPanel( this, p_intf, p_root, selector, model, NULL );
#endif

    /* Location Bar */
    locationBar = new LocationBar( model );
    locationBar->setSizePolicy( QSizePolicy::Ignored, QSizePolicy::Preferred );
    layout->addWidget( locationBar, 0, 0, 1, 2 );
    layout->setColumnStretch( 0, 5 );
    CONNECT( locationBar, invoked( const QModelIndex & ),
             mainView, browseInto( const QModelIndex & ) );

    QHBoxLayout *topbarLayout = new QHBoxLayout();
    layout->addLayout( topbarLayout, 0, 1 );
    topbarLayout->setSpacing( 10 );

    /* Button to switch views */
    QToolButton *viewButton = new QToolButton( this );
    viewButton->setIcon( style()->standardIcon( QStyle::SP_FileDialogDetailedView ) );
    viewButton->setToolTip( qtr("Change playlistview") );
    topbarLayout->addWidget( viewButton );

    /* View selection menu */
    QSignalMapper *viewSelectionMapper = new QSignalMapper( this );
    CONNECT( viewSelectionMapper, mapped( int ), mainView, showView( int ) );

    QActionGroup *actionGroup = new QActionGroup( this );

#ifndef NDEBUG
# define MAX_VIEW StandardPLPanel::VIEW_COUNT
#else
# define MAX_VIEW StandardPLPanel::VIEW_COUNT - 1
#endif
    for( int i = 0; i < MAX_VIEW; i++ )
    {
        viewActions[i] = actionGroup->addAction( viewNames[i] );
        viewActions[i]->setCheckable( true );
        viewSelectionMapper->setMapping( viewActions[i], i );
        CONNECT( viewActions[i], triggered(), viewSelectionMapper, map() );
    }
    viewActions[mainView->currentViewIndex()]->setChecked( true );

    QMenu *viewMenu = new QMenu( viewButton );
    viewMenu->addActions( actionGroup->actions() );
    viewButton->setMenu( viewMenu );
    CONNECT( viewButton, clicked(), mainView, cycleViews() );

    /* Search */
    searchEdit = new SearchLineEdit( this );
    searchEdit->setMaximumWidth( 250 );
    searchEdit->setMinimumWidth( 80 );
    searchEdit->setToolTip( qtr("Search the playlist") );
    topbarLayout->addWidget( searchEdit );
    CONNECT( searchEdit, textChanged( const QString& ),
             mainView, search( const QString& ) );
    CONNECT( searchEdit, searchDelayedChanged( const QString& ),
             mainView, searchDelayed( const QString & ) );

    CONNECT( mainView, viewChanged( const QModelIndex& ),
             this, changeView( const QModelIndex &) );

    /* Connect the activation of the selector to a redefining of the PL */
    DCONNECT( selector, categoryActivated( playlist_item_t *, bool ),
              mainView, setRootItem( playlist_item_t *, bool ) );
    mainView->setRootItem( p_root, false );

    /* */
    split = new PlaylistSplitter( this );

    /* Add the two sides of the QSplitter */
    split->addWidget( leftSplitter );
    split->addWidget( mainView );

    QList<int> sizeList;
    sizeList << 180 << 420 ;
    split->setSizes( sizeList );
    split->setStretchFactor( 0, 0 );
    split->setStretchFactor( 1, 3 );
    split->setCollapsible( 1, false );
    leftSplitter->setMaximumWidth( 250 );

    /* In case we want to keep the splitter information */
    // components shall never write there setting to a fixed location, may infer
    // with other uses of the same component...
    getSettings()->beginGroup("Playlist");
    split->restoreState( getSettings()->value("splitterSizes").toByteArray());
    leftSplitter->restoreState( getSettings()->value("leftSplitterGeometry").toByteArray() );
    getSettings()->endGroup();

    layout->addWidget( split, 1, 0, 1, -1 );

    setAcceptDrops( true );
    setWindowTitle( qtr( "Playlist" ) );
    setWindowRole( "vlc-playlist" );
    setWindowIcon( QApplication::windowIcon() );
}
예제 #3
0
MemoryWindow::MemoryWindow(running_machine* machine, QWidget* parent) :
	WindowQt(machine, nullptr)
{
	setWindowTitle("Debug: Memory View");

	if (parent != nullptr)
	{
		QPoint parentPos = parent->pos();
		setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400);
	}

	//
	// The main frame and its input and log widgets
	//
	QFrame* mainWindowFrame = new QFrame(this);

	// The top frame & groupbox that contains the input widgets
	QFrame* topSubFrame = new QFrame(mainWindowFrame);

	// The input edit
	m_inputEdit = new QLineEdit(topSubFrame);
	connect(m_inputEdit, &QLineEdit::returnPressed, this, &MemoryWindow::expressionSubmitted);

	// The memory space combo box
	m_memoryComboBox = new QComboBox(topSubFrame);
	m_memoryComboBox->setObjectName("memoryregion");
	m_memoryComboBox->setMinimumWidth(300);
	connect(m_memoryComboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &MemoryWindow::memoryRegionChanged);

	// The main memory window
	m_memTable = new DebuggerMemView(DVT_MEMORY, m_machine, this);

	// Layout
	QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame);
	subLayout->addWidget(m_inputEdit);
	subLayout->addWidget(m_memoryComboBox);
	subLayout->setSpacing(3);
	subLayout->setContentsMargins(2,2,2,2);

	QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame);
	vLayout->setSpacing(3);
	vLayout->setContentsMargins(2,2,2,2);
	vLayout->addWidget(topSubFrame);
	vLayout->addWidget(m_memTable);

	setCentralWidget(mainWindowFrame);

	//
	// Menu bars
	//

	// Create a data format group
	QActionGroup* dataFormat = new QActionGroup(this);
	dataFormat->setObjectName("dataformat");
	QAction* formatActOne  = new QAction("1-byte chunks", this);
	QAction* formatActTwo  = new QAction("2-byte chunks", this);
	QAction* formatActFour = new QAction("4-byte chunks", this);
	QAction* formatActEight = new QAction("8-byte chunks", this);
	QAction* formatAct32bitFloat = new QAction("32 bit floating point", this);
	QAction* formatAct64bitFloat = new QAction("64 bit floating point", this);
	QAction* formatAct80bitFloat = new QAction("80 bit floating point", this);
	formatActOne->setObjectName("formatActOne");
	formatActTwo->setObjectName("formatActTwo");
	formatActFour->setObjectName("formatActFour");
	formatActEight->setObjectName("formatActEight");
	formatAct32bitFloat->setObjectName("formatAct32bitFloat");
	formatAct64bitFloat->setObjectName("formatAct64bitFloat");
	formatAct80bitFloat->setObjectName("formatAct80bitFloat");
	formatActOne->setCheckable(true);
	formatActTwo->setCheckable(true);
	formatActFour->setCheckable(true);
	formatActEight->setCheckable(true);
	formatAct32bitFloat->setCheckable(true);
	formatAct64bitFloat->setCheckable(true);
	formatAct80bitFloat->setCheckable(true);
	formatActOne->setActionGroup(dataFormat);
	formatActTwo->setActionGroup(dataFormat);
	formatActFour->setActionGroup(dataFormat);
	formatActEight->setActionGroup(dataFormat);
	formatAct32bitFloat->setActionGroup(dataFormat);
	formatAct64bitFloat->setActionGroup(dataFormat);
	formatAct80bitFloat->setActionGroup(dataFormat);
	formatActOne->setShortcut(QKeySequence("Ctrl+1"));
	formatActTwo->setShortcut(QKeySequence("Ctrl+2"));
	formatActFour->setShortcut(QKeySequence("Ctrl+4"));
	formatActEight->setShortcut(QKeySequence("Ctrl+8"));
	formatAct32bitFloat->setShortcut(QKeySequence("Ctrl+9"));
	formatActOne->setChecked(true);
	connect(dataFormat, &QActionGroup::triggered, this, &MemoryWindow::formatChanged);
	// Create a address display group
	QActionGroup* addressGroup = new QActionGroup(this);
	addressGroup->setObjectName("addressgroup");
	QAction* addressActLogical = new QAction("Logical Addresses", this);
	QAction* addressActPhysical = new QAction("Physical Addresses", this);
	addressActLogical->setCheckable(true);
	addressActPhysical->setCheckable(true);
	addressActLogical->setActionGroup(addressGroup);
	addressActPhysical->setActionGroup(addressGroup);
	addressActLogical->setShortcut(QKeySequence("Ctrl+G"));
	addressActPhysical->setShortcut(QKeySequence("Ctrl+Y"));
	addressActLogical->setChecked(true);
	connect(addressGroup, &QActionGroup::triggered, this, &MemoryWindow::addressChanged);

	// Create a reverse view radio
	QAction* reverseAct = new QAction("Reverse View", this);
	reverseAct->setObjectName("reverse");
	reverseAct->setCheckable(true);
	reverseAct->setShortcut(QKeySequence("Ctrl+R"));
	connect(reverseAct, &QAction::toggled, this, &MemoryWindow::reverseChanged);

	// Create increase and decrease bytes-per-line actions
	QAction* increaseBplAct = new QAction("Increase Bytes Per Line", this);
	QAction* decreaseBplAct = new QAction("Decrease Bytes Per Line", this);
	increaseBplAct->setShortcut(QKeySequence("Ctrl+P"));
	decreaseBplAct->setShortcut(QKeySequence("Ctrl+O"));
	connect(increaseBplAct, &QAction::triggered, this, &MemoryWindow::increaseBytesPerLine);
	connect(decreaseBplAct, &QAction::triggered, this, &MemoryWindow::decreaseBytesPerLine);

	// Assemble the options menu
	QMenu* optionsMenu = menuBar()->addMenu("&Options");
	optionsMenu->addActions(dataFormat->actions());
	optionsMenu->addSeparator();
	optionsMenu->addActions(addressGroup->actions());
	optionsMenu->addSeparator();
	optionsMenu->addAction(reverseAct);
	optionsMenu->addSeparator();
	optionsMenu->addAction(increaseBplAct);
	optionsMenu->addAction(decreaseBplAct);


	//
	// Initialize
	//
	populateComboBox();

	// Set to the current CPU's memory view
	setToCurrentCpu();
}
예제 #4
0
void TextEdit::setupTextActions()
{
    QToolBar *tb = new QToolBar(this);
    tb->setWindowTitle(tr("Format Actions"));
    addToolBar(tb);

    QMenu *menu = new QMenu(tr("F&ormat"), this);
    menuBar()->addMenu(menu);

    actionTextBold = new QAction(QIcon::fromTheme("format-text-bold", QIcon(rsrcPath + "/textbold.png")),
                                 tr("&Bold"), this);
    actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B);
    actionTextBold->setPriority(QAction::LowPriority);
	QFont bold;
    bold.setBold(true);
    actionTextBold->setFont(bold);
    connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold()));
    tb->addAction(actionTextBold);
    menu->addAction(actionTextBold);
    actionTextBold->setCheckable(true);

    actionTextItalic = new QAction(QIcon::fromTheme("format-text-italic", QIcon(rsrcPath + "/textitalic.png")),
                                   tr("&Italic"), this);
    actionTextItalic->setPriority(QAction::LowPriority);
    actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I);
    QFont italic;
    italic.setItalic(true);
    actionTextItalic->setFont(italic);
    connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic()));
    tb->addAction(actionTextItalic);
    menu->addAction(actionTextItalic);
    actionTextItalic->setCheckable(true);

    actionTextUnderline = new QAction(QIcon::fromTheme("format-text-underline", QIcon(rsrcPath + "/textunder.png")),
                                      tr("&Underline"), this);
    actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U);
    actionTextUnderline->setPriority(QAction::LowPriority);
    QFont underline;
    underline.setUnderline(true);
    actionTextUnderline->setFont(underline);
    connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline()));
    tb->addAction(actionTextUnderline);
    menu->addAction(actionTextUnderline);
    actionTextUnderline->setCheckable(true);

    menu->addSeparator();

    QActionGroup *grp = new QActionGroup(this);
    connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(textAlign(QAction*)));

    // Make sure the alignLeft  is always left of the alignRight
    if (QApplication::isLeftToRight()) {
        actionAlignLeft = new QAction(QIcon::fromTheme("format-justify-left", QIcon(rsrcPath + "/textleft.png")),
                                      tr("&Left"), grp);
        actionAlignCenter = new QAction(QIcon::fromTheme("format-justify-center", QIcon(rsrcPath + "/textcenter.png")), tr("C&enter"), grp);
        actionAlignRight = new QAction(QIcon::fromTheme("format-justify-right", QIcon(rsrcPath + "/textright.png")), tr("&Right"), grp);
    } else {
        actionAlignRight = new QAction(QIcon::fromTheme("format-justify-right", QIcon(rsrcPath + "/textright.png")), tr("&Right"), grp);
        actionAlignCenter = new QAction(QIcon::fromTheme("format-justify-center", QIcon(rsrcPath + "/textcenter.png")), tr("C&enter"), grp);
        actionAlignLeft = new QAction(QIcon::fromTheme("format-justify-left", QIcon(rsrcPath + "/textleft.png")), tr("&Left"), grp);
    }
    actionAlignJustify = new QAction(QIcon::fromTheme("format-justify-fill", QIcon(rsrcPath + "/textjustify.png")), tr("&Justify"), grp);

    actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L);
    actionAlignLeft->setCheckable(true);
    actionAlignLeft->setPriority(QAction::LowPriority);
    actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E);
    actionAlignCenter->setCheckable(true);
    actionAlignCenter->setPriority(QAction::LowPriority);
    actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R);
    actionAlignRight->setCheckable(true);
    actionAlignRight->setPriority(QAction::LowPriority);
    actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J);
    actionAlignJustify->setCheckable(true);
    actionAlignJustify->setPriority(QAction::LowPriority);

    tb->addActions(grp->actions());
    menu->addActions(grp->actions());

    menu->addSeparator();

    QPixmap pix(16, 16);
    pix.fill(Qt::black);
    actionTextColor = new QAction(pix, tr("&Color..."), this);
    connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor()));
    tb->addAction(actionTextColor);
    menu->addAction(actionTextColor);


    tb = new QToolBar(this);
    tb->setAllowedAreas(Qt::TopToolBarArea | Qt::BottomToolBarArea);
    tb->setWindowTitle(tr("Format Actions"));
    addToolBarBreak(Qt::TopToolBarArea);
    addToolBar(tb);

    comboStyle = new QComboBox(tb);
    tb->addWidget(comboStyle);
    comboStyle->addItem("Standard");
    comboStyle->addItem("Bullet List (Disc)");
    comboStyle->addItem("Bullet List (Circle)");
    comboStyle->addItem("Bullet List (Square)");
    comboStyle->addItem("Ordered List (Decimal)");
    comboStyle->addItem("Ordered List (Alpha lower)");
    comboStyle->addItem("Ordered List (Alpha upper)");
    comboStyle->addItem("Ordered List (Roman lower)");
    comboStyle->addItem("Ordered List (Roman upper)");
    connect(comboStyle, SIGNAL(activated(int)),
            this, SLOT(textStyle(int)));

    comboFont = new QFontComboBox(tb);
    tb->addWidget(comboFont);
    connect(comboFont, SIGNAL(activated(QString)),
            this, SLOT(textFamily(QString)));

    comboSize = new QComboBox(tb);
    comboSize->setObjectName("comboSize");
    tb->addWidget(comboSize);
    comboSize->setEditable(true);

    QFontDatabase db;
    foreach(int size, db.standardSizes())
        comboSize->addItem(QString::number(size));

    connect(comboSize, SIGNAL(activated(QString)),
            this, SLOT(textSize(QString)));
    comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font()
                                                                   .pointSize())));
}
예제 #5
0
ArrangerView::ArrangerView(QWidget* parent)
   : TopWin(TopWin::ARRANGER, parent, "arrangerview", Qt::Window)
{
  setWindowTitle(tr("MusE: Arranger"));
  setFocusPolicy(Qt::NoFocus);  

  arranger = new Arranger(this, "arranger");
  setCentralWidget(arranger);
  //setFocusProxy(arranger);

  scoreOneStaffPerTrackMapper = new QSignalMapper(this);
  scoreAllInOneMapper = new QSignalMapper(this);

  editSignalMapper = new QSignalMapper(this);

  // Toolbars ---------------------------------------------------------
  editTools = new EditToolBar(this, arrangerTools);
  addToolBar(editTools);
  editTools->setObjectName("arrangerTools");

  visTracks = new VisibleTracks(this);
  addToolBar(visTracks);



  connect(editTools, SIGNAL(toolChanged(int)), arranger, SLOT(setTool(int)));
  connect(visTracks, SIGNAL(visibilityChanged()), MusEGlobal::song, SLOT(update()) );
  connect(arranger, SIGNAL(editPart(MusECore::Track*)), MusEGlobal::muse, SLOT(startEditor(MusECore::Track*)));
  connect(arranger, SIGNAL(dropSongFile(const QString&)), MusEGlobal::muse, SLOT(loadProjectFile(const QString&)));
  connect(arranger, SIGNAL(dropMidiFile(const QString&)), MusEGlobal::muse, SLOT(importMidi(const QString&)));
  connect(arranger, SIGNAL(startEditor(MusECore::PartList*,int)),  MusEGlobal::muse, SLOT(startEditor(MusECore::PartList*,int)));
  connect(arranger, SIGNAL(toolChanged(int)), editTools, SLOT(set(int)));
  connect(MusEGlobal::muse, SIGNAL(configChanged()), arranger, SLOT(configChanged()));
  connect(arranger, SIGNAL(setUsedTool(int)), editTools, SLOT(set(int)));
  connect(arranger, SIGNAL(selectionChanged()), SLOT(selectionChanged()));
  connect(MusEGlobal::song, SIGNAL(songChanged(MusECore::SongChangedFlags_t)), this, SLOT(songChanged(MusECore::SongChangedFlags_t)));






  //-------- Edit Actions
  editDeleteAction = new QAction(QIcon(*deleteIcon), tr("D&elete"), this);
  editCutAction = new QAction(QIcon(*editcutIconSet), tr("C&ut"), this);
  editCopyAction = new QAction(QIcon(*editcopyIconSet), tr("&Copy"), this);
  editCopyRangeAction = new QAction(QIcon(*editcopyIconSet), tr("Copy in range"), this);
  editPasteAction = new QAction(QIcon(*editpasteIconSet), tr("&Paste"), this);
  editPasteCloneAction = new QAction(QIcon(*editpasteCloneIconSet), tr("Paste c&lone"), this);
  editPasteToTrackAction = new QAction(QIcon(*editpaste2TrackIconSet), tr("Paste to selected &track"), this);
  editPasteCloneToTrackAction = new QAction(QIcon(*editpasteClone2TrackIconSet), tr("Paste clone to selected trac&k"), this);
  editPasteDialogAction = new QAction(QIcon(*editpasteIconSet), tr("Paste (show dialo&g)"), this);
  editInsertEMAction = new QAction(QIcon(*editpasteIconSet), tr("&Insert Empty Measure"), this);
  editDeleteSelectedAction = new QAction(QIcon(*edit_track_delIcon), tr("Delete Selected Tracks"), this);
  editDuplicateSelTrackAction = new QAction(QIcon(*edit_track_addIcon), tr("Duplicate Selected Tracks"), this);

  editShrinkPartsAction = new QAction(tr("Shrink selected parts"), this);
  editExpandPartsAction = new QAction(tr("Expand selected parts"), this);
  editCleanPartsAction = new QAction(tr("Purge hidden events from selected parts"), this);


  addTrack = new QMenu(tr("Add Track"), this);
  addTrack->setIcon(QIcon(*edit_track_addIcon));
  select = new QMenu(tr("Select"), this);
  select->setIcon(QIcon(*selectIcon));

  editSelectAllAction = new QAction(QIcon(*select_allIcon), tr("Select &All"), this);
  editDeselectAllAction = new QAction(QIcon(*select_deselect_allIcon), tr("&Deselect All"), this);
  editInvertSelectionAction = new QAction(QIcon(*select_invert_selectionIcon), tr("Invert &Selection"), this);
  editInsideLoopAction = new QAction(QIcon(*select_inside_loopIcon), tr("&Inside Loop"), this);
  editOutsideLoopAction = new QAction(QIcon(*select_outside_loopIcon), tr("&Outside Loop"), this);
  editAllPartsAction = new QAction( QIcon(*select_all_parts_on_trackIcon), tr("All &Parts on Track"), this);

	
  scoreSubmenu = new QMenu(tr("Score"), this);
  scoreSubmenu->setIcon(QIcon(*scoreIconSet));

  scoreAllInOneSubsubmenu = new QMenu(tr("all tracks in one staff"), this);
  scoreOneStaffPerTrackSubsubmenu = new QMenu(tr("one staff per track"), this);

  scoreSubmenu->addMenu(scoreAllInOneSubsubmenu);
  scoreSubmenu->addMenu(scoreOneStaffPerTrackSubsubmenu);
  updateScoreMenus();

  startScoreEditAction = new QAction(*scoreIconSet, tr("New score window"), this);
  startPianoEditAction = new QAction(*pianoIconSet, tr("Pianoroll"), this);
  startDrumEditAction = new QAction(QIcon(*edit_drummsIcon), tr("Drums"), this);
  startListEditAction = new QAction(QIcon(*edit_listIcon), tr("List"), this);
  startWaveEditAction = new QAction(QIcon(*edit_waveIcon), tr("Wave"), this);

  master = new QMenu(tr("Mastertrack"), this);
  master->setIcon(QIcon(*edit_mastertrackIcon));
  masterGraphicAction = new QAction(QIcon(*mastertrack_graphicIcon),tr("Graphic"), this);
  masterListAction = new QAction(QIcon(*mastertrack_listIcon),tr("List"), this);

  midiTransformerAction = new QAction(QIcon(*midi_transformIcon), tr("Midi &Transform"), this);


  //-------- Structure Actions
  strGlobalCutAction = new QAction(tr("Global Cut"), this);
  strGlobalInsertAction = new QAction(tr("Global Insert"), this);
  strGlobalSplitAction = new QAction(tr("Global Split"), this);

  strGlobalCutSelAction = new QAction(tr("Global Cut - selected tracks"), this);
  strGlobalInsertSelAction = new QAction(tr("Global Insert - selected tracks"), this);
  strGlobalSplitSelAction = new QAction(tr("Global Split - selected tracks"), this);



  //-------------------------------------------------------------
  //    popup Edit
  //-------------------------------------------------------------

  QMenu* menuEdit = menuBar()->addMenu(tr("&Edit"));
  menuEdit->addActions(MusEGlobal::undoRedo->actions());
  menuEdit->addSeparator();

  menuEdit->addAction(editDeleteAction);
  menuEdit->addAction(editCutAction);
  menuEdit->addAction(editCopyAction);
  menuEdit->addAction(editCopyRangeAction);
  menuEdit->addAction(editPasteAction);
  menuEdit->addAction(editPasteToTrackAction);
  menuEdit->addAction(editPasteCloneAction);
  menuEdit->addAction(editPasteCloneToTrackAction);
  menuEdit->addAction(editPasteDialogAction);
  menuEdit->addAction(editInsertEMAction);
  menuEdit->addSeparator();
  menuEdit->addAction(editShrinkPartsAction);
  menuEdit->addAction(editExpandPartsAction);
  menuEdit->addAction(editCleanPartsAction);
  menuEdit->addSeparator();
  menuEdit->addAction(editDeleteSelectedAction);

  menuEdit->addMenu(addTrack);
  menuEdit->addAction(editDuplicateSelTrackAction);
  menuEdit->addMenu(select);
    select->addAction(editSelectAllAction);
    select->addAction(editDeselectAllAction);
    select->addAction(editInvertSelectionAction);
    select->addAction(editInsideLoopAction);
    select->addAction(editOutsideLoopAction);
    select->addAction(editAllPartsAction);
  menuEdit->addSeparator();

  menuEdit->addAction(startPianoEditAction);
  menuEdit->addMenu(scoreSubmenu);
  menuEdit->addAction(startScoreEditAction);
  menuEdit->addAction(startDrumEditAction);
  menuEdit->addAction(startListEditAction);
  menuEdit->addAction(startWaveEditAction);

  menuEdit->addMenu(master);
    master->addAction(masterGraphicAction);
    master->addAction(masterListAction);
  menuEdit->addSeparator();

  menuEdit->addAction(midiTransformerAction);

  QMenu* menuStructure = menuEdit->addMenu(tr("&Structure"));
    menuStructure->addAction(strGlobalCutAction);
    menuStructure->addAction(strGlobalInsertAction);
    menuStructure->addAction(strGlobalSplitAction);
    menuStructure->addSeparator();
    menuStructure->addAction(strGlobalCutSelAction);
    menuStructure->addAction(strGlobalInsertSelAction);
    menuStructure->addAction(strGlobalSplitSelAction);

  
  
  QMenu* functions_menu = menuBar()->addMenu(tr("Functions"));
		QAction* func_quantize_action = functions_menu->addAction(tr("&Quantize Notes"), editSignalMapper, SLOT(map()));
		QAction* func_notelen_action = functions_menu->addAction(tr("Change note &length"), editSignalMapper, SLOT(map()));
		QAction* func_velocity_action = functions_menu->addAction(tr("Change note &velocity"), editSignalMapper, SLOT(map()));
		QAction* func_cresc_action = functions_menu->addAction(tr("Crescendo/Decrescendo"), editSignalMapper, SLOT(map()));
		QAction* func_transpose_action = functions_menu->addAction(tr("Transpose"), editSignalMapper, SLOT(map()));
		QAction* func_erase_action = functions_menu->addAction(tr("Erase Events (Not Parts)"), editSignalMapper, SLOT(map()));
		QAction* func_move_action = functions_menu->addAction(tr("Move Events (Not Parts)"), editSignalMapper, SLOT(map()));
		QAction* func_fixed_len_action = functions_menu->addAction(tr("Set Fixed Note Length"), editSignalMapper, SLOT(map()));
		QAction* func_del_overlaps_action = functions_menu->addAction(tr("Delete Overlapping Notes"), editSignalMapper, SLOT(map()));
		QAction* func_legato_action = functions_menu->addAction(tr("Legato"), editSignalMapper, SLOT(map()));
		editSignalMapper->setMapping(func_quantize_action, CMD_QUANTIZE);
		editSignalMapper->setMapping(func_notelen_action, CMD_NOTELEN);
		editSignalMapper->setMapping(func_velocity_action, CMD_VELOCITY);
		editSignalMapper->setMapping(func_cresc_action, CMD_CRESCENDO);
		editSignalMapper->setMapping(func_transpose_action, CMD_TRANSPOSE);
		editSignalMapper->setMapping(func_erase_action, CMD_ERASE);
		editSignalMapper->setMapping(func_move_action, CMD_MOVE);
		editSignalMapper->setMapping(func_fixed_len_action, CMD_FIXED_LEN);
		editSignalMapper->setMapping(func_del_overlaps_action, CMD_DELETE_OVERLAPS);
		editSignalMapper->setMapping(func_legato_action, CMD_LEGATO);

  
  
  QMenu* menuSettings = menuBar()->addMenu(tr("Window &Config"));
  menuSettings->addAction(tr("Configure &custom columns"), this, SLOT(configCustomColumns()));
  menuSettings->addSeparator();
  menuSettings->addAction(subwinAction);
  menuSettings->addAction(shareAction);
  menuSettings->addAction(fullscreenAction);


  //-------- Edit connections
  connect(editDeleteAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editCutAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editCopyAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editCopyRangeAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editPasteAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editPasteCloneAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editPasteToTrackAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editPasteCloneToTrackAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editPasteDialogAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editInsertEMAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editDeleteSelectedAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editDuplicateSelTrackAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));

  connect(editShrinkPartsAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editExpandPartsAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editCleanPartsAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));

  connect(editSelectAllAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editDeselectAllAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editInvertSelectionAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editInsideLoopAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editOutsideLoopAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
  connect(editAllPartsAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));

  editSignalMapper->setMapping(editDeleteAction, CMD_DELETE);
  editSignalMapper->setMapping(editCutAction, CMD_CUT);
  editSignalMapper->setMapping(editCopyAction, CMD_COPY);
  editSignalMapper->setMapping(editCopyRangeAction, CMD_COPY_RANGE);
  editSignalMapper->setMapping(editPasteAction, CMD_PASTE);
  editSignalMapper->setMapping(editPasteCloneAction, CMD_PASTE_CLONE);
  editSignalMapper->setMapping(editPasteToTrackAction, CMD_PASTE_TO_TRACK);
  editSignalMapper->setMapping(editPasteCloneToTrackAction, CMD_PASTE_CLONE_TO_TRACK);
  editSignalMapper->setMapping(editPasteDialogAction, CMD_PASTE_DIALOG);
  editSignalMapper->setMapping(editInsertEMAction, CMD_INSERTMEAS);
  editSignalMapper->setMapping(editDeleteSelectedAction, CMD_DELETE_TRACK);
  editSignalMapper->setMapping(editDuplicateSelTrackAction, CMD_DUPLICATE_TRACK);
  editSignalMapper->setMapping(editShrinkPartsAction, CMD_SHRINK_PART);
  editSignalMapper->setMapping(editExpandPartsAction, CMD_EXPAND_PART);
  editSignalMapper->setMapping(editCleanPartsAction, CMD_CLEAN_PART);
  editSignalMapper->setMapping(editSelectAllAction, CMD_SELECT_ALL);
  editSignalMapper->setMapping(editDeselectAllAction, CMD_SELECT_NONE);
  editSignalMapper->setMapping(editInvertSelectionAction, CMD_SELECT_INVERT);
  editSignalMapper->setMapping(editInsideLoopAction, CMD_SELECT_ILOOP);
  editSignalMapper->setMapping(editOutsideLoopAction, CMD_SELECT_OLOOP);
  editSignalMapper->setMapping(editAllPartsAction, CMD_SELECT_PARTS);

  connect(editSignalMapper, SIGNAL(mapped(int)), this, SLOT(cmd(int)));

  connect(startPianoEditAction, SIGNAL(triggered()), MusEGlobal::muse, SLOT(startPianoroll()));
  connect(startScoreEditAction, SIGNAL(triggered()), MusEGlobal::muse, SLOT(startScoreQuickly()));
  connect(startDrumEditAction, SIGNAL(triggered()), MusEGlobal::muse, SLOT(startDrumEditor()));
  connect(startListEditAction, SIGNAL(triggered()), MusEGlobal::muse, SLOT(startListEditor()));
  connect(startWaveEditAction, SIGNAL(triggered()), MusEGlobal::muse, SLOT(startWaveEditor()));
  connect(scoreOneStaffPerTrackMapper, SIGNAL(mapped(QWidget*)), MusEGlobal::muse, SLOT(openInScoreEdit_oneStaffPerTrack(QWidget*)));
  connect(scoreAllInOneMapper, SIGNAL(mapped(QWidget*)), MusEGlobal::muse, SLOT(openInScoreEdit_allInOne(QWidget*)));


  connect(masterGraphicAction, SIGNAL(triggered()), MusEGlobal::muse, SLOT(startMasterEditor()));
  connect(masterListAction, SIGNAL(triggered()), MusEGlobal::muse, SLOT(startLMasterEditor()));

  connect(midiTransformerAction, SIGNAL(triggered()), MusEGlobal::muse, SLOT(startMidiTransformer()));


  //-------- Structure connections
  connect(strGlobalCutAction, SIGNAL(triggered()), SLOT(globalCut()));
  connect(strGlobalInsertAction, SIGNAL(triggered()), SLOT(globalInsert()));
  connect(strGlobalSplitAction, SIGNAL(triggered()), SLOT(globalSplit()));
  connect(strGlobalCutSelAction, SIGNAL(triggered()), SLOT(globalCutSel()));
  connect(strGlobalInsertSelAction, SIGNAL(triggered()), SLOT(globalInsertSel()));
  connect(strGlobalSplitSelAction, SIGNAL(triggered()), SLOT(globalSplitSel()));



  connect(MusEGlobal::muse, SIGNAL(configChanged()), SLOT(updateShortcuts()));


  QClipboard* cb = QApplication::clipboard();
  connect(cb, SIGNAL(dataChanged()), SLOT(clipboardChanged()));
  connect(cb, SIGNAL(selectionChanged()), SLOT(clipboardChanged()));

  finalizeInit();

  // work around for probable QT/WM interaction bug.
  // for certain window managers, e.g xfce, this window is
  // is displayed although not specifically set to show();
  // bug: 2811156     Softsynth GUI unclosable with XFCE4 (and a few others)
  // Nov 21, 2012 Hey this causes the thing not to open at all, EVER, on Lubuntu and some others!
  // And we had a request to remove this from a knowledgable tester. REMOVE Tim.
  ///show();
  ///hide();
}
예제 #6
0
game_list_frame::game_list_frame(std::shared_ptr<gui_settings> settings, Render_Creator r_Creator, QWidget *parent) 
	: QDockWidget(tr("Game List"), parent), xgui_settings(settings), m_Render_Creator(r_Creator)
{
	m_isListLayout = xgui_settings->GetValue(GUI::gl_listMode).toBool();
	m_Icon_Size_Str = xgui_settings->GetValue(GUI::gl_iconSize).toString();
	m_Margin_Factor = xgui_settings->GetValue(GUI::gl_marginFactor).toReal();
	m_Text_Factor = xgui_settings->GetValue(GUI::gl_textFactor).toReal();
	m_showToolBar = xgui_settings->GetValue(GUI::gl_toolBarVisible).toBool();

	m_oldLayoutIsList = m_isListLayout;

	// get icon size from list
	int icon_size_index = 0;
	for (int i = 0; i < GUI::gl_icon_size.count(); i++)
	{
		if (GUI::gl_icon_size.at(i).first == m_Icon_Size_Str)
		{
			m_Icon_Size = GUI::gl_icon_size.at(i).second;
			icon_size_index = i;
			break;
		}
	}

	// Save factors for first setup
	xgui_settings->SetValue(GUI::gl_marginFactor, m_Margin_Factor);
	xgui_settings->SetValue(GUI::gl_textFactor, m_Text_Factor);
	xgui_settings->SetValue(GUI::gl_toolBarVisible, m_showToolBar);

	m_Game_Dock = new QMainWindow(this);
	m_Game_Dock->setWindowFlags(Qt::Widget);

	// Set up toolbar
	m_Tool_Bar = new QToolBar(m_Game_Dock);
	m_Tool_Bar->setMovable(false);
	m_Tool_Bar->setVisible(m_showToolBar);
	m_Tool_Bar->setContextMenuPolicy(Qt::PreventContextMenu);

	// ToolBar Actions
	m_catActHDD = { new QAction(""), QIcon(":/Icons/hdd_blue.png"), QIcon(":/Icons/hdd_gray.png") };
	m_catActHDD.action->setIcon(xgui_settings->GetValue(GUI::cat_hdd_game).toBool() ? m_catActHDD.colored : m_catActHDD.gray);
	m_catActHDD.action->setToolTip(tr("Show HDD Category"));

	m_catActDisc = { new QAction(""), QIcon(":/Icons/disc_blue.png"), QIcon(":/Icons/disc_gray.png") };
	m_catActDisc.action->setIcon(xgui_settings->GetValue(GUI::cat_disc_game).toBool() ? m_catActDisc.colored : m_catActDisc.gray);
	m_catActDisc.action->setToolTip(tr("Show Disc Category"));

	m_catActHome = { new QAction(""), QIcon(":/Icons/home_blue.png"), QIcon(":/Icons/home_gray.png") };
	m_catActHome.action->setIcon(xgui_settings->GetValue(GUI::cat_home).toBool() ? m_catActHome.colored : m_catActHome.gray);
	m_catActHome.action->setToolTip(tr("Show Home Category"));

	m_catActAudioVideo = { new QAction(""), QIcon(":/Icons/media_blue.png"), QIcon(":/Icons/media_gray.png") };
	m_catActAudioVideo.action->setIcon(xgui_settings->GetValue(GUI::cat_audio_video).toBool() ? m_catActAudioVideo.colored : m_catActAudioVideo.gray);
	m_catActAudioVideo.action->setToolTip(tr("Show Audio/Video Category"));

	m_catActGameData = { new QAction(""), QIcon(":/Icons/data_blue.png"), QIcon(":/Icons/data_gray.png") };
	m_catActGameData.action->setIcon(xgui_settings->GetValue(GUI::cat_game_data).toBool() ? m_catActGameData.colored : m_catActGameData.gray);
	m_catActGameData.action->setToolTip(tr("Show GameData Category"));

	m_catActUnknown = { new QAction(""), QIcon(":/Icons/unknown_blue.png"), QIcon(":/Icons/unknown_gray.png") };
	m_catActUnknown.action->setIcon(xgui_settings->GetValue(GUI::cat_unknown).toBool() ? m_catActUnknown.colored : m_catActUnknown.gray);
	m_catActUnknown.action->setToolTip(tr("Show Unknown Category"));

	m_categoryButtons = { m_catActHDD , m_catActDisc, m_catActHome, m_catActAudioVideo, m_catActGameData, m_catActUnknown };

	m_categoryActs = new QActionGroup(m_Tool_Bar);
	m_categoryActs->addAction(m_catActHDD.action);
	m_categoryActs->addAction(m_catActDisc.action);
	m_categoryActs->addAction(m_catActHome.action);
	m_categoryActs->addAction(m_catActAudioVideo.action);
	m_categoryActs->addAction(m_catActGameData.action);
	m_categoryActs->addAction(m_catActUnknown.action);
	m_categoryActs->setEnabled(m_isListLayout);

	m_modeActList = { new QAction(""), QIcon(":/Icons/list_blue.png"), QIcon(":/Icons/list_gray.png") };
	m_modeActList.action->setIcon(m_isListLayout ? m_modeActList.colored : m_modeActList.gray);
	m_modeActList.action->setToolTip(tr("Enable List Mode"));

	m_modeActGrid = { new QAction(""), QIcon(":/Icons/grid_blue.png"), QIcon(":/Icons/grid_gray.png") };
	m_modeActGrid.action->setIcon(m_isListLayout ? m_modeActGrid.gray : m_modeActGrid.colored);
	m_modeActGrid.action->setToolTip(tr("Enable Grid Mode"));

	m_modeActs = new QActionGroup(m_Tool_Bar);
	m_modeActs->addAction(m_modeActList.action);
	m_modeActs->addAction(m_modeActGrid.action);

	// Search Bar
	m_Search_Bar = new QLineEdit(m_Tool_Bar);
	m_Search_Bar->setPlaceholderText(tr("Search games ..."));
	connect(m_Search_Bar, &QLineEdit::textChanged, [this]() {
		Refresh();
	});

	// Icon Size Slider
	m_Slider_Size = new QSlider(Qt::Horizontal , m_Tool_Bar);
	m_Slider_Size->setRange(0, GUI::gl_icon_size.size() - 1);
	m_Slider_Size->setSliderPosition(icon_size_index);
	m_Slider_Size->setFixedWidth(100);

	m_Tool_Bar->addWidget(m_Search_Bar);
	m_Tool_Bar->addWidget(new QLabel("       "));
	m_Tool_Bar->addSeparator();
	m_Tool_Bar->addWidget(new QLabel("       "));
	m_Tool_Bar->addActions(m_categoryActs->actions());
	m_Tool_Bar->addWidget(new QLabel("       "));
	m_Tool_Bar->addSeparator();
	m_Tool_Bar->addWidget(new QLabel(tr("       View Mode  ")));
	m_Tool_Bar->addAction(m_modeActList.action);
	m_Tool_Bar->addAction(m_modeActGrid.action);
	m_Tool_Bar->addWidget(new QLabel(tr("       ")));
	m_Tool_Bar->addSeparator();
	m_Tool_Bar->addWidget(new QLabel(tr("       Tiny  "))); // Can this be any easier?
	m_Tool_Bar->addWidget(m_Slider_Size);
	m_Tool_Bar->addWidget(new QLabel(tr("  Large       ")));

	m_Game_Dock->addToolBar(m_Tool_Bar);
	setWidget(m_Game_Dock);

	bool showText = (m_Icon_Size_Str != GUI::gl_icon_key_small && m_Icon_Size_Str != GUI::gl_icon_key_tiny);
	m_xgrid = new game_list_grid(m_Icon_Size, m_Margin_Factor, m_Text_Factor, showText);

	gameList = new QTableWidget();
	gameList->setShowGrid(false);
	gameList->setItemDelegate(new table_item_delegate(this));
	gameList->setSelectionBehavior(QAbstractItemView::SelectRows);
	gameList->setSelectionMode(QAbstractItemView::SingleSelection);
	gameList->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
	gameList->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed);	
	gameList->verticalHeader()->setMinimumSectionSize(m_Icon_Size.height());
	gameList->verticalHeader()->setMaximumSectionSize(m_Icon_Size.height());
	gameList->verticalHeader()->setVisible(false);
	gameList->horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu);
	gameList->setContextMenuPolicy(Qt::CustomContextMenu);

	gameList->setColumnCount(7);
	gameList->setHorizontalHeaderItem(0, new QTableWidgetItem(tr("Icon")));
	gameList->setHorizontalHeaderItem(1, new QTableWidgetItem(tr("Name")));
	gameList->setHorizontalHeaderItem(2, new QTableWidgetItem(tr("Serial")));
	gameList->setHorizontalHeaderItem(3, new QTableWidgetItem(tr("FW")));
	gameList->setHorizontalHeaderItem(4, new QTableWidgetItem(tr("App version")));
	gameList->setHorizontalHeaderItem(5, new QTableWidgetItem(tr("Category")));
	gameList->setHorizontalHeaderItem(6, new QTableWidgetItem(tr("Path")));

	m_Central_Widget = new QStackedWidget(this);
	m_Central_Widget->addWidget(gameList);
	m_Central_Widget->addWidget(m_xgrid);
	m_Central_Widget->setCurrentWidget(m_isListLayout ? gameList : m_xgrid);

	m_Game_Dock->setCentralWidget(m_Central_Widget);

	// Actions
	showIconColAct = new QAction(tr("Show Icons"), this);
	showNameColAct = new QAction(tr("Show Names"), this);
	showSerialColAct = new QAction(tr("Show Serials"), this);
	showFWColAct = new QAction(tr("Show FWs"), this);
	showAppVersionColAct = new QAction(tr("Show App Versions"), this);
	showCategoryColAct = new QAction(tr("Show Categories"), this);
	showPathColAct = new QAction(tr("Show Paths"), this);

	columnActs = { showIconColAct, showNameColAct, showSerialColAct, showFWColAct, showAppVersionColAct, showCategoryColAct, showPathColAct };

	// Events
	connect(gameList, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu);
	connect(gameList->horizontalHeader(), &QHeaderView::customContextMenuRequested, [=](const QPoint& pos) {
		QMenu* configure = new QMenu(this);
		configure->addActions({ showIconColAct, showNameColAct, showSerialColAct, showFWColAct, showAppVersionColAct, showCategoryColAct, showPathColAct });
		configure->exec(mapToGlobal(pos));
	});
	connect(gameList, &QTableWidget::doubleClicked, this, &game_list_frame::doubleClickedSlot);
	connect(gameList->horizontalHeader(), &QHeaderView::sectionClicked, this, &game_list_frame::OnColClicked);

	connect(m_xgrid, &QTableWidget::doubleClicked, this, &game_list_frame::doubleClickedSlot);
	connect(m_xgrid, &QTableWidget::customContextMenuRequested, this, &game_list_frame::ShowContextMenu);

	connect(m_Slider_Size, &QSlider::valueChanged, [=](int value) { emit RequestIconSizeActSet(value); });

	connect(m_modeActs, &QActionGroup::triggered, [=](QAction* act) {
		emit RequestListModeActSet(act == m_modeActList.action);
		m_modeActList.action->setIcon(m_isListLayout ? m_modeActList.colored : m_modeActList.gray);
		m_modeActGrid.action->setIcon(m_isListLayout ? m_modeActGrid.gray : m_modeActGrid.colored);
	});

	connect(m_categoryActs, &QActionGroup::triggered, [=](QAction* act) {
		emit RequestCategoryActSet(m_categoryActs->actions().indexOf(act));
	});

	for (int col = 0; col < columnActs.count(); ++col)
	{
		columnActs[col]->setCheckable(true);

		auto l_CallBack = [this, col](bool val) {
			if (!val) // be sure to have at least one column left so you can call the context menu at all time
			{
				int c = 0;
				for (int i = 0; i < columnActs.count(); ++i)
				{
					if (xgui_settings->GetGamelistColVisibility(i)) { if (++c > 1) { break; } }
				}
				if (c < 2)
				{
					columnActs[col]->setChecked(true); // re-enable the checkbox if we don't change the actual state
					return;
				}
			}
			gameList->setColumnHidden(col, !val); // Negate because it's a set col hidden and we have menu say show.
			xgui_settings->SetGamelistColVisibility(col, val);
		};
		columnActs[col]->setChecked(xgui_settings->GetGamelistColVisibility(col));
		connect(columnActs[col], &QAction::triggered, l_CallBack);
	}

	// Init
	LoadSettings();
}
예제 #7
0
파일: log_frame.cpp 프로젝트: DHrpcs3/rpcs3
void log_frame::CreateAndConnectActions()
{
	// I, for one, welcome our lambda overlord
	// It's either this or a signal mapper
	// Then, probably making a list of these actions so that it's easier to iterate to generate the mapper.
	auto l_initAct = [this](QAction* act, logs::level logLevel)
	{
		act->setCheckable(true);

		// This sets the log level properly when the action is triggered.
		connect(act, &QAction::triggered, [this, logLevel]()
		{
			s_gui_listener.enabled = std::max(logLevel, logs::level::fatal);
			xgui_settings->SetValue(gui::l_level, static_cast<uint>(logLevel));
		});
	};

	m_clearAct = new QAction(tr("Clear"), this);
	connect(m_clearAct, &QAction::triggered, m_log, &QTextEdit::clear);

	m_clearTTYAct = new QAction(tr("Clear"), this);
	connect(m_clearTTYAct, &QAction::triggered, m_tty, &QTextEdit::clear);

	// Action groups make these actions mutually exclusive.
	m_logLevels = new QActionGroup(this);
	m_nothingAct = new QAction(tr("Nothing"), m_logLevels);
	m_nothingAct->setVisible(false);
	m_fatalAct = new QAction(tr("Fatal"), m_logLevels);
	m_errorAct = new QAction(tr("Error"), m_logLevels);
	m_todoAct = new QAction(tr("Todo"), m_logLevels);
	m_successAct = new QAction(tr("Success"), m_logLevels);
	m_warningAct = new QAction(tr("Warning"), m_logLevels);
	m_noticeAct = new QAction(tr("Notice"), m_logLevels);
	m_traceAct = new QAction(tr("Trace"), m_logLevels);

	m_stackAct = new QAction(tr("Stack Mode"), this);
	m_stackAct->setCheckable(true);
	connect(m_stackAct, &QAction::toggled, xgui_settings.get(), [=](bool checked)
	{
		xgui_settings->SetValue(gui::l_stack, checked);
		m_stack_log = checked;
	});

	m_TTYAct = new QAction(tr("TTY"), this);
	m_TTYAct->setCheckable(true);
	connect(m_TTYAct, &QAction::triggered, xgui_settings.get(), [=](bool checked)
	{
		xgui_settings->SetValue(gui::l_tty, checked);
	});

	l_initAct(m_nothingAct, logs::level::fatal);
	l_initAct(m_fatalAct, logs::level::fatal);
	l_initAct(m_errorAct, logs::level::error);
	l_initAct(m_todoAct, logs::level::todo);
	l_initAct(m_successAct, logs::level::success);
	l_initAct(m_warningAct, logs::level::warning);
	l_initAct(m_noticeAct, logs::level::notice);
	l_initAct(m_traceAct, logs::level::trace);

	connect(m_log, &QWidget::customContextMenuRequested, [=](const QPoint& pos)
	{
		QMenu* menu = m_log->createStandardContextMenu();
		menu->addAction(m_clearAct);
		menu->addSeparator();
		menu->addActions({ m_nothingAct, m_fatalAct, m_errorAct, m_todoAct, m_successAct, m_warningAct, m_noticeAct, m_traceAct });
		menu->addSeparator();
		menu->addAction(m_stackAct);
		menu->addSeparator();
		menu->addAction(m_TTYAct);
		menu->exec(mapToGlobal(pos));
	});

	connect(m_tty, &QWidget::customContextMenuRequested, [=](const QPoint& pos)
	{
		QMenu* menu = m_tty->createStandardContextMenu();
		menu->addAction(m_clearTTYAct);
		menu->exec(mapToGlobal(pos));
	});

	connect(m_tabWidget, &QTabWidget::currentChanged, [this](int/* index*/)
	{
		if (m_find_dialog)
			m_find_dialog->close();
	});

	LoadSettings();
}
예제 #8
0
void KonqPopupMenuPrivate::populate()
{
    Q_ASSERT(m_popupItemProperties.items().count() >= 1);

    bool bTrashIncluded = false;

    const KFileItemList lstItems = m_popupItemProperties.items();
    KFileItemList::const_iterator it = lstItems.constBegin();
    const KFileItemList::const_iterator kend = lstItems.constEnd();
    for (; it != kend; ++it) {
        const QUrl url = (*it).url();
        if (!bTrashIncluded && ((url.scheme() == QLatin1String("trash") && url.path().length() <= 1))) {
            bTrashIncluded = true;
        }
    }

    const bool isDirectory = m_popupItemProperties.isDirectory();
    const bool sReading = m_popupItemProperties.supportsReading();
    bool sDeleting = (m_popupFlags & KonqPopupMenu::NoDeletion) == 0
                     && m_popupItemProperties.supportsDeleting();
    const bool sWriting = m_popupItemProperties.supportsWriting();
    const bool sMoving = sDeleting && m_popupItemProperties.supportsMoving();

    QUrl url = m_sViewURL.adjusted(QUrl::NormalizePathSegments);

    bool isTrashLink     = false;
    bool isCurrentTrash = false;
    bool currentDir     = false;
    bool isSymLink = false;
    bool isSymLinkInSameDir = false; // true for "ln -s foo bar", false for links to foo/sub or /foo

    //check if url is current directory
    if (lstItems.count() == 1) {
        KFileItem firstPopupItem(lstItems.first());
        if (firstPopupItem.isLink()) {
            isSymLink = true;
            isSymLinkInSameDir = !firstPopupItem.linkDest().contains(QLatin1Char('/'));
        }
        QUrl firstPopupURL(firstPopupItem.url().adjusted(QUrl::NormalizePathSegments));
        //kDebug(1203) << "View path is " << url.url();
        //kDebug(1203) << "First popup path is " << firstPopupURL.url();
        currentDir = (firstPopupURL.matches(url, QUrl::StripTrailingSlash));
        if (firstPopupItem.isDesktopFile()) {
            KDesktopFile desktopFile(firstPopupItem.localPath());
            const KConfigGroup cfg = desktopFile.desktopGroup();
            isTrashLink = cfg.readEntry("Type") == QLatin1String("Link")
                          && cfg.readEntry("URL") == QLatin1String("trash:/");
        }

        if (isTrashLink) {
            sDeleting = false;
        }

        // isCurrentTrash: popup on trash:/ itself, or on the trash.desktop link
        isCurrentTrash = (firstPopupURL.scheme() == QLatin1String("trash") && firstPopupURL.path().length() <= 1)
                         || isTrashLink;
    }

    const bool isIntoTrash = (url.scheme() == QLatin1String("trash")) && !isCurrentTrash; // trashed file, not trash:/ itself

    const bool bIsLink  = (m_popupFlags & KonqPopupMenu::IsLink);

    //kDebug() << "isLocal=" << isLocal << " url=" << url << " isCurrentTrash=" << isCurrentTrash << " isIntoTrash=" << isIntoTrash << " bTrashIncluded=" << bTrashIncluded;

    //////////////////////////////////////////////////////////////////////////

    addGroup(KonqPopupMenu::TopActions); // used e.g. for ShowMenuBar. includes a separator at the end

    QAction *act;

    QAction *actNewWindow = 0;

#if 0 // TODO in the desktop code itself.
    if ((flags & KonqPopupMenu::ShowProperties) && isOnDesktop &&
            !KAuthorized::authorizeKAction("editable_desktop_icons")) {
        flags &= ~KonqPopupMenu::ShowProperties; // remove flag
    }
#endif

    // Either 'newview' is in the actions we're given (probably in the tabhandling group)
    // or we need to insert it ourselves (e.g. for the desktop).
    // In the first case, actNewWindow must remain 0.
    if (((m_popupFlags & KonqPopupMenu::ShowNewWindow) != 0) && sReading) {
        const QString openStr = i18n("&Open");
        actNewWindow = new QAction(m_parentWidget /*for status tips*/);
        m_ownActions.append(actNewWindow);
        actNewWindow->setIcon(QIcon::fromTheme(QStringLiteral("window-new")));
        actNewWindow->setText(openStr);
        QObject::connect(actNewWindow, &QAction::triggered, [this]() {
            slotPopupNewView();
        });
    }

    if (isDirectory && sWriting && !isCurrentTrash) { // A dir, and we can create things into it
        const bool mkdirRequested = m_popupFlags & KonqPopupMenu::ShowCreateDirectory;
        if ((currentDir || mkdirRequested) && m_pMenuNew) { // Current dir -> add the "new" menu
            // As requested by KNewFileMenu :
            m_pMenuNew->checkUpToDate();
            m_pMenuNew->setPopupFiles(m_popupItemProperties.urlList());

            q->addAction(m_pMenuNew);
            q->addSeparator();
        } else if (mkdirRequested) {
            QAction *actNewDir = new QAction(m_parentWidget);
            m_ownActions.append(actNewDir);
            actNewDir->setIcon(QIcon::fromTheme(QStringLiteral("folder-new")));
            actNewDir->setText(i18n("Create &Folder..."));
            QObject::connect(actNewDir, &QAction::triggered, [this]() {
                slotPopupNewDir();
            });
            q->addAction(actNewDir);
            q->addSeparator();
        }
    } else if (isIntoTrash) {
        // Trashed item, offer restoring
        act = new QAction(m_parentWidget /*for status tips*/);
        m_ownActions.append(act);
        act->setText(i18n("&Restore"));
        //PORT QT5 act->setHelpText(i18n("Restores this file or directory, back to the location where it was deleted from initially"));
        QObject::connect(act, &QAction::triggered, [this]() {
            slotPopupRestoreTrashedItems();
        });
        q->addAction(act);
    }

    if (m_popupFlags & KonqPopupMenu::ShowNavigationItems) {
        if (m_popupFlags & KonqPopupMenu::ShowUp) {
            addNamedAction("go_up");
        }
        addNamedAction("go_back");
        addNamedAction("go_forward");
        if (m_popupFlags & KonqPopupMenu::ShowReload) {
            addNamedAction("reload");
        }
        q->addSeparator();
    }

    if (!currentDir && isSymLink && !isSymLinkInSameDir) {
        // #65151: offer to open the target's parent dir
        act = new QAction(m_parentWidget);
        m_ownActions.append(act);
        act->setText(isDirectory ? i18n("Show Original Directory") : i18n("Show Original File"));
        //PORT TO QT5 act->setHelpText(i18n("Opens a new file manager window showing the target of this link, in its parent directory."));
        QObject::connect(act, &QAction::triggered, [this]() {
            slotShowOriginalFile();
        });
        q->addAction(act);
    }

    // "open in new window" is either provided by us, or by the tabhandling group
    if (actNewWindow) {
        q->addAction(actNewWindow);
        q->addSeparator();
    }
    addGroup(KonqPopupMenu::TabHandlingActions);   // includes a separator at the end

    if (m_popupFlags & KonqPopupMenu::ShowUrlOperations) {
        if (!currentDir && sReading) {
            if (sDeleting) {
                addNamedAction("cut");
            }
            addNamedAction("copy");
        }

        if (isDirectory && sWriting) {
            if (currentDir) {
                addNamedAction("paste");
            } else {
                addNamedAction("pasteto");
            }
        }
    }
    if (isCurrentTrash) {
        act = new QAction(m_parentWidget);
        m_ownActions.append(act);
        act->setIcon(QIcon::fromTheme(QStringLiteral("trash-empty")));
        act->setText(i18n("&Empty Trash Bin"));
        KConfig trashConfig(QStringLiteral("trashrc"), KConfig::SimpleConfig);
        act->setEnabled(!trashConfig.group("Status").readEntry("Empty", true));
        QObject::connect(act, &QAction::triggered, [this]() {
            slotPopupEmptyTrashBin();
        });
        q->addAction(act);
    }
    if (isCurrentTrash) {
        act = new QAction(m_parentWidget);
        m_ownActions.append(act);
        act->setIcon(QIcon::fromTheme(QStringLiteral("trash-empty")));
        act->setText(i18n("&Configure Trash Bin"));
        QObject::connect(act, &QAction::triggered, [this]() {
            slotConfigTrashBin();
        });
        q->addAction(act);
    }

    // This is used by KHTML, see khtml_popupmenu.rc (copy, selectAll, searchProvider etc.)
    // and by DolphinPart (rename, trash, delete)
    addGroup(KonqPopupMenu::EditActions);

    if (m_popupFlags & KonqPopupMenu::ShowTextSelectionItems) {
        // OK, we have to stop here.

        // Anything else that is provided by the part
        addGroup(KonqPopupMenu::CustomActions);
        return;
    }

    if (!isCurrentTrash && !isIntoTrash && (m_popupFlags & KonqPopupMenu::ShowBookmark)) {
        QString caption;
        if (currentDir) {
            const bool httpPage = m_sViewURL.scheme().startsWith(QLatin1String("http"), Qt::CaseInsensitive);
            if (httpPage) {
                caption = i18n("&Bookmark This Page");
            } else {
                caption = i18n("&Bookmark This Location");
            }
        } else if (isDirectory) {
            caption = i18n("&Bookmark This Folder");
        } else if (bIsLink) {
            caption = i18n("&Bookmark This Link");
        } else {
            caption = i18n("&Bookmark This File");
        }

        act = new QAction(m_parentWidget);
        m_ownActions.append(act);
        act->setObjectName(QLatin1String("bookmark_add"));   // for unittest
        act->setIcon(QIcon::fromTheme(QStringLiteral("bookmark-new")));
        act->setText(caption);
        QObject::connect(act, &QAction::triggered, [this]() {
            slotPopupAddToBookmark();
        });
        if (lstItems.count() > 1) {
            act->setEnabled(false);
        }
        if (KAuthorized::authorizeKAction(QStringLiteral("bookmarks"))) {
            q->addAction(act);
        }
        if (bIsLink) {
            addGroup(KonqPopupMenu::LinkActions);    // see khtml
        }
    }

    // "Open With" actions

    m_menuActions.setItemListProperties(m_popupItemProperties);

    if (sReading) {
        m_menuActions.addOpenWithActionsTo(q, QStringLiteral("DesktopEntryName != 'kfmclient' and DesktopEntryName != 'kfmclient_dir' and DesktopEntryName != 'kfmclient_html'"));

        QList<QAction *> previewActions = m_actionGroups.value(KonqPopupMenu::PreviewActions);
        if (!previewActions.isEmpty()) {
            if (previewActions.count() == 1) {
                q->addAction(previewActions.first());
            } else {
                QMenu *subMenu = new QMenu(i18n("Preview In"), q);
                subMenu->menuAction()->setObjectName(QLatin1String("preview_submenu"));   // for the unittest
                q->addMenu(subMenu);
                subMenu->addActions(previewActions);
            }
        }
    }

    // Second block, builtin + user
    m_menuActions.addServiceActionsTo(q);

    q->addSeparator();

    // Use the Dolphin setting for showing the "Copy To" and "Move To" actions
    KSharedConfig::Ptr dolphin = KSharedConfig::openConfig(QStringLiteral("dolphinrc"));

    // CopyTo/MoveTo menus
    if (m_popupFlags & KonqPopupMenu::ShowUrlOperations &&
            KConfigGroup(dolphin, "General").readEntry("ShowCopyMoveMenu", false)) {

        m_copyToMenu.setItems(lstItems);
        m_copyToMenu.setReadOnly(sMoving == false);
        m_copyToMenu.addActionsTo(q);
        q->addSeparator();
    }

    if (!isCurrentTrash && !isIntoTrash && sReading &&
            (m_popupFlags & KonqPopupMenu::NoPlugins) == 0) {
        addPlugins(); // now it's time to add plugins
    }

    if ((m_popupFlags & KonqPopupMenu::ShowProperties) && KPropertiesDialog::canDisplay(lstItems)) {
        act = new QAction(m_parentWidget);
        m_ownActions.append(act);
        act->setObjectName(QLatin1String("properties"));   // for unittest
        act->setText(i18n("&Properties"));
        QObject::connect(act, &QAction::triggered, [this]() {
            slotPopupProperties();
        });
        q->addAction(act);
    }

    while (!q->actions().isEmpty() &&
            q->actions().last()->isSeparator()) {
        delete q->actions().last();
    }

    // Anything else that is provided by the part
    addGroup(KonqPopupMenu::CustomActions);

    QObject::connect(&m_menuActions, &KFileItemActions::openWithDialogAboutToBeShown, q, &KonqPopupMenu::openWithDialogAboutToBeShown);
}
예제 #9
0
void ThingRulesView::contextMenuEvent(QContextMenuEvent * e)
{
	Q_UNUSED(e)
	QMenu* popup = new QMenu(this);
	QList<QAction *> actions;
	actions	<<new QAction(QString::fromUtf8("Добавить"), popup)
			<<new QAction(PluginHosts::psiIcon->getIcon("psi/action_templates_edit"), QString::fromUtf8("Редактировать"), popup)
			<<new QAction(PluginHosts::psiIcon->getIcon("psi/remove"), QString::fromUtf8("Удалить"), popup)
			<<new QAction(PluginHosts::psiIcon->getIcon("psi/arrowUp"), QString::fromUtf8("Выше"), popup)
			<<new QAction(PluginHosts::psiIcon->getIcon("psi/arrowDown"), QString::fromUtf8("Ниже"), popup);
	popup->addActions(actions);
	QAction *result = popup->exec(e->globalPos());
	int iresult;
	if (result) {
		iresult = actions.indexOf(result);
		int row = currentIndex().row();
		switch (iresult) {
			case 0: // add
				if (true) {
					struct ThingFilter::thing_rule_ex new_rule;
					new_rule.param = ThingFilter::NoParamRole;
					new_rule.negative = false;
					new_rule.operand = ThingFilter::NoOperRole;
					new_rule.int_value = 0;
					new_rule.value = "";
					new_rule.action = ThingFilter::NoActionRole;
					ThingRuleEditDialog* dlg = new ThingRuleEditDialog(this, &new_rule);
					if (dlg) {
						if (dlg->exec() == QDialog::Accepted) {
							if (thingRulesTableModel->appendRule(new_rule.param, new_rule.negative, new_rule.operand, new_rule.value, new_rule.action)) {
								if (row >= 0 && row < model()->rowCount()) {
									selectionModel()->select(model()->index(row, 0), QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
								}
								selectionModel()->select(model()->index(model()->rowCount() - 1, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
							} else {
								QMessageBox::warning(this, QString::fromUtf8("Добавление правила"), QString::fromUtf8("Произошла ошибка при добавлении правила"), QMessageBox::Ok, QMessageBox::Ok);
							}
						}
						delete dlg;
					}
				}
				break;
			case 1: // edit
				if (row >= 0 && row < model()->rowCount()) {
					struct ThingFilter::thing_rule_ex rule;
					const struct ThingFilter::thing_rule_ex* curr_rule = thingRulesTableModel->getRule(row);
					if (curr_rule) {
						rule = *curr_rule;
						ThingRuleEditDialog* dlg = new ThingRuleEditDialog(this, &rule);
						if (dlg) {
							if (dlg->exec() == QDialog::Accepted) {
								thingRulesTableModel->modifyRule(row, &rule);
							}
							delete dlg;
						}
					}
				}
				break;
			case 2: // delete
				if (row >= 0 && row < model()->rowCount()) {
					if (QMessageBox::question(this, QString::fromUtf8("Удаление правила"), QString::fromUtf8("Вы действительно хотите удалить правило?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
						model()->removeRows(row, 1);
						int cnt = model()->rowCount();
						if (cnt > 0) {
							if (row >= cnt)
								row--;
							selectionModel()->select(model()->index(row, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
						}
					}
				}
				break;
			case 3: // up
				if (row > 0 && row < model()->rowCount()) {
					thingRulesTableModel->upRow(row);
					selectionModel()->select(model()->index(row, 0), QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
					selectionModel()->select(model()->index(row - 1, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
				}
				break;
			case 4: // down
				if (row >= 0 && row < model()->rowCount() - 1) {
					thingRulesTableModel->downRow(row);
					selectionModel()->select(model()->index(row, 0), QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
					selectionModel()->select(model()->index(row + 1, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
				}
				break;
		}
	}
	delete popup;
}
예제 #10
0
void ThingFiltersView::contextMenuEvent( QContextMenuEvent * e )
{
	Q_UNUSED(e)
	QMenu* popup = new QMenu(this);
	QList<QAction *> actions;
	actions	<< new QAction(QString::fromUtf8("Добавить"), popup)
	<< new QAction(PluginHosts::psiIcon->getIcon("psi/action_templates_edit"), QString::fromUtf8("Редактировать"), popup)
	<< new QAction(PluginHosts::psiIcon->getIcon("psi/remove"), QString::fromUtf8("Удалить"), popup)
	<< new QAction(PluginHosts::psiIcon->getIcon("psi/arrowUp"), QString::fromUtf8("Выше"), popup)
	<< new QAction(PluginHosts::psiIcon->getIcon("psi/arrowDown"), QString::fromUtf8("Ниже"), popup);
	popup->addActions(actions);
	QAction *result = popup->exec(e->globalPos());
	int iresult;
	if (result) {
		iresult = actions.indexOf(result);
		int row = currentIndex().row();
//		if (iresult == 2)
//			emit currFilterChanged(0);
		switch (iresult) {
			case 0: // add
				if (true) {
					bool active = true;
					QString name = "";
					ThingFilterEditDialog* dlg = new ThingFilterEditDialog(this, &active, &name);
					if (dlg) {
						if (dlg->exec() == QDialog::Accepted) {
							int new_row = model()->rowCount();
							model()->insertRows(new_row, 1, QModelIndex());
							model()->setData(model()->index(new_row, 0), QVariant(active));
							model()->setData(model()->index(new_row, 1), QVariant(name));
							if (row >= 0 && row < model()->rowCount()) {
								selectionModel()->select(model()->index(row, 0), QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
							}
							selectionModel()->select(model()->index(new_row, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
							emit currRowChanged(model()->index(new_row, 0));
						}
						delete dlg;
					}
					break;
				}
			case 1: // edit
				if (row >= 0 && row < model()->rowCount()) {
					bool active = model()->data(model()->index(row, 0), Qt::UserRole).toBool();
					QString name = model()->data(model()->index(row, 1), Qt::DisplayRole).toString();
					ThingFilterEditDialog* dlg = new ThingFilterEditDialog(this, &active, &name);
					if (dlg) {
						if (dlg->exec() == QDialog::Accepted) {
							model()->setData(model()->index(row, 0), QVariant(active));
							model()->setData(model()->index(row, 1), QVariant(name));
						}
						delete dlg;
					}
				}
				break;
			case 2: // delete
				if (row >= 0 && row < model()->rowCount()) {
					if (QMessageBox::question(this, QString::fromUtf8("Удаление фильтра"), QString::fromUtf8("Вы действительно хотите удалить фильтр?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
						model()->removeRows(row, 1, QModelIndex());
						int cnt = model()->rowCount();
						if (cnt > 0) {
							if (row >= cnt)
								row--;
							selectionModel()->select(model()->index(row, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
							emit currRowChanged(model()->index(row, 0));
						} else {
							emit currRowChanged(QModelIndex()); // Для отчистки строк после удаления последней записи
						}
					}
				}
				break;
			case 3: // up
				if (row > 0 && row < model()->rowCount()) {
					thingFiltersTableModel->swapRows(row - 1, row);
					selectionModel()->select(model()->index(row, 0), QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
					selectionModel()->select(model()->index(row -1, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
					emit currRowChanged(model()->index(row - 1, 0));
				}
				break;
			case 4: // down
				if (row >= 0 && row < model()->rowCount() - 1) {
					thingFiltersTableModel->swapRows(row, row + 1);
					selectionModel()->select(model()->index(row, 0), QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
					selectionModel()->select(model()->index(row + 1, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows);
					emit currRowChanged(model()->index(row + 1, 0));
				}
				break;
		}
	}
	delete popup;
}
예제 #11
0
void CreateBlogMsg::setupTextActions()
{

    QMenu *menu = new QMenu(tr("F&ormat"), this);
    menuBar()->addMenu(menu);
    
    actionTextBold = new QAction(QIcon(":/images/textedit/textbold.png"),tr("&Bold"), this);
    actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B);
    //actionTextBold->setPriority(QAction::LowPriority);
    QFont bold;
    bold.setBold(true);
    actionTextBold->setFont(bold);
    connect(actionTextBold, SIGNAL(triggered()), this, SLOT(textBold()));
    
    ui.toolBar_2->addAction(actionTextBold);
    menu->addAction(actionTextBold);
    actionTextBold->setCheckable(true);

    actionTextItalic = new QAction(QIcon(":/images/textedit/textitalic.png"),tr("&Italic"), this);
    //actionTextItalic->setPriority(QAction::LowPriority);
    actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I);
    QFont italic;
    italic.setItalic(true);
    actionTextItalic->setFont(italic);
    connect(actionTextItalic, SIGNAL(triggered()), this, SLOT(textItalic()));
    
    ui.toolBar_2->addAction(actionTextItalic);
    menu->addAction(actionTextItalic);
    actionTextItalic->setCheckable(true);

    actionTextUnderline = new QAction(QIcon(":/images/textedit/textunder.png"),tr("&Underline"), this);
    actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U);
    //actionTextUnderline->setPriority(QAction::LowPriority);
    QFont underline;
    underline.setUnderline(true);
    actionTextUnderline->setFont(underline);
    connect(actionTextUnderline, SIGNAL(triggered()), this, SLOT(textUnderline()));
    
    ui.toolBar_2->addAction(actionTextUnderline);
    menu->addAction(actionTextUnderline);
    actionTextUnderline->setCheckable(true);

    menu->addSeparator();

    QActionGroup *grp = new QActionGroup(this);
    connect(grp, SIGNAL(triggered(QAction*)), this, SLOT(textAlign(QAction*)));

    // Make sure the alignLeft  is always left of the alignRight
    if (QApplication::isLeftToRight()) {
        actionAlignLeft = new QAction(QIcon(":/images/textedit/textleft.png"),tr("&Left"), grp);
        actionAlignCenter = new QAction(QIcon(":/images/textedit/textcenter.png"), tr("C&enter"), grp);
        actionAlignRight = new QAction(QIcon(":/images/textedit/textright.png"), tr("&Right"), grp);
    } else {
        actionAlignRight = new QAction(QIcon(":/images/textedit/textright.png"), tr("&Right"), grp);
        actionAlignCenter = new QAction(QIcon(":/images/textedit/textcenter.png"), tr("C&enter"), grp);
        actionAlignLeft = new QAction(QIcon(":/images/textedit/textleft.png"), tr("&Left"), grp);
    }
    actionAlignJustify = new QAction(QIcon(":/images/textedit/textjustify.png"), tr("&Justify"), grp);

    actionAlignLeft->setShortcut(Qt::CTRL + Qt::Key_L);
    actionAlignLeft->setCheckable(true);
    //actionAlignLeft->setPriority(QAction::LowPriority);
    actionAlignCenter->setShortcut(Qt::CTRL + Qt::Key_E);
    actionAlignCenter->setCheckable(true);
    //actionAlignCenter->setPriority(QAction::LowPriority);
    actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R);
    actionAlignRight->setCheckable(true);
    //actionAlignRight->setPriority(QAction::LowPriority);
    actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J);
    actionAlignJustify->setCheckable(true);
    //actionAlignJustify->setPriority(QAction::LowPriority);

    ui.toolBar_2->addActions(grp->actions());
    menu->addActions(grp->actions());

    menu->addSeparator();

    QPixmap pix(16, 16);
    pix.fill(Qt::black);
    actionTextColor = new QAction(pix, tr("&Text Color..."), this);
    connect(actionTextColor, SIGNAL(triggered()), this, SLOT(textColor()));
    
    ui.toolBar_2->addAction(actionTextColor);
    menu->addAction(actionTextColor);
    
    menu->addAction(ui.actionOrderedlist);
    menu->addAction(ui.actionUnorderedlist);
    menu->addAction(ui.actionBlockquoute);


    /*comboStyle = new QComboBox(ui.toolBar_2);
    ui.toolBar_2->addWidget(comboStyle);
    comboStyle->addItem("Paragraph");
    comboStyle->addItem("Heading 1");
    comboStyle->addItem("Heading 2");
    comboStyle->addItem("Heading 3");
    comboStyle->addItem("Heading 4");
    comboStyle->addItem("Heading 5");
    comboStyle->addItem("Heading 6");

    connect(comboStyle, SIGNAL(activated(int)),
            this, SLOT(changeFormatType(int)));*/

    comboFont = new QFontComboBox(ui.toolBar_2);
    ui.toolBar_2->addWidget(comboFont);
    connect(comboFont, SIGNAL(activated(QString)),
            this, SLOT(textFamily(QString)));

    comboSize = new QComboBox(ui.toolBar_2);
    comboSize->setObjectName("comboSize");
    ui.toolBar_2->addWidget(comboSize);
    comboSize->setEditable(true);

    QFontDatabase db;
    foreach(int size, db.standardSizes())
        comboSize->addItem(QString::number(size));

    connect(comboSize, SIGNAL(activated(QString)),
            this, SLOT(textSize(QString)));
    comboSize->setCurrentIndex(comboSize->findText(QString::number(QApplication::font()
                                                                   .pointSize())));
}
예제 #12
0
Dialog::Dialog(QWidget *parent) :
    QDialog(parent, Qt::Tool | Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint),
    ui(new Ui::Dialog),
    mSettings(new LxQt::Settings("lxqt-runner", this)),
    mGlobalShortcut(0),
    mLockCascadeChanges(false),
    mConfigureDialog(0)
{
    ui->setupUi(this);
    setWindowTitle("LXQt Runner");
    setAttribute(Qt::WA_TranslucentBackground);

    connect(LxQt::Settings::globalSettings(), SIGNAL(iconThemeChanged()), this, SLOT(update()));
    connect(ui->closeButton, SIGNAL(clicked()), this, SLOT(hide()));
    connect(mSettings, SIGNAL(settingsChanged()), this, SLOT(applySettings()));

    ui->commandEd->installEventFilter(this);

    connect(ui->commandEd, SIGNAL(textChanged(QString)), this, SLOT(setFilter(QString)));
    connect(ui->commandEd, SIGNAL(returnPressed()), this, SLOT(runCommand()));

    mCommandItemModel = new CommandItemModel(this);
    ui->commandList->installEventFilter(this);
    ui->commandList->setModel(mCommandItemModel);
    ui->commandList->setEditTriggers(QAbstractItemView::NoEditTriggers);
    connect(ui->commandList, SIGNAL(clicked(QModelIndex)), this, SLOT(runCommand()));
    setFilter("");
    dataChanged();

    ui->commandList->setItemDelegate(new LxQt::HtmlDelegate(QSize(32, 32), ui->commandList));

    // Popup menu ...............................
    QAction *a = new QAction(XdgIcon::fromTheme("configure"), tr("Configure"), this);
    connect(a, SIGNAL(triggered()), this, SLOT(showConfigDialog()));
    addAction(a);

    a = new QAction(XdgIcon::fromTheme("edit-clear-history"), tr("Clear History"), this);
    connect(a, SIGNAL(triggered()), mCommandItemModel, SLOT(clearHistory()));
    addAction(a);

    mPowerManager = new LxQt::PowerManager(this);
    addActions(mPowerManager->availableActions());
    mScreenSaver = new LxQt::ScreenSaver(this);
    addActions(mScreenSaver->availableActions());

    setContextMenuPolicy(Qt::ActionsContextMenu);

    QMenu *menu = new QMenu(this);
    menu->addActions(actions());
    ui->actionButton->setMenu(menu);
    ui->actionButton->setIcon(XdgIcon::fromTheme("configure"));
    // End of popup menu ........................

    applySettings();

    connect(QApplication::desktop(), SIGNAL(screenCountChanged(int)), SLOT(realign()));
    connect(QApplication::desktop(), SIGNAL(workAreaResized(int)), SLOT(realign()));
    connect(mGlobalShortcut, SIGNAL(activated()), this, SLOT(showHide()));
    connect(mGlobalShortcut, SIGNAL(shortcutChanged(QString,QString)), this, SLOT(shortcutChanged(QString,QString)));

    resize(mSettings->value("dialog/width", 400).toInt(), size().height());


    // TEST
    connect(mCommandItemModel, SIGNAL(layoutChanged()), this, SLOT(dataChanged()));
}
void QmitkExtWorkbenchWindowAdvisor::PostWindowCreate()
{
  // very bad hack...
  berry::IWorkbenchWindow::Pointer window =
      this->GetWindowConfigurer()->GetWindow();
  QMainWindow* mainWindow =
      qobject_cast<QMainWindow*> (window->GetShell()->GetControl());

  if (!windowIcon.isEmpty())
  {
    mainWindow->setWindowIcon(QIcon(windowIcon));
  }
  mainWindow->setContextMenuPolicy(Qt::PreventContextMenu);

  /*mainWindow->setStyleSheet("color: white;"
 "background-color: #808080;"
 "selection-color: #659EC7;"
 "selection-background-color: #808080;"
 " QMenuBar {"
 "background-color: #808080; }");*/

  // Load selected icon theme

  QStringList searchPaths = QIcon::themeSearchPaths();
  searchPaths.push_front( QString(":/org_mitk_icons/icons/") );
  QIcon::setThemeSearchPaths( searchPaths );

  berry::IPreferencesService* prefService = berry::Platform::GetPreferencesService();
  berry::IPreferences::Pointer stylePref = prefService->GetSystemPreferences()->Node(berry::QtPreferences::QT_STYLES_NODE);
  QString iconTheme = stylePref->Get(berry::QtPreferences::QT_ICON_THEME, "<<default>>");
  if( iconTheme == QString( "<<default>>" ) )
  {
    iconTheme = QString( "tango" );
  }
  QIcon::setThemeName( iconTheme );

  // ==== Application menu ============================

    QMenuBar* menuBar = mainWindow->menuBar();
    menuBar->setContextMenuPolicy(Qt::PreventContextMenu);

#ifdef __APPLE__
    menuBar->setNativeMenuBar(true);
#else
    menuBar->setNativeMenuBar(false);
#endif

    QAction* fileOpenAction = new QmitkFileOpenAction(QIcon::fromTheme("document-open",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-open.svg")), window);
    fileOpenAction->setShortcut(QKeySequence::Open);
    QAction* fileSaveAction = new QmitkFileSaveAction(QIcon(":/org.mitk.gui.qt.ext/Save_48.png"), window);
    fileSaveAction->setShortcut(QKeySequence::Save);
    fileSaveProjectAction = new QmitkExtFileSaveProjectAction(window);
    fileSaveProjectAction->setIcon(QIcon::fromTheme("document-save",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/document-save.svg")));
    closeProjectAction = new QmitkCloseProjectAction(window);
    closeProjectAction->setIcon(QIcon::fromTheme("edit-delete",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-delete.svg")));

    auto   perspGroup = new QActionGroup(menuBar);
    std::map<QString, berry::IViewDescriptor::Pointer> VDMap;

    // sort elements (converting vector to map...)
    QList<berry::IViewDescriptor::Pointer>::const_iterator iter;

    berry::IViewRegistry* viewRegistry =
        berry::PlatformUI::GetWorkbench()->GetViewRegistry();
    const QList<berry::IViewDescriptor::Pointer> viewDescriptors = viewRegistry->GetViews();

    bool skip = false;
    for (iter = viewDescriptors.begin(); iter != viewDescriptors.end(); ++iter)
    {

      // if viewExcludeList is set, it contains the id-strings of view, which
      // should not appear as an menu-entry in the menu
      if (viewExcludeList.size() > 0)
      {
        for (int i=0; i<viewExcludeList.size(); i++)
        {
          if (viewExcludeList.at(i) == (*iter)->GetId())
          {
            skip = true;
            break;
          }
        }
        if (skip)
        {
          skip = false;
          continue;
        }
      }

      if ((*iter)->GetId() == "org.blueberry.ui.internal.introview")
        continue;
      if ((*iter)->GetId() == "org.mitk.views.imagenavigator")
        continue;
      if ((*iter)->GetId() == "org.mitk.views.viewnavigatorview")
        continue;

      std::pair<QString, berry::IViewDescriptor::Pointer> p(
            (*iter)->GetLabel(), (*iter));
      VDMap.insert(p);
    }

    std::map<QString, berry::IViewDescriptor::Pointer>::const_iterator
        MapIter;
    for (MapIter = VDMap.begin(); MapIter != VDMap.end(); ++MapIter)
    {
      berry::QtShowViewAction* viewAction = new berry::QtShowViewAction(window,
                                                                        (*MapIter).second);
      viewActions.push_back(viewAction);
    }


    if (!USE_EXPERIMENTAL_COMMAND_CONTRIBUTIONS)
    {

    QMenu* fileMenu = menuBar->addMenu("&File");
    fileMenu->setObjectName("FileMenu");
    fileMenu->addAction(fileOpenAction);
    fileMenu->addAction(fileSaveAction);
    fileMenu->addAction(fileSaveProjectAction);
    fileMenu->addAction(closeProjectAction);
    fileMenu->addSeparator();

    QAction* fileExitAction = new QmitkFileExitAction(window);
    fileExitAction->setIcon(QIcon::fromTheme("system-log-out",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/system-log-out.svg")));
    fileExitAction->setShortcut(QKeySequence::Quit);
    fileExitAction->setObjectName("QmitkFileExitAction");
    fileMenu->addAction(fileExitAction);

    // another bad hack to get an edit/undo menu...
    QMenu* editMenu = menuBar->addMenu("&Edit");
    undoAction = editMenu->addAction(QIcon::fromTheme("edit-undo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-undo.svg")),
                                     "&Undo",
                                     QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onUndo()),
                                     QKeySequence("CTRL+Z"));
    undoAction->setToolTip("Undo the last action (not supported by all modules)");
    redoAction = editMenu->addAction(QIcon::fromTheme("edit-redo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-redo.svg"))
                                     , "&Redo",
                                     QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onRedo()),
                                     QKeySequence("CTRL+Y"));
    redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)");

    // ==== Window Menu ==========================
    QMenu* windowMenu = menuBar->addMenu("Window");
    if (showNewWindowMenuItem)
    {
      windowMenu->addAction("&New Window", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onNewWindow()));
      windowMenu->addSeparator();
    }

    QMenu* perspMenu = windowMenu->addMenu("&Open Perspective");

    QMenu* viewMenu;
    if (showViewMenuItem)
    {
      viewMenu = windowMenu->addMenu("Show &View");
      viewMenu->setObjectName("Show View");
    }
    windowMenu->addSeparator();
    resetPerspAction = windowMenu->addAction("&Reset Perspective",
                                             QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onResetPerspective()));

    if(showClosePerspectiveMenuItem)
      closePerspAction = windowMenu->addAction("&Close Perspective", QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onClosePerspective()));

    windowMenu->addSeparator();
    windowMenu->addAction("&Preferences...",
                          QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onEditPreferences()),
                          QKeySequence("CTRL+P"));

    // fill perspective menu
    berry::IPerspectiveRegistry* perspRegistry =
        window->GetWorkbench()->GetPerspectiveRegistry();

    QList<berry::IPerspectiveDescriptor::Pointer> perspectives(
          perspRegistry->GetPerspectives());

    skip = false;
    for (QList<berry::IPerspectiveDescriptor::Pointer>::iterator perspIt =
         perspectives.begin(); perspIt != perspectives.end(); ++perspIt)
    {

      // if perspectiveExcludeList is set, it contains the id-strings of perspectives, which
      // should not appear as an menu-entry in the perspective menu
      if (perspectiveExcludeList.size() > 0)
      {
        for (int i=0; i<perspectiveExcludeList.size(); i++)
        {
          if (perspectiveExcludeList.at(i) == (*perspIt)->GetId())
          {
            skip = true;
            break;
          }
        }
        if (skip)
        {
          skip = false;
          continue;
        }
      }

      QAction* perspAction = new berry::QtOpenPerspectiveAction(window,
                                                                *perspIt, perspGroup);
      mapPerspIdToAction.insert((*perspIt)->GetId(), perspAction);
    }
    perspMenu->addActions(perspGroup->actions());

    if (showViewMenuItem)
    {
      for (auto viewAction : viewActions)
      {
        viewMenu->addAction(viewAction);
      }
    }


    // ===== Help menu ====================================
    QMenu* helpMenu = menuBar->addMenu("&Help");
    helpMenu->addAction("&Welcome",this, SLOT(onIntro()));
    helpMenu->addAction("&Open Help Perspective", this, SLOT(onHelpOpenHelpPerspective()));
    helpMenu->addAction("&Context Help",this, SLOT(onHelp()),  QKeySequence("F1"));
    helpMenu->addAction("&About",this, SLOT(onAbout()));
    // =====================================================


    }
    else
    {
      undoAction = new QAction(QIcon::fromTheme("edit-undo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-undo.svg")),
                                       "&Undo", nullptr);
      undoAction->setToolTip("Undo the last action (not supported by all modules)");
      redoAction = new QAction(QIcon::fromTheme("edit-redo",QIcon(":/org_mitk_icons/icons/tango/scalable/actions/edit-redo.svg"))
                                       , "&Redo", nullptr);
      redoAction->setToolTip("execute the last action that was undone again (not supported by all modules)");

    }


    // toolbar for showing file open, undo, redo and other main actions
    auto   mainActionsToolBar = new QToolBar;
    mainActionsToolBar->setObjectName("mainActionsToolBar");
    mainActionsToolBar->setContextMenuPolicy(Qt::PreventContextMenu);
#ifdef __APPLE__
    mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextUnderIcon );
#else
    mainActionsToolBar->setToolButtonStyle ( Qt::ToolButtonTextBesideIcon );
#endif

    imageNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/Slider.png"), "&Image Navigator", nullptr);
    bool imageNavigatorViewFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.imagenavigator");

    if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor"))
    {
      openDicomEditorAction = new QmitkOpenDicomEditorAction(QIcon(":/org.mitk.gui.qt.ext/dcm-icon.png"),window);
    }
    if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser"))
    {
      openXnatEditorAction = new QmitkOpenXnatEditorAction(QIcon(":/org.mitk.gui.qt.ext/xnat-icon.png"),window);
    }

    if (imageNavigatorViewFound)
    {
      QObject::connect(imageNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onImageNavigator()));
      imageNavigatorAction->setCheckable(true);

      // add part listener for image navigator
      imageNavigatorPartListener.reset(new PartListenerForImageNavigator(imageNavigatorAction));
      window->GetPartService()->AddPartListener(imageNavigatorPartListener.data());
      berry::IViewPart::Pointer imageNavigatorView =
          window->GetActivePage()->FindView("org.mitk.views.imagenavigator");
      imageNavigatorAction->setChecked(false);
      if (imageNavigatorView)
      {
        bool isImageNavigatorVisible = window->GetActivePage()->IsPartVisible(imageNavigatorView);
        if (isImageNavigatorVisible)
          imageNavigatorAction->setChecked(true);
      }
      imageNavigatorAction->setToolTip("Toggle image navigator for navigating through image");
    }

    viewNavigatorAction = new QAction(QIcon(":/org.mitk.gui.qt.ext/view-manager_48.png"),"&View Navigator", nullptr);
    viewNavigatorFound = window->GetWorkbench()->GetViewRegistry()->Find("org.mitk.views.viewnavigatorview");
    if (viewNavigatorFound)
    {
      QObject::connect(viewNavigatorAction, SIGNAL(triggered(bool)), QmitkExtWorkbenchWindowAdvisorHack::undohack, SLOT(onViewNavigator()));
      viewNavigatorAction->setCheckable(true);

      // add part listener for view navigator
      viewNavigatorPartListener.reset(new PartListenerForViewNavigator(viewNavigatorAction));
      window->GetPartService()->AddPartListener(viewNavigatorPartListener.data());
      berry::IViewPart::Pointer viewnavigatorview =
          window->GetActivePage()->FindView("org.mitk.views.viewnavigatorview");
      viewNavigatorAction->setChecked(false);
      if (viewnavigatorview)
      {
        bool isViewNavigatorVisible = window->GetActivePage()->IsPartVisible(viewnavigatorview);
        if (isViewNavigatorVisible)
          viewNavigatorAction->setChecked(true);
      }
      viewNavigatorAction->setToolTip("Toggle View Navigator");
    }

    mainActionsToolBar->addAction(fileOpenAction);
    mainActionsToolBar->addAction(fileSaveProjectAction);
    mainActionsToolBar->addAction(closeProjectAction);
    mainActionsToolBar->addAction(undoAction);
    mainActionsToolBar->addAction(redoAction);
    if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.dicomeditor"))
    {
      mainActionsToolBar->addAction(openDicomEditorAction);
    }
    if(this->GetWindowConfigurer()->GetWindow()->GetWorkbench()->GetEditorRegistry()->FindEditor("org.mitk.editors.xnat.browser"))
    {
      mainActionsToolBar->addAction(openXnatEditorAction);
    }
    if (imageNavigatorViewFound)
    {
      mainActionsToolBar->addAction(imageNavigatorAction);
    }
    if (viewNavigatorFound)
    {
      mainActionsToolBar->addAction(viewNavigatorAction);
    }
    mainWindow->addToolBar(mainActionsToolBar);


    // ==== Perspective Toolbar ==================================
    auto   qPerspectiveToolbar = new QToolBar;
    qPerspectiveToolbar->setObjectName("perspectiveToolBar");

    if (showPerspectiveToolbar)
    {
      qPerspectiveToolbar->addActions(perspGroup->actions());
      mainWindow->addToolBar(qPerspectiveToolbar);
    }
    else
      delete qPerspectiveToolbar;

    // ==== View Toolbar ==================================
    auto   qToolbar = new QToolBar;
    qToolbar->setObjectName("viewToolBar");

    if (showViewToolbar)
    {
      mainWindow->addToolBar(qToolbar);

      for (auto viewAction : viewActions)
      {
        qToolbar->addAction(viewAction);
      }

    }
    else
      delete qToolbar;

    QSettings settings(GetQSettingsFile(), QSettings::IniFormat);
    mainWindow->restoreState(settings.value("ToolbarPosition").toByteArray());

    auto   qStatusBar = new QStatusBar();

    //creating a QmitkStatusBar for Output on the QStatusBar and connecting it with the MainStatusBar
    auto  statusBar = new QmitkStatusBar(qStatusBar);
    //disabling the SizeGrip in the lower right corner
    statusBar->SetSizeGripEnabled(false);



    auto  progBar = new QmitkProgressBar();

    qStatusBar->addPermanentWidget(progBar, 0);
    progBar->hide();
    // progBar->AddStepsToDo(2);
    // progBar->Progress(1);

    mainWindow->setStatusBar(qStatusBar);

    if (showMemoryIndicator)
    {
      auto   memoryIndicator = new QmitkMemoryUsageIndicatorView();
      qStatusBar->addPermanentWidget(memoryIndicator, 0);
    }

}
예제 #14
0
DasmWindow::DasmWindow(running_machine* machine, QWidget* parent) :
	WindowQt(machine, NULL)
{
	setWindowTitle("Debug: Disassembly View");

	if (parent != NULL)
	{
		QPoint parentPos = parent->pos();
		setGeometry(parentPos.x()+100, parentPos.y()+100, 800, 400);
	}

	//
	// The main frame and its input and log widgets
	//
	QFrame* mainWindowFrame = new QFrame(this);

	// The top frame & groupbox that contains the input widgets
	QFrame* topSubFrame = new QFrame(mainWindowFrame);

	// The input edit
	m_inputEdit = new QLineEdit(topSubFrame);
	connect(m_inputEdit, SIGNAL(returnPressed()), this, SLOT(expressionSubmitted()));

	// The cpu combo box
	m_cpuComboBox = new QComboBox(topSubFrame);
	m_cpuComboBox->setObjectName("cpu");
	m_cpuComboBox->setMinimumWidth(300);
	connect(m_cpuComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(cpuChanged(int)));

	// The main disasm window
	m_dasmView = new DebuggerView(DVT_DISASSEMBLY,
									m_machine,
									this);

	// Force a recompute of the disassembly region
	downcast<debug_view_disasm*>(m_dasmView->view())->set_expression("curpc");

	// Populate the combo box & set the proper cpu
	populateComboBox();
	//const debug_view_source *source = mem->views[0]->view->source_for_device(curcpu);
	//gtk_combo_box_set_active(zone_w, mem->views[0]->view->source_list().indexof(*source));
	//mem->views[0]->view->set_source(*source);


	// Layout
	QHBoxLayout* subLayout = new QHBoxLayout(topSubFrame);
	subLayout->addWidget(m_inputEdit);
	subLayout->addWidget(m_cpuComboBox);
	subLayout->setSpacing(3);
	subLayout->setContentsMargins(2,2,2,2);

	QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame);
	vLayout->setSpacing(3);
	vLayout->setContentsMargins(2,2,2,2);
	vLayout->addWidget(topSubFrame);
	vLayout->addWidget(m_dasmView);

	setCentralWidget(mainWindowFrame);

	//
	// Menu bars
	//
	// Create two commands
	QAction* breakpointSetAct = new QAction("Toggle Breakpoint At Cursor", this);
	QAction* runToCursorAct = new QAction("Run To Cursor", this);
	breakpointSetAct->setShortcut(Qt::Key_F9);
	runToCursorAct->setShortcut(Qt::Key_F4);
	connect(breakpointSetAct, SIGNAL(triggered(bool)), this, SLOT(toggleBreakpointAtCursor(bool)));
	connect(runToCursorAct, SIGNAL(triggered(bool)), this, SLOT(runToCursor(bool)));

	// Right bar options
	QActionGroup* rightBarGroup = new QActionGroup(this);
	rightBarGroup->setObjectName("rightbargroup");
	QAction* rightActRaw = new QAction("Raw Opcodes", this);
	QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this);
	QAction* rightActComments = new QAction("Comments", this);
	rightActRaw->setCheckable(true);
	rightActEncrypted->setCheckable(true);
	rightActComments->setCheckable(true);
	rightActRaw->setActionGroup(rightBarGroup);
	rightActEncrypted->setActionGroup(rightBarGroup);
	rightActComments->setActionGroup(rightBarGroup);
	rightActRaw->setShortcut(QKeySequence("Ctrl+R"));
	rightActEncrypted->setShortcut(QKeySequence("Ctrl+E"));
	rightActComments->setShortcut(QKeySequence("Ctrl+C"));
	rightActRaw->setChecked(true);
	connect(rightBarGroup, SIGNAL(triggered(QAction*)), this, SLOT(rightBarChanged(QAction*)));

	// Assemble the options menu
	QMenu* optionsMenu = menuBar()->addMenu("&Options");
	optionsMenu->addAction(breakpointSetAct);
	optionsMenu->addAction(runToCursorAct);
	optionsMenu->addSeparator();
	optionsMenu->addActions(rightBarGroup->actions());
}
예제 #15
0
void FavoriteHubs::slotContexMenu(const QPoint &){
    QItemSelectionModel *s_model = treeView->selectionModel();
    QModelIndexList list = s_model->selectedRows(0);
    WulforUtil *WU = WulforUtil::getInstance();
    bool empty = list.empty();
    QMenu *menu = new QMenu(this);

    if (empty){
        QAction *add_new = new QAction(WU->getPixmap(WulforUtil::eiBOOKMARK_ADD), tr("Add new"), menu);
        menu->addAction(add_new);

        QAction *res = menu->exec(QCursor::pos());

        if (res){
            FavoriteHubEditor editor;

            initHubEditor(editor);

            if (editor.exec() == QDialog::Accepted){
                StrMap map;
                FavoriteHubEntry entry;

                getParams(editor, map);
                updateEntry(entry, map);

                FavoriteManager::getInstance()->addFavorite(entry);
            }
        }
    }
    else {
        FavoriteHubItem *item = static_cast<FavoriteHubItem*>(list.at(0).internalPointer());

        if (!item){
            delete menu;

            return;
        }

        QAction *add_new = new QAction(WU->getPixmap(WulforUtil::eiBOOKMARK_ADD), tr("Add new"), menu);
        QAction *change  = new QAction(WU->getPixmap(WulforUtil::eiEDIT), tr("Change"), menu);
        QAction *remove  = new QAction(WU->getPixmap(WulforUtil::eiEDITDELETE), tr("Delete"), menu);
        QAction *conn    = new QAction(WU->getPixmap(WulforUtil::eiCONNECT), tr("Connect"), menu);
        QAction *sep1    = new QAction(menu);
        QAction *sep2    = new QAction(menu);
        sep1->setSeparator(true);
        sep2->setSeparator(true);

        menu->addActions(QList<QAction*>() << change
                                           << remove
                                           << sep1
                                           << conn
                                           << sep2
                                           << add_new);

        QAction *res = menu->exec(QCursor::pos());

        if (res == change)
            slotChangeButtonClicked();
        else if (res == remove)
            slotRemoveButtonClicked();
        else if (res == conn)
            slotDblClicked();
        else if (res == add_new)
            slotAdd_newButtonClicked();
    }

    delete menu;
}
예제 #16
0
파일: mainwindow.cpp 프로젝트: mbarnes/mame
MainWindow::MainWindow(running_machine* machine, QWidget* parent) :
	WindowQt(machine, nullptr),
	m_historyIndex(0),
	m_inputHistory()
{
	setGeometry(300, 300, 1000, 600);

	//
	// The main frame and its input and log widgets
	//
	QFrame* mainWindowFrame = new QFrame(this);

	// The input line
	m_inputEdit = new QLineEdit(mainWindowFrame);
	connect(m_inputEdit, &QLineEdit::returnPressed, this, &MainWindow::executeCommandSlot);
	m_inputEdit->installEventFilter(this);


	// The log view
	m_consoleView = new DebuggerView(DVT_CONSOLE,
										m_machine,
										mainWindowFrame);
	m_consoleView->setFocusPolicy(Qt::NoFocus);
	m_consoleView->setPreferBottom(true);

	QVBoxLayout* vLayout = new QVBoxLayout(mainWindowFrame);
	vLayout->addWidget(m_consoleView);
	vLayout->addWidget(m_inputEdit);
	vLayout->setSpacing(3);
	vLayout->setContentsMargins(4,0,4,2);

	setCentralWidget(mainWindowFrame);

	//
	// Options Menu
	//
	// Create three commands
	m_breakpointToggleAct = new QAction("Toggle Breakpoint at Cursor", this);
	m_breakpointEnableAct = new QAction("Disable Breakpoint at Cursor", this);
	m_runToCursorAct = new QAction("Run to Cursor", this);
	m_breakpointToggleAct->setShortcut(Qt::Key_F9);
	m_breakpointEnableAct->setShortcut(Qt::SHIFT + Qt::Key_F9);
	m_runToCursorAct->setShortcut(Qt::Key_F4);
	connect(m_breakpointToggleAct, &QAction::triggered, this, &MainWindow::toggleBreakpointAtCursor);
	connect(m_breakpointEnableAct, &QAction::triggered, this, &MainWindow::enableBreakpointAtCursor);
	connect(m_runToCursorAct, &QAction::triggered, this, &MainWindow::runToCursor);

	// Right bar options
	QActionGroup* rightBarGroup = new QActionGroup(this);
	rightBarGroup->setObjectName("rightbargroup");
	QAction* rightActRaw = new QAction("Raw Opcodes", this);
	QAction* rightActEncrypted = new QAction("Encrypted Opcodes", this);
	QAction* rightActComments = new QAction("Comments", this);
	rightActRaw->setCheckable(true);
	rightActEncrypted->setCheckable(true);
	rightActComments->setCheckable(true);
	rightActRaw->setActionGroup(rightBarGroup);
	rightActEncrypted->setActionGroup(rightBarGroup);
	rightActComments->setActionGroup(rightBarGroup);
	rightActRaw->setShortcut(QKeySequence("Ctrl+R"));
	rightActEncrypted->setShortcut(QKeySequence("Ctrl+E"));
	rightActComments->setShortcut(QKeySequence("Ctrl+N"));
	rightActRaw->setChecked(true);
	connect(rightBarGroup, &QActionGroup::triggered, this, &MainWindow::rightBarChanged);

	// Assemble the options menu
	QMenu* optionsMenu = menuBar()->addMenu("&Options");
	optionsMenu->addAction(m_breakpointToggleAct);
	optionsMenu->addAction(m_breakpointEnableAct);
	optionsMenu->addAction(m_runToCursorAct);
	optionsMenu->addSeparator();
	optionsMenu->addActions(rightBarGroup->actions());

	//
	// Images menu
	//
	image_interface_iterator imageIterTest(m_machine->root_device());
	if (imageIterTest.first() != nullptr)
	{
		createImagesMenu();
	}

	//
	// Dock window menu
	//
	QMenu* dockMenu = menuBar()->addMenu("Doc&ks");

	setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea);
	setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);

	// The processor dock
	QDockWidget* cpuDock = new QDockWidget("processor", this);
	cpuDock->setObjectName("cpudock");
	cpuDock->setAllowedAreas(Qt::LeftDockWidgetArea);
	m_procFrame = new ProcessorDockWidget(m_machine, cpuDock);
	cpuDock->setWidget(dynamic_cast<QWidget*>(m_procFrame));

	addDockWidget(Qt::LeftDockWidgetArea, cpuDock);
	dockMenu->addAction(cpuDock->toggleViewAction());

	// The disassembly dock
	QDockWidget* dasmDock = new QDockWidget("dasm", this);
	dasmDock->setObjectName("dasmdock");
	dasmDock->setAllowedAreas(Qt::TopDockWidgetArea);
	m_dasmFrame = new DasmDockWidget(m_machine, dasmDock);
	dasmDock->setWidget(m_dasmFrame);
	connect(m_dasmFrame->view(), &DebuggerView::updated, this, &MainWindow::dasmViewUpdated);

	addDockWidget(Qt::TopDockWidgetArea, dasmDock);
	dockMenu->addAction(dasmDock->toggleViewAction());
}
예제 #17
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    // Setup this MainWindow with the parameters mainwindow.ui:
    // Definition of size, creation of widgets inside etc..
    ui->setupUi(this);

    // Retrieve pointers of widgets already created by the up operation
    // Those who will be used again outside the creator are saved at class variables
    QMenuBar * menuBar = ui->menuBar;
    QSlider *slider_color = ui->verticalSlider;
    QSlider *slider_style = ui->verticalSlider_2;
    QToolBar * toolbar = ui->toolBar;
    mydrawzone = ui->widget;

    // Declaration of menus and adition inside menubar
    QMenu * openMenu = menuBar->addMenu( tr("&Open"));
    QMenu * saveMenu = menuBar->addMenu( tr("&Save"));
    QMenu * quitMenu = menuBar->addMenu( tr("&Quit"));
    QMenu * penMenu = menuBar->addMenu( tr("&Pen Settings"));
    QMenu * colorMenu = menuBar->addMenu( tr("&Color Settings"));
    QMenu * styleMenu = menuBar->addMenu( tr("&Style Settings"));
    QMenu * formMenu = menuBar->addMenu( tr("&Form Settings"));

    // Declaration of principal actions
    // Those that will be shown at the toolbar
    QAction * openAction = new QAction( QIcon(":/icons/open.png"), tr("&Open"), this);
    QAction * saveAction = new QAction( QIcon(":/icons/save.png"), tr("&Save"), this);
    QAction * quitAction = new QAction( QIcon(":/icons/quit.png"), tr("&Quit"), this);
    QAction * paintAction = new QAction( QIcon(":/icons/paint.png"), tr("&Paint"), this);
    QAction * editAction = new QAction( QIcon(":/icons/edit.png"), tr("&Edit"), this);
    QAction * moveAction = new QAction( QIcon(":/icons/move.png"), tr("&Edit"), this);

    // Declaration of some other actions
    // Those that will have shortcuts as well but wont be shown in the toolbar
    QAction *set_pen_color =new QAction(tr("Alternate Color Pen"), this);
    QAction *set_pen_width_larger =new QAction(tr("&Pen Width +"), this);
    QAction *set_pen_width_shorter =new QAction(tr("&Pen Width -"), this);
    QAction *set_pen_style =new QAction(tr("&Alternate Style Pen"), this);
    QAction *set_figure_form =new QAction(tr("&Alternate Figure Form"), this);
    QAction *undo =new QAction(tr("&Undo"), this);

    // Declaration of action groups
    // The pointers for the actions are saved inside class variables
    // to be used outside the class creator
    QActionGroup *action_group_color = new QActionGroup(this);
    color0 = action_group_color->addAction(tr("Black Pen"));
    color1 = action_group_color->addAction(tr("White Pen"));
    color2 = action_group_color->addAction(tr("Dark Gray Pen"));
    color3 = action_group_color->addAction(tr("Gray Pen"));
    color4 = action_group_color->addAction(tr("Light Gray Pen"));
    color5 = action_group_color->addAction(tr("Red Pen"));
    color6 = action_group_color->addAction(tr("Green Pen"));
    color7 = action_group_color->addAction(tr("Blue Pen"));
    color8 = action_group_color->addAction(tr("Cyan Pen"));
    color9 = action_group_color->addAction(tr("Magenta Pen"));
    color10 = action_group_color->addAction(tr("Yellow Pen"));
    color11 = action_group_color->addAction(tr("Dark Red Pen"));
    color12 = action_group_color->addAction(tr("Dark Green Pen"));
    color13 = action_group_color->addAction(tr("Dark Blue Pen"));
    color14 = action_group_color->addAction(tr("Dark Cyan Pen"));
    color15 = action_group_color->addAction(tr("Dark Magenta Pen"));
    color16 = action_group_color->addAction(tr("Dark Yellow Pen"));
    color17 = action_group_color->addAction(tr("Transparent"));

    QActionGroup *action_group_style = new QActionGroup(this);
    style0 = action_group_style->addAction(tr("Solid Pen"));
    style1 = action_group_style->addAction(tr("Dash Line Pen"));
    style2 = action_group_style->addAction(tr("Dot Line Pen"));
    style3 = action_group_style->addAction(tr("Dash dot Line Pen"));
    style4 = action_group_style->addAction(tr("Dash Dot Dot Line Pen"));
    style5 = action_group_style->addAction(tr("Custom Dash Line Pen"));

    QActionGroup *action_group_form = new QActionGroup(this);
    form0 = action_group_form->addAction(tr("Line Form"));
    form1 = action_group_form->addAction(tr("Rectangle Form"));
    form2 = action_group_form->addAction(tr("Elipse Form"));

    // Adition of shortcuts for principal actions
    openAction->setShortcut( tr("Ctrl+O"));
    saveAction->setShortcut( tr("Ctrl+S"));
    quitAction->setShortcut( tr("Ctrl+Q"));
    paintAction->setShortcut( tr("Ctrl+P"));
    editAction->setShortcut( tr("Ctrl+E"));
    moveAction->setShortcut( tr("Ctrl+M"));

    // Adition of shortcuts for those other actions
    set_pen_color->setShortcut( tr("Ctrl+C"));
    set_pen_style->setShortcut( tr("Ctrl+Space"));
    set_pen_width_larger->setShortcut( tr("Ctrl++"));
    set_pen_width_shorter->setShortcut( tr("Ctrl+-"));
    set_figure_form->setShortcut( tr("Ctrl+F"));
    undo->setShortcut(tr ("Ctrl+Z"));

    // Adition of tool tips for principal actions
    openAction->setToolTip( tr("Open file"));
    saveAction->setToolTip( tr("Save file"));
    quitAction->setToolTip( tr("Quit file"));

    // Adition of status tips for principal actions
    openAction->setStatusTip( tr("Open file"));
    saveAction->setStatusTip( tr("Save file"));
    quitAction->setStatusTip( tr("Quit file"));

    // Adition of actions to menus
    openMenu->addAction(openAction);
    saveMenu->addAction(saveAction);
    quitMenu->addAction(quitAction);

    penMenu->addAction(set_pen_width_larger);
    penMenu->addAction(set_pen_width_shorter);
    penMenu->addAction(undo);

    colorMenu->addAction(set_pen_color);
    colorMenu->addActions(action_group_color->actions());

    styleMenu->addAction(set_pen_style);
    styleMenu->addActions(action_group_style->actions());

    formMenu->addAction(set_figure_form);
    formMenu->addActions(action_group_form->actions());

    // Adition of principal actions to toolbar
    toolbar->addAction(openAction);
    toolbar->addAction(saveAction);
    toolbar->addAction(quitAction);
    toolbar->addAction(paintAction);
    toolbar->addAction(editAction);
    toolbar->addAction(moveAction);

    // Set some parameters to the sliders
    slider_color->setTickPosition(QSlider::TicksBothSides);
    slider_color->setMinimum(0);
    slider_color->setMaximum(17);
    slider_color->setSingleStep(1);

    slider_style->setTickPosition(QSlider::TicksBothSides);
    slider_style->setMinimum(0);
    slider_style->setMaximum(5);
    slider_style->setSingleStep(1);

    // Link actions and signals to slots
    connect(openAction, SIGNAL(triggered( )), this, SLOT(openFile()));
    connect(saveAction, SIGNAL(triggered( )), this, SLOT(saveFile()));
    connect(quitAction, SIGNAL(triggered( )), this, SLOT(quitApp()));

    connect(paintAction, SIGNAL(triggered( )), mydrawzone, SLOT(set_draw_mode_paint()));
    connect(editAction, SIGNAL(triggered( )), mydrawzone, SLOT(set_draw_mode_edit()));
    connect(moveAction, SIGNAL(triggered( )), mydrawzone, SLOT(set_draw_mode_move()));
    connect(set_pen_width_larger, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_width_larger()));
    connect(set_pen_width_shorter, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_width_shorter()));
    connect(undo, SIGNAL(triggered( )), mydrawzone, SLOT(undo()));

    connect(set_pen_color, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_color()));
    connect(action_group_color, SIGNAL(triggered(QAction *)), this, SLOT(doIt(QAction *)));
    connect(this, SIGNAL(color_pen_changed(int)), mydrawzone, SLOT(set_pen_color(int)));

    connect(set_pen_style, SIGNAL(triggered( )), mydrawzone, SLOT(set_pen_style()));
    connect(action_group_style, SIGNAL(triggered(QAction *)), this, SLOT(doIt2(QAction *)));
    connect(this, SIGNAL(style_pen_changed(int)), mydrawzone, SLOT(set_pen_style(int)));

    connect(set_figure_form, SIGNAL(triggered( )), mydrawzone, SLOT(set_figure_form()));
    connect(action_group_form, SIGNAL(triggered(QAction *)), this, SLOT(doIt3(QAction *)));
    connect(this, SIGNAL(form_painter_changed(int)), mydrawzone, SLOT(set_figure_form(int)));

    connect(slider_color, SIGNAL(valueChanged(int)), this, SLOT(slide_color_pen_changed(int)));
    connect(slider_style, SIGNAL(valueChanged(int)), this, SLOT(slide_style_pen_changed(int)));
}