Beispiel #1
0
void Monitor::mousePressEvent(QMouseEvent* e)
{
  if (e->button() & RightButton)
    {
      QString dir;
      _app->settings()->get(KEY_SYSTEM_DIR, dir);
      dir += QString("/") + PIXMAPPATH;

      QPopupMenu* menu;
      menu = new QPopupMenu;
      menu->setCheckable(false);
      
      QPopupMenu* displayMenu;
      displayMenu = new QPopupMenu();
      displayMenu->setCheckable(true);
      displayMenu->insertItem("&Absolute", ID_ABSOLUTE);
      displayMenu->insertItem("&Relative to Device", ID_RELATIVE);
      displayMenu->setItemChecked(s_displayStyle, true);

      QPopupMenu* speedMenu;
      speedMenu = new QPopupMenu();
      speedMenu->setCheckable(true);
      speedMenu->insertItem("16Hz", ID_16HZ);
      speedMenu->insertItem("32Hz", ID_32HZ);
      speedMenu->insertItem("64Hz", ID_64HZ);
      speedMenu->setItemChecked(s_updateFrequency, true);

      menu->insertItem(QPixmap(dir + "/monitor.xpm"), 
		       "Channel &Display", displayMenu);
      menu->insertItem(QPixmap(dir + "/clock.xpm"), 
		       "&Update Speed", speedMenu);
      menu->insertSeparator();
      menu->insertItem(QPixmap(dir + "/move.xpm"),
		       "&Resize to Default", ID_RESIZE_SQUARE);
      menu->insertItem(QPixmap(dir + "/rename.xpm"),
		       "Choose &Font", ID_CHOOSE_FONT);

      connect(menu, SIGNAL(activated(int)), 
	      this, SLOT(slotMenuCallback(int)));
      connect(displayMenu, SIGNAL(activated(int)), 
	      this, SLOT(slotMenuCallback(int)));
      connect(speedMenu, SIGNAL(activated(int)), 
	      this, SLOT(slotMenuCallback(int)));

      menu->exec(mapToGlobal(e->pos()));
      
      delete displayMenu;
      delete speedMenu;
      delete menu;
    }
Beispiel #2
0
SpawnPointListMenu::SpawnPointListMenu(SpawnPointList* spawnPointList,
				       QWidget* parent, const char* name)
  : QPopupMenu(parent, name),
    m_spawnPointList(spawnPointList),
    m_currentItem(NULL)
{
  m_id_rename = insertItem("&Rename Spawn Point...",
			   this, SLOT(rename_item(int)));
  m_id_delete = insertItem("&Delete Spawn Point...",
			   this, SLOT(delete_item(int)));
  insertItem("&Clear Spawn Points...",
	     m_spawnPointList, SLOT(clearItems(void)));

  QPopupMenu* listColMenu = new QPopupMenu;
  insertItem("Show &Column", listColMenu);
  listColMenu->setCheckable(true);

  int x = tSpawnPointCoord1;
  m_id_cols[x] = listColMenu->insertItem("Coord &1");
  listColMenu->setItemParameter(m_id_cols[x], x);
  x++;
  m_id_cols[x] = listColMenu->insertItem("Coord &2");
  listColMenu->setItemParameter(m_id_cols[x], x);
  x++;
  m_id_cols[x] = listColMenu->insertItem("Coord &3");
  listColMenu->setItemParameter(m_id_cols[x], x);
  x++;
  m_id_cols[x] = listColMenu->insertItem("&Remaining");
  listColMenu->setItemParameter(m_id_cols[x], x);
  x++;
  m_id_cols[x] = listColMenu->insertItem("&Name");
  listColMenu->setItemParameter(m_id_cols[x], x);
  x++;
  m_id_cols[x] = listColMenu->insertItem("&Last");
  listColMenu->setItemParameter(m_id_cols[x], x);
  x++;
  m_id_cols[x] = listColMenu->insertItem("&Spawned");
  listColMenu->setItemParameter(m_id_cols[x], x);
  x++;
  m_id_cols[x] = listColMenu->insertItem("&Count");
  listColMenu->setItemParameter(m_id_cols[x], x);
  
  connect (listColMenu, SIGNAL(activated(int)), 
	   this, SLOT(toggle_col(int)));
  
  insertSeparator(-1);
  insertItem("&Font...", this, SLOT(set_font(int)));
  insertItem("&Caption...", this, SLOT(set_caption(int)));

  insertSeparator(-1);
  x = insertItem("Keep Sorted", this, SLOT(toggle_keepSorted(int)));
  setItemChecked(x, m_spawnPointList->keepSorted());

  connect(this, SIGNAL(aboutToShow()),
	  this, SLOT(init_menu()));
}
Beispiel #3
0
Frame::Frame( QWidget *parent, const char *name )
    : QMainWindow( parent, name )
{
    QMenuBar *mainMenu = menuBar();
    QPopupMenu *fileMenu = new QPopupMenu( this, "file" );
    fileMenu->insertItem( tr( "&Exit" ), this, SLOT( close() ),
			  QAccel::stringToKey( tr( "Ctrl+Q" ) ) );

    QPopupMenu *styleMenu = new QPopupMenu( this, "style" );
    styleMenu->setCheckable( TRUE );
    QActionGroup *ag = new QActionGroup( this, 0 );
    ag->setExclusive( TRUE );
    QSignalMapper *styleMapper = new QSignalMapper( this );
    connect( styleMapper, SIGNAL( mapped( const QString& ) ),
	     this, SLOT( setStyle( const QString& ) ) );

    QStringList list = QStyleFactory::keys();
    list.sort();
    QDict<int> stylesDict( 17, FALSE );
    for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
	QString style = *it;
	QString styleAccel = style;
	if ( stylesDict[styleAccel.left(1)] ) {
	    for ( uint i = 0; i < styleAccel.length(); i++ ) {
		if ( !stylesDict[styleAccel.mid( i, 1 )] ) {
		    stylesDict.insert(styleAccel.mid( i, 1 ), (const int *)1);
		    styleAccel = styleAccel.insert( i, '&' );
		    break;
		}
	    }
	} else {
	    stylesDict.insert(styleAccel.left(1), (const int *)1);
	    styleAccel = "&"+styleAccel;
	}
	QAction *a = new QAction( style, QIconSet(),
				  styleAccel, 0, ag, 0, ag->isExclusive() );
	connect( a, SIGNAL( activated() ), styleMapper, SLOT(map()) );
	styleMapper->setMapping( a, a->text() );
    }
    ag->addTo( styleMenu );

    mainMenu->insertItem( tr( "&File" ), fileMenu );
    mainMenu->insertItem( tr( "St&yle" ), styleMenu );

    stack = new QWidgetStack( this );

    setCentralWidget( stack );
}
Beispiel #4
0
//
// Right mouse button has been pressed in the listview
//
void DeviceManagerView::slotRightButtonClicked(QListViewItem* item, 
					       const QPoint& point, int col)
{
  QPopupMenu* menu = new QPopupMenu();
  menu->setCheckable(false);
  
  QString dir;
  _app->settings()->get(KEY_SYSTEM_DIR, dir);
  dir += QString("/") + PIXMAPPATH;

  menu->insertItem(QPixmap(dir + "/addoutputdevice.xpm"),
		   "Add...", KMenuItemAdd);
  menu->insertItem(QPixmap(dir + "/editcopy.xpm"),
                   "Clone...", KMenuItemClone);
  menu->insertItem(QPixmap(dir + "/remove.xpm"),
		   "Remove", KMenuItemRemove);
  menu->insertItem(QPixmap(dir + "/settings.xpm"),
		   "Properties...", KMenuItemProperties);
  menu->insertSeparator();
  menu->insertItem(QPixmap(dir + "/monitor.xpm"),
		   "View Monitor...", KMenuItemMonitor);
  menu->insertItem(QPixmap(dir + "/console.xpm"),
		   "View Console...", KMenuItemConsole);
  
  if (_app->mode() == App::Operate)
    {
      // Operate mode, remove and edit impossible
      menu->setItemEnabled(KMenuItemAdd, false);
      menu->setItemEnabled(KMenuItemRemove, false);
      menu->setItemEnabled(KMenuItemProperties, false);
      menu->setItemEnabled(KMenuItemClone, false);
    }
  
  // No item selected, unable to do other things either
  if (!item)
    {
      menu->setItemEnabled(KMenuItemRemove, false);
      menu->setItemEnabled(KMenuItemConsole, false);
      menu->setItemEnabled(KMenuItemMonitor, false);
      menu->setItemEnabled(KMenuItemProperties, false);
      menu->setItemEnabled(KMenuItemClone, false);
    }

  connect(menu, SIGNAL(activated(int)), this, SLOT(slotMenuCallBack(int)));
  menu->exec(point, 0);
  delete menu;
}
Beispiel #5
0
Themes::Themes( QWidget *parent, const char *name, WFlags f )
    : QMainWindow( parent, name, f )
{
    appFont = QApplication::font();
    tabwidget = new QTabWidget( this );

    tabwidget->addTab( new ButtonsGroups( tabwidget ), "Buttons/Groups" );
    QHBox *hbox = new QHBox( tabwidget );
    hbox->setMargin( 5 );
    (void)new LineEdits( hbox );
    (void)new ProgressBar( hbox );
    tabwidget->addTab( hbox, "Lineedits/Progressbar" );
    tabwidget->addTab( new ListBoxCombo( tabwidget ), "Listboxes/Comboboxes" );
    tabwidget->addTab( new CheckLists( tabwidget ), "Listviews" );
    tabwidget->addTab( new RangeControls( tabwidget ), "Rangecontrols" );
    tabwidget->addTab( new MyRichText( tabwidget ), "Fortune" );

    setCentralWidget( tabwidget );

    QPopupMenu *style = new QPopupMenu( this );
    style->setCheckable( TRUE );
    menuBar()->insertItem( "&Style" , style );

    sMetal = style->insertItem( "&Metal", this, SLOT( styleMetal() ) );
    sWood = style->insertItem( "&Norwegian Wood", this, SLOT( styleWood() ) );
    sPlatinum = style->insertItem( "&Platinum" , this ,SLOT( stylePlatinum() ) );
    sWindows = style->insertItem( "&Windows", this, SLOT( styleWindows() ) );
    sCDE = style->insertItem( "&CDE", this, SLOT( styleCDE() ) );
    sMotif = style->insertItem( "M&otif", this, SLOT( styleMotif() ) );
    sMotifPlus = style->insertItem( "Motif P&lus", this, SLOT( styleMotifPlus() ) );
    style->insertSeparator();
    style->insertItem("&Quit", qApp, SLOT( quit() ), CTRL | Key_Q );

    QPopupMenu * help = new QPopupMenu( this );
    menuBar()->insertSeparator();
    menuBar()->insertItem( "&Help", help );
    help->insertItem( "&About", this, SLOT(about()), Key_F1);
    help->insertItem( "About &Qt", this, SLOT(aboutQt()));

    qApp->setStyle( new NorwegianWoodStyle );
    menuBar()->setItemChecked( sWood, TRUE );
}
Beispiel #6
0
QPopupMenu *KOTodoView::getCategoryPopupMenu( KOTodoViewItem *todoItem )
{
  QPopupMenu *tempMenu = new QPopupMenu( this );
  QStringList checkedCategories = todoItem->todo()->categories();

  tempMenu->setCheckable( true );
  QStringList::Iterator it;
  for ( it = KOPrefs::instance()->mCustomCategories.begin();
        it != KOPrefs::instance()->mCustomCategories.end();
        ++it ) {
    int index = tempMenu->insertItem( *it );
    mCategory[ index ] = *it;
    if ( checkedCategories.find( *it ) != checkedCategories.end() )
      tempMenu->setItemChecked( index, true );
  }

  connect ( tempMenu, SIGNAL( activated( int ) ),
            SLOT( changedCategories( int ) ) );
  return tempMenu;
}
Beispiel #7
0
SpawnListMenu::SpawnListMenu(SEQListView* spawnlist,
                             SEQWindow* spawnlistWindow,
                             FilterMgr* filterMgr,
                             CategoryMgr* categoryMgr,
                             QWidget* parent, const char* name)
    : m_spawnlist(spawnlist),
      m_spawnlistWindow(spawnlistWindow),
      m_filterMgr(filterMgr),
      m_categoryMgr(categoryMgr)
{
    // Show Columns
    QPopupMenu* spawnListColMenu = new QPopupMenu;
    insertItem( "Show &Column", spawnListColMenu);
    spawnListColMenu->setCheckable(true);
    m_id_spawnList_Cols[tSpawnColName] =
        spawnListColMenu->insertItem("&Name");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColName],
                                       tSpawnColName);
    m_id_spawnList_Cols[tSpawnColLevel] = spawnListColMenu->insertItem("&Level");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColLevel],
                                       tSpawnColLevel);
    m_id_spawnList_Cols[tSpawnColHP] = spawnListColMenu->insertItem("&HP");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColHP],
                                       tSpawnColHP);
    m_id_spawnList_Cols[tSpawnColMaxHP] = spawnListColMenu->insertItem("&Max HP");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColMaxHP],
                                       tSpawnColMaxHP);
    m_id_spawnList_Cols[tSpawnColXPos] = spawnListColMenu->insertItem("Coord &1");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColXPos],
                                       tSpawnColXPos);
    m_id_spawnList_Cols[tSpawnColYPos] = spawnListColMenu->insertItem("Coord &2");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColYPos],
                                       tSpawnColYPos);
    m_id_spawnList_Cols[tSpawnColZPos] = spawnListColMenu->insertItem("Coord &3");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColZPos],
                                       tSpawnColZPos);
    m_id_spawnList_Cols[tSpawnColID] = spawnListColMenu->insertItem("I&D");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColID],
                                       tSpawnColID);
    m_id_spawnList_Cols[tSpawnColDist] = spawnListColMenu->insertItem("&Dist");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColDist],
                                       tSpawnColDist);
    m_id_spawnList_Cols[tSpawnColRace] = spawnListColMenu->insertItem("&Race");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColRace],
                                       tSpawnColRace);
    m_id_spawnList_Cols[tSpawnColClass] = spawnListColMenu->insertItem("&Class");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColClass],
                                       tSpawnColClass);
    m_id_spawnList_Cols[tSpawnColInfo] = spawnListColMenu->insertItem("&Info");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColInfo],
                                       tSpawnColInfo);
    m_id_spawnList_Cols[tSpawnColSpawnTime] = spawnListColMenu->insertItem("Spawn &Time");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColSpawnTime],
                                       tSpawnColSpawnTime);
    m_id_spawnList_Cols[tSpawnColDeity] = spawnListColMenu->insertItem("&Deity");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColDeity],
                                       tSpawnColDeity);
    m_id_spawnList_Cols[tSpawnColBodyType] = spawnListColMenu->insertItem("&Body Type");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColBodyType],
                                       tSpawnColBodyType);
    m_id_spawnList_Cols[tSpawnColGuildID] = spawnListColMenu->insertItem("Guild Tag");
    spawnListColMenu->setItemParameter(m_id_spawnList_Cols[tSpawnColGuildID],
                                       tSpawnColGuildID);

    connect (spawnListColMenu, SIGNAL(activated(int)),
             this, SLOT(toggle_spawnListCol(int)));

    int x;
    QPopupMenu* filterMenu = new QPopupMenu;
    m_id_filterMenu = insertItem("Add &Filter", filterMenu);
    setItemEnabled(m_id_filterMenu, false);
    x = filterMenu->insertItem("&Hunt...");
    filterMenu->setItemParameter(x, HUNT_FILTER);
    x = filterMenu->insertItem("&Caution...");
    filterMenu->setItemParameter(x, CAUTION_FILTER);
    x = filterMenu->insertItem("&Danger...");
    filterMenu->setItemParameter(x, DANGER_FILTER);
    x = filterMenu->insertItem("&Locate...");
    filterMenu->setItemParameter(x, LOCATE_FILTER);
    x = filterMenu->insertItem("&Alert...");
    filterMenu->setItemParameter(x, ALERT_FILTER);
    x = filterMenu->insertItem("&Filtered...");
    filterMenu->setItemParameter(x, FILTERED_FILTER);
    x = filterMenu->insertItem("&Tracer...");
    filterMenu->setItemParameter(x, TRACER_FILTER);
    connect (filterMenu, SIGNAL(activated(int)),
             this, SLOT(add_filter(int)));

    QPopupMenu* zoneFilterMenu = new QPopupMenu;
    m_id_zoneFilterMenu = insertItem("Add &Zone Filter", zoneFilterMenu);
    setItemEnabled(m_id_zoneFilterMenu, false);
    x = zoneFilterMenu->insertItem("&Hunt...");
    zoneFilterMenu->setItemParameter(x, HUNT_FILTER);
    x = zoneFilterMenu->insertItem("&Caution...");
    zoneFilterMenu->setItemParameter(x, CAUTION_FILTER);
    x = zoneFilterMenu->insertItem("&Danger...");
    zoneFilterMenu->setItemParameter(x, DANGER_FILTER);
    x = zoneFilterMenu->insertItem("&Locate...");
    zoneFilterMenu->setItemParameter(x, LOCATE_FILTER);
    x = zoneFilterMenu->insertItem("&Alert...");
    zoneFilterMenu->setItemParameter(x, ALERT_FILTER);
    x = zoneFilterMenu->insertItem("&Filtered...");
    zoneFilterMenu->setItemParameter(x, FILTERED_FILTER);
    x = zoneFilterMenu->insertItem("&Tracer...");
    zoneFilterMenu->setItemParameter(x, TRACER_FILTER);
    connect (zoneFilterMenu, SIGNAL(activated(int)),
             this, SLOT(add_zoneFilter(int)));

    insertSeparator(-1);

    x = insertItem("&Add Category...", this, SLOT(add_category(int)));
    m_id_edit_category =
        insertItem("&Edit Category...", this, SLOT(edit_category(int)));
    m_id_delete_category =
        insertItem("&Delete Category...", this, SLOT(delete_category(int)));
    insertItem("&Reload Categories", this, SLOT(reload_categories(int)));
    insertSeparator(-1);
    insertItem("&Font...", this, SLOT(set_font(int)));
    insertItem("&Caption...", this, SLOT(set_caption(int)));

    connect(this, SIGNAL(aboutToShow()),
            this, SLOT(init_Menu()));
}
Beispiel #8
0
MenuExample::MenuExample( QWidget *parent, const char *name )
    : QWidget( parent, name )
{
    QPixmap p1( p1_xpm );
    QPixmap p2( p2_xpm );
    QPixmap p3( p3_xpm );

    QPopupMenu *print = new QPopupMenu( this );
    CHECK_PTR( print );
    print->insertTearOffHandle();
    print->insertItem( "&Print to printer", this, SLOT(printer()) );
    print->insertItem( "Print to &file", this, SLOT(file()) );
    print->insertItem( "Print to fa&x", this, SLOT(fax()) );
    print->insertSeparator();
    print->insertItem( "Printer &Setup", this, SLOT(printerSetup()) );

    QPopupMenu *file = new QPopupMenu( this );
    CHECK_PTR( file );
    file->insertItem( p1, "&Open",  this, SLOT(open()), CTRL+Key_O );
    file->insertItem( p2, "&New", this, SLOT(news()), CTRL+Key_N );
    file->insertItem( p3, "&Save", this, SLOT(save()), CTRL+Key_S );
    file->insertItem( "&Close", this, SLOT(closeDoc()), CTRL+Key_W );
    file->insertSeparator();
    file->insertItem( "&Print", print, CTRL+Key_P );
    file->insertSeparator();
    file->insertItem( "E&xit",  qApp, SLOT(quit()), CTRL+Key_Q );

    QPopupMenu *edit = new QPopupMenu( this );
    CHECK_PTR( edit );
    int undoID = edit->insertItem( "&Undo", this, SLOT(undo()) );
    int redoID = edit->insertItem( "&Redo", this, SLOT(redo()) );
    edit->setItemEnabled( undoID, FALSE );
    edit->setItemEnabled( redoID, FALSE );

    QPopupMenu* options = new QPopupMenu( this );
    CHECK_PTR( options );
    options->insertTearOffHandle();
    options->setCaption("Options");
    options->insertItem( "&Normal Font", this, SLOT(normal()) );
    options->insertSeparator();

    options->polish(); // adjust system settings
    QFont f = options->font();
    f.setBold( TRUE );
    boldID = options->insertItem( new MyMenuItem( "Bold", f ) );
    options->setAccel( CTRL+Key_B, boldID );
    options->connectItem( boldID, this, SLOT(bold()) );
    f = font();
    f.setUnderline( TRUE );
    underlineID = options->insertItem( new MyMenuItem( "Underline", f ) );
    options->setAccel( CTRL+Key_U, underlineID );
    options->connectItem( underlineID, this, SLOT(underline()) );

    isBold = FALSE;
    isUnderline = FALSE;
    options->setCheckable( TRUE );


    QPopupMenu *help = new QPopupMenu( this );
    CHECK_PTR( help );
    help->insertItem( "&About", this, SLOT(about()), CTRL+Key_H );
    help->insertItem( "About &Qt", this, SLOT(aboutQt()) );

    menu = new QMenuBar( this );
    CHECK_PTR( menu );
    menu->insertItem( "&File", file );
    menu->insertItem( "&Edit", edit );
    menu->insertItem( "&Options", options );
    menu->insertSeparator();
    menu->insertItem( "&Help", help );
    menu->setSeparator( QMenuBar::InWindowsStyle );

    label = new QLabel( this );
    CHECK_PTR( label );
    label->setGeometry( 20, rect().center().y()-20, width()-40, 40 );
    label->setFrameStyle( QFrame::Box | QFrame::Raised );
    label->setLineWidth( 1 );
    label->setAlignment( AlignCenter );

    connect( this,  SIGNAL(explain(const QString&)),
             label, SLOT(setText(const QString&)) );

    setMinimumSize( 100, 80 );
}
Beispiel #9
0
int Kpacman::lookupSchemes()
{
    APP_CONFIG_BEGIN( cfg );
    int ModeCount = cfg->readNumEntry("ModeCount", 0);
    int Mode = cfg->readNumEntry("Mode", 0);
    int SchemeCount = cfg->readNumEntry("SchemeCount", 0);
    int Scheme = cfg->readNumEntry("Scheme", 0);

	/*
    if (SchemeCount == 0 || Scheme == -1) {
        QMessageBox::warning(this, tr("Configuration Error"),
                                   tr("There are no schemes defined,\n"
                                        "or no scheme is selected."));
        APP_CONFIG_END( cfg );
        return 0;
    }
	*/

    connect(modesPopup, SIGNAL(activated(int)), this, SLOT(schemeChecked(int)));
    modeID.resize(ModeCount > 0 ? ModeCount : 0);

    if (!schemesPopup->isEmpty())
        schemesPopup->clear();

    SAVE_CONFIG_GROUP( cfg, oldgroup );

    QString ModeGroup;
    QString ModeName;

    for (int m = 0; m < ModeCount; m++) {
        ModeGroup.sprintf("Mode %d", m);
        cfg->setGroup(ModeGroup);

        ModeName = cfg->readEntry("Description", ModeGroup);

        QPopupMenu *p = new QPopupMenu;
        p->setCheckable(TRUE);
        connect(p, SIGNAL(activated(int)), this, SLOT(schemeChecked(int)));
        schemesPopup->append(p);

        modeID[m] = modesPopup->insertItem(ModeName, schemesPopup->at(m));
        modesPopup->setItemEnabled(modeID[m], FALSE);
        modesPopup->setItemChecked(modeID[m], m == Mode);
    }

    schemeID.resize(SchemeCount);
    schemeMode.resize(SchemeCount);

    QString SchemeGroup;
    QString SchemeName;
    int SchemeMode;

    for (int i = 0; i < SchemeCount; i++) {
        SchemeGroup.sprintf("Scheme %d", i);
        cfg->setGroup(SchemeGroup);

        SchemeName = cfg->readEntry("Description", SchemeGroup);
        SchemeMode = cfg->readNumEntry("Mode", -1);

        schemeMode[i] = SchemeMode;
        if (SchemeMode == -1) {
            schemeID[i] = modesPopup->insertItem(SchemeName);
            modesPopup->setItemChecked(schemeID[i], i == Scheme);
        } else {
            schemeID[i] = schemesPopup->at(SchemeMode)->insertItem(SchemeName);
            schemesPopup->at(SchemeMode)->
                setItemChecked(schemeID[i], i == Scheme);
            modesPopup->setItemEnabled(modeID[SchemeMode], TRUE);
        }
    }

    RESTORE_CONFIG_GROUP( cfg, oldgroup );

    APP_CONFIG_END( cfg );
    return SchemeCount;
}
Beispiel #10
0
ThemeDemo::ThemeDemo()
    : QMainWindow(0, "Toolbar Demo")
{

	appFont = QApplication::font();

	//建立动作
	QAction *fileNewAction, *fileOpenAction, *fileSaveAction,
		*fileSaveAsAction, *filePrintAction, *fileCloseAction,
		*fileQuitAction;
	fileNewAction = new QAction( "New", tr("新建(&N)"), 
		CTRL+Key_N, this, "new" );
	connect( fileNewAction, SIGNAL( activated() ) ,this, SLOT( newDoc()));
	fileOpenAction = new QAction( "Open File", QPixmap( fileopen ), 
		tr("打开(&O)"), CTRL+Key_O, this, "open" );
	connect( fileOpenAction, SIGNAL( activated() ) , this, SLOT( load() ) );
	QMimeSourceFactory::defaultFactory()->setPixmap( "fileopen",
		QPixmap( fileopen ) );
	fileOpenAction->setWhatsThis( tr(fileOpenText) );

	fileSaveAction = new QAction( "Save File", QPixmap( filesave ), 
		tr("保存(&S)"), CTRL+Key_S, this, "save" );
	connect( fileSaveAction, SIGNAL( activated() ) , this, SLOT( save() ) );
	fileSaveAction->setWhatsThis( tr(fileSaveText) );

	fileSaveAsAction = new QAction( "Save File As", tr("保存为(&s)..."), 
		0,  this, "save as" );
	connect( fileSaveAsAction, SIGNAL(activated()),this,SLOT( saveAs() ));
	fileSaveAsAction->setWhatsThis( tr(fileSaveText) );
	filePrintAction = new QAction( "Print File", QPixmap( fileprint ), 
		tr("打印(&P)"), CTRL+Key_P, this, "print" );
	connect( filePrintAction, SIGNAL(activated()) , this, SLOT(print()));
	filePrintAction->setWhatsThis( tr(filePrintText) );

	fileCloseAction = new QAction( "Close", tr("关闭(&C)"), CTRL+Key_W, 
		this, "close" );
	connect( fileCloseAction, SIGNAL(activated()) , this, SLOT(close()) );

	fileQuitAction = new QAction( "Quit", tr("退出(&Q)"), CTRL+Key_Q, 
		this, "quit" );
	connect(fileQuitAction,SIGNAL(activated()),qApp,SLOT(closeAllWindows()));


	//建立按钮条
	QToolBar* fileTools = new QToolBar( this, "file operations" );
	fileTools->setLabel( "File Operations" );
	fileOpenAction->addTo( fileTools );
	fileSaveAction->addTo( fileTools );
	filePrintAction->addTo( fileTools );
	(void)QWhatsThis::whatsThisButton( fileTools );


	//建立文件菜单
	QPopupMenu * file = new QPopupMenu( this );
	menuBar()->insertItem( tr("文件(&F)"), file );
	fileNewAction->addTo( file );
	fileOpenAction->addTo( file );
	fileSaveAction->addTo( file );
	fileSaveAsAction->addTo( file );
	file->insertSeparator();
	filePrintAction->addTo( file );
	file->insertSeparator();
	fileCloseAction->addTo( file );
	fileQuitAction->addTo( file );

	//建立Style菜单
	QPopupMenu *style = new QPopupMenu( this );
	style->setCheckable( TRUE );
	menuBar()->insertItem( tr("风格(&S)") , style );
	sMetal = style->insertItem( "&Metal", this, SLOT( styleMetal() ) );
	sWood = style->insertItem( "&Norwegian Wood", this, SLOT( styleWood() ) );
	sPlatinum = style->insertItem( "&Platinum" , this ,SLOT( stylePlatinum() ) );
	sWindows = style->insertItem( "&Windows", this, SLOT( styleWindows() ) );
	sCDE = style->insertItem( "&CDE", this, SLOT( styleCDE() ) );
	sMotif = style->insertItem( "M&otif", this, SLOT( styleMotif() ) );
	sMotifPlus = style->insertItem( "Motif P&lus", this, SLOT( styleMotifPlus() ) );

	//建立帮助菜单
	QPopupMenu * help = new QPopupMenu( this );
	menuBar()->insertSeparator();
	menuBar()->insertItem( tr("帮助(&H)"), help );
	help->insertItem( tr("关于(&A)"), this, SLOT(about()), Key_F1 );
	help->insertItem( tr("关于 &Qt"), this, SLOT(aboutQt()) );
	help->insertSeparator();
	help->insertItem(tr("这是什么?"),this,SLOT(whatsThis()),SHIFT+Key_F1);


	QMultiLineEdit *e = new QMultiLineEdit( this, "editor" );
	e->setFocus();
	setCentralWidget( e );
	statusBar()->message( tr("准备就绪"), 2000 );
	resize( 400, 400 );

}
Beispiel #11
0
Themes::Themes( QWidget *parent, const char *name, WFlags f )
    : QMainWindow( parent, name, f )
{
    appFont = QApplication::font();
    tabwidget = new QTabWidget( this );

    tabwidget->addTab( new ButtonsGroups( tabwidget ), "Buttons/Groups" );
    QHBox *hbox = new QHBox( tabwidget );
    hbox->setMargin( 5 );
    (void)new LineEdits( hbox );
    (void)new ProgressBar( hbox );
    tabwidget->addTab( hbox, "Lineedits/Progressbar" );
    tabwidget->addTab( new ListBoxCombo( tabwidget ), "Listboxes/Comboboxes" );
    tabwidget->addTab( new CheckLists( tabwidget ), "Listviews" );
    tabwidget->addTab( new RangeControls( tabwidget ), "Rangecontrols" );
    tabwidget->addTab( new MyRichText( tabwidget ), "Fortune" );

    setCentralWidget( tabwidget );

    QPopupMenu *style = new QPopupMenu( this );
    style->setCheckable( TRUE );
    menuBar()->insertItem( "&Style" , style );

    style->setCheckable( TRUE );
    QActionGroup *ag = new QActionGroup( this, 0 );
    ag->setExclusive( TRUE );
    QSignalMapper *styleMapper = new QSignalMapper( this );
    connect( styleMapper, SIGNAL( mapped( const QString& ) ), this, SLOT( makeStyle( const QString& ) ) );
    QStringList list = QStyleFactory::keys();
    list.sort();
#ifndef QT_NO_STYLE_WINDOWS
    list.insert(list.begin(), "Norwegian Wood");
    list.insert(list.begin(), "Metal");
#endif
    QDict<int> stylesDict( 17, FALSE );
    for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
	QString styleStr = *it;
	QString styleAccel = styleStr;
	if ( stylesDict[styleAccel.left(1)] ) {
	    for ( uint i = 0; i < styleAccel.length(); i++ ) {
		if ( !stylesDict[styleAccel.mid( i, 1 )] ) {
		    stylesDict.insert(styleAccel.mid( i, 1 ), (const int *)1);
		    styleAccel = styleAccel.insert( i, '&' );
		    break;
		}
	    }
	} else {
	    stylesDict.insert(styleAccel.left(1), (const int *)1);
	    styleAccel = "&"+styleAccel;
	}
	QAction *a = new QAction( styleStr, QIconSet(), styleAccel, 0, ag, 0, ag->isExclusive() );
	connect( a, SIGNAL( activated() ), styleMapper, SLOT(map()) );
	styleMapper->setMapping( a, a->text() );
    }
    ag->addTo(style);
    style->insertSeparator();
    style->insertItem("&Quit", qApp, SLOT( quit() ), CTRL | Key_Q );

    QPopupMenu * help = new QPopupMenu( this );
    menuBar()->insertSeparator();
    menuBar()->insertItem( "&Help", help );
    help->insertItem( "&About", this, SLOT(about()), Key_F1);
    help->insertItem( "About &Qt", this, SLOT(aboutQt()));

#ifndef QT_NO_STYLE_WINDOWS
    qApp->setStyle( new NorwegianWoodStyle );
#endif
}
Beispiel #12
0
void kdvi::makeMenuBar()
{
    if (menuBar) delete menuBar;
    menuBar = new KMenuBar( this );
    CHECK_PTR( menuBar );

    QPopupMenu *p = new QPopupMenu;
    CHECK_PTR( p );

    m_fn = p->insertItem( i18n("&New"),	this, SLOT(fileNew()) );
    m_fo = p->insertItem( i18n("&Open ..."),	this, SLOT(fileOpen()) );

    recentmenu = new QPopupMenu;
    CHECK_PTR( recentmenu );

    connect( recentmenu, SIGNAL(activated(int)), SLOT(openRecent(int)) );

    m_fr = p->insertItem( i18n("Open &recent"),	recentmenu );

    m_fp = p->insertItem( i18n("&Print ..."),	this, SLOT(filePrint()));
    m_fx = p->insertItem( i18n("E&xit"), this, SLOT(fileExit()));

    m_f = p;
    menuBar->insertItem( i18n("&File"), p, -2 );

    p = new QPopupMenu;
    CHECK_PTR( p );
    m_vi = p->insertItem( i18n("Zoom &in"),	dviwin, SLOT(prevShrink()) );
    m_vo = p->insertItem( i18n("Zoom &out"),	dviwin, SLOT(nextShrink()) );
    m_vf = p->insertItem( i18n("&Fit to page"),	this, SLOT(viewFitPage()) );
    m_vw = p->insertItem( i18n("Fit to page &width"),	this, SLOT(viewFitPageWidth()));
    p->insertSeparator();
    m_vr = p->insertItem( i18n("&Redraw page"),	dviwin, SLOT(drawPage()) );

    m_v = p;
    menuBar->insertItem( i18n("&View"), p, -2 );

    p = new QPopupMenu;
    CHECK_PTR( p );
    m_pp = p->insertItem( i18n("&Previous"),	dviwin, SLOT(prevPage()) );
    m_pn = p->insertItem( i18n("&Next"),		dviwin, SLOT(nextPage()) );
    m_pf = p->insertItem( i18n("&First"),	dviwin, SLOT(firstPage()) );
    m_pl = p->insertItem( i18n("&Last"),		dviwin, SLOT(lastPage()) );
    m_pg = p->insertItem( i18n("&Go to ..."),	this,   SLOT(pageGoto()) );

    m_p = p;
    menuBar->insertItem( i18n("&Page"), p, -2 );

    p = new QPopupMenu;
    CHECK_PTR( p );
    p->setCheckable( TRUE );
    m_op = p->insertItem( i18n("&Preferences ..."), this, SLOT(optionsPreferences()));
    m_ok = p->insertItem( i18n("&Keys ..."), this, SLOT(configKeys()));
    p->insertSeparator();
    m_of = p->insertItem( i18n("Make PK-&fonts"), this, SLOT(toggleMakePK()) );
    p->setItemChecked( m_of, makepk );
    m_o0 = p->insertItem( i18n("Show PS"), this, SLOT(toggleShowPS()));
    p->setItemChecked( m_o0, showPS );
    m_om = p->insertItem( i18n("Show &Menubar"), this, SLOT(toggleShowMenubar()) );
    p->setItemChecked( m_om, !hideMenubar );
    m_ob = p->insertItem( i18n("Show &Buttons"), this, SLOT(toggleShowButtons()) );
    p->setItemChecked( m_ob, !hideButtons );
    m_ot = p->insertItem( i18n("Show Page Lis&t"), this, SLOT(toggleVertToolbar()) );
    p->setItemChecked( m_ol, vertToolbar );
    m_os = p->insertItem( i18n("Show &Statusbar"), this, SLOT(toggleShowStatusbar()) );
    p->setItemChecked( m_os, !hideStatusbar );
    m_ol = p->insertItem( i18n("Show Scro&llbars"), this, SLOT(toggleShowScrollbars()) );
    p->setItemChecked( m_ol, !hideScrollbars );

    m_o = p;
    menuBar->insertItem( i18n("&Options"), p, -2 );
    optionsmenu = p;

    menuBar->insertSeparator();

    QPopupMenu *help = kapp->getHelpMenu(true, QString(i18n("DVI Viewer"))
                                         + " " + KDVI_VERSION
                                         + i18n("\n\nby Markku Hihnala")
                                         + " ([email protected])");

    m_h = p;
    menuBar->insertItem( i18n("&Help"), help );
    if ( hideMenubar )	menuBar->hide();
    setMenu( menuBar );
}