Exemplo n.º 1
0
EditTools::EditTools(QWidget* parent)
  : QDockWidget(parent)
      {
      setObjectName("edit-tools");
      setWindowTitle(tr("Edit Mode Tools"));
      setAllowedAreas(Qt::DockWidgetAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea));

      QToolBar* tb = new QToolBar(tr("Edit Mode Tools"));
      tb->setIconSize(QSize(preferences.iconWidth, preferences.iconHeight));

      QToolButton* b = new QToolButton(this);
      QAction* a = getAction("hraster");
      a->setCheckable(true);
      b->setDefaultAction(a);
      b->setContextMenuPolicy(Qt::ActionsContextMenu);
      b->addAction(getAction("config-raster"));
      tb->addWidget(b);

      b = new QToolButton(this);
      a = getAction("vraster");
      a->setCheckable(true);
      b->setDefaultAction(a);
      b->setContextMenuPolicy(Qt::ActionsContextMenu);
      b->addAction(getAction("config-raster"));
      tb->addWidget(b);

      _editX  = new QDoubleSpinBox(this);
      _editX->setSuffix(tr("sp"));
      _editX->setRange(-99999, 99999);
      _editX->setSingleStep(.1);
      _editY  = new QDoubleSpinBox(this);
      _editY->setSuffix(tr("sp"));
      _editY->setRange(-99999, 99999);
      _editY->setSingleStep(.1);
      xLabel = new QLabel(tr("x:"), this);
      yLabel = new QLabel(tr("y:"), this);
      _localEdit = false;
      tb->addWidget(xLabel);
      tb->addWidget(_editX);
      tb->addWidget(yLabel);
      tb->addWidget(_editY);

      connect(_editX, SIGNAL(valueChanged(double)), SLOT(editXChanged(double)));
      connect(_editY, SIGNAL(valueChanged(double)), SLOT(editYChanged(double)));

      setWidget(tb);
      QWidget* w = new QWidget(this);
      setTitleBarWidget(w);
      titleBarWidget()->hide();
      }
Exemplo n.º 2
0
QToolButton* QuickButtonDisplay::actionButton(const char* objName, const char* icon, QString value) {
    QToolButton* toolButton = new QToolButton();
    toolButton->setIconSize(QSize(32, 32));
    toolButton->setObjectName(objName);
    toolButton->setIcon(QIcon(icon));
    toolButton->setText(value);
    toolButton->setToolTip(value);
    toolButton->setCursor(Qt::PointingHandCursor);
    toolButton->setContextMenuPolicy(Qt::CustomContextMenu);

    toolButton->setStyleSheet("QToolButton {"
                              "background: #242024;"
                              "}");

    connect(toolButton, SIGNAL(clicked()),
            toolBar, SLOT(quickButtonAction()));

    return toolButton;
}
Exemplo n.º 3
0
AMScanViewScanBar::AMScanViewScanBar(AMScanSetModel* model, int scanIndex, QWidget* parent)
	: QFrame(parent)
{
	model_ = model;
	scanIndex_ = scanIndex;

	setObjectName("AMScanViewScanBar");
	setStyleSheet("QFrame#AMScanViewScanBar { "
				  "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(81, 81, 81, 255), stop:0.494444 rgba(81, 81, 81, 255), stop:0.5 rgba(64, 64, 64, 255), stop:1 rgba(64, 64, 64, 255));"
				  "border-bottom: 1px solid black;"
				  "}");


	exclusiveModeOn_ = false;
	sourceButtons_.setExclusive(false);

	AMScan* source = model->scanAt(scanIndex_);


	// UI Setup:
	///////////////////////

	QHBoxLayout* hl = new QHBoxLayout();
	nameLabel_ = new QLabel();
	if(source)
		nameLabel_->setText(source->name() + QString(" #%1").arg(source->number()));
	nameLabel_->setStyleSheet("color: white;");
	hl->addWidget(nameLabel_);
	hl->addStretch(0);

	cramBar_ = new AMCramBarHorizontal();


	if(source) {
		for(int i=0; i<source->dataSourceCount(); i++) {
			QColor color = model->plotColor(scanIndex, i);

			QToolButton* sourceButton = new AMColoredTextToolButton(color); /// \todo special buttons, with lines underneath that show the line color / style, and differentiate 1D, 2D datasets.

			sourceButton->setMaximumHeight(18);
			sourceButton->setText(source->dataSourceAt(i)->name());	/// \todo description or name? both? name if description is empty?
			sourceButton->setCheckable(true);
			sourceButton->setChecked(model->isVisible(scanIndex, i));
			sourceButtons_.addButton(sourceButton, i);
			cramBar_->addWidget(sourceButton);
			// hide the button if this data source should be hidden from users:
			sourceButton->setHidden(model->isHiddenFromUsers(scanIndex, i));

			sourceButton->setContextMenuPolicy(Qt::CustomContextMenu);
			connect(sourceButton, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onDataSourceButtonRightClicked(QPoint)));
		}
	}

	hl->addWidget(cramBar_);
	hl->addStretch(1);

	hl->setContentsMargins(6, 0, 6, 0);
	hl->setSpacing(24);
	setLayout(hl);

	connect(model, SIGNAL(rowsInserted(QModelIndex, int, int)), this, SLOT(onRowInserted(QModelIndex,int,int)));
	connect(model, SIGNAL(rowsAboutToBeRemoved(QModelIndex, int, int)), this, SLOT(onRowAboutToBeRemoved(QModelIndex,int,int)));
	connect(model, SIGNAL(rowsRemoved(QModelIndex, int, int)), this, SLOT(onRowRemoved(QModelIndex,int,int)));
	connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(onModelDataChanged(QModelIndex,QModelIndex)));
	connect(model, SIGNAL(exclusiveDataSourceChanged(QString)), this, SLOT(onExclusiveDataSourceChanged(QString)));

	connect(&sourceButtons_, SIGNAL(buttonClicked(int)), this, SLOT(onSourceButtonClicked(int)));

	// connect(closeButton_, SIGNAL(clicked()), this, SLOT(onCloseButtonClicked()));

}
Exemplo n.º 4
0
void PlaylistWidget::init(PlayqueueModel* model)
{
    m_model    = model;
    m_view     = new PlaylistView(this, m_model);
    
    /* ------- menu & actions ------------------ */
    m_menu     = 0;
    
    m_actions->insert(PLAYQUEUE_JUMP_TO_TRACK, new QAction(QIcon(":/images/jump_to_32x32.png"),tr("Jump to track"), this));
    
    m_actions->insert(PLAYQUEUE_ADD_FILE, new QAction(QIcon(":/images/track-48x48.png"),tr("&Add media to playlist"), this));
    m_actions->insert(PLAYQUEUE_ADD_DIR, new QAction(QIcon(":/images/folder-48x48.png"),tr("&Add directory to playlist"), this));
    m_actions->insert(PLAYQUEUE_ADD_URL, new QAction(QIcon(":/images/media-url-48x48.png"),tr("&Add Url..."), this));
    m_actions->insert(PLAYQUEUE_CLEAR, new QAction(QIcon::fromTheme("edit-clear-list"), tr("&Clear playlist"), this));    
    m_actions->insert(PLAYQUEUE_EXPORT, new QAction(QIcon(":/images/save-32x32.png"), tr("&Export playlist to file"), this));
    m_actions->insert(PLAYQUEUE_AUTOSAVE, new QAction(QIcon(":/images/save-32x32.png"), tr("&Save playlist"), this));
    m_actions->insert(PLAYQUEUE_REMOVE_ITEM,new QAction(QIcon::fromTheme("edit-delete"),tr("&Remove media from playlist"), this));
    m_actions->insert(PLAYQUEUE_REMOVE_DUPLICATE,new QAction(QIcon(),tr("Remove duplicate"), this));
    
    m_actions->value(PLAYQUEUE_REMOVE_DUPLICATE)->setCheckable(true);
    m_actions->value(PLAYQUEUE_REMOVE_DUPLICATE)->setChecked( !SETTINGS()->_playqueueDuplicate );

    m_actions->insert(PLAYQUEUE_TRACK_LOVE, new QAction(QIcon(":/images/lastfm.png"), tr("Send LastFm love"), this));
    
    m_actions->insert(PLAYQUEUE_OPTION_SHOW_COVER, new QAction(tr("Show cover"), this));
    m_actions->value(PLAYQUEUE_OPTION_SHOW_COVER)->setCheckable(true);
    m_actions->value(PLAYQUEUE_OPTION_SHOW_COVER)->setChecked( SETTINGS()->_playqueueShowCover );

    m_actions->insert(PLAYQUEUE_OPTION_SHOW_RATING, new QAction(tr("Show rating"), this));
    m_actions->value(PLAYQUEUE_OPTION_SHOW_RATING)->setCheckable(true);
    m_actions->value(PLAYQUEUE_OPTION_SHOW_RATING)->setChecked( SETTINGS()->_playqueueShowRating );

    m_actions->insert(PLAYQUEUE_OPTION_SHOW_NUMBER, new QAction(tr("Show track number"), this));
    m_actions->value(PLAYQUEUE_OPTION_SHOW_NUMBER)->setCheckable(true);
    m_actions->value(PLAYQUEUE_OPTION_SHOW_NUMBER)->setChecked( SETTINGS()->_playqueueShowNumber );
    

    /* ------- playqueue sorter widget --------- */
    m_sort_menu = new QMenu();
    ui_sort_widget = 0;

    QToolButton *button = new QToolButton();
    button->setText(tr("sort"));
    button->setAutoRaise(true);
    button->setToolTip(tr("Sort playqueue"));
    button->setMenu(m_sort_menu);
    button->setContextMenuPolicy( Qt::CustomContextMenu );
    connect( button, SIGNAL( clicked ( bool ) ), this, SLOT( slot_show_sortmenu() ) );

    /* ------- playqueue filter widget --------- */
    ui_playqueue_filter = new ExLineEdit();
    ui_playqueue_filter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    ui_playqueue_filter->setInactiveText(tr("Playqueue filter"));
    
    ui_filter_container = new QWidget(this);
    ui_filter_container->setMinimumHeight(30);
  
    QHBoxLayout* h1 = new QHBoxLayout(ui_filter_container);
    h1->setSpacing(0);
    h1->setContentsMargins(2, 2, 2, 2);   
    h1->addWidget(ui_playqueue_filter); 
    h1->addWidget(button); 


    /* ------- main layout --------------------- */
    QVBoxLayout *main_layout = new QVBoxLayout(this);
    main_layout->setSpacing(0);
    main_layout->setContentsMargins(0, 0, 0, 0);
    main_layout->addWidget(ui_filter_container);
    main_layout->addWidget(m_view);
    
    /* ------- actions ------------------------- */
    m_action_show_filter = new QAction(QIcon(),tr("Show filter"), this);
    m_action_show_filter->setCheckable(true);    
    m_action_show_filter->setChecked( SETTINGS()->_playqueueShowFilter );
    
    m_action_stop_after = new QAction(QIcon(),tr("Stop after this track"), this);
    m_action_stop_after->setCheckable(true);
    
    /* ------- signals connection -------------- */
    connect(m_model, SIGNAL(updated()), this, SLOT(slot_update_playqueue_status_info()));

    connect(m_actions->value(PLAYQUEUE_TRACK_LOVE), SIGNAL(triggered()), m_view, SLOT(slot_lastfm_love()));    
    connect(m_actions->value(PLAYQUEUE_JUMP_TO_TRACK), SIGNAL(triggered()), m_view, SLOT(jumpToCurrentlyPlayingTrack()));
    
    connect(m_actions->value(PLAYQUEUE_REMOVE_DUPLICATE), SIGNAL(triggered()), SLOT(slot_removeduplicate_changed()));
    connect(m_actions->value(PLAYQUEUE_CLEAR), SIGNAL(triggered()), SLOT(slot_playqueue_clear()));
    
    connect(m_actions->value(PLAYQUEUE_ADD_FILE), SIGNAL(triggered()), SLOT(slot_add_to_playqueue()));
    connect(m_actions->value(PLAYQUEUE_ADD_DIR), SIGNAL(triggered()), SLOT(slot_add_to_playqueue()));
    connect(m_actions->value(PLAYQUEUE_ADD_URL), SIGNAL(triggered()), SLOT(slot_add_to_playqueue()));
    connect(m_actions->value(PLAYQUEUE_EXPORT), SIGNAL(triggered()), SLOT(slot_playqueue_export()));
    connect(m_actions->value(PLAYQUEUE_AUTOSAVE), SIGNAL(triggered()), SLOT(slot_playqueue_save_auto()));
    connect(m_actions->value(PLAYQUEUE_REMOVE_ITEM), SIGNAL(triggered()), this, SLOT(slot_remove_selected_tracks()));

    connect(ui_playqueue_filter, SIGNAL(textfield_entered()),this, SLOT(slot_update_filter()));

    connect(m_action_show_filter, SIGNAL(triggered()), this, SLOT(slot_show_filter_triggered()));
    connect(m_action_stop_after, SIGNAL(triggered()), this, SLOT(slot_stop_after_triggered()));

    /* ------- init state ---------------------- */
    ui_filter_container->setVisible( SETTINGS()->_playqueueShowFilter );
}
Exemplo n.º 5
0
MainWindow::MainWindow(FmPath* path):
  QMainWindow(),
  fileLauncher_(this) {

  Settings& settings = static_cast<Application*>(qApp)->settings();
  setAttribute(Qt::WA_DeleteOnClose);
  // setup user interface
  ui.setupUi(this);

  // FIXME: why popup menus over back/forward buttons don't work when they're disabled?
  QToolButton* forwardButton = static_cast<QToolButton*>(ui.toolBar->widgetForAction(ui.actionGoForward));
  forwardButton->setContextMenuPolicy(Qt::CustomContextMenu);
  connect(forwardButton, SIGNAL(customContextMenuRequested(QPoint)), SLOT(onBackForwardContextMenu(QPoint)));
  QToolButton* backButton = static_cast<QToolButton*>(ui.toolBar->widgetForAction(ui.actionGoBack));
  backButton->setContextMenuPolicy(Qt::CustomContextMenu);
  connect(backButton, SIGNAL(customContextMenuRequested(QPoint)), SLOT(onBackForwardContextMenu(QPoint)));
  /*
  QToolButton* btn = new QToolButton();
  btn->setArrowType(Qt::DownArrow);
  btn->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed);
  ui.toolBar->insertWidget(ui.actionGoUp, btn);
  */

  // tabbed browsing interface
  ui.tabBar->setDocumentMode(true);
  ui.tabBar->setTabsClosable(true);
  ui.tabBar->setElideMode(Qt::ElideRight);
  ui.tabBar->setExpanding(false);
  connect(ui.tabBar, SIGNAL(currentChanged(int)), SLOT(onTabBarCurrentChanged(int)));
  connect(ui.tabBar, SIGNAL(tabCloseRequested(int)), SLOT(onTabBarCloseRequested(int)));
  connect(ui.stackedWidget, SIGNAL(widgetRemoved(int)), SLOT(onStackedWidgetWidgetRemoved(int)));

  // side pane
  ui.sidePane->setIconSize(QSize(settings.sidePaneIconSize(), settings.sidePaneIconSize()));
  ui.sidePane->setMode(Fm::SidePane::ModePlaces);
  connect(ui.sidePane, SIGNAL(chdirRequested(int, FmPath*)), SLOT(onSidePaneChdirRequested(int, FmPath*)));

  // path bar
  pathEntry = new Fm::PathEdit(this);
  connect(pathEntry, SIGNAL(returnPressed()), SLOT(onPathEntryReturnPressed()));
  ui.toolBar->insertWidget(ui.actionGo, pathEntry);

  // add filesystem info to status bar
  fsInfoLabel = new QLabel(ui.statusbar);
  ui.statusbar->addPermanentWidget(fsInfoLabel);

  // setup the splitter
  ui.splitter->setStretchFactor(1, 1); // only the right pane can be stretched
  QList<int> sizes;
  sizes.append(150);
  sizes.append(300);
  ui.splitter->setSizes(sizes);

  // load bookmark menu
  bookmarks = fm_bookmarks_dup();
  g_signal_connect(bookmarks, "changed", G_CALLBACK(onBookmarksChanged), this);
  loadBookmarksMenu();

  // Fix the menu groups which is not done by Qt designer
  // To my suprise, this was supported in Qt designer 3 :-(
  QActionGroup* group = new QActionGroup(ui.menu_View);
  group->setExclusive(true);
  group->addAction(ui.actionIconView);
  group->addAction(ui.actionCompactView);
  group->addAction(ui.actionThumbnailView);
  group->addAction(ui.actionDetailedList);

  group = new QActionGroup(ui.menuSorting);
  group->setExclusive(true);
  group->addAction(ui.actionByFileName);
  group->addAction(ui.actionByMTime);
  group->addAction(ui.actionByFileSize);
  group->addAction(ui.actionByFileType);
  group->addAction(ui.actionByOwner);

  group = new QActionGroup(ui.menuSorting);
  group->setExclusive(true);
  group->addAction(ui.actionAscending);
  group->addAction(ui.actionDescending);

  // create shortcuts
  QShortcut* shortcut = new QShortcut(Qt::CTRL + Qt::Key_L, this);
  connect(shortcut, SIGNAL(activated()), pathEntry, SLOT(setFocus()));
  shortcut = new QShortcut(Qt::ALT + Qt::Key_D, this);
  connect(shortcut, SIGNAL(activated()), pathEntry, SLOT(setFocus()));

  shortcut = new QShortcut(Qt::CTRL + Qt::Key_Tab, this);
  connect(shortcut, SIGNAL(activated()), SLOT(onShortcutNextTab()));
  shortcut = new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab, this);
  connect(shortcut, SIGNAL(activated()), SLOT(onShortcutPrevTab()));

  int i;
  for(i = 0; i < 10; ++i) {
    shortcut = new QShortcut(QKeySequence(Qt::ALT + Qt::Key_0 + i), this);
    connect(shortcut, SIGNAL(activated()), SLOT(onShortcutJumpToTab()));
    shortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_0 + i), this);
    connect(shortcut, SIGNAL(activated()), SLOT(onShortcutJumpToTab()));
  }

  if(path)
    addTab(path);
}