SettingDialog::SettingDialog(QWidget *parent):
    QDialog(parent)
//    , m_settingLayout(new QVBoxLayout(this))
//    , m_stackedWidget(new QStackedWidget)
//    , m_okBtn(new QPushButton(this))
{
    this->setWindowFlags(Qt::FramelessWindowHint);
    this->setFixedSize(479, 421);
    this->setFocusPolicy(Qt::ClickFocus);
    this->setWindowTitle(tr("Kylin Weather - Setting"));
    this->setWindowIcon(QIcon(":/res/indicator-china-weather.png"));
    //Why????? setStyleSheet将导致添加城市后,列表没有自动拉伸,出现重叠,但是qDebug打印的高度确实增加了,但是使用paintEvent可以
    //this->setStyleSheet("QDialog{border:1px solid #000000;border-radius:2px;background:rgba(255, 255, 255, 0.7);}QDialog:hover{background: rgba(255, 255, 255, 1.0);}");


    initSettings();
    initSearch();

    QStackedLayout *contentLayout = new QStackedLayout(this);
    contentLayout->setContentsMargins(20, 20, 20, 20);
    contentLayout->setMargin(0);
    contentLayout->setSpacing(0);
    contentLayout->addWidget(m_settingFrame);
    contentLayout->addWidget(m_searchFrame);
    m_settingFrame->setVisible(true);
}
Exemplo n.º 2
0
Speed::Speed(QWidget *parent): QWidget(parent)
{
	QHBoxLayout *layout = new QHBoxLayout();
	layout->setSpacing(0);
	layout->setMargin(0);
	
	setStyleSheet("padding: 0;");
	
		QVBoxLayout *contentLayout = new QVBoxLayout();
		contentLayout->setSpacing(2);
		contentLayout->setMargin(0);
		contentLayout->setContentsMargins(0, 2, 0, 0);
		
		QWidget *content = new QWidget();
		content->setLayout(contentLayout);
		content->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum);
			
			QStackedLayout *speedometerLayout = new QStackedLayout(contentLayout);
			speedometerLayout->setSpacing(2);
			speedometerLayout->setMargin(0);
			speedometerLayout->setContentsMargins(0, 2, 0, 0);
			speedometerLayout->setStackingMode(QStackedLayout::StackAll);
			
			speedometerNeedle = new RotatableImageView(":/resources/speedometer-needle_160x160.png");
			speedometerNeedle->rotate(-129);
			speedometerLayout->addWidget(speedometerNeedle);
			
			QLabel *speedometer = new QLabel();
			speedometer->setPixmap(QPixmap(":/resources/speedometer_160x160.png"));
			speedometer->setMargin(2);
			speedometerLayout->addWidget(speedometer);
			
			speedometerLabel = new QLabel("N/A");
			speedometerLabel->setAlignment(Qt::AlignCenter);
			speedometerLabel->setStyleSheet("font: 13pt; font-weight: bold;");
			contentLayout->addWidget(speedometerLabel);
		
		TitledBox *box = new TitledBox(tr("Speed"), content);
		layout->addWidget(box);
		
	QGraphicsDropShadowEffect *dropShadow = new QGraphicsDropShadowEffect();
	dropShadow->setBlurRadius(6);
	dropShadow->setColor(QColor(0, 0, 0));
	dropShadow->setOffset(0, 0);
	
	setGraphicsEffect(dropShadow);
	
	setLayout(layout);
}
WeatherPlugin::WeatherPlugin(QObject *parent)
    : QObject(parent),
      m_view(new QFrame),
      m_requestManager(new WeatherRequest(this))
{
    WeatherWidget *weatherWidget = new WeatherWidget(m_requestManager);
    SetLocationPage *locationPage = new SetLocationPage(m_requestManager);

    QStackedLayout *layout = new QStackedLayout;
    layout->setSpacing(0);
    layout->setMargin(0);

    layout->addWidget(weatherWidget);
    layout->addWidget(locationPage);

    m_view->setLayout(layout);
    m_view->setObjectName("WeatherView");
    m_view->setStyleSheet("#WeatherView {"
                          "background-color: rgba(255, 255, 255, .03);"
                          "}");

    connect(weatherWidget, &WeatherWidget::locationButtonClicked, this, [this, layout, locationPage] {
        locationPage->reset();
        locationPage->setCurrentCity(m_requestManager->city());
        layout->setCurrentWidget(locationPage);
    });

    connect(locationPage, &SetLocationPage::citySet, this, [this, layout, weatherWidget] (const QString &preferredService, const City &city) {
        qDebug() << "set city to " << city.localizedName;
        QList<WeatherItem> empty;
        weatherWidget->refreshView(empty);
        m_requestManager->setPreferredWeatherService(preferredService);
        m_requestManager->setCity(city);
        layout->setCurrentWidget(weatherWidget);
    });

    connect(locationPage, &SetLocationPage::cancelled, this, [=] {
        qDebug() << "cancelled setting city" ;
        layout->setCurrentWidget(weatherWidget);
    });
}
Exemplo n.º 4
0
NewFileDialog::NewFileDialog(QWidget *parent):QDialog(parent)
{

  this->setupUi(this);
  this->createButton->setDisabled(true);
  connect(this->browse,SIGNAL(clicked()),SLOT(browseFile()));
  connect(this->filepath,SIGNAL(textChanged(QString)),SLOT(setButtonStatus()));
  this->filetypes->addItem(QString("Client-Side Files"));
  this->filetypes->addItem(QString("Server-Side Files"));
  this->filetypes->setCurrentRow(0);

  //the client side widgets);
  this->clientside = new QWidget(this);
  QHBoxLayout *clientsidelayout = new QHBoxLayout(this->clientside);
  this->clientside->setLayout(clientsidelayout);
  clientsidelayout->setMargin(0);
  this->clientSideFileTypes = new QListWidget(this);
  this->clientSideFileTypes->addItem(tr("HTML File"));
  this->clientSideFileTypes->addItem(tr("CSS File"));
  this->clientSideFileTypes->addItem(tr("Javascript File"));
  this->clientSideFileTypes->addItem(tr("Adobe Flex MXML File"));
  this->clientSideFileTypes->setCurrentRow(0);

  this->clientsidedetail = new QWidget(this);
  QStackedLayout *clientsidedetaillayout = new QStackedLayout(this->clientsidedetail);
  this->clientsidedetail->setLayout(clientsidedetaillayout);
  clientsidedetaillayout->setMargin(0);

  QListWidget *htmlTemplates = new QListWidget(this);
  htmlTemplates->addItem(tr("Plain HTML File"));
  htmlTemplates->setCurrentRow(0);

  QListWidget *cssTemplates = new QListWidget(this);
  cssTemplates->addItem(tr("Plain CSS File"));
  cssTemplates->setCurrentRow(0);

  QListWidget *jsTemplates = new QListWidget(this);
  jsTemplates->addItem(tr("Plain JS File"));
  jsTemplates->setCurrentRow(0);

  QListWidget *mxmlTemplates = new QListWidget(this);
  mxmlTemplates->addItem(tr("Plain MXML File"));
  mxmlTemplates->setCurrentRow(0);

  clientsidedetaillayout->addWidget(htmlTemplates);
  clientsidedetaillayout->addWidget(cssTemplates);
  clientsidedetaillayout->addWidget(jsTemplates);
  clientsidedetaillayout->addWidget(mxmlTemplates);
  connect(this->clientSideFileTypes,SIGNAL(currentRowChanged(int)),clientsidedetaillayout,SLOT(setCurrentIndex(int)));


  clientsidelayout->addWidget(this->clientSideFileTypes);
  clientsidelayout->addWidget(this->clientsidedetail);

  this->serverSideFileTypes = new QListWidget(this);
  this->serverSideFileTypes->addItem(tr("PHP File"));
  this->serverSideFileTypes->setCurrentRow(0);
  //this->serverSideFileTypes->addItem(tr("Python File"));

  this->detailLayout = new QStackedLayout();
  detailLayout->setMargin(0);
  this->detail->setLayout(this->detailLayout);
  detailLayout->addWidget(this->clientside);
  detailLayout->addWidget(this->serverSideFileTypes);

  connect(this->filetypes,SIGNAL(currentRowChanged(int)),this->detailLayout,SLOT(setCurrentIndex(int)));


}