Пример #1
1
QComboBox* FilterButton::createComboBox(const QStringList& options, const QString& currentOption)
{
	// Stylesheet
	QFile stylefile(":/qss/filterbutton.qss"); stylefile.open(QFile::ReadOnly);
	QString stylesheet(stylefile.readAll());

	filtersComboBox = new QComboBox;

	QListView * listView = new QListView(filtersComboBox);
	filtersComboBox->addItems(options);
	listView->setStyleSheet(stylesheet);


	filtersComboBox->setView(listView);
	filtersComboBox->setStyleSheet(stylesheet);

	// Filter
	filtersComboBox->setCurrentIndex(options.indexOf(currentOption));

	// Connect the combobox's signal to our own
	connect(filtersComboBox, SIGNAL(currentIndexChanged(const QString&)),
			this, SIGNAL(selectionChanged(const QString&)));

	return filtersComboBox;
}
Пример #2
0
DComboBox::DComboBox(QWidget *parent) :
    QComboBox(parent)
{
    QString style = ""
            "QComboBox {"
                "color:#b4b4b4;"
                "font-size: 14px;"
                "border: 0px solid gray;"
                "border-radius: 3px;"
                "padding: 1px 18px 1px 3px;"
                "min-width: 6em;"
            "}"
            "QComboBox:editable {"
                "background: #232323;"
            "}"
            "QComboBox:!editable, QComboBox::drop-down:editable {"
                "border-image:url(:/ui/images/button_normal.png);"
            "}"
            "/* QComboBox gets the \"on\" state when the popup is open */"
            "QComboBox:!editable:on, QComboBox::drop-down:editable:on {"
                "border-image:url(:/ui/images/button_normal.png);"
            "}"
            "QComboBox:on { /* shift the text when the popup opens */"
                "padding-top: 3px;"
                "padding-left: 4px;"
            "}"
            "QComboBox::drop-down {"
                "subcontrol-origin: padding;"
                "subcontrol-position: top right;"
                "width: 20px;"
                "border-width: 0px;"
                "border-top-right-radius: 3px; /* same radius as the QComboBox */"
                "border-bottom-right-radius: 3px;"
            "}"
            "QComboBox::down-arrow {"
                "image: url(:/ui/images/arrow_down_normal.png);"
            "}"
            "QComboBox::down-arrow:hover {"
                "image: url(:/ui/images/arrow_down_hover.png);"
            "}"
            "QComboBox::down-arrow:on { /* shift the arrow when popup is open */"
                "top: 1px;"
                "left: 1px;"
            "}";
    setStyleSheet(style);

    QListView * listView = new QListView(this);
    style = ""
    "QListView {"
        "color:#b4b4b4;"
        "font-size: 14px;"
        "border: 1px solid #232323;;"
        "alternate-background-color: #232323;"
        "show-decoration-selected: 1;"
        "background: #232323;"
    "}"
    "QListView::item {"
        "border: 0px solid gray;"
        "background: #232323;"
    "}"
    "QListView::item:alternate {"
        "border: 0px solid gray;"
        "background: #232323;"
    "}"
    "QListView::item:selected {"
        "background: #232323;"
        "border: 0px solid #6a6ea9;"
    "}"
    "QListView::item:selected:!active {"
        "border: 0px solid gray;"
        "background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
                                    "stop: 0 black, stop: 1 #232323);"
    "}"
    "QListView::item:selected:active {"
        "border: 0px solid gray;"
        "background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
                                    "stop: 0 black, stop: 1 #232323);"
    "}"
    "QListView::item:hover {"
        "border: 0px solid gray;"
        "background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
                                    "stop: 0 black, stop: 1 #232323);"
    "}";
    listView->setStyleSheet(style);

    this->setView(listView);
}
Пример #3
0
QgsWelcomePage::QgsWelcomePage( QWidget* parent )
    : QTabWidget( parent )
{
  QVBoxLayout* mainLayout = new QVBoxLayout;
  mainLayout->setMargin( 0 );
  setLayout( mainLayout );

  QHBoxLayout* layout = new QHBoxLayout();
  layout->setMargin( 9 );

  mainLayout->addLayout( layout );

  QWidget* recentProjctsContainer = new QWidget;
  recentProjctsContainer->setLayout( new QVBoxLayout );
  QLabel* recentProjectsTitle = new QLabel( QString( "<h1>%1</h1>" ).arg( tr( "Recent Projects" ) ) );
  recentProjctsContainer->layout()->addWidget( recentProjectsTitle );

  QListView* recentProjectsListView = new QListView();
  mModel = new QgsWelcomePageItemsModel( recentProjectsListView );
  recentProjectsListView->setModel( mModel );
  recentProjectsListView->setStyleSheet( "QListView::item {"
                                         "  margin-top: 5px;"
                                         "  margin-bottom: 5px;"
                                         "  margin-left: 15px;"
                                         "  margin-right: 15px;"
                                         "  border-width: 1px;"
                                         "  border-color: #999;"
                                         "  border-radius: 9px;"
                                         "  background: #eee;"
                                         "  padding: 10px;"
                                         "}"
                                         "QListView::item:selected:active {"
                                         "  background: #aaaaaa;"
                                         "}" );

  recentProjctsContainer->layout()->addWidget( recentProjectsListView );

  addTab( recentProjctsContainer, "Recent Projects" );

  QWidget* whatsNewContainer = new QWidget;
  whatsNewContainer->setLayout( new QVBoxLayout );
  QLabel* whatsNewTitle = new QLabel( QString( "<h1>%1</h1>" ).arg( tr( "QGIS News" ) ) );
  whatsNewContainer->layout()->addWidget( whatsNewTitle );

  QgsWebView* whatsNewPage = new QgsWebView();
  whatsNewPage->setUrl( QUrl::fromLocalFile( QgsApplication::whatsNewFilePath() ) );
  whatsNewPage->page()->setLinkDelegationPolicy( QWebPage::DelegateAllLinks );
  whatsNewPage->setContextMenuPolicy( Qt::NoContextMenu );
  whatsNewPage->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
  whatsNewPage->setStyleSheet( "background:transparent" );
  whatsNewPage->setAttribute( Qt::WA_TranslucentBackground );

  whatsNewContainer->layout()->addWidget( whatsNewPage );
//  whatsNewContainer->setMaximumWidth( 250 );
//  whatsNewContainer->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
  addTab( whatsNewContainer, "News" );

  connect( whatsNewPage, SIGNAL( linkClicked( QUrl ) ), this, SLOT( whatsNewLinkClicked( QUrl ) ) );

  mVersionInformation = new QLabel;
  mainLayout->addWidget( mVersionInformation );
  mVersionInformation->setVisible( false );

  mVersionInfo = new QgsVersionInfo();
  connect( mVersionInfo, SIGNAL( versionInfoAvailable() ), this, SLOT( versionInfoReceived() ) );
  mVersionInfo->checkVersion();

  connect( recentProjectsListView, SIGNAL( activated( QModelIndex ) ), this, SLOT( itemActivated( QModelIndex ) ) );
}