Пример #1
0
void Decoration::init()
    {
    createMainWidget();
    widget()->setEraseColor( red );
    widget()->installEventFilter( this );
    if( isCloseable())
	{
        button = new TQPushButton( widget());
        button->show();
        button->setCursor( tqarrowCursor );
	button->move( 0, 0 );
        connect( button, TQT_SIGNAL( clicked()), TQT_SLOT( closeWindow()));
	TQToolTip::add( button, "Zelva Mana" );
	}
    }
Пример #2
0
/** Adds the buttons for one side of the title bar, based on the spec
 * string; see the KWinInternal::KDecoration class, methods
 * titleButtonsLeft and titleBUttonsRight. */
void NextClient::addButtons(QBoxLayout* titleLayout, const QString& spec)
{
    for (unsigned int i=0; i<spec.length(); i++) {
        switch (spec[i].latin1()) {
        case 'A':
            if (isMaximizable()) {
                button[MAXIMIZE_IDX] =
                    new NextButton(this, "maximize", maximize_bits, 10, 10,
                                   i18n("Maximize"), LeftButton|MidButton|RightButton);
                titleLayout->addWidget( button[MAXIMIZE_IDX] );
                connect( button[MAXIMIZE_IDX], SIGNAL(clicked()),
                         this, SLOT(maximizeButtonClicked()) );
            }
            break;

        case 'H':
	    if (providesContextHelp()) {
		button[HELP_IDX] = new NextButton(this,
			"help", question_bits, 10, 10, i18n("Help"));
		titleLayout->addWidget( button[HELP_IDX] );
		connect( button[HELP_IDX], SIGNAL(clicked()),
			 this, SLOT(showContextHelp()) );
	    }
            break;

        case 'I':
            if (isMinimizable()) {
                button[ICONIFY_IDX] =
                    new NextButton(this, "iconify", iconify_bits, 10, 10,
                                   i18n("Minimize"));
                titleLayout->addWidget( button[ICONIFY_IDX] );
                connect( button[ICONIFY_IDX], SIGNAL(clicked()),
                         this, SLOT(minimize()) );
            }
            break;

        case 'M':
            button[MENU_IDX] =
                new NextButton(this, "menu", NULL, 10, 10, i18n("Menu"), LeftButton|RightButton);
            titleLayout->addWidget( button[MENU_IDX] );
            // NOTE DIFFERENCE: capture pressed(), not clicked()
            connect( button[MENU_IDX], SIGNAL(pressed()),
                     this, SLOT(menuButtonPressed()) );
            break;

        case 'L':
            button[SHADE_IDX] =
                new NextButton(this, "shade", NULL, 0, 0, i18n("Shade"));
            titleLayout->addWidget( button[SHADE_IDX] );
            connect( button[SHADE_IDX], SIGNAL(clicked()),
                     this, SLOT(shadeClicked()) );
            // NOTE DIFFERENCE: set the pixmap separately (2 states)
	    shadeChange();
            break;
	    
        case 'S':
            button[STICKY_IDX] =
                new NextButton(this, "sticky", NULL, 0, 0, i18n("On all desktops"));
            titleLayout->addWidget( button[STICKY_IDX] );
            connect( button[STICKY_IDX], SIGNAL(clicked()),
                     this, SLOT(toggleOnAllDesktops()) );
            // NOTE DIFFERENCE: set the pixmap separately (2 states)
	    desktopChange();
            break;

	case 'F':
            button[ABOVE_IDX] = new NextButton(this, "above", NULL, 0, 0, "");
            titleLayout->addWidget( button[ABOVE_IDX] );
            connect( button[ABOVE_IDX], SIGNAL(clicked()),
                     this, SLOT(aboveClicked()) );
	    connect(this, SIGNAL(keepAboveChanged(bool)), 
		    SLOT(keepAboveChange(bool)));
	    keepAboveChange(keepAbove());
	    break;
	    
	case 'B':
            button[BELOW_IDX] = new NextButton(this, "below", NULL, 0, 0, "");
            titleLayout->addWidget( button[BELOW_IDX] );
            connect( button[BELOW_IDX], SIGNAL(clicked()),
                     this, SLOT(belowClicked()) );
	    connect(this, SIGNAL(keepBelowChanged(bool)), 
		    SLOT(keepBelowChange(bool)));
	    keepBelowChange(keepBelow());
	    break;
        
	case 'X':
            if (isCloseable()) {
		button[CLOSE_IDX] =
		    new NextButton(this, "close", close_bits, 10, 10,
				   i18n("Close"));
		titleLayout->addWidget(button[CLOSE_IDX]);
		connect(button[CLOSE_IDX], SIGNAL(clicked()),
			 this, SLOT(closeWindow()));
            }
            break;

	case 'R':
            if (mustDrawHandle()) {
		button[RESIZE_IDX] =
		    new NextButton(this, "resize", resize_bits, 10, 10,
				   i18n("Resize"));
		titleLayout->addWidget(button[RESIZE_IDX]);
		// NOTE DIFFERENCE: capture pressed(), not clicked()
		connect(button[RESIZE_IDX], SIGNAL(pressed()),
			 this, SLOT(resizePressed()));
            }
	    break;
        case '_':
            // TODO: Add spacer handling
            break;

        default:
            kdDebug() << " Can't happen: unknown button code "
                      << QString(spec[i]);
            break;
        }
    }
}
Пример #3
0
void Manager::createTitle()
{
   leftButtonList_.clear();
   rightButtonList_.clear();

   TQString buttons;

   if (options()->customButtonPositions())
      buttons = options()->titleButtonsLeft() + "|" +
                options()->titleButtonsRight();
   else
      buttons = "XSH|IA";

   TQPtrList<Button> *buttonList = &leftButtonList_;

   for (unsigned int i = 0; i < buttons.length(); ++i)
   {
      Button * tb = NULL;

      switch (buttons[i].latin1())
      {
         case 'S': // Sticky
            tb = new StickyButton(widget());
            connect(this, TQT_SIGNAL(stickyChanged(bool)),
                    tb, TQT_SLOT(setOn(bool)));
            connect(tb, TQT_SIGNAL(toggleSticky()), this, TQT_SLOT(slotToggleSticky()));
            emit(stickyChanged(isOnAllDesktops()));
            break;

         case 'H': // Help
            if (providesContextHelp())
            {
               tb = new HelpButton(widget());
               connect(tb, TQT_SIGNAL(help()), this, TQT_SLOT(showContextHelp()));
            }
            break;

         case 'I': // Minimize
            if (isMinimizable())
            {
               tb = new IconifyButton(widget());
               connect(tb, TQT_SIGNAL(iconify()), this, TQT_SLOT(minimize()));
            }
            break;

         case 'A': // Maximize
            if (isMaximizable())
            {
               tb = new MaximiseButton(widget());
               connect(tb, TQT_SIGNAL(maximizeClicked(ButtonState)),
                       this, TQT_SLOT(slotMaximizeClicked(ButtonState)));
               connect(this, TQT_SIGNAL(maximizeChanged(bool)),
                       tb, TQT_SLOT(setOn(bool)));
               emit(maximizeChanged(maximizeMode() == MaximizeFull));
            }
            break;

         case 'F': // Above
            tb = new AboveButton(widget());
            connect(tb, TQT_SIGNAL(above()), this, TQT_SLOT(slotAbove()));
            break;

         case 'B': // Lower
            tb = new LowerButton(widget());
            connect(tb, TQT_SIGNAL(lower()), this, TQT_SLOT(slotLower()));
            break;

         case 'X': // Close
            if (isCloseable())
            {
               tb = new CloseButton(widget());
               connect(tb, TQT_SIGNAL(closeWindow()), this, TQT_SLOT(closeWindow()));
            }
            break;

         case '|':
            buttonList = &rightButtonList_;
            break;
      }

      if (tb != NULL)
      {
         connect(this, TQT_SIGNAL(activeChanged(bool)), tb, TQT_SLOT(setActive(bool)));
         buttonList->append(tb);
      }
   }
Пример #4
0
BOOL LLAlertDialog::hasTitleBar() const
{
	return (getCurrentTitle() != "" && getCurrentTitle() != " ")	// has title
			|| isMinimizeable()
			|| isCloseable();
}
Пример #5
0
void KCommonDecoration::addButtons(ButtonContainer &btnContainer, const QString& s, bool isLeft)
{
    if (s.length() > 0) {
        for (unsigned n=0; n < s.length(); n++) {
            KCommonDecorationButton *btn = 0;
            switch (s[n]) {
              case 'M': // Menu button
                  if (!m_button[MenuButton]){
                      btn = createButton(MenuButton);
                      if (!btn) break;
                      btn->setTipText(i18n("Menu") );
                      btn->setRealizeButtons(LeftButton|RightButton);
                      connect(btn, SIGNAL(pressed()), SLOT(menuButtonPressed()));
                      connect(btn, SIGNAL(released()), this, SLOT(menuButtonReleased()));

                      m_button[MenuButton] = btn;
                  }
                  break;
              case 'S': // OnAllDesktops button
                  if (!m_button[OnAllDesktopsButton]){
                      btn = createButton(OnAllDesktopsButton);
                      if (!btn) break;
                      const bool oad = isOnAllDesktops();
                      btn->setTipText(oad?i18n("Not on all desktops"):i18n("On all desktops") );
                      btn->setToggleButton(true);
                      btn->setOn( oad );
                      connect(btn, SIGNAL(clicked()), SLOT(toggleOnAllDesktops()));

                      m_button[OnAllDesktopsButton] = btn;
                  }
                  break;
              case 'H': // Help button
                  if ((!m_button[HelpButton]) && providesContextHelp()){
                      btn = createButton(HelpButton);
                      if (!btn) break;
                      btn->setTipText(i18n("Help") );
                      connect(btn, SIGNAL(clicked()), SLOT(showContextHelp()));

                      m_button[HelpButton] = btn;
                  }
                  break;
              case 'I': // Minimize button
                  if ((!m_button[MinButton]) && isMinimizable()){
                      btn = createButton(MinButton);
                      if (!btn) break;
                      btn->setTipText(i18n("Minimize") );
                      connect(btn, SIGNAL(clicked()), SLOT(minimize()));

                      m_button[MinButton] = btn;
                  }
                  break;
              case 'A': // Maximize button
                  if ((!m_button[MaxButton]) && isMaximizable()){
                      btn = createButton(MaxButton);
                      if (!btn) break;
                      btn->setRealizeButtons(LeftButton|MidButton|RightButton);
                      const bool max = maximizeMode()==MaximizeFull;
                      btn->setTipText(max?i18n("Restore"):i18n("Maximize") );
                      btn->setToggleButton(true);
                      btn->setOn( max );
                      connect(btn, SIGNAL(clicked()), SLOT(slotMaximize()));

                      m_button[MaxButton] = btn;
                  }
                  break;
              case 'X': // Close button
                  if ((!m_button[CloseButton]) && isCloseable()){
                      btn = createButton(CloseButton);
                      if (!btn) break;
                      btn->setTipText(i18n("Close") );
                      connect(btn, SIGNAL(clicked()), SLOT(closeWindow()));

                      m_button[CloseButton] = btn;
                  }
                  break;
              case 'F': // AboveButton button
                  if (!m_button[AboveButton]){
                      btn = createButton(AboveButton);
                      if (!btn) break;
                      bool above = keepAbove();
                      btn->setTipText(above?i18n("Do not keep above others"):i18n("Keep above others") );
                      btn->setToggleButton(true);
                      btn->setOn( above );
                      connect(btn, SIGNAL(clicked()), SLOT(slotKeepAbove()));

                      m_button[AboveButton] = btn;
                  }
                  break;
              case 'B': // BelowButton button
                  if (!m_button[BelowButton]){
                      btn = createButton(BelowButton);
                      if (!btn) break;
                      bool below = keepBelow();
                      btn->setTipText(below?i18n("Do not keep below others"):i18n("Keep below others") );
                      btn->setToggleButton(true);
                      btn->setOn( below );
                      connect(btn, SIGNAL(clicked()), SLOT(slotKeepBelow()));

                      m_button[BelowButton] = btn;
                  }
                  break;
              case 'L': // Shade button
                  if ((!m_button[ShadeButton]) && isShadeable()){
                      btn = createButton(ShadeButton);
                      if (!btn) break;
                      bool shaded = isSetShade();
                      btn->setTipText(shaded?i18n("Unshade"):i18n("Shade") );
                      btn->setToggleButton(true);
                      btn->setOn( shaded );
                      connect(btn, SIGNAL(clicked()), SLOT(slotShade()));

                      m_button[ShadeButton] = btn;
                  }
                  break;
              case '_': // Spacer item
                  btnContainer.append(0);
            }


            if (btn) {
                btn->setLeft(isLeft);
                btn->setSize(QSize(layoutMetric(LM_ButtonWidth, true, btn),layoutMetric(LM_ButtonHeight, true, btn)) );
                btn->show();
                btnContainer.append(btn);
            }

        }
    }
}