示例#1
0
void KexiItemMenu::update(KexiPart::Info* partInfo, KexiPart::Item* partItem)
{
    clear();
    QString title_text(partItem->name());
    if (partInfo && !partInfo->instanceCaption().isEmpty()) {
        title_text += (" : " + partInfo->instanceCaption());
    }
    addTitle(KIcon(partInfo->itemIconName()), title_text);

    if (m_actionCollection->action("open_object")
            && m_actionCollection->action("open_object")->isEnabled()
            && partItem && (partInfo->supportedViewModes() & Kexi::DataViewMode)) {
        addAction("open_object");
    }
    if (m_actionCollection->action("design_object")
            && m_actionCollection->action("design_object")->isEnabled()
            && partItem && (partInfo->supportedViewModes() & Kexi::DesignViewMode)) {
        addAction("design_object");
    }
    if (m_actionCollection->action("editText_object")
            && m_actionCollection->action("editText_object")->isEnabled()
            && partItem && (partInfo->supportedViewModes() & Kexi::TextViewMode)) {
        addAction("editText_object");
    }
    addSeparator();

#ifdef KEXI_SHOW_UNIMPLEMENTED
    //! @todo plugSharedAction("edit_cut", m_itemMenu);
    //! @todo plugSharedAction("edit_copy", m_itemMenu);
    //! @todo addSeparator();
#endif
    bool addSep = false;
    if (partItem && partInfo->isExecuteSupported()) {
        addAction("data_execute");
        addSep = true;
    }
    if (partItem && partInfo->isDataExportSupported()) {
        addAction("export_object");
        addSep = true;
    }
    if (addSep)
        addSeparator();

#ifndef KEXI_NO_QUICK_PRINTING
    if (partItem && partInfo->isPrintingSupported())
        addAction("print_object");
    if (partItem && partInfo->isPrintingSupported())
        addAction("pageSetupForObject");
    if (m_actionCollection->action("edit_rename") || m_actionCollection->action("edit_delete"))
        addSeparator();
#endif
    addAction("edit_rename");
    addAction("edit_delete");
}
void AlbumCoverChoiceController::ShowCover(const Song& song) {
  QDialog* dialog = new QDialog(this);
  dialog->setAttribute(Qt::WA_DeleteOnClose, true);

  // Use Artist - Album as the window title
  QString title_text(song.albumartist());
  if (title_text.isEmpty()) title_text = song.artist();

  if (!song.album().isEmpty()) title_text += " - " + song.album();

  dialog->setWindowTitle(title_text);

  QLabel* label = new QLabel(dialog);
  label->setPixmap(AlbumCoverLoader::TryLoadPixmap(
      song.art_automatic(), song.art_manual(), song.url().toLocalFile()));

  dialog->resize(label->pixmap()->size());
  dialog->show();
}
void AlbumCoverChoiceController::ShowCover(const Song& song) {
  QDialog* dialog = new QDialog(this);
  dialog->setAttribute(Qt::WA_DeleteOnClose, true);

  // Use (Album)Artist - Album as the window title
  QString title_text(song.effective_albumartist());
  if (!song.effective_album().isEmpty())
    title_text += " - " + song.effective_album();

  QLabel* label = new QLabel(dialog);
  label->setPixmap(AlbumCoverLoader::TryLoadPixmap(
      song.art_automatic(), song.art_manual(), song.url().toLocalFile()));

  // add (WxHpx) to the title before possibly resizing
  title_text += " (" + QString::number(label->pixmap()->width()) + "x" +
                QString::number(label->pixmap()->height()) + "px)";

  // if the cover is larger than the screen, resize the window
  // 85% seems to be enough to account for title bar and taskbar etc.
  QDesktopWidget desktop;
  int current_screen = desktop.screenNumber(this);
  int desktop_height = desktop.screenGeometry(current_screen).height();
  int desktop_width = desktop.screenGeometry(current_screen).width();

  // resize differently if monitor is in portrait mode
  if (desktop_width < desktop_height) {
    const int new_width = (double)desktop_width * 0.95;
    if (new_width < label->pixmap()->width()) {
      label->setPixmap(
          label->pixmap()->scaledToWidth(new_width, Qt::SmoothTransformation));
    }
  } else {
    const int new_height = (double)desktop_height * 0.85;
    if (new_height < label->pixmap()->height()) {
      label->setPixmap(label->pixmap()->scaledToHeight(
          new_height, Qt::SmoothTransformation));
    }
  }

  dialog->setWindowTitle(title_text);
  dialog->setFixedSize(label->pixmap()->size());
  dialog->show();
}
示例#4
0
void re_title()
{
 char bob[40];
 make_title(bob);
 title_text(bob);
}
示例#5
0
RenderQueue* BREW::CreateWindowDrawable( SharedPtr<const Window> window ) const {
	RenderQueue* queue( new RenderQueue );
	sf::Color background_color( GetProperty<sf::Color>( "BackgroundColor", window ) );
	sf::Color border_color( GetProperty<sf::Color>( "BorderColor", window ) );
	sf::Color title_background_color( GetProperty<sf::Color>( "TitleBackgroundColor", window ) );
	sf::Color title_text_color( GetProperty<sf::Color>( "Color", window ) );
	int border_color_shift( GetProperty<int>( "BorderColorShift", window ) );
	float border_width( GetProperty<float>( "BorderWidth", window ) );
	float title_padding( GetProperty<float>( "TitlePadding", window ) );
	float shadow_distance( GetProperty<float>( "ShadowDistance", window ) );
	float handle_size( GetProperty<float>( "HandleSize", window ) );
	sf::Uint8 shadow_alpha( GetProperty<sf::Uint8>( "ShadowAlpha", window ) );
	unsigned int title_font_size( GetProperty<unsigned int>( "FontSize", window ) );
	const sf::Font& title_font( *GetResourceManager().GetFont( GetProperty<std::string>( "FontName", window ) ) );
	float title_size( GetFontLineHeight( title_font, title_font_size ) + 2 * title_padding );

	if( window->HasStyle( Window::SHADOW ) ) {
		// Shadow.
		sf::Color shadow_color( 0, 0, 0, shadow_alpha );

		sf::FloatRect shadow_rect(
			shadow_distance,
			shadow_distance,
			window->GetAllocation().width,
			window->GetAllocation().height
		);

		queue->Add(
			Renderer::Get().CreateRect(
				shadow_rect,
				shadow_color
			)
		);
	}

	if( window->HasStyle( Window::BACKGROUND ) ) {
		// Pane.
		queue->Add(
			Renderer::Get().CreatePane(
				sf::Vector2f( 0.f, 0.f ),
				sf::Vector2f( window->GetAllocation().width, window->GetAllocation().height ),
				border_width,
				background_color,
				border_color,
				border_color_shift
			)
		);
	}

	if( window->HasStyle( Window::RESIZE ) ) {
		queue->Add(
			Renderer::Get().CreateTriangle(
				sf::Vector2f( window->GetAllocation().width, window->GetAllocation().height - handle_size ),
				sf::Vector2f( window->GetAllocation().width - handle_size, window->GetAllocation().height ),
				sf::Vector2f( window->GetAllocation().width, window->GetAllocation().height ),
				title_background_color
			)
		);
	}


	if( !window->HasStyle( Window::TITLEBAR ) ) {
		title_size = 0;
	}

	if( title_size > 0 ) {
		queue->Add(
			Renderer::Get().CreateRect(
				sf::FloatRect(
					border_width + .1f,
					border_width + .1f,
					window->GetAllocation().width - 2 * border_width,
					title_size
				),
				title_background_color
			)
		);

		// Find out visible text, count in "...".
		float avail_width( window->GetAllocation().width - 2.f * border_width - 2.f * title_padding );

		sf::Text title_text( window->GetTitle(), title_font, title_font_size );

		if( title_text.getLocalBounds().width > avail_width ) {
			sf::Text dots( "...", title_font, title_font_size );
			const sf::String& title_string( window->GetTitle() );
			sf::String visible_title;

			avail_width = window->GetAllocation().width - 2.f * border_width - 2.f * title_padding - dots.getLocalBounds().width;

			for( std::size_t ch_index = 0; ch_index < title_string.getSize(); ++ch_index ) {
				avail_width -= static_cast<float>( title_font.getGlyph( title_string[ch_index], title_font_size, false ).advance );

				if( avail_width < 0.f ) {
					visible_title += "...";
					break;
				}

				visible_title += title_string[ch_index];
			}

			title_text.setString( visible_title );
		}

		// Calculate title text position.
		sf::Vector2f title_position(
			border_width + title_padding,
			border_width + title_size / 2.f - static_cast<float>( title_font_size ) / 2.f
		);

		title_text.setPosition( title_position );
		title_text.setColor( title_text_color );

		queue->Add( Renderer::Get().CreateText( title_text ) );
	}

	return queue;
}